kss-modern 1.2.1 → 1.3.0-beta.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.
@@ -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, I as INSERT_VITE_PUG_TAG_RE, P as PUG_SRC_RE, a as PUG_ERROR_OVERLAY_TAG, c as compileMarkup, p as pugErrorFile, b as slugify, d as sectionSanitizeId, e as stripPugErrorOverlay, f as ensureStartingSlash, g as generateId, r as replaceWrapperContent, h as htmlToSearchText } from '../shared/kss-modern.rh78o-vW.mjs';
7
- export { i as createLogger } from '../shared/kss-modern.rh78o-vW.mjs';
6
+ import { l as logger, s as sanitizeSpecialCharacters, I as INSERT_VITE_PUG_TAG_RE, P as PUG_SRC_RE, a as PUG_ERROR_OVERLAY_TAG, c as compileMarkup, p as pugErrorFile, b as slugify, d as sectionSanitizeId, e as stripPugErrorOverlay, f as ensureStartingSlash, g as generateId, r as replaceWrapperContent, h as htmlToSearchText } from '../shared/kss-modern.BQiL0d8K.mjs';
7
+ export { i as createLogger } from '../shared/kss-modern.BQiL0d8K.mjs';
8
8
  import htmlLang from '@shikijs/langs/html';
9
9
  import markdownLang from '@shikijs/langs/markdown';
10
10
  import scssLang from '@shikijs/langs/scss';
@@ -1230,6 +1230,7 @@ async function logicalWriteFile(filepath, content) {
1230
1230
  }
1231
1231
 
1232
1232
  async function generateFullPageFile(data) {
1233
+ const supportsDarkMode = !(data.deactivateDarkMode ?? false);
1233
1234
  const computedScriptTags = data.js.filter((entry) => entry.type !== "overwriteStyleguide").map((js) => {
1234
1235
  const additionalAttributes = js.additionalAttributes ? Object.entries(js.additionalAttributes).map(([key, value]) => `${key}="${value}"`).join(" ") : "";
1235
1236
  return `<script src="${js.src}" ${additionalAttributes}><\/script>`;
@@ -1239,7 +1240,7 @@ async function generateFullPageFile(data) {
1239
1240
  }).join("\n");
1240
1241
  const content = `
1241
1242
  <!DOCTYPE html>
1242
- <html lang="${data.page.lang}"${data.page.htmlclass ? ` class="scroll-smooth ${data.page.htmlclass}"` : ""}>
1243
+ <html lang="${data.page.lang}"${data.page.htmlclass ? ` class="scroll-smooth ${data.page.htmlclass}"` : ""} data-styleguide-dark-mode="${supportsDarkMode}">
1243
1244
  <head>
1244
1245
  <title>${sanitizeSpecialCharacters(data.page.title)}</title>
1245
1246
  ${data.page.description ? `<meta name="description" content="${sanitizeSpecialCharacters(data.page.description)}">` : ""}
@@ -1252,7 +1253,7 @@ async function generateFullPageFile(data) {
1252
1253
  <meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.theme.light}">
1253
1254
  <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.theme.dark}">
1254
1255
  ` : `<meta name="theme-color" content="${data.theme}">`}
1255
- <script type="module" src="/styleguide-assets/fullpage-CGBSSxKh.js"><\/script>
1256
+ <script type="module" src="/styleguide-assets/fullpage-DpAT8aw3.js"><\/script>
1256
1257
  ${computedStyleTags}
1257
1258
  </head>
1258
1259
  <body${data.page.bodyclass ? ` class="${data.page.bodyclass}"` : ""}>
@@ -2059,7 +2060,7 @@ async function generatePreviewFile(data) {
2059
2060
  <meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.theme.light}">
2060
2061
  <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.theme.dark}">
