starlight-cannoli-plugins 2.3.1 → 2.3.2

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.
@@ -0,0 +1,48 @@
1
+ // src/plugins/starlight-dom-patches/index.ts
2
+ import { fileURLToPath } from "url";
3
+ function starlightDomPatches(options = {}) {
4
+ const {
5
+ hideSingleLineGutters = false,
6
+ syncTocLabelsFromHeadings = false,
7
+ wrapDetailsContent = false
8
+ } = options;
9
+ return {
10
+ name: "starlight-dom-patches",
11
+ hooks: {
12
+ "astro:config:setup": ({ injectScript }) => {
13
+ const currentFile = fileURLToPath(import.meta.url);
14
+ let pageScriptUrl;
15
+ if (currentFile.endsWith(".ts")) {
16
+ pageScriptUrl = new URL("./page-script.ts", import.meta.url);
17
+ } else if (currentFile.endsWith("starlight-dom-patches.js")) {
18
+ pageScriptUrl = new URL(
19
+ "./starlight-dom-patches/page-script.js",
20
+ import.meta.url
21
+ );
22
+ } else {
23
+ pageScriptUrl = new URL(
24
+ "./plugins/starlight-dom-patches/page-script.js",
25
+ import.meta.url
26
+ );
27
+ }
28
+ const scriptPath = JSON.stringify(fileURLToPath(pageScriptUrl));
29
+ const imports = [
30
+ hideSingleLineGutters ? "hideSingleLineGutters" : null,
31
+ syncTocLabelsFromHeadings ? "syncTocLabelsFromHeadings" : null,
32
+ wrapDetailsContent ? "wrapDetailsContent" : null
33
+ ].filter(Boolean);
34
+ if (imports.length === 0) return;
35
+ const calls = imports.map((fn) => `${fn}();`).join("\n");
36
+ injectScript(
37
+ "page",
38
+ `import { ${imports.join(", ")} } from ${scriptPath};
39
+ ${calls}`
40
+ );
41
+ }
42
+ }
43
+ };
44
+ }
45
+
46
+ export {
47
+ starlightDomPatches
48
+ };
@@ -3,8 +3,8 @@ import {
3
3
  } from "./chunk-ICUS267J.js";
4
4
  import "./chunk-MT4FGOLU.js";
5
5
  import "./chunk-YJV35WLF.js";
6
- import "./chunk-XOMTOLBK.js";
7
6
  import "./chunk-IWM27JZF.js";
7
+ import "./chunk-XOMTOLBK.js";
8
8
  import "./chunk-QGM4M3NI.js";
9
9
  export {
10
10
  cpp_default as default
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  ruby_default
3
- } from "./chunk-7DJE5LRN.js";
3
+ } from "./chunk-VX22H7BZ.js";
4
+ import "./chunk-S3SFQXYS.js";
4
5
  import "./chunk-ZSX4GOHC.js";
6
+ import "./chunk-NE25QJUZ.js";
5
7
  import "./chunk-OII47WE4.js";
6
8
  import "./chunk-76C5RMV7.js";
7
- import "./chunk-S3SFQXYS.js";
8
- import "./chunk-NE25QJUZ.js";
9
9
  import "./chunk-ICUS267J.js";
10
10
  import "./chunk-MT4FGOLU.js";
11
11
  import "./chunk-YJV35WLF.js";
12
12
  import "./chunk-5TDK5Y5S.js";
13
- import "./chunk-XOMTOLBK.js";
14
13
  import "./chunk-IWM27JZF.js";
14
+ import "./chunk-XOMTOLBK.js";
15
15
  import "./chunk-VB3O6QM4.js";
16
16
  import "./chunk-QFOAKHDY.js";
17
17
  import "./chunk-AZIN3OHL.js";
package/dist/index.d.ts CHANGED
@@ -1,29 +1,16 @@
1
1
  export { starlightIndexOnlySidebar } from './plugins/starlight-index-only-sidebar.js';
