kss-modern 1.3.0-beta.0 → 1.3.0-beta.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.
- package/dist/node/lib/index.mjs +52 -10
- package/dist/styleguide-assets/.vite/manifest.json +4 -4
- package/dist/styleguide-assets/fullpage-B5QPff3p.js +919 -0
- package/dist/styleguide-assets/{html-validator-BGApR8VB.js → html-validator-BxGmbFa-.js} +86 -60
- package/dist/styleguide-assets/kss-modern-CTiCJXSr.css +3 -0
- package/dist/styleguide-assets/{preview-BNQ_kTZ_.js → preview-D2-sk3lE.js} +1 -1
- package/package.json +1 -1
- package/dist/styleguide-assets/fullpage-DpAT8aw3.js +0 -385
- package/dist/styleguide-assets/kss-modern-Bw6-exnr.css +0 -3
package/dist/node/lib/index.mjs
CHANGED
|
@@ -16,11 +16,11 @@ import githubLightDefault from '@shikijs/themes/github-light-default';
|
|
|
16
16
|
import MarkdownItAsync from 'markdown-it-async';
|
|
17
17
|
import { createHighlighterCore } from 'shiki/core';
|
|
18
18
|
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
|
19
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
19
20
|
import os from 'node:os';
|
|
20
21
|
import { Worker } from 'node:worker_threads';
|
|
21
22
|
import fs$1 from 'node:fs/promises';
|
|
22
23
|
import { objectEntries } from '@antfu/utils';
|
|
23
|
-
import { readFileSync } from 'node:fs';
|
|
24
24
|
import chokidar from 'chokidar';
|
|
25
25
|
import 'pug';
|
|
26
26
|
import 'consola';
|
|
@@ -390,7 +390,7 @@ function shiftHeadingLevels(markdownContent, rootHeadingLevel) {
|
|
|
390
390
|
}
|
|
391
391
|
return markdownContent;
|
|
392
392
|
}
|
|
393
|
-
|
|
393
|
+
function getMarkdownRenderer() {
|
|
394
394
|
if (!md) {
|
|
395
395
|
md = MarkdownItAsync({ linkify: true, typographer: true });
|
|
396
396
|
md.use(markdownItComponent, {
|
|
@@ -411,6 +411,29 @@ async function parseMarkdown(data) {
|
|
|
411
411
|
)
|
|
412
412
|
);
|
|
413
413
|
}
|
|
414
|
+
return md;
|
|
415
|
+
}
|
|
416
|
+
const RENDER_CACHE_MAX_ENTRIES = 2e3;
|
|
417
|
+
const renderCache = /* @__PURE__ */ new Map();
|
|
418
|
+
async function renderMarkdownCached(source) {
|
|
419
|
+
const cached = renderCache.get(source);
|
|
420
|
+
if (cached !== void 0) {
|
|
421
|
+
return cached;
|
|
422
|
+
}
|
|
423
|
+
const promise = getMarkdownRenderer().renderAsync(source);
|
|
424
|
+
renderCache.set(source, promise);
|
|
425
|
+
promise.catch(() => {
|
|
426
|
+
if (renderCache.get(source) === promise)
|
|
427
|
+
renderCache.delete(source);
|
|
428
|
+
});
|
|
429
|
+
if (renderCache.size > RENDER_CACHE_MAX_ENTRIES) {
|
|
430
|
+
const oldest = renderCache.keys().next().value;
|
|
431
|
+
if (oldest !== void 0 && oldest !== source)
|
|
432
|
+
renderCache.delete(oldest);
|
|
433
|
+
}
|
|
434
|
+
return promise;
|
|
435
|
+
}
|
|
436
|
+
async function parseMarkdown(data) {
|
|
414
437
|
if ("filePath" in data) {
|
|
415
438
|
const doesFileExist = fs.existsSync(data.filePath);
|
|
416
439
|
if (!doesFileExist) {
|
|
@@ -419,12 +442,12 @@ async function parseMarkdown(data) {
|
|
|
419
442
|
}
|
|
420
443
|
let fileContent = await fs.readFile(data.filePath, "utf8");
|
|
421
444
|
fileContent = shiftHeadingLevels(fileContent, data.rootHeadingLevel);
|
|
422
|
-
const parsedMarkdown = await
|
|
445
|
+
const parsedMarkdown = await renderMarkdownCached(fileContent);
|
|
423
446
|
return parsedMarkdown;
|
|
424
447
|
} else {
|
|
425
448
|
let fileContent = data.markdownContent.replace("Markdown:", "");
|
|
426
449
|
fileContent = shiftHeadingLevels(fileContent, data.rootHeadingLevel);
|
|
427
|
-
return await
|
|
450
|
+
return await renderMarkdownCached(fileContent);
|
|
428
451
|
}
|
|
429
452
|
}
|
|
430
453
|
|
|
@@ -1038,8 +1061,17 @@ function getPugDependencyGraph() {
|
|
|
1038
1061
|
}
|
|
1039
1062
|
const __filename$1 = fileURLToPath(import.meta.url);
|
|
1040
1063
|
const __dirname$1 = path.dirname(__filename$1);
|
|
1041
|
-
|
|
1042
|
-
const
|
|
1064
|
+
function resolveWorkerFile() {
|
|
1065
|
+
const candidates = ["./worker.ts", "./worker.mjs", "./pug/worker.mjs"];
|
|
1066
|
+
for (const candidate of candidates) {
|
|
1067
|
+
const resolved = path.resolve(__dirname$1, candidate);
|
|
1068
|
+
if (existsSync(resolved))
|
|
1069
|
+
return resolved;
|
|
1070
|
+
}
|
|
1071
|
+
return void 0;
|
|
1072
|
+
}
|
|
1073
|
+
const workerFilePathResolved = resolveWorkerFile();
|
|
1074
|
+
let warnedMissingWorker = false;
|
|
1043
1075
|
const slots = Array.from({ length: MAX_POOL_SIZE }, () => ({ tail: Promise.resolve(), active: 0 }));
|
|
1044
1076
|
const allWorkers = /* @__PURE__ */ new Set();
|
|
1045
1077
|
function slotIndexFor(id) {
|
|
@@ -1051,6 +1083,8 @@ function slotIndexFor(id) {
|
|
|
1051
1083
|
return (hash >>> 0) % MAX_POOL_SIZE;
|
|
1052
1084
|
}
|
|
1053
1085
|
function spawnWorker(index) {
|
|
1086
|
+
if (!workerFilePathResolved)
|
|
1087
|
+
throw new Error("pug compile worker file could not be located");
|
|
1054
1088
|
const worker = new Worker(workerFilePathResolved, { name: `pug-worker-${index}` });
|
|
1055
1089
|
allWorkers.add(worker);
|
|
1056
1090
|
return worker;
|
|
@@ -1185,7 +1219,11 @@ async function compileIds(mode, contentDir, repository, ids) {
|
|
|
1185
1219
|
if (misses.length === 0)
|
|
1186
1220
|
return clonedRepository;
|
|
1187
1221
|
const errors = [];
|
|
1188
|
-
|
|
1222
|
+
if (!workerFilePathResolved && misses.length > INLINE_THRESHOLD && !warnedMissingWorker) {
|
|
1223
|
+
warnedMissingWorker = true;
|
|
1224
|
+
logger.warn("Pug compile worker not found; compiling markup on the main thread. Rebuilds stay correct but are slower.");
|
|
1225
|
+
}
|
|
1226
|
+
const useInline = !workerFilePathResolved || mode === "development" && misses.length <= INLINE_THRESHOLD;
|
|
1189
1227
|
if (useInline) {
|
|
1190
1228
|
await Promise.all(misses.map((id) => compileInline(mode, contentDir, clonedRepository, id, errors)));
|
|
1191
1229
|
} else {
|
|
@@ -1253,7 +1291,7 @@ async function generateFullPageFile(data) {
|
|
|
1253
1291
|
<meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.theme.light}">
|
|
1254
1292
|
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.theme.dark}">
|
|
1255
1293
|
` : `<meta name="theme-color" content="${data.theme}">`}
|
|
1256
|
-
<script type="module" src="/styleguide-assets/fullpage-
|
|
1294
|
+
<script type="module" src="/styleguide-assets/fullpage-B5QPff3p.js"><\/script>
|
|
1257
1295
|
${computedStyleTags}
|
|
1258
1296
|
</head>
|
|
1259
1297
|
<body${data.page.bodyclass ? ` class="${data.page.bodyclass}"` : ""}>
|
|
@@ -2060,7 +2098,7 @@ async function generatePreviewFile(data) {
|
|
|
2060
2098
|
<meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.theme.light}">
|
|
2061
2099
|
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.theme.dark}">
|
|
2062
2100
|
` : `<meta name="theme-color" content="${data.theme}">`}
|
|
2063
|
-
<link rel="stylesheet" type="text/css" href="/styleguide-assets/kss-modern-
|
|
2101
|
+
<link rel="stylesheet" type="text/css" href="/styleguide-assets/kss-modern-CTiCJXSr.css">
|
|
2064
2102
|
<script>
|
|
2065
2103
|
//#region client/lib/iframe-resize.ts
|
|
2066
2104
|
var e = [
|
|
@@ -2223,7 +2261,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
2223
2261
|
//#endregion
|
|
2224
2262
|
;
|
|
2225
2263
|
<\/script>
|
|
2226
|
-
<script type="module" src="/styleguide-assets/preview-
|
|
2264
|
+
<script type="module" src="/styleguide-assets/preview-D2-sk3lE.js"><\/script>
|
|
2227
2265
|
<link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
|
2228
2266
|
<link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
|
2229
2267
|
<link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-300-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
|
@@ -2377,6 +2415,10 @@ function watchStyleguideForChanges(watchPath, handlers) {
|
|
|
2377
2415
|
handlers.onStructuralChange();
|
|
2378
2416
|
else if (isMarkupFile(filePath))
|
|
2379
2417
|
handlers.onMarkupChange(path.resolve(filePath));
|
|
2418
|
+
}).on("error", (error) => {
|
|
2419
|
+
if (isTransientFsError(error))
|
|
2420
|
+
return;
|
|
2421
|
+
logger.error("Styleguide watcher error (ignored to keep the dev server running):", error);
|
|
2380
2422
|
});
|
|
2381
2423
|
}
|
|
2382
2424
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"name": "utils"
|
|
25
25
|
},
|
|
26
26
|
"client/fullpage.ts": {
|
|
27
|
-
"file": "fullpage-
|
|
27
|
+
"file": "fullpage-B5QPff3p.js",
|
|
28
28
|
"name": "fullpage",
|
|
29
29
|
"src": "client/fullpage.ts",
|
|
30
30
|
"isEntry": true,
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"isDynamicEntry": true
|
|
56
56
|
},
|
|
57
57
|
"client/lib/html-validator.ts": {
|
|
58
|
-
"file": "html-validator-
|
|
58
|
+
"file": "html-validator-BxGmbFa-.js",
|
|
59
59
|
"name": "html-validator",
|
|
60
60
|
"src": "client/lib/html-validator.ts",
|
|
61
61
|
"isDynamicEntry": true,
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"isEntry": true
|
|
83
83
|
},
|
|
84
84
|
"client/preview.ts": {
|
|
85
|
-
"file": "preview-
|
|
85
|
+
"file": "preview-D2-sk3lE.js",
|
|
86
86
|
"name": "preview",
|
|
87
87
|
"src": "client/preview.ts",
|
|
88
88
|
"isEntry": true,
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
]
|
|
120
120
|
},
|
|
121
121
|
"style.css": {
|
|
122
|
-
"file": "kss-modern-
|
|
122
|
+
"file": "kss-modern-CTiCJXSr.css",
|
|
123
123
|
"src": "style.css"
|
|
124
124
|
}
|
|
125
125
|
}
|