@shortwind/cli 0.1.0-beta.13 → 0.1.0-beta.15
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/dist/{bench-B7SxNGiU.js → bench-vo5aWJUx.js} +106 -6
- package/dist/bench-vo5aWJUx.js.map +1 -0
- package/dist/bin.js +9 -2
- package/dist/bin.js.map +1 -1
- package/dist/catalog.generated-fXJjJvJ2.js +98 -0
- package/dist/catalog.generated-fXJjJvJ2.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/bench-B7SxNGiU.js.map +0 -1
- package/dist/catalog.generated-BdZstlkf.js +0 -83
- package/dist/catalog.generated-BdZstlkf.js.map +0 -1
|
@@ -168,7 +168,7 @@ const BUNDLED_ORIGIN = "bundled:@shortwind/catalog";
|
|
|
168
168
|
function bundledSource() {
|
|
169
169
|
let cache = null;
|
|
170
170
|
const load = () => {
|
|
171
|
-
cache ??= import("./catalog.generated-
|
|
171
|
+
cache ??= import("./catalog.generated-fXJjJvJ2.js");
|
|
172
172
|
return cache;
|
|
173
173
|
};
|
|
174
174
|
return {
|
|
@@ -445,6 +445,21 @@ function blockSectionValues(selector) {
|
|
|
445
445
|
}
|
|
446
446
|
const THEME_LIGHT_VALUES = blockSectionValues(":root");
|
|
447
447
|
const THEME_DARK_VALUES = blockSectionValues(".dark");
|
|
448
|
+
const PREFERS_DARK_RE = /@media\s*\(\s*prefers-color-scheme\s*:\s*dark\s*\)/;
|
|
449
|
+
function darkSection(css, lines, { mediaWrapRoot = true } = {}) {
|
|
450
|
+
const out = [
|
|
451
|
+
".dark {",
|
|
452
|
+
...lines,
|
|
453
|
+
"}"
|
|
454
|
+
];
|
|
455
|
+
if (PREFERS_DARK_RE.test(css)) {
|
|
456
|
+
out.push("@media (prefers-color-scheme: dark) {");
|
|
457
|
+
if (mediaWrapRoot) out.push(" :root {", ...lines.map((l) => ` ${l}`), " }");
|
|
458
|
+
else out.push(...lines.map((l) => ` ${l}`));
|
|
459
|
+
out.push("}");
|
|
460
|
+
}
|
|
461
|
+
return out;
|
|
462
|
+
}
|
|
448
463
|
function buildThemeSupplement(css, missing) {
|
|
449
464
|
const tokens = missing.filter((t) => THEME_LIGHT_VALUES.has(t));
|
|
450
465
|
if (tokens.length === 0) return null;
|
|
@@ -457,13 +472,79 @@ function buildThemeSupplement(css, missing) {
|
|
|
457
472
|
...light,
|
|
458
473
|
"}"
|
|
459
474
|
];
|
|
460
|
-
if (dark.length > 0)
|
|
461
|
-
if (/@custom-variant\s+dark|\.dark\s*\{/.test(css)) lines.push(".dark {", ...dark, "}");
|
|
462
|
-
else if (/@media\s*\(\s*prefers-color-scheme\s*:\s*dark\s*\)/.test(css)) lines.push("@media (prefers-color-scheme: dark) {", " :root {", ...dark.map((l) => ` ${l}`), " }", "}");
|
|
463
|
-
}
|
|
475
|
+
if (dark.length > 0) lines.push(...darkSection(css, dark));
|
|
464
476
|
lines.push("@theme inline {", ...mapping, "}", "/* end shortwind theme-supplement */");
|
|
465
477
|
return lines.join("\n");
|
|
466
478
|
}
|
|
479
|
+
const DARK_CLASS_VARIANT = "@custom-variant dark (&:is(.dark *));";
|
|
480
|
+
const CUSTOM_VARIANT_RE = /@custom-variant\s+dark\b/;
|
|
481
|
+
function ensureDarkClassVariant(css) {
|
|
482
|
+
if (CUSTOM_VARIANT_RE.test(css)) return css;
|
|
483
|
+
const m = css.match(TAILWIND_IMPORT_RE);
|
|
484
|
+
if (!m) return css;
|
|
485
|
+
const at = (m.index ?? 0) + m[0].length;
|
|
486
|
+
return `${css.slice(0, at)}\n${DARK_CLASS_VARIANT}${css.slice(at)}`;
|
|
487
|
+
}
|
|
488
|
+
const DARK_PROMOTE_MARKER = "/* shortwind:dark-promote";
|
|
489
|
+
function promoteMediaDarkToClass(css) {
|
|
490
|
+
if (css.includes("/* shortwind:dark-promote")) return null;
|
|
491
|
+
const decls = [...(css.match(/@media\s*\(\s*prefers-color-scheme\s*:\s*dark\s*\)\s*\{\s*:root\s*\{([^}]*)\}/)?.[1] ?? "").matchAll(/--([\w-]+)\s*:\s*([^;]+);/g)].map((d) => ` --${d[1]}: ${d[2].trim()};`);
|
|
492
|
+
if (decls.length === 0) return null;
|
|
493
|
+
return [
|
|
494
|
+
`${DARK_PROMOTE_MARKER} — base dark tokens mirrored from your @media block so a .dark toggle drives them. */`,
|
|
495
|
+
".dark {",
|
|
496
|
+
...decls,
|
|
497
|
+
"}",
|
|
498
|
+
"/* end shortwind dark-promote */"
|
|
499
|
+
].join("\n");
|
|
500
|
+
}
|
|
501
|
+
const TONE_MARKER = "/* shortwind:tones";
|
|
502
|
+
const TONES = [
|
|
503
|
+
{
|
|
504
|
+
name: "neutral",
|
|
505
|
+
bg: "var(--muted)",
|
|
506
|
+
fg: "var(--muted-foreground)"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
name: "success",
|
|
510
|
+
bg: "oklch(0.962 0.044 156.743)",
|
|
511
|
+
fg: "oklch(0.448 0.119 151.328)",
|
|
512
|
+
darkBg: "oklch(0.393 0.095 152.535)",
|
|
513
|
+
darkFg: "oklch(0.925 0.084 155.995)"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: "warning",
|
|
517
|
+
bg: "oklch(0.962 0.059 95.617)",
|
|
518
|
+
fg: "oklch(0.473 0.137 46.201)",
|
|
519
|
+
darkBg: "oklch(0.414 0.112 45.904)",
|
|
520
|
+
darkFg: "oklch(0.924 0.12 95.746)"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
name: "danger",
|
|
524
|
+
bg: "color-mix(in oklab, var(--destructive) 15%, transparent)",
|
|
525
|
+
fg: "var(--destructive)"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
name: "info",
|
|
529
|
+
bg: "color-mix(in oklab, var(--primary) 15%, transparent)",
|
|
530
|
+
fg: "var(--primary)"
|
|
531
|
+
}
|
|
532
|
+
];
|
|
533
|
+
function buildToneBlock(css) {
|
|
534
|
+
const rule = (name, bg, fg) => `[data-tone="${name}"] { --tone-bg: ${bg}; --tone-fg: ${fg}; }`;
|
|
535
|
+
const lines = [
|
|
536
|
+
`${TONE_MARKER} — semantic tones for tone-aware recipes (@badge, …). Set on an element:`,
|
|
537
|
+
` <span class="@badge" data-tone="success">. Add your own: [data-tone="sev1"] { --tone-bg: …; --tone-fg: … } */`,
|
|
538
|
+
...TONES.map((t) => rule(t.name, t.bg, t.fg))
|
|
539
|
+
];
|
|
540
|
+
const darkTones = TONES.filter((t) => t.darkBg && t.darkFg);
|
|
541
|
+
if (darkTones.length > 0) {
|
|
542
|
+
const darkRules = darkTones.map((t) => " " + rule(t.name, t.darkBg, t.darkFg));
|
|
543
|
+
lines.push(...darkSection(css, darkRules, { mediaWrapRoot: false }));
|
|
544
|
+
}
|
|
545
|
+
lines.push("/* end shortwind tones */");
|
|
546
|
+
return lines.join("\n");
|
|
547
|
+
}
|
|
467
548
|
const COLOR_UTILITY_RE = /^(?:bg|text|border|ring|outline|fill|stroke|divide|accent|caret|decoration|shadow|from|via|to|placeholder)-(.+)$/;
|
|
468
549
|
function referencedThemeTokens(flattened) {
|
|
469
550
|
const out = /* @__PURE__ */ new Set();
|
|
@@ -660,6 +741,23 @@ async function init(options) {
|
|
|
660
741
|
themeAction = "supplemented";
|
|
661
742
|
}
|
|
662
743
|
}
|
|
744
|
+
if (theme.themePath) {
|
|
745
|
+
const css = await readFile(theme.themePath, "utf8");
|
|
746
|
+
let next = ensureDarkClassVariant(css);
|
|
747
|
+
const promote = promoteMediaDarkToClass(next);
|
|
748
|
+
if (promote) next = `${next.replace(/\s*$/, "")}\n\n${promote}\n`;
|
|
749
|
+
if (next !== css) await writeFile(theme.themePath, next);
|
|
750
|
+
}
|
|
751
|
+
let tonesPath = null;
|
|
752
|
+
let tonesAction = "skipped";
|
|
753
|
+
if (theme.themePath) {
|
|
754
|
+
const css = await readFile(theme.themePath, "utf8");
|
|
755
|
+
tonesPath = theme.themePath;
|
|
756
|
+
if (!css.includes("/* shortwind:tones")) {
|
|
757
|
+
await writeFile(theme.themePath, `${css.replace(/\s*$/, "")}\n\n${buildToneBlock(css)}\n`);
|
|
758
|
+
tonesAction = "written";
|
|
759
|
+
}
|
|
760
|
+
}
|
|
663
761
|
const safelistCssPaths = [];
|
|
664
762
|
if (shape.bundler !== "vite" && shape.bundler !== "astro" && skillRegistry) for (const file of findTailwindEntryCssFiles(cwd)) {
|
|
665
763
|
syncSourceDirectiveToFile(file, skillRegistry);
|
|
@@ -682,6 +780,8 @@ async function init(options) {
|
|
|
682
780
|
skillPath,
|
|
683
781
|
themePath: theme.themePath,
|
|
684
782
|
themeAction,
|
|
783
|
+
tonesPath,
|
|
784
|
+
tonesAction,
|
|
685
785
|
supplementedThemeTokens,
|
|
686
786
|
safelistCssPaths,
|
|
687
787
|
missingThemeTokens,
|
|
@@ -2495,4 +2595,4 @@ function formatBenchTable(result) {
|
|
|
2495
2595
|
//#endregion
|
|
2496
2596
|
export { createRegistrySource as A, readConfig as C, init as D, cliVersion as E, extractHeader as F, rewriteHeaderSha as I, sealRecipeFile as L, detectProject as M, buildHeaderLine as N, readLockfile as O, computeBodySha as P, verifyFetchedFamily as R, installedFamilies as S, DEFAULT_REGISTRY as T, reseal as _, extractClassUsages as a, remove as b, verify as c, dev as d, BuildError as f, preset as g, ls as h, DEFAULT_CONTENT as i, resolvePresetFamilies as j, writeLockfile as k, UpgradeError as l, formatLsText as m, formatBenchTable as n, formatFindingsText as o, build as p, ALL_RULES as r, lint as s, bench as t, upgrade as u, NewFamilyError as v, renameFamilyInSource as w, add as x, newFamily as y };
|
|
2497
2597
|
|
|
2498
|
-
//# sourceMappingURL=bench-
|
|
2598
|
+
//# sourceMappingURL=bench-vo5aWJUx.js.map
|