@liascript/editor 1.1.43--2.1.0 → 1.1.43--2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},e={},i={},n=t.parcelRequirea18f;null==n&&((n=function(t){if(t in e)return e[t].exports;if(t in i){var n=i[t];delete i[t];var r={id:t,exports:{}};return e[t]=r,n.call(r.exports,r,r.exports),r.exports}var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(t,e){i[t]=e},t.parcelRequirea18f=n),n.register("b6fDG",(function(t,e){var i=n("1fvgI"),r=n("aRjZm"),o=n("eU0x9");const s=/(?:https?:)(?:\/\/)liascript\.github\.io\/course\/\?(.+\.md)/i,a=/\/\/([a-z-]+)(?:\.m)?\.(wikipedia|wiktionary|wikibooks|wikinews|wikiquote|wikisource|wikiversity|wikivoyage|wikimedia|wikidata)\.org\/wiki\/([^#?\s]+)/i,c=new Map;let l,d=0,u=null;class h extends HTMLElement{light=!0;clicked=!1;connectedCallback(){this.addEventListener("mouseenter",this.activate),this.addEventListener("focusin",this.activate),this.addEventListener("mouseleave",this.deactivate),this.addEventListener("focusout",this.deactivate),this.addEventListener("click",this.handleClick)}activate(){if(this.clicked)return void(this.clicked=!1);const t=this.getAttribute("src")?.replace(/\/$/,"");t&&(clearTimeout(d),u=this,this.cursor("progress"),function(t){return c.has(t)||c.set(t,function(t){const e=t.match(s);if(e)return new Promise(((t,i)=>r.fetch(e[1],((e,i)=>t({title:i.title,description:i.description,image:i.logo,image_alt:i.logo_alt})),i)));const n=()=>i.extract(t,{}).then((t=>({title:t.title,image:t.thumbnail_url}))).catch((()=>i.fetchText(t,!0,3e4).then((e=>o.parse(t,e))))),c=t.match(a);return c?async function([,t,e,i]){try{i=decodeURIComponent(i)}catch(t){}const n=await fetch(`https://${t}.${e}.org/api/rest_v1/page/summary/${encodeURIComponent(i)}`,{headers:{Accept:"application/json"}});if(!n.ok)throw new Error(`wikimedia: ${n.status}`);const r=await n.json();return{title:r.title,description:r.extract,image:r.thumbnail?.source}}(c).catch(n):n()}(t).then((e=>function(t,e){if(!e.title&&!e.description&&!e.image)return null;const i=document.createElement("div");if(e.image)try{const n=p(i,"img");n.src=new URL(e.image,t).href,e.image_alt&&(n.alt=e.image_alt),n.style.cssText="background-color:white; margin-bottom:1.5rem"}catch(t){}e.title&&(p(i,"h4").textContent=e.title),e.description&&(p(i,"p").textContent=e.description),p(i,"hr").style.cssText="border:0; height:1px; background:#888";const n=p(i,"a");return n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.textContent=t,n.style.cssText="font-size:x-small; display:block",i}(t,e))).catch((()=>null))),c.get(t)}(t).then((t=>{this.cursor(""),t&&u===this&&function(t,e){const i=(l||(l=document.createElement("div"),l.id="lia-tooltip",l.setAttribute("role","tooltip"),l.style.cssText="position:fixed; z-index:20000; display:none; box-sizing:border-box; padding:15px; max-height:480px; overflow:auto",l.addEventListener("mouseenter",(()=>clearTimeout(d))),l.addEventListener("mouseleave",g),document.body.appendChild(l)),l),n=e.getBoundingClientRect(),r=n.left+n.width/2,o=n.top+n.height/2,s=Math.min(455,window.innerWidth-20);i.style.width=`${s}px`,i.style.left=r*(window.innerWidth-s)/window.innerWidth+"px",1.5*o>window.innerHeight?(i.style.top="",i.style.bottom=window.innerHeight-o+10+"px"):(i.style.top=`${o+10}px`,i.style.bottom=""),i.style.background=e.light?"white":"#202020",i.style.boxShadow=e.light?"0 30px 90px -20px rgba(0, 0, 0, 0.3)":"0 30px 90px -20px rgba(120, 120, 120, 0.3)",i.textContent="",i.appendChild(t),i.style.display="block"}(t,this)})))}deactivate(){u===this&&(u=null),this.cursor(""),g()}handleClick(){this.clicked=!0,this.deactivate(),m()}cursor(t){const e=this.firstElementChild;e&&(e.style.cursor=t)}}function p(t,e){return t.appendChild(document.createElement(e))}function m(){clearTimeout(d),l&&(l.style.display="none")}function g(){clearTimeout(d),d=window.setTimeout(m,300)}document.addEventListener("keyup",(t=>{"Escape"===t.key&&(u=null,m())})),customElements.define("preview-link",h)})),n.register("eU0x9",(function(t,e){var i,n;function r(t,e){const i=(new DOMParser).parseFromString(e,"text/html"),n=t=>i.querySelector(`meta[property="${t}"], meta[name="${t}"]`)?.getAttribute("content")?.trim()||void 0,r=t=>i.querySelector(t)?.textContent?.trim()||void 0,o=i.querySelector("img");let[s,a]=[[n("og:image"),n("og:image:alt")],[i.querySelector('link[rel="image_src"]')?.getAttribute("href")],[n("twitter:image"),n("twitter:image:alt")],[o?.getAttribute("src"),o?.getAttribute("alt")]].find((([t])=>t))||[];if(s)try{const e=i.querySelector("base")?.getAttribute("href");s=new URL(s,e?new URL(e,t):t).href}catch(t){s=void 0}return{title:n("og:title")||n("twitter:title")||i.title.trim()||r("h1")||r("h2"),description:n("og:description")||n("twitter:description")||n("description")||r("p"),image:s||void 0,image_alt:a||void 0}}i=t.exports,n=()=>r,Object.defineProperty(i,"parse",{get:n,set:undefined,enumerable:!0,configurable:!0})})),n("b6fDG");