@shortwind/cli 0.1.0-beta.15 → 0.1.0-beta.16

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.
@@ -445,22 +445,14 @@ 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 = [
448
+ function darkSection(lines) {
449
+ return [
451
450
  ".dark {",
452
451
  ...lines,
453
452
  "}"
454
453
  ];
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
454
  }
463
- function buildThemeSupplement(css, missing) {
455
+ function buildThemeSupplement(missing) {
464
456
  const tokens = missing.filter((t) => THEME_LIGHT_VALUES.has(t));
465
457
  if (tokens.length === 0) return null;
466
458
  const light = tokens.map((t) => ` --${t}: ${THEME_LIGHT_VALUES.get(t)};`);
@@ -472,7 +464,7 @@ function buildThemeSupplement(css, missing) {
472
464
  ...light,
473
465
  "}"
474
466
  ];
475
- if (dark.length > 0) lines.push(...darkSection(css, dark));
467
+ if (dark.length > 0) lines.push(...darkSection(dark));
476
468
  lines.push("@theme inline {", ...mapping, "}", "/* end shortwind theme-supplement */");
477
469
  return lines.join("\n");
478
470
  }
@@ -486,17 +478,29 @@ function ensureDarkClassVariant(css) {
486
478
  return `${css.slice(0, at)}\n${DARK_CLASS_VARIANT}${css.slice(at)}`;
487
479
  }
488
480
  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. */`,
481
+ const MEDIA_DARK_ROOT_RE = /@media\s*\(\s*prefers-color-scheme\s*:\s*dark\s*\)\s*\{\s*:root\s*\{([^}]*)\}\s*\}/;
482
+ function convertMediaDarkToClass(css) {
483
+ if (css.includes("/* shortwind:dark-promote")) return {
484
+ css,
485
+ converted: false
486
+ };
487
+ const decls = [...(css.match(MEDIA_DARK_ROOT_RE)?.[1] ?? "").matchAll(/--([\w-]+)\s*:\s*([^;]+);/g)].map((d) => ` --${d[1]}: ${d[2].trim()};`);
488
+ if (decls.length === 0) return {
489
+ css,
490
+ converted: false
491
+ };
492
+ const without = css.replace(MEDIA_DARK_ROOT_RE, "").replace(/\n{3,}/g, "\n\n");
493
+ const block = [
494
+ `${DARK_PROMOTE_MARKER} — dark tokens moved out of the system-preference media query so a .dark toggle is the single source of truth. */`,
495
495
  ".dark {",
496
496
  ...decls,
497
497
  "}",
498
498
  "/* end shortwind dark-promote */"
499
499
  ].join("\n");
500
+ return {
501
+ css: `${without.replace(/\s*$/, "")}\n\n${block}\n`,
502
+ converted: true
503
+ };
500
504
  }
501
505
  const TONE_MARKER = "/* shortwind:tones";
502
506
  const TONES = [
@@ -530,7 +534,7 @@ const TONES = [
530
534
  fg: "var(--primary)"
531
535
  }
532
536
  ];
533
- function buildToneBlock(css) {
537
+ function buildToneBlock() {
534
538
  const rule = (name, bg, fg) => `[data-tone="${name}"] { --tone-bg: ${bg}; --tone-fg: ${fg}; }`;
535
539
  const lines = [
536
540
  `${TONE_MARKER} — semantic tones for tone-aware recipes (@badge, …). Set on an element:`,
@@ -540,7 +544,7 @@ function buildToneBlock(css) {
540
544
  const darkTones = TONES.filter((t) => t.darkBg && t.darkFg);
541
545
  if (darkTones.length > 0) {
542
546
  const darkRules = darkTones.map((t) => " " + rule(t.name, t.darkBg, t.darkFg));
543
- lines.push(...darkSection(css, darkRules, { mediaWrapRoot: false }));
547
+ lines.push(...darkSection(darkRules));
544
548
  }
545
549
  lines.push("/* end shortwind tones */");
546
550
  return lines.join("\n");
@@ -733,7 +737,7 @@ async function init(options) {
733
737
  if (theme.action === "skipped" && theme.themePath && skillRegistry) {
734
738
  const css = await readFile(theme.themePath, "utf8");
735
739
  missingThemeTokens = findMissingThemeTokens(css, skillRegistry.flattened);
736
- const supplement = buildThemeSupplement(css, missingThemeTokens);
740
+ const supplement = buildThemeSupplement(missingThemeTokens);
737
741
  if (supplement) {
738
742
  await writeFile(theme.themePath, `${css.replace(/\s*$/, "")}\n\n${supplement}\n`);
739
743
  supplementedThemeTokens = missingThemeTokens;
@@ -743,9 +747,7 @@ async function init(options) {
743
747
  }
744
748
  if (theme.themePath) {
745
749
  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`;
750
+ const { css: next } = convertMediaDarkToClass(ensureDarkClassVariant(css));
749
751
  if (next !== css) await writeFile(theme.themePath, next);
750
752
  }
751
753
  let tonesPath = null;
@@ -754,7 +756,7 @@ async function init(options) {
754
756
  const css = await readFile(theme.themePath, "utf8");
755
757
  tonesPath = theme.themePath;
756
758
  if (!css.includes("/* shortwind:tones")) {
757
- await writeFile(theme.themePath, `${css.replace(/\s*$/, "")}\n\n${buildToneBlock(css)}\n`);
759
+ await writeFile(theme.themePath, `${css.replace(/\s*$/, "")}\n\n${buildToneBlock()}\n`);
758
760
  tonesAction = "written";
759
761
  }
760
762
  }
@@ -807,7 +809,7 @@ function cliVersion() {
807
809
  }
808
810
  }
809
811
  function pickPackages(bundler) {
810
- const base = ["@shortwind/tailwind"];
812
+ const base = ["@shortwind/cli", "@shortwind/tailwind"];
811
813
  switch (bundler) {
812
814
  case "vite": return [...base, "@shortwind/vite"];
813
815
  case "next": return [...base, "@shortwind/next"];
@@ -923,7 +925,7 @@ async function wireVscodeClassRegex(vscodePath) {
923
925
  parse(next);
924
926
  await writeFile(vscodePath, next.endsWith("\n") ? next : next + "\n");
925
927
  }
926
- const HUSKY_LINE = "npx @shortwind/cli build";
928
+ const HUSKY_LINE = "npx shortwind build";
927
929
  async function installHuskyHook(cwd, huskyPath) {
928
930
  if (!existsSync(path.join(cwd, ".git"))) return null;
929
931
  await mkdir(path.dirname(huskyPath), { recursive: true });
@@ -933,7 +935,7 @@ async function installHuskyHook(cwd, huskyPath) {
933
935
  }
934
936
  const current = await readFile(huskyPath, "utf8");
935
937
  if (current.includes(HUSKY_LINE)) return huskyPath;
936
- await writeFile(huskyPath, current.endsWith("\n") ? current + HUSKY_LINE + "\n" : current + "\nnpx @shortwind/cli build\n", { mode: 493 });
938
+ await writeFile(huskyPath, current.endsWith("\n") ? current + HUSKY_LINE + "\n" : current + "\nnpx shortwind build\n", { mode: 493 });
937
939
  return huskyPath;
938
940
  }
939
941
  async function writeSkillMd(skillPath, recipesDir, families, bundler) {
@@ -2595,4 +2597,4 @@ function formatBenchTable(result) {
2595
2597
  //#endregion
2596
2598
  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 };
2597
2599
 
2598
- //# sourceMappingURL=bench-vo5aWJUx.js.map
2600
+ //# sourceMappingURL=bench-DG0TCu9M.js.map