2
- import { AstroIntegration } from 'astro';
2
+ export { DomPatchesOptions, starlightDomPatches } from './plugins/starlight-dom-patches.js';
3
3
  export { SyncDocsToPublicOptions, syncDocsToPublic } from './plugins/astro-sync-docs-to-public.js';
4
4
  export { default as rehypeValidateLinks } from './plugins/rehype-validate-links.js';
5
5
  export { astroNormalizePaths } from './plugins/astro-normalize-paths.js';
6
6
  import { RemarkLatexCompileOptions } from './plugins/astro-latex-compile.js';
7
7
  export { default as remarkLatexCompile } from './plugins/astro-latex-compile.js';
8
+ import { AstroIntegration } from 'astro';
8
9
  import '@astrojs/starlight/types';
9
10
  import 'hast';
10
11
  import 'vfile';
11
12
  import 'mdast';
12
13
 
13
- interface DomPatchesOptions {
14
- /** Hide line number gutters on single-line code blocks. @default false */
15
- hideSingleLineGutters?: boolean;
16
- /** Copy rendered heading innerHTML into matching Starlight TOC anchor labels. @default false */
17
- syncTocLabelsFromHeadings?: boolean;
18
- /** Wrap `<details>` content (excluding `<summary>`) in a `.details-wrapper` div. @default false */
19
- wrapDetailsContent?: boolean;
20
- }
21
- /**
22
- * Astro integration that injects a client-side script to apply DOM patches
23
- * on every page. Each patch can be individually enabled or disabled via options.
24
- */
25
- declare function starlightDomPatches(options?: DomPatchesOptions): AstroIntegration;
26
-
27
14
  interface LatexCompileOptions extends RemarkLatexCompileOptions {
28
15
  /**
29
16
  * When `true`, SVG files in `svgOutputDir` that are no longer referenced by
@@ -36,4 +23,4 @@ interface LatexCompileOptions extends RemarkLatexCompileOptions {
36
23
  }
37
24
  declare function astroLatexCompile(options: LatexCompileOptions): AstroIntegration;
38
25
 
39
- export { type DomPatchesOptions, type LatexCompileOptions, astroLatexCompile, starlightDomPatches };
26
+ export { type LatexCompileOptions, astroLatexCompile };
package/dist/index.js CHANGED
@@ -14,53 +14,11 @@ import {
14
14
  syncDocsToPublic
15
15
  } from "./chunk-WZNJ5VFU.js";
16
16
  import "./chunk-IY4A67ZP.js";
17
+ import {
18
+ starlightDomPatches
19
+ } from "./chunk-XMGAWBJ5.js";
17
20
  import "./chunk-QGM4M3NI.js";
18
21
 
19
- // src/plugins/starlight-dom-patches/index.ts
20
- import { fileURLToPath } from "url";
21
- function starlightDomPatches(options = {}) {
22
- const {
23
- hideSingleLineGutters = false,
24
- syncTocLabelsFromHeadings = false,
25
- wrapDetailsContent = false
26
- } = options;
27
- return {
28
- name: "starlight-dom-patches",
29
- hooks: {
30
- "astro:config:setup": ({ injectScript }) => {
31
- const currentFile = fileURLToPath(import.meta.url);
32
- let pageScriptUrl;
33
- if (currentFile.endsWith(".ts")) {
34
- pageScriptUrl = new URL("./page-script.ts", import.meta.url);
35
- } else if (currentFile.endsWith("starlight-dom-patches.js")) {
36
- pageScriptUrl = new URL(
37
- "./starlight-dom-patches/page-script.js",
38
- import.meta.url
39
- );
40
- } else {
41
- pageScriptUrl = new URL(
42
- "./plugins/starlight-dom-patches/page-script.js",
43
- import.meta.url
44
- );
45
- }
46
- const scriptPath = JSON.stringify(fileURLToPath(pageScriptUrl));
47
- const imports = [
48
- hideSingleLineGutters ? "hideSingleLineGutters" : null,
49
- syncTocLabelsFromHeadings ? "syncTocLabelsFromHeadings" : null,
50
- wrapDetailsContent ? "wrapDetailsContent" : null
51
- ].filter(Boolean);
52
- if (imports.length === 0) return;
53
- const calls = imports.map((fn) => `${fn}();`).join("\n");
54
- injectScript(
55
- "page",
56
- `import { ${imports.join(", ")} } from ${scriptPath};
57
- ${calls}`
58
- );
59
- }
60
- }
61
- };
62
- }
63
-
64
22
  // src/plugins/astro-latex-compile/astro-integration.ts
65
23
  import fs from "fs";
66
24
  import { readdir, rm } from "fs/promises";
@@ -3,23 +3,23 @@ import {
3
3
  } from "./chunk-Z2VUFOSG.js";
4
4
  import {
5
5
  ruby_default
6
- } from "./chunk-7DJE5LRN.js";
6
+ } from "./chunk-VX22H7BZ.js";
7
+ import "./chunk-S3SFQXYS.js";
7
8
  import "./chunk-ZSX4GOHC.js";
9
+ import "./chunk-NE25QJUZ.js";
8
10
  import "./chunk-OII47WE4.js";
9
11
  import "./chunk-76C5RMV7.js";
10
- import "./chunk-S3SFQXYS.js";
11
- import "./chunk-NE25QJUZ.js";
12
12
  import "./chunk-ICUS267J.js";
13
13
  import "./chunk-MT4FGOLU.js";
14
14
  import "./chunk-YJV35WLF.js";
15
15
  import {
16
16
  shellscript_default
17
17
  } from "./chunk-5TDK5Y5S.js";
18
- import "./chunk-XOMTOLBK.js";
19
18
  import {
20
19
  python_default
21
20
  } from "./chunk-QH2T6GYZ.js";
22
21
  import "./chunk-IWM27JZF.js";
22
+ import "./chunk-XOMTOLBK.js";
23
23
  import {
24
24
  typescript_default
25
25
  } from "./chunk-VB3O6QM4.js";
@@ -0,0 +1,5 @@
1
+ declare function hideSingleLineGutters(): void;
2
+ declare function syncTocLabelsFromHeadings(): void;
3
+ declare function wrapDetailsContent(): void;
4
+
5
+ export { hideSingleLineGutters, syncTocLabelsFromHeadings, wrapDetailsContent };
@@ -0,0 +1,65 @@
1
+ import "../../chunk-QGM4M3NI.js";
2
+
3
+ // src/plugins/starlight-dom-patches/page-script.ts
4
+ function hideSingleLineGutters() {
5
+ console.log("Hiding Single Line Gutters");
6
+ const codeElements = document.querySelectorAll(
7
+ "div.expressive-code > figure > pre > code"
8
+ );
9
+ codeElements.forEach((codeElement) => {
10
+ const lineElements = codeElement.querySelectorAll("div.ec-line");
11
+ if (lineElements.length === 1) {
12
+ const gutter = lineElements[0].querySelector("div.gutter");
13
+ if (gutter) {
14
+ gutter.classList.add("visually-hidden");
15
+ }
16
+ }
17
+ });
18
+ }
19
+ function syncTocLabelsFromHeadings() {
20
+ document.querySelectorAll("starlight-toc ul li > a").forEach((anchor) => {
21
+ const href = anchor.getAttribute("href") ?? "";
22
+ const hashIndex = href.indexOf("#");
23
+ if (hashIndex === -1) return;
24
+ const id = href.slice(hashIndex + 1);
25
+ if (id == "_top") return;
26
+ const heading = document.getElementById(id);
27
+ if (!heading) return;
28
+ const span = anchor.querySelector(":scope > span");
29
+ if (!span) return;
30
+ span.innerHTML = heading.innerHTML;
31
+ });
32
+ }
33
+ function wrapDetailsContent() {
34
+ console.log("Wrapping details element contents");
35
+ const detailsElements = document.querySelectorAll(".main-pane details");
36
+ detailsElements.forEach((details) => {
37
+ if (details.children.length === 0) return;
38
+ const summary = details.querySelector(":scope > summary");
39
+ if (!summary) {
40
+ const wrapper = document.createElement("div");
41
+ wrapper.className = "details-wrapper";
42
+ while (details.children.length > 0) {
43
+ wrapper.appendChild(details.children[0]);
44
+ }
45
+ details.appendChild(wrapper);
46
+ } else {
47
+ const wrapper = document.createElement("div");
48
+ wrapper.className = "details-wrapper";
49
+ const childrenToWrap = Array.from(details.children).filter(
50
+ (child) => child !== summary
51
+ );
52
+ childrenToWrap.forEach((child) => {
53
+ wrapper.appendChild(child);
54
+ });
55
+ details.innerHTML = "";
56
+ details.appendChild(summary);
57
+ details.appendChild(wrapper);
58
+ }
59
+ });
60
+ }
61
+ export {
62
+ hideSingleLineGutters,
63
+ syncTocLabelsFromHeadings,
64
+ wrapDetailsContent
65
+ };
@@ -0,0 +1,17 @@
1
+ import { AstroIntegration } from 'astro';
2
+
3
+ interface DomPatchesOptions {
4
+ /** Hide line number gutters on single-line code blocks. @default false */
5
+ hideSingleLineGutters?: boolean;
6
+ /** Copy rendered heading innerHTML into matching Starlight TOC anchor labels. @default false */
7
+ syncTocLabelsFromHeadings?: boolean;
8
+ /** Wrap `<details>` content (excluding `<summary>`) in a `.details-wrapper` div. @default false */
9
+ wrapDetailsContent?: boolean;
10
+ }
11
+ /**
12
+ * Astro integration that injects a client-side script to apply DOM patches
13
+ * on every page. Each patch can be individually enabled or disabled via options.
14
+ */
15
+ declare function starlightDomPatches(options?: DomPatchesOptions): AstroIntegration;
16
+
17
+ export { type DomPatchesOptions, starlightDomPatches };
@@ -0,0 +1,7 @@
1
+ import {
2
+ starlightDomPatches
3
+ } from "../chunk-XMGAWBJ5.js";
4
+ import "../chunk-QGM4M3NI.js";
5
+ export {
6
+ starlightDomPatches
7
+ };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  ruby_default
3
- } from "./chunk-7DJE5LRN.js";
3
+ } from "./chunk-VX22H7BZ.js";
4
+ import "./chunk-S3SFQXYS.js";
4
5
  import "./chunk-ZSX4GOHC.js";
