diff --git a/node_modules/gist-simple/dist/gist-simple.js b/node_modules/gist-simple/dist/gist-simple.js index 4ce9dc0..c019e08 100644 --- a/node_modules/gist-simple/dist/gist-simple.js +++ b/node_modules/gist-simple/dist/gist-simple.js @@ -142,8 +142,10 @@ */ const LOADED_FLAG = '__gist_simple_css_loaded__'; function loadCSS(url, callback, doc = document) { + const searchRoot = doc.body || doc.head || doc.documentElement; + // Already exists. - let el = doc.body.querySelector(`link[href="${url}"]`); + let el = searchRoot.querySelector(`link[href="${url}"]`); if (!el) { el = doc.createElement('link'); el.href = url; diff --git a/node_modules/gist-simple/dist/gist-simple.min.js b/node_modules/gist-simple/dist/gist-simple.min.js index 57149bf..7ae9556 100644 --- a/node_modules/gist-simple/dist/gist-simple.min.js +++ b/node_modules/gist-simple/dist/gist-simple.min.js @@ -3,4 +3,4 @@ * Copyright 2024 nK * Licensed under MIT (https://github.com/nk-o/gist-simple/blob/master/LICENSE) */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).gistSimple=t()}(this,(function(){"use strict";let e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=e;function n(e,...t){return e=e||{},Object.keys(t).forEach((n=>{t[n]&&Object.keys(t[n]).forEach((i=>{e[i]=t[n][i]}))})),e}function i(){this.doneCallbacks=[],this.failCallbacks=[]}i.prototype={execute(e,t){let n=e.length;for(t=Array.prototype.slice.call(t);n;)n-=1,e[n].apply(null,t)},resolve(...e){this.execute(this.doneCallbacks,e)},reject(...e){this.execute(this.failCallbacks,e)},done(e){this.doneCallbacks.push(e)},fail(e){this.failCallbacks.push(e)}};const o="__gist_simple_jsonp__";const s="__gist_simple_css_loaded__";var l={id:"",theme:"system",file:"",caption:"",lines:"",linesExpanded:!1,highlightLines:"",showFooter:!0,showLineNumbers:!0,enableCache:!0,onInit:null,onInitEnd:null,onDestroy:null,onDestroyEnd:null,onAjaxBeforeSend:null,onAjaxSuccess:null,onAjaxLoaded:null};const r={};let c=0;class a{constructor(e,t){const i=this;i.instanceID=c,c+=1,i.$container=e,i.defaults={...l};const o=i.$container.dataset||{},s={};Object.keys(o).forEach((e=>{e&&void 0!==i.defaults[e]&&(s[e]=o[e])})),i.options=n({},i.defaults,s,t),i.pureOptions=n({},i.options),Object.keys(i.options).forEach((e=>{"true"===i.options[e]?i.options[e]=!0:"false"===i.options[e]&&(i.options[e]=!1)})),i.init()}init(){const e=this,{options:t}=e,n=`https://gist.github.com/${t.id}.json`,{lines:l}=t,c={};if(e.options.onInit&&e.options.onInit.call(e),t.file&&(c.file=t.file),e.$container.classList.add("gist-simple"),"dark"!==t.theme&&"system"!==t.theme||e.$container.classList.add(`gist-simple-${t.theme}`),!t.id)return void e.insertContent("Gist ID is required",!0);const a=n+t.file,d=t.enableCache||r[a];function p(n){const i=document.createElement("div");i.innerHTML=n.div,i.firstChild&&i.firstChild.removeAttribute("id"),e.insertContent(i.innerHTML),e.highlightLines(t.highlightLines),e.showSpecificLines(l,t.linesExpanded),e.showCaption(t.caption),t.showFooter||e.removeFooter(),t.showLineNumbers||e.removeLineNumbers(),e.options.onAjaxLoaded&&e.options.onAjaxLoaded.call(e,n)}function u(t){if(t&&t.div){let{stylesheet:n}=t;n?(0===n.indexOf("{i[s]=!0,t(i)}),!1)}}(n,(()=>{p(t)}),e.$container.ownerDocument)):p(t)}else e.insertContent(`Failed loading gist ${n}`,!0)}function h(t){e.insertContent(`Failed loading gist ${n}: ${t}`,!0)}e.insertContent('',!0),function(e,t){const{data:n={},beforeSend:i,success:s}=t;if(window[o]=(window[o]||0)+1,n.callback=`${o}_cb_${window[o]}`,Object.keys(n).forEach((t=>{e.match(/\?/)?e+=`&${t}=${n[t]}`:e+=`?${t}=${n[t]}`})),i&&!i())return;let l=document.createElement("script");l.type="text/javascript",l.src=e,window[n.callback]=function(e){s.call(window,e),document.head.removeChild(l),l=null,delete window[n.callback]},document.head.appendChild(l)}(n,{data:c,beforeSend(){if(e.options.onAjaxBeforeSend&&e.options.onAjaxBeforeSend.call(e),d){if(r[a])return r[a].div?(u(r[a]),!1):(r[a].done((e=>{u(e)})),r[a].fail((e=>{h(e)})),!1);r[a]=new i}return!0},success(t){e.options.onAjaxSuccess&&e.options.onAjaxSuccess.call(e,t),d&&r[a]&&r[a].resolve&&(r[a].resolve(t),r[a]=t),u(t)},error(e){h(e)}}),e.options.onInitEnd&&e.options.onInitEnd.call(e)}destroy(){const e=this;e.options.onDestroy&&e.options.onDestroy.call(e),e.$container.innerHTML="",delete e.$container.GistSimple,e.options.onDestroyEnd&&e.options.onDestroyEnd.call(e)}chunkBy(e,t){return 0===e.length?[]:e.slice(1).reduce(((e,n)=>(t(n)?e.push([n]):e.push(e.pop().concat([n])),e)),[e.slice(0,1)])}getLineNumbers(e){const t=[];let n,i;if("number"==typeof e)t.push(e);else{i=e.split(",");for(let e=0;e${e}`),this.$container.innerHTML=e}highlightLines(e){if(!e)return;const t=this.getLineNumbers(e);this.$container.querySelectorAll("td.line-data").forEach((e=>{e.style.width="100%"})),this.$container.querySelectorAll(".js-file-line").forEach(((e,n)=>{-1!==t.indexOf(n+1)&&e.classList.add("gist-simple-highlighted-line")}))}showSpecificLines(e,t){if(!e)return;const n=this.getLineNumbers(e),i=[];if(this.$container.querySelectorAll(".js-file-line").forEach(((e,o)=>{-1===n.indexOf(o+1)&&(t?(i.push(o+1),e.parentNode.style.display="none"):e.parentNode.remove())})),t){this.chunkBy(i,(e=>!i.includes(e-1))).forEach((e=>{const t=e[0],n=t-1,i=e[e.length-1],o=document.createElement("a");o.setAttribute("lines",e.join()),o.style.display="block",o.style.cursor="pointer",o.innerHTML='\n \n',o.addEventListener("click",(e=>{e.preventDefault(),o.closest("table.highlight").querySelectorAll('tr[style*="display: none"] td[data-line-number]').forEach((function(e){const t=o.getAttribute("lines").split(","),n=e.getAttribute("data-line-number");-1!==t.indexOf(n)&&(e.parentNode.style.display="")})),o.closest("tr").remove()}));const s=`\n ... Lines ${t} - ${i}\n `,l=document.createElement("tr");l.innerHTML='\n \x3c!-- Icon Here --\x3e\n '+s,l.querySelector("td:first-child").append(o);const r=this.$container.querySelector(`.js-line-number[data-line-number="${0===n?1:n}"]`);r&&(0===n?r.parentElement.before(l):r.parentElement.after(l))}))}}showCaption(e){if(!e)return;const t=this.$container.querySelector("table tbody"),n=document.createElement("tr"),i=document.createElement("td");n.classList.add("gist-simple-caption"),i.innerHTML=e;const o=document.createElement("td");n.append(o),n.append(i),t.prepend(n)}removeFooter(){this.$container.querySelector(".gist-meta").remove(),this.$container.querySelector(".gist-data").style.borderBottom="0px",this.$container.querySelector(".gist-file").style.borderBottom="1px solid #ddd"}removeLineNumbers(){this.$container.querySelectorAll(".js-line-number").forEach((e=>{e.remove()})),this.$container.querySelector("table.highlight").style.width="100%"}}const d=function(e,t,...n){("object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName)&&(e=[e]);const i=e.length;let o,s=0;for(;s{d(document.querySelectorAll(".gist-simple[data-id]"))},"complete"===document.readyState||"interactive"===document.readyState?u():document.addEventListener("DOMContentLoaded",u,{capture:!0,once:!0,passive:!0}),d}));//# sourceMappingURL=gist-simple.min.js.map +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).gistSimple=t()}(this,(function(){"use strict";let e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=e;function n(e,...t){return e=e||{},Object.keys(t).forEach((n=>{t[n]&&Object.keys(t[n]).forEach((i=>{e[i]=t[n][i]}))})),e}function i(){this.doneCallbacks=[],this.failCallbacks=[]}i.prototype={execute(e,t){let n=e.length;for(t=Array.prototype.slice.call(t);n;)n-=1,e[n].apply(null,t)},resolve(...e){this.execute(this.doneCallbacks,e)},reject(...e){this.execute(this.failCallbacks,e)},done(e){this.doneCallbacks.push(e)},fail(e){this.failCallbacks.push(e)}};const o="__gist_simple_jsonp__";const s="__gist_simple_css_loaded__";var l={id:"",theme:"system",file:"",caption:"",lines:"",linesExpanded:!1,highlightLines:"",showFooter:!0,showLineNumbers:!0,enableCache:!0,onInit:null,onInitEnd:null,onDestroy:null,onDestroyEnd:null,onAjaxBeforeSend:null,onAjaxSuccess:null,onAjaxLoaded:null};const r={};let c=0;class a{constructor(e,t){const i=this;i.instanceID=c,c+=1,i.$container=e,i.defaults={...l};const o=i.$container.dataset||{},s={};Object.keys(o).forEach((e=>{e&&void 0!==i.defaults[e]&&(s[e]=o[e])})),i.options=n({},i.defaults,s,t),i.pureOptions=n({},i.options),Object.keys(i.options).forEach((e=>{"true"===i.options[e]?i.options[e]=!0:"false"===i.options[e]&&(i.options[e]=!1)})),i.init()}init(){const e=this,{options:t}=e,n=`https://gist.github.com/${t.id}.json`,{lines:l}=t,c={};if(e.options.onInit&&e.options.onInit.call(e),t.file&&(c.file=t.file),e.$container.classList.add("gist-simple"),"dark"!==t.theme&&"system"!==t.theme||e.$container.classList.add(`gist-simple-${t.theme}`),!t.id)return void e.insertContent("Gist ID is required",!0);const a=n+t.file,d=t.enableCache||r[a];function p(n){const i=document.createElement("div");i.innerHTML=n.div,i.firstChild&&i.firstChild.removeAttribute("id"),e.insertContent(i.innerHTML),e.highlightLines(t.highlightLines),e.showSpecificLines(l,t.linesExpanded),e.showCaption(t.caption),t.showFooter||e.removeFooter(),t.showLineNumbers||e.removeLineNumbers(),e.options.onAjaxLoaded&&e.options.onAjaxLoaded.call(e,n)}function u(t){if(t&&t.div){let{stylesheet:n}=t;n?(0===n.indexOf("{i[s]=!0,t(i)}),!1)}}(n,(()=>{p(t)}),e.$container.ownerDocument)):p(t)}else e.insertContent(`Failed loading gist ${n}`,!0)}function h(t){e.insertContent(`Failed loading gist ${n}: ${t}`,!0)}e.insertContent('',!0),function(e,t){const{data:n={},beforeSend:i,success:s}=t;if(window[o]=(window[o]||0)+1,n.callback=`${o}_cb_${window[o]}`,Object.keys(n).forEach((t=>{e.match(/\?/)?e+=`&${t}=${n[t]}`:e+=`?${t}=${n[t]}`})),i&&!i())return;let l=document.createElement("script");l.type="text/javascript",l.src=e,window[n.callback]=function(e){s.call(window,e),document.head.removeChild(l),l=null,delete window[n.callback]},document.head.appendChild(l)}(n,{data:c,beforeSend(){if(e.options.onAjaxBeforeSend&&e.options.onAjaxBeforeSend.call(e),d){if(r[a])return r[a].div?(u(r[a]),!1):(r[a].done((e=>{u(e)})),r[a].fail((e=>{h(e)})),!1);r[a]=new i}return!0},success(t){e.options.onAjaxSuccess&&e.options.onAjaxSuccess.call(e,t),d&&r[a]&&r[a].resolve&&(r[a].resolve(t),r[a]=t),u(t)},error(e){h(e)}}),e.options.onInitEnd&&e.options.onInitEnd.call(e)}destroy(){const e=this;e.options.onDestroy&&e.options.onDestroy.call(e),e.$container.innerHTML="",delete e.$container.GistSimple,e.options.onDestroyEnd&&e.options.onDestroyEnd.call(e)}chunkBy(e,t){return 0===e.length?[]:e.slice(1).reduce(((e,n)=>(t(n)?e.push([n]):e.push(e.pop().concat([n])),e)),[e.slice(0,1)])}getLineNumbers(e){const t=[];let n,i;if("number"==typeof e)t.push(e);else{i=e.split(",");for(let e=0;e${e}`),this.$container.innerHTML=e}highlightLines(e){if(!e)return;const t=this.getLineNumbers(e);this.$container.querySelectorAll("td.line-data").forEach((e=>{e.style.width="100%"})),this.$container.querySelectorAll(".js-file-line").forEach(((e,n)=>{-1!==t.indexOf(n+1)&&e.classList.add("gist-simple-highlighted-line")}))}showSpecificLines(e,t){if(!e)return;const n=this.getLineNumbers(e),i=[];if(this.$container.querySelectorAll(".js-file-line").forEach(((e,o)=>{-1===n.indexOf(o+1)&&(t?(i.push(o+1),e.parentNode.style.display="none"):e.parentNode.remove())})),t){this.chunkBy(i,(e=>!i.includes(e-1))).forEach((e=>{const t=e[0],n=t-1,i=e[e.length-1],o=document.createElement("a");o.setAttribute("lines",e.join()),o.style.display="block",o.style.cursor="pointer",o.innerHTML='\n \n',o.addEventListener("click",(e=>{e.preventDefault(),o.closest("table.highlight").querySelectorAll('tr[style*="display: none"] td[data-line-number]').forEach((function(e){const t=o.getAttribute("lines").split(","),n=e.getAttribute("data-line-number");-1!==t.indexOf(n)&&(e.parentNode.style.display="")})),o.closest("tr").remove()}));const s=`\n ... Lines ${t} - ${i}\n `,l=document.createElement("tr");l.innerHTML='\n \x3c!-- Icon Here --\x3e\n '+s,l.querySelector("td:first-child").append(o);const r=this.$container.querySelector(`.js-line-number[data-line-number="${0===n?1:n}"]`);r&&(0===n?r.parentElement.before(l):r.parentElement.after(l))}))}}showCaption(e){if(!e)return;const t=this.$container.querySelector("table tbody"),n=document.createElement("tr"),i=document.createElement("td");n.classList.add("gist-simple-caption"),i.innerHTML=e;const o=document.createElement("td");n.append(o),n.append(i),t.prepend(n)}removeFooter(){this.$container.querySelector(".gist-meta").remove(),this.$container.querySelector(".gist-data").style.borderBottom="0px",this.$container.querySelector(".gist-file").style.borderBottom="1px solid #ddd"}removeLineNumbers(){this.$container.querySelectorAll(".js-line-number").forEach((e=>{e.remove()})),this.$container.querySelector("table.highlight").style.width="100%"}}const d=function(e,t,...n){("object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName)&&(e=[e]);const i=e.length;let o,s=0;for(;s{d(document.querySelectorAll(".gist-simple[data-id]"))},"complete"===document.readyState||"interactive"===document.readyState?u():document.addEventListener("DOMContentLoaded",u,{capture:!0,once:!0,passive:!0}),d}));//# sourceMappingURL=gist-simple.min.js.map diff --git a/node_modules/gist-simple/src/utils/load-css.js b/node_modules/gist-simple/src/utils/load-css.js index 0c0cea6..ae2132d 100644 --- a/node_modules/gist-simple/src/utils/load-css.js +++ b/node_modules/gist-simple/src/utils/load-css.js @@ -4,8 +4,10 @@ const LOADED_FLAG = '__gist_simple_css_loaded__'; export default function loadCSS(url, callback, doc = document) { + const searchRoot = doc.body || doc.head || doc.documentElement; + // Already exists. - let el = doc.body.querySelector(`link[href="${url}"]`); + let el = searchRoot.querySelector(`link[href="${url}"]`); if (!el) { el = doc.createElement('link');