clean-jsdoc-theme 4.2.7 → 4.2.8

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,6 +1,6 @@
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.6-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.2.9-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)
4
4
  <br>
5
5
 
6
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
package/jsdoc-config.json CHANGED
@@ -53,7 +53,8 @@
53
53
  "js_external": "https://code.jquery.com/jquery-3.6.0.min.js",
54
54
  "js_pre_processor": "babel"
55
55
  }
56
- }
56
+ },
57
+ "prefixModuleToSidebarItems_experimental": true
57
58
  }
58
59
  },
59
60
  "templates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clean-jsdoc-theme",
3
- "version": "4.2.7",
3
+ "version": "4.2.8",
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": {
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@jsdoc/salty": "^0.2.4",
49
49
  "fs-extra": "^10.1.0",
50
- "html-minifier": "^4.0.0",
50
+ "html-minifier-terser": "^7.2.0",
51
51
  "klaw-sync": "^6.0.0",
52
52
  "lodash": "^4.17.21",
53
53
  "nanoid": "^3.3.4",
package/publish.js CHANGED
@@ -7,7 +7,7 @@ const path = require('jsdoc/path');
7
7
  const { taffy } = require('@jsdoc/salty');
8
8
  const template = require('jsdoc/template');
9
9
  const nanoid = require('nanoid').nanoid;
10
- const htmlMinify = require('html-minifier');
10
+ const htmlMinify = require('html-minifier-terser');
11
11
 
12
12
  const {
13
13
  buildFooter,
@@ -284,7 +284,39 @@ function getPathFromDoclet({ meta }) {
284
284
  : meta.filename;
285
285
  }
286
286
 
287
- function generate(title, docs, filename, resolveLinks) {
287
+ function createPrettyAnchor(elementType, ancestor, name, href) {
288
+ return `<${elementType} ${href ? `href="${href}"` : ''} class="has-anchor">
289
+ <span class="ancestors">
290
+ ${ancestor}~
291
+ </span>
292
+ ${name}
293
+ </${elementType}>`;
294
+ }
295
+
296
+ function prefixModuleToItemAnchor(item) {
297
+ let { anchor } = item;
298
+
299
+ let anchorLink = anchor.split('href="')[1].split('"')[0];
300
+ let cleanLink = anchorLink.replace(/\.html$/, '');
301
+
302
+ let prettyAnchor;
303
+
304
+ cleanLink.replace(
305
+ /module-([^-]+)(?:-|\.)(.*)/,
306
+ (_match, modulename, methodname) => {
307
+ prettyAnchor = createPrettyAnchor(
308
+ 'a',
309
+ modulename,
310
+ methodname,
311
+ anchorLink
312
+ );
313
+ }
314
+ );
315
+
316
+ return prettyAnchor || anchor;
317
+ }
318
+
319
+ async function generate(title, docs, filename, resolveLinks) {
288
320
  let docData;
289
321
  let html;
290
322
  let outpath;
@@ -302,11 +334,9 @@ function generate(title, docs, filename, resolveLinks) {
302
334
  html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
303
335
  }
304
336
 
305
- fs.writeFileSync(
306
- outpath,
307
- htmlMinify.minify(html, HTML_MINIFY_OPTIONS),
308
- 'utf8'
309
- );
337
+ const minifiedHtml = await htmlMinify.minify(html, HTML_MINIFY_OPTIONS);
338
+
339
+ fs.writeFileSync(outpath, minifiedHtml, 'utf8');
310
340
  }
311
341
 
312
342
  function generateSourceFiles(sourceFiles, encoding = 'utf8') {
@@ -455,8 +485,8 @@ function buildSearchListForData() {
455
485
  searchList.push({
456
486
  title: item.longname,
457
487
  link: linkto(item.longname, item.name),
458
- description: item.description
459
- })
488
+ description: item.description,
489
+ });
460
490
  }
461
491
  });
462
492
  }