6
+ import "./chunk-NE25QJUZ.js";
5
7
  import "./chunk-OII47WE4.js";
6
8
  import {
7
9
  yaml_default
8
10
  } from "./chunk-76C5RMV7.js";
9
- import "./chunk-S3SFQXYS.js";
10
- import "./chunk-NE25QJUZ.js";
11
11
  import {
12
12
  cpp_default
13
13
  } from "./chunk-ICUS267J.js";
@@ -16,17 +16,17 @@ import "./chunk-YJV35WLF.js";
16
16
  import {
17
17
  shellscript_default
18
18
  } from "./chunk-5TDK5Y5S.js";
19
- import {
20
- cmake_default
21
- } from "./chunk-CYKSS2Y7.js";
22
- import "./chunk-XOMTOLBK.js";
23
19
  import {
24
20
  python_default
25
21
  } from "./chunk-QH2T6GYZ.js";
22
+ import {
23
+ cmake_default
24
+ } from "./chunk-CYKSS2Y7.js";
26
25
  import {
27
26
  html_derivative_default
28
27
  } from "./chunk-HO32H4C2.js";
29
28
  import "./chunk-IWM27JZF.js";
29
+ import "./chunk-XOMTOLBK.js";
30
30
  import "./chunk-VB3O6QM4.js";
