kss-modern 0.0.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.
Files changed (28) hide show
  1. package/README.md +15 -0
  2. package/dist/node/lib/index.d.mts +86 -0
  3. package/dist/node/lib/index.d.ts +86 -0
  4. package/dist/node/lib/index.mjs +1900 -0
  5. package/dist/node/lib/vite-pug/worker.d.mts +24 -0
  6. package/dist/node/lib/vite-pug/worker.d.ts +24 -0
  7. package/dist/node/lib/vite-pug/worker.mjs +107 -0
  8. package/dist/styleguide-assets/.vite/manifest.json +63 -0
  9. package/dist/styleguide-assets/assets/worker-D4V8OS0H.js +12 -0
  10. package/dist/styleguide-assets/browser-BSX_g1yp.js +22671 -0
  11. package/dist/styleguide-assets/client-BZlkq2d8.js +1 -0
  12. package/dist/styleguide-assets/client-fullpage-1rKiNQVN.js +62 -0
  13. package/dist/styleguide-assets/clipboard-DhKzwemV.js +19 -0
  14. package/dist/styleguide-assets/fonts/geist-mono-latin-300-normal.woff2 +0 -0
  15. package/dist/styleguide-assets/fonts/geist-mono-latin-400-normal.woff2 +0 -0
  16. package/dist/styleguide-assets/fonts/geist-mono-latin-600-normal.woff2 +0 -0
  17. package/dist/styleguide-assets/fonts/geist-sans-latin-300-normal.woff2 +0 -0
  18. package/dist/styleguide-assets/fonts/geist-sans-latin-400-normal.woff2 +0 -0
  19. package/dist/styleguide-assets/fonts/geist-sans-latin-600-normal.woff2 +0 -0
  20. package/dist/styleguide-assets/html-validator-DqoaRE1y.js +136 -0
  21. package/dist/styleguide-assets/icons/external-link.svg +4 -0
  22. package/dist/styleguide-assets/icons/figma.svg +1 -0
  23. package/dist/styleguide-assets/icons/phpstorm.svg +1 -0
  24. package/dist/styleguide-assets/icons/vscode.svg +1 -0
  25. package/dist/styleguide-assets/icons-oK5xUF8R.js +37 -0
  26. package/dist/styleguide-assets/main-B97JcbYk.js +3603 -0
  27. package/dist/styleguide-assets/styleguide-BQbUioN5.css +1 -0
  28. package/package.json +42 -0
