basalt-ui 2.8.0 → 2.8.1

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +186 -190
  2. package/MIGRATING.md +52 -13
  3. package/dist/cli/doctor-upgrade.d.ts +5 -4
  4. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  5. package/dist/cli/doctor-upgrade.js +23 -99
  6. package/dist/cli/doctor.d.ts +2 -1
  7. package/dist/cli/doctor.d.ts.map +1 -1
  8. package/dist/cli/doctor.js +17 -13
  9. package/dist/cli/index.d.ts +15 -6
  10. package/dist/cli/index.d.ts.map +1 -1
  11. package/dist/cli/index.js +16 -27
  12. package/dist/cli/init.d.ts.map +1 -1
  13. package/dist/cli/init.js +9 -6
  14. package/dist/cli/router-wiring.d.ts +37 -0
  15. package/dist/cli/router-wiring.d.ts.map +1 -0
  16. package/dist/cli/router-wiring.js +116 -0
  17. package/dist/cli/source-text.d.ts +12 -0
  18. package/dist/cli/source-text.d.ts.map +1 -0
  19. package/dist/cli/source-text.js +46 -0
  20. package/dist/cli/sync.d.ts.map +1 -1
  21. package/dist/cli/sync.js +15 -10
  22. package/dist/content/code-block.d.ts.map +1 -1
  23. package/dist/content/code-block.js +36 -27
  24. package/dist/content/code-block.module.css +19 -1
  25. package/dist/content/mermaid-sanitize.d.ts +15 -0
  26. package/dist/content/mermaid-sanitize.d.ts.map +1 -0
  27. package/dist/content/mermaid-sanitize.js +28 -0
  28. package/dist/content/mermaid.d.ts +6 -0
  29. package/dist/content/mermaid.d.ts.map +1 -1
  30. package/dist/content/mermaid.js +3 -1
  31. package/dist/provider/index.d.ts.map +1 -1
  32. package/dist/provider/index.js +3 -2
  33. package/dist/vite-boot.d.ts +25 -0
  34. package/dist/vite-boot.d.ts.map +1 -0
  35. package/dist/vite-boot.js +36 -0
  36. package/dist/vite.d.ts +24 -3
  37. package/dist/vite.d.ts.map +1 -1
  38. package/dist/vite.js +7 -16
  39. package/llms.txt +4 -3
  40. package/package.json +1 -1
  41. package/src/cli/doctor-upgrade.ts +29 -145
  42. package/src/cli/doctor.ts +19 -14
  43. package/src/cli/index.ts +26 -41
  44. package/src/cli/init.ts +9 -6
  45. package/src/cli/router-wiring.ts +185 -0
  46. package/src/cli/source-text.ts +62 -0
  47. package/src/cli/sync.ts +17 -10
  48. package/src/content/code-block.module.css +19 -1
  49. package/src/content/code-block.tsx +7 -2
  50. package/src/content/mermaid-sanitize.ts +49 -0
  51. package/src/content/mermaid.tsx +3 -2
  52. package/src/provider/index.tsx +6 -3
  53. package/src/vite-boot.ts +109 -0
  54. package/src/vite.ts +32 -61