31
31
  import "./chunk-QFOAKHDY.js";
32
32
  import "./chunk-AZIN3OHL.js";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  ruby_default
3
- } from "./chunk-7DJE5LRN.js";
3
+ } from "./chunk-VX22H7BZ.js";
4
+ import "./chunk-S3SFQXYS.js";
4
5
  import "./chunk-ZSX4GOHC.js";
6
+ import "./chunk-NE25QJUZ.js";
5
7
  import "./chunk-OII47WE4.js";
6
8
  import "./chunk-76C5RMV7.js";
7
- import "./chunk-S3SFQXYS.js";
8
- import "./chunk-NE25QJUZ.js";
9
9
  import "./chunk-ICUS267J.js";
10
10
  import "./chunk-MT4FGOLU.js";
11
11
  import "./chunk-YJV35WLF.js";
12
12
  import "./chunk-5TDK5Y5S.js";
13
- import "./chunk-XOMTOLBK.js";
14
13
  import "./chunk-IWM27JZF.js";
14
+ import "./chunk-XOMTOLBK.js";
15
15
  import "./chunk-VB3O6QM4.js";
16
16
  import "./chunk-QFOAKHDY.js";
17
17
  import "./chunk-AZIN3OHL.js";
@@ -3,23 +3,26 @@ import {
3
3
  } from "./chunk-LU63TSZZ.js";
