kss-modern 1.7.0-beta.7 → 1.7.0-beta.8

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.
@@ -1 +1 @@
1
- export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.C0c9PPgd.mjs';
1
+ export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.BCBrjEsE.mjs';
@@ -1 +1 @@
1
- export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.C0c9PPgd.js';
1
+ export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.BCBrjEsE.js';
@@ -3,8 +3,8 @@ import process from 'node:process';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import fs from 'fs-extra';
5
5
  import { glob } from 'tinyglobby';
6
- import { l as logger, s as sanitizeSpecialCharacters, P as PUG_ERROR_OVERLAY_TAG, r as requireZod, e as evaluateMixinSchema, c as compileMixinModule, p as pugErrorFile, a as compileMarkup, g as getZodVersion, d as discoverMixins, M as MIXIN_COMPILE_OPTIONS, b as getMixinWrapperSource, f as slugify, I as INSERT_VITE_PUG_TAG_RE, h as PUG_SRC_RE, t as themeClassList, i as ensureStartingSlash, j as sectionSanitizeId, k as stripPugErrorOverlay, m as generateId, n as replaceWrapperContent, o as formatSourceCode, q as htmlToSearchText } from '../shared/kss-modern.AIWT72eU.mjs';
7
- export { u as createLogger } from '../shared/kss-modern.AIWT72eU.mjs';
6
+ import { l as logger, s as sanitizeSpecialCharacters, P as PUG_ERROR_OVERLAY_TAG, p as prepareSchemaRegistry, r as requireZod, e as evaluateMixinSchema, c as compileMixinModule, a as pugErrorFile, b as compileSection, i as isSchemaSource, g as getZodVersion, d as discoverMixins, f as loadSchemaRegistry, h as evaluateComponentDefinition, j as getMixinPath, M as MIXIN_COMPILE_OPTIONS, k as getMixinWrapperSource, m as slugify, n as MIXIN_MANIFEST_PATH, S as SCHEMA_OUTPUT_DIR, I as INSERT_VITE_PUG_TAG_RE, o as PUG_SRC_RE, t as themeClassList, q as getMixinExplorerHref, u as ensureStartingSlash, v as sectionSanitizeId, w as stripPugErrorOverlay, x as modifierFullpageFileName, y as generateId, z as getMixinStandaloneFileName, A as MIXIN_OVERVIEW_FILE, B as formatSourceCode, C as htmlToSearchText, D as replaceWrapperContent } from '../shared/kss-modern.Cr_kBwur.mjs';
7
+ export { E as createLogger } from '../shared/kss-modern.Cr_kBwur.mjs';
8
8
  import { existsSync, readFileSync } from 'node:fs';
9
9
  import fs$1 from 'node:fs/promises';
10
10
  import { createHash } from 'node:crypto';
@@ -155,7 +155,10 @@ function resolveInsertMarkupForSections(repository, sectionsById, ids) {
155
155
  const entry = repository.get(id);
156
156
  if (!entry)
157
157
  continue;
158
- resolved.set(id, resolveMarkup(entry.markup, repository, sectionsById, /* @__PURE__ */ new Set([id])));
158
+ resolved.set(id, {
159
+ markup: resolveMarkup(entry.markup, repository, sectionsById, /* @__PURE__ */ new Set([id])),
160
+ modifierMarkup: entry.modifierMarkup?.map((markup) => resolveMarkup(markup, repository, sectionsById, /* @__PURE__ */ new Set([id])))
161
+ });
159
162
  }
160
163
  return resolved;
161
164
  }
@@ -177,7 +180,7 @@ function resolveMarkup(markup, repository, sectionsById, visited) {
177
180
  if (!modifier)
178
181
  return errorBlock(refId, `modifier index ${modifierIdx} out of range for section "${refId}"`);
179
182
  const className = modifier.name.replace(/^\./, "");
180
- inserted = inserted.replaceAll("{{modifier_class}}", className);
183
+ inserted = refEntry.modifierMarkup?.[modifierIdx] ?? inserted.replaceAll("{{modifier_class}}", className);
181
184
  }
182
185
  const nextVisited = new Set(visited);
183
186
  nextVisited.add(refId);
@@ -331,6 +334,10 @@ function renderPugErrorOverlay(error, lastHtml = "") {
331
334
  return `${lastHtml}${overlay}`.trim();
332
335
  }
333
336
 
337
+ function cacheSourceOf(source) {
338
+ return source.modifiers?.length ? `${source.markup}
339
+ ${source.modifiers.join("\n")}` : source.markup;
340
+ }
334
341
  const MAX_POOL_SIZE = Math.max(2, os.cpus().length - 1);
335
342
  const INLINE_THRESHOLD = 2;
336
343
  const cache = new PugCompileCache();
@@ -429,10 +436,10 @@ const signals = ["SIGINT", "SIGTERM", "SIGQUIT"];
429
436
  signals.forEach((signal) => process.on(signal, () => {
430
437
  void terminatePugWorkers();
431
438
  }));