@@ -605,7 +635,7 @@ function buildSidebar(members) {
605
635
  nav.sections.push(sections[section]);
606
636
  } else {
607
637
  const errorMsg = `While building nav. Section name: ${section} is not recognized.
608
- Accepted sections are: ${defaultSections.join(', ')}
638
+ Accepted sections are: ${defaultSections.join(', ')}
609
639
  `;
610
640
 
611
641
  throw new Error(errorMsg);
@@ -620,7 +650,7 @@ function buildSidebar(members) {
620
650
  @param {object} opts
621
651
  @param {Tutorial} tutorials
622
652
  */
623
- exports.publish = function (taffyData, opts, tutorials) {
653
+ exports.publish = async function (taffyData, opts, tutorials) {
624
654
  let classes;
625
655
  let conf;
626
656
  let externals;
@@ -671,10 +701,10 @@ exports.publish = function (taffyData, opts, tutorials) {
671
701
  data = helper.prune(data);
672
702
 
673
703
  // eslint-disable-next-line no-extra-boolean-cast, no-implicit-coercion
674
- if(themeOpts.sort !== false ) {
704
+ if (themeOpts.sort !== false) {
675
705
  data.sort('longname, version, since');
676
706
  }
677
-
707
+
678
708
  helper.addEventListeners(data);
679
709
 
680
710
  data().each((doclet) => {
@@ -871,13 +901,23 @@ exports.publish = function (taffyData, opts, tutorials) {
871
901
  members.modules
872
902
  );
873
903
 
904
+ if (themeOpts.prefixModuleToSidebarItems_experimental) {
905
+ view.sidebar.sections.forEach((section, i) => {
906
+ view.sidebar.sections[i].items = section.items.map((item) => {
907
+ item.anchor = prefixModuleToItemAnchor(item);
908
+
909
+ return item;
910
+ });
911
+ });
912
+ }
913
+
874
914
  // generate the pretty-printed source files first so other pages can link to them
875
915
  if (outputSourceFiles) {
876
916
  generateSourceFiles(sourceFiles, opts.encoding);
877
917
  }
878
918
 
879
919
  if (members.globals.length) {
880
- generate('Global', [{ kind: 'globalobj' }], globalUrl);
920
+ await generate('Global', [{ kind: 'globalobj' }], globalUrl);
881
921
  }
882
922
 
883
923
  // index page displays information from package.json and lists files
@@ -888,7 +928,7 @@ exports.publish = function (taffyData, opts, tutorials) {
888
928
  const includeFilesListInHomepage =
889
929
  themeOpts.includeFilesListInHomepage || false;
890
930
 
891
- generate(
931
+ await generate(
892
932
  homepageTitle,
893
933
  packages
894
934
  .concat([
@@ -912,7 +952,7 @@ exports.publish = function (taffyData, opts, tutorials) {
912
952
  externals = taffy(members.externals);
913
953
  interfaces = taffy(members.interfaces);
914
954
 
915
- Object.keys(helper.longnameToUrl).forEach(function (longname) {
955
+ Object.keys(helper.longnameToUrl).forEach(async function (longname) {
916
956
  const myClasses = helper.find(classes, { longname: longname });
917
957
  const myExternals = helper.find(externals, { longname: longname });
918
958
  const myInterfaces = helper.find(interfaces, { longname: longname });
@@ -921,7 +961,7 @@ exports.publish = function (taffyData, opts, tutorials) {
921
961
  const myNamespaces = helper.find(namespaces, { longname: longname });
922
962
 
923
963
  if (myModules.length) {
924
- generate(
964
+ await generate(
925
965
  `Module: ${myModules[0].name}`,
926
966
  myModules,
927
967
  helper.longnameToUrl[longname]
@@ -929,7 +969,7 @@ exports.publish = function (taffyData, opts, tutorials) {
929
969
  }
930
970
 
931
971
  if (myClasses.length) {
932
- generate(
972
+ await generate(
933
973
  `Class: ${myClasses[0].name}`,
934
974
  myClasses,
935
975
  helper.longnameToUrl[longname]
@@ -937,7 +977,7 @@ exports.publish = function (taffyData, opts, tutorials) {
937
977
  }
938
978
 
939
979
  if (myNamespaces.length) {
940
- generate(
980
+ await generate(
941
981
  `Namespace: ${myNamespaces[0].name}`,
942
982
  myNamespaces,
943
983
  helper.longnameToUrl[longname]
@@ -945,7 +985,7 @@ exports.publish = function (taffyData, opts, tutorials) {
945
985
  }
946
986
 
947
987
  if (myMixins.length) {
948
- generate(
988
+ await generate(
949
989
  `Mixin: ${myMixins[0].name}`,
950
990
  myMixins,
951
991
  helper.longnameToUrl[longname]
@@ -953,7 +993,7 @@ exports.publish = function (taffyData, opts, tutorials) {
953
993
  }
954
994
 
955
995
  if (myExternals.length) {
956
- generate(
996
+ await generate(
957
997
  `External: ${myExternals[0].name}`,
958
998
  myExternals,
959
999
  helper.longnameToUrl[longname]
@@ -961,7 +1001,7 @@ exports.publish = function (taffyData, opts, tutorials) {
961
1001
  }
962
1002
 
963
1003
  if (myInterfaces.length) {
964
- generate(
1004
+ await generate(
965
1005
  `Interface: ${myInterfaces[0].name}`,
966
1006
  myInterfaces,
967
1007
  helper.longnameToUrl[longname]
@@ -970,7 +1010,7 @@ exports.publish = function (taffyData, opts, tutorials) {
970
1010
  });
971
1011
 
972
1012
  // TODO: move the tutorial functions to templateHelper.js
973
- function generateTutorial(title, tutorial, filename) {
1013
+ async function generateTutorial(title, tutorial, filename) {
974
1014
  const tutorialData = {
975
1015
  title: title,
976
1016
  header: tutorial.title,
@@ -984,49 +1024,49 @@ exports.publish = function (taffyData, opts, tutorials) {
984
1024
  // yes, you can use {@link} in tutorials too!
985
1025
  html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
986
1026
 
987
- fs.writeFileSync(
988
- tutorialPath,
989
- htmlMinify.minify(html, HTML_MINIFY_OPTIONS),
990
- 'utf8'
991
- );
1027
+ const minifiedHTML = await htmlMinify.minify(html, HTML_MINIFY_OPTIONS);
1028
+
1029
+ fs.writeFileSync(tutorialPath, minifiedHTML, 'utf8');
992
1030
 
993
1031
  // added by clean-jsdoc-theme-devs
994
1032
  // adding support for tutorial
995
- if(!hasSearch) return
1033
+ if (!hasSearch) return;
996
1034
 
997
- try{
998
- const baseName = path.basename(tutorialPath)
999
- let body = /<body.*?>([\s\S]*)<\/body>/.exec(tutorialData.content)
1000
- let description = ''
1035
+ try {
1036
+ const baseName = path.basename(tutorialPath);
1037
+ let body = /<body.*?>([\s\S]*)<\/body>/.exec(tutorialData.content);
1038
+ let description = '';
1001
1039
 
1002
- if(!Array.isArray(body)) {
1003
- body = /<article.*?>([\s\S]*)<\/article>/.exec(tutorialData.content)
1040
+ if (!Array.isArray(body)) {
1041
+ body = /<article.*?>([\s\S]*)<\/article>/.exec(
1042
+ tutorialData.content
1043
+ );
1004
1044
  }
1005
1045
 
1006
- if(Array.isArray(body) && typeof body[1] === 'string') {
1046
+ if (Array.isArray(body) && typeof body[1] === 'string') {
1007
1047
  description = body[1]
1008
- // Replacing all html tags
1009
- .replace(/(<([^>]+)>)/g, '')
1010
- // Replacing all kind of line breaks
1011
- .replace(/(\r\n|\n|\r)/gm, " ")
1012
- // Replacing all multi spaces with single space
1013
- .replace(/\s+/gm, ' ')
1014
- // Taking only first 100 characters
1015
- .substring(0, 100)
1048
+ // Replacing all html tags
1049
+ .replace(/(<([^>]+)>)/g, '')
1050
+ // Replacing all kind of line breaks
1051
+ .replace(/(\r\n|\n|\r)/gm, ' ')
1052
+ // Replacing all multi spaces with single space
1053
+ .replace(/\s+/gm, ' ')
1054
+ // Taking only first 100 characters
1055
+ .substring(0, 100);
1016
1056
  }
1017
1057
 
1018
- if(typeof baseName === 'string' && baseName) {
1058
+ if (typeof baseName === 'string' && baseName) {
1019
1059
  searchList.push({
1020
1060
  title: tutorialData.header,
1021
1061
  link: `<a href="${baseName}">${baseName}</a>`,
1022
1062
  description,
1023
- })
1063
+ });
1024
1064
  }
1025
-
1026
-
1027
- } catch(error) {
1028
- console.error('There was some error while creating search array for tutorial.')
1029
- console.error(error)
1065
+ } catch (error) {
1066
+ console.error(
1067
+ 'There was some error while creating search array for tutorial.'
1068
+ );
1069
+ console.error(error);
1030
1070
  }
1031
1071
  }
1032
1072
 
@@ -1047,7 +1087,7 @@ exports.publish = function (taffyData, opts, tutorials) {
1047
1087
  // added by clean-jsdoc-theme-devs
1048
1088
  // output search file if search
1049
1089
  if (hasSearch) {
1050
- buildSearchListForData()
1090
+ buildSearchListForData();
1051
1091
  mkdirSync(path.join(outdir, 'data'));
1052
1092
  fs.writeFileSync(
1053
1093
  path.join(outdir, 'data', 'search.json'),
@@ -16,7 +16,7 @@ function getTheme() {
16
16
  return body.getAttribute('data-theme');
17
17
  }
18
18
 
19
- function updateTheme(theme) {
19
+ function localUpdateTheme(theme) {
20
20
  var body = document.body;
21
21
  var svgUse = document.querySelectorAll('.theme-svg-use');
22
22
  var iconID = theme === 'dark' ? '#light-theme-icon' : '#dark-theme-icon';
@@ -28,7 +28,10 @@ function updateTheme(theme) {
28
28
  svgUse.forEach(function (svg) {
29
29
  svg.setAttribute('xlink:href', iconID);
30
30
  });
31
+ }
31
32
 
33
+ function updateTheme(theme) {
34
+ localUpdateTheme(theme);
32
35
  localStorage.setItem(themeLocalStorageKey, theme);
33
36
  }
34
37
 
@@ -145,7 +148,7 @@ function bringElementIntoView(element, updateHistory = true) {
145
148
  /**
146
149
  * tocbotInstance is defined in layout.tmpl
147
150
  * It is defined when we are initializing tocbot.
148
- *
151
+ *
149
152
  */
150
153
  // eslint-disable-next-line no-undef
151
154
  if (tocbotInstance) {
@@ -401,9 +404,9 @@ function getFontSize() {
401
404
  return currentFontSize;
402
405
  }
403
406
 
404
- function updateFontSize(fontSize) {
407
+ function localUpdateFontSize(fontSize) {
405
408
  html.style.fontSize = fontSize + 'px';
406
- localStorage.setItem(fontSizeLocalStorageKey, fontSize);
409
+
407
410
  var fontSizeText = document.querySelector(
408
411
  '#b77a68a492f343baabea06fad81f651e'
409
412
  );
@@ -413,6 +416,11 @@ function updateFontSize(fontSize) {
413
416
  }
414
417
  }
415
418
 
419
+ function updateFontSize(fontSize) {
420
+ localUpdateFontSize(fontSize);
421
+ localStorage.setItem(fontSizeLocalStorageKey, fontSize);
422
+ }
423
+
416
424
  (function () {
417
425
  var fontSize = getFontSize();
418
426
  var fontSizeInLocalStorage = localStorage.getItem(fontSizeLocalStorageKey);
@@ -653,3 +661,15 @@ window.addEventListener('hashchange', (event) => {
653
661
  bringIdToViewOnMount(url.hash);
654
662
  }
655
663
  });
664
+
665
+ // eslint-disable-next-line no-undef
666
+ window.addEventListener('storage', event => {
667
+ if (event.newValue === 'undefined') return;
668
+
669
+ initTooltip();
670
+
671
+ if (event.key === themeLocalStorageKey)
672
+ localUpdateTheme(event.newValue);
673
+ if (event.key === fontSizeLocalStorageKey)
674
+ localUpdateFontSize(event.newValue);
675
+ });
@@ -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(){return document.body.getAttribute("data-theme")}function updateTheme(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)}),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){console.log(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 updateFontSize(e){html.style.fontSize=e+"px",localStorage.setItem(fontSizeLocalStorageKey,e);var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=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()}!function(){var e=getTheme(),t=localStorage.getItem(themeLocalStorageKey);t?e!==t&&updateTheme(t):localStorage.setItem(themeLocalStorageKey,e)}(),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)});
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(){return document.body.getAttribute("data-theme")}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){console.log(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()}!function(){var e=getTheme(),t=localStorage.getItem(themeLocalStorageKey);t?e!==t&&updateTheme(t):localStorage.setItem(themeLocalStorageKey,e)}(),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))});