From 092042a42d522c1daeab34517d1fce50acc571d7 Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Wed, 27 Mar 2024 14:37:57 +0100 Subject: [PATCH] Add: npm zero-md package --- node_modules/.package-lock.json | 16 + node_modules/zero-md/LICENSE | 15 + node_modules/zero-md/README.md | 445 ++++++++++++++++++ .../zero-md/dist/zero-md.legacy.min.js | 2 + .../zero-md/dist/zero-md.legacy.min.js.map | 1 + node_modules/zero-md/dist/zero-md.min.js | 2 + node_modules/zero-md/dist/zero-md.min.js.map | 1 + node_modules/zero-md/package.json | 53 +++ node_modules/zero-md/src/index.js | 353 ++++++++++++++ 9 files changed, 888 insertions(+) create mode 100644 node_modules/.package-lock.json create mode 100644 node_modules/zero-md/LICENSE create mode 100644 node_modules/zero-md/README.md create mode 100644 node_modules/zero-md/dist/zero-md.legacy.min.js create mode 100644 node_modules/zero-md/dist/zero-md.legacy.min.js.map create mode 100644 node_modules/zero-md/dist/zero-md.min.js create mode 100644 node_modules/zero-md/dist/zero-md.min.js.map create mode 100644 node_modules/zero-md/package.json create mode 100644 node_modules/zero-md/src/index.js diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 0000000..7e7b7f5 --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,16 @@ +{ + "name": "nginx-file-browser", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/zero-md": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/zero-md/-/zero-md-2.5.4.tgz", + "integrity": "sha512-FbfH1k2kX3W0l/Wck4PuVJXmdS68JpbW3Iq5JthJctyga4PdVRmgPYt2AuBzmtekihFre+PhX+Hav2H1N41aWA==", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + } + } +} diff --git a/node_modules/zero-md/LICENSE b/node_modules/zero-md/LICENSE new file mode 100644 index 0000000..def6be7 --- /dev/null +++ b/node_modules/zero-md/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2024, Jason Lee + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/zero-md/README.md b/node_modules/zero-md/README.md new file mode 100644 index 0000000..4083062 --- /dev/null +++ b/node_modules/zero-md/README.md @@ -0,0 +1,445 @@ +![GitHub package.json version](https://img.shields.io/github/package-json/v/zerodevx/zero-md) +![jsDelivr hits (GitHub)](https://img.shields.io/jsdelivr/gh/hm/zerodevx/zero-md) + +# <zero-md> + +> Ridiculously simple zero-config markdown displayer + +A native markdown-to-html web component based on +[Custom Elements V1 specs](https://www.w3.org/TR/custom-elements/) to load and display an external +MD file. Under the hood, it uses [Marked](https://github.com/markedjs/marked) for super-fast +markdown transformation, and [Prism](https://github.com/PrismJS/prism) for feature-packed syntax +highlighting - automagically rendering into its own self-contained shadow DOM container, while +encapsulating implementation details into one embarassingly easy-to-use package. + +**NOTE: This is the V2 branch. If you're looking for the older version, see the +[V1 branch](https://github.com/zerodevx/zero-md/tree/v1).** + +Featuring: + +- [x] Automated hash-link scrolls +- [x] Built-in FOUC prevention +- [x] Automatically rewrite URLs relative to `src` +- [x] Automatically re-render when `src` changes +- [x] Automatically re-render when inline markdown or style template changes +- [x] Support for >200 code languages with detection for unhinted code blocks +- [x] Easy styling mechanism +- [x] Highly extensible + +Documentation: https://zerodevx.github.io/zero-md/ + +**NOTE: Your markdown file(s) needs to be hosted! Browsers don't generally allow javascript to +access files on the local hard drive because of security concerns. Standard +[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) rules apply.** + +## Installation + +### Load via CDN (recommended) + +`zero-md` is designed to be zero-config with good defaults. For most use-cases, just importing the +script from CDN and consuming the component directly should suffice. + +```html + + ... + + + ... + + + ... + + + ... + +``` + +Latest stable: `https://cdn.jsdelivr.net/gh/zerodevx/zero-md@2/dist/zero-md.min.js` + +Latest beta: `https://cdn.jsdelivr.net/npm/zero-md@next/dist/zero-md.min.js` + +### Install in web projects + +Install package with `npm` or `yarn`. Note that you'll need [Node.js](https://nodejs.org/) +installed. + +``` +$ npm install --save zero-md +``` + +Import the class, register the element, and use anywhere. + +```js +// Import the element definition +import ZeroMd from 'zero-md' + +// Register the custom element +customElements.define('zero-md', ZeroMd) + +// Render anywhere +app.render(``, target) +``` + +Or load the distribution directly in HTML. + +```html + +... + +``` + +## Basic Usage + +### Display an external markdown file + +```html + + +``` + +At its most basic, `` loads and displays an external MD file with **default stylesheets** - +a Github-themed stylesheet paired with a light-themed one for code blocks, just like what you see in +these docs. So internally, the above code block is semantically equivalent to the one below: + +```html + + + + +``` + +### Using your own styles + +To override the default theme, supply your own style template. + +```html + + + + +``` + +### Or your own stylesheets + +```html + + + + +``` + +### Or both + +```html + + + +``` + +### Write markdown inline + +You can pass in your markdown inline too. + +```html + + + + + +``` + +By default, `` first tries to render `src`. If `src` is falsy (undefined, file not found, +empty file etc), it **falls-back** to the contents inside the ` + +``` + +## API + +Advanced usage: https://zerodevx.github.io/zero-md/advanced-usage/ + +Attributes and helpers: https://zerodevx.github.io/zero-md/attributes-and-helpers/ + +Configuration: https://zerodevx.github.io/zero-md/configuration/ + +## Migrating from V1 to V2 + +1. Support for `` tag is removed; use `<script type="text/markdown">` instead. + +<!-- prettier-ignore --> +```html +<!-- Previous --> +<zero-md> + <template> + <xmp> +# `This` is my [markdown](example.md) + + + + + + + + + + + + + + + +``` + +2. Markdown source behaviour has changed. Think of ` + +``` + +3. The `css-urls` attribute is deprecated. Use `` instead. + + +```html + + + + + + + + + + + + + + + + + + + + + + + +``` + +4. The attributes `marked-url` and `prism-url` are deprecated. To load `marked` or `prism` from + another location, simply load their scripts _before_ importing `zero-md`. + +```html + + ... + + + + +``` + +5. The global config object has been renamed from `ZeroMd.config` to `ZeroMdConfig`. + +```html + + + + + + + + +``` + +6. The convenience events `zero-md-marked-ready` and `zero-md-prism-ready` are removed and **will no + longer fire**. Instead, the `zero-md-ready` event guarantees that everything is ready, and that + render can begin. + +## Contributing + +### Noticed a bug? Have a feature request? + +Open a new [issue](https://github.com/zerodevx/zero-md/issues) in the Github repo, or raise a +[PR](https://github.com/zerodevx/zero-md/pulls)! I'd be stoked to accept any contributions! + +### Development + +Standard Github [contribution workflow](https://github.com/firstcontributions/first-contributions) +applies. + +#### Run the dev server + +``` +$ npm run dev +``` + +Point your browser to `http://localhost:8000` and you should see the test suite running. + +#### Testing + +Tests are browser-based and run on [Mocha](https://mochajs.org/) with +[Chai](https://www.chaijs.com/) asserts. If you're adding a new feature or bugfixing, please add the +corresponding regression test into `test/index.spec.js` accordingly. + +#### Format and lint + +``` +$ npm run format +$ npm run lint +``` + +Formatting and linting by [prettier](https://github.com/prettier/prettier) and +[eslint](https://github.com/eslint/eslint) respectively. + +#### Making changes to docs + +Documentation is in the `/docs` folder in the form of `readme.md` files, and published on +[Github Pages](https://pages.github.com/). This setup is based on +[`zero-md-docs`](https://github.com/zerodevx/zero-md-docs). + +To make changes to docs, simply raise a PR on any `readme.md` files should suffice. + +## Changelog + +Check out the [releases](https://github.com/zerodevx/zero-md/releases) page. + +## License + +ISC + +## Acknowledgement + +A big thank you to the following contributors and sponsors! :pray: + +### Contributors + + +[](https://github.com/alifeee) [](https://github.com/EmilePerron) [](https://github.com/bennypowers) [](https://github.com/TheUnlocked) [](https://github.com/ernsheong) + +### Sponsors + + +[](https://github.com/RootofalleviI)[](https://github.com/alifeee) diff --git a/node_modules/zero-md/dist/zero-md.legacy.min.js b/node_modules/zero-md/dist/zero-md.legacy.min.js new file mode 100644 index 0000000..5113707 --- /dev/null +++ b/node_modules/zero-md/dist/zero-md.legacy.min.js @@ -0,0 +1,2 @@ +var ZeroMd=function(t){"use strict";function e(t,e,n){return e=f(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return p(t)}(t,r()?Reflect.construct(e,n||[],f(t).constructor):e.apply(t,n))}function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(r=function(){return!!t})()}function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function o(t){for(var e=1;e=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function a(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function c(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,u,"next",t)}function u(t){c(i,n,o,a,u,"throw",t)}a(void 0)}))}}function s(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r
'))),i.constructor.ready||(i.constructor.ready=Promise.all([!!window.marked||i.loadScript(i.config.markedUrl),!!window.Prism||i.loadScript(i.config.prismUrl)])),i.clicked=i.clicked.bind(p(i)),i.manualRender||i.render().then((function(){return setTimeout((function(){return i.goto(location.hash)}),250)})),i.observer=new MutationObserver((function(){i.observeChanges(),i.manualRender||i.render()})),i.observer.observe(p(i),{childList:!0}),i.observeChanges(),i}var n,a,c,l,f,d,m;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}(r,t),n=r,a=[{key:"src",get:function(){return this.getAttribute("src")},set:function(t){this.reflect("src",t)}},{key:"manualRender",get:function(){return this.hasAttribute("manual-render")},set:function(t){this.reflect("manual-render",t)}},{key:"reflect",value:function(t,e){!1===e?this.removeAttribute(t):this.setAttribute(t,!0===e?"":e)}},{key:"attributeChangedCallback",value:function(t,e,r){"src"===t&&this.connected&&!this.manualRender&&r!==e&&this.render()}},{key:"observeChanges",value:function(){var t=this;this.querySelectorAll('template,script[type="text/markdown"]').forEach((function(e){t.observer.observe(e.content||e,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}))}},{key:"connectedCallback",value:function(){var t=this;this.connected=!0,this.fire("zero-md-connected",{},{bubbles:!1,composed:!1}),this.waitForReady().then((function(){t.fire("zero-md-ready")})),this.shadowRoot&&this.shadowRoot.addEventListener("click",this.clicked)}},{key:"disconnectedCallback",value:function(){this.connected=!1,this.shadowRoot&&this.shadowRoot.removeEventListener("click",this.clicked)}},{key:"waitForReady",value:function(){var t=this,e=this.connected||new Promise((function(e){t.addEventListener("zero-md-connected",(function t(){this.removeEventListener("zero-md-connected",t),e()}))}));return Promise.all([this.constructor.ready,e])}},{key:"fire",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{bubbles:!0,composed:!0};e.msg&&console.warn(e.msg),this.dispatchEvent(new CustomEvent(t,o({detail:o({node:this},e)},r)))}},{key:"tick",value:function(){return new Promise((function(t){return requestAnimationFrame(t)}))}},{key:"arrify",value:function(t){return t?Array.isArray(t)?t:[t]:[]}},{key:"onload",value:function(t){return new Promise((function(e,r){t.onload=e,t.onerror=function(t){return r(t.path?t.path[0]:t.composedPath()[0])}}))}},{key:"loadScript",value:function(t){var e=this;return Promise.all(this.arrify(t).map((function(t){var r=y(e.arrify(t)),n=r[0],o=r.slice(1),i=document.createElement("script");return i.src=n,i.async=!1,o.forEach((function(t){return i.setAttribute(t,"")})),e.onload(document.head.appendChild(i))})))}},{key:"goto",value:function(t){var e;try{e=this.root.querySelector(t)}catch(t){}e&&e.scrollIntoView()}},{key:"clicked",value:function(t){if(!(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||t.defaultPrevented)){var e=t.target.closest("a");e&&e.hash&&e.host===location.host&&e.pathname===location.pathname&&this.goto(e.hash)}}},{key:"dedent",value:function(t){var e=(t=t.replace(/^\n/,"")).match(/^\s+/);return e?t.replace(new RegExp("^".concat(e[0]),"gm"),""):t}},{key:"getBaseUrl",value:function(t){var e=document.createElement("a");return e.href=t,e.href.substring(0,e.href.lastIndexOf("/")+1)}},{key:"highlight",value:function(t){return new Promise((function(e){t.querySelectorAll('pre>code:not([class*="language-"])').forEach((function(t){var e=t.innerText.match(/^\s*".concat(this.config.hostCss,"").concat(e('template[data-merge="prepend"]')).concat(e("template:not([data-merge])")||r.reduce((function(t,e){return"".concat(t,'')}),"")).concat(e('template[data-merge="append"]'))}},{key:"buildMd",value:(m=u(i().mark((function t(){var e,r,n,a=this,c=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=c.length>0&&void 0!==c[0]?c[0]:{},r=function(){var t=u(i().mark((function t(){var r,n;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a.src){t.next=2;break}return t.abrupt("return","");case 2:return t.next=4,fetch(a.src);case 4:if(!(r=t.sent).ok){t.next=12;break}return t.next=8,r.text();case 8:return n=t.sent,t.abrupt("return",window.marked.parse(n,o({baseUrl:a.getBaseUrl(a.src)},e)));case 12:return a.fire("zero-md-error",{msg:"[zero-md] HTTP error ".concat(r.status," while fetching src"),status:r.status,src:a.src}),t.abrupt("return","");case 14:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),n=function(){var t=a.querySelector('script[type="text/markdown"]');if(!t)return"";var r=t.hasAttribute("data-dedent")?a.dedent(t.text):t.text;return window.marked.parse(r,e)},t.next=5,r();case 5:if(t.t0=t.sent,t.t0){t.next=8;break}t.t0=n();case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),t)}))),function(){return m.apply(this,arguments)})},{key:"getHash",value:function(t){for(var e=5381,r=0;r>>0).toString(36)}},{key:"stampStyles",value:(d=u(i().mark((function t(e){var r,n,o,a,c=this;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.getHash(e),(n=this.root.querySelector(".markdown-styles")).getAttribute("data-hash")===r){t.next=11;break}return n.setAttribute("data-hash",r),o=this.makeNodes(e),a=v(o).filter((function(t){return"LINK"===t.tagName&&"stylesheet"===t.getAttribute("rel")})),n.innerHTML="",n.append.apply(n,v(o)),t.next=10,Promise.all(a.map((function(t){return c.onload(t)}))).catch((function(t){c.fire("zero-md-error",{msg:"[zero-md] An external stylesheet failed to load",status:void 0,src:t.href})}));case 10:return t.abrupt("return",!0);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return d.apply(this,arguments)})},{key:"stampBody",value:(f=u(i().mark((function t(e,r){var n,o,a,c;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.arrify(r),o=this.getHash(e+JSON.stringify(n)),(a=this.root.querySelector(".markdown-body")).getAttribute("data-hash")===o){t.next=13;break}return a.setAttribute("data-hash",o),n.unshift("markdown-body"),a.setAttribute("class",n.join(" ")),c=this.makeNodes(e),a.innerHTML="",a.append.apply(a,v(c)),t.next=12,this.highlight(a);case 12:return t.abrupt("return",!0);case 13:case"end":return t.stop()}}),t,this)}))),function(t,e){return f.apply(this,arguments)})},{key:"render",value:(l=u(i().mark((function t(){var e,r,n,o,a=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=a.length>0&&void 0!==a[0]?a[0]:{},t.next=3,this.waitForReady();case 3:return r=this.buildMd(e),t.next=6,this.stampStyles(this.buildStyles());case 6:return n=t.sent,t.next=9,this.tick();case 9:return t.t0=this,t.next=12,r;case 12:return t.t1=t.sent,t.t2=e.classes,t.next=16,t.t0.stampBody.call(t.t0,t.t1,t.t2);case 16:o=t.sent,this.fire("zero-md-rendered",{node:this,stamped:{styles:n,body:o}});case 18:case"end":return t.stop()}}),t,this)}))),function(){return l.apply(this,arguments)})}],c=[{key:"observedAttributes",get:function(){return["src"]}}],a&&s(n.prototype,a),c&&s(n,c),Object.defineProperty(n,"prototype",{writable:!1}),r}(d(HTMLElement));return customElements.define("zero-md",w),t.ZeroMd=w,t}({}); +//# sourceMappingURL=zero-md.legacy.min.js.map diff --git a/node_modules/zero-md/dist/zero-md.legacy.min.js.map b/node_modules/zero-md/dist/zero-md.legacy.min.js.map new file mode 100644 index 0000000..f7ad4f0 --- /dev/null +++ b/node_modules/zero-md/dist/zero-md.legacy.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"zero-md.legacy.min.js","sources":["../src/index.js"],"sourcesContent":["export class ZeroMd extends HTMLElement {\n get src() {\n return this.getAttribute('src')\n }\n\n set src(val) {\n this.reflect('src', val)\n }\n\n get manualRender() {\n return this.hasAttribute('manual-render')\n }\n\n set manualRender(val) {\n this.reflect('manual-render', val)\n }\n\n reflect(name, val) {\n if (val === false) {\n this.removeAttribute(name)\n } else {\n this.setAttribute(name, val === true ? '' : val)\n }\n }\n\n static get observedAttributes() {\n return ['src']\n }\n\n attributeChangedCallback(name, old, val) {\n if (name === 'src' && this.connected && !this.manualRender && val !== old) {\n this.render()\n }\n }\n\n constructor(defaults) {\n super()\n this.version = '$VERSION'\n this.config = {\n markedUrl: 'https://cdn.jsdelivr.net/gh/markedjs/marked@4/marked.min.js',\n prismUrl: [\n ['https://cdn.jsdelivr.net/gh/PrismJS/prism@1/prism.min.js', 'data-manual'],\n 'https://cdn.jsdelivr.net/gh/PrismJS/prism@1/plugins/autoloader/prism-autoloader.min.js'\n ],\n cssUrls: [\n 'https://cdn.jsdelivr.net/gh/sindresorhus/github-markdown-css@4/github-markdown.min.css',\n 'https://cdn.jsdelivr.net/gh/PrismJS/prism@1/themes/prism.min.css'\n ],\n hostCss:\n ':host{display:block;position:relative;contain:content;}:host([hidden]){display:none;}',\n ...defaults,\n ...window.ZeroMdConfig\n }\n this.root = this.hasAttribute('no-shadow') ? this : this.attachShadow({ mode: 'open' })\n this.root.prepend(\n ...this.makeNodes(`
`)\n )\n if (!this.constructor.ready) {\n this.constructor.ready = Promise.all([\n !!window.marked || this.loadScript(this.config.markedUrl),\n !!window.Prism || this.loadScript(this.config.prismUrl)\n ])\n }\n this.clicked = this.clicked.bind(this)\n if (!this.manualRender) {\n // Scroll to hash id after first render. However, `history.scrollRestoration` inteferes with this\n // on refresh. It's much better to use a `setTimeout` rather than to alter the browser's behaviour.\n this.render().then(() => setTimeout(() => this.goto(location.hash), 250))\n }\n this.observer = new MutationObserver(() => {\n this.observeChanges()\n if (!this.manualRender) this.render()\n })\n this.observer.observe(this, { childList: true })\n this.observeChanges()\n }\n\n /**\n * Start observing changes, if not already so, in `template` and `script`.\n */\n observeChanges() {\n this.querySelectorAll('template,script[type=\"text/markdown\"]').forEach((n) => {\n this.observer.observe(n.content || n, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true\n })\n })\n }\n\n connectedCallback() {\n this.connected = true\n this.fire('zero-md-connected', {}, { bubbles: false, composed: false })\n this.waitForReady().then(() => {\n this.fire('zero-md-ready')\n })\n if (this.shadowRoot) {\n this.shadowRoot.addEventListener('click', this.clicked)\n }\n }\n\n disconnectedCallback() {\n this.connected = false\n if (this.shadowRoot) {\n this.shadowRoot.removeEventListener('click', this.clicked)\n }\n }\n\n waitForReady() {\n const ready =\n this.connected ||\n new Promise((resolve) => {\n this.addEventListener('zero-md-connected', function handler() {\n this.removeEventListener('zero-md-connected', handler)\n resolve()\n })\n })\n return Promise.all([this.constructor.ready, ready])\n }\n\n fire(name, detail = {}, opts = { bubbles: true, composed: true }) {\n if (detail.msg) {\n console.warn(detail.msg)\n }\n this.dispatchEvent(\n new CustomEvent(name, {\n detail: { node: this, ...detail },\n ...opts\n })\n )\n }\n\n tick() {\n return new Promise((resolve) => requestAnimationFrame(resolve))\n }\n\n // Coerce anything into an array\n arrify(any) {\n return any ? (Array.isArray(any) ? any : [any]) : []\n }\n\n // Promisify an element's onload callback\n onload(node) {\n return new Promise((resolve, reject) => {\n node.onload = resolve\n node.onerror = (err) => reject(err.path ? err.path[0] : err.composedPath()[0])\n })\n }\n\n // Load a url or load (in order) an array of urls via