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/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ export {
|
|
|
21
21
|
useBasaltNav,
|
|
22
22
|
type NavItemId,
|
|
23
23
|
} from './router-tanstack'
|
|
24
|
-
export { scrollParentOf, useCoarsePointer } from './common'
|
|
24
|
+
export { scrollParentOf, useCoarsePointer, type Tone } from './common'
|
|
25
25
|
export { createBasaltTheme } from './theme'
|
|
26
26
|
export { ThemeToggle } from './theme/theme-toggle'
|
|
27
27
|
export {
|
|
@@ -41,7 +41,6 @@ export {
|
|
|
41
41
|
StatCard,
|
|
42
42
|
type StatCardBreakdownRow,
|
|
43
43
|
type StatCardSparklineSize,
|
|
44
|
-
type StatCardTone,
|
|
45
44
|
StatGroup,
|
|
46
45
|
EmptyState,
|
|
47
46
|
SettingsSection,
|
package/src/provider/index.tsx
CHANGED
|
@@ -418,8 +418,11 @@ function useDataTelemetry(router: AnyRouter, client: QueryClient, emit: Telemetr
|
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
// ── Dev dock (dev-only, behind a literal NODE_ENV read at the lazy site) ──────────────────────────
|
|
421
|
+
// The gate wraps `lazy()` itself so the dock chunks never ship; the consumer bundler must define
|
|
422
|
+
// `process.env.NODE_ENV` for the fold, as it already must for `lab-theme.ts`.
|
|
421
423
|
|
|
422
|
-
const
|
|
424
|
+
const loadDevDock = () => import('../dev-dock').then((m) => ({ default: m.BasaltDevDock }))
|
|
425
|
+
const LazyDevDock = process.env.NODE_ENV === 'production' ? null : lazy(loadDevDock)
|
|
423
426
|
|
|
424
427
|
function readQueryClient(router: AnyRouter): QueryClient {
|
|
425
428
|
const client = (router.options.context as Partial<BasaltRouterContext> | undefined)?.queryClient
|
|
@@ -523,8 +526,8 @@ export function BasaltProvider({
|
|
|
523
526
|
) : (
|
|
524
527
|
<RouterProvider router={mountedRouter} />
|
|
525
528
|
)}
|
|
526
|
-
{/*
|
|
527
|
-
{
|
|
529
|
+
{/* `LazyDevDock` is `null` in production (module-scope gate above), so nothing mounts. */}
|
|
530
|
+
{LazyDevDock !== null && (
|
|
528
531
|
<Suspense fallback={null}>
|
|
529
532
|
<LazyDevDock
|
|
530
533
|
tool={devTool}
|
|
@@ -200,17 +200,6 @@ function warnPatchDropped(input: { key: string; name: string; param: string }):
|
|
|
200
200
|
)
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
/**
|
|
204
|
-
* The public store plus the one member only the deprecated wrappers need: `markReaderWired`, so a
|
|
205
|
-
* consumer whose only reader is the wrapper's own `useStore()` still counts as wired and never sees
|
|
206
|
-
* the pinned-link warning it never used to see.
|
|
207
|
-
*
|
|
208
|
-
* @internal — absent from `SearchStore`, so it is invisible on `createSearchStore`'s return type.
|
|
209
|
-
*/
|
|
210
|
-
export type InternalSearchStore<S extends Record<string, AnyField>> = SearchStore<S> & {
|
|
211
|
-
markReaderWired: () => void
|
|
212
|
-
}
|
|
213
|
-
|
|
214
203
|
/**
|
|
215
204
|
* A thunk fallback belongs to the LOCAL and MEMORY lanes only. On the URL lane `validateSearch`
|
|
216
205
|
* would evaluate it on every navigation and write the result into the URL, so a deep link would
|
|
@@ -264,7 +253,7 @@ function isMemoryLane(entry: StoreEntry): boolean {
|
|
|
264
253
|
*/
|
|
265
254
|
export function buildSearchStore<const S extends Record<string, AnyField>>(
|
|
266
255
|
o: CreateSearchStoreOptions<S>,
|
|
267
|
-
):
|
|
256
|
+
): SearchStore<S> {
|
|
268
257
|
assertNoLazyUrlFallback(o.key, o.fields)
|
|
269
258
|
const core = createStoreCore(o)
|
|
270
259
|
|
|
@@ -570,7 +559,7 @@ export function buildSearchStore<const S extends Record<string, AnyField>>(
|
|
|
570
559
|
}
|
|
571
560
|
}
|
|
572
561
|
|
|
573
|
-
const store:
|
|
562
|
+
const store: SearchStore<S> = {
|
|
574
563
|
validateSearch,
|
|
575
564
|
linkSearch,
|
|
576
565
|
readStored,
|
|
@@ -582,7 +571,6 @@ export function buildSearchStore<const S extends Record<string, AnyField>>(
|
|
|
582
571
|
useValues,
|
|
583
572
|
useActiveCount,
|
|
584
573
|
useReset,
|
|
585
|
-
markReaderWired,
|
|
586
574
|
}
|
|
587
575
|
|
|
588
576
|
return store
|
package/src/shell/index.tsx
CHANGED
|
@@ -87,6 +87,8 @@ export {
|
|
|
87
87
|
} from './mobile-nav-model'
|
|
88
88
|
export { AppBreadcrumbs, type AppBreadcrumbsProps } from './app-breadcrumbs'
|
|
89
89
|
export { PageBar, type PageBarProps, type PageBarSlot } from './page-bar'
|
|
90
|
+
// Internal (not listed in `src/index.ts`): `Section` clears a shell-less bar with these.
|
|
91
|
+
export { PAGE_BAR_HEIGHT_VAR, useInPageBarShell } from './page-bar'
|
|
90
92
|
export { PageAside, type PageAsideProps, type PageAsideSlot } from './page-aside'
|
|
91
93
|
export { useSizeClass, type SizeClass } from './use-size-class'
|
|
92
94
|
export { PageTitle, type PageTitleProps, type PageTitleSlot } from './page-title'
|
package/src/shell/nav-types.ts
CHANGED
|
@@ -76,7 +76,7 @@ export type SidebarSection = {
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Status tone on a sidebar-block item — byte-identical to the common `Tone` vocabulary
|
|
79
|
-
* (`common/props.ts`, audit A13) and to `
|
|
79
|
+
* (`common/props.ts`, audit A13) and to `StatCard`'s `tone`, whose members are `VX.status` keys by
|
|
80
80
|
* construction. Declared here rather than aliased to `common`'s `Tone`: this module is the one
|
|
81
81
|
* `./router-tanstack` reads, and `common/props.ts` re-exports `Tier` (type-only) from
|
|
82
82
|
* `../widget-header/widget-header`, a Mantine-coupled file — importing anything from `common/props`
|
package/src/shell/page-bar.tsx
CHANGED
|
@@ -199,6 +199,15 @@ export function PageBarBandOutlet({ className }: { className?: string }) {
|
|
|
199
199
|
return <div ref={setBandTarget} className={className} />
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Internal — whether a `BasaltShell` provides this tree. `Section` reads it: inside the shell the
|
|
204
|
+
* bars sit outside the scrollport, so an anchor needs no bar offset; without one `PageBar` is
|
|
205
|
+
* sticky in the document and `Section` must clear it.
|
|
206
|
+
*/
|
|
207
|
+
export function useInPageBarShell(): boolean {
|
|
208
|
+
return useContext(PageBarContext).inShell
|
|
209
|
+
}
|
|
210
|
+
|
|
202
211
|
/** Internal — `true` while a page's `ActionGroup` owns the header's one mobile kebab. */
|
|
203
212
|
export function usePageKebabClaimed(): boolean {
|
|
204
213
|
return useContext(PageBarContext).kebabClaims > 0
|
|
@@ -300,8 +309,18 @@ export type PageBarProps = BasaltProps &
|
|
|
300
309
|
*/
|
|
301
310
|
function publishBarHeight(node: HTMLElement): void {
|
|
302
311
|
const { height } = node.getBoundingClientRect()
|
|
303
|
-
if (height
|
|
304
|
-
|
|
312
|
+
if (height <= 0) return
|
|
313
|
+
const root = document.documentElement
|
|
314
|
+
const first = root.style.getPropertyValue(PAGE_BAR_HEIGHT_VAR) === ''
|
|
315
|
+
root.style.setProperty(PAGE_BAR_HEIGHT_VAR, `${height}px`)
|
|
316
|
+
// The browser's native fragment scroll on a cold `/page#anchor` load ran BEFORE this first
|
|
317
|
+
// publish, so `Section`'s scroll-margin read the 0px fallback and the heading sits under the bar.
|
|
318
|
+
// Re-aim it once, instantly (never a smooth scroll the reader would watch). Only the FIRST
|
|
319
|
+
// publish: later height changes must not yank a reader who has since scrolled away.
|
|
320
|
+
if (first && location.hash.length > 1) {
|
|
321
|
+
document.getElementById(decodeURIComponent(location.hash.slice(1)))?.scrollIntoView({
|
|
322
|
+
behavior: 'instant',
|
|
323
|
+
})
|
|
305
324
|
}
|
|
306
325
|
}
|
|
307
326
|
|
package/src/state/fields.ts
CHANGED
|
@@ -305,7 +305,7 @@ export type LocalFieldHandle<F extends AnyField> = FieldHandle<F> & {
|
|
|
305
305
|
export type FieldHandle<F extends AnyField> = {
|
|
306
306
|
readonly kind: F['kind']
|
|
307
307
|
readonly fallback: FieldValue<F>
|
|
308
|
-
/** enum / multi / range options, labelled by `labels()`.
|
|
308
|
+
/** enum / multi / range options, labelled by `labels()`. A number lists only the values `labels()` names; empty for the other kinds. */
|
|
309
309
|
readonly options: readonly FieldOption[]
|
|
310
310
|
/**
|
|
311
311
|
* Read + write. Reads the URL when the field is on the URL lane (`useSearch({ strict: false })`,
|
|
@@ -986,7 +986,12 @@ export function createStoreCore(o: StoreCoreOptions): StoreCore {
|
|
|
986
986
|
const readRecord = (): StoreRecord => toRecord(readPersistedValue(o.key, version))
|
|
987
987
|
|
|
988
988
|
const optionsFor = (entry: StoreEntry): readonly FieldOption[] => {
|
|
989
|
-
|
|
989
|
+
const named = labels.get(entry.name)
|
|
990
|
+
// A number has no closed value set, so its options are exactly the values `labels()` names —
|
|
991
|
+
// `{ 0: 'Any' }` names the unset state of a threshold, and `NumberFilter`'s pill reads it.
|
|
992
|
+
const values =
|
|
993
|
+
entry.codec.kind === 'number' ? Object.keys(named ?? {}) : entry.codec.optionValues
|
|
994
|
+
return labelledOptions(values, named)
|
|
990
995
|
}
|
|
991
996
|
|
|
992
997
|
const clearField = (name: string): void => {
|
package/src/surfaces.ts
CHANGED
|
@@ -391,10 +391,8 @@ export const SURFACES = {
|
|
|
391
391
|
rule: 'batteries',
|
|
392
392
|
skill: ['basalt-design'],
|
|
393
393
|
guardKinds: [],
|
|
394
|
-
// The one
|
|
395
|
-
//
|
|
396
|
-
// only stops resetting. `warn` through the 1.30.0 grace because it fires on what every
|
|
397
|
-
// consumer ships today (`PLUGIN_RULE_GRACE`).
|
|
394
|
+
// The one forms change a compiler cannot see: `inputProps` does not return `key`, and the old
|
|
395
|
+
// spread still type-checks, renders and validates — it only stops resetting.
|
|
398
396
|
pluginRules: ['forms-field-key'],
|
|
399
397
|
description:
|
|
400
398
|
'Mantine form layer: useBasaltForm + inputProps/fieldKey (two calls — a spread `key` is a React 19 warning), on @mantine/form',
|
|
@@ -421,7 +419,7 @@ export const SURFACES = {
|
|
|
421
419
|
guardKinds: [],
|
|
422
420
|
pluginRules: [],
|
|
423
421
|
description:
|
|
424
|
-
'BasaltDataTable and createColumnHelper: a data table over TanStack Table v9, rendered with Mantine
|
|
422
|
+
'BasaltDataTable and createColumnHelper: a data table over TanStack Table v9, rendered with Mantine',
|
|
425
423
|
optionalPeers: ['@tanstack/react-table'],
|
|
426
424
|
forbiddenImports: [],
|
|
427
425
|
},
|
|
@@ -480,12 +478,8 @@ export const SURFACES = {
|
|
|
480
478
|
// The text lane of law C1 — the plugin's `control-outside-home` seen through a host-tag nesting
|
|
481
479
|
// count, since a regex scan has no AST. Same law, same wave, same promotion.
|
|
482
480
|
guardKinds: ['raw-selection-control'],
|
|
483
|
-
// The control tier itself (laws C1/C3/C5/C9)
|
|
484
|
-
// `
|
|
485
|
-
// `PLUGIN_RULE_GRACE`, both promoting at 1.30.0 — `control-outside-home` re-dated against the
|
|
486
|
-
// wave-7 measurement, `bound-control-outside-home` new since 1.28.0 (ASIDE-SPEC G5: the basalt
|
|
487
|
-
// half of C1, where a bound control in a section body rendered as a stray pill). The action
|
|
488
|
-
// budgets are types now (`PageBarActions` / `SectionActions`, `controls/actions.tsx`).
|
|
481
|
+
// The control tier itself (laws C1/C3/C5/C9), every rule at `error`. The action budgets are
|
|
482
|
+
// types (`PageBarActions` / `SectionActions`, `controls/actions.tsx`).
|
|
489
483
|
pluginRules: [
|
|
490
484
|
'hand-rolled-filter',
|
|
491
485
|
'control-outside-home',
|
package/src/table/data-table.tsx
CHANGED
|
@@ -672,8 +672,8 @@ export type BasaltDataTableProps<T extends RowData> = BasaltProps &
|
|
|
672
672
|
manualFiltering?: boolean
|
|
673
673
|
/**
|
|
674
674
|
* Right-aligned toolbar slot (e.g. an "Export" button). Renders the toolbar row even when no
|
|
675
|
-
* search input or facets are configured.
|
|
676
|
-
*
|
|
675
|
+
* search input or facets are configured. The toolbar (search + facets + this slot) is wrapped
|
|
676
|
+
* in `CtlSlot` (C1/C5), so its controls resolve to the `ctl` tier.
|
|
677
677
|
*
|
|
678
678
|
* Two accepted forms (law C15): a typed `BarAction[]`, projected through the same row `PageBar`
|
|
679
679
|
* and `ActionGroup` use — ≤3 inline, the rest folded into `More`, one kebab below `sm` — or an
|
package/src/tokens/core.ts
CHANGED
|
@@ -192,9 +192,6 @@ export const VX = {
|
|
|
192
192
|
sheetRowHeight: 'var(--vx-space-sheet-row-height)',
|
|
193
193
|
},
|
|
194
194
|
|
|
195
|
-
// Secondary-line color (back-compat alias; now theme-aware via --vx-line2)
|
|
196
|
-
line2Dark: 'var(--vx-line2)',
|
|
197
|
-
|
|
198
195
|
// Semantic fills — consistent opacity across all charts
|
|
199
196
|
good: 'var(--vx-good)',
|
|
200
197
|
goodSoft: 'var(--vx-good-soft)',
|
|
@@ -356,41 +353,12 @@ const groupSide = (prefix: string, map: SeriesMap, side: Side): string =>
|
|
|
356
353
|
.map(([key, pair]) => decl(`${prefix}${key}`, pair[side]))
|
|
357
354
|
.join('\n')
|
|
358
355
|
|
|
359
|
-
/**
|
|
360
|
-
* The 16 deprecated camelCase aliases for `frameworkPrimitives`' per-scheme canonicals, each
|
|
361
|
-
* defined as `var(--vx-<canonical-kebab-name>)` so it can never drift from the value above it.
|
|
362
|
-
* Emitted as its own commented, trailing group (never interleaved with the canonicals) — gated by
|
|
363
|
-
* {@link BuildPaletteOpts.legacyAliases}, default on. See that option's doc for the migration
|
|
364
|
-
* rationale (1.4.0 kebab-case normalization).
|
|
365
|
-
*/
|
|
366
|
-
function frameworkPrimitivesAliases(): string {
|
|
367
|
-
return [
|
|
368
|
-
' /* Deprecated camelCase aliases — removed in a future minor; migrate to the kebab names above. */',
|
|
369
|
-
decl('goodSolid', 'var(--vx-good-solid)'),
|
|
370
|
-
decl('badSolid', 'var(--vx-bad-solid)'),
|
|
371
|
-
decl('warnSolid', 'var(--vx-warn-solid)'),
|
|
372
|
-
decl('axisStroke', 'var(--vx-axis-stroke)'),
|
|
373
|
-
decl('dotStroke', 'var(--vx-dot-stroke)'),
|
|
374
|
-
decl('tooltipBg', 'var(--vx-tooltip-bg)'),
|
|
375
|
-
decl('tooltipText', 'var(--vx-tooltip-text)'),
|
|
376
|
-
decl('tooltipMuted', 'var(--vx-tooltip-muted)'),
|
|
377
|
-
decl('tooltipBorder', 'var(--vx-tooltip-border)'),
|
|
378
|
-
decl('tooltipShadow', 'var(--vx-tooltip-shadow)'),
|
|
379
|
-
decl('legendText', 'var(--vx-legend-text)'),
|
|
380
|
-
decl('accentHover', 'var(--vx-accent-hover)'),
|
|
381
|
-
decl('accentFill', 'var(--vx-accent-fill)'),
|
|
382
|
-
decl('accentFillHover', 'var(--vx-accent-fill-hover)'),
|
|
383
|
-
decl('onAccent', 'var(--vx-on-accent)'),
|
|
384
|
-
decl('surface-panelHover', 'var(--vx-surface-panel-hover)'),
|
|
385
|
-
].join('\n')
|
|
386
|
-
}
|
|
387
|
-
|
|
388
356
|
/**
|
|
389
357
|
* Built-in framework primitives for a given scheme side — STATUS group, semantic solids,
|
|
390
358
|
* neutral line/axis/grid/tooltip chrome, legend text, and the surface ramp. Domain series
|
|
391
359
|
* (SERIES/ACTIVITY/USAGE) are NOT shipped — apps append them via `opts.groups`.
|
|
392
360
|
*/
|
|
393
|
-
function frameworkPrimitives(side: Side, data: PaletteData
|
|
361
|
+
function frameworkPrimitives(side: Side, data: PaletteData): string {
|
|
394
362
|
const n = data.NEUTRAL
|
|
395
363
|
const s = data.SEMANTIC
|
|
396
364
|
const su = data.SURFACE
|
|
@@ -439,7 +407,7 @@ function frameworkPrimitives(side: Side, data: PaletteData, legacyAliases: boole
|
|
|
439
407
|
decl('surface-border', su.border[side]),
|
|
440
408
|
decl('surface-hairline', su.hairline[side]),
|
|
441
409
|
].join('\n')
|
|
442
|
-
return
|
|
410
|
+
return canonical
|
|
443
411
|
}
|
|
444
412
|
|
|
445
413
|
/**
|
|
@@ -698,32 +666,13 @@ const DEFAULT_SPACE_VALUES: SpaceValues = {
|
|
|
698
666
|
rowLineHeight: ROW_LINE_HEIGHT,
|
|
699
667
|
}
|
|
700
668
|
|
|
701
|
-
/**
|
|
702
|
-
* The 16 deprecated camelCase aliases for `frameworkDerived`'s theme-independent (`:root`)
|
|
703
|
-
* canonicals — the 12 `fill-hover-<family>` fills plus `good-soft`/`good-ref`/`bad-ref`/`warn-ref`.
|
|
704
|
-
* Each is a `var(--vx-<canonical-kebab-name>)` ref so it can never drift. Emitted as its own
|
|
705
|
-
* commented, trailing group — gated by {@link BuildPaletteOpts.legacyAliases}, default on.
|
|
706
|
-
*/
|
|
707
|
-
function frameworkDerivedAliases(data: PaletteData): string {
|
|
708
|
-
return [
|
|
709
|
-
' /* Deprecated camelCase aliases — removed in a future minor; migrate to the kebab names above. */',
|
|
710
|
-
...Object.keys(data.FILL).map((name) =>
|
|
711
|
-
decl(`fillHover-${name}`, `var(--vx-fill-hover-${name})`),
|
|
712
|
-
),
|
|
713
|
-
decl('goodSoft', 'var(--vx-good-soft)'),
|
|
714
|
-
decl('goodRef', 'var(--vx-good-ref)'),
|
|
715
|
-
decl('badRef', 'var(--vx-bad-ref)'),
|
|
716
|
-
decl('warnRef', 'var(--vx-warn-ref)'),
|
|
717
|
-
].join('\n')
|
|
718
|
-
}
|
|
719
|
-
|
|
720
669
|
/**
|
|
721
670
|
* Theme-independent scalars + semantic fills, defined once on `:root`.
|
|
722
671
|
*
|
|
723
672
|
* Area-gradient strength is a global knob (the theme lab overrides these two on `:root`
|
|
724
673
|
* to retune every line-area fill live). 0%/0% disables gradients app-wide.
|
|
725
674
|
*/
|
|
726
|
-
function frameworkDerived(data: PaletteData, only: 'core' | 'all'
|
|
675
|
+
function frameworkDerived(data: PaletteData, only: 'core' | 'all'): string {
|
|
727
676
|
const space = spaceDecls(DEFAULT_SPACE_VALUES)
|
|
728
677
|
const canonical = [
|
|
729
678
|
decl('radius-card', `${RADIUS.card}px`),
|
|
@@ -768,7 +717,7 @@ function frameworkDerived(data: PaletteData, only: 'core' | 'all', legacyAliases
|
|
|
768
717
|
decl('bad-ref', 'color-mix(in srgb, var(--vx-bad-solid) 30%, transparent)'),
|
|
769
718
|
decl('warn-ref', 'color-mix(in srgb, var(--vx-warn-solid) 20%, transparent)'),
|
|
770
719
|
].join('\n')
|
|
771
|
-
return
|
|
720
|
+
return canonical
|
|
772
721
|
}
|
|
773
722
|
|
|
774
723
|
/**
|
|
@@ -925,15 +874,6 @@ export type BuildPaletteOpts = {
|
|
|
925
874
|
* — see {@link CORE_SPACE_VARS}.
|
|
926
875
|
*/
|
|
927
876
|
only?: 'core' | 'all'
|
|
928
|
-
/**
|
|
929
|
-
* Whether to also emit the 32 deprecated camelCase aliases (`--vx-accentFill`, `--vx-tooltipBg`,
|
|
930
|
-
* `--vx-fillHover-gray`, …) alongside the canonical kebab-case names the 1.4.0 normalization
|
|
931
|
-
* introduced. Default: `true`, so an existing consumer's hand-written CSS referencing a
|
|
932
|
-
* camelCase name keeps resolving. Each alias is defined as `var(--vx-<canonical>)` — it can
|
|
933
|
-
* never drift from the value it aliases. Pass `false` once every reference in your own code has
|
|
934
|
-
* migrated to the kebab names to drop the extra 32 lines.
|
|
935
|
-
*/
|
|
936
|
-
legacyAliases?: boolean
|
|
937
877
|
}
|
|
938
878
|
|
|
939
879
|
/** Mantine's own color-scheme attribute — the default {@link ColorSchemeSelector.attribute}. */
|
|
@@ -1025,10 +965,9 @@ export function buildPaletteCss(
|
|
|
1025
965
|
data: PaletteData = buildPaletteData(),
|
|
1026
966
|
): string {
|
|
1027
967
|
const groups = opts.groups ?? []
|
|
1028
|
-
const legacyAliases = opts.legacyAliases ?? true
|
|
1029
968
|
const only = opts.only ?? 'all'
|
|
1030
969
|
const extraDerived = (opts.derived ?? []).map((d) => ` ${d}`).join('\n')
|
|
1031
|
-
const derivedBlock = frameworkDerived(data, only
|
|
970
|
+
const derivedBlock = frameworkDerived(data, only)
|
|
1032
971
|
const derived = extraDerived ? `${derivedBlock}\n${extraDerived}` : derivedBlock
|
|
1033
972
|
const side = (s: Side): string => {
|
|
1034
973
|
const extra = groups
|
|
@@ -1042,7 +981,7 @@ export function buildPaletteCss(
|
|
|
1042
981
|
return groupSide(payload.prefix, payload.map, s)
|
|
1043
982
|
})
|
|
1044
983
|
.join('\n')
|
|
1045
|
-
const framework = frameworkPrimitives(s, data
|
|
984
|
+
const framework = frameworkPrimitives(s, data)
|
|
1046
985
|
return extra ? `${framework}\n${extra}` : framework
|
|
1047
986
|
}
|
|
1048
987
|
// The scalars, then the ONE `@media` block that re-points two of them below `sm` (see
|
package/src/vite-boot.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-boot.ts — the anti-FOUC boot subsystem of `basaltAppPlugin`: the unlayered `<style>` that
|
|
3
|
+
* paints the page before any stylesheet lands, and the tiny inline script that makes that paint
|
|
4
|
+
* follow the scheme the user last stored.
|
|
5
|
+
*
|
|
6
|
+
* Internal to the `./vite` subpath only — deliberately NOT re-exported from `vite.ts`.
|
|
7
|
+
*/
|
|
8
|
+
import type { HtmlTagDescriptor } from 'vite'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The selector every anti-FOUC declaration is scoped to.
|
|
12
|
+
*
|
|
13
|
+
* The rule paints the page before any stylesheet lands, so it is UNLAYERED by construction — and an
|
|
14
|
+
* unlayered declaration outranks every layered one regardless of specificity. Through 1.20.0 that
|
|
15
|
+
* meant a flat `html{color-scheme:dark}` permanently beat Mantine's own
|
|
16
|
+
* `@layer mantine{:root{color-scheme:var(--mantine-color-scheme)}}`: a light-scheme consumer got
|
|
17
|
+
* dark scrollbars, dark `<select>` popups and dark date pickers forever, with no opt-out (found
|
|
18
|
+
* independently by two consumers).
|
|
19
|
+
*
|
|
20
|
+
* `MantineProvider` writes `data-mantine-color-scheme` onto `<html>` as soon as it mounts, so
|
|
21
|
+
* scoping the boot rule to its ABSENCE makes it expire exactly when the real theme exists — which
|
|
22
|
+
* is the anti-FOUC contract stated honestly. A cascade layer would also work in principle and is
|
|
23
|
+
* deliberately NOT used: a layer's position is fixed by where its name is first encountered, and in
|
|
24
|
+
* dev Mantine's CSS is injected by JS after this `<style>` is already in the document, so the layer
|
|
25
|
+
* order would depend on bundler mode. Selector scoping depends on nothing.
|
|
26
|
+
*/
|
|
27
|
+
const BOOT_SCOPE = 'html:not([data-mantine-color-scheme])'
|
|
28
|
+
|
|
29
|
+
/** Boot-only attribute `BOOT_SCRIPT` sets; never `data-mantine-color-scheme`, which would expire the rule. */
|
|
30
|
+
const BOOT_ATTRIBUTE = 'data-basalt-boot'
|
|
31
|
+
|
|
32
|
+
/** Mantine's default `localStorageColorSchemeManager` key — BasaltProvider installs no manager of its own. */
|
|
33
|
+
const BOOT_STORAGE_KEY = 'mantine-color-scheme-value'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Stored value is Mantine's raw `light` | `dark` | `auto` string; `auto` resolves through
|
|
37
|
+
* `prefers-color-scheme`. A throwing or empty store, or a missing `matchMedia`, leaves the
|
|
38
|
+
* attribute off. IIFE + `let`: a classic inline script shares the page's global scope.
|
|
39
|
+
*/
|
|
40
|
+
const BOOT_SCRIPT =
|
|
41
|
+
'(function(){try{' +
|
|
42
|
+
`let v=localStorage.getItem('${BOOT_STORAGE_KEY}');` +
|
|
43
|
+
"if(v==='auto')v=matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';" +
|
|
44
|
+
`if(v==='light'||v==='dark')document.documentElement.setAttribute('${BOOT_ATTRIBUTE}',v)` +
|
|
45
|
+
'}catch(e){}})()'
|
|
46
|
+
|
|
47
|
+
/** The `color-scheme` value each boot mode declares. `false` declares none. */
|
|
48
|
+
const BOOT_COLOR_SCHEME = { dark: 'dark', light: 'light', auto: 'light dark' } as const
|
|
49
|
+
|
|
50
|
+
/** The `colorScheme` option: which scheme the boot paint assumes; `false` declares no `color-scheme`. */
|
|
51
|
+
export type BootColorScheme = 'dark' | 'light' | 'auto' | false
|
|
52
|
+
|
|
53
|
+
type BootInput = {
|
|
54
|
+
colorScheme: BootColorScheme
|
|
55
|
+
themeColor: { light: string; dark: string }
|
|
56
|
+
backgroundColor: string
|
|
57
|
+
explicitBackground: boolean
|
|
58
|
+
/** Inject the stored-scheme script and the variant rules it drives. */
|
|
59
|
+
bootScript: boolean
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The base rule: paint the surface (and, unless opted out, tell the UA which native-control palette
|
|
64
|
+
* to use) for the frames between first paint and Mantine's stylesheet.
|
|
65
|
+
*
|
|
66
|
+
* `'auto'` with no explicit `backgroundColor` emits a `prefers-color-scheme` pair so the pre-boot
|
|
67
|
+
* paint follows the OS the same way `color-scheme: light dark` does; an explicit `backgroundColor`
|
|
68
|
+
* is used verbatim for both, since the consumer has named one color on purpose.
|
|
69
|
+
*/
|
|
70
|
+
function buildBaseBootStyle(input: BootInput): string {
|
|
71
|
+
const { colorScheme, themeColor, backgroundColor, explicitBackground } = input
|
|
72
|
+
|
|
73
|
+
if (colorScheme === false) return `${BOOT_SCOPE}{background-color:${backgroundColor}}`
|
|
74
|
+
|
|
75
|
+
const scheme = BOOT_COLOR_SCHEME[colorScheme]
|
|
76
|
+
if (colorScheme !== 'auto' || explicitBackground) {
|
|
77
|
+
return `${BOOT_SCOPE}{background-color:${backgroundColor};color-scheme:${scheme}}`
|
|
78
|
+
}
|
|
79
|
+
return (
|
|
80
|
+
`${BOOT_SCOPE}{background-color:${themeColor.light};color-scheme:${scheme}}` +
|
|
81
|
+
`@media(prefers-color-scheme:dark){${BOOT_SCOPE}{background-color:${themeColor.dark}}}`
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function buildBootStyle(input: BootInput): string {
|
|
86
|
+
const { colorScheme, themeColor, explicitBackground, bootScript } = input
|
|
87
|
+
const base = buildBaseBootStyle(input)
|
|
88
|
+
if (!bootScript) return base
|
|
89
|
+
|
|
90
|
+
// Stored-scheme variants: keyed off the attribute BOOT_SCRIPT sets, still inside BOOT_SCOPE so
|
|
91
|
+
// they expire with the rest. The extra attribute outranks the base rule and its `auto` media pair.
|
|
92
|
+
// An explicit backgroundColor is the consumer's one chosen color — only `color-scheme` follows.
|
|
93
|
+
const variants = (['light', 'dark'] as const).map((scheme) => {
|
|
94
|
+
const declarations = [
|
|
95
|
+
...(explicitBackground ? [] : [`background-color:${themeColor[scheme]}`]),
|
|
96
|
+
...(colorScheme === false ? [] : [`color-scheme:${scheme}`]),
|
|
97
|
+
]
|
|
98
|
+
if (declarations.length === 0) return ''
|
|
99
|
+
return `${BOOT_SCOPE}[${BOOT_ATTRIBUTE}=${scheme}]{${declarations.join(';')}}`
|
|
100
|
+
})
|
|
101
|
+
return base + variants.join('')
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The boot `<style>`, then (unless `bootScript: false`) the script — adjacent, head-prepend. */
|
|
105
|
+
export function buildBootTags(input: BootInput): HtmlTagDescriptor[] {
|
|
106
|
+
const tags: HtmlTagDescriptor[] = [{ tag: 'style', children: buildBootStyle(input) }]
|
|
107
|
+
if (input.bootScript) tags.push({ tag: 'script', children: BOOT_SCRIPT })
|
|
108
|
+
return tags
|
|
109
|
+
}
|
package/src/vite.ts
CHANGED
|
@@ -23,6 +23,8 @@ import { dirname, resolve } from 'node:path'
|
|
|
23
23
|
import { searchForWorkspaceRoot } from 'vite'
|
|
24
24
|
import type { HtmlTagDescriptor, Plugin, PluginOption, UserConfig } from 'vite'
|
|
25
25
|
import { SURFACE } from './tokens/palette'
|
|
26
|
+
import { buildBootTags } from './vite-boot'
|
|
27
|
+
import type { BootColorScheme } from './vite-boot'
|
|
26
28
|
import { resolveColorMix } from './vite-color-mix'
|
|
27
29
|
|
|
28
30
|
type BasaltViteOptions = {
|
|
@@ -243,9 +245,29 @@ type BasaltAppOptions = {
|
|
|
243
245
|
*
|
|
244
246
|
* Set this to whatever the app passes as `defaultColorScheme` — a mismatch is a visible flash of
|
|
245
247
|
* the wrong surface, not a correctness bug: the boot rule stops applying the moment Mantine
|
|
246
|
-
* writes `data-mantine-color-scheme` on `<html>` (see `
|
|
248
|
+
* writes `data-mantine-color-scheme` on `<html>` (see `./vite-boot.ts`).
|
|
247
249
|
*/
|
|
248
|
-
colorScheme?:
|
|
250
|
+
colorScheme?: BootColorScheme
|
|
251
|
+
/**
|
|
252
|
+
* Default `true`. Injects a ~300-byte inline `<script>` that reads the scheme the user last chose
|
|
253
|
+
* (Mantine's default `mantine-color-scheme-value` localStorage key — `light`, `dark` or `auto`,
|
|
254
|
+
* `auto` resolved through `prefers-color-scheme`) and sets a boot-only `data-basalt-boot`
|
|
255
|
+
* attribute on `<html>`, so the pre-boot paint matches the stored scheme instead of the build-time
|
|
256
|
+
* `colorScheme`. Storage unavailable or unset → the `colorScheme` paint stands. The script never
|
|
257
|
+
* writes `data-mantine-color-scheme`, so the boot rule still expires when Mantine mounts.
|
|
258
|
+
*
|
|
259
|
+
* `colorScheme: false` still gets the stored-scheme background paint; only `color-scheme` is
|
|
260
|
+
* suppressed. A stored value wins over the build-time `colorScheme`: an app that removes its scheme toggle
|
|
261
|
+
* should clear the stored key or set `bootScript: false`.
|
|
262
|
+
*
|
|
263
|
+
* CSP: Vite stamps `html.cspNonce` onto every `<script>`/`<style>` in the transformed HTML,
|
|
264
|
+
* plugin-injected ones included, so one nonce covers both boot tags. Without a nonce, a CSP that
|
|
265
|
+
* forbids inline scripts needs `bootScript: false`.
|
|
266
|
+
*
|
|
267
|
+
* Also set `false` when `BasaltProvider` gets a custom `colorSchemeManager` with another key
|
|
268
|
+
* (e.g. `localStorageColorSchemeManager({ key })`) — the script reads only the default key.
|
|
269
|
+
*/
|
|
270
|
+
bootScript?: boolean
|
|
249
271
|
/**
|
|
250
272
|
* Manifest `background_color` + anti-FOUC paint color. Default: the theme color matching
|
|
251
273
|
* `colorScheme` (the dark one for `'dark'` / `'auto'` / `false`, the light one for `'light'`).
|
|
@@ -409,58 +431,6 @@ const VIEWPORT_TAG: HtmlTagDescriptor = {
|
|
|
409
431
|
attrs: { name: 'viewport', content: 'width=device-width, initial-scale=1.0, viewport-fit=cover' },
|
|
410
432
|
}
|
|
411
433
|
|
|
412
|
-
// ── The anti-FOUC boot rule ───────────────────────────────────────────────────────────────────
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* The selector every anti-FOUC declaration is scoped to.
|
|
416
|
-
*
|
|
417
|
-
* The rule paints the page before any stylesheet lands, so it is UNLAYERED by construction — and an
|
|
418
|
-
* unlayered declaration outranks every layered one regardless of specificity. Through 1.20.0 that
|
|
419
|
-
* meant a flat `html{color-scheme:dark}` permanently beat Mantine's own
|
|
420
|
-
* `@layer mantine{:root{color-scheme:var(--mantine-color-scheme)}}`: a light-scheme consumer got
|
|
421
|
-
* dark scrollbars, dark `<select>` popups and dark date pickers forever, with no opt-out (found
|
|
422
|
-
* independently by two consumers).
|
|
423
|
-
*
|
|
424
|
-
* `MantineProvider` writes `data-mantine-color-scheme` onto `<html>` as soon as it mounts, so
|
|
425
|
-
* scoping the boot rule to its ABSENCE makes it expire exactly when the real theme exists — which
|
|
426
|
-
* is the anti-FOUC contract stated honestly. A cascade layer would also work in principle and is
|
|
427
|
-
* deliberately NOT used: a layer's position is fixed by where its name is first encountered, and in
|
|
428
|
-
* dev Mantine's CSS is injected by JS after this `<style>` is already in the document, so the layer
|
|
429
|
-
* order would depend on bundler mode. Selector scoping depends on nothing.
|
|
430
|
-
*/
|
|
431
|
-
const BOOT_SCOPE = 'html:not([data-mantine-color-scheme])'
|
|
432
|
-
|
|
433
|
-
/** The `color-scheme` value each boot mode declares. `false` declares none. */
|
|
434
|
-
const BOOT_COLOR_SCHEME = { dark: 'dark', light: 'light', auto: 'light dark' } as const
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Builds the anti-FOUC stylesheet: paint the surface (and, unless opted out, tell the UA which
|
|
438
|
-
* native-control palette to use) for the frames between first paint and Mantine's stylesheet.
|
|
439
|
-
*
|
|
440
|
-
* `'auto'` with no explicit `backgroundColor` emits a `prefers-color-scheme` pair so the pre-boot
|
|
441
|
-
* paint follows the OS the same way `color-scheme: light dark` does; an explicit `backgroundColor`
|
|
442
|
-
* is used verbatim for both, since the consumer has named one color on purpose.
|
|
443
|
-
*/
|
|
444
|
-
function buildBootStyle(input: {
|
|
445
|
-
colorScheme: 'dark' | 'light' | 'auto' | false
|
|
446
|
-
themeColor: { light: string; dark: string }
|
|
447
|
-
backgroundColor: string
|
|
448
|
-
explicitBackground: boolean
|
|
449
|
-
}): string {
|
|
450
|
-
const { colorScheme, themeColor, backgroundColor, explicitBackground } = input
|
|
451
|
-
|
|
452
|
-
if (colorScheme === false) return `${BOOT_SCOPE}{background-color:${backgroundColor}}`
|
|
453
|
-
|
|
454
|
-
const scheme = BOOT_COLOR_SCHEME[colorScheme]
|
|
455
|
-
if (colorScheme !== 'auto' || explicitBackground) {
|
|
456
|
-
return `${BOOT_SCOPE}{background-color:${backgroundColor};color-scheme:${scheme}}`
|
|
457
|
-
}
|
|
458
|
-
return (
|
|
459
|
-
`${BOOT_SCOPE}{background-color:${themeColor.light};color-scheme:${scheme}}` +
|
|
460
|
-
`@media(prefers-color-scheme:dark){${BOOT_SCOPE}{background-color:${themeColor.dark}}}`
|
|
461
|
-
)
|
|
462
|
-
}
|
|
463
|
-
|
|
464
434
|
// ── The encoding declaration ──────────────────────────────────────────────────────────────────
|
|
465
435
|
|
|
466
436
|
/** `<meta charset="…">`, with the value in group 1/2/3 depending on the quoting style. */
|
|
@@ -549,7 +519,7 @@ function buildStaticTags(input: {
|
|
|
549
519
|
options: BasaltAppOptions
|
|
550
520
|
shortName: string
|
|
551
521
|
themeColor: { light: string; dark: string }
|
|
552
|
-
|
|
522
|
+
bootTags: HtmlTagDescriptor[]
|
|
553
523
|
icons: ResolvedIcons
|
|
554
524
|
darkreader: 'lock' | false
|
|
555
525
|
manifestEnabled: boolean
|
|
@@ -560,7 +530,7 @@ function buildStaticTags(input: {
|
|
|
560
530
|
options,
|
|
561
531
|
shortName,
|
|
562
532
|
themeColor,
|
|
563
|
-
|
|
533
|
+
bootTags,
|
|
564
534
|
icons,
|
|
565
535
|
darkreader,
|
|
566
536
|
manifestEnabled,
|
|
@@ -592,8 +562,8 @@ function buildStaticTags(input: {
|
|
|
592
562
|
// Anti-FOUC — paints the boot surface before any stylesheet loads. injectTo defaults to
|
|
593
563
|
// 'head-prepend', so this (and every tag below) lands immediately after <head> and the hoisted
|
|
594
564
|
// <meta charset>, ahead of the consumer's own <link rel="stylesheet"> tags. Scoped to
|
|
595
|
-
// BOOT_SCOPE so it expires the moment Mantine resolves the real scheme — see
|
|
596
|
-
tags.push(
|
|
565
|
+
// BOOT_SCOPE so it expires the moment Mantine resolves the real scheme — see ./vite-boot.ts.
|
|
566
|
+
tags.push(...bootTags)
|
|
597
567
|
|
|
598
568
|
if (icons.mode === 'default') {
|
|
599
569
|
tags.push(
|
|
@@ -763,11 +733,12 @@ function createMainPlugin(options: BasaltAppOptions): Plugin {
|
|
|
763
733
|
const colorScheme = options.colorScheme ?? 'dark'
|
|
764
734
|
const schemeColor = colorScheme === 'light' ? themeColor.light : themeColor.dark
|
|
765
735
|
const backgroundColor = options.backgroundColor ?? schemeColor
|
|
766
|
-
const
|
|
736
|
+
const bootTags = buildBootTags({
|
|
767
737
|
colorScheme,
|
|
768
738
|
themeColor,
|
|
769
739
|
backgroundColor,
|
|
770
740
|
explicitBackground: options.backgroundColor !== undefined,
|
|
741
|
+
bootScript: options.bootScript !== false,
|
|
771
742
|
})
|
|
772
743
|
|
|
773
744
|
// Icon hrefs, the manifest link, and the manifest's start_url/scope/icon src all depend on
|
|
@@ -805,7 +776,7 @@ function createMainPlugin(options: BasaltAppOptions): Plugin {
|
|
|
805
776
|
options,
|
|
806
777
|
shortName,
|
|
807
778
|
themeColor,
|
|
808
|
-
|
|
779
|
+
bootTags,
|
|
809
780
|
icons,
|
|
810
781
|
darkreader,
|
|
811
782
|
manifestEnabled,
|
|
@@ -907,7 +878,7 @@ function createServiceWorkerPlugin(
|
|
|
907
878
|
* • It HOISTS the shell's `<meta charset>` ahead of everything it injects, so the encoding
|
|
908
879
|
* declaration stays inside the spec's first 1024 bytes (see `hoistCharset`).
|
|
909
880
|
* • The anti-FOUC `<style>` expires the moment Mantine resolves the real scheme, and `colorScheme`
|
|
910
|
-
* selects which surface it paints until then (see `
|
|
881
|
+
* selects which surface it paints until then (see `./vite-boot.ts`).
|
|
911
882
|
*
|
|
912
883
|
* @example
|
|
913
884
|
* // vite.config.ts
|