432
- async function storeResult(id, markupSource, html, dependencies, mixinUsage) {
439
+ async function storeResult(id, markupSource, html, modifierHtml, dependencies, mixinUsage) {
433
440
  graph.setDependencies(id, dependencies);
434
441
  const depSignatures = await computeDepSignatures(dependencies);
435
- cache.set(id, { markupSource, compiledHtml: html, dependencies, depSignatures, mixinUsage });
442
+ cache.set(id, { markupSource, compiledHtml: html, modifierHtml, dependencies, depSignatures, mixinUsage });
436
443
  }
437
444
  function recordFailure(mode, repository, errors, pugError) {
438
445
  logger.error(`Pug markup failed to compile for section "${pugError.id}": ${pugError.message}`);
@@ -442,24 +449,23 @@ function recordFailure(mode, repository, errors, pugError) {
442
449
  repository.set(pugError.id, { markup: renderPugErrorOverlay(pugError, lastHtml) });
443
450
  }
444
451
  }
445
- async function compileInline(mode, contentDir, repository, id, errors) {
446
- const markupSource = repository.get(id).markup;
452
+ async function compileInline(mode, contentDir, repository, source, id, errors, schemaRegistry) {
447
453
  try {
448
- const { html, dependencies, mixinUsage } = await compileMarkup(contentDir, mode, markupSource, id);
449
- repository.set(id, { markup: html, mixinUsage });
450
- await storeResult(id, markupSource, html, dependencies, mixinUsage);
454
+ const { html, modifierHtml, dependencies, mixinUsage } = await compileSection(contentDir, mode, source.markup, id, schemaRegistry, source.modifiers);
455
+ repository.set(id, { markup: html, modifierMarkup: modifierHtml, mixinUsage });
456
+ await storeResult(id, cacheSourceOf(source), html, modifierHtml, dependencies, mixinUsage);
451
457
  } catch (error) {
452
458
  const message = error instanceof Error ? error.message : String(error);
453
459
  const file = pugErrorFile(error);
454
460
  recordFailure(mode, repository, errors, { id, file: file ? path.resolve(file) : void 0, message });
455
461
  }
456
462
  }
457
- async function compileViaWorkerPool(mode, contentDir, repository, ids, errors) {
463
+ async function compileViaWorkerPool(mode, contentDir, repository, sources, ids, errors, schemaRegistry) {
458
464
  const tasks = ids.map(async (id) => {
459
- const markupSource = repository.get(id).markup;
465
+ const source = sources.get(id);
460
466
  let result;
461
467
  try {
462
- result = await runPinned(id, { id, mode, html: markupSource, contentDir });
468
+ result = await runPinned(id, { id, mode, html: source.markup, contentDir, schemaRegistry, modifiers: source.modifiers });
463
469
  } catch (error) {
464
470
  const message = error instanceof Error ? error.message : String(error);
465
471
  recordFailure(mode, repository, errors, { id, message });
@@ -473,8 +479,8 @@ async function compileViaWorkerPool(mode, contentDir, repository, ids, errors) {
473
479
  });
474
480
  return;
475
481
  }
476
- repository.set(id, { markup: result.html, mixinUsage: result.mixinUsage });
477
- await storeResult(id, markupSource, result.html, result.dependencies, result.mixinUsage);
482
+ repository.set(id, { markup: result.html, modifierMarkup: result.modifierHtml, mixinUsage: result.mixinUsage });
483
+ await storeResult(id, cacheSourceOf(source), result.html, result.modifierHtml, result.dependencies, result.mixinUsage);
478
484
  });
479
485
  await Promise.all(tasks);
480
486
  }
@@ -484,12 +490,12 @@ async function compileIds(mode, contentDir, repository, ids) {
484
490
  return clonedRepository;
485
491
  const misses = [];
486
492
  await Promise.all(ids.map(async (id) => {
487
- const entry = clonedRepository.get(id);
488
- if (!entry)
493
+ const source = repository.get(id);
494
+ if (!source)
489
495
  return;
490
- if (await cache.isFresh(id, entry.markup)) {
496
+ if (await cache.isFresh(id, cacheSourceOf(source))) {
491
497
  const cached = cache.get(id);
492
- clonedRepository.set(id, { markup: cached.compiledHtml, mixinUsage: cached.mixinUsage });
498
+ clonedRepository.set(id, { markup: cached.compiledHtml, modifierMarkup: cached.modifierHtml, mixinUsage: cached.mixinUsage });
493
499
  graph.setDependencies(id, cached.dependencies);
494
500
  return;
495
501
  }
@@ -497,6 +503,10 @@ async function compileIds(mode, contentDir, repository, ids) {
497
503
  }));
498
504
  if (misses.length === 0)
499
505
  return clonedRepository;
506
+ const registry = await prepareSchemaRegistry(contentDir);
507
+ const schemaRegistry = registry && !("error" in registry) ? registry.nodeRegistry : void 0;
508
+ if (registry && "error" in registry)
509
+ logger.error(`The .schema.ts files could not be prepared: ${registry.error}`);
500
510
  const errors = [];
501
511
  if (!workerFilePathResolved && misses.length > INLINE_THRESHOLD && !warnedMissingWorker) {
502
512
  warnedMissingWorker = true;
@@ -504,9 +514,9 @@ async function compileIds(mode, contentDir, repository, ids) {
504
514
  }
505
515
  const useInline = !workerFilePathResolved || mode === "development" && misses.length <= INLINE_THRESHOLD;
506
516
  if (useInline) {
507
- await Promise.all(misses.map((id) => compileInline(mode, contentDir, clonedRepository, id, errors)));
517
+ await Promise.all(misses.map((id) => compileInline(mode, contentDir, clonedRepository, repository.get(id), id, errors, schemaRegistry)));
508
518
  } else {
509
- await compileViaWorkerPool(mode, contentDir, clonedRepository, misses, errors);
519
+ await compileViaWorkerPool(mode, contentDir, clonedRepository, repository, misses, errors, schemaRegistry);
510
520
  }
511
521
  if (mode === "production" && errors.length > 0) {
512
522
  throw new Error(
@@ -618,20 +628,7 @@ async function writeJsonSchemaFiles(directory, manifest, previous = /* @__PURE__
618
628
  return written;
619
629
  }
620
630
 
621
- const MIXIN_MANIFEST_PATH = "mixins/manifest.json";
622
- const MIXIN_OVERVIEW_FILE = "mixins.html";
623
- function getMixinExplorerHref(id) {
624
- return `${MIXIN_OVERVIEW_FILE}#mixin=${id}`;
625
- }
626
- function getMixinPath(name, mixinName) {
627
- const segments = (mixinName ?? "").split("/").map((segment) => segment.trim()).filter(Boolean);
628
- return segments.length > 0 ? segments : [name];
629
- }
630
- function getMixinStandaloneFileName(id) {
631
- return `mixins-${id}-standalone.html`;
632
- }
633
-
634
- const CACHE_FORMAT = 4;
631
+ const CACHE_FORMAT = 5;
635
632
  const DEFAULT_CACHE_DIR = "node_modules/.cache/kss-modern";
636
633
  const MIXIN_GRAPH_PREFIX = "mixin:";
637
634
  let kssModernVersion;
@@ -704,7 +701,7 @@ function assignIds(mixins) {
704
701
  function getNavigationSignature(manifest) {
705
702
  return JSON.stringify(manifest?.mixins.map((entry) => [entry.id, entry.name, entry.path, entry.hasSchema]) ?? []);
706
703
  }
707
- async function writeOutput(outDir, manifest, modules) {
704
+ async function writeOutput(outDir, manifest, modules, schemaFiles) {
708
705
  const mixinsDirectory = path.join(outDir, "mixins");
709
706
  if (manifest.mixins.length === 0) {
710
707
  await fs$1.rm(mixinsDirectory, { recursive: true, force: true });
@@ -712,9 +709,14 @@ async function writeOutput(outDir, manifest, modules) {
712
709
  }
713
710
  await Promise.all([
714
711
  ...[...modules].map(([modulePath, code]) => logicalWriteFile(path.join(outDir, modulePath), code)),
712
+ ...[...schemaFiles].map(([filePath, code]) => logicalWriteFile(path.join(outDir, filePath), code)),
715
713
  logicalWriteFile(path.join(outDir, MIXIN_MANIFEST_PATH), `${JSON.stringify(manifest, null, 2)}
716
714
  `)
717
715
  ]);
716
+ const schemasDirectory = path.join(outDir, SCHEMA_OUTPUT_DIR);
717
+ const currentHash = manifest.schemaRegistry?.slice(SCHEMA_OUTPUT_DIR.length + 1).split("/")[0];
718
+ const hashDirectories = await fs$1.readdir(schemasDirectory).catch(() => []);
719
+ await Promise.all(hashDirectories.filter((name) => name !== currentHash).map((name) => fs$1.rm(path.join(schemasDirectory, name), { recursive: true, force: true })));
718
720
  const referenced = new Set([...modules.keys()].map((modulePath) => path.basename(modulePath)));
719
721
  const present = await fs$1.readdir(mixinsDirectory).catch(() => []);
720
722
  await Promise.all(present.filter((file) => file.endsWith(".js") && !referenced.has(file)).map((file) => fs$1.rm(path.join(mixinsDirectory, file), { force: true })));
@@ -730,7 +732,8 @@ function createMixinPipeline(config) {
730
732
  const build = async (changedFiles) => {
731
733
  const startedAt = performance.now();
732
734
  const changedPugFiles = changedFiles?.filter((file) => file.endsWith(".pug")).map((file) => path.resolve(file));
733
- if (lastResult && changedPugFiles && changedPugFiles.length === 0)
735
+ const hasChangedSchemaSources = changedFiles?.some((file) => !file.endsWith(".pug") && isSchemaSource(file)) ?? false;
736
+ if (lastResult && changedPugFiles && changedPugFiles.length === 0 && !hasChangedSchemaSources)
734
737
  return lastResult;
735
738
  const zodVersion = getZodVersion();
736
739
  if (!zodVersion) {
@@ -787,18 +790,55 @@ function createMixinPipeline(config) {
787
790
  }));
788
791
  const discovered = [...pugFiles].sort().flatMap((file) => (data.files[file]?.mixins ?? []).map((mixin) => ({ file, mixin })));
789
792
  const ids = assignIds(discovered);
790
- const getSchemaForm = (mixin) => mixin.isDefineComponent ? "defineComponent" : "mixinSchema";
791
- const schemaKeys = discovered.map(({ mixin }) => mixin.schemaSource === void 0 ? void 0 : hashContent(`${getSchemaForm(mixin)}
793
+ const getSchemaForm = (mixin) => mixin.isSchemaModule ? "module" : mixin.isDefineComponent ? "defineComponent" : "mixinSchema";
794
+ const registry = discovered.some(({ mixin }) => mixin.isSchemaModule) ? await prepareSchemaRegistry(config.contentDir) : void 0;
795
+ const registryKey = registry ? "error" in registry ? `error:${registry.error}` : registry.hash : "none";
796
+ const schemaKeys = discovered.map(({ mixin }) => {
797
+ if (mixin.schemaSource === void 0)
798
+ return void 0;
799
+ const form = getSchemaForm(mixin);
800
+ return hashContent(form === "module" ? `${form}
801
+ ${mixin.mixinName}
802
+ ${registryKey}
803
+ ${zodVersion}` : `${form}
792
804
  ${mixin.schemaSource}
793
- ${zodVersion}`));
805
+ ${zodVersion}`);
806
+ });
794
807
  const usedSchemaKeys = new Set(schemaKeys.filter((key) => key !== void 0));
795
808
  const schemaMisses = /* @__PURE__ */ new Map();
809
+ const moduleMisses = /* @__PURE__ */ new Map();
796
810
  discovered.forEach(({ mixin }, index) => {
797
811
  const schemaKey = schemaKeys[index];
798
- if (schemaKey !== void 0 && !data.schemas[schemaKey])
812
+ if (schemaKey === void 0 || data.schemas[schemaKey])
813
+ return;
814
+ if (mixin.isSchemaModule)
815
+ moduleMisses.set(schemaKey, mixin.mixinName ?? "");
816
+ else
799
817
  schemaMisses.set(schemaKey, { source: mixin.schemaSource, form: getSchemaForm(mixin) });
800
818
  });
801
819
  const evaluated = await evaluateSchemaJobs([...schemaMisses].map(([id, job]) => ({ id, ...job })));
820
+ if (moduleMisses.size > 0) {
821
+ const z = requireZod();
822
+ let components;
823
+ let loadError;
824
+ if (registry && !("error" in registry)) {
825
+ try {
826
+ components = (await loadSchemaRegistry(registry.nodeRegistry)).components;
827
+ } catch (error) {
828
+ loadError = `The .schema.ts files could not be loaded: ${error instanceof Error ? error.message : String(error)}`;
829
+ }
830
+ }
831
+ for (const [schemaKey, name] of moduleMisses) {
832
+ if (!registry)
833
+ evaluated.set(schemaKey, { error: `No .schema.ts file found for "${name}"` });
834
+ else if ("error" in registry)
835
+ evaluated.set(schemaKey, { error: registry.error });
836
+ else if (loadError !== void 0)
837
+ evaluated.set(schemaKey, { error: loadError });
838
+ else
839
+ evaluated.set(schemaKey, evaluateComponentDefinition(z, components.get(name), name));
840
+ }
841
+ }
802
842
  for (const [schemaKey, schema] of evaluated) {
803
843
  data.schemas[schemaKey] = schema;
804
844
  isCacheDirty = true;
@@ -828,6 +868,8 @@ ${schema.error}`);
828
868
  if (schema.name !== void 0)
829
869
  entry.path = getMixinPath(mixin.name, schema.name);
830
870
  entry.hasSchema = true;
871
+ if (mixin.isSchemaModule)
872
+ entry.isSchemaModule = true;
831
873
  entry.jsonSchema = schema.jsonSchema;
832
874
  if (typeof schema.jsonSchema.description === "string")
833
875
  entry.description = schema.jsonSchema.description;
@@ -941,7 +983,10 @@ ${failures.join("\n\n")}`] : []
941
983
  }
942
984
  }
943
985
  const manifest = { mixins: entries.filter((entry) => entry.hasSchema || entry.schemaError !== void 0) };
944
- await writeOutput(config.outDir, manifest, modules);
986
+ const schemaFiles = registry && !("error" in registry) ? registry.browserFiles : /* @__PURE__ */ new Map();
987
+ if (registry && !("error" in registry))
988
+ manifest.schemaRegistry = registry.browserRegistry;
989
+ await writeOutput(config.outDir, manifest, modules, schemaFiles);
945
990
  if (config.mixinJsonSchemaDir)
946
991
  jsonSchemaFiles = await writeJsonSchemaFiles(config.mixinJsonSchemaDir, manifest, jsonSchemaFiles);
947
992
  if (isCacheDirty)
@@ -1848,8 +1893,8 @@ async function generateFullPageFile(data) {
1848
1893
  <meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.brandColor.light}">
1849
1894
  <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.brandColor.dark}">
1850
1895
  ` : `<meta name="theme-color" content="${data.brandColor}">`}
1851
- <script type="module" src="styleguide-assets/fullpage-aWqc0gjm.js"><\/script>
1852
- ${data.playgroundConfig ? '<script type="module" src="styleguide-assets/playground-B_pD0mat.js"><\/script>' : ""}
1896
+ <script type="module" src="styleguide-assets/fullpage-DTD81JJi.js"><\/script>
1897
+ ${data.playgroundConfig ? '<script type="module" src="styleguide-assets/playground-A7z-WgLU.js"><\/script>' : ""}
1853
1898
  ${computedStyleTags}
1854
1899
  ${computedThemeStyleTags}
1855
1900
  </head>
@@ -2458,7 +2503,9 @@ function getMainContentRegular(section, config, mixinUsageHtml = "") {
2458
2503
  </svg>
2459
2504
  </h3>
2460
2505
  <ul class="mt-4 grid gap-6 overflow-hidden rounded-2xl border p-6 border-styleguide-border bg-styleguide-bg-highlight md:gap-x-10 md:gap-y-14">
2461
- ${section.modifiers?.map((modifier) => `
2506
+ ${section.modifiers?.map((modifier, modifierIndex) => {
2507
+ const modifierFileName = section.modifierMarkup?.[modifierIndex] !== void 0 ? modifierFullpageFileName(section.fullpageFileName, modifierIndex) : section.fullpageFileName;
2508
+ return `
2462
2509
  <li>
2463
2510
  <div>
2464
2511
  <div class="flex items-center justify-between gap-6">
@@ -2478,7 +2525,7 @@ function getMainContentRegular(section, config, mixinUsageHtml = "") {
2478
2525
 
2479
2526
  <a
2480
2527
  class="p-2 group"
2481
- href="${section.fullpageFileName}?modifier=${modifier.value}"
2528
+ href="${modifierFileName}?modifier=${modifier.value}"
2482
2529
  target="_blank"
2483
2530
  title="Open in fullpage"
2484
2531
  >
@@ -2492,7 +2539,7 @@ function getMainContentRegular(section, config, mixinUsageHtml = "") {
2492
2539
 
2493
2540
  <div class="preview-resize-container relative max-w-full group/resize [&.is-resizing_iframe]:pointer-events-none mt-2">
2494
2541
  <iframe
2495
- src="${section.fullpageFileName}"
2542
+ src="${modifierFileName}"
2496
2543
  class="preview-iframe"
2497
2544
  data-preview="true"
2498
2545
  data-modifier="${modifier.value}"
@@ -2503,7 +2550,8 @@ function getMainContentRegular(section, config, mixinUsageHtml = "") {
2503
2550
  </div>
2504
2551
  </div>
2505
2552
  </li>
2506
- `).join("\n")}
2553
+ `;
2554
+ }).join("\n")}
2507
2555
  </ul>
2508
2556
  ` : ""}
2509
2557
  `;
@@ -2960,7 +3008,7 @@ document.addEventListener("DOMContentLoaded", () => {
2960
3008
  //#endregion
2961
3009
  ;
2962
3010
  <\/script>
2963
- <script type="module" src="styleguide-assets/preview-C7DV5Nmc.js"><\/script>
3011
+ <script type="module" src="styleguide-assets/preview-BA2cMrzH.js"><\/script>
2964
3012
  <link rel="preload" href="styleguide-assets/fonts/geist-mono-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
2965
3013
  <link rel="preload" href="styleguide-assets/fonts/geist-mono-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
2966
3014
  <link rel="preload" href="styleguide-assets/fonts/geist-mono-latin-300-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
@@ -3123,7 +3171,8 @@ function getMixinExplorerHtml(manifest, config) {
3123
3171
  const tabs = [
3124
3172
  { id: "controls", title: "Controls" },
3125
3173
  { id: "code", title: "Code" },
3126
- { id: "pug", title: "Pug call" }
3174
+ { id: "pug", title: "Pug call" },
3175
+ { id: "output", title: "Output" }
3127
3176
  ];
3128
3177
  return `
3129
3178
  <section
@@ -3242,6 +3291,10 @@ function getMixinExplorerHtml(manifest, config) {
3242
3291
  <div id="mixin-explorer-panel-pug" class="hidden min-h-0 grow overflow-auto p-4 text-sm" role="tabpanel" aria-labelledby="mixin-explorer-tab-pug" tabindex="-1">
3243
3292
  <code class="block whitespace-pre-wrap break-all font-mono text-styleguide-highlight" data-playground-pug-call></code>
3244
3293
  </div>
3294
+ <div id="mixin-explorer-panel-output" class="hidden min-h-0 grow overflow-auto p-4 text-sm" role="tabpanel" aria-labelledby="mixin-explorer-tab-output" tabindex="-1">
3295
+ <p class="mb-3 max-w-[65ch]">What the template received: the props after defaults and <code class="font-mono">.transform()</code>. With a transform this is the object the integration hands to the template.</p>
3296
+ <pre class="whitespace-pre-wrap break-all font-mono text-styleguide-highlight" data-playground-output></pre>
3297
+ </div>
3245
3298
  </div>
3246
3299
  </div>
3247
3300
  </section>
@@ -3382,10 +3435,10 @@ function watchStyleguideForChanges(watchPath, handlers) {
3382
3435
  handleCss(filePath);
3383
3436
  else if (isMarkdownFile(filePath))
3384
3437
  requestStructural();
3385
- else if (isMarkupFile(filePath))
3438
+ else if (isMarkupFile(filePath) || isSchemaSource(filePath))
3386
3439
  requestMarkup(filePath);
3387
3440
  };
3388
- const validFileTypes = [...VALID_CSS_FILE_TYPES, ".md", ...MARKUP_FILE_TYPES];
3441
+ const validFileTypes = [...VALID_CSS_FILE_TYPES, ".md", ...MARKUP_FILE_TYPES, ".ts"];
3389
3442
  return chokidar.watch(watchPath, {
3390
3443
  ignoreInitial: true,
3391
3444
  usePolling: USE_POLLING,
@@ -3515,14 +3568,22 @@ function getNextPageControlsData(pageSequence, href) {
3515
3568
  async function writeFullPageFile(config, baseDirectory, section) {
3516
3569
  if (section.markup === void 0 || section.markup.length === 0)
3517
3570
  return;
3571
+ await Promise.all([
3572
+ writeFullPageVariant(config, baseDirectory, section, section.markup, section.fullpageFileName),
3573
+ ...(section.modifierMarkup ?? []).map(
3574
+ (markup, index) => writeFullPageVariant(config, baseDirectory, section, markup, modifierFullpageFileName(section.fullpageFileName, index))
3575
+ )
3576
+ ]);
3577
+ }
3578
+ async function writeFullPageVariant(config, baseDirectory, section, markup, fileName) {
3518
3579
  try {
3519
- let htmlMarkup = section.markup;
3580
+ let htmlMarkup = markup;
3520
3581
  if (section.wrapper) {
3521
3582
  htmlMarkup = replaceWrapperContent(section.wrapper, htmlMarkup);
3522
3583
  }
3523
3584
  await generateFullPageFile({
3524
3585
  id: section.id,
3525
- filePath: path.join(baseDirectory, section.fullpageFileName),
3586
+ filePath: path.join(baseDirectory, fileName),
3526
3587
  page: {
3527
3588
  title: section.header,
3528
3589
  description: !section.hasMarkdownDescription ? section.description : void 0,
@@ -3646,11 +3707,12 @@ function reindexInsertMarkupConsumer(context, id) {
3646
3707
  }
3647
3708
  }
3648
3709
  async function assignMarkup(nodeById, resolved) {
3649
- await Promise.all([...resolved].map(async ([id, markup]) => {
3710
+ await Promise.all([...resolved].map(async ([id, { markup, modifierMarkup }]) => {
3650
3711
  const node = nodeById.get(id);
3651
3712
  if (!node)
3652
3713
  return;
3653
3714
  node.markup = markup;
3715
+ node.modifierMarkup = modifierMarkup;
3654
3716
  node.sourceCode = await formatSourceCode(stripPugErrorOverlay(markup), id);
3655
3717
  }));
3656
3718
  }
@@ -3679,7 +3741,7 @@ async function buildContext(config, mixinsPromise) {
3679
3741
  });
3680
3742
  const repository = /* @__PURE__ */ new Map();
3681
3743
  for (const [id, markup] of rawMarkupBySection)
3682
- repository.set(id, { markup });
3744
+ repository.set(id, { markup, modifiers: sectionsById.get(id)?.modifiers.map((modifier) => modifier.name) });
3683
3745
  const compiledRepository = await compilePugMarkup(config.mode, config.contentDir, repository);
3684
3746
  const insertMarkupConsumers = /* @__PURE__ */ new Map();
3685
3747
  for (const [id, entry] of compiledRepository) {
@@ -3809,7 +3871,7 @@ async function rebuildSections(config, context, changedSectionIds) {
3809
3871
  for (const id of affected) {
3810
3872
  const raw = context.rawMarkupBySection.get(id);
3811
3873
  if (raw !== void 0)
3812
- subset.set(id, { markup: raw });
3874
+ subset.set(id, { markup: raw, modifiers: context.sectionsById.get(id)?.modifiers.map((modifier) => modifier.name) });
3813
3875
  }
3814
3876
  if (subset.size === 0)
3815
3877
  return;
@@ -1,4 +1,4 @@
1
- import { S as StyleguideConfiguration, M as MixinUsageNode } from '../../shared/kss-modern.C0c9PPgd.mjs';
1
+ import { S as StyleguideConfiguration, M as MixinUsageNode } from '../../shared/kss-modern.BCBrjEsE.mjs';
2
2
 
3
3
  type MixinSchemaResult = {
4
4
  jsonSchema: Record<string, unknown>;
@@ -7,8 +7,11 @@ type MixinSchemaResult = {
7
7
  } | {
8
8
  error: string;
9
9
  };
10
- /** How a mixin declares its schema, see `./discovery.ts`. */
11
- type MixinSchemaForm = 'defineComponent' | 'mixinSchema';
10
+ /**
11
+ * How a mixin declares its schema, see `./discovery.ts`: in a `defineComponent` block, in a
12
+ * `mixinSchema` block, or by name in a `.schema.ts` file (`module`, see `./schema-registry.ts`).
13
+ */
14
+ type MixinSchemaForm = 'defineComponent' | 'mixinSchema' | 'module';
12
15
 
13
16
  type Mode = StyleguideConfiguration['mode'];
14
17
 
@@ -18,6 +21,10 @@ interface PugSectionJob {
18
21
  mode: Mode;
19
22
  contentDir: `${string}/`;
20
23
  html: string;
24
+ /** The Node registry module of the `.schema.ts` files, when the content directory has any. */
25
+ schemaRegistry?: string;
26
+ /** The section's KSS modifier names, each rendered once more, see `compileSection`. */
27
+ modifiers?: string[];
21
28
  }
22
29
  /** Precompile one mixin into its playground render module (see `lib/mixins`). */
23
30
  interface PugMixinJob {
@@ -37,6 +44,7 @@ type PugWorkerInput = PugSectionJob | PugMixinJob | PugSchemaJob;
37
44
  interface PugWorkerSuccess {
38
45
  id: string;
39
46
  html: string;
47
+ modifierHtml?: string[];
40
48
  dependencies: string[];
41
49
  mixinUsage: MixinUsageNode[];
42
50
  }
@@ -1,4 +1,4 @@
1
- import { S as StyleguideConfiguration, M as MixinUsageNode } from '../../shared/kss-modern.C0c9PPgd.js';
1
+ import { S as StyleguideConfiguration, M as MixinUsageNode } from '../../shared/kss-modern.BCBrjEsE.js';
2
2
 
3
3
  type MixinSchemaResult = {
4
4
  jsonSchema: Record<string, unknown>;
@@ -7,8 +7,11 @@ type MixinSchemaResult = {
7
7
  } | {
8
8
  error: string;
9
9
  };
10
- /** How a mixin declares its schema, see `./discovery.ts`. */
11
- type MixinSchemaForm = 'defineComponent' | 'mixinSchema';
10
+ /**
11
+ * How a mixin declares its schema, see `./discovery.ts`: in a `defineComponent` block, in a
12
+ * `mixinSchema` block, or by name in a `.schema.ts` file (`module`, see `./schema-registry.ts`).
13
+ */
14
+ type MixinSchemaForm = 'defineComponent' | 'mixinSchema' | 'module';
12
15
 
13
16
  type Mode = StyleguideConfiguration['mode'];
14
17
 
@@ -18,6 +21,10 @@ interface PugSectionJob {
18
21
  mode: Mode;
19
22
  contentDir: `${string}/`;
20
23
  html: string;
24
+ /** The Node registry module of the `.schema.ts` files, when the content directory has any. */
25
+ schemaRegistry?: string;
26
+ /** The section's KSS modifier names, each rendered once more, see `compileSection`. */
27
+ modifiers?: string[];
21
28
  }
22
29
  /** Precompile one mixin into its playground render module (see `lib/mixins`). */
23
30
  interface PugMixinJob {
@@ -37,6 +44,7 @@ type PugWorkerInput = PugSectionJob | PugMixinJob | PugSchemaJob;
37
44
  interface PugWorkerSuccess {
38
45
  id: string;
39
46
  html: string;
47
+ modifierHtml?: string[];
40
48
  dependencies: string[];
41
49
  mixinUsage: MixinUsageNode[];
42
50
  }
@@ -1,12 +1,16 @@
1
1
  import { parentPort } from 'node:worker_threads';
2
- import { r as requireZod, e as evaluateMixinSchema, c as compileMixinModule, a as compileMarkup, p as pugErrorFile } from '../../shared/kss-modern.AIWT72eU.mjs';
2
+ import { r as requireZod, e as evaluateMixinSchema, c as compileMixinModule, b as compileSection, a as pugErrorFile } from '../../shared/kss-modern.Cr_kBwur.mjs';
3
3
  import 'node:path';
4
4
  import 'pug';
5
5
  import 'node:fs';
6
6
  import 'node:fs/promises';
7
7
  import 'consola';
8
8
  import 'consola/utils';
9
+ import 'node:crypto';
9
10
  import 'node:module';
11
+ import 'node:process';
12
+ import 'node:url';
13
+ import 'tinyglobby';
10
14
  import 'pug-walk';
11
15
  import 'pug-lexer';
12
16
  import 'pug-parser';
@@ -29,8 +33,8 @@ parentPort.on("message", async (data) => {
29
33
  parentPort.postMessage({ id, code, dependencies: dependencies2 });
30
34
  return;
31
35
  }
32
- const { html: compiled, dependencies, mixinUsage } = await compileMarkup(data.contentDir, data.mode, data.html, id);
33
- parentPort.postMessage({ id, html: compiled, dependencies, mixinUsage });
36
+ const { html: compiled, modifierHtml, dependencies, mixinUsage } = await compileSection(data.contentDir, data.mode, data.html, id, data.schemaRegistry, data.modifiers);
37
+ parentPort.postMessage({ id, html: compiled, modifierHtml, dependencies, mixinUsage });
34
38
  } catch (error) {
35
39
  const message = error instanceof Error ? error.message : String(error);
36
40
  parentPort.postMessage({ id, error: message, file: pugErrorFile(error) });
@@ -25,6 +25,8 @@ interface MixinManifestEntry {
25
25
  line: number;
26
26
  /** The mixin declares a usable schema (`defineComponent` or `mixinSchema`), so it gets a playground. */
27
27
  hasSchema: boolean;
28
+ /** The schema lives in a `.schema.ts` file and needs the manifest's `schemaRegistry`. */
29
+ isSchemaModule?: boolean;
28
30
  /** `.describe()` of the schema itself, shown under the mixin's name. */
29
31
  description?: string;
30
32
  /** The schema as JSON Schema (`io: 'input'`), present when `hasSchema`. */
@@ -46,6 +48,11 @@ interface MixinManifestEntry {
46
48
  */
47
49
  interface MixinManifest {
48
50
  mixins: MixinManifestEntry[];
51
+ /**
52
+ * The registry module of the `.schema.ts` files, relative to the output directory. The
53
+ * playground imports it before rendering a mixin that names its component in `defineComponent`.
54
+ */
55
+ schemaRegistry?: string;
49
56
  }
50
57
 
51
58
  interface MixinBuildStats {
@@ -100,6 +107,11 @@ interface in2Section {
100
107
  markup: string;
101
108
  /** `markup` formatted for the code views. Set once the markup is compiled. */
102
109
  sourceCode?: string;
110
+ /**
111
+ * Pug markup rendered once per modifier, in the order of `modifiers`. Each one gets its own
112
+ * fullpage file, see `modifierFullpageFileName`. Plain HTML markup has none.
113
+ */
114
+ modifierMarkup?: string[];
103
115
  modifiers: {
104
116
  value: string;
105
117
  description: string;
@@ -151,6 +163,8 @@ interface MixinUsageNode {
151
163
  /** A section's markup, compiled, with the mixins it called while rendering. */
152
164
  interface CompiledSection {
153
165
  markup: string;
166
+ /** The markup rendered per modifier, in the order of the section's modifiers, see `compileSection`. */
167
+ modifierMarkup?: string[];
154
168
  mixinUsage?: MixinUsageNode[];
155
169
  }
156
170
 
@@ -25,6 +25,8 @@ interface MixinManifestEntry {
25
25
  line: number;
26
26
  /** The mixin declares a usable schema (`defineComponent` or `mixinSchema`), so it gets a playground. */
27
27
  hasSchema: boolean;
28
+ /** The schema lives in a `.schema.ts` file and needs the manifest's `schemaRegistry`. */
29
+ isSchemaModule?: boolean;
28
30
  /** `.describe()` of the schema itself, shown under the mixin's name. */
29
31
  description?: string;
30
32
  /** The schema as JSON Schema (`io: 'input'`), present when `hasSchema`. */
@@ -46,6 +48,11 @@ interface MixinManifestEntry {
46
48
  */
47
49
  interface MixinManifest {
48
50
  mixins: MixinManifestEntry[];
51
+ /**
52
+ * The registry module of the `.schema.ts` files, relative to the output directory. The
53
+ * playground imports it before rendering a mixin that names its component in `defineComponent`.
54
+ */
55
+ schemaRegistry?: string;
49
56
  }
50
57
 
51
58
  interface MixinBuildStats {
@@ -100,6 +107,11 @@ interface in2Section {
100
107
  markup: string;
101
108
  /** `markup` formatted for the code views. Set once the markup is compiled. */
102
109
  sourceCode?: string;
110
+ /**
111
+ * Pug markup rendered once per modifier, in the order of `modifiers`. Each one gets its own
112
+ * fullpage file, see `modifierFullpageFileName`. Plain HTML markup has none.
113
+ */
114
+ modifierMarkup?: string[];
103
115
  modifiers: {
104
116
  value: string;
105
117
  description: string;
@@ -151,6 +163,8 @@ interface MixinUsageNode {
151
163
  /** A section's markup, compiled, with the mixins it called while rendering. */
152
164
  interface CompiledSection {
153
165
  markup: string;
166
+ /** The markup rendered per modifier, in the order of the section's modifiers, see `compileSection`. */
167
+ modifierMarkup?: string[];
154
168
  mixinUsage?: MixinUsageNode[];
155
169
  }
156
170