@@ -0,0 +1,24 @@
1
+ import { StyleguideConfiguration } from '../index.mjs';
2
+
3
+ /**
4
+ * Replaces all <insert-vite-pug src="path/to/file.pug" modifierClass="modifier"> tags with the pug file content
5
+ * depending on the mode provided
6
+ */
7
+ declare function compilePug(contentDir: `${string}/`, mode: StyleguideConfiguration['mode'], html: string): Promise<string>;
8
+ interface PugWorkerInput {
9
+ id: string;
10
+ mode: StyleguideConfiguration['mode'];
11
+ contentDir: `${string}/`;
12
+ html: string;
13
+ }
14
+ interface PugWorkerSuccess {
15
+ id: string;
16
+ html: string;
17
+ }
18
+ interface PugWorkerError {
19
+ error: string;
20
+ }
21
+ type PugWorkerOutput = PugWorkerSuccess | PugWorkerError;
22
+
23
+ export { compilePug };
24
+ export type { PugWorkerInput, PugWorkerOutput };
@@ -0,0 +1,24 @@
1
+ import { StyleguideConfiguration } from '../index.js';
2
+
3
+ /**
4
+ * Replaces all <insert-vite-pug src="path/to/file.pug" modifierClass="modifier"> tags with the pug file content
5
+ * depending on the mode provided
6
+ */
7
+ declare function compilePug(contentDir: `${string}/`, mode: StyleguideConfiguration['mode'], html: string): Promise<string>;
8
+ interface PugWorkerInput {
9
+ id: string;
10
+ mode: StyleguideConfiguration['mode'];
11
+ contentDir: `${string}/`;
12
+ html: string;
13
+ }
14
+ interface PugWorkerSuccess {
15
+ id: string;
16
+ html: string;
17
+ }
18
+ interface PugWorkerError {
19
+ error: string;
20
+ }
21
+ type PugWorkerOutput = PugWorkerSuccess | PugWorkerError;
22
+
23
+ export { compilePug };
24
+ export type { PugWorkerInput, PugWorkerOutput };
@@ -0,0 +1,107 @@
1
+ import path from 'node:path';
2
+ import { parentPort } from 'node:worker_threads';
3
+ import { Biome, Distribution } from '@biomejs/js-api';
4
+ import pug from 'pug';
5
+
6
+ let biomeInstance;
7
+ let biomePromise;
8
+ let projectKey;
9
+ async function getBiome() {
10
+ if (biomeInstance && projectKey !== void 0) {
11
+ return { biome: biomeInstance, projectKey };
12
+ }
13
+ if (biomePromise) {
14
+ const biome2 = await biomePromise;
15
+ return { biome: biome2, projectKey };
16
+ }
17
+ biomePromise = (async () => {
18
+ const instance = await Biome.create({
19
+ distribution: Distribution.NODE
20
+ });
21
+ projectKey = instance.openProject(".").projectKey;
22
+ instance.applyConfiguration(projectKey, {
23
+ html: {
24
+ formatter: {
25
+ lineWidth: 100
26
+ }
27
+ }
28
+ });
29
+ biomeInstance = instance;
30
+ return instance;
31
+ })();
32
+ const biome = await biomePromise;
33
+ return { biome, projectKey };
34
+ }
35
+ async function biomeFormat(content) {
36
+ try {
37
+ const { biome, projectKey: projectKey2 } = await getBiome();
38
+ const result = biome.formatContent(projectKey2, content, {
39
+ filePath: "example.html"
40
+ });
41
+ const hasFatalErrors = result.diagnostics?.some(
42
+ (diag) => diag.severity === "fatal" || diag.severity === "error"
43
+ );
44
+ if (hasFatalErrors) {
45
+ console.warn("Biome HTML formatting has errors, falling back to original content");
46
+ return content;
47
+ }
48
+ return result.content;
49
+ } catch (error) {
50
+ console.warn("Biome HTML formatting not supported or failed:", error);
51
+ return content;
52
+ }
53
+ }
54
+ const regexModifierLine = /<insert-vite-pug src="(.+?)".*(?:[\n\r\u2028\u2029]\s*)?(modifierClass="(.+?)")? *><\/insert-vite-pug>/g;
55
+ async function compilePug(contentDir, mode, html) {
56
+ const vitePugTags = html.match(regexModifierLine);
57
+ if (!vitePugTags) {
58
+ return html;
59
+ }
60
+ let markupOutput = html;
61
+ await Promise.all(vitePugTags.map(async (vitePugTag) => {
62
+ const pugSourcePath = vitePugTag.match(/src="(.+?)"/)?.[1];
63
+ if (!pugSourcePath) {
64
+ return void 0;
65
+ }
66
+ const pugModifierClass = vitePugTag.match(/modifierClass="(.+?)"/);
67
+ let pugLocals = {};
68
+ if (pugModifierClass && pugModifierClass[1]) {
69
+ pugLocals = {
70
+ modifierClass: pugModifierClass[1]
71
+ };
72
+ }
73
+ const pugFilePath = path.join(contentDir, pugSourcePath);
74
+ if (mode === "production") {
75
+ const isPugFile = path.extname(pugSourcePath) === ".pug";
76
+ if (!isPugFile) {
77
+ throw new Error(`${pugSourcePath} is not a valid .pug file`);
78
+ }
79
+ const pugFn = pug.compileFile(pugFilePath, {
80
+ pretty: true,
81
+ // define doctype to avoid self-closing tags on wrong places
82
+ doctype: "html"
83
+ });
84
+ const pugOutput = pugFn(pugLocals);
85
+ markupOutput = markupOutput.replaceAll(vitePugTag, pugOutput);
86
+ } else {
87
+ const pugTag = pugModifierClass && pugModifierClass[1] ? `<pug src="${pugFilePath}" locals="${encodeURIComponent(JSON.stringify(pugLocals))}"></pug>` : `<pug src="${pugFilePath}"></pug>`;
88
+ markupOutput = markupOutput.replaceAll(vitePugTag, pugTag);
89
+ }
90
+ }));
91
+ return markupOutput;
92
+ }
93
+ if (!parentPort) {
94
+ throw new Error("This file must be run as a worker thread");
95
+ }
96
+ parentPort.on("message", async (data) => {
97
+ const { id, mode, html, contentDir } = data;
98
+ let result = html;
99
+ const needsFormatting = mode === "development" && !result.includes("<insert-vite-pug") || mode === "production";
100
+ result = await compilePug(contentDir, mode, html);
101
+ if (needsFormatting) {
102
+ result = await biomeFormat(result);
103
+ }
104
+ parentPort.postMessage({ id, html: result });
105
+ });
106
+
107
+ export { compilePug };
@@ -0,0 +1,63 @@
1
+ {
2
+ "_main-B97JcbYk.js": {
3
+ "file": "main-B97JcbYk.js",
4
+ "name": "main",
5
+ "dynamicImports": [
6
+ "client/lib/html-validator.ts",
7
+ "client/lib/icons.ts",
8
+ "client/lib/clipboard.ts"
9
+ ]
10
+ },
11
+ "client/fullpage.ts": {
12
+ "file": "client-fullpage-1rKiNQVN.js",
13
+ "name": "client-fullpage",
14
+ "src": "client/fullpage.ts",
15
+ "isEntry": true
16
+ },
17
+ "client/lib/clipboard.ts": {
18
+ "file": "clipboard-DhKzwemV.js",
19
+ "name": "clipboard",
20
+ "src": "client/lib/clipboard.ts",
21
+ "isDynamicEntry": true,
22
+ "imports": [
23
+ "_main-B97JcbYk.js"
24
+ ]
25
+ },
26
+ "client/lib/html-validator.ts": {
27
+ "file": "html-validator-DqoaRE1y.js",
28
+ "name": "html-validator",
29
+ "src": "client/lib/html-validator.ts",
30
+ "isDynamicEntry": true,
31
+ "dynamicImports": [
32
+ "node_modules/html-validate/dist/es/browser.js"
33
+ ]
34
+ },
35
+ "client/lib/icons.ts": {
36
+ "file": "icons-oK5xUF8R.js",
37
+ "name": "icons",
38
+ "src": "client/lib/icons.ts",
39
+ "isDynamicEntry": true,
40
+ "imports": [
41
+ "_main-B97JcbYk.js"
42
+ ]
43
+ },
44
+ "client/main.ts": {
45
+ "file": "client-BZlkq2d8.js",
46
+ "name": "client",
47
+ "src": "client/main.ts",
48
+ "isEntry": true,
49
+ "imports": [
50
+ "_main-B97JcbYk.js"
51
+ ]
52
+ },
53
+ "node_modules/html-validate/dist/es/browser.js": {
54
+ "file": "browser-BSX_g1yp.js",
55
+ "name": "browser",
56
+ "src": "node_modules/html-validate/dist/es/browser.js",
57
+ "isDynamicEntry": true
58
+ },
59
+ "style.css": {
60
+ "file": "styleguide-BQbUioN5.css",
61
+ "src": "style.css"
62
+ }
63
+ }