@@ -0,0 +1,37 @@
1
+ import { tokenize } from './source-text.js';
2
+ /** The module `index.html` loads for the app at `dir` (default src/main.tsx), relative to `dir`. */
3
+ export declare function appEntry(dir: string): string;
4
+ type Tokens = ReturnType<typeof tokenize>;
5
+ /**
6
+ * Whether the entry or a module it imports (relative imports, static or dynamic, `IMPORT_DEPTH`
7
+ * hops) matches `pattern` in code — a global regex, ignoring comments and string literals; an
8
+ * import inside a comment or a string is not followed. `entryTokens` reuses an already-tokenized entry.
9
+ */
10
+ export declare function callsIn(dir: string, entry: string, pattern: RegExp, entryTokens?: Tokens): boolean;
11
+ /** A global regex matching a CALL of `name` (itself a regex source), generic or not — not an import or bare mention. */
12
+ export declare function callOf(pattern: string): RegExp;
13
+ /** The directories a generated `routeTree.gen.*` is looked for in: beside the entry, then src/. */
14
+ export declare function routeTreeDirs(entry: string): string[];
15
+ /** A TanStack router plugin in the vite config, or a `routeTree.gen.*` in `routeTreeDirs`. */
16
+ export declare function hasRouteTree(dir: string, entry: string): boolean;
17
+ /** Whether `createBasaltRouter` is called in a module reachable from the entry. */
18
+ export declare function hasRouter(dir: string, entry: string, entryTokens?: Tokens): boolean;
19
+ /**
20
+ * THE classification, shared by `init`, `sync` and `doctor`: code-routed = `createBasaltRouter` is
21
+ * called in a module reachable from the entry, no router plugin is registered and no
22
+ * `routeTree.gen.*` exists, and the entry does not import a generated tree (a freshly seeded entry
23
+ * does, before the first vite run — that app is file-routed). Comments and strings do not count.
24
+ */
25
+ export declare function isCodeRoutedApp(cwd: string, appRel: string): boolean;
26
+ /** A TanStack Start app owns its router, so its router seeds give way to an in-tree `<BasaltProvider>`. */
27
+ export declare function isStartApp(cwd: string, appRel: string): boolean;
28
+ /** Why an app's router seeds are not placed (see `routerSeedSkip`). */
29
+ export type RouterSeedSkip = 'start' | 'code-routed' | null;
30
+ export declare const CODE_ROUTED_NOTE = "code-routed app (createBasaltRouter, no route-tree plugin or routeTree.gen) \u2014 no main.tsx/nav.tsx/__root.tsx seeded.";
31
+ /**
32
+ * Why an app's router seeds (main/nav/__root) are not placed: `start` (Start owns the router, and
33
+ * wins when both apply) or `code-routed` (no generated tree to assume); null when they are.
34
+ */
35
+ export declare function routerSeedSkip(cwd: string, appRel: string): RouterSeedSkip;
36
+ export {};
37
+ //# sourceMappingURL=router-wiring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-wiring.d.ts","sourceRoot":"","sources":["../../src/cli/router-wiring.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,QAAQ,EAAE,MAAM,eAAe,CAAA;AAuErE,oGAAoG;AACpG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAEzC;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAqBT;AAED,wHAAwH;AACxH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9C;AAID,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAErD;AAED,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQhE;AAED,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAEnF;AAOD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAMpE;AAED,2GAA2G;AAC3G,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,aAAa,GAAG,IAAI,CAAA;AAE3D,eAAO,MAAM,gBAAgB,8HAC2F,CAAA;AAExH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAG1E"}
@@ -0,0 +1,116 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { hasDependency, readIfExists, tokenize } from "./source-text.js";
4
+ const IMPORT_DEPTH = 3;
5
+ const VITE_CONFIGS = ["ts", "mts", "cts", "js", "mjs", "cjs"].map((e) => `vite.config.${e}`);
6
+ function htmlEntry(html) {
7
+ for (const [, attrs = ""] of html.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<script\b([^>]*)>/gi)) {
8
+ const src = /\bsrc\s*=\s*["']?([^"'\s>]+)/i.exec(attrs)?.[1];
9
+ if (/\btype\s*=\s*["']?module\b/i.test(attrs) && src !== void 0 && !/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(src)) {
10
+ return src;
11
+ }
12
+ }
13
+ return void 0;
14
+ }
15
+ function registersRouterPlugin(src) {
16
+ const { code, inLiteral } = tokenize(src);
17
+ const pluginsAt = [...code.matchAll(/\bplugins\b/g)].find((m) => !inLiteral(m.index))?.index;
18
+ if (pluginsAt === void 0) return false;
19
+ const imports = code.matchAll(
20
+ /(?:^|;)[ \t]*import\s+(?:type\s+)?([^'"`;]*?)\s*from\s*(['"])@tanstack\/router-plugin(?:\/[^'"]*)?\2/gm
21
+ );
22
+ return [...imports].some((m) => {
23
+ if (inLiteral(m.index)) return false;
24
+ const names = (m[1] ?? "").replace(/[{}]/g, "").split(",").map((part) => part.trim()).filter((part) => part !== "" && !/^type\s/.test(part)).map((part) => part.split(/\s+as\s+/).pop() ?? part);
25
+ return names.some(
26
+ (name) => [
27
+ ...code.matchAll(
28
+ new RegExp(`(?<![.\\w$])${name.replace(/\$/g, "\\$")}(?:\\.\\w+)?\\s*\\(`, "g")
29
+ )
30
+ ].some((call) => call.index > pluginsAt && !inLiteral(call.index))
31
+ );
32
+ });
33
+ }
34
+ const RELATIVE_IMPORT = /(?<![.\w$])(?:(?:import|export)\b[^'";]*?\bfrom|import\s*\(?)\s*['"](\.{1,2}\/[^'"]+)['"]/g;
35
+ const GENERATED_TREE_IMPORT = /(?<![.\w$])(?:(?:import|export)\b[^'";]*?\bfrom|import\s*\(?)\s*['"][^'"]*routeTree\.gen[^'"]*['"]/g;
36
+ function resolveRelative(from, spec) {
37
+ const base = resolve(dirname(from), spec.replace(/\.[jt]sx?$/, ""));
38
+ return [
39
+ resolve(dirname(from), spec),
40
+ `${base}.ts`,
41
+ `${base}.tsx`,
42
+ `${base}/index.ts`,
43
+ `${base}/index.tsx`
44
+ ].find((f) => /\.[jt]sx?$/.test(f) && existsSync(f)) ?? null;
45
+ }
46
+ function appEntry(dir) {
47
+ const src = htmlEntry(readIfExists(resolve(dir, "index.html")) ?? "") ?? "src/main.tsx";
48
+ return src.replace(/^\//, "");
49
+ }
50
+ function callsIn(dir, entry, pattern, entryTokens) {
51
+ const entryPath = resolve(dir, entry);
52
+ const seen = /* @__PURE__ */ new Set([entryPath]);
53
+ let frontier = [entryPath];
54
+ for (let depth = 0; depth <= IMPORT_DEPTH && frontier.length > 0; depth++) {
55
+ const next = [];
56
+ for (const file of frontier) {
57
+ const { code, inLiteral } = file === entryPath && entryTokens ? entryTokens : tokenize(readIfExists(file) ?? "");
58
+ if ([...code.matchAll(pattern)].some((c) => !inLiteral(c.index))) return true;
59
+ for (const m of code.matchAll(RELATIVE_IMPORT)) {
60
+ if (inLiteral(m.index)) continue;
61
+ const dep = resolveRelative(file, m[1] ?? "");
62
+ if (dep === null || seen.has(dep)) continue;
63
+ seen.add(dep);
64
+ next.push(dep);
65
+ }
66
+ }
67
+ frontier = next;
68
+ }
69
+ return false;
70
+ }
71
+ function callOf(pattern) {
72
+ return new RegExp(`\\b${pattern}\\b\\s*(?:<[^()]*>)?\\s*\\(`, "g");
73
+ }
74
+ const CREATE_BASALT_ROUTER = callOf("createBasaltRouter");
75
+ function routeTreeDirs(entry) {
76
+ return [.../* @__PURE__ */ new Set([dirname(entry), "src"])];
77
+ }
78
+ function hasRouteTree(dir, entry) {
79
+ const vite = VITE_CONFIGS.map((f) => readIfExists(resolve(dir, f))).find((t) => t !== null) ?? "";
80
+ return registersRouterPlugin(vite) || routeTreeDirs(entry).some(
81
+ (d) => ["ts", "tsx", "js"].some((e) => existsSync(resolve(dir, d, `routeTree.gen.${e}`)))
82
+ );
83
+ }
84
+ function hasRouter(dir, entry, entryTokens) {
85
+ return callsIn(dir, entry, CREATE_BASALT_ROUTER, entryTokens);
86
+ }
87
+ function importsGeneratedTree({ code, inLiteral }) {
88
+ return [...code.matchAll(GENERATED_TREE_IMPORT)].some((m) => !inLiteral(m.index));
89
+ }
90
+ function isCodeRoutedApp(cwd, appRel) {
91
+ const dir = resolve(cwd, appRel);
92
+ const entry = appEntry(dir);
93
+ const tokens = tokenize(readIfExists(resolve(dir, entry)) ?? "");
94
+ if (importsGeneratedTree(tokens)) return false;
95
+ return hasRouter(dir, entry, tokens) && !hasRouteTree(dir, entry);
96
+ }
97
+ function isStartApp(cwd, appRel) {
98
+ return hasDependency(resolve(cwd, appRel), "@tanstack/react-start");
99
+ }
100
+ const CODE_ROUTED_NOTE = "code-routed app (createBasaltRouter, no route-tree plugin or routeTree.gen) \u2014 no main.tsx/nav.tsx/__root.tsx seeded.";
101
+ function routerSeedSkip(cwd, appRel) {
102
+ if (isStartApp(cwd, appRel)) return "start";
103
+ return isCodeRoutedApp(cwd, appRel) ? "code-routed" : null;
104
+ }
105
+ export {
106
+ CODE_ROUTED_NOTE,
107
+ appEntry,
108
+ callOf,
109
+ callsIn,
110
+ hasRouteTree,
111
+ hasRouter,
112
+ isCodeRoutedApp,
113
+ isStartApp,
114
+ routeTreeDirs,
115
+ routerSeedSkip
116
+ };
@@ -0,0 +1,12 @@
1
+ /** `abs` read as text, or null: absent, a directory, unreadable or raced away all mean "not there". */
2
+ export declare function readIfExists(abs: string): string | null;
3
+ /** `<dir>/package.json` parsed as `T`; null when absent or not JSON. */
4
+ export declare function readPackageJson<T>(dir: string): T | null;
5
+ /** True when `pkgName` appears in any of the consumer's dependencies, devDependencies or peerDependencies. */
6
+ export declare function hasDependency(cwd: string, pkgName: string): boolean;
7
+ /** Source with comments blanked (and template text), plus a test for "offset sits inside a string". */
8
+ export declare function tokenize(src: string): {
9
+ code: string;
10
+ inLiteral: (at: number) => boolean;
11
+ };
12
+ //# sourceMappingURL=source-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-text.d.ts","sourceRoot":"","sources":["../../src/cli/source-text.ts"],"names":[],"mappings":"AAOA,uGAAuG;AACvG,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMvD;AAED,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAOxD;AAID,8GAA8G;AAC9G,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMnE;AAUD,uGAAuG;AACvG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,CAe1F"}
@@ -0,0 +1,46 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ function readIfExists(abs) {
4
+ try {
5
+ return readFileSync(abs, "utf8");
6
+ } catch {
7
+ return null;
8
+ }
9
+ }
10
+ function readPackageJson(dir) {
11
+ const raw = readIfExists(resolve(dir, "package.json"));
12
+ try {
13
+ return raw === null ? null : JSON.parse(raw);
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+ const DEPENDENCY_FIELDS = ["dependencies", "devDependencies", "peerDependencies"];
19
+ function hasDependency(cwd, pkgName) {
20
+ const pkg = readPackageJson(
21
+ cwd
22
+ );
23
+ return DEPENDENCY_FIELDS.some((field) => pkg?.[field]?.[pkgName] !== void 0);
24
+ }
25
+ const TOKEN = /("(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`)|\/\/[^\n]*|\/\*[\s\S]*?\*\//g;
26
+ function tokenize(src) {
27
+ const literals = [];
28
+ const code = src.replace(TOKEN, (m, literal, at) => {
29
+ if (literal === void 0) return m.replace(/[^\n]/g, " ");
30
+ if (!literal.startsWith("`")) {
31
+ literals.push([at, at + m.length]);
32
+ return m;
33
+ }
34
+ return m.replace(
35
+ /(\$\{[^}]*\})|[^\n`]/g,
36
+ (c, interpolation) => interpolation ?? " "
37
+ );
38
+ });
39
+ return { code, inLiteral: (at) => literals.some(([from, to]) => at >= from && at < to) };
40
+ }
41
+ export {
42
+ hasDependency,
43
+ readIfExists,
44
+ readPackageJson,
45
+ tokenize
46
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/cli/sync.ts"],"names":[],"mappings":"AA2CA,gGAAgG;AAChG,wBAAgB,uBAAuB,CAAC,OA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
@@ -10,7 +10,6 @@ import {
10
10
  diffSummary,
11
11
  findBasaltInstall,
12
12
  inspectLefthookGate,
13
- isStartApp,
14
13
  isStringArray,
15
14
  managedFiles,
16
15
  normalizeForLedger,
@@ -29,7 +28,7 @@ import {
29
28
  reportPrune,
30
29
  resolvePlacement,
31
30
  resolveProjectDir,
32
- routerSeedDests,
31
+ routerSeedPlan,
33
32
  rootsNotices,
34
33
  sha256,
35
34
  shippedAssetPath,
@@ -74,8 +73,8 @@ function sync(opts = {}, invocationCwd = process.cwd()) {
74
73
  if (!existsSync(resolve(cwd, MANIFEST_PATH))) {
75
74
  const elsewhere = findManifestAbove(cwd);
76
75
  const refused = resolvePlacement(cwd);
77
- const startSeeds = isStartApp(cwd, refused.appRel) ? routerSeedDests(refused.appRel) : [];
78
- const wouldWrite = managedFiles(refused).filter((f) => !startSeeds.includes(f.dest)).length;
76
+ const { skipped: skippedSeeds } = routerSeedPlan(cwd, refused.appRel);
77
+ const wouldWrite = managedFiles(refused).filter((f) => !skippedSeeds.has(f.dest)).length;
79
78
  console.error(
80
79
  `\u2716 basalt-ui sync: no ${MANIFEST_PATH} at ${cwd} \u2014 refusing to scaffold. \`sync\` refreshes an EXISTING basalt install; creating one is \`basalt-ui init\`'s decision, and continuing here would write ${wouldWrite} managed file(s) into this directory.` + (elsewhere === null ? " No manifest exists at any ancestor either \u2014 run `basalt-ui init` here if this package really is meant to be a consumer." : ` ${parentInstallAdvice(cwd, elsewhere, "sync")}`)
81
80
  );
@@ -85,8 +84,7 @@ function sync(opts = {}, invocationCwd = process.cwd()) {
85
84
  const ctx = renderContext(cwd);
86
85
  const manifest = readManifest(cwd);
87
86
  const placement = resolvePlacement(cwd);
88
- const startApp = isStartApp(cwd, placement.appRel);
89
- const skipped = new Set(startApp ? routerSeedDests(placement.appRel) : []);
87
+ const { skip: seedSkip, skipped } = routerSeedPlan(cwd, placement.appRel);
90
88
  const files = managedFiles(placement).filter((f) => !skipped.has(f.dest));
91
89
  let updated = 0;
92
90
  let created = 0;
@@ -133,9 +131,16 @@ function sync(opts = {}, invocationCwd = process.cwd()) {
133
131
  force: opts.force === true
134
132
  });
135
133
  staleForCheck += pruned.removed.length + pruned.drifted.length;
136
- const stale = [...skipped].filter(
137
- (d) => manifest.files[d] !== void 0 && existsSync(resolve(cwd, d))
138
- );
134
+ const isTracked = (d) => manifest.files[d] !== void 0;
135
+ const codeRoutedSeeds = seedSkip === "code-routed" ? [...skipped].filter(isTracked) : [];
136
+ if (codeRoutedSeeds.length > 0 && !opts.check) {
137
+ for (const d of codeRoutedSeeds) delete manifest.files[d];
138
+ console.error(
139
+ `\u26A0 basalt-ui sync: code-routed app \u2014 dropped ${codeRoutedSeeds.join(", ")} from the manifest (any file is yours).`
140
+ );
141
+ }
142
+ const startSkippedSeeds = seedSkip === "start" ? [...skipped] : [];
143
+ const stale = startSkippedSeeds.filter((d) => isTracked(d) && existsSync(resolve(cwd, d)));
139
144
  const mounting = stale.filter((d) => !d.endsWith("nav.tsx"));
140
145
  const inert = stale.filter((d) => d.endsWith("nav.tsx"));
141
146
  const embedded = "Delete them and render <BasaltProvider><Outlet /></BasaltProvider> in the Start root route (embedded mode).";
@@ -149,7 +154,7 @@ function sync(opts = {}, invocationCwd = process.cwd()) {
149
154
  `\u26A0 basalt-ui sync: ${inert.join(", ")} was seeded before this became a Start app; it mounts nothing, so keep or delete it. Left untouched.`
150
155
  );
151
156
  }
152
- if (startApp && (!opts.check || syncFlags.includes("--verbose")))
157
+ if (seedSkip === "start" && (!opts.check || syncFlags.includes("--verbose")))
153
158
  console.log(`basalt-ui sync: ${START_APP_NOTE}`);
154
159
  const placementSkips = placementNotices(cwd, placement);
155
160
  if (opts.check !== true || syncFlags.includes("--verbose")) {
@@ -1 +1 @@
1
- {"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/content/code-block.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAO1C,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAC/B,CAAA;AAED,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,QAAe,EACf,SAAS,EACT,KAAK,GACN,EAAE,cAAc,+BAuFhB"}
1
+ {"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/content/code-block.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAO1C,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAC/B,CAAA;AAED,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,QAAe,EACf,SAAS,EACT,KAAK,GACN,EAAE,cAAc,+BA4FhB"}
@@ -46,33 +46,42 @@ function CodeBlock({
46
46
  };
47
47
  }, [html, code]);
48
48
  const containerClass = [classes.container, className].filter(Boolean).join(" ");
49
- return /* @__PURE__ */ jsxs("div", { className: containerClass, ...style !== void 0 && { style }, children: [
50
- title !== void 0 && /* @__PURE__ */ jsxs("div", { className: classes.header, children: [
51
- /* @__PURE__ */ jsx("span", { className: classes.title, children: title }),
52
- /* @__PURE__ */ jsxs("div", { className: classes.headerRight, children: [
53
- language !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.langBadge, children: language }),
54
- showCopy && /* @__PURE__ */ jsx(CopyAction, { value: code, ariaLabel: "Copy code" })
55
- ] })
56
- ] }),
57
- html !== null ? /* @__PURE__ */ jsx(
58
- "div",
59
- {
60
- ref: setBodyRef,
61
- className: classes.body,
62
- ...showOverflowFade && { "data-code-overflow": true },
63
- dangerouslySetInnerHTML: { __html: html }
64
- }
65
- ) : /* @__PURE__ */ jsx(
66
- "pre",
67
- {
68
- ref: setBodyRef,
69
- className: classes.body,
70
- ...showOverflowFade && { "data-code-overflow": true },
71
- children: /* @__PURE__ */ jsx("code", { children: code })
72
- }
73
- ),
74
- title === void 0 && showCopy && /* @__PURE__ */ jsx("div", { className: classes.floatingCopy, children: /* @__PURE__ */ jsx(CopyAction, { value: code, ariaLabel: "Copy code" }) })
75
- ] });
49
+ const showFloatingCopy = title === void 0 && showCopy;
50
+ return /* @__PURE__ */ jsxs(
51
+ "div",
52
+ {
53
+ className: containerClass,
54
+ ...showFloatingCopy && { "data-floating-copy": true },
55
+ ...style !== void 0 && { style },
56
+ children: [
57
+ title !== void 0 && /* @__PURE__ */ jsxs("div", { className: classes.header, children: [
58
+ /* @__PURE__ */ jsx("span", { className: classes.title, children: title }),
59
+ /* @__PURE__ */ jsxs("div", { className: classes.headerRight, children: [
60
+ language !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.langBadge, children: language }),
61
+ showCopy && /* @__PURE__ */ jsx(CopyAction, { value: code, ariaLabel: "Copy code" })
62
+ ] })
63
+ ] }),
64
+ html !== null ? /* @__PURE__ */ jsx(
65
+ "div",
66
+ {
67
+ ref: setBodyRef,
68
+ className: classes.body,
69
+ ...showOverflowFade && { "data-code-overflow": true },
70
+ dangerouslySetInnerHTML: { __html: html }
71
+ }
72
+ ) : /* @__PURE__ */ jsx(
73
+ "pre",
74
+ {
75
+ ref: setBodyRef,
76
+ className: classes.body,
77
+ ...showOverflowFade && { "data-code-overflow": true },
78
+ children: /* @__PURE__ */ jsx("code", { children: code })
79
+ }
80
+ ),
81
+ showFloatingCopy && /* @__PURE__ */ jsx("div", { className: classes.floatingCopy, children: /* @__PURE__ */ jsx(CopyAction, { value: code, ariaLabel: "Copy code" }) })
82
+ ]
83
+ }
84
+ );
76
85
  }
77
86
  export {
78
87
  CodeBlock
@@ -77,7 +77,13 @@
77
77
  );
78
78
  }
79
79
 
80
- .body :global(pre.shiki) {
80
+ /* Both body states — the highlighted wrapper's `pre.shiki` and the bare fallback `<pre class=body>`
81
+ * — outrank Prose's `.root.article pre` block margin (0,2,1): at a tie, stylesheet order decided
82
+ * whether the inner pre kept 18px, so the fallback was ~36px taller than the highlighted fence and
83
+ * the swap jumped. `.body.body` lifts the fallback to (0,3,0); the outer `.container` margin alone
84
+ * owns the rhythm. */
85
+ .container .body.body,
86
+ .container .body :global(pre.shiki) {
81
87
  margin: 0;
82
88
  padding: 0;
83
89
  background: transparent !important;
@@ -93,6 +99,18 @@ html[data-mantine-color-scheme='light'] .body :global(.shiki span) {
93
99
  color: var(--shiki-light);
94
100
  }
95
101
 
102
+ /* The floating button sits over the body's top-right corner, so the body reserves its box: the
103
+ * first line starts below offset + button height instead of running underneath it on touch (always
104
+ * visible) or on hover. `--code-block-copy-size` mirrors ActionIcon size="sm" (Mantine scopes its
105
+ * own `--ai-size-sm` to the button, out of the body's reach); the layout suite pins the two. */
106
+ .container[data-floating-copy] {
107
+ --code-block-copy-size: calc(1.375rem * var(--mantine-scale, 1));
108
+ }
109
+
110
+ .container[data-floating-copy] .body {
111
+ padding-top: calc(var(--vx-space-code-block-floating-copy-offset) + var(--code-block-copy-size));
112
+ }
113
+
96
114
  /* Floating copy button — shown only when there is no header (no title), revealed on hover/focus. */
97
115
  .floatingCopy {
98
116
  position: absolute;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Post-process for beautiful-mermaid's SVG (consumed by `./mermaid`).
3
+ *
4
+ * `buildStyleBlock(font)` treats the font as a family NAME: it emits a Google Fonts `@import` (plus
5
+ * a JetBrains Mono one when `mono` is set) and writes `text { font-family: '<font>', … }`. basalt
6
+ * feeds it `var(--basalt-font-sans)`, so the import is a broken request and the quoted `'var(…)'`
7
+ * is an invalid family. basalt self-hosts its fonts: drop the import, unquote the var().
8
+ *
9
+ * Patterns verified against beautiful-mermaid 1.1.3 (peer range ^1.1.0): the style block is a
10
+ * single `<style>` holding the `@import`s and one `text { font-family }` rule; `font-family`
11
+ * never appears as a presentation attribute. Only `<style>` content is rewritten — a node label
12
+ * that happens to contain the same text is left alone.
13
+ */
14
+ export declare function sanitizeMermaidFonts(svg: string): string;
15
+ //# sourceMappingURL=mermaid-sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mermaid-sanitize.d.ts","sourceRoot":"","sources":["../../src/content/mermaid-sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA+BH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKxD"}
@@ -0,0 +1,28 @@
1
+ const STYLE_BLOCK = /(<style\b[^>]*>)([\s\S]*?)(<\/style>)/gi;
2
+ const HOST = String.raw`(?:https?:)?\/\/fonts\.googleapis\.com`;
3
+ const QUOTED_FORM = String.raw`(?:url\(\s*)?(['"])${HOST}[^'"}\n]*\1(?:\s*\))?`;
4
+ const URL_FORM = String.raw`url\(\s*${HOST}[^}'"\n]*?\)`;
5
+ const MEDIA_LIST = String.raw`(?:[ \t]+[^;{}\n]*)?`;
6
+ const GOOGLE_FONTS_IMPORT = new RegExp(
7
+ String.raw`@import\s+(?:${QUOTED_FORM}|${URL_FORM})${MEDIA_LIST}[ \t]*;?`,
8
+ "g"
9
+ );
10
+ const QUOTED_VAR_FONT_FAMILY = /(font-family\s*:\s*)(['"])(var\([^'"]*\))\2/g;
11
+ function sanitizeStyle(css) {
12
+ const cleaned = css.replace(GOOGLE_FONTS_IMPORT, "").replace(QUOTED_VAR_FONT_FAMILY, "$1$3");
13
+ if (process.env.NODE_ENV !== "production" && /googleapis/i.test(cleaned)) {
14
+ console.warn(
15
+ "[basalt] MermaidDiagram: a remote font import survived sanitization \u2014 beautiful-mermaid changed its <style> output; update src/content/mermaid-sanitize.ts."
16
+ );
17
+ }
18
+ return cleaned;
19
+ }
20
+ function sanitizeMermaidFonts(svg) {
21
+ return svg.replace(
22
+ STYLE_BLOCK,
23
+ (_block, open, css, close) => open + sanitizeStyle(css) + close
24
+ );
25
+ }
26
+ export {
27
+ sanitizeMermaidFonts
28
+ };
@@ -20,6 +20,12 @@
20
20
  * <MermaidDiagram code={'graph TD\n A --> B'} />
21
21
  */
22
22
  import type { CSSProperties, ReactNode } from 'react';
23
+ import type { RenderOptions } from 'beautiful-mermaid';
24
+ /**
25
+ * Static theme mapping onto the `--vx-*` token layer — every value is a `var(--vx-*)` string, so
26
+ * this object never changes across renders/schemes and can live at module scope.
27
+ */
28
+ export declare const MERMAID_THEME_OPTIONS: RenderOptions;
23
29
  export type MermaidDiagramProps = {
24
30
  /** Raw mermaid source (the fence body, without the surrounding ``` marks). */
25
31
  readonly code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../src/content/mermaid.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAqCrD,MAAM,MAAM,mBAAmB,GAAG;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAA;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B,CAAA;AAED,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,mBAAmB,4SA0DvF"}
1
+ {"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../src/content/mermaid.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAMtD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAUnC,CAAA;AAUD,MAAM,MAAM,mBAAmB,GAAG;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAA;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B,CAAA;AAED,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,mBAAmB,4SA0DvF"}
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { CodeBlock } from "./code-block.js";
4
4
  import classes from "./mermaid.module.css";
5
+ import { sanitizeMermaidFonts } from "./mermaid-sanitize.js";
5
6
  const MERMAID_THEME_OPTIONS = {
6
7
  bg: "var(--vx-surface-panel)",
7
8
  fg: "var(--vx-ink)",
@@ -34,7 +35,7 @@ function MermaidDiagram({ code, className, style, fallback }) {
34
35
  const rendered = useMemo(() => {
35
36
  if (!mod) return null;
36
37
  try {
37
- return mod.renderMermaidSVG(code, MERMAID_THEME_OPTIONS);
38
+ return sanitizeMermaidFonts(mod.renderMermaidSVG(code, MERMAID_THEME_OPTIONS));
38
39
  } catch {
39
40
  return void 0;
40
41
  }
@@ -66,5 +67,6 @@ function MermaidDiagram({ code, className, style, fallback }) {
66
67
  );
67
68
  }
68
69
  export {
70
+ MERMAID_THEME_OPTIONS,
69
71
  MermaidDiagram
70
72
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AASzD,OAAO,EAAE,SAAS,EAAqE,MAAM,OAAO,CAAA;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAStD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAQxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,iBAAiB,CAAA;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGzD,KAAK,yBAAyB,GAAG;IAC/B,qFAAqF;IACrF,KAAK,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAA;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,yGAAyG;IACzG,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CAAC,CAAA;IACtD;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAA;IACjC,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;IAC/D;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MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAYD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAmBvC;AAwND,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,SAAS,EACT,QAAQ,EACR,aAAoB,EACpB,cAAc,EACd,kBAA2B,EAC3B,KAAK,EACL,aAAyB,EACzB,eAAe,EACf,SAAgB,EAChB,MAAM,EAAE,aAAa,EACrB,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,mBAAmB,+BAsFrB"}
@@ -228,7 +228,8 @@ function useDataTelemetry(router, client, emit) {
228
228
  };
229
229
  }, [router, client, emit]);
230
230
  }
231
- const LazyDevDock = lazy(() => import("../dev-dock.js").then((m) => ({ default: m.BasaltDevDock })));
231
+ const loadDevDock = () => import("../dev-dock.js").then((m) => ({ default: m.BasaltDevDock }));
232
+ const LazyDevDock = process.env.NODE_ENV === "production" ? null : lazy(loadDevDock);
232
233
  function readQueryClient(router) {
233
234
  const client = router.options.context?.queryClient;
234
235
  if (client === void 0) {
@@ -300,7 +301,7 @@ function BasaltProvider({
300
301
  children: /* @__PURE__ */ jsx(RootBoundary, { emit, fallback, children: /* @__PURE__ */ jsx(BasaltBridge, { injectPalette, paletteOptions, nonce, children: /* @__PURE__ */ jsx(TelemetryContext.Provider, { value: emit, children: /* @__PURE__ */ jsxs(SizeClassHintContext.Provider, { value: sizeClassHint, children: [
301
302
  /* @__PURE__ */ jsx(QueryClientProvider, { client, children: /* @__PURE__ */ jsxs(ModalsProvider, { children: [
302
303
  mountedRouter === void 0 ? children : /* @__PURE__ */ jsx(RouterProvider, { router: mountedRouter }),
303
- process.env.NODE_ENV !== "production" && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
304
+ LazyDevDock !== null && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
304
305
  LazyDevDock,
305
306
  {
306
307
  tool: devTool,
@@ -0,0 +1,25 @@
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
+ /** The `colorScheme` option: which scheme the boot paint assumes; `false` declares no `color-scheme`. */
10
+ export type BootColorScheme = 'dark' | 'light' | 'auto' | false;
11
+ type BootInput = {
12
+ colorScheme: BootColorScheme;
13
+ themeColor: {
14
+ light: string;
15
+ dark: string;
16
+ };
17
+ backgroundColor: string;
18
+ explicitBackground: boolean;
19
+ /** Inject the stored-scheme script and the variant rules it drives. */
20
+ bootScript: boolean;
21
+ };
22
+ /** The boot `<style>`, then (unless `bootScript: false`) the script — adjacent, head-prepend. */
23
+ export declare function buildBootTags(input: BootInput): HtmlTagDescriptor[];
24
+ export {};
25
+ //# sourceMappingURL=vite-boot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-boot.d.ts","sourceRoot":"","sources":["../src/vite-boot.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AA0C7C,yGAAyG;AACzG,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;AAE/D,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,eAAe,CAAA;IAC5B,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3C,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AA4CD,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,iBAAiB,EAAE,CAInE"}
@@ -0,0 +1,36 @@
1
+ const BOOT_SCOPE = "html:not([data-mantine-color-scheme])";
2
+ const BOOT_ATTRIBUTE = "data-basalt-boot";
3
+ const BOOT_STORAGE_KEY = "mantine-color-scheme-value";
4
+ const BOOT_SCRIPT = `(function(){try{let v=localStorage.getItem('${BOOT_STORAGE_KEY}');if(v==='auto')v=matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';if(v==='light'||v==='dark')document.documentElement.setAttribute('${BOOT_ATTRIBUTE}',v)}catch(e){}})()`;
5
+ const BOOT_COLOR_SCHEME = { dark: "dark", light: "light", auto: "light dark" };
6
+ function buildBaseBootStyle(input) {
7
+ const { colorScheme, themeColor, backgroundColor, explicitBackground } = input;
8
+ if (colorScheme === false) return `${BOOT_SCOPE}{background-color:${backgroundColor}}`;
9
+ const scheme = BOOT_COLOR_SCHEME[colorScheme];
10
+ if (colorScheme !== "auto" || explicitBackground) {
11
+ return `${BOOT_SCOPE}{background-color:${backgroundColor};color-scheme:${scheme}}`;
12
+ }
13
+ return `${BOOT_SCOPE}{background-color:${themeColor.light};color-scheme:${scheme}}@media(prefers-color-scheme:dark){${BOOT_SCOPE}{background-color:${themeColor.dark}}}`;
14
+ }
15
+ function buildBootStyle(input) {
16
+ const { colorScheme, themeColor, explicitBackground, bootScript } = input;
17
+ const base = buildBaseBootStyle(input);
18
+ if (!bootScript) return base;
19
+ const variants = ["light", "dark"].map((scheme) => {
20
+ const declarations = [
21
+ ...explicitBackground ? [] : [`background-color:${themeColor[scheme]}`],
22
+ ...colorScheme === false ? [] : [`color-scheme:${scheme}`]
23
+ ];
24
+ if (declarations.length === 0) return "";
25
+ return `${BOOT_SCOPE}[${BOOT_ATTRIBUTE}=${scheme}]{${declarations.join(";")}}`;
26
+ });
27
+ return base + variants.join("");
28
+ }
29
+ function buildBootTags(input) {
30
+ const tags = [{ tag: "style", children: buildBootStyle(input) }];
31
+ if (input.bootScript) tags.push({ tag: "script", children: BOOT_SCRIPT });
32
+ return tags;
33
+ }
34
+ export {
35
+ buildBootTags
36
+ };