kss-modern 0.0.17 → 0.0.19

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.
@@ -25,7 +25,15 @@ interface in2Section {
25
25
  wrapper?: string;
26
26
  htmlclass?: string;
27
27
  bodyclass?: string;
28
- sourceFileName: string;
28
+ source: {
29
+ css: {
30
+ file: string;
31
+ line: number;
32
+ };
33
+ markup?: {
34
+ file: string;
35
+ };
36
+ };
29
37
  previewFileName: string;
30
38
  fullpageFileName: string;
31
39
  }
@@ -25,7 +25,15 @@ interface in2Section {
25
25
  wrapper?: string;
26
26
  htmlclass?: string;
27
27
  bodyclass?: string;
28
- sourceFileName: string;
28
+ source: {
29
+ css: {
30
+ file: string;
31
+ line: number;
32
+ };
33
+ markup?: {
34
+ file: string;
35
+ };
36
+ };
29
37
  previewFileName: string;
30
38
  fullpageFileName: string;
31
39
  }
@@ -644,8 +644,8 @@ function extractMarkdownPath(input) {
644
644
  }
645
645
  return path2;
646
646
  }
647
- async function parse(text, config) {
648
- const data = kssParser(text).sections.filter((section) => Boolean(section.reference));
647
+ async function parse(input, config) {
648
+ const data = kssParser(input).sections.filter((section) => Boolean(section.reference));
649
649
  const overwrittenSectionsIds = [];
650
650
  const sortedData = data.sort((a, b) => {
651
651
  return a.reference.localeCompare(b.reference);
@@ -666,6 +666,34 @@ async function parse(text, config) {
666
666
  hasMarkdownDescription: true
667
667
  };
668
668
  }
669
+ function computeSource(section) {
670
+ const cssSource = section.source;
671
+ let sourceMarkup = void 0;
672
+ const hasExtractableMarkupFile = section.markup.includes('<insert-vite-pug src="');
673
+ if (hasExtractableMarkupFile) {
674
+ const regexModifierLine = /<insert-vite-pug src="(.+?)".*(?:[\n\r\u2028\u2029]\s*)?(modifierClass="(.+?)")? *><\/insert-vite-pug>/g;
675
+ const vitePugTags = section.markup.match(regexModifierLine);
676
+ if (!vitePugTags)
677
+ throw new Error("No Vite Pug tags found");
678
+ vitePugTags.forEach((vitePugTag) => {
679
+ let pugSourcePath = vitePugTag.match(/src="(.+?)"/)?.[1];
680
+ if (!pugSourcePath || !pugSourcePath.endsWith(".pug")) {
681
+ throw new Error("No or invalid Pug source path found");
682
+ }
683
+ pugSourcePath = path.join(config.contentDir, pugSourcePath);
684
+ sourceMarkup = {
685
+ file: pugSourcePath
686
+ };
687
+ });
688
+ }
689
+ return {
690
+ css: {
691
+ file: cssSource.filename,
692
+ line: cssSource.line
693
+ },
694
+ markup: sourceMarkup
695
+ };
696
+ }
669
697
  for await (const section of sortedData) {
670
698
  if (!section.reference)
671
699
  return;
@@ -696,7 +724,7 @@ async function parse(text, config) {
696
724
  wrapper: section.wrapper,
697
725
  htmlclass: section.htmlclass,
698
726
  bodyclass: section.bodyclass,
699
- sourceFileName: section.source.filename,
727
+ source: computeSource(section),
700
728
  previewFileName: `preview-${section.reference}.html`,
701
729
  fullpageFileName: `fullpage-${section.reference}.html`
702
730
  };
@@ -732,7 +760,7 @@ async function parse(text, config) {
732
760
  wrapper: section.wrapper,
733
761
  htmlclass: section.htmlclass,
734
762
  bodyclass: section.bodyclass,
735
- sourceFileName: section.source.filename,
763
+ source: computeSource(section),
736
764
  previewFileName: `preview-${section.reference}.html`,
737
765
  fullpageFileName: `fullpage-${section.reference}.html`
738
766
  });
@@ -761,7 +789,7 @@ async function parse(text, config) {
761
789
  htmlclass: section.htmlclass,
762
790
  bodyclass: section.bodyclass,
763
791
  sections: [],
764
- sourceFileName: section.source.filename,
792
+ source: computeSource(section),
765
793
  previewFileName: `preview-${section.reference}.html`,
766
794
  fullpageFileName: `fullpage-${section.reference}.html`
767
795
  };
@@ -805,7 +833,7 @@ async function generateFullPageFile(data) {
805
833
  <link rel="icon" type="image/svg+xml" href="/styleguide-assets/favicon/fullpage-light.svg">
806
834
  `}
807
835
  ${data.ogImageUrl ? `<meta property="og:image" content="${data.ogImageUrl}">` : ""}
808
- <script type="module" src="/styleguide-assets/client-fullpage-1rKiNQVN.js"><\/script>
836
+ <script type="module" src="/styleguide-assets/client-fullpage-DjIkCnMm.js"><\/script>
809
837
  ${computedStyleTags}
810
838
  </head>
811
839
  <body${data.page.bodyclass ? ` class="${data.page.bodyclass}"` : ""}>
@@ -1068,30 +1096,20 @@ ${html ?? ""}
1068
1096
  `;
1069
1097
  }
1070
1098
  function getMainContentRegular(section, config) {
1071
- let sourceFilePath = "";
1072
- if (config.mode === "development" && config.launchInEditor && section.markup.includes('<pug src="')) {
1073
- const regexModifierLine = /<pug src="(.+?)".*(?:[\n\r\u2028\u2029]\s*)?(modifierClass="(.+?)")? *><\/pug>/g;
1074
- const vitePugTags = section.markup.match(regexModifierLine);
1075
- if (!vitePugTags)
1076
- throw new Error("No Vite Pug tags found");
1077
- vitePugTags.forEach((vitePugTag) => {
1078
- const pugSourcePath = vitePugTag.match(/src="(.+?)"/)?.[1];
1079
- if (!pugSourcePath || !pugSourcePath.endsWith(".pug")) {
1080
- throw new Error("No or invalid Pug source path found");
1081
- }
1082
- sourceFilePath = pugSourcePath;
1083
- });
1084
- } else if (config.mode === "development" && section.sourceFileName) {
1085
- sourceFilePath = path.join(config.contentDir, section.sourceFileName);
1086
- }
1087
- const shouldLaunchInEditor = config.mode === "development" && config.launchInEditor && sourceFilePath;
1088
- let openInEditorPathPhpStorm = "";
1089
- let openInEditorPathVscode = "";
1090
- if (shouldLaunchInEditor) {
1099
+ const openInEditorPaths = {
1100
+ css: {},
1101
+ html: {}
1102
+ };
1103
+ if (config.mode === "development" && config.launchInEditor) {
1091
1104
  const computedRootPath = config.launchInEditor && typeof config.launchInEditor === "object" && "rootDir" in config.launchInEditor ? config.launchInEditor.rootDir : process.cwd();
1092
- const computedFilePath = ensureStartingSlash(path.join(computedRootPath, sourceFilePath));
1093
- openInEditorPathPhpStorm = shouldLaunchInEditor ? `phpstorm://open?file=${computedFilePath}` : "";
1094
- openInEditorPathVscode = shouldLaunchInEditor ? `vscode://file//${computedFilePath}` : "";
1105
+ const cssFilePath = ensureStartingSlash(path.join(computedRootPath, section.source.css.file));
1106
+ openInEditorPaths.css.vscode = `vscode://file//${cssFilePath}:${section.source.css.line}`;
1107
+ openInEditorPaths.css.phpstorm = `phpstorm://open?file=${cssFilePath}&line=${section.source.css.line}`;
1108
+ if (section.source.markup && section.source.markup.file) {
1109
+ const htmlFilePath = ensureStartingSlash(path.join(computedRootPath, section.source.markup.file));
1110
+ openInEditorPaths.html.vscode = `vscode://file//${htmlFilePath}`;
1111
+ openInEditorPaths.html.phpstorm = `phpstorm://open?file=${htmlFilePath}`;
1112
+ }
1095
1113
  }
1096
1114
  const computeFigmaExternalLink = (url) => {
1097
1115
  if (!url)
@@ -1100,6 +1118,14 @@ function getMainContentRegular(section, config) {
1100
1118
  urlObj.hostname = "www.figma.com";
1101
1119
  return urlObj.toString();
1102
1120
  };
1121
+ const phpstormOpenLinks = [
1122
+ openInEditorPaths.css.phpstorm,
1123
+ openInEditorPaths.html.phpstorm
1124
+ ].filter(Boolean).join(",");
1125
+ const vscodeOpenLinks = [
1126
+ openInEditorPaths.css.vscode,
1127
+ openInEditorPaths.html.vscode
1128
+ ].filter(Boolean).join(",");
1103
1129
  const codePreviewMarkup = `
1104
1130
  <!-- Preview Box -->
1105
1131
  <div class="mt-4 overflow-hidden rounded-2xl border border-styleguide-border">
@@ -1144,39 +1170,41 @@ function getMainContentRegular(section, config) {
1144
1170
  >
1145
1171
  </a>` : ""}
1146
1172
 
1147
- ${openInEditorPathPhpStorm ? `<a
1148
- class="hidden @md:inline-flex items-center group/phpstorm gap-1.5 p-4 desktop-device-only cursor-pointer active:scale-90 transition hover:text-styleguide-highlight duration-200"
1149
- href="${openInEditorPathPhpStorm}"
1150
- >
1151
- <span class="hidden @2xl:inline-block">Open in</span>
1152
- <span class="sr-only">PHPStorm</span>
1153
- <img
1154
- src="styleguide-assets/icons/phpstorm.svg"
1155
- width="70"
1156
- height="70"
1157
- class="size-4 saturate-0 group-hover/phpstorm:saturate-100 transition"
1158
- alt="PHPStorm Logo"
1159
- aria-hidden="true"
1160
- >
1161
- </a>
1162
- ` : ""}
1163
-
1164
- ${openInEditorPathVscode ? `<a
1165
- class="hidden @md:inline-flex items-center group/vscode gap-1.5 p-4 desktop-device-only cursor-pointer active:scale-90 transition hover:text-styleguide-highlight duration-200"
1166
- href="${openInEditorPathVscode}"
1167
- >
1168
- <span class="hidden @2xl:inline-block">Open in</span>
1169
- <span class="sr-only">VsCode</span>
1170
- <img
1171
- src="styleguide-assets/icons/vscode.svg"
1172
- width="100"
1173
- height="100"
1174
- class="size-4 saturate-0 group-hover/vscode:saturate-100 transition"
1175
- alt="VsCode Logo"
1176
- aria-hidden="true"
1177
- >
1178
- </a>
1179
- ` : ""}
1173
+ ${phpstormOpenLinks.length > 0 ? `<a
1174
+ class="hidden @md:inline-flex items-center group/phpstorm gap-1.5 p-4 desktop-device-only cursor-pointer active:scale-90 transition hover:text-styleguide-highlight duration-200"
1175
+ href="#"
1176
+ data-link-multiple="${phpstormOpenLinks}"
1177
+ >
1178
+ <span class="hidden @2xl:inline-block">Open in</span>
1179
+ <span class="sr-only">PHPStorm</span>
1180
+ <img
1181
+ src="styleguide-assets/icons/phpstorm.svg"
1182
+ width="70"
1183
+ height="70"
1184
+ class="size-4 saturate-0 group-hover/phpstorm:saturate-100 transition"
1185
+ alt="PHPStorm Logo"
1186
+ aria-hidden="true"
1187
+ >
1188
+ </a>
1189
+ ` : ""}
1190
+
1191
+ ${vscodeOpenLinks.length > 0 ? `<a
1192
+ class="hidden @md:inline-flex items-center group/vscode gap-1.5 p-4 desktop-device-only cursor-pointer active:scale-90 transition hover:text-styleguide-highlight duration-200"
1193
+ href="#"
1194
+ data-link-multiple="${vscodeOpenLinks}"
1195
+ >
1196
+ <span class="hidden @2xl:inline-block">Open in</span>
1197
+ <span class="sr-only">VsCode</span>
1198
+ <img
1199
+ src="styleguide-assets/icons/vscode.svg"
1200
+ width="100"
1201
+ height="100"
1202
+ class="size-4 saturate-0 group-hover/vscode:saturate-100 transition"
1203
+ alt="VsCode Logo"
1204
+ aria-hidden="true"
1205
+ >
1206
+ </a>
1207
+ ` : ""}
1180
1208
 
1181
1209
  <button
1182
1210
  class="inline-flex items-center gap-1.5 p-4 cursor-pointer active:scale-90 transition hover:text-styleguide-highlight duration-200"
@@ -1538,8 +1566,8 @@ async function generatePreviewFile(data) {
1538
1566
  <meta name="theme-color" content="${data.theme}">
1539
1567
  <link rel="icon" type="image/svg+xml" href="/styleguide-assets/favicon/preview-light.svg">
1540
1568
  `}
1541
- <link rel="stylesheet" type="text/css" href="/styleguide-assets/kss-modern-B8wkm2Af.css">
1542
- <script type="module" src="/styleguide-assets/client-CgJCvRoi.js"><\/script>
1569
+ <link rel="stylesheet" type="text/css" href="/styleguide-assets/kss-modern-DDees9Y5.css">
1570
+ <script type="module" src="/styleguide-assets/client-CHYLSUpU.js"><\/script>
1543
1571
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
1544
1572
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
1545
1573
  <link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-300-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
@@ -1731,7 +1759,12 @@ globalThis.isWatchMode = false;
1731
1759
  async function buildStyleguide(config) {
1732
1760
  globalThis.styleguideConfiguration = config;
1733
1761
  const styleguideContentPaths = await glob(`${config.contentDir}/**/*.{css,scss}`);
1734
- const styleguideContent = (await Promise.all(styleguideContentPaths.map((file) => fs.readFile(file, "utf-8")))).join("\n");
1762
+ const styleguideContent = await Promise.all(
1763
+ styleguideContentPaths.map(async (filePath) => ({
1764
+ path: filePath,
1765
+ contents: await fs.readFile(filePath, "utf-8")
1766
+ }))
1767
+ );
1735
1768
  const rawParsedOutput = await parse(styleguideContent, config);
1736
1769
  if (!rawParsedOutput)
1737
1770
  throw new Error("Could not parse content");
@@ -1,6 +1,6 @@
1
1
  {
2
- "_main-BYXbx-16.js": {
3
- "file": "main-BYXbx-16.js",
2
+ "_main-CTV8iVap.js": {
3
+ "file": "main-CTV8iVap.js",
4
4
  "name": "main",
5
5
  "dynamicImports": [
6
6
  "client/lib/html-validator.ts",
@@ -9,55 +9,55 @@
9
9
  ]
10
10
  },
11
11
  "client/fullpage.ts": {
12
- "file": "client-fullpage-1rKiNQVN.js",
12
+ "file": "client-fullpage-DjIkCnMm.js",
13
13
  "name": "client-fullpage",
14
14
  "src": "client/fullpage.ts",
15
15
  "isEntry": true
16
16
  },
17
17
  "client/lib/clipboard.ts": {
18
- "file": "clipboard-Dr_iJrxX.js",
18
+ "file": "clipboard-BX-6wcwn.js",
19
19
  "name": "clipboard",
20
20
  "src": "client/lib/clipboard.ts",
21
21
  "isDynamicEntry": true,
22
22
  "imports": [
23
- "_main-BYXbx-16.js"
23
+ "_main-CTV8iVap.js"
24
24
  ]
25
25
  },
26
26
  "client/lib/html-validator.ts": {
27
- "file": "html-validator-D8B6CYwU.js",
27
+ "file": "html-validator-bX8Fj2mZ.js",
28
28
  "name": "html-validator",
29
29
  "src": "client/lib/html-validator.ts",
30
30
  "isDynamicEntry": true,
31
31
  "dynamicImports": [
32
- "node_modules/html-validate/dist/es/browser.js"
32
+ "node_modules/html-validate/dist/esm/browser.js"
33
33
  ]
34
34
  },
35
35
  "client/lib/icons.ts": {
36
- "file": "icons-_8qk0_-D.js",
36
+ "file": "icons-Bsi5dZux.js",
37
37
  "name": "icons",
38
38
  "src": "client/lib/icons.ts",
39
39
  "isDynamicEntry": true,
40
40
  "imports": [
41
- "_main-BYXbx-16.js"
41
+ "_main-CTV8iVap.js"
42
42
  ]
43
43
  },
44
44
  "client/main.ts": {
45
- "file": "client-CgJCvRoi.js",
45
+ "file": "client-CHYLSUpU.js",
46
46
  "name": "client",
47
47
  "src": "client/main.ts",
48
48
  "isEntry": true,
49
49
  "imports": [
50
- "_main-BYXbx-16.js"
50
+ "_main-CTV8iVap.js"
51
51
  ]
52
52
  },
53
- "node_modules/html-validate/dist/es/browser.js": {
54
- "file": "browser-zT2GwTFu.js",
53
+ "node_modules/html-validate/dist/esm/browser.js": {
54
+ "file": "browser-KlOfx-vG.js",
55
55
  "name": "browser",
56
- "src": "node_modules/html-validate/dist/es/browser.js",
56
+ "src": "node_modules/html-validate/dist/esm/browser.js",
57
57
  "isDynamicEntry": true
58
58
  },
59
59
  "style.css": {
60
- "file": "kss-modern-B8wkm2Af.css",
60
+ "file": "kss-modern-DDees9Y5.css",
61
61
  "src": "style.css"
62
62
  }
63
63
  }