4
4
  import {
5
5
  ruby_default
6
- } from "./chunk-7DJE5LRN.js";
6
+ } from "./chunk-VX22H7BZ.js";
7
+ import "./chunk-S3SFQXYS.js";
7
8
  import "./chunk-ZSX4GOHC.js";
9
+ import "./chunk-NE25QJUZ.js";
8
10
  import "./chunk-OII47WE4.js";
9
11
  import "./chunk-76C5RMV7.js";
10
- import "./chunk-S3SFQXYS.js";
11
- import "./chunk-NE25QJUZ.js";
12
12
  import "./chunk-ICUS267J.js";
13
13
  import "./chunk-MT4FGOLU.js";
14
14
  import "./chunk-YJV35WLF.js";
15
15
  import "./chunk-5TDK5Y5S.js";
16
- import "./chunk-XOMTOLBK.js";
17
16
  import {
18
17
  python_default
19
18
  } from "./chunk-QH2T6GYZ.js";
20
19
  import "./chunk-IWM27JZF.js";
20
+ import "./chunk-XOMTOLBK.js";
21
21
  import "./chunk-VB3O6QM4.js";
22
22
  import "./chunk-QFOAKHDY.js";
23
+ import {
24
+ scss_default
25
+ } from "./chunk-3TOTNBUR.js";
23
26
  import "./chunk-AZIN3OHL.js";
24
27
  import "./chunk-YBPIMBI6.js";
25
28
  import "./chunk-GL2Q3EDW.js";
@@ -27,9 +30,6 @@ import "./chunk-L4TNW36O.js";
27
30
  import {
28
31
  javascript_default
29
32
  } from "./chunk-2QHMH6QB.js";
30
- import {
31
- scss_default
32
- } from "./chunk-3TOTNBUR.js";
33
33
  import {
34
34
  css_default
35
35
  } from "./chunk-MQJVB2GB.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "starlight-cannoli-plugins",
3
3
  "type": "module",
4
- "version": "2.3.1",
4
+ "version": "2.3.2",
5
5
  "description": "Starlight plugins for automatic sidebar generation and link validation",
6
6
  "license": "ISC",
7
7
  "main": "./dist/index.js",
@@ -34,6 +34,10 @@
34
34
  "import": "./dist/plugins/astro-sync-docs-to-public.js",
35
35
  "types": "./dist/plugins/astro-sync-docs-to-public.d.ts"
36
36
  },
37
+ "./starlight-dom-patches": {
38
+ "import": "./dist/plugins/starlight-dom-patches.js",
39
+ "types": "./dist/plugins/starlight-dom-patches.d.ts"
40
+ },
37
41
  "./styles": "./dist/styles/",
38
42
  "./styles/*": "./dist/styles/*"
39
43
  },