2061
2062
  ` : `<meta name="theme-color" content="${data.theme}">`}
2062
- <link rel="stylesheet" type="text/css" href="/styleguide-assets/kss-modern-3dYdkdaU.css">
2063
+ <link rel="stylesheet" type="text/css" href="/styleguide-assets/kss-modern-Bw6-exnr.css">
2063
2064
  <script>
2064
2065
  //#region client/lib/iframe-resize.ts
2065
2066
  var e = [
@@ -2170,8 +2171,16 @@ var u = async (e) => {
2170
2171
  normal: "theme-normal",
2171
2172
  light: "theme-light",
2172
2173
  dark: "theme-dark"
2174
+ }, f = {
2175
+ normal: "light dark",
2176
+ light: "only light",
2177
+ dark: "only dark"
2173
2178
  };
2174
- function f(e) {
2179
+ function p(e, t) {
2180
+ let n = e.contentDocument?.documentElement;
2181
+ n && (n.style.colorScheme = f[t]);
2182
+ }
2183
+ function m(e) {
2175
2184
  let t = window.matchMedia("(prefers-color-scheme: dark)");
2176
2185
  function n() {
2177
2186
  return localStorage.getItem("in2theme") || (localStorage.setItem("in2theme", "normal"), "normal");
@@ -2183,7 +2192,7 @@ function f(e) {
2183
2192
  Object.values(d).forEach((t) => e.classList.remove(t));
2184
2193
  };
2185
2194
  a(e), e.classList.add(i), a(document.body), document.body.classList.add(i), document.querySelectorAll("iframe").forEach((e) => {
2186
- a(e), e.classList.add(i);
2195
+ a(e), e.classList.add(i), p(e, r);
2187
2196
  }), Array.from(document.querySelectorAll("iframe")).filter((e) => e.src.includes("embed.figma.com")).forEach((e) => {
2188
2197
  let t = new URL(e.src);
2189
2198
  t.searchParams.set("theme", r === "normal" ? "system" : r), e.src = t.href;
@@ -2191,7 +2200,9 @@ function f(e) {
2191
2200
  document.body.classList.add("allow-transitions");
2192
2201
  }, 500);
2193
2202
  }
2194
- r();
2203
+ r(), document.querySelectorAll("iframe").forEach((e) => {
2204
+ e.addEventListener("load", () => p(e, n()));
2205
+ });
2195
2206
  let i = e.querySelector(\`input[value="\${n()}"]\`);
2196
2207
  i && (i.checked = !0), e.addEventListener("change", () => {
2197
2208
  let t = e.querySelector("input[name=\\"theme\\"]:checked");
@@ -2205,14 +2216,14 @@ function f(e) {
2205
2216
  //#region client/preview-inline.ts
2206
2217
  document.addEventListener("DOMContentLoaded", () => {
2207
2218
  let e = document.querySelector(".theme-select");
2208
- e && f(e);
2219
+ e && m(e);
2209
2220
  let t = Array.from(document.querySelectorAll(".preview-iframe"));
2210
2221
  t.length > 0 ? u(t).catch(console.error) : l(), a();
2211
2222
  });
2212
2223
  //#endregion
2213
2224
  ;
2214
2225
  <\/script>
2215
- <script type="module" src="/styleguide-assets/preview-B-NERQ5n.js"><\/script>
2226
+ <script type="module" src="/styleguide-assets/preview-BNQ_kTZ_.js"><\/script>
2216
2227
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
2217
2228
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
2218
2229
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-300-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
@@ -2441,6 +2452,7 @@ async function writeFullPageFile(config, baseDirectory, section) {
2441
2452
  js: config.html.assets.js,
2442
2453
  html: htmlMarkup,
2443
2454
  theme: config.theme,
2455
+ deactivateDarkMode: config.deactivateDarkMode,
2444
2456
  ogImageUrl: config.plugins?.ogImage ? config.plugins.ogImage(section) : void 0
2445
2457
  });
2446
2458
  } catch (error) {
@@ -1,5 +1,5 @@
1
1
  import { parentPort } from 'node:worker_threads';
2
- import { c as compileMarkup, p as pugErrorFile } from '../../shared/kss-modern.rh78o-vW.mjs';
2
+ import { c as compileMarkup, p as pugErrorFile } from '../../shared/kss-modern.BQiL0d8K.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
5
  import 'node:path';
@@ -147,22 +147,25 @@ function getBiome() {
147
147
  })();
148
148
  return biomePromise;
149
149
  }
150
- async function biomeFormat(content) {
150
+ async function biomeFormat(content, sectionId) {
151
+ const filePath = "example.html";
151
152
  try {
152
153
  const { biome, projectKey } = await getBiome();
153
- const result = biome.formatContent(projectKey, content, {
154
- filePath: "example.html"
155
- });
156
- const hasFatalErrors = result.diagnostics?.some(
154
+ const result = biome.formatContent(projectKey, content, { filePath });
155
+ const fatalDiagnostics = result.diagnostics?.filter(
157
156
  (diag) => diag.severity === "fatal" || diag.severity === "error"
158
157
  );
159
- if (hasFatalErrors) {
160
- logger.warn("Biome HTML formatting has errors, falling back to original content");
158
+ if (fatalDiagnostics?.length) {
159
+ const rendered = biome.printDiagnostics(fatalDiagnostics, { filePath, fileSource: content });
160
+ logger.warn(
161
+ `Biome HTML formatting failed for section ${sectionId}, using unformatted markup:
162
+ ${rendered}`
163
+ );
161
164
  return content;
162
165
  }
163
166
  return result.content;
164
167
  } catch (error) {
165
- logger.warn("Biome HTML formatting not supported or failed:", error);
168
+ logger.warn(`Biome HTML formatting not supported or failed for section ${sectionId}:`, error);
166
169
  return content;
167
170
  }
168
171
  }
@@ -242,7 +245,7 @@ async function compileMarkup(contentDir, mode, html, sectionId) {
242
245
  result = expanded.html;
243
246
  dependencies.push(...expanded.dependencies);
244
247
  if (mode === "production") {
245
- result = await biomeFormat(result);
248
+ result = await biomeFormat(result, sectionId);
246
249
  }
247
250
  result = fixAccessibilityIssues(result);
248
251
  return { html: result, dependencies: [...new Set(dependencies)] };
@@ -1,10 +1,10 @@
1
1
  {
2
- "_animate-DRGZltJ3.js": {
3
- "file": "animate-DRGZltJ3.js",
2
+ "_animate-x_9xNIEv.js": {
3
+ "file": "animate-x_9xNIEv.js",
4
4
  "name": "animate"
5
5
  },
6
- "_code-highlight-BygtMiLu.js": {
7
- "file": "code-highlight-BygtMiLu.js",
6
+ "_code-highlight-Fm7cxf-E.js": {
7
+ "file": "code-highlight-Fm7cxf-E.js",
8
8
  "name": "code-highlight"
9
9
  },
10
10
  "_rolldown-runtime-B1bRi_D7.js": {
@@ -24,7 +24,7 @@
24
24
  "name": "utils"
25
25
  },
26
26
  "client/fullpage.ts": {
27
- "file": "fullpage-CGBSSxKh.js",
27
+ "file": "fullpage-DpAT8aw3.js",
28
28
  "name": "fullpage",
29
29
  "src": "client/fullpage.ts",
30
30
  "isEntry": true,
@@ -38,12 +38,12 @@
38
38
  ]
39
39
  },
40
40
  "client/lib/clipboard.ts": {
41
- "file": "clipboard-0X6xnPVo.js",
41
+ "file": "clipboard-BUvXbiCa.js",
42
42
  "name": "clipboard",
43
43
  "src": "client/lib/clipboard.ts",
44
44
  "isDynamicEntry": true,
45
45
  "imports": [
46
- "_animate-DRGZltJ3.js",
46
+ "_animate-x_9xNIEv.js",
47
47
  "_signal-ZVBNTRLw.js",
48
48
  "_utils-DrMb1LbR.js"
49
49
  ]
@@ -55,40 +55,40 @@
55
55
  "isDynamicEntry": true
56
56
  },
57
57
  "client/lib/html-validator.ts": {
58
- "file": "html-validator-CeH3wXbU.js",
58
+ "file": "html-validator-BGApR8VB.js",
59
59
  "name": "html-validator",
60
60
  "src": "client/lib/html-validator.ts",
61
61
  "isDynamicEntry": true,
62
62
  "imports": [
63
- "_code-highlight-BygtMiLu.js",
63
+ "_code-highlight-Fm7cxf-E.js",
64
64
  "_utils-DrMb1LbR.js",
65
65
  "_shared-hGcWlnRM.js"
66
66
  ]
67
67
  },
68
68
  "client/lib/icons.ts": {
69
- "file": "icons-Do1H6FzJ.js",
69
+ "file": "icons-C6KKEuT_.js",
70
70
  "name": "icons",
71
71
  "src": "client/lib/icons.ts",
72
72
  "isDynamicEntry": true,
73
73
  "imports": [
74
- "_animate-DRGZltJ3.js",
74
+ "_animate-x_9xNIEv.js",
75
75
  "_utils-DrMb1LbR.js"
76
76
  ]
77
77
  },
78
78
  "client/preview-inline.ts": {
79
- "file": "preview-inline-CW9Pw65W.js",
79
+ "file": "preview-inline-ByTkw_pt.js",
80
80
  "name": "preview-inline",
81
81
  "src": "client/preview-inline.ts",
82
82
  "isEntry": true
83
83
  },
84
84
  "client/preview.ts": {
85
- "file": "preview-B-NERQ5n.js",
85
+ "file": "preview-BNQ_kTZ_.js",
86
86
  "name": "preview",
87
87
  "src": "client/preview.ts",
88
88
  "isEntry": true,
89
89
  "imports": [
90
- "_animate-DRGZltJ3.js",
91
- "_code-highlight-BygtMiLu.js",
90
+ "_animate-x_9xNIEv.js",
91
+ "_code-highlight-Fm7cxf-E.js",
92
92
  "_signal-ZVBNTRLw.js",
93
93
  "_utils-DrMb1LbR.js",
94
94
  "_shared-hGcWlnRM.js"
@@ -110,7 +110,7 @@
110
110
  ]
111
111
  },
112
112
  "node_modules/html-validate/dist/esm/browser.js": {
113
- "file": "browser-BgMZpraI.js",
113
+ "file": "browser-nU7CpeVb.js",
114
114
  "name": "browser",
115
115
  "src": "node_modules/html-validate/dist/esm/browser.js",
116
116
  "isDynamicEntry": true,
@@ -119,7 +119,7 @@
119
119
  ]
120
120
  },
121
121
  "style.css": {
122
- "file": "kss-modern-3dYdkdaU.css",
122
+ "file": "kss-modern-Bw6-exnr.css",
123
123
  "src": "style.css"
124
124
  }
125
125
  }