basalt-ui 2.28.0 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +461 -401
- package/MIGRATING.md +202 -12
- package/agent/skills/basalt-app/SKILL.md +3 -3
- package/agent/skills/basalt-charts/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +11 -5
- package/agent/skills/basalt-design/references/catalogue.md +3 -1
- package/agent/skills/basalt-design/references/recipes.md +1 -1
- package/agent/skills/basalt-design/references/states.md +1 -1
- package/configs/oxlint-plugin.js +2 -1
- package/configs/oxlint.json +1 -0
- package/dist/charts/ChartCard.d.ts +9 -5
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +68 -12
- package/dist/charts/Sparkline.d.ts +5 -0
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +53 -5
- package/dist/charts/chart-box.module.css +9 -2
- package/dist/charts/chart-card.module.css +16 -13
- package/dist/charts/chart-card.module.css.d.ts +2 -0
- package/dist/charts/compile.d.ts +1 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +18 -9
- package/dist/charts/ref-label.d.ts +6 -0
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +19 -5
- package/dist/charts/sparkline.module.css +44 -0
- package/dist/charts/sparkline.module.css.d.ts +3 -0
- package/dist/charts/state.d.ts +1 -1
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +3 -3
- package/dist/cli/doctor-upgrade.d.ts +11 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +54 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +8 -3
- package/dist/cli/index.d.ts +13 -13
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +36 -2
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +118 -27
- package/dist/cli/router-wiring.d.ts +3 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +2 -0
- package/dist/cli/shot/capture.d.ts +28 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +77 -7
- package/dist/cli/shot/detect.d.ts +4 -1
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +38 -16
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +9 -2
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +11 -2
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +10 -2
- package/dist/common/could-not-load.d.ts +13 -0
- package/dist/common/could-not-load.d.ts.map +1 -0
- package/dist/common/could-not-load.js +14 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +3 -0
- package/dist/common/props.d.ts +20 -0
- package/dist/common/props.d.ts.map +1 -1
- package/dist/common/props.js +13 -1
- package/dist/common/retry-button.module.css +7 -3
- package/dist/dashboard/bar-list.d.ts +4 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +10 -7
- package/dist/dashboard/bar-list.module.css +21 -3
- package/dist/dashboard/board.d.ts +2 -2
- package/dist/dashboard/board.d.ts.map +1 -1
- package/dist/dashboard/board.js +31 -12
- package/dist/dashboard/board.module.css +19 -0
- package/dist/dashboard/board.module.css.d.ts +2 -0
- package/dist/dashboard/empty-state.d.ts +3 -3
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +4 -2
- package/dist/dashboard/event-list-model.d.ts +3 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -1
- package/dist/dashboard/event-list-model.js +5 -1
- package/dist/dashboard/event-list-rows.d.ts.map +1 -1
- package/dist/dashboard/event-list-rows.js +2 -6
- package/dist/dashboard/event-list-scroll.d.ts +32 -4
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -1
- package/dist/dashboard/event-list-scroll.js +117 -4
- package/dist/dashboard/event-list-skeleton.d.ts.map +1 -1
- package/dist/dashboard/event-list-skeleton.js +2 -4
- package/dist/dashboard/event-list.d.ts +4 -4
- package/dist/dashboard/event-list.d.ts.map +1 -1
- package/dist/dashboard/event-list.js +53 -23
- package/dist/dashboard/event-list.module.css +90 -37
- package/dist/dashboard/event-list.module.css.d.ts +1 -0
- package/dist/dashboard/meter-model.d.ts +6 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +9 -4
- package/dist/dashboard/meter-parts.d.ts +3 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +32 -4
- package/dist/dashboard/meter.d.ts +3 -3
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +10 -2
- package/dist/dashboard/meter.module.css +18 -11
- package/dist/dashboard/meter.module.css.d.ts +0 -1
- package/dist/dashboard/page-summary.d.ts +3 -3
- package/dist/dashboard/page-summary.d.ts.map +1 -1
- package/dist/dashboard/page-summary.js +7 -2
- package/dist/dashboard/page-summary.module.css +5 -2
- package/dist/dashboard/query-state.d.ts +9 -8
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +28 -10
- package/dist/dashboard/section.d.ts +11 -3
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +34 -7
- package/dist/dashboard/settings-section.d.ts +4 -4
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +11 -7
- package/dist/dashboard/settings-section.module.css +6 -0
- package/dist/dashboard/settings-section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card.d.ts +3 -3
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +24 -8
- package/dist/dashboard/stat-card.module.css +11 -0
- package/dist/dashboard/stat-group.d.ts +2 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +10 -3
- package/dist/dashboard/stat-strip.d.ts +5 -4
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +41 -31
- package/dist/dashboard/stat-strip.module.css +4 -5
- package/dist/dashboard/visual-slot.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +2 -0
- package/dist/dashboard/widget-header.d.ts +6 -6
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +4 -2
- package/dist/dashboard/widget-header.module.css +6 -25
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +24 -1
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -1
- package/dist/styles.css +23 -0
- package/dist/table/cell-kinds.d.ts +10 -7
- package/dist/table/cell-kinds.d.ts.map +1 -1
- package/dist/table/cell-kinds.js +18 -7
- package/dist/table/data-table-fold.d.ts +13 -5
- package/dist/table/data-table-fold.d.ts.map +1 -1
- package/dist/table/data-table-fold.js +48 -16
- package/dist/table/data-table.d.ts +2 -2
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +16 -9
- package/dist/table/data-table.module.css +74 -2
- package/dist/table/data-table.module.css.d.ts +4 -0
- package/dist/theme/controls.module.css +23 -2
- package/llms.txt +263 -2
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +98 -16
- package/src/charts/Sparkline.tsx +84 -5
- package/src/charts/chart-box.module.css +9 -2
- package/src/charts/chart-card.module.css +16 -13
- package/src/charts/chart-card.module.css.d.ts +2 -0
- package/src/charts/compile.ts +37 -15
- package/src/charts/ref-label.ts +36 -9
- package/src/charts/sparkline.module.css +44 -0
- package/src/charts/sparkline.module.css.d.ts +3 -0
- package/src/charts/state.tsx +4 -3
- package/src/cli/doctor-upgrade.ts +75 -0
- package/src/cli/doctor.ts +36 -0
- package/src/cli/help.ts +16 -6
- package/src/cli/index.ts +73 -67
- package/src/cli/init.ts +157 -36
- package/src/cli/router-wiring.ts +2 -2
- package/src/cli/shot/capture.ts +109 -10
- package/src/cli/shot/detect.ts +46 -22
- package/src/cli/shot/index.ts +8 -2
- package/src/cli/shot/measure.ts +11 -2
- package/src/cli/shot/types.ts +4 -1
- package/src/cli/sync.ts +12 -2
- package/src/common/could-not-load.ts +22 -0
- package/src/common/index.ts +1 -0
- package/src/common/props.ts +30 -0
- package/src/common/retry-button.module.css +7 -3
- package/src/dashboard/bar-list.module.css +21 -3
- package/src/dashboard/bar-list.tsx +46 -41
- package/src/dashboard/board.module.css +19 -0
- package/src/dashboard/board.module.css.d.ts +2 -0
- package/src/dashboard/board.tsx +69 -48
- package/src/dashboard/empty-state.tsx +5 -2
- package/src/dashboard/event-list-model.ts +13 -1
- package/src/dashboard/event-list-rows.tsx +3 -6
- package/src/dashboard/event-list-scroll.ts +154 -8
- package/src/dashboard/event-list-skeleton.tsx +5 -1
- package/src/dashboard/event-list.module.css +90 -37
- package/src/dashboard/event-list.module.css.d.ts +1 -0
- package/src/dashboard/event-list.tsx +92 -65
- package/src/dashboard/meter-model.ts +16 -7
- package/src/dashboard/meter-parts.tsx +45 -13
- package/src/dashboard/meter.module.css +18 -11
- package/src/dashboard/meter.module.css.d.ts +0 -1
- package/src/dashboard/meter.tsx +36 -18
- package/src/dashboard/page-summary.module.css +5 -2
- package/src/dashboard/page-summary.tsx +13 -6
- package/src/dashboard/query-state.tsx +54 -29
- package/src/dashboard/section.tsx +83 -41
- package/src/dashboard/settings-section.module.css +6 -0
- package/src/dashboard/settings-section.module.css.d.ts +1 -0
- package/src/dashboard/settings-section.tsx +11 -6
- package/src/dashboard/stat-card.module.css +11 -0
- package/src/dashboard/stat-card.tsx +31 -8
- package/src/dashboard/stat-group.tsx +22 -14
- package/src/dashboard/stat-strip.module.css +4 -5
- package/src/dashboard/stat-strip.tsx +29 -20
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +6 -25
- package/src/dashboard/widget-header.tsx +8 -5
- package/src/format/shared.ts +30 -1
- package/src/guard/index.ts +5 -1
- package/src/styles.css +23 -0
- package/src/table/cell-kinds.tsx +42 -13
- package/src/table/data-table-fold.tsx +65 -12
- package/src/table/data-table.module.css +74 -2
- package/src/table/data-table.module.css.d.ts +4 -0
- package/src/table/data-table.tsx +34 -13
- package/src/theme/controls.module.css +23 -2
package/dist/cli/init.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { deriveSpacing } from "../tokens/core.js";
|
|
4
4
|
import { shellConfigError } from "./config.js";
|
|
5
5
|
import {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
managedFiles,
|
|
13
13
|
mergeOxlintExtends,
|
|
14
14
|
normalizeForLedger,
|
|
15
|
+
OXLINT_IGNORE_FLAG,
|
|
15
16
|
patchPackageJson,
|
|
16
17
|
placementNotices,
|
|
17
18
|
pruneRetiredManagedFiles,
|
|
@@ -28,7 +29,14 @@ import {
|
|
|
28
29
|
writeUnit
|
|
29
30
|
} from "./index.js";
|
|
30
31
|
import { ROUTER_PLUGIN_FIX, seedTsconfigExtends } from "./doctor-upgrade.js";
|
|
31
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
appEntry,
|
|
34
|
+
registersRouterPlugin,
|
|
35
|
+
routeTreeDirs,
|
|
36
|
+
routerSeedDest,
|
|
37
|
+
VITE_CONFIGS
|
|
38
|
+
} from "./router-wiring.js";
|
|
39
|
+
import { readPackageJson, tokenize } from "./source-text.js";
|
|
32
40
|
import { readOxlintPresetPlugins } from "./sync.js";
|
|
33
41
|
const KEPT_FILE_COST = {
|
|
34
42
|
"lefthook.yml": "the pre-commit oxlint / oxfmt / check-theme jobs are not wired \u2014 add `extends: [<preset>]` to your own file.",
|
|
@@ -55,24 +63,88 @@ const STOCK_MAINS = [true, false].flatMap(
|
|
|
55
63
|
);
|
|
56
64
|
const isStockViteMain = (text) => STOCK_MAINS.includes(normalise(text));
|
|
57
65
|
const ALSO_REQUIRED_PEERS = ["motion"];
|
|
58
|
-
function
|
|
66
|
+
function requiredPeers(pkgRoot) {
|
|
59
67
|
const shipped = JSON.parse(readFileSync(resolve(pkgRoot, "package.json"), "utf8"));
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
return Object.fromEntries(
|
|
69
|
+
Object.entries(shipped.peerDependencies ?? {}).filter(
|
|
70
|
+
([name]) => shipped.peerDependenciesMeta?.[name]?.optional !== true || ALSO_REQUIRED_PEERS.includes(name)
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function declaredNames(cwd) {
|
|
75
|
+
const app = readPackageJson(cwd) ?? {};
|
|
76
|
+
return new Set(
|
|
62
77
|
["dependencies", "devDependencies", "peerDependencies"].flatMap(
|
|
63
78
|
(k) => Object.keys(app[k] ?? {})
|
|
64
79
|
)
|
|
65
80
|
);
|
|
81
|
+
}
|
|
82
|
+
function missingPeers(cwd, pkgRoot) {
|
|
83
|
+
const declared = declaredNames(cwd);
|
|
66
84
|
return Object.fromEntries(
|
|
67
|
-
Object.entries(
|
|
68
|
-
|
|
69
|
-
|
|
85
|
+
Object.entries(requiredPeers(pkgRoot)).filter(([name]) => !declared.has(name))
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const ROUTER_PLUGIN_IMPORT = "import { tanstackRouter } from '@tanstack/router-plugin/vite'";
|
|
89
|
+
const ROUTER_PLUGIN_RANGE = "^1.168.40";
|
|
90
|
+
function viteConfigOf(dir) {
|
|
91
|
+
const file = VITE_CONFIGS.map((f) => resolve(dir, f)).find((abs) => existsSync(abs));
|
|
92
|
+
return file === void 0 ? void 0 : { file, text: readFileSync(file, "utf8") };
|
|
93
|
+
}
|
|
94
|
+
function withRouterPlugin(text) {
|
|
95
|
+
if ((text.match(/\bplugins\s*:\s*\[/g) ?? []).length !== 1) return null;
|
|
96
|
+
const wired = text.replace(
|
|
97
|
+
/(\bplugins\s*:\s*\[\s*)(react\()/,
|
|
98
|
+
"$1tanstackRouter({ target: 'react', autoCodeSplitting: true }), $2"
|
|
70
99
|
);
|
|
100
|
+
if (wired === text) return null;
|
|
101
|
+
const imported = /\bimport\s*(?:type\s*)?\{[^}]*\btanstackRouter\b[^}]*\}\s*from\s*['"]@tanstack\/router-plugin\/vite['"]/;
|
|
102
|
+
return imported.test(tokenize(text).code) ? wired : `${ROUTER_PLUGIN_IMPORT}
|
|
103
|
+
${wired}`;
|
|
104
|
+
}
|
|
105
|
+
function isInstalled(dir, name) {
|
|
106
|
+
for (let d = dir; ; d = dirname(d)) {
|
|
107
|
+
if (existsSync(resolve(d, "node_modules", name, "package.json"))) return true;
|
|
108
|
+
if (dirname(d) === d) return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function packageManager(dir) {
|
|
112
|
+
for (let d = dir; ; d = dirname(d)) {
|
|
113
|
+
const has = (f) => existsSync(resolve(d, f));
|
|
114
|
+
if (has("pnpm-lock.yaml"))
|
|
115
|
+
return { install: ["pnpm", "install"], vite: ["pnpm", "exec", "vite"] };
|
|
116
|
+
if (has("yarn.lock")) return { install: ["yarn", "install"], vite: ["yarn", "vite"] };
|
|
117
|
+
if (has("package-lock.json")) return { install: ["npm", "install"], vite: ["npx", "vite"] };
|
|
118
|
+
if (has("bun.lock") || has("bun.lockb") || dirname(d) === d)
|
|
119
|
+
return { install: ["bun", "install"], vite: ["bunx", "vite"] };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function finishInstall(dir, pkgRoot, run) {
|
|
123
|
+
const plugin = registersRouterPlugin(viteConfigOf(dir)?.text ?? "");
|
|
124
|
+
const declared = declaredNames(dir);
|
|
125
|
+
const names = ["@tanstack/router-plugin", ...Object.keys(requiredPeers(pkgRoot))];
|
|
126
|
+
const needsInstall = names.some((n) => declared.has(n) && !isInstalled(dir, n));
|
|
127
|
+
const hasTree = () => !plugin || routeTreeDirs(appEntry(dir)).some((d) => existsSync(resolve(dir, d, "routeTree.gen.ts")));
|
|
128
|
+
if (!needsInstall && hasTree()) return [];
|
|
129
|
+
const pm = packageManager(dir);
|
|
130
|
+
const [install, build] = [pm.install.join(" "), [...pm.vite, "build"].join(" ")];
|
|
131
|
+
const out = [];
|
|
132
|
+
if (needsInstall) {
|
|
133
|
+
if (run?.(pm.install, dir) !== true) {
|
|
134
|
+
return [
|
|
135
|
+
`run \`${install}\` (init did not)${plugin ? `, then \`${build}\` once to generate routeTree.gen.ts` : ""}.`
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
out.push(`ran \`${install}\`.`);
|
|
139
|
+
}
|
|
140
|
+
if (!hasTree()) {
|
|
141
|
+
run?.([...pm.vite, "build"], dir);
|
|
142
|
+
out.push(
|
|
143
|
+
hasTree() ? `ran \`${build}\` (generated routeTree.gen.ts).` : `run \`${build}\` once to generate routeTree.gen.ts (init did not).`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
71
147
|
}
|
|
72
|
-
const hasRouterPlugin = (cwd) => ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"].some((f) => {
|
|
73
|
-
const abs = resolve(cwd, f);
|
|
74
|
-
return existsSync(abs) && readFileSync(abs, "utf8").includes("@tanstack/router-plugin");
|
|
75
|
-
});
|
|
76
148
|
function oxlintrcCost(merge) {
|
|
77
149
|
if (merge === "added" || merge === "already") {
|
|
78
150
|
return "now extends the shipped preset: the basalt/* design rules and the jsx-a11y / import / promise / unicorn plugins are on.";
|
|
@@ -104,7 +176,7 @@ function init(cwd = process.cwd(), scaffoldFlags = {}) {
|
|
|
104
176
|
ruleRootsFor(rootsState) ?? (rootsState.kind === "undetectable" ? [`${appSrc ? `${appSrc}/` : ""}src`] : void 0),
|
|
105
177
|
scaffoldFlags.pkgRoot
|
|
106
178
|
);
|
|
107
|
-
const lintScript = `oxlint . && ${ctx.vars.BASALT_BIN} check-theme`;
|
|
179
|
+
const lintScript = `oxlint ${OXLINT_IGNORE_FLAG} . && ${ctx.vars.BASALT_BIN} check-theme`;
|
|
108
180
|
const seededLintScript = patchPackageJson(cwd, (pkg) => {
|
|
109
181
|
const scripts = pkg["scripts"] ?? {};
|
|
110
182
|
if (scripts["lint:basalt"] !== void 0) return false;
|
|
@@ -138,6 +210,31 @@ function init(cwd = process.cwd(), scaffoldFlags = {}) {
|
|
|
138
210
|
const mainDest = routerSeedDest(placement.appRel, "main");
|
|
139
211
|
const mainPath = resolve(cwd, mainDest);
|
|
140
212
|
const stockMain = !skippedSeeds.has(mainDest) && existsSync(mainPath) && isStockViteMain(readFileSync(mainPath, "utf8"));
|
|
213
|
+
const advice = [];
|
|
214
|
+
const appDir = resolve(cwd, placement.appRel);
|
|
215
|
+
if (stockMain) {
|
|
216
|
+
const missing = missingPeers(cwd, ctx.pkgRoot);
|
|
217
|
+
const count = Object.keys(missing).length;
|
|
218
|
+
const vite = viteConfigOf(appDir);
|
|
219
|
+
const wired = vite !== void 0 && !registersRouterPlugin(vite.text) ? withRouterPlugin(vite.text) : null;
|
|
220
|
+
patchPackageJson(cwd, (pkg) => {
|
|
221
|
+
pkg["dependencies"] = { ...pkg["dependencies"], ...missing };
|
|
222
|
+
if (wired !== null) {
|
|
223
|
+
pkg["devDependencies"] = {
|
|
224
|
+
"@tanstack/router-plugin": ROUTER_PLUGIN_RANGE,
|
|
225
|
+
...pkg["devDependencies"]
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return count > 0 || wired !== null;
|
|
229
|
+
});
|
|
230
|
+
if (count > 0) advice.push(`added ${count} missing peers to package.json.`);
|
|
231
|
+
if (wired !== null && vite !== void 0) {
|
|
232
|
+
writeFileSync(vite.file, wired, "utf8");
|
|
233
|
+
advice.push("wired the TanStack router plugin into vite.config (before react()).");
|
|
234
|
+
} else if (!registersRouterPlugin(vite?.text ?? "")) {
|
|
235
|
+
advice.push(ROUTER_PLUGIN_FIX.replace(/^Fix: /, "router plugin: "));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
141
238
|
const writtenFiles = [];
|
|
142
239
|
const keptFiles = [];
|
|
143
240
|
const missingSources = [];
|
|
@@ -160,24 +257,17 @@ function init(cwd = process.cwd(), scaffoldFlags = {}) {
|
|
|
160
257
|
const pruned = pruneRetiredManagedFiles(cwd, manifest, files);
|
|
161
258
|
const mergeLint = scaffoldFlags.noMergeLint === true ? null : mergeOxlintExtends(cwd, ctx.vars.OXLINT_PRESET_PATH);
|
|
162
259
|
const keptUnwired = keptFiles.includes(mainDest) && !/from ['"]basalt-ui['"/]/.test(readFileSync(mainPath, "utf8"));
|
|
163
|
-
|
|
164
|
-
if (stockMain || keptUnwired) {
|
|
260
|
+
if (keptUnwired) {
|
|
165
261
|
const missing = missingPeers(cwd, ctx.pkgRoot);
|
|
166
|
-
|
|
167
|
-
if (count > 0 && stockMain) {
|
|
168
|
-
patchPackageJson(cwd, (pkg) => {
|
|
169
|
-
pkg["dependencies"] = { ...pkg["dependencies"], ...missing };
|
|
170
|
-
return true;
|
|
171
|
-
});
|
|
172
|
-
advice.push(
|
|
173
|
-
`added ${count} missing peers to package.json; run \`bun install\` (init does not).`
|
|
174
|
-
);
|
|
175
|
-
} else if (count > 0) {
|
|
262
|
+
if (Object.keys(missing).length > 0) {
|
|
176
263
|
const specs = Object.entries(missing).map(([name, range]) => `${name}@${range}`);
|
|
177
264
|
advice.push(`missing peers: \`bun add ${specs.join(" ")}\`.`);
|
|
178
265
|
}
|
|
179
|
-
if (!
|
|
266
|
+
if (!registersRouterPlugin(viteConfigOf(appDir)?.text ?? "")) {
|
|
267
|
+
advice.push(ROUTER_PLUGIN_FIX.replace(/^Fix: /, "router plugin: "));
|
|
268
|
+
}
|
|
180
269
|
}
|
|
270
|
+
advice.push(...finishInstall(appDir, ctx.pkgRoot, scaffoldFlags.run));
|
|
181
271
|
manifest.basaltVersion = ctx.vars.BASALT_VERSION;
|
|
182
272
|
manifest.spacingScale = { ...deriveSpacing(0).scale };
|
|
183
273
|
writeFileEnsuringDir(resolve(cwd, MANIFEST_PATH), `${JSON.stringify(manifest, null, 2)}
|
|
@@ -253,6 +343,7 @@ First run: run \`${ctx.vars.BASALT_BIN} check-theme\` next (or \`bun run lint:ba
|
|
|
253
343
|
return 0;
|
|
254
344
|
}
|
|
255
345
|
export {
|
|
346
|
+
ROUTER_PLUGIN_RANGE,
|
|
256
347
|
init,
|
|
257
348
|
isStockViteMain
|
|
258
349
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { tokenize } from './source-text.js';
|
|
2
|
+
export declare const VITE_CONFIGS: string[];
|
|
3
|
+
/** True when `src` calls a binding imported from `@tanstack/router-plugin` after its `plugins` key (a textual proxy for "inside the array"). */
|
|
4
|
+
export declare function registersRouterPlugin(src: string): boolean;
|
|
2
5
|
/** The module `index.html` loads for the app at `dir` (default src/main.tsx), relative to `dir`. */
|
|
3
6
|
export declare function appEntry(dir: string): string;
|
|
4
7
|
type Tokens = ReturnType<typeof tokenize>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-wiring.d.ts","sourceRoot":"","sources":["../../src/cli/router-wiring.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"router-wiring.d.ts","sourceRoot":"","sources":["../../src/cli/router-wiring.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,QAAQ,EAAE,MAAM,eAAe,CAAA;AAKrE,eAAO,MAAM,YA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AAED,eAAO,MAAM,eAAe,mHACiF,CAAA;AAE7G,0GAA0G;AAC1G,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAA;AAEV,qGAAqG;AACrG,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,iBAAiB,GAAG,MAAM,CAE3F;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAIxD;AAED,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,wGACuE,CAAA"}
|
|
@@ -122,6 +122,7 @@ export {
|
|
|
122
122
|
ROUTER_SEED_DESTS,
|
|
123
123
|
SHELL_LESS_NOTE,
|
|
124
124
|
START_PROVIDER_HINT,
|
|
125
|
+
VITE_CONFIGS,
|
|
125
126
|
appEntry,
|
|
126
127
|
callOf,
|
|
127
128
|
callsIn,
|
|
@@ -129,6 +130,7 @@ export {
|
|
|
129
130
|
hasRouter,
|
|
130
131
|
isCodeRoutedApp,
|
|
131
132
|
isStartApp,
|
|
133
|
+
registersRouterPlugin,
|
|
132
134
|
routeTreeDirs,
|
|
133
135
|
routerSeedDest,
|
|
134
136
|
routerSeedDests,
|
|
@@ -22,10 +22,14 @@ export type CaptureInput = {
|
|
|
22
22
|
type PageFacts = {
|
|
23
23
|
anchors: string[];
|
|
24
24
|
declared: string[];
|
|
25
|
+
/** Anchors that carry `data-shot-states` themselves (on, inside or above the anchor element). Absent in a hand-built fact: the page's `declared` stands for every anchor. */
|
|
26
|
+
declaring?: string[];
|
|
25
27
|
/** Anchors that hold a basalt state surface (ChartCard, StatCard, a chart state). */
|
|
26
28
|
stateful?: string[];
|
|
27
29
|
/** Anchor → the URL states it declares itself absent in (`data-shot-absent="empty error"`). */
|
|
28
30
|
absent?: Record<string, string[]>;
|
|
31
|
+
/** The page's visible text, to tell whether every route rendered the same thing. */
|
|
32
|
+
content?: string;
|
|
29
33
|
};
|
|
30
34
|
/** Everything one page visit shares: where the records go and what was already measured. */
|
|
31
35
|
type Ctx = {
|
|
@@ -42,10 +46,12 @@ type Ctx = {
|
|
|
42
46
|
measured: Set<string>;
|
|
43
47
|
/** What the last visit showed to be wrong about the data itself: a failed seed, a 401/403, no API answer. */
|
|
44
48
|
problems: string[];
|
|
49
|
+
content?: string;
|
|
45
50
|
/** Read on the first page of a context that loads. */
|
|
46
51
|
scale?: Steps | undefined;
|
|
47
52
|
scaleError?: string | undefined;
|
|
48
53
|
};
|
|
54
|
+
export declare const SAME_CONTENT_WARNING = "[shot] warning: every route rendered the same content \u2014 a lock screen or auth wall? see --api";
|
|
49
55
|
/** `<route>-<hash>__<name>-<hash>__…`: the hash of the RAW text keeps `/a/b` and `/a-b` apart. */
|
|
50
56
|
export declare const fileName: (route: string, name: string, scheme: Scheme, viewport: Viewport, state: ShotState) => string;
|
|
51
57
|
/** The state URL: the query goes before any `#fragment`. */
|
|
@@ -54,7 +60,11 @@ export declare function withParam(route: string, state: ShotState): string;
|
|
|
54
60
|
export declare function unionClip(boxes: readonly Box[], margin: number, viewport: Viewport, tall?: number): Box | null;
|
|
55
61
|
/** A clip of `targets` re-measured against the live page height (`c.height` goes stale after a reflow); an empty clip is retried once after a frame, then fails. */
|
|
56
62
|
export declare function snapClip(c: Ctx, path: string, targets: readonly PwLocator[]): Promise<void>;
|
|
57
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Runs in the page: numbers every Card, Paper and table in DOM order, tagging those over 120×60 px as
|
|
65
|
+
* anchors. A page with none of them (Tailwind, a reader) falls back to `main`, `section`, `header`
|
|
66
|
+
* and `form` under the same floor.
|
|
67
|
+
*/
|
|
58
68
|
export declare function tagAutoAnchors(): void;
|
|
59
69
|
/**
|
|
60
70
|
* Runs in the page: why the anchor paints nothing (`display: none` on it or an ancestor, hidden,
|
|
@@ -85,6 +95,23 @@ export declare function hiddenScrollPx(): number;
|
|
|
85
95
|
* a tooltip another component already holds open is never taken for the one a trigger opens.
|
|
86
96
|
*/
|
|
87
97
|
export declare function markVisibleTooltips(): void;
|
|
98
|
+
/** Runs in the page: how many tooltips are rendered now (the readouts a hover leaves behind while they animate out). */
|
|
99
|
+
export declare function visibleTooltipCount(): number;
|
|
100
|
+
/**
|
|
101
|
+
* Moves the pointer off the previous anchor and waits for its tooltip to unmount, so a hover crop
|
|
102
|
+
* (a union box over the anchor and its tooltip) never holds a fragment of the component above.
|
|
103
|
+
* Bounded: a tooltip that stays (pinned by the app) is left to `markVisibleTooltips`.
|
|
104
|
+
*/
|
|
105
|
+
export declare function clearStrayTooltips(page: PwPage): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Runs in the page, on the tooltip a hover opened: hides every other visible one (another anchor's
|
|
108
|
+
* readout still fading or pinned) so the crop holds none, and marks what it hid.
|
|
109
|
+
*/
|
|
110
|
+
export declare function muteOtherTooltips(open: Element): void;
|
|
111
|
+
/** Runs in the page, for a trigger with no `aria-describedby`: marks the tooltips outside it as seen, so an earlier chart's stale readout never wins `.first()`. */
|
|
112
|
+
export declare function claimOwnTooltip(trigger: Element): void;
|
|
113
|
+
/** Runs in the page: puts back exactly what `muteOtherTooltips` marked. */
|
|
114
|
+
export declare function unmuteTooltips(): void;
|
|
88
115
|
/** Runs in the page: the first id a trigger names in `aria-describedby`, looking at it and its descendants. */
|
|
89
116
|
export declare function describedByOf(el: Element | null): string;
|
|
90
117
|
/** The tooltip the trigger names, else any that was not already visible at the snapshot. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/capture.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAGvC,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAe,MAAM,cAAc,CAAA;AAS7F,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,KAAK,EACL,MAAM,EACN,UAAU,EACV,SAAS,EAC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,CAAA;CACpB,CAAC,CA2DD"}
|
package/dist/cli/shot/capture.js
CHANGED
|
@@ -23,6 +23,7 @@ const TAB_PRESSES = 80;
|
|
|
23
23
|
const FOCUS_MARGIN_PX = 8;
|
|
24
24
|
const TIP_PROBE_MS = 250;
|
|
25
25
|
const TIP_SETTLE_MS = 60;
|
|
26
|
+
const TIP_CLEAR_MS = 1e3;
|
|
26
27
|
const TIP_SETTLE_READS = 10;
|
|
27
28
|
class NotDeclared extends Error {
|
|
28
29
|
}
|
|
@@ -36,6 +37,7 @@ function within(what, work, ms = STEP_TIMEOUT_MS) {
|
|
|
36
37
|
});
|
|
37
38
|
return Promise.race([work, late]).finally(() => clearTimeout(timer));
|
|
38
39
|
}
|
|
40
|
+
const SAME_CONTENT_WARNING = "[shot] warning: every route rendered the same content \u2014 a lock screen or auth wall? see --api";
|
|
39
41
|
const hash = (text) => createHash("sha1").update(text).digest("hex").slice(0, 6);
|
|
40
42
|
const slug = (text) => text.replace(/[^\w-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
41
43
|
const firstLine = (error) => (error instanceof Error ? error.message : String(error)).split("\n")[0] ?? "";
|
|
@@ -95,18 +97,26 @@ async function load(page, url, settle = 0) {
|
|
|
95
97
|
if (settle > 0) await new Promise((done) => setTimeout(done, settle));
|
|
96
98
|
}
|
|
97
99
|
function tagAutoAnchors() {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
const tag = (selector) => {
|
|
101
|
+
let tagged = 0;
|
|
102
|
+
Array.from(document.querySelectorAll(selector)).forEach((el, i) => {
|
|
103
|
+
const { width, height } = el.getBoundingClientRect();
|
|
104
|
+
if (width <= 120 || height <= 60) return;
|
|
102
105
|
el.setAttribute("data-shot", `auto-${String(i + 1).padStart(2, "0")}`);
|
|
103
|
-
|
|
106
|
+
tagged++;
|
|
107
|
+
});
|
|
108
|
+
return tagged;
|
|
109
|
+
};
|
|
110
|
+
if (tag(".mantine-Card-root, .mantine-Paper-root, table") === 0)
|
|
111
|
+
tag("main, section, header, form");
|
|
104
112
|
}
|
|
105
113
|
const STATE_SURFACE = '[data-basalt-chart-card], [data-basalt-chart-state], [style*="container-name: basalt-card"]';
|
|
106
114
|
const readFacts = (page) => page.evaluate(`(() => { const STATE_SURFACE = ${JSON.stringify(STATE_SURFACE)}; return {
|
|
107
115
|
anchors: [...new Set([...document.querySelectorAll('[data-shot]')].map((e) => e.getAttribute('data-shot')).filter(Boolean))],
|
|
108
116
|
declared: [...document.querySelectorAll('[data-shot-states]')].flatMap((e) => (e.getAttribute('data-shot-states') ?? '').split(/\\s+/)).filter(Boolean),
|
|
117
|
+
declaring: [...new Set([...document.querySelectorAll('[data-shot]')].filter((e) => e.closest('[data-shot-states]') || e.querySelector('[data-shot-states]')).map((e) => e.getAttribute('data-shot')).filter(Boolean))],
|
|
109
118
|
stateful: [...new Set([...document.querySelectorAll('[data-shot]')].filter((e) => e.matches(STATE_SURFACE) || e.querySelector(STATE_SURFACE)).map((e) => e.getAttribute('data-shot')).filter(Boolean))],
|
|
119
|
+
content: document.body ? document.body.innerText : '',
|
|
110
120
|
absent: Object.fromEntries([...document.querySelectorAll('[data-shot][data-shot-absent]')].map((e) => [e.getAttribute('data-shot'), (e.getAttribute('data-shot-absent') ?? '').split(/\\s+/).filter(Boolean)])),
|
|
111
121
|
}; })()`);
|
|
112
122
|
const addProblem = (c, problem) => {
|
|
@@ -327,6 +337,39 @@ function markVisibleTooltips() {
|
|
|
327
337
|
el.setAttribute("data-shot-seen", "");
|
|
328
338
|
}
|
|
329
339
|
}
|
|
340
|
+
function visibleTooltipCount() {
|
|
341
|
+
return Array.from(document.querySelectorAll('[role="tooltip"]')).filter((el) => {
|
|
342
|
+
const rect = el.getBoundingClientRect();
|
|
343
|
+
return rect.width > 0 && rect.height > 0 && getComputedStyle(el).visibility !== "hidden";
|
|
344
|
+
}).length;
|
|
345
|
+
}
|
|
346
|
+
async function clearStrayTooltips(page) {
|
|
347
|
+
await page.mouse.move(0, 0);
|
|
348
|
+
for (let waited = 0; waited < TIP_CLEAR_MS; waited += TIP_SETTLE_MS) {
|
|
349
|
+
if (await page.evaluate(visibleTooltipCount, void 0) === 0) return;
|
|
350
|
+
await sleep(TIP_SETTLE_MS);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function muteOtherTooltips(open) {
|
|
354
|
+
for (const el of Array.from(document.querySelectorAll('[role="tooltip"]'))) {
|
|
355
|
+
const rect = el.getBoundingClientRect();
|
|
356
|
+
if (el === open || rect.width === 0 || rect.height === 0) continue;
|
|
357
|
+
el.setAttribute("data-shot-muted", el.style.visibility);
|
|
358
|
+
el.style.setProperty("visibility", "hidden", "important");
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function claimOwnTooltip(trigger) {
|
|
362
|
+
const tips = Array.from(document.querySelectorAll('[role="tooltip"]'));
|
|
363
|
+
if (tips.some((el) => trigger.contains(el))) {
|
|
364
|
+
for (const el of tips) if (!trigger.contains(el)) el.setAttribute("data-shot-seen", "");
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function unmuteTooltips() {
|
|
368
|
+
for (const el of Array.from(document.querySelectorAll("[data-shot-muted]"))) {
|
|
369
|
+
el.style.visibility = el.getAttribute("data-shot-muted") ?? "";
|
|
370
|
+
el.removeAttribute("data-shot-muted");
|
|
371
|
+
}
|
|
372
|
+
}
|
|
330
373
|
function describedByOf(el) {
|
|
331
374
|
const named = el?.matches("[aria-describedby]") ? el : el?.querySelector("[aria-describedby]");
|
|
332
375
|
return named?.getAttribute("aria-describedby")?.split(/\s+/)[0] ?? "";
|
|
@@ -375,12 +418,19 @@ async function captureHover(c, name) {
|
|
|
375
418
|
await reveal(c, name, "hover");
|
|
376
419
|
const inner = c.page.locator(`${sel(name)} [data-shot-hover]`).first();
|
|
377
420
|
const target = await inner.count() > 0 ? inner : anchor;
|
|
421
|
+
await clearStrayTooltips(c.page);
|
|
378
422
|
await c.page.evaluate(markVisibleTooltips, void 0);
|
|
379
423
|
await hoverTrigger(target);
|
|
380
424
|
const describedBy = idOf(await target.evaluate(describedByOf));
|
|
425
|
+
if (describedBy === "") await target.evaluate(claimOwnTooltip);
|
|
381
426
|
const [box, tip] = [await settledBox(anchor), await openTooltipBox(c, describedBy)];
|
|
382
427
|
if (!box || !tip) return void await snap(anchor, path);
|
|
383
|
-
|
|
428
|
+
try {
|
|
429
|
+
await tipOf(c, describedBy).evaluate(muteOtherTooltips);
|
|
430
|
+
await snapClip(c, path, [anchor, tipOf(c, describedBy)]);
|
|
431
|
+
} finally {
|
|
432
|
+
await c.page.evaluate(unmuteTooltips, void 0).catch(() => void 0);
|
|
433
|
+
}
|
|
384
434
|
});
|
|
385
435
|
await c.page.mouse.move(0, 0);
|
|
386
436
|
}
|
|
@@ -430,9 +480,11 @@ async function captureTooltip(c, name) {
|
|
|
430
480
|
if (await trigger.count() === 0) throw new NotDeclared("no [data-shot-tooltip] in the anchor");
|
|
431
481
|
const anchor = anchorOf(c, name);
|
|
432
482
|
await reveal(c, name, "tooltip");
|
|
483
|
+
await clearStrayTooltips(c.page);
|
|
433
484
|
await c.page.evaluate(markVisibleTooltips, void 0);
|
|
434
485
|
await hoverTrigger(trigger);
|
|
435
486
|
const describedBy = idOf(await trigger.evaluate(describedByOf));
|
|
487
|
+
if (describedBy === "") await trigger.evaluate(claimOwnTooltip);
|
|
436
488
|
const t = await openTooltipBox(c, describedBy, TOOLTIP_TIMEOUT_MS);
|
|
437
489
|
if (!t) throw new Error('no visible [role="tooltip"] after hover');
|
|
438
490
|
const a = await settledBox(anchor);
|
|
@@ -447,6 +499,11 @@ const POINTER_STATES = {
|
|
|
447
499
|
focus: captureFocus,
|
|
448
500
|
tooltip: captureTooltip
|
|
449
501
|
};
|
|
502
|
+
function lacksStates(c, name, state) {
|
|
503
|
+
const { stateful, declaring, declared, absent } = c.facts;
|
|
504
|
+
const own = declaring ?? (declared.length > 0 ? c.facts.anchors : []);
|
|
505
|
+
return stateful?.includes(name) === true && !own.includes(name) && !absent?.[name]?.includes(state);
|
|
506
|
+
}
|
|
450
507
|
async function captureUrlState(c, state) {
|
|
451
508
|
const restNames = c.facts.anchors;
|
|
452
509
|
if (!c.facts.declared.includes(state)) {
|
|
@@ -456,7 +513,7 @@ async function captureUrlState(c, state) {
|
|
|
456
513
|
state,
|
|
457
514
|
status: "not-declared",
|
|
458
515
|
note: c.facts.declared.length === 0 ? NO_STATES_NOTE : "page does not declare this state",
|
|
459
|
-
...c
|
|
516
|
+
...lacksStates(c, name, state) ? { stateful: true } : {}
|
|
460
517
|
});
|
|
461
518
|
}
|
|
462
519
|
return;
|
|
@@ -480,6 +537,8 @@ async function captureUrlState(c, state) {
|
|
|
480
537
|
}
|
|
481
538
|
const note = restNames.includes(name) ? void 0 : "anchor only present in this state";
|
|
482
539
|
await attempt(c, name, state, (path) => restCrop(c, name, state, path), note);
|
|
540
|
+
const shot = c.shots.findLast((r) => r.name === name && r.state === state);
|
|
541
|
+
if (shot && shot.status !== "not-declared" && lacksStates(c, name, state)) shot.stateful = true;
|
|
483
542
|
}
|
|
484
543
|
}
|
|
485
544
|
const STEPS = ["xs", "sm", "md", "lg", "xl", "default"];
|
|
@@ -564,6 +623,7 @@ async function capturePage(args) {
|
|
|
564
623
|
input.apiProblems?.();
|
|
565
624
|
try {
|
|
566
625
|
c.facts = await visit(c, input.base + route);
|
|
626
|
+
if (c.facts.content) c.content = hash(c.facts.content);
|
|
567
627
|
} catch (error) {
|
|
568
628
|
record(c, {
|
|
569
629
|
name: PAGE_ANCHOR,
|
|
@@ -680,6 +740,7 @@ async function capture(input) {
|
|
|
680
740
|
scale: [],
|
|
681
741
|
scaleError: void 0
|
|
682
742
|
};
|
|
743
|
+
const contents = /* @__PURE__ */ new Map();
|
|
683
744
|
for (const scheme of SCHEMES) {
|
|
684
745
|
for (const viewport of VIEWPORTS) {
|
|
685
746
|
input.apiProblems?.();
|
|
@@ -707,6 +768,7 @@ async function capture(input) {
|
|
|
707
768
|
out.scale.push({ scheme, viewport, ...done.scale });
|
|
708
769
|
scaled = true;
|
|
709
770
|
}
|
|
771
|
+
if (done.content && !contents.has(route)) contents.set(route, done.content);
|
|
710
772
|
if (done.scaleError) out.scaleError = out.scaleError ?? done.scaleError;
|
|
711
773
|
out.anchors.push(...done.anchors);
|
|
712
774
|
out.shots.push(...done.shots);
|
|
@@ -716,6 +778,8 @@ async function capture(input) {
|
|
|
716
778
|
}
|
|
717
779
|
}
|
|
718
780
|
}
|
|
781
|
+
if (input.routes.length > 1 && contents.size === new Set(input.routes).size && new Set(contents.values()).size === 1)
|
|
782
|
+
input.log(SAME_CONTENT_WARNING);
|
|
719
783
|
await writeSheets(input, out).catch(
|
|
720
784
|
(error) => input.log(`[shot] contact sheets not written: ${firstLine(error)}`)
|
|
721
785
|
);
|
|
@@ -725,7 +789,10 @@ async function capture(input) {
|
|
|
725
789
|
return { anchors, shots, scale, scaleError: out.scaleError };
|
|
726
790
|
}
|
|
727
791
|
export {
|
|
792
|
+
SAME_CONTENT_WARNING,
|
|
728
793
|
capture,
|
|
794
|
+
claimOwnTooltip,
|
|
795
|
+
clearStrayTooltips,
|
|
729
796
|
describedByOf,
|
|
730
797
|
fileName,
|
|
731
798
|
groupScale,
|
|
@@ -735,6 +802,7 @@ export {
|
|
|
735
802
|
hoverAtOf,
|
|
736
803
|
hoverTrigger,
|
|
737
804
|
markVisibleTooltips,
|
|
805
|
+
muteOtherTooltips,
|
|
738
806
|
openContext,
|
|
739
807
|
parseHoverAt,
|
|
740
808
|
readScaleInPage,
|
|
@@ -745,6 +813,8 @@ export {
|
|
|
745
813
|
tagAutoAnchors,
|
|
746
814
|
tooltipSelector,
|
|
747
815
|
unionClip,
|
|
816
|
+
unmuteTooltips,
|
|
748
817
|
visibleTooltip,
|
|
818
|
+
visibleTooltipCount,
|
|
749
819
|
withParam
|
|
750
820
|
};
|
|
@@ -41,7 +41,10 @@ export type HistoryEntry = {
|
|
|
41
41
|
out: string;
|
|
42
42
|
commit?: string;
|
|
43
43
|
counts: Record<Severity, number>;
|
|
44
|
-
|
|
44
|
+
/** Null when no anchor resolved: nothing was measured, so there is no score. */
|
|
45
|
+
score: number | null;
|
|
46
|
+
/** Total findings: the score floors at 0, this keeps counting. */
|
|
47
|
+
findings?: number;
|
|
45
48
|
};
|
|
46
49
|
export declare const scoreOf: (findings: readonly Finding[]) => number;
|
|
47
50
|
/** Every deterministic finding of one round, grouped across scheme × viewport, content → layout → style. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/detect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/detect.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAwB,WAAW,EAAS,MAAM,SAAS,CAAA;AAEvE,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAChD,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAElD,MAAM,MAAM,OAAO,GAAG;IACpB,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gEAAgE;IAChE,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,kEAAkE;AAClE,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE;QACX,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;Q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