@@ -1,3 +1,6 @@
1
+ import {
2
+ scss_default
3
+ } from "./chunk-3TOTNBUR.js";
1
4
  import {
2
5
  angular_expression_default,
3
6
  angular_html_default,
@@ -7,9 +10,6 @@ import {
7
10
  } from "./chunk-VN4MPI3U.js";
8
11
  import "./chunk-L4TNW36O.js";
9
12
  import "./chunk-2QHMH6QB.js";
10
- import {
11
- scss_default
12
- } from "./chunk-3TOTNBUR.js";
13
13
  import "./chunk-MQJVB2GB.js";
14
14
  import "./chunk-QGM4M3NI.js";
15
15
 
@@ -1,3 +1,6 @@
1
+ import {
2
+ haml_default
3
+ } from "./chunk-S3SFQXYS.js";
1
4
  import {
2
5
  graphql_default
3
6
  } from "./chunk-ZSX4GOHC.js";
@@ -7,21 +10,18 @@ import {
7
10
  import {
8
11
  yaml_default
9
12
  } from "./chunk-76C5RMV7.js";
10
- import {
11
- haml_default
12
- } from "./chunk-S3SFQXYS.js";
13
13
  import {
14
14
  cpp_default
15
15
  } from "./chunk-ICUS267J.js";
16
16
  import {
17
17
  shellscript_default
18
18
  } from "./chunk-5TDK5Y5S.js";
19
- import {
20
- c_default
21
- } from "./chunk-XOMTOLBK.js";
22
19
  import {
23
20
  sql_default
24
21
  } from "./chunk-IWM27JZF.js";
22
+ import {
23
+ c_default
24
+ } from "./chunk-XOMTOLBK.js";
25
25
  import {
26
26
  xml_default
27
27
  } from "./chunk-AZIN3OHL.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  shellscript_default
3
3
  } from "./chunk-5TDK5Y5S.js";
4
- import {
5
- c_default
6
- } from "./chunk-XOMTOLBK.js";
7
4
  import {
8
5
  sql_default
9
6
  } from "./chunk-IWM27JZF.js";
7
+ import {
8
+ c_default
9
+ } from "./chunk-XOMTOLBK.js";
10
10
  import {
11
11
  html_default
12
12
  } from "./chunk-L4TNW36O.js";
@@ -1,9 +1,9 @@
1
- import {
2
- gdshader_default
3
- } from "./chunk-45O7TJOW.js";
4
1
  import {
5
2
  gdscript_default
6
3
  } from "./chunk-YWWGTQZD.js";
4
+ import {
5
+ gdshader_default
6
+ } from "./chunk-45O7TJOW.js";
7
7
  import "./chunk-QGM4M3NI.js";
8
8
 
9
9
  // node_modules/@shikijs/langs/dist/gdresource.mjs
@@ -6,13 +6,13 @@ import {
6
6
  } from "./chunk-ICUS267J.js";
7
7
  import "./chunk-MT4FGOLU.js";
8
8
  import "./chunk-YJV35WLF.js";
9
- import "./chunk-XOMTOLBK.js";
10
9
  import {
11
10
  python_default
12
11
  } from "./chunk-QH2T6GYZ.js";
13
12
  import {
14
13
  sql_default
15
14
  } from "./chunk-IWM27JZF.js";
15
+ import "./chunk-XOMTOLBK.js";
16
16
  import {
17
17
  javascript_default
18
18
  } from "./chunk-2QHMH6QB.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  glsl_default
3
3
  } from "./chunk-YJV35WLF.js";
4
- import "./chunk-XOMTOLBK.js";
5
4
  import {
6
5
  sql_default
7
6
  } from "./chunk-IWM27JZF.js";
7
+ import "./chunk-XOMTOLBK.js";
8
8
  import {
9
9
  typescript_default
10
10
  } from "./chunk-VB3O6QM4.js";
@@ -7,12 +7,12 @@ import {
7
7
  import {
8
8
  postcss_default
9
9
  } from "./chunk-3BGADQKG.js";
10
- import {
11
- javascript_default
12
- } from "./chunk-2QHMH6QB.js";
13
10
  import {
14
11
  scss_default
15
12
  } from "./chunk-3TOTNBUR.js";
13
+ import {
14
+ javascript_default
15
+ } from "./chunk-2QHMH6QB.js";
16
16
  import {
17
17
  css_default
18
18
  } from "./chunk-MQJVB2GB.js";