basalt-ui 2.8.0 → 2.9.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/AGENTS.md +2 -2
- package/CHANGELOG.md +209 -189
- package/MIGRATING.md +98 -28
- package/README.md +7 -8
- package/agent/rules/basalt-controls.md +1 -1
- package/agent/rules/basalt-state.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/templates/AGENTS-block.md.tpl +2 -2
- package/configs/oxlint-plugin.js +25 -68
- package/configs/oxlint-plugin.test.ts +19 -27
- package/dist/charts/BandStrip.d.ts +1 -1
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +1 -10
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +2 -9
- package/dist/charts/band-fold.d.ts +15 -0
- package/dist/charts/band-fold.d.ts.map +1 -0
- package/dist/charts/band-fold.js +19 -0
- package/dist/charts/index.d.ts +1 -0
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/index.js +3 -1
- package/dist/cli/audit-allows.d.ts.map +1 -1
- package/dist/cli/audit-allows.js +1 -1
- package/dist/cli/check-theme.d.ts.map +1 -1
- package/dist/cli/check-theme.js +4 -1
- package/dist/cli/config.d.ts +4 -4
- package/dist/cli/doctor-upgrade.d.ts +5 -4
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +23 -99
- package/dist/cli/doctor.d.ts +2 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +23 -25
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +2 -3
- package/dist/cli/index.d.ts +15 -6
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +16 -27
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +9 -6
- package/dist/cli/install-root.d.ts +10 -0
- package/dist/cli/install-root.d.ts.map +1 -0
- package/dist/cli/install-root.js +32 -0
- package/dist/cli/router-wiring.d.ts +37 -0
- package/dist/cli/router-wiring.d.ts.map +1 -0
- package/dist/cli/router-wiring.js +116 -0
- package/dist/cli/source-text.d.ts +12 -0
- package/dist/cli/source-text.d.ts.map +1 -0
- package/dist/cli/source-text.js +46 -0
- package/dist/cli/sync.d.ts +0 -2
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +23 -21
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +1 -6
- package/dist/common/errors.d.ts +1 -6
- package/dist/common/errors.d.ts.map +1 -1
- package/dist/common/errors.js +0 -7
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +1 -9
- package/dist/common/props.d.ts +2 -2
- package/dist/common/vx-family.d.ts +1 -1
- package/dist/content/code-block.d.ts.map +1 -1
- package/dist/content/code-block.js +36 -27
- package/dist/content/code-block.module.css +19 -1
- package/dist/content/mermaid-sanitize.d.ts +15 -0
- package/dist/content/mermaid-sanitize.d.ts.map +1 -0
- package/dist/content/mermaid-sanitize.js +28 -0
- package/dist/content/mermaid.d.ts +6 -0
- package/dist/content/mermaid.d.ts.map +1 -1
- package/dist/content/mermaid.js +3 -1
- package/dist/content/toc-click-pin.d.ts +45 -0
- package/dist/content/toc-click-pin.d.ts.map +1 -0
- package/dist/content/toc-click-pin.js +111 -0
- package/dist/content/toc-spy.d.ts +25 -0
- package/dist/content/toc-spy.d.ts.map +1 -0
- package/dist/content/toc-spy.js +43 -0
- package/dist/content/toc.d.ts +1 -4
- package/dist/content/toc.d.ts.map +1 -1
- package/dist/content/toc.js +38 -49
- package/dist/controls/number-filter.d.ts.map +1 -1
- package/dist/controls/number-filter.js +1 -1
- package/dist/dashboard/index.d.ts +1 -1
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +1 -3
- package/dist/dashboard/section.d.ts +10 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +20 -3
- package/dist/dashboard/stat-card.d.ts +2 -8
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +1 -1
- package/dist/guard/index.d.ts +13 -9
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +74 -37
- package/dist/guard/types.d.ts +8 -7
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/vx-names.d.ts +1 -1
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +1 -33
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +3 -2
- package/dist/router-tanstack/search-store.d.ts +1 -11
- package/dist/router-tanstack/search-store.d.ts.map +1 -1
- package/dist/router-tanstack/search-store.js +1 -2
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +3 -0
- package/dist/shell/nav-types.d.ts +1 -1
- package/dist/shell/page-bar.d.ts +6 -0
- package/dist/shell/page-bar.d.ts.map +1 -1
- package/dist/shell/page-bar.js +12 -2
- package/dist/state/fields.d.ts +1 -1
- package/dist/state/fields.d.ts.map +1 -1
- package/dist/state/fields.js +3 -1
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +5 -11
- package/dist/table/data-table.d.ts +2 -2
- package/dist/tokens/core.d.ts +0 -10
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -44
- package/dist/vite-boot.d.ts +25 -0
- package/dist/vite-boot.d.ts.map +1 -0
- package/dist/vite-boot.js +36 -0
- package/dist/vite.d.ts +24 -3
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +7 -16
- package/llms.txt +26 -9
- package/package.json +8 -5
- package/src/charts/BandStrip.tsx +4 -16
- package/src/charts/MirroredBars.tsx +2 -11
- package/src/charts/band-fold.ts +26 -0
- package/src/charts/index.ts +1 -0
- package/src/cli/audit-allows.ts +1 -3
- package/src/cli/check-theme.ts +7 -1
- package/src/cli/config.ts +4 -4
- package/src/cli/doctor-upgrade.ts +29 -145
- package/src/cli/doctor.ts +25 -31
- package/src/cli/help.ts +1 -4
- package/src/cli/index.ts +27 -43
- package/src/cli/init.ts +9 -6
- package/src/cli/install-root.ts +40 -0
- package/src/cli/router-wiring.ts +185 -0
- package/src/cli/source-text.ts +62 -0
- package/src/cli/sync.ts +26 -22
- package/src/cli/tokens-css.ts +0 -5
- package/src/common/errors.ts +1 -18
- package/src/common/index.ts +1 -8
- package/src/common/props.ts +2 -2
- package/src/common/vx-family.ts +1 -1
- package/src/content/code-block.module.css +19 -1
- package/src/content/code-block.tsx +7 -2
- package/src/content/mermaid-sanitize.ts +49 -0
- package/src/content/mermaid.tsx +3 -2
- package/src/content/toc-click-pin.ts +156 -0
- package/src/content/toc-spy.ts +61 -0
- package/src/content/toc.tsx +47 -95
- package/src/controls/form-layout.tsx +1 -1
- package/src/controls/number-filter.tsx +6 -1
- package/src/dashboard/index.ts +1 -6
- package/src/dashboard/section.tsx +39 -8
- package/src/dashboard/stat-card.tsx +4 -11
- package/src/guard/index.ts +114 -89
- package/src/guard/types.ts +8 -7
- package/src/guard/vx-names.ts +1 -33
- package/src/index.ts +1 -2
- package/src/provider/index.tsx +6 -3
- package/src/router-tanstack/search-store.ts +2 -14
- package/src/shell/index.tsx +2 -0
- package/src/shell/nav-types.ts +1 -1
- package/src/shell/page-bar.tsx +21 -2
- package/src/state/fields.ts +7 -2
- package/src/surfaces.ts +5 -11
- package/src/table/data-table.tsx +2 -2
- package/src/tokens/core.ts +6 -67
- package/src/vite-boot.ts +109 -0
- package/src/vite.ts +32 -61
- package/dist/tokens.css +0 -331
package/src/cli/index.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
existsSync,
|
|
12
12
|
mkdirSync,
|
|
13
13
|
readdirSync,
|
|
14
|
-
readFileSync,
|
|
15
14
|
rmdirSync,
|
|
16
15
|
statSync,
|
|
17
16
|
realpathSync,
|
|
@@ -30,6 +29,9 @@ import { guardHook } from './guard-hook'
|
|
|
30
29
|
import { COMMAND_OPTIONS, USAGE, unknownFlag } from './help'
|
|
31
30
|
import { init } from './init'
|
|
32
31
|
import { sync } from './sync'
|
|
32
|
+
import { CODE_ROUTED_NOTE, routerSeedSkip } from './router-wiring'
|
|
33
|
+
import type { RouterSeedSkip } from './router-wiring'
|
|
34
|
+
import { hasDependency, readIfExists, readPackageJson } from './source-text'
|
|
33
35
|
import { fontsCss, normalizeColorFunctions, tokensCss } from './tokens-css'
|
|
34
36
|
import { DEFAULT_ROOT, exemptRulePaths, resolveRoots } from './config'
|
|
35
37
|
import type { BasaltConfig } from './config'
|
|
@@ -477,24 +479,6 @@ export function sha256(text: string): string {
|
|
|
477
479
|
return createHash('sha256').update(text, 'utf8').digest('hex')
|
|
478
480
|
}
|
|
479
481
|
|
|
480
|
-
export function readIfExists(abs: string): string | null {
|
|
481
|
-
try {
|
|
482
|
-
return readFileSync(abs, 'utf8')
|
|
483
|
-
} catch {
|
|
484
|
-
return null // absent, a directory, unreadable or raced away: callers treat all four as "not there"
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/** `<dir>/package.json` parsed as `T`; null when absent or not JSON. */
|
|
489
|
-
export function readPackageJson<T>(dir: string): T | null {
|
|
490
|
-
const raw = readIfExists(resolve(dir, 'package.json'))
|
|
491
|
-
try {
|
|
492
|
-
return raw === null ? null : (JSON.parse(raw) as T)
|
|
493
|
-
} catch {
|
|
494
|
-
return null
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
482
|
/** Read a shipped source asset from the package root; null if the sibling hasn't authored it yet. */
|
|
499
483
|
export function readSource(pkgRoot: string, source: string): string | null {
|
|
500
484
|
return readIfExists(resolve(pkgRoot, source))
|
|
@@ -677,15 +661,29 @@ export function routerSeedDests(appRel: string): string[] {
|
|
|
677
661
|
)
|
|
678
662
|
}
|
|
679
663
|
|
|
680
|
-
/** A TanStack Start app owns its router, so its router seeds give way to an in-tree `<BasaltProvider>`. */
|
|
681
|
-
export function isStartApp(cwd: string, appRel: string): boolean {
|
|
682
|
-
return hasDependency(resolve(cwd, appRel), '@tanstack/react-start')
|
|
683
|
-
}
|
|
684
|
-
|
|
685
664
|
export const START_APP_NOTE =
|
|
686
665
|
'TanStack Start app — no main.tsx/nav.tsx/__root.tsx seeded (Start owns the router); render ' +
|
|
687
666
|
'<BasaltProvider><Outlet /></BasaltProvider> in your root route component.'
|
|
688
667
|
|
|
668
|
+
/**
|
|
669
|
+
* The router seeds an app does not get, for `init` and `sync`: why (`start` | `code-routed` | null)
|
|
670
|
+
* and which dests. A tokens-only consumer gets none of them either.
|
|
671
|
+
*/
|
|
672
|
+
export function routerSeedPlan(
|
|
673
|
+
cwd: string,
|
|
674
|
+
appRel: string,
|
|
675
|
+
tokensOnly = false,
|
|
676
|
+
): { skip: RouterSeedSkip; skipped: Set<string> } {
|
|
677
|
+
const skip = tokensOnly ? null : routerSeedSkip(cwd, appRel)
|
|
678
|
+
return { skip, skipped: new Set(tokensOnly || skip !== null ? routerSeedDests(appRel) : []) }
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/** The note `init` prints for a router-seed skip, or null when nothing was skipped. */
|
|
682
|
+
export function seedSkipNote(skip: RouterSeedSkip): string | null {
|
|
683
|
+
if (skip === 'start') return START_APP_NOTE
|
|
684
|
+
return skip === 'code-routed' ? CODE_ROUTED_NOTE : null
|
|
685
|
+
}
|
|
686
|
+
|
|
689
687
|
/** The app directory a command's app-scoped half targets: `rel` is '' when it is the install root. */
|
|
690
688
|
export type AppResolution = { dir: string; rel: string } | { error: string }
|
|
691
689
|
|
|
@@ -731,22 +729,6 @@ export function resolveAppDir(root: string): AppResolution {
|
|
|
731
729
|
}
|
|
732
730
|
}
|
|
733
731
|
|
|
734
|
-
/** True when `pkgName` appears in the consumer's dependencies, devDependencies, or peerDependencies. */
|
|
735
|
-
function hasDependency(cwd: string, pkgName: string): boolean {
|
|
736
|
-
const pkg =
|
|
737
|
-
readPackageJson<
|
|
738
|
-
Record<
|
|
739
|
-
'dependencies' | 'devDependencies' | 'peerDependencies',
|
|
740
|
-
Record<string, string> | undefined
|
|
741
|
-
>
|
|
742
|
-
>(cwd)
|
|
743
|
-
return Boolean(
|
|
744
|
-
pkg?.dependencies?.[pkgName] ??
|
|
745
|
-
pkg?.devDependencies?.[pkgName] ??
|
|
746
|
-
pkg?.peerDependencies?.[pkgName],
|
|
747
|
-
)
|
|
748
|
-
}
|
|
749
|
-
|
|
750
732
|
/**
|
|
751
733
|
* Where the seed engine is running relative to the consumer's git repo — decides which
|
|
752
734
|
* repo-root-shaped seeds are safe to write. `init`/`sync` compute it once per run via
|
|
@@ -863,8 +845,7 @@ export function managedFiles(placement: PlacementFlags = ROOT_PLACEMENT): Manage
|
|
|
863
845
|
},
|
|
864
846
|
}
|
|
865
847
|
|
|
866
|
-
// Scaffold destination is `.oxfmtrc.json` — oxfmt auto-discovers that filename, not `oxfmt.json
|
|
867
|
-
// (the pre-rename scaffold; see migrateLegacyOxfmt for the one-time cleanup of the old dest).
|
|
848
|
+
// Scaffold destination is `.oxfmtrc.json` — oxfmt auto-discovers that filename, not `oxfmt.json`.
|
|
868
849
|
// Content is a starting copy, not a reference — oxfmt has no `extends` mechanism.
|
|
869
850
|
const oxfmt: ManagedFile = {
|
|
870
851
|
dest: '.oxfmtrc.json',
|
|
@@ -1225,7 +1206,8 @@ export function writeUnit(file: ManagedFile, cwd: string, desired: string): stri
|
|
|
1225
1206
|
* - missing : absent on disk → recreate.
|
|
1226
1207
|
* - current : on disk == desired → nothing to do.
|
|
1227
1208
|
* - unchanged: on disk matches a KNOWN-SHIPPED rendering (raw manifest hash, normalized manifest
|
|
1228
|
-
* hash, or
|
|
1209
|
+
* hash, or — with or without a manifest entry — normalized == normalized desired,
|
|
1210
|
+
* the format-only difference a formatter pass leaves) → safe overwrite.
|
|
1229
1211
|
* - drifted : matches none of them (a real local edit) → skip unless --force.
|
|
1230
1212
|
*/
|
|
1231
1213
|
export function classify(state: UnitState, manifestHash: string | undefined): Classification {
|
|
@@ -1784,6 +1766,8 @@ export function run(argv: string[], cwd: string = process.cwd()): number | Promi
|
|
|
1784
1766
|
}
|
|
1785
1767
|
|
|
1786
1768
|
// `RULE_NAMES`/`SKILL_NAMES` re-exported for testing / introspection (no default export).
|
|
1769
|
+
export { isStartApp } from './router-wiring'
|
|
1770
|
+
export { readIfExists, readPackageJson } from './source-text'
|
|
1787
1771
|
export { RULE_NAMES, SKILL_NAMES }
|
|
1788
1772
|
export type { ManagedFile }
|
|
1789
1773
|
|
package/src/cli/init.ts
CHANGED
|
@@ -11,9 +11,8 @@ import type { MergeLintResult, ScaffoldFlags } from './index'
|
|
|
11
11
|
import {
|
|
12
12
|
MANIFEST_PATH,
|
|
13
13
|
declaredProfile,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
START_APP_NOTE,
|
|
14
|
+
routerSeedPlan,
|
|
15
|
+
seedSkipNote,
|
|
17
16
|
readBasaltConfig,
|
|
18
17
|
findBasaltInstall,
|
|
19
18
|
managedFiles,
|
|
@@ -128,8 +127,11 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
128
127
|
const placement = resolvePlacement(cwd)
|
|
129
128
|
// A tokens-only consumer has no use for the Mantine/React scaffolds (doctor skips them there too).
|
|
130
129
|
const tokensOnly = declaredProfile(readBasaltConfig(cwd), []) === 'tokens-only'
|
|
131
|
-
const
|
|
132
|
-
|
|
130
|
+
const { skip: seedSkip, skipped: skippedSeeds } = routerSeedPlan(
|
|
131
|
+
cwd,
|
|
132
|
+
placement.appRel,
|
|
133
|
+
tokensOnly,
|
|
134
|
+
)
|
|
133
135
|
const files = managedFiles(placement).filter((f) => !skippedSeeds.has(f.dest))
|
|
134
136
|
|
|
135
137
|
const writtenFiles: string[] = []
|
|
@@ -205,7 +207,8 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
205
207
|
const tsconfigLine = tokensOnly ? null : seedTsconfigExtends(cwd)
|
|
206
208
|
if (tsconfigLine !== null) console.log(`basalt-ui init: ${tsconfigLine}`)
|
|
207
209
|
if (buildNote !== null) console.log(`basalt-ui init: ${buildNote}`)
|
|
208
|
-
|
|
210
|
+
const skipNote = seedSkipNote(seedSkip)
|
|
211
|
+
if (skipNote !== null) console.log(`basalt-ui init: ${skipNote}`)
|
|
209
212
|
const rootsMessages = rootsNotices(rootsState)
|
|
210
213
|
for (const line of rootsMessages.log) console.log(`basalt-ui init: ${line}`)
|
|
211
214
|
for (const line of rootsMessages.error) console.error(`⚠ basalt-ui init: ${line}`)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Which install root a project-scoped command run inside a workspace package reads — one answer for `doctor` and `sync`. */
|
|
2
|
+
import { existsSync, realpathSync } from 'node:fs'
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { MANIFEST_PATH, findBasaltInstall, resolveAppDir } from './index'
|
|
6
|
+
import { hasDependency } from './source-text'
|
|
7
|
+
|
|
8
|
+
/** The nearest ANCESTOR of `dir` (exclusive) carrying a basalt manifest, or null. */
|
|
9
|
+
export function findManifestAbove(dir: string): string | null {
|
|
10
|
+
let current = resolve(dir, '..')
|
|
11
|
+
for (;;) {
|
|
12
|
+
if (existsSync(resolve(current, MANIFEST_PATH))) return current
|
|
13
|
+
const parent = resolve(current, '..')
|
|
14
|
+
if (parent === current) return null
|
|
15
|
+
current = parent
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function sameInstall(a: string | null, b: string | null): boolean {
|
|
20
|
+
if (a === null || b === null) return false
|
|
21
|
+
return a === b || realpathSync(a) === realpathSync(b)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The install root above `dir`, when `dir` is the APP package of that install: no manifest here,
|
|
26
|
+
* basalt-ui declared here, an ancestor manifest, `resolveAppDir(root)` naming `dir`, and the
|
|
27
|
+
* basalt-ui that resolves from `dir` the same copy (or version) the root uses. Anything else is
|
|
28
|
+
* null — a sub-package with its own basalt-ui is a competing install, not part of the root's.
|
|
29
|
+
*/
|
|
30
|
+
export function installRootAbove(dir: string): string | null {
|
|
31
|
+
if (existsSync(resolve(dir, MANIFEST_PATH)) || !hasDependency(dir, 'basalt-ui')) return null
|
|
32
|
+
const root = findManifestAbove(dir)
|
|
33
|
+
if (root === null) return null
|
|
34
|
+
const app = resolveAppDir(root)
|
|
35
|
+
if ('error' in app || app.dir !== dir) return null
|
|
36
|
+
const here = findBasaltInstall(dir)
|
|
37
|
+
const there = findBasaltInstall(root)
|
|
38
|
+
const sameVersion = here.version !== null && here.version === there.version
|
|
39
|
+
return sameInstall(here.dir, there.dir) || sameVersion ? root : null
|
|
40
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router wiring: is an app TanStack Start, code-routed (route tree defined in code) or file-routed
|
|
3
|
+
* (plugin or `routeTree.gen.*`)? Textual, no TS program. A leaf module shared by init/sync/doctor.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from 'node:fs'
|
|
6
|
+
import { dirname, resolve } from 'node:path'
|
|
7
|
+
|
|
8
|
+
import { hasDependency, readIfExists, tokenize } from './source-text'
|
|
9
|
+
|
|
10
|
+
/** Relative-import hops (static or dynamic) `callsIn` follows from the entry; a router often lives in a singleton module. */
|
|
11
|
+
const IMPORT_DEPTH = 3
|
|
12
|
+
|
|
13
|
+
const VITE_CONFIGS = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'].map((e) => `vite.config.${e}`)
|
|
14
|
+
/** The first local `<script type="module" src>` in index.html (comments and remote src skipped). */
|
|
15
|
+
function htmlEntry(html: string): string | undefined {
|
|
16
|
+
for (const [, attrs = ''] of html
|
|
17
|
+
.replace(/<!--[\s\S]*?-->/g, '')
|
|
18
|
+
.matchAll(/<script\b([^>]*)>/gi)) {
|
|
19
|
+
const src = /\bsrc\s*=\s*["']?([^"'\s>]+)/i.exec(attrs)?.[1]
|
|
20
|
+
if (
|
|
21
|
+
/\btype\s*=\s*["']?module\b/i.test(attrs) &&
|
|
22
|
+
src !== undefined &&
|
|
23
|
+
!/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(src)
|
|
24
|
+
) {
|
|
25
|
+
return src
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** True when `src` calls a binding imported from `@tanstack/router-plugin` after its `plugins` key (a textual proxy for "inside the array"). */
|
|
32
|
+
function registersRouterPlugin(src: string): boolean {
|
|
33
|
+
const { code, inLiteral } = tokenize(src)
|
|
34
|
+
const pluginsAt = [...code.matchAll(/\bplugins\b/g)].find((m) => !inLiteral(m.index))?.index
|
|
35
|
+
if (pluginsAt === undefined) return false
|
|
36
|
+
const imports = code.matchAll(
|
|
37
|
+
/(?:^|;)[ \t]*import\s+(?:type\s+)?([^'"`;]*?)\s*from\s*(['"])@tanstack\/router-plugin(?:\/[^'"]*)?\2/gm,
|
|
38
|
+
)
|
|
39
|
+
return [...imports].some((m) => {
|
|
40
|
+
if (inLiteral(m.index)) return false
|
|
41
|
+
const names = (m[1] ?? '')
|
|
42
|
+
.replace(/[{}]/g, '')
|
|
43
|
+
.split(',')
|
|
44
|
+
.map((part) => part.trim())
|
|
45
|
+
.filter((part) => part !== '' && !/^type\s/.test(part))
|
|
46
|
+
.map((part) => part.split(/\s+as\s+/).pop() ?? part)
|
|
47
|
+
return names.some((name) =>
|
|
48
|
+
[
|
|
49
|
+
...code.matchAll(
|
|
50
|
+
new RegExp(`(?<![.\\w$])${name.replace(/\$/g, '\\$')}(?:\\.\\w+)?\\s*\\(`, 'g'),
|
|
51
|
+
),
|
|
52
|
+
].some((call) => call.index > pluginsAt && !inLiteral(call.index)),
|
|
53
|
+
)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A relative specifier: `import … from`, `export … from`, bare `import '…'` and dynamic `import('…')`. */
|
|
58
|
+
const RELATIVE_IMPORT =
|
|
59
|
+
/(?<![.\w$])(?:(?:import|export)\b[^'";]*?\bfrom|import\s*\(?)\s*['"](\.{1,2}\/[^'"]+)['"]/g
|
|
60
|
+
|
|
61
|
+
/** An import/export specifier naming the generated route tree (`./routeTree.gen`). */
|
|
62
|
+
const GENERATED_TREE_IMPORT =
|
|
63
|
+
/(?<![.\w$])(?:(?:import|export)\b[^'";]*?\bfrom|import\s*\(?)\s*['"][^'"]*routeTree\.gen[^'"]*['"]/g
|
|
64
|
+
|
|
65
|
+
/** The source file a relative specifier names: as written, `.ts`/`.tsx` appended, or a directory index. */
|
|
66
|
+
function resolveRelative(from: string, spec: string): string | null {
|
|
67
|
+
const base = resolve(dirname(from), spec.replace(/\.[jt]sx?$/, ''))
|
|
68
|
+
return (
|
|
69
|
+
[
|
|
70
|
+
resolve(dirname(from), spec),
|
|
71
|
+
`${base}.ts`,
|
|
72
|
+
`${base}.tsx`,
|
|
73
|
+
`${base}/index.ts`,
|
|
74
|
+
`${base}/index.tsx`,
|
|
75
|
+
].find((f) => /\.[jt]sx?$/.test(f) && existsSync(f)) ?? null
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The module `index.html` loads for the app at `dir` (default src/main.tsx), relative to `dir`. */
|
|
80
|
+
export function appEntry(dir: string): string {
|
|
81
|
+
const src = htmlEntry(readIfExists(resolve(dir, 'index.html')) ?? '') ?? 'src/main.tsx'
|
|
82
|
+
return src.replace(/^\//, '')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type Tokens = ReturnType<typeof tokenize>
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Whether the entry or a module it imports (relative imports, static or dynamic, `IMPORT_DEPTH`
|
|
89
|
+
* hops) matches `pattern` in code — a global regex, ignoring comments and string literals; an
|
|
90
|
+
* import inside a comment or a string is not followed. `entryTokens` reuses an already-tokenized entry.
|
|
91
|
+
*/
|
|
92
|
+
export function callsIn(
|
|
93
|
+
dir: string,
|
|
94
|
+
entry: string,
|
|
95
|
+
pattern: RegExp,
|
|
96
|
+
entryTokens?: Tokens,
|
|
97
|
+
): boolean {
|
|
98
|
+
const entryPath = resolve(dir, entry)
|
|
99
|
+
const seen = new Set([entryPath])
|
|
100
|
+
let frontier = [entryPath]
|
|
101
|
+
for (let depth = 0; depth <= IMPORT_DEPTH && frontier.length > 0; depth++) {
|
|
102
|
+
const next: string[] = []
|
|
103
|
+
for (const file of frontier) {
|
|
104
|
+
const { code, inLiteral } =
|
|
105
|
+
file === entryPath && entryTokens ? entryTokens : tokenize(readIfExists(file) ?? '')
|
|
106
|
+
if ([...code.matchAll(pattern)].some((c) => !inLiteral(c.index))) return true
|
|
107
|
+
for (const m of code.matchAll(RELATIVE_IMPORT)) {
|
|
108
|
+
if (inLiteral(m.index)) continue
|
|
109
|
+
const dep = resolveRelative(file, m[1] ?? '')
|
|
110
|
+
if (dep === null || seen.has(dep)) continue
|
|
111
|
+
seen.add(dep)
|
|
112
|
+
next.push(dep)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
frontier = next
|
|
116
|
+
}
|
|
117
|
+
return false
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** A global regex matching a CALL of `name` (itself a regex source), generic or not — not an import or bare mention. */
|
|
121
|
+
export function callOf(pattern: string): RegExp {
|
|
122
|
+
return new RegExp(`\\b${pattern}\\b\\s*(?:<[^()]*>)?\\s*\\(`, 'g')
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const CREATE_BASALT_ROUTER = callOf('createBasaltRouter')
|
|
126
|
+
|
|
127
|
+
/** The directories a generated `routeTree.gen.*` is looked for in: beside the entry, then src/. */
|
|
128
|
+
export function routeTreeDirs(entry: string): string[] {
|
|
129
|
+
return [...new Set([dirname(entry), 'src'])]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** A TanStack router plugin in the vite config, or a `routeTree.gen.*` in `routeTreeDirs`. */
|
|
133
|
+
export function hasRouteTree(dir: string, entry: string): boolean {
|
|
134
|
+
const vite = VITE_CONFIGS.map((f) => readIfExists(resolve(dir, f))).find((t) => t !== null) ?? ''
|
|
135
|
+
return (
|
|
136
|
+
registersRouterPlugin(vite) ||
|
|
137
|
+
routeTreeDirs(entry).some((d) =>
|
|
138
|
+
['ts', 'tsx', 'js'].some((e) => existsSync(resolve(dir, d, `routeTree.gen.${e}`))),
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Whether `createBasaltRouter` is called in a module reachable from the entry. */
|
|
144
|
+
export function hasRouter(dir: string, entry: string, entryTokens?: Tokens): boolean {
|
|
145
|
+
return callsIn(dir, entry, CREATE_BASALT_ROUTER, entryTokens)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Whether the (tokenized) entry imports the generated route tree — a freshly seeded entry does. */
|
|
149
|
+
function importsGeneratedTree({ code, inLiteral }: Tokens): boolean {
|
|
150
|
+
return [...code.matchAll(GENERATED_TREE_IMPORT)].some((m) => !inLiteral(m.index))
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* THE classification, shared by `init`, `sync` and `doctor`: code-routed = `createBasaltRouter` is
|
|
155
|
+
* called in a module reachable from the entry, no router plugin is registered and no
|
|
156
|
+
* `routeTree.gen.*` exists, and the entry does not import a generated tree (a freshly seeded entry
|
|
157
|
+
* does, before the first vite run — that app is file-routed). Comments and strings do not count.
|
|
158
|
+
*/
|
|
159
|
+
export function isCodeRoutedApp(cwd: string, appRel: string): boolean {
|
|
160
|
+
const dir = resolve(cwd, appRel)
|
|
161
|
+
const entry = appEntry(dir)
|
|
162
|
+
const tokens = tokenize(readIfExists(resolve(dir, entry)) ?? '')
|
|
163
|
+
if (importsGeneratedTree(tokens)) return false
|
|
164
|
+
return hasRouter(dir, entry, tokens) && !hasRouteTree(dir, entry)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** A TanStack Start app owns its router, so its router seeds give way to an in-tree `<BasaltProvider>`. */
|
|
168
|
+
export function isStartApp(cwd: string, appRel: string): boolean {
|
|
169
|
+
return hasDependency(resolve(cwd, appRel), '@tanstack/react-start')
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Why an app's router seeds are not placed (see `routerSeedSkip`). */
|
|
173
|
+
export type RouterSeedSkip = 'start' | 'code-routed' | null
|
|
174
|
+
|
|
175
|
+
export const CODE_ROUTED_NOTE =
|
|
176
|
+
'code-routed app (createBasaltRouter, no route-tree plugin or routeTree.gen) — no main.tsx/nav.tsx/__root.tsx seeded.'
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Why an app's router seeds (main/nav/__root) are not placed: `start` (Start owns the router, and
|
|
180
|
+
* wins when both apply) or `code-routed` (no generated tree to assume); null when they are.
|
|
181
|
+
*/
|
|
182
|
+
export function routerSeedSkip(cwd: string, appRel: string): RouterSeedSkip {
|
|
183
|
+
if (isStartApp(cwd, appRel)) return 'start'
|
|
184
|
+
return isCodeRoutedApp(cwd, appRel) ? 'code-routed' : null
|
|
185
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Textual source helpers shared by the CLI's router detection and its checks: reading a file as
|
|
3
|
+
* `null` when it is not there, a package.json dependency probe, and a comment/string tokenizer.
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from 'node:fs'
|
|
6
|
+
import { resolve } from 'node:path'
|
|
7
|
+
|
|
8
|
+
/** `abs` read as text, or null: absent, a directory, unreadable or raced away all mean "not there". */
|
|
9
|
+
export function readIfExists(abs: string): string | null {
|
|
10
|
+
try {
|
|
11
|
+
return readFileSync(abs, 'utf8')
|
|
12
|
+
} catch {
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** `<dir>/package.json` parsed as `T`; null when absent or not JSON. */
|
|
18
|
+
export function readPackageJson<T>(dir: string): T | null {
|
|
19
|
+
const raw = readIfExists(resolve(dir, 'package.json'))
|
|
20
|
+
try {
|
|
21
|
+
return raw === null ? null : (JSON.parse(raw) as T)
|
|
22
|
+
} catch {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies'] as const
|
|
28
|
+
|
|
29
|
+
/** True when `pkgName` appears in any of the consumer's dependencies, devDependencies or peerDependencies. */
|
|
30
|
+
export function hasDependency(cwd: string, pkgName: string): boolean {
|
|
31
|
+
const pkg =
|
|
32
|
+
readPackageJson<Partial<Record<(typeof DEPENDENCY_FIELDS)[number], Record<string, string>>>>(
|
|
33
|
+
cwd,
|
|
34
|
+
)
|
|
35
|
+
return DEPENDENCY_FIELDS.some((field) => pkg?.[field]?.[pkgName] !== undefined)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Strings and template literals (captured) and comments. Known, accepted gap: a regex literal that
|
|
40
|
+
* contains a quote (`/'/`) opens a string this tokenizer never closes, which can blank or hide code
|
|
41
|
+
* after it on that line; a template literal nested inside a `${…}` is not tracked either.
|
|
42
|
+
*/
|
|
43
|
+
const TOKEN =
|
|
44
|
+
/("(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`)|\/\/[^\n]*|\/\*[\s\S]*?\*\//g
|
|
45
|
+
|
|
46
|
+
/** Source with comments blanked (and template text), plus a test for "offset sits inside a string". */
|
|
47
|
+
export function tokenize(src: string): { code: string; inLiteral: (at: number) => boolean } {
|
|
48
|
+
const literals: [number, number][] = []
|
|
49
|
+
const code = src.replace(TOKEN, (m, literal: string | undefined, at: number) => {
|
|
50
|
+
if (literal === undefined) return m.replace(/[^\n]/g, ' ')
|
|
51
|
+
if (!literal.startsWith('`')) {
|
|
52
|
+
literals.push([at, at + m.length])
|
|
53
|
+
return m
|
|
54
|
+
}
|
|
55
|
+
// Template literal: blank the text, keep the delimiters and the `${…}` code scannable.
|
|
56
|
+
return m.replace(
|
|
57
|
+
/(\$\{[^}]*\})|[^\n`]/g,
|
|
58
|
+
(c, interpolation: string | undefined) => interpolation ?? ' ',
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
return { code, inLiteral: (at) => literals.some(([from, to]) => at >= from && at < to) }
|
|
62
|
+
}
|
package/src/cli/sync.ts
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
diffSummary,
|
|
13
13
|
findBasaltInstall,
|
|
14
14
|
inspectLefthookGate,
|
|
15
|
-
isStartApp,
|
|
16
15
|
isStringArray,
|
|
17
16
|
managedFiles,
|
|
18
17
|
normalizeForLedger,
|
|
@@ -31,7 +30,7 @@ import {
|
|
|
31
30
|
reportPrune,
|
|
32
31
|
resolvePlacement,
|
|
33
32
|
resolveProjectDir,
|
|
34
|
-
|
|
33
|
+
routerSeedPlan,
|
|
35
34
|
rootsNotices,
|
|
36
35
|
sha256,
|
|
37
36
|
shippedAssetPath,
|
|
@@ -40,6 +39,7 @@ import {
|
|
|
40
39
|
writeFileEnsuringDir,
|
|
41
40
|
writeUnit,
|
|
42
41
|
} from './index'
|
|
42
|
+
import { findManifestAbove, installRootAbove } from './install-root'
|
|
43
43
|
|
|
44
44
|
/** The oxlint plugins the shipped preset switches on — read from the preset, never restated. */
|
|
45
45
|
export function readOxlintPresetPlugins(pkgRoot: string): string[] {
|
|
@@ -65,17 +65,6 @@ export function parentInstallAdvice(cwd: string, parent: string, verb: string):
|
|
|
65
65
|
)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
/** The nearest ANCESTOR of `dir` (exclusive) carrying a basalt manifest, or null. */
|
|
69
|
-
export function findManifestAbove(dir: string): string | null {
|
|
70
|
-
let current = resolve(dir, '..')
|
|
71
|
-
for (;;) {
|
|
72
|
-
if (existsSync(resolve(current, MANIFEST_PATH))) return current
|
|
73
|
-
const parent = resolve(current, '..')
|
|
74
|
-
if (parent === current) return null
|
|
75
|
-
current = parent
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
68
|
/**
|
|
80
69
|
* Reconcile managed files with the shipped versions via a sha256 three-way compare.
|
|
81
70
|
*
|
|
@@ -90,8 +79,15 @@ export function sync(opts: SyncOptions = {}, invocationCwd: string = process.cwd
|
|
|
90
79
|
const syncFlags = opts.flags ?? []
|
|
91
80
|
if (conflictingProfileFlags('sync', syncFlags)) return 1
|
|
92
81
|
const project = resolveProjectDir(invocationCwd)
|
|
93
|
-
const cwd = project.dir
|
|
94
82
|
noteRelocation('sync', project)
|
|
83
|
+
// Inside the app package of a workspace the manifest is at the install root above: sync there.
|
|
84
|
+
const installAbove = project.relocatedFrom === null ? installRootAbove(project.dir) : null
|
|
85
|
+
const cwd = installAbove ?? project.dir
|
|
86
|
+
if (installAbove !== null) {
|
|
87
|
+
console.log(
|
|
88
|
+
`basalt-ui sync: ${project.dir} is a package of the install at ${installAbove}; syncing there.`,
|
|
89
|
+
)
|
|
90
|
+
}
|
|
95
91
|
|
|
96
92
|
// Profile before the refusal: init is NOT the fix for a tokens-only consumer. Declared, never
|
|
97
93
|
// inferred (the answer silences the whole reconciliation); exits 0 so `sync --check` is wirable.
|
|
@@ -114,8 +110,8 @@ export function sync(opts: SyncOptions = {}, invocationCwd: string = process.cwd
|
|
|
114
110
|
if (!existsSync(resolve(cwd, MANIFEST_PATH))) {
|
|
115
111
|
const elsewhere = findManifestAbove(cwd)
|
|
116
112
|
const refused = resolvePlacement(cwd)
|
|
117
|
-
const
|
|
118
|
-
const wouldWrite = managedFiles(refused).filter((f) => !
|
|
113
|
+
const { skipped: skippedSeeds } = routerSeedPlan(cwd, refused.appRel)
|
|
114
|
+
const wouldWrite = managedFiles(refused).filter((f) => !skippedSeeds.has(f.dest)).length
|
|
119
115
|
console.error(
|
|
120
116
|
`✖ basalt-ui sync: no ${MANIFEST_PATH} at ${cwd} — refusing to scaffold. ` +
|
|
121
117
|
`\`sync\` refreshes an EXISTING basalt install; creating one is \`basalt-ui init\`'s ` +
|
|
@@ -134,8 +130,7 @@ export function sync(opts: SyncOptions = {}, invocationCwd: string = process.cwd
|
|
|
134
130
|
const ctx = renderContext(cwd)
|
|
135
131
|
const manifest = readManifest(cwd)
|
|
136
132
|
const placement = resolvePlacement(cwd)
|
|
137
|
-
const
|
|
138
|
-
const skipped = new Set(startApp ? routerSeedDests(placement.appRel) : [])
|
|
133
|
+
const { skip: seedSkip, skipped } = routerSeedPlan(cwd, placement.appRel)
|
|
139
134
|
const files = managedFiles(placement).filter((f) => !skipped.has(f.dest))
|
|
140
135
|
|
|
141
136
|
let updated = 0
|
|
@@ -205,13 +200,22 @@ export function sync(opts: SyncOptions = {}, invocationCwd: string = process.cwd
|
|
|
205
200
|
})
|
|
206
201
|
staleForCheck += pruned.removed.length + pruned.drifted.length
|
|
207
202
|
|
|
203
|
+
// A code-routed app takes no router seeds: their manifest entries go; any file stays the consumer's.
|
|
204
|
+
const isTracked = (d: string): boolean => manifest.files[d] !== undefined
|
|
205
|
+
const codeRoutedSeeds = seedSkip === 'code-routed' ? [...skipped].filter(isTracked) : []
|
|
206
|
+
if (codeRoutedSeeds.length > 0 && !opts.check) {
|
|
207
|
+
for (const d of codeRoutedSeeds) delete manifest.files[d]
|
|
208
|
+
console.error(
|
|
209
|
+
`⚠ basalt-ui sync: code-routed app — dropped ${codeRoutedSeeds.join(', ')} from the manifest (any file is yours).`,
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
208
213
|
// Placement notices — informational, never affecting the exit code, and PERMANENT: `--check`
|
|
209
214
|
// hides them behind `--verbose` (it sits in consumers' CI chains, where three unchanging
|
|
210
215
|
// "skipped" paragraphs per run are noise indistinguishable from drift) but still prints the COUNT.
|
|
211
216
|
// Start added AFTER a pre-Start init: the old seeds are the consumer's now — left untouched, named.
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
)
|
|
217
|
+
const startSkippedSeeds = seedSkip === 'start' ? [...skipped] : []
|
|
218
|
+
const stale = startSkippedSeeds.filter((d) => isTracked(d) && existsSync(resolve(cwd, d)))
|
|
215
219
|
const mounting = stale.filter((d) => !d.endsWith('nav.tsx'))
|
|
216
220
|
const inert = stale.filter((d) => d.endsWith('nav.tsx'))
|
|
217
221
|
const embedded =
|
|
@@ -226,7 +230,7 @@ export function sync(opts: SyncOptions = {}, invocationCwd: string = process.cwd
|
|
|
226
230
|
`⚠ basalt-ui sync: ${inert.join(', ')} was seeded before this became a Start app; it mounts nothing, so keep or delete it. Left untouched.`,
|
|
227
231
|
)
|
|
228
232
|
}
|
|
229
|
-
if (
|
|
233
|
+
if (seedSkip === 'start' && (!opts.check || syncFlags.includes('--verbose')))
|
|
230
234
|
console.log(`basalt-ui sync: ${START_APP_NOTE}`)
|
|
231
235
|
const placementSkips = placementNotices(cwd, placement)
|
|
232
236
|
if (opts.check !== true || syncFlags.includes('--verbose')) {
|
package/src/cli/tokens-css.ts
CHANGED
|
@@ -168,11 +168,6 @@ export function tokensCss(flags: string[], cwd: string = process.cwd()): number
|
|
|
168
168
|
: { defaultScheme: defaultScheme as 'dark' | 'light' | 'none' }),
|
|
169
169
|
...(flags.includes('--media-fallback') ? { mediaFallback: true } : {}),
|
|
170
170
|
...(only === undefined ? {} : { only: only as 'core' | 'all' }),
|
|
171
|
-
// The tokens-only consumer is exactly the one who writes these names by hand, so they are also
|
|
172
|
-
// the one who wants the deprecated camelCase aliases gone — and this command is their only
|
|
173
|
-
// entry point. Without the flag the CLI and the API could disagree about what basalt's tokens
|
|
174
|
-
// are, which is the one thing this command is documented never to allow.
|
|
175
|
-
...(flags.includes('--no-legacy-aliases') ? { legacyAliases: false } : {}),
|
|
176
171
|
})
|
|
177
172
|
|
|
178
173
|
if (schemeClass !== undefined) {
|
package/src/common/errors.ts
CHANGED
|
@@ -39,28 +39,11 @@ export function oneOf(
|
|
|
39
39
|
)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* A prop still shipped and still working, with a named successor and the version it goes away in.
|
|
44
|
-
* Majors are banned here, so the deprecation notice IS the migration channel.
|
|
45
|
-
*/
|
|
46
|
-
export function deprecatedProp(
|
|
47
|
-
component: string,
|
|
48
|
-
oldProp: string,
|
|
49
|
-
newProp: string,
|
|
50
|
-
removeIn: string,
|
|
51
|
-
note?: string,
|
|
52
|
-
): string {
|
|
53
|
-
return message(
|
|
54
|
-
component,
|
|
55
|
-
`prop "${oldProp}" is deprecated — use "${newProp}" instead. "${oldProp}" is removed in ${removeIn}.${note === undefined ? '' : ` ${note}`}`,
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
42
|
/**
|
|
60
43
|
* A prop the component ACCEPTS, reads nothing from, and cannot report as wrong — because a SECOND
|
|
61
44
|
* prop it was passed alongside decides the same thing and won.
|
|
62
45
|
*
|
|
63
|
-
* Distinct from {@link
|
|
46
|
+
* Distinct from {@link oneOf} (read, and the
|
|
64
47
|
* value is out of range): this one renders something the caller did not ask for and nothing in the
|
|
65
48
|
* type system, the linter or the console says so. A 1.x chart's `height` under `fill` was the
|
|
66
49
|
* reference case — weatherorb passed both for the life of the file and never learnt that eight height
|
package/src/common/index.ts
CHANGED
|
@@ -9,14 +9,7 @@
|
|
|
9
9
|
export { type BasaltProps, type SlotClassNames, type SlotStylesProps } from './props'
|
|
10
10
|
export { type Tone, type ToneWithNeutral, type Tier, cx } from './props'
|
|
11
11
|
export { assignRef, mergeRefs } from './refs'
|
|
12
|
-
export {
|
|
13
|
-
BASALT_PREFIX,
|
|
14
|
-
requiredProp,
|
|
15
|
-
oneOf,
|
|
16
|
-
deprecatedProp,
|
|
17
|
-
duplicateMount,
|
|
18
|
-
missingLayer,
|
|
19
|
-
} from './errors'
|
|
12
|
+
export { BASALT_PREFIX, requiredProp, oneOf, duplicateMount, missingLayer } from './errors'
|
|
20
13
|
export { useValidateProps, assertRequiredProps, resetValidatedProps } from './validate'
|
|
21
14
|
export { scrollParentOf, SCROLLPORT_ATTRIBUTE } from './scroll-parent'
|
|
22
15
|
export { useCoarsePointer } from './use-media-query'
|
package/src/common/props.ts
CHANGED
|
@@ -45,8 +45,8 @@ export interface SlotStylesProps<S extends string> {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* The ONE status vocabulary (audit A13).
|
|
49
|
-
*
|
|
48
|
+
* The ONE status vocabulary (audit A13). Forks exist today — `SidebarBlockTone` is
|
|
49
|
+
* byte-identical to this, `CalloutKind` / `AccountBadgeTone` /
|
|
50
50
|
* `NotificationIntent` each differ — and they stay put for now: an adopter aliases its fork to this
|
|
51
51
|
* type, it does not get renamed out from under a consumer.
|
|
52
52
|
*/
|
package/src/common/vx-family.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A `--vx-*` name's FAMILY — its leading lowercase run: `--vx-surface-bg` → `surface`, `--vx-ink2`
|
|
3
|
-
* → `ink`, `--vx-
|
|
3
|
+
* → `ink`, `--vx-tooltip-bg` → `tooltip`, `--vx-fill-hover-cyan` → `fill`. Dependency-free, because
|
|
4
4
|
* three sides must agree on it byte for byte: the generator that writes `BASALT_VX_FAMILIES`, the
|
|
5
5
|
* guard that judges every name inside one of those families, and the token factories that refuse a
|
|
6
6
|
* consumer name inside one — the refusal is what makes the guard's judgement honest.
|