clean-jsdoc-theme 4.2.17 → 4.3.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.
package/README.md CHANGED
@@ -1,25 +1,20 @@
1
1
  # clean-jsdoc-theme
2
2
 
3
- [![Stars](https://img.shields.io/github/stars/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme) [![Fork](https://img.shields.io/github/forks/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork) ![Version](https://img.shields.io/badge/version-4.2.17-005bff) [![Issues Open](https://img.shields.io/github/issues/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues) [![Contributors](https://img.shields.io/github/contributors/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/graphs/contributors) [![Build Status](https://travis-ci.org/ankitskvmdam/clean-jsdoc-theme.svg?branch=production)](https://travis-ci.org/ankitskvmdam/clean-jsdoc-theme) [![license](https://img.shields.io/github/license/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/master/LICENSE)
3
+ [![Stars](https://img.shields.io/github/stars/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme) [![Fork](https://img.shields.io/github/forks/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork) ![Version](https://img.shields.io/badge/version-4.3.0-005bff) [![Issues Open](https://img.shields.io/github/issues/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues) [![Contributors](https://img.shields.io/github/contributors/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/graphs/contributors) [![license](https://img.shields.io/github/license/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/master/LICENSE)
4
4
  <br>
5
5
 
6
- `clean-jsdoc-theme` is a beautifully crafted theme for JSDoc 3/JSDoc 4. It is a clean and fully responsive theme with loads of
7
- customisation features.
6
+ `clean-jsdoc-theme` enhances your JSDoc 3 or 4 documentation with a beautiful and responsive design. It offers a variety of customization options to tailor the look and feel to your preferences.
8
7
 
9
- Some salient features:
8
+ ## Key Features
10
9
 
11
- 1. It supports most screens, i.e. desktops, laptops, iPad and mobile devices.
12
- 2. It has a premium-looking dark and light theme.
13
- 3. It minifies all the output HTML files (this helps in saving a few KBs).
14
- 4. It has search support. The search feature doesn't increase the size of output HTML files.
15
- 5. It is regularly updated.
16
- 6. It is highly
17
- performant. [Check lighthouse report here](https://googlechrome.github.io/lighthouse/viewer/?psiurl=https%3A%2F%2Fankdev.me%2Fclean-jsdoc-theme%2Fv4%2Findex.html&strategy=desktop&category=performance&category=accessibility&category=best-practices&category=seo&category=pwa&utm_source=lh-chrome-ext)
18
- .
10
+ - **Widespread Device Compatibility:** `clean-jsdoc-theme` adapts seamlessly to desktops, laptops, tablets, and mobile devices, ensuring a smooth user experience across all platforms.
11
+ - **Premium Aesthetics:** Choose between a sleek dark theme or a bright light theme, both designed to deliver a high-quality appearance for your documentation.
12
+ - **Optimized File Size:** `clean-jsdoc-theme` automatically minifies the generated HTML files, reducing their overall size by several kilobytes without compromising functionality.
13
+ - **Robust Search Functionality:** The built-in search feature allows users to quickly find specific information within your documentation, and it does so without adding extra weight to the output files.
14
+ - **Regular Updates:** We actively maintain `clean-jsdoc-theme`, ensuring it remains up-to-date and compatible with the latest technologies.
15
+ - **Exceptional Performance:** `clean-jsdoc-theme` prioritizes performance, delivering a fast and responsive user experience for your documentation consumers. You can view the [Lighthouse report](https://googlechrome.github.io/lighthouse/viewer/?psiurl=https%3A%2F%2Fankdev.me%2Fclean-jsdoc-theme%2Fv4%2Findex.html&strategy=desktop&category=performance&category=accessibility&category=best-practices&category=seo&category=pwa&utm_source=lh-chrome-ext#) for a detailed performance analysis.
16
+ - **Open Communication:** The `clean-jsdoc-theme` team acknowledges that continuous improvement is essential. We welcome feedback from the community, so feel free to share your suggestions, questions, or bug reports by creating an issue on [GitHub](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues).
19
17
 
20
- We know that no library is perfect. That's why we are open to hearing from the community about the theme. For any
21
- suggestions, questions or bugs, feel free to create
22
- an <a href="https://github.com/ankitskvmdam/clean-jsdoc-theme/issues">issue</a>.
23
18
 
24
19
  ## Demo
25
20
 
@@ -250,7 +245,7 @@ of `meta` tags into `head`.
250
245
  'Mixins',
251
246
  'Tutorials',
252
247
  'Interfaces',
253
- 'Global'
248
+ 'Global',
254
249
  ];
255
250
  ```
256
251
 
@@ -537,13 +532,27 @@ To exclude inherited symbols. Example:
537
532
 
538
533
  This will remove all symbols (members, methods ...) that come from inherited parents.
539
534
 
535
+ ### To remove styled applied to scrollbar
536
+
537
+ By default `clean-jsdoc-theme` applies some styles to browser's scroll bar. However if you want to remove this style do the following
538
+
539
+ ```json
540
+ {
541
+ "theme_opts": {
542
+ "shouldRemoveScrollbarStyle": false
543
+ }
544
+ }
545
+ ```
546
+
547
+ This will remove all symbols (members, methods ...) that come from inherited parents.
548
+
540
549
  ## Cheat sheet
541
550
 
542
551
  | name | default | use case | expected value(s) |
543
552
  | ---------------------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- | ---------------------------------------------------------- |
544
553
  | `default_theme` | `"dark"` | To set the default theme | `"light", "dark"`, `"fallback-light"` or `"fallback-dark"` |
545
- | `homepageTitle` | "Home" | To set the title of homepage | `string` |
546
- | `title` | `null` | To set the title | `HTML` or `string` |
554
+ | `homepageTitle` | "Home" | To set the title of homepage. This will update HTML `<title>`. | `string` |
555
+ | `title` | `null` | To set the title of the sidebar. | `HTML` or `string` |
547
556
  | `base_url` | `/` | To set the base URL | `string` |
548
557
  | `menu` | `null` | To render extra link in navbar | Array of Object(s) |
549
558
  | `meta` | `null` | Meta tag attributes | Array of Object(s) |
@@ -562,6 +571,7 @@ This will remove all symbols (members, methods ...) that come from inherited par
562
571
  | `displayModuleHeader` | `false` | If you want the module name to appear on its page | `boolean` |
563
572
  | `includeFilesListInHomepage` | `false` | If you want to add or remove the list of files in homepage | `boolean` |
564
573
  | `sort` | `true` | To sort the output members/methods/events | `boolean` |
574
+ | `shouldRemoveScrollbarStyle` | `false` | To remove styles applied to browser's scrollbar | `boolean` |
565
575
 
566
576
  Don't forget to add the following in your jsdoc config file, otherwise toc will not work on some pages.
567
577
 
@@ -0,0 +1,56 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ function parseCSS(cssContent) {
5
+ // Implement your CSS parsing logic here
6
+ // You can use regular expressions, string manipulation, or a CSS parsing library
7
+
8
+ // Example: Simple parsing using regular expressions to extract CSS rules
9
+ const cssRules = [];
10
+ const ruleRegex = /(.+?)\s*{\s*(.*?)\s*}/gs;
11
+ let match;
12
+
13
+ while ((match = ruleRegex.exec(cssContent)) !== null) {
14
+ const selector = match[1].trim();
15
+ const declarations = match[2].split(';').map((declaration) => {
16
+ const parts = declaration.split(':').map((part) => part.trim());
17
+
18
+ return {
19
+ property: parts[0],
20
+ value: parts[1],
21
+ };
22
+ });
23
+
24
+ cssRules.push({
25
+ selector,
26
+ declarations: declarations
27
+ .sort((a, b) => a.property.localeCompare(b.property))
28
+ .filter((declaration) => declaration.property !== ''),
29
+ });
30
+ }
31
+
32
+ return cssRules;
33
+ }
34
+
35
+ const cssFile = fs.readFileSync(
36
+ path.join('.', 'static', 'styles', 'clean-jsdoc-theme-light.css')
37
+ );
38
+
39
+ const parsed = parseCSS(cssFile);
40
+
41
+ let output = '';
42
+
43
+ for (const parse of parsed) {
44
+ output += `${parse.selector} {\n`;
45
+
46
+ for (const declaration of parse.declarations) {
47
+ output += `\t${declaration.property}: ${declaration.value};\n`;
48
+ }
49
+ output += '\n}\n\n';
50
+ }
51
+
52
+ fs.writeFileSync(
53
+ path.join('.', 'static', 'styles', 'clean-jsdoc-theme-list.update.css'),
54
+ output
55
+ );
56
+
package/jsdoc-config.json CHANGED
@@ -18,9 +18,11 @@
18
18
  "template": "./",
19
19
  "tutorials": "./demo/src/tutorials",
20
20
  "theme_opts": {
21
+ "shouldRemoveScrollbarStyle": false,
21
22
  "includeFilesListInHomepage": true,
22
23
  "search": true,
23
24
  "homepageTitle": "Clean JSDoc Theme",
25
+ "title": "Clean JSDoc Theme",
24
26
  "default_theme": "dark",
25
27
  "exclude_inherited": false,
26
28
  "include_css": [
@@ -48,7 +50,6 @@
48
50
  "add_scripts": "function foo(){console.log('foo')} function bar() {console.log('bar')} bar(); foo();",
49
51
  "create_style": ".test-create-style{ background: red}",
50
52
  "displayModuleHeader": true,
51
- "title": "clean-jsdoc-theme",
52
53
  "footer": "<div style='margin-bottom: 0.5rem;'>clean-jsdoc-theme</div> Fork: <a href='https://github.com/ankitskvmdam/clean-jsdoc-theme'>https://github.com/ankitskvmdam/clean-jsdoc-theme</a>",
53
54
  "meta": [
54
55
  {
package/minify.js CHANGED
@@ -10,30 +10,30 @@ const cssPath = path.join(pwd, 'static', 'styles');
10
10
  const uglifyFiles = [
11
11
  {
12
12
  src: path.join(scriptsPath, 'core.js'),
13
- dest: path.join(scriptsPath, 'core.min.js')
13
+ dest: path.join(scriptsPath, 'core.min.js'),
14
14
  },
15
15
  {
16
16
  src: path.join(scriptsPath, 'search.js'),
17
- dest: path.join(scriptsPath, 'search.min.js')
17
+ dest: path.join(scriptsPath, 'search.min.js'),
18
18
  },
19
19
  {
20
20
  src: path.join(scriptsPath, 'third-party', 'hljs-original.js'),
21
- dest: path.join(scriptsPath, 'third-party', 'hljs.js')
21
+ dest: path.join(scriptsPath, 'third-party', 'hljs.js'),
22
22
  },
23
23
  {
24
24
  src: path.join(scriptsPath, 'third-party', 'hljs-line-num-original.js'),
25
- dest: path.join(scriptsPath, 'third-party', 'hljs-line-num.js')
25
+ dest: path.join(scriptsPath, 'third-party', 'hljs-line-num.js'),
26
26
  },
27
27
  {
28
28
  src: path.join(scriptsPath, 'third-party', 'tocbot.js'),
29
- dest: path.join(scriptsPath, 'third-party', 'tocbot.min.js')
30
- }
29
+ dest: path.join(scriptsPath, 'third-party', 'tocbot.min.js'),
30
+ },
31
31
  ];
32
32
 
33
33
  const cssFilePaths = [
34
34
  path.join(cssPath, 'clean-jsdoc-theme-base.css'),
35
35
  path.join(cssPath, 'clean-jsdoc-theme-dark.css'),
36
- path.join(cssPath, 'clean-jsdoc-theme-light.css')
36
+ path.join(cssPath, 'clean-jsdoc-theme-light.css'),
37
37
  ];
38
38
 
39
39
  let css = '';
@@ -42,10 +42,22 @@ for (const p of cssFilePaths) {
42
42
  css += fs.readFileSync(p, 'utf-8');
43
43
  }
44
44
 
45
+ const cssWithScrollbar =
46
+ css +
47
+ fs.readFileSync(path.join(cssPath, 'clean-jsdoc-theme-scrollbar.css'));
48
+
45
49
  const minifiedCss = csso.minify(css, { restructure: false });
50
+ const minifiedCssWithScrollbar = csso.minify(cssWithScrollbar, {
51
+ restructure: false,
52
+ });
46
53
 
47
54
  fs.writeFileSync(
48
55
  path.join(cssPath, 'clean-jsdoc-theme.min.css'),
56
+ minifiedCssWithScrollbar.css
57
+ );
58
+
59
+ fs.writeFileSync(
60
+ path.join(cssPath, 'clean-jsdoc-theme-without-scrollbar.min.css'),
49
61
  minifiedCss.css
50
62
  );
51
63
 
@@ -53,7 +65,7 @@ for (const f of uglifyFiles) {
53
65
  const data = fs.readFileSync(f.src, 'utf-8');
54
66
 
55
67
  const out = uglify.minify(data, {
56
- compress: true
68
+ compress: true,
57
69
  });
58
70
 
59
71
  fs.writeFileSync(f.dest, out.code);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clean-jsdoc-theme",
3
- "version": "4.2.17",
3
+ "version": "4.3.0",
4
4
  "description": "A beautifully crafted theme/template for JSDoc 3. This theme/template looks and feels like a premium theme/template. This is a fully mobile responsive theme and also fully customizable theme.",
5
5
  "main": "publish.js",
6
6
  "scripts": {
package/publish.js CHANGED
@@ -530,7 +530,7 @@ function buildNavbar() {
530
530
  * @return {string} The HTML for the navigation sidebar.
531
531
  */
532
532
  function buildSidebar(members) {
533
- const title = themeOpts.title || 'Home';
533
+ const title = themeOpts.title;
534
534
 
535
535
  const isHTML = RegExp.prototype.test.bind(/(<([^>]+)>)/i);
536
536
 
@@ -732,6 +732,7 @@ exports.publish = async function (taffyData, opts, tutorials) {
732
732
  };
733
733
  });
734
734
  }
735
+
735
736
  if (doclet.see) {
736
737
  doclet.see.forEach(function (seeItem, i) {
737
738
  doclet.see[i] = hashToLink(doclet, seeItem);
@@ -896,6 +897,9 @@ exports.publish = async function (taffyData, opts, tutorials) {
896
897
  view.codepen = codepen(themeOpts);
897
898
  view.excludeInherited = Boolean(themeOpts.exclude_inherited);
898
899
  view.baseURL = getBaseURL(themeOpts);
900
+ view.shouldRemoveScrollbarStyle = Boolean(
901
+ themeOpts.shouldRemoveScrollbarStyle
902
+ );
899
903
  attachModuleSymbols(
900
904
  find({ longname: { left: 'module:' } }),
901
905
  members.modules
@@ -632,6 +632,29 @@ function addHrefToSidebarTitle() {
632
632
  });
633
633
  }
634
634
 
635
+ function highlightActiveLinkInSidebar() {
636
+ const list = document.location.href.split('/');
637
+ const targetURL = decodeURI(list[list.length - 1]);
638
+ let element = document.querySelector(`.sidebar a[href*='${targetURL}']`);
639
+
640
+ if (!element) {
641
+ try {
642
+ element = document.querySelector(
643
+ `.sidebar a[href*='${targetURL.split('#')[0]}']`
644
+ );
645
+ } catch (e) {
646
+ console.error(e);
647
+
648
+ return;
649
+ }
650
+ }
651
+
652
+ if (!element) return;
653
+
654
+ element.parentElement.classList.add('active');
655
+ element.scrollIntoView();
656
+ }
657
+
635
658
  function onDomContentLoaded() {
636
659
  var themeButton = document.querySelectorAll('.theme-toggle');
637
660
 
@@ -676,6 +699,7 @@ function onDomContentLoaded() {
676
699
  initTooltip();
677
700
  fixTable();
678
701
  addHrefToSidebarTitle();
702
+ highlightActiveLinkInSidebar();
679
703
  }
680
704
 
681
705
  // eslint-disable-next-line no-undef
@@ -1,23 +1,23 @@
1
- var accordionLocalStorageKey="accordion-id",themeLocalStorageKey="theme",fontSizeLocalStorageKey="font-size",html=document.querySelector("html"),MAX_FONT_SIZE=30,MIN_FONT_SIZE=10,localStorage=window.localStorage;function getTheme(){var e=localStorage.getItem(themeLocalStorageKey);if(e)return e;switch(e=document.body.getAttribute("data-theme")){case"dark":case"light":return e;case"fallback-dark":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";case"fallback-light":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";default:return"dark"}}function localUpdateTheme(e){var t=document.body,o=document.querySelectorAll(".theme-svg-use"),n="dark"===e?"#light-theme-icon":"#dark-theme-icon";t.setAttribute("data-theme",e),t.classList.remove("dark","light"),t.classList.add(e),o.forEach(function(e){e.setAttribute("xlink:href",n)})}function updateTheme(e){localUpdateTheme(e),localStorage.setItem(themeLocalStorageKey,e)}function toggleTheme(){updateTheme("dark"===document.body.getAttribute("data-theme")?"light":"dark")}function setAccordionIdToLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));t[e]=e,localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function removeAccordionIdFromLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));delete t[e],localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function getAccordionIdsFromLocalStorage(){return JSON.parse(localStorage.getItem(accordionLocalStorageKey))||{}}function toggleAccordion(e){"false"===e.getAttribute("data-isopen")?(e.setAttribute("data-isopen","true"),setAccordionIdToLocalStorage(e.id)):(e.setAttribute("data-isopen","false"),removeAccordionIdFromLocalStorage(e.id))}function initAccordion(){void 0!==localStorage.getItem(accordionLocalStorageKey)&&null!==localStorage.getItem(accordionLocalStorageKey)||localStorage.setItem(accordionLocalStorageKey,"{}");var e=document.querySelectorAll(".sidebar-section-title"),t=getAccordionIdsFromLocalStorage();e.forEach(function(e){e.addEventListener("click",function(){toggleAccordion(e)}),e.id in t&&toggleAccordion(e)})}function isSourcePage(){return Boolean(document.querySelector("#source-page"))}function bringElementIntoView(e,t=!0){var o,n,i,c;e&&(tocbotInstance&&setTimeout(()=>tocbotInstance.updateTocListActiveElement(e),60),o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16,o&&(c+=o.scrollHeight),n&&n.scrollBy(0,i-c),t&&history.pushState(null,null,"#"+e.id))}function bringLinkToView(e){e.preventDefault(),e.stopPropagation();var e=e.currentTarget.getAttribute("href");!e||(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e)}function bringIdToViewOnMount(){var e,t;isSourcePage()||""!==(e=window.location.hash)&&((t=document.getElementById(e.slice(1)))||(e=decodeURI(e),t=document.getElementById(e.slice(1))),t&&bringElementIntoView(t,!1))}function createAnchorElement(e){var t=document.createElement("a");return t.textContent="#",t.href="#"+e,t.classList.add("link-anchor"),t.onclick=bringLinkToView,t}function addAnchor(){var e=document.querySelector(".main-content").querySelector("section");[e.querySelectorAll("h1"),e.querySelectorAll("h2"),e.querySelectorAll("h3"),e.querySelectorAll("h4")].forEach(function(e){e.forEach(function(e){var t=createAnchorElement(e.id);e.classList.add("has-anchor"),e.append(t)})})}function copy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function showTooltip(e){var t=document.getElementById(e);t.classList.add("show-tooltip"),setTimeout(function(){t.classList.remove("show-tooltip")},3e3)}function copyFunction(e){var t=document.getElementById(e);copy((t.querySelector(".linenums")||t.querySelector("code")).innerText.trim().replace(/(^\t)/gm,"")),showTooltip("tooltip-"+e)}function hideTocOnSourcePage(){isSourcePage()&&(document.querySelector(".toc-container").style.display="none")}function getPreTopBar(e,t=""){e='<button aria-label="copy code" class="icon-button copy-code" onclick="copyFunction(\''+e+'\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>'+('<div class="tooltip" id="tooltip-'+e+'">Copied!</div>')+"</button>";return'<div class="pre-top-bar-container">'+('<div class="code-lang-name-container"><div class="code-lang-name">'+t.toLocaleUpperCase()+"</div></div>")+e+"</div>"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.appendChild(e))})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function localUpdateFontSize(e){html.style.fontSize=e+"px";var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function updateFontSize(e){localUpdateFontSize(e),localStorage.setItem(fontSizeLocalStorageKey,e)}function incrementFont(e){var t=getFontSize();t<MAX_FONT_SIZE&&updateFontSize(t+1)}function decrementFont(e){var t=getFontSize();MIN_FONT_SIZE<t&&updateFontSize(t-1)}function fontSizeTooltip(){var e=getFontSize();return`
2
- <div class="font-size-tooltip">
3
- <button aria-label="decrease-font-size" class="icon-button ${MAX_FONT_SIZE<=e?"disabled":""}" onclick="decrementFont(event)">
4
- <svg>
5
- <use xlink:href="#minus-icon"></use>
6
- </svg>
7
- </button>
8
- <div class="font-size-text" id="b77a68a492f343baabea06fad81f651e">
9
- ${e}
10
- </div>
11
- <button aria-label="increase-font-size" class="icon-button ${e<=MIN_FONT_SIZE?"disabled":""}" onclick="incrementFont(event)">
12
- <svg>
13
- <use xlink:href="#add-icon"></use>
14
- </svg>
15
- </button>
16
- <button class="icon-button" onclick="updateFontSize(16)">
17
- <svg>
18
- <use xlink:href="#reset-icon"></use>
19
- </svg>
20
- </button>
21
- </div>
22
-
23
- `}function initTooltip(){tippy(".theme-toggle",{content:"Toggle Theme",delay:500}),tippy(".search-button",{content:"Search",delay:500}),tippy(".font-size",{content:"Change font size",delay:500}),tippy(".codepen-button",{content:"Open code in CodePen",placement:"left"}),tippy(".copy-code",{content:"Copy this code",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){for(const t of document.querySelectorAll("table")){if(t.classList.contains("hljs-ln"))return;var e=document.createElement("div");e.classList.add("table-div"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}function hideMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.remove("show"),t&&t.setAttribute("data-isopen","false"),o&&o.setAttribute("xlink:href","#menu-icon")}function showMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.add("show"),t&&t.setAttribute("data-isopen","true"),o&&o.setAttribute("xlink:href","#close-icon")}function onMobileMenuClick(){("true"===document.querySelector("#mobile-menu").getAttribute("data-isopen")?hideMobileMenu:showMobileMenu)()}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function addHrefToSidebarTitle(){document.querySelectorAll(".sidebar-title-anchor").forEach(function(e){e.setAttribute("href",baseURL)})}function onDomContentLoaded(){var e=document.querySelectorAll(".theme-toggle");initMobileMenu(),e&&e.forEach(function(e){e.addEventListener("click",toggleTheme)}),hljs.addPlugin({"after:highlightElement":function(e){e.el.parentNode.setAttribute("data-lang","code")}}),hljs.highlightAll(),hljs.initLineNumbersOnLoad({singleLine:!0}),initAccordion(),addAnchor(),processAllPre(),hideTocOnSourcePage(),setTimeout(function(){bringIdToViewOnMount(),isSourcePage()&&highlightAndBringLineIntoView()},1e3),initTooltip(),fixTable(),addHrefToSidebarTitle()}updateTheme(getTheme()),function(){var e=getFontSize(),t=localStorage.getItem(fontSizeLocalStorageKey);t?(t=Number.parseInt(t,10))!==e&&updateFontSize(t):updateFontSize(e)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",e=>{e=new URL(e.newURL);""!==e.hash&&bringIdToViewOnMount(e.hash)}),window.addEventListener("storage",e=>{"undefined"!==e.newValue&&(initTooltip(),e.key===themeLocalStorageKey&&localUpdateTheme(e.newValue),e.key===fontSizeLocalStorageKey&&localUpdateFontSize(e.newValue))});
1
+ var accordionLocalStorageKey="accordion-id",themeLocalStorageKey="theme",fontSizeLocalStorageKey="font-size",html=document.querySelector("html"),MAX_FONT_SIZE=30,MIN_FONT_SIZE=10,localStorage=window.localStorage;function getTheme(){var e=localStorage.getItem(themeLocalStorageKey);if(e)return e;switch(e=document.body.getAttribute("data-theme")){case"dark":case"light":return e;case"fallback-dark":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";case"fallback-light":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";default:return"dark"}}function localUpdateTheme(e){var t=document.body,o=document.querySelectorAll(".theme-svg-use"),n="dark"===e?"#light-theme-icon":"#dark-theme-icon";t.setAttribute("data-theme",e),t.classList.remove("dark","light"),t.classList.add(e),o.forEach(function(e){e.setAttribute("xlink:href",n)})}function updateTheme(e){localUpdateTheme(e),localStorage.setItem(themeLocalStorageKey,e)}function toggleTheme(){updateTheme("dark"===document.body.getAttribute("data-theme")?"light":"dark")}function setAccordionIdToLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));t[e]=e,localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function removeAccordionIdFromLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));delete t[e],localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function getAccordionIdsFromLocalStorage(){return JSON.parse(localStorage.getItem(accordionLocalStorageKey))||{}}function toggleAccordion(e){"false"===e.getAttribute("data-isopen")?(e.setAttribute("data-isopen","true"),setAccordionIdToLocalStorage(e.id)):(e.setAttribute("data-isopen","false"),removeAccordionIdFromLocalStorage(e.id))}function initAccordion(){void 0!==localStorage.getItem(accordionLocalStorageKey)&&null!==localStorage.getItem(accordionLocalStorageKey)||localStorage.setItem(accordionLocalStorageKey,"{}");var e=document.querySelectorAll(".sidebar-section-title"),t=getAccordionIdsFromLocalStorage();e.forEach(function(e){e.addEventListener("click",function(){toggleAccordion(e)}),e.id in t&&toggleAccordion(e)})}function isSourcePage(){return Boolean(document.querySelector("#source-page"))}function bringElementIntoView(e,t=!0){var o,n,i,c;e&&(tocbotInstance&&setTimeout(()=>tocbotInstance.updateTocListActiveElement(e),60),o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16,o&&(c+=o.scrollHeight),n&&n.scrollBy(0,i-c),t&&history.pushState(null,null,"#"+e.id))}function bringLinkToView(e){e.preventDefault(),e.stopPropagation();var e=e.currentTarget.getAttribute("href");!e||(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e)}function bringIdToViewOnMount(){var e,t;isSourcePage()||""!==(e=window.location.hash)&&((t=document.getElementById(e.slice(1)))||(e=decodeURI(e),t=document.getElementById(e.slice(1))),t&&bringElementIntoView(t,!1))}function createAnchorElement(e){var t=document.createElement("a");return t.textContent="#",t.href="#"+e,t.classList.add("link-anchor"),t.onclick=bringLinkToView,t}function addAnchor(){var e=document.querySelector(".main-content").querySelector("section");[e.querySelectorAll("h1"),e.querySelectorAll("h2"),e.querySelectorAll("h3"),e.querySelectorAll("h4")].forEach(function(e){e.forEach(function(e){var t=createAnchorElement(e.id);e.classList.add("has-anchor"),e.append(t)})})}function copy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function showTooltip(e){var t=document.getElementById(e);t.classList.add("show-tooltip"),setTimeout(function(){t.classList.remove("show-tooltip")},3e3)}function copyFunction(e){var t=document.getElementById(e);copy((t.querySelector(".linenums")||t.querySelector("code")).innerText.trim().replace(/(^\t)/gm,"")),showTooltip("tooltip-"+e)}function hideTocOnSourcePage(){isSourcePage()&&(document.querySelector(".toc-container").style.display="none")}function getPreTopBar(e,t=""){e='<button aria-label="copy code" class="icon-button copy-code" onclick="copyFunction(\''+e+'\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>'+('<div class="tooltip" id="tooltip-'+e+'">Copied!</div>')+"</button>";return'<div class="pre-top-bar-container">'+('<div class="code-lang-name-container"><div class="code-lang-name">'+t.toLocaleUpperCase()+"</div></div>")+e+"</div>"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.appendChild(e))})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function localUpdateFontSize(e){html.style.fontSize=e+"px";var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function updateFontSize(e){localUpdateFontSize(e),localStorage.setItem(fontSizeLocalStorageKey,e)}function incrementFont(e){var t=getFontSize();t<MAX_FONT_SIZE&&updateFontSize(t+1)}function decrementFont(e){var t=getFontSize();MIN_FONT_SIZE<t&&updateFontSize(t-1)}function fontSizeTooltip(){var e=getFontSize();return`
2
+ <div class="font-size-tooltip">
3
+ <button aria-label="decrease-font-size" class="icon-button ${MAX_FONT_SIZE<=e?"disabled":""}" onclick="decrementFont(event)">
4
+ <svg>
5
+ <use xlink:href="#minus-icon"></use>
6
+ </svg>
7
+ </button>
8
+ <div class="font-size-text" id="b77a68a492f343baabea06fad81f651e">
9
+ ${e}
10
+ </div>
11
+ <button aria-label="increase-font-size" class="icon-button ${e<=MIN_FONT_SIZE?"disabled":""}" onclick="incrementFont(event)">
12
+ <svg>
13
+ <use xlink:href="#add-icon"></use>
14
+ </svg>
15
+ </button>
16
+ <button class="icon-button" onclick="updateFontSize(16)">
17
+ <svg>
18
+ <use xlink:href="#reset-icon"></use>
19
+ </svg>
20
+ </button>
21
+ </div>
22
+
23
+ `}function initTooltip(){tippy(".theme-toggle",{content:"Toggle Theme",delay:500}),tippy(".search-button",{content:"Search",delay:500}),tippy(".font-size",{content:"Change font size",delay:500}),tippy(".codepen-button",{content:"Open code in CodePen",placement:"left"}),tippy(".copy-code",{content:"Copy this code",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){for(const t of document.querySelectorAll("table")){if(t.classList.contains("hljs-ln"))return;var e=document.createElement("div");e.classList.add("table-div"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}function hideMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.remove("show"),t&&t.setAttribute("data-isopen","false"),o&&o.setAttribute("xlink:href","#menu-icon")}function showMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.add("show"),t&&t.setAttribute("data-isopen","true"),o&&o.setAttribute("xlink:href","#close-icon")}function onMobileMenuClick(){("true"===document.querySelector("#mobile-menu").getAttribute("data-isopen")?hideMobileMenu:showMobileMenu)()}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function addHrefToSidebarTitle(){document.querySelectorAll(".sidebar-title-anchor").forEach(function(e){e.setAttribute("href",baseURL)})}function highlightActiveLinkInSidebar(){var e=document.location.href.split("/");const t=decodeURI(e[e.length-1]);let o=document.querySelector(`.sidebar a[href*='${t}']`);if(!o)try{o=document.querySelector(`.sidebar a[href*='${t.split("#")[0]}']`)}catch(e){return void console.error(e)}o&&(o.parentElement.classList.add("active"),o.scrollIntoView())}function onDomContentLoaded(){var e=document.querySelectorAll(".theme-toggle");initMobileMenu(),e&&e.forEach(function(e){e.addEventListener("click",toggleTheme)}),hljs.addPlugin({"after:highlightElement":function(e){e.el.parentNode.setAttribute("data-lang","code")}}),hljs.highlightAll(),hljs.initLineNumbersOnLoad({singleLine:!0}),initAccordion(),addAnchor(),processAllPre(),hideTocOnSourcePage(),setTimeout(function(){bringIdToViewOnMount(),isSourcePage()&&highlightAndBringLineIntoView()},1e3),initTooltip(),fixTable(),addHrefToSidebarTitle(),highlightActiveLinkInSidebar()}updateTheme(getTheme()),function(){var e=getFontSize(),t=localStorage.getItem(fontSizeLocalStorageKey);t?(t=Number.parseInt(t,10))!==e&&updateFontSize(t):updateFontSize(e)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",e=>{e=new URL(e.newURL);""!==e.hash&&bringIdToViewOnMount(e.hash)}),window.addEventListener("storage",e=>{"undefined"!==e.newValue&&(initTooltip(),e.key===themeLocalStorageKey&&localUpdateTheme(e.newValue),e.key===fontSizeLocalStorageKey&&localUpdateFontSize(e.newValue))});