basalt-ui 2.20.0 → 2.21.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 +39 -0
- package/MIGRATING.md +129 -12
- package/agent/agents/basalt-design-reviewer.md +22 -5
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +10 -23
- package/agent/skills/basalt-design/references/anti-defaults.md +24 -0
- package/agent/skills/basalt-design/references/catalogue.md +48 -0
- package/agent/skills/basalt-design/references/concept.md +36 -0
- package/agent/skills/basalt-design/references/encoding-rules.md +45 -0
- package/agent/skills/basalt-design/references/stat-tile.md +24 -0
- package/agent/templates/AGENTS-block.md.tpl +3 -3
- package/configs/oxlint-plugin.js +1 -0
- package/dist/charts/ChartCard.d.ts +6 -2
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +4 -0
- package/dist/charts/state.d.ts +5 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +2 -0
- package/dist/cli/check-theme.d.ts.map +1 -1
- package/dist/cli/check-theme.js +3 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +3 -2
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +27 -15
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +3 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +6 -1
- package/dist/cli/shot/detect.d.ts +51 -0
- package/dist/cli/shot/detect.d.ts.map +1 -0
- package/dist/cli/shot/detect.js +396 -0
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +7 -4
- package/dist/cli/shot/measure.d.ts +2 -0
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +2 -0
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/sync.d.ts +2 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -2
- package/dist/common/retry-button.d.ts +12 -0
- package/dist/common/retry-button.d.ts.map +1 -0
- package/dist/common/retry-button.js +22 -0
- package/dist/common/retry-button.module.css +58 -0
- package/dist/common/retry-button.module.css.d.ts +8 -0
- package/dist/dashboard/bar-list.d.ts +5 -2
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +2 -2
- package/dist/dashboard/meter-model.d.ts +34 -6
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +44 -13
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +167 -135
- package/dist/dashboard/meter.d.ts +11 -7
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +5 -1
- package/dist/dashboard/meter.module.css +18 -65
- package/dist/dashboard/meter.module.css.d.ts +2 -7
- package/dist/dashboard/query-state.d.ts +1 -1
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +3 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +2 -1
- package/dist/dashboard/stat-strip.d.ts +17 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +35 -5
- package/dist/dashboard/stat-strip.module.css +97 -14
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +2 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -0
- package/dist/dashboard/visual-slot.js +5 -0
- package/dist/guard/index.d.ts +15 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +14 -0
- package/dist/guard/palette.d.ts +51 -0
- package/dist/guard/palette.d.ts.map +1 -0
- package/dist/guard/palette.js +190 -0
- package/dist/guard/series-file.d.ts +15 -0
- package/dist/guard/series-file.d.ts.map +1 -0
- package/dist/guard/series-file.js +29 -0
- package/dist/guard/types.d.ts +3 -3
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/theme/controls.module.css +10 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +18 -0
- package/dist/tokens/oklab.d.ts +28 -0
- package/dist/tokens/oklab.d.ts.map +1 -0
- package/dist/tokens/oklab.js +73 -0
- package/llms.txt +7 -5
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +9 -1
- package/src/charts/state.tsx +9 -0
- package/src/cli/check-theme.ts +3 -0
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +48 -17
- package/src/cli/init.ts +2 -1
- package/src/cli/shot/capture.ts +15 -2
- package/src/cli/shot/detect.ts +533 -0
- package/src/cli/shot/index.ts +8 -4
- package/src/cli/shot/measure.ts +4 -0
- package/src/cli/shot/types.ts +5 -1
- package/src/cli/sync.ts +4 -2
- package/src/common/retry-button.module.css +58 -0
- package/src/common/retry-button.module.css.d.ts +8 -0
- package/src/common/retry-button.tsx +29 -0
- package/src/dashboard/bar-list.tsx +11 -8
- package/src/dashboard/meter-model.ts +91 -20
- package/src/dashboard/meter-parts.tsx +155 -115
- package/src/dashboard/meter.module.css +18 -65
- package/src/dashboard/meter.module.css.d.ts +2 -7
- package/src/dashboard/meter.tsx +18 -8
- package/src/dashboard/query-state.tsx +4 -7
- package/src/dashboard/stat-card.tsx +4 -1
- package/src/dashboard/stat-strip.module.css +97 -14
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +85 -5
- package/src/dashboard/visual-slot.ts +8 -0
- package/src/guard/index.ts +16 -4
- package/src/guard/palette.ts +261 -0
- package/src/guard/series-file.ts +51 -0
- package/src/guard/types.ts +3 -2
- package/src/surfaces.ts +2 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +82 -48
- package/src/theme/controls.module.css +10 -0
- package/src/theme/index.ts +26 -0
- package/src/tokens/oklab.ts +97 -0
package/src/charts/ChartCard.tsx
CHANGED
|
@@ -124,7 +124,11 @@ type ChartCardBaseProps = BasaltProps &
|
|
|
124
124
|
* unsized chart takes — pass the chart's own `height` when it states one, so a `<Suspense
|
|
125
125
|
* fallback={<ChartCard state={{ pending: true }} …/>}>` reserves the final size. */
|
|
126
126
|
placeholderHeight?: number | ResponsiveChartHeight | undefined
|
|
127
|
-
/**
|
|
127
|
+
/** An errored `state` shows the shared Retry button (the one `ErrorState` renders). */
|
|
128
|
+
onRetry?: (() => void) | undefined
|
|
129
|
+
/** A refetch is in flight: Retry is inert and marked busy. */
|
|
130
|
+
retrying?: boolean | undefined
|
|
131
|
+
/** Any other action under the placeholder, e.g. a "clear filters" link; after Retry. */
|
|
128
132
|
stateAction?: ReactNode
|
|
129
133
|
children?: ReactNode
|
|
130
134
|
}
|
|
@@ -191,6 +195,8 @@ export function ChartCard({
|
|
|
191
195
|
state,
|
|
192
196
|
placeholderHeight,
|
|
193
197
|
stateAction,
|
|
198
|
+
onRetry,
|
|
199
|
+
retrying,
|
|
194
200
|
className,
|
|
195
201
|
classNames,
|
|
196
202
|
style,
|
|
@@ -240,6 +246,8 @@ export function ChartCard({
|
|
|
240
246
|
<ChartPlaceholder
|
|
241
247
|
state={state}
|
|
242
248
|
{...(placeholderHeight !== undefined && { height: placeholderHeight })}
|
|
249
|
+
{...(onRetry !== undefined && { onRetry })}
|
|
250
|
+
{...(retrying !== undefined && { retrying })}
|
|
243
251
|
action={stateAction}
|
|
244
252
|
/>
|
|
245
253
|
)}
|
package/src/charts/state.tsx
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { CSSProperties, ReactElement, ReactNode } from 'react'
|
|
6
6
|
import { toErrorMessage } from '../common/errors'
|
|
7
|
+
import { RetryButton } from '../common/retry-button'
|
|
7
8
|
import { VX } from '../tokens'
|
|
8
9
|
import { ChartBox, growClass, stateClass } from './box'
|
|
9
10
|
import type { ChartBoxHeight } from './box'
|
|
@@ -74,6 +75,11 @@ const emptyLabel = (state: ChartState | undefined): string =>
|
|
|
74
75
|
export function ChartPlaceholder(props: {
|
|
75
76
|
state: ChartState | undefined
|
|
76
77
|
height?: ChartBoxHeight
|
|
78
|
+
/** Error only: the shared Retry button, the same one `ErrorState` renders. */
|
|
79
|
+
onRetry?: () => void
|
|
80
|
+
/** A refetch is in flight: Retry is inert and marked busy. */
|
|
81
|
+
retrying?: boolean
|
|
82
|
+
/** Any other action (a "clear filters" link), after Retry. */
|
|
77
83
|
action?: ReactNode
|
|
78
84
|
/** For a box too small to hold a sentence (a sparkline): error and empty show a `—` and carry the
|
|
79
85
|
* label as the accessible name and the hover title. */
|
|
@@ -108,6 +114,9 @@ export function ChartPlaceholder(props: {
|
|
|
108
114
|
</span>
|
|
109
115
|
)}
|
|
110
116
|
<span style={errorMessageStyle}>{label}</span>
|
|
117
|
+
{kind === 'error' && props.onRetry !== undefined && (
|
|
118
|
+
<RetryButton onClick={props.onRetry} retrying={props.retrying ?? false} />
|
|
119
|
+
)}
|
|
111
120
|
{props.action}
|
|
112
121
|
</>
|
|
113
122
|
)
|
package/src/cli/check-theme.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
unmatchedExemptPatterns,
|
|
15
15
|
} from '../guard'
|
|
16
16
|
import type { Finding } from '../guard'
|
|
17
|
+
import { checkSeriesModule } from '../guard/series-file'
|
|
17
18
|
import { auditAllows } from './audit-allows'
|
|
18
19
|
import { DEFAULT_ROOTS, resolveRoots } from './config'
|
|
19
20
|
import {
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
resolveGuardConfig,
|
|
35
36
|
resolveProjectDir,
|
|
36
37
|
scannableFiles,
|
|
38
|
+
defaultExempt,
|
|
37
39
|
SERIES_MODULE_HINT_RE,
|
|
38
40
|
waiverHintFor,
|
|
39
41
|
} from './index'
|
|
@@ -116,6 +118,7 @@ export function checkTheme(
|
|
|
116
118
|
findings.push(...checkSource(readFileSync(resolve(cwd, rel), 'utf8'), rel, guardCfg))
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
findings.push(...checkSeriesModule(cwd, defaultExempt(cfg)[0] ?? '', guardCfg)) // the exempt series file: palette checks
|
|
119
122
|
if (scanned.length === 0) {
|
|
120
123
|
// A configured-but-wrong root is never intentional, and silently scanning 0 files under the
|
|
121
124
|
// built-in defaults (argo's pre-migration layout) is the same failure mode for every other
|
package/src/cli/help.ts
CHANGED
|
@@ -57,6 +57,7 @@ export const COMMAND_OPTIONS: Record<
|
|
|
57
57
|
wait: { type: 'string' },
|
|
58
58
|
'auto-anchors': { type: 'boolean' },
|
|
59
59
|
'api-allow-writes': { type: 'boolean' },
|
|
60
|
+
lint: { type: 'string' },
|
|
60
61
|
},
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -81,7 +82,7 @@ export const USAGE =
|
|
|
81
82
|
' sync [--force] [--check] [--verbose] [--tokens-only|--framework] |\n' +
|
|
82
83
|
' check-theme [--audit-allows] |\n' +
|
|
83
84
|
' doctor [--tokens-only|--framework] | guard-hook | tokens:css | fonts:css |\n' +
|
|
84
|
-
' shot <route…> | help>\n\n' +
|
|
85
|
+
' shot <route…> | shot detect | help>\n\n' +
|
|
85
86
|
'check-theme [--tokens-only|--framework] [--audit-allows]\n' +
|
|
86
87
|
' --audit-allows reports instead of scanning: every `theme-allow` annotation and every\n' +
|
|
87
88
|
' `basalt.exemptRules` entry, with what each one still suppresses — proved by re-running the\n' +
|
|
@@ -113,6 +114,22 @@ export const USAGE =
|
|
|
113
114
|
" app holds other people's data. Example:\n" +
|
|
114
115
|
' basalt-ui shot /overview --dist dist --api /api=https://app.example.com \\\n' +
|
|
115
116
|
' --local-storage auth-token=@env:APP_TOKEN --header authorization=@env:APP_BEARER --auto-anchors\n\n' +
|
|
117
|
+
'shot detect [--out <dir>] [--lint <oxlint-json-file>]\n' +
|
|
118
|
+
' The deterministic second review pass, no browser and no model: reads <out>/metrics.json (default: the\n' +
|
|
119
|
+
' out dir in .basalt/shots/last.json) and, with --lint, the basalt/* diagnostics of `oxlint --format json`\n' +
|
|
120
|
+
' output saved to a file. Writes <out>/detect.json and a findings table, content, then layout, then style:\n' +
|
|
121
|
+
' off-scale inset/gap/radius, nested radius step under 3 px, more than 3 font sizes, an empty region of\n' +
|
|
122
|
+
' 40 % or more, contrast failures, error shots, a missing scale or no anchors.\n' +
|
|
123
|
+
' Exit codes: 0 clean (P2/P3 findings are listed, not failing), 2 a P0 or P1 finding, 1 scan failure (missing\n' +
|
|
124
|
+
' or unreadable metrics.json or lint file, or detect.json/history.json cannot be written).\n' +
|
|
125
|
+
' P0 fails: broken, unreadable or a contrast failure; an error shot; no anchors\n' +
|
|
126
|
+
' P1 fails: a rubric item fails (off-scale value, font sizes, empty region, nested radius, lint error)\n' +
|
|
127
|
+
' P2 noted, not failing: degraded: a lint warning, a contrast measured on an assumed white backdrop\n' +
|
|
128
|
+
' P3 noted, not failing: polish: an off-scale value within 1 px of a step\n' +
|
|
129
|
+
' score = 100 - (25 per P0 + 10 per P1 + 3 per P2 + 1 per P3), floored at 0. Each run appends\n' +
|
|
130
|
+
' {at, out, commit, counts, score} to .basalt/shots/history.json and prints the last 5 scores as a trend.\n' +
|
|
131
|
+
' A component can declare a rest anchor absent in a URL state with data-shot-absent="empty error": that\n' +
|
|
132
|
+
' cell is recorded `absent`, not `error`.\n\n' +
|
|
116
133
|
'doctor [--tokens-only|--framework]\n' +
|
|
117
134
|
' Checks THIS project only: the manifest exists, the oxlint preset is wired, the pre-commit\n' +
|
|
118
135
|
' hook runs check-theme (via `lefthook dump`), and the ai package major is consistent within\n' +
|
package/src/cli/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
unlinkSync,
|
|
18
18
|
writeFileSync,
|
|
19
19
|
} from 'node:fs'
|
|
20
|
-
import { dirname, isAbsolute, relative, resolve } from 'node:path'
|
|
20
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
21
21
|
import { fileURLToPath } from 'node:url'
|
|
22
22
|
|
|
23
23
|
import { DEFAULT_GUARD_CONFIG, guardWaiverHint } from '../guard'
|
|
@@ -677,7 +677,11 @@ export function importsAgentsMd(text: string): boolean {
|
|
|
677
677
|
}
|
|
678
678
|
|
|
679
679
|
/** Scaffold options. `noMergeLint`: `--no-merge-lint` leaves an existing `.oxlintrc.json` untouched. */
|
|
680
|
-
export type ScaffoldFlags = {
|
|
680
|
+
export type ScaffoldFlags = {
|
|
681
|
+
noMergeLint?: boolean
|
|
682
|
+
/** Shipped-source root; defaults to this package. Tests point it at a scratch package. */
|
|
683
|
+
pkgRoot?: string
|
|
684
|
+
}
|
|
681
685
|
|
|
682
686
|
export { ROUTER_SEED_DESTS, START_PROVIDER_HINT, routerSeedDest, routerSeedDests }
|
|
683
687
|
|
|
@@ -819,8 +823,23 @@ export function resolvePlacement(cwd: string): PlacementFlags {
|
|
|
819
823
|
}
|
|
820
824
|
}
|
|
821
825
|
|
|
826
|
+
/** Every `.md` file under a shipped skill dir (no dot-segments), relative and sorted; `SKILL.md` first. Empty if the dir is absent. */
|
|
827
|
+
function skillFiles(pkgRoot: string, name: string): string[] {
|
|
828
|
+
const root = resolve(pkgRoot, 'agent/skills', name)
|
|
829
|
+
if (!existsSync(root)) return []
|
|
830
|
+
const rels = readdirSync(root, { recursive: true, withFileTypes: true })
|
|
831
|
+
.filter((e) => e.isFile() && e.name.endsWith('.md'))
|
|
832
|
+
.map((e) => relative(root, join(e.parentPath, e.name)).split(sep).join('/'))
|
|
833
|
+
.filter((rel) => !rel.split('/').some((seg) => seg.startsWith('.')))
|
|
834
|
+
.toSorted()
|
|
835
|
+
return [...rels.filter((r) => r === 'SKILL.md'), ...rels.filter((r) => r !== 'SKILL.md')]
|
|
836
|
+
}
|
|
837
|
+
|
|
822
838
|
/** The full managed-file manifest. Stable, declarative — the single source of truth for init/sync. */
|
|
823
|
-
export function managedFiles(
|
|
839
|
+
export function managedFiles(
|
|
840
|
+
placement: PlacementFlags = ROOT_PLACEMENT,
|
|
841
|
+
pkgRoot: string = packageRoot(),
|
|
842
|
+
): ManagedFile[] {
|
|
824
843
|
// ── managed: exactly what Claude reads ──────────────────────────────────────
|
|
825
844
|
const rules: ManagedFile[] = RULE_NAMES.map((name) => ({
|
|
826
845
|
dest: `.claude/rules/basalt-${name}.md`,
|
|
@@ -835,12 +854,16 @@ export function managedFiles(placement: PlacementFlags = ROOT_PLACEMENT): Manage
|
|
|
835
854
|
// Skills take the same managed path the rules do — Claude Code cannot load skills from
|
|
836
855
|
// node_modules, and a plugin cannot ship rules, so init/sync is the one delivery channel for the
|
|
837
856
|
// whole agentic layer. The `basalt-` filename prefix keeps the /basalt-design ergonomics.
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
857
|
+
// Every file under `agent/skills/<name>/` is its own managed unit (SKILL.md plus `references/**`),
|
|
858
|
+
// found by walking the shipped tree — no per-file list to maintain.
|
|
859
|
+
const skills: ManagedFile[] = SKILL_NAMES.flatMap((name) =>
|
|
860
|
+
skillFiles(pkgRoot, name).map((rel) => ({
|
|
861
|
+
dest: `.claude/skills/${name}/${rel}`,
|
|
862
|
+
mode: 'managed' as const,
|
|
863
|
+
source: `agent/skills/${name}/${rel}`,
|
|
864
|
+
render: () => readSource(pkgRoot, `agent/skills/${name}/${rel}`),
|
|
865
|
+
})),
|
|
866
|
+
)
|
|
844
867
|
|
|
845
868
|
// Subagents load only walking UP from the session cwd, so the consumer root is the right home.
|
|
846
869
|
const agents: ManagedFile[] = AGENT_NAMES.map((name) => ({
|
|
@@ -1082,7 +1105,7 @@ export function readManifest(cwd: string): Manifest {
|
|
|
1082
1105
|
*/
|
|
1083
1106
|
const RETIREABLE_DEST_PATTERNS: readonly RegExp[] = [
|
|
1084
1107
|
/^\.claude\/rules\/basalt-[a-z0-9-]+\.md$/,
|
|
1085
|
-
/^\.claude\/skills\/basalt-[a-z0-9-]+\/SKILL\.md$/,
|
|
1108
|
+
/^\.claude\/skills\/basalt-[a-z0-9-]+\/(SKILL\.md|references\/.+\.md)$/,
|
|
1086
1109
|
/^\.claude\/agents\/basalt-[a-z0-9-]+\.md$/,
|
|
1087
1110
|
]
|
|
1088
1111
|
|
|
@@ -1161,11 +1184,16 @@ export function pruneRetiredManagedFiles(
|
|
|
1161
1184
|
* reason to keep it, not an error to report.
|
|
1162
1185
|
*/
|
|
1163
1186
|
function removeEmptyParentDir(fileAbs: string): void {
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1187
|
+
const inSkill = /[\\/]\.claude[\\/]skills[\\/]basalt-[^\\/]+(?:[\\/]|$)/
|
|
1188
|
+
// The file's own dir always; then upward only inside `.claude/skills/<name>` (never `.claude/skills`).
|
|
1189
|
+
for (let dir = dirname(fileAbs), first = true; first || inSkill.test(dir); dir = dirname(dir)) {
|
|
1190
|
+
first = false
|
|
1191
|
+
try {
|
|
1192
|
+
if (readdirSync(dir).length > 0) return
|
|
1193
|
+
rmdirSync(dir)
|
|
1194
|
+
} catch {
|
|
1195
|
+
return
|
|
1196
|
+
}
|
|
1169
1197
|
}
|
|
1170
1198
|
}
|
|
1171
1199
|
|
|
@@ -1278,8 +1306,11 @@ export function diffSummary(file: ManagedFile, state: UnitState): string {
|
|
|
1278
1306
|
}
|
|
1279
1307
|
|
|
1280
1308
|
/** Build the render context for a run from the package root + consumer cwd/config. */
|
|
1281
|
-
export function renderContext(
|
|
1282
|
-
|
|
1309
|
+
export function renderContext(
|
|
1310
|
+
cwd: string,
|
|
1311
|
+
ruleRoots?: readonly string[],
|
|
1312
|
+
pkgRoot: string = packageRoot(),
|
|
1313
|
+
): RenderContext {
|
|
1283
1314
|
const vars = buildTemplateVars(pkgRoot, cwd, readBasaltConfig(cwd))
|
|
1284
1315
|
return { pkgRoot, vars: ruleRoots === undefined ? vars : { ...vars, RULE_ROOTS: [...ruleRoots] } }
|
|
1285
1316
|
}
|
package/src/cli/init.ts
CHANGED
|
@@ -106,6 +106,7 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
106
106
|
cwd,
|
|
107
107
|
ruleRootsFor(rootsState) ??
|
|
108
108
|
(rootsState.kind === 'undetectable' ? [`${appSrc ? `${appSrc}/` : ''}src`] : undefined),
|
|
109
|
+
scaffoldFlags.pkgRoot,
|
|
109
110
|
)
|
|
110
111
|
|
|
111
112
|
// `basalt-tokens.md` tells the consumer to wire `oxlint . && basalt-ui check-theme` into their
|
|
@@ -146,7 +147,7 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
146
147
|
placement.appRel,
|
|
147
148
|
tokensOnly,
|
|
148
149
|
)
|
|
149
|
-
const files = managedFiles(placement).filter((f) => !skippedSeeds.has(f.dest))
|
|
150
|
+
const files = managedFiles(placement, ctx.pkgRoot).filter((f) => !skippedSeeds.has(f.dest))
|
|
150
151
|
|
|
151
152
|
const writtenFiles: string[] = []
|
|
152
153
|
const keptFiles: string[] = []
|
package/src/cli/shot/capture.ts
CHANGED
|
@@ -48,7 +48,12 @@ export type CaptureInput = {
|
|
|
48
48
|
log: (line: string) => void
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
type PageFacts = {
|
|
51
|
+
type PageFacts = {
|
|
52
|
+
anchors: string[]
|
|
53
|
+
declared: string[]
|
|
54
|
+
/** Anchor → the URL states it declares itself absent in (`data-shot-absent="empty error"`). */
|
|
55
|
+
absent?: Record<string, string[]>
|
|
56
|
+
}
|
|
52
57
|
|
|
53
58
|
/** Everything one page visit shares: where the records go and what was already measured. */
|
|
54
59
|
type Ctx = {
|
|
@@ -156,6 +161,7 @@ const readFacts = (page: PwPage): Promise<PageFacts> =>
|
|
|
156
161
|
page.evaluate(`(() => ({
|
|
157
162
|
anchors: [...new Set([...document.querySelectorAll('[data-shot]')].map((e) => e.getAttribute('data-shot')).filter(Boolean))],
|
|
158
163
|
declared: [...document.querySelectorAll('[data-shot-states]')].flatMap((e) => (e.getAttribute('data-shot-states') ?? '').split(/\\s+/)).filter(Boolean),
|
|
164
|
+
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)])),
|
|
159
165
|
}))()`)
|
|
160
166
|
|
|
161
167
|
const addProblem = (c: Ctx, problem: string): void => {
|
|
@@ -477,7 +483,14 @@ async function captureUrlState(c: Ctx, state: ShotState): Promise<void> {
|
|
|
477
483
|
}
|
|
478
484
|
for (const name of new Set([...restNames, ...here.anchors])) {
|
|
479
485
|
if (!here.anchors.includes(name)) {
|
|
480
|
-
|
|
486
|
+
// The declaration lives on the element, which is gone in this state: it is read from the rest render.
|
|
487
|
+
const declared = c.facts.absent?.[name]?.includes(state) ?? false
|
|
488
|
+
record(
|
|
489
|
+
c,
|
|
490
|
+
declared
|
|
491
|
+
? { name, state, status: 'absent', note: 'declared absent in this state' }
|
|
492
|
+
: { name, state, status: 'error', note: 'anchor absent in this state' },
|
|
493
|
+
)
|
|
481
494
|
continue
|
|
482
495
|
}
|
|
483
496
|
const note = restNames.includes(name) ? undefined : 'anchor only present in this state'
|