drab 5.3.4 → 5.3.6
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/define.iife.js +1 -1
- package/index.iife.js +1 -1
- package/package.json +6 -6
- package/prefetch/define.iife.js +1 -1
- package/prefetch/index.iife.js +1 -1
- package/prefetch/index.js +21 -15
package/define.iife.js
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
${u}`});else if(u&&l.length===n){t.preventDefault();let m=this.#e,N=m-l.length;for(let D=0;D<l.length;D++)this.text=k(this.text,m-(D+1));setTimeout(async()=>{this.#r(N,N),this.textArea.focus(),await this.#o({type:"inline",value:`
|
7
7
|
`})},0)}}else{let s=Object.values(this.keyPairs).includes(i),r=this.#i!==this.#e;if((t.ctrlKey||t.metaKey)&&this.#i===this.#e&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:n,lineNumber:a,columnNumber:u}=this.#a();if(await navigator.clipboard.writeText(`${a===0&&t.key==="x"?"":`
|
8
8
|
`}${n[a]}`),t.key==="x"){let l=this.#i-u;n.splice(a,1),this.text=n.join(`
|
9
|
-
`),setTimeout(()=>{this.#r(l,l)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#s.find(a=>a.key===t.key);n&&this.#o(n)}else s&&(i===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#r(this.#i+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#o({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#i!==this.#e&&(this.text[this.#i]===" "&&this.#r(this.#i+1,this.#e),this.text[this.#e-1]===" "&&this.#r(this.#i,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#o(this.#l(t))})}},P=o=>{let t=o.match(/^(\d+)\./);return t?Number(t[1]):null},B=(o,t,e)=>o.slice(0,e)+t+o.slice(e),k=(o,t)=>o.slice(0,t)+o.slice(t+1);var v=class extends c{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let t of this.getTrigger())!this.fullscreenSupported()&&"disabled"in t&&(t.disabled=!0)}};var w=class extends c{#t=[];#s=[];constructor(){super()}get#n(){return Number(this.getAttribute("threshold")??0)}onIntersect(t){this.#t.push(t)}onExit(t){this.#s.push(t)}mount(){let t=new IntersectionObserver(e=>{let i="data-intersect";for(let s of e)if(s.isIntersecting){this.getContent().setAttribute(i,"");for(let r of this.#t)r()}else{this.getContent().removeAttribute(i);for(let r of this.#s)r()}},{threshold:this.#n});for(let e of this.getTrigger())t.observe(e)}};var E=class extends p{constructor(){super()}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}async show(){this.getContent().showPopover(),await this.animateElement()}async hide(){await this.animateElement({options:{direction:"reverse"}}),this.getContent().hidePopover()}async toggle(){this.open?this.hide():this.show()}mount(){this.triggerListener(t=>{t.preventDefault(),this.toggle()}),this.getContent().addEventListener("toggle",t=>{t.newState==="open"?this.open=!0:this.open=!1}),this.safeListener("keydown",t=>{t.key==="Escape"&&this.open&&(t.preventDefault(),this.hide())})}};var T=class extends c{#t=[];constructor(){super()}get#s(){return this.getAttribute("strategy")??"hover"}get#n(){return this.hasAttribute("prerender")}get#e(){return this.getAttribute("url")}appendTag(t){let{url:e,prerender:i}=t;if(e!==window.location.href&&!this.#t.includes(e))
|
9
|
+
`),setTimeout(()=>{this.#r(l,l)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#s.find(a=>a.key===t.key);n&&this.#o(n)}else s&&(i===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#r(this.#i+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#o({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#i!==this.#e&&(this.text[this.#i]===" "&&this.#r(this.#i+1,this.#e),this.text[this.#e-1]===" "&&this.#r(this.#i,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#o(this.#l(t))})}},P=o=>{let t=o.match(/^(\d+)\./);return t?Number(t[1]):null},B=(o,t,e)=>o.slice(0,e)+t+o.slice(e),k=(o,t)=>o.slice(0,t)+o.slice(t+1);var v=class extends c{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let t of this.getTrigger())!this.fullscreenSupported()&&"disabled"in t&&(t.disabled=!0)}};var w=class extends c{#t=[];#s=[];constructor(){super()}get#n(){return Number(this.getAttribute("threshold")??0)}onIntersect(t){this.#t.push(t)}onExit(t){this.#s.push(t)}mount(){let t=new IntersectionObserver(e=>{let i="data-intersect";for(let s of e)if(s.isIntersecting){this.getContent().setAttribute(i,"");for(let r of this.#t)r()}else{this.getContent().removeAttribute(i);for(let r of this.#s)r()}},{threshold:this.#n});for(let e of this.getTrigger())t.observe(e)}};var E=class extends p{constructor(){super()}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}async show(){this.getContent().showPopover(),await this.animateElement()}async hide(){await this.animateElement({options:{direction:"reverse"}}),this.getContent().hidePopover()}async toggle(){this.open?this.hide():this.show()}mount(){this.triggerListener(t=>{t.preventDefault(),this.toggle()}),this.getContent().addEventListener("toggle",t=>{t.newState==="open"?this.open=!0:this.open=!1}),this.safeListener("keydown",t=>{t.key==="Escape"&&this.open&&(t.preventDefault(),this.hide())})}};var T=class extends c{#t=[];constructor(){super()}get#s(){return this.getAttribute("strategy")??"hover"}get#n(){return this.hasAttribute("prerender")}get#e(){return this.getAttribute("url")}appendTag(t){let{url:e,prerender:i}=t;if(e!==window.location.href&&!this.#t.includes(e))if(this.#t.push(e),HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){let s={prefetch:[{source:"list",urls:[e]}]};i&&(s.prerender=s.prefetch);let r=document.createElement("script");r.type="speculationrules",r.textContent=JSON.stringify(s),document.head.append(r)}else{let s=document.createElement("link");s.rel="prefetch",s.as="document",s.href=e,document.head.append(s)}}prefetch(t={anchors:this.getTrigger(),prerender:this.#n,strategy:this.#s}){let{anchors:e=this.getTrigger(),prerender:i=this.#n,strategy:s=this.#s}=t,r,n=(l=200)=>h=>{let{href:m}=h.currentTarget;r=setTimeout(()=>this.appendTag({url:m,prerender:i}),l)},a=()=>clearTimeout(r),u=new IntersectionObserver(l=>{for(let h of l)h.isIntersecting&&this.appendTag({url:h.target.href,prerender:i})});for(let l of e)s==="load"?this.appendTag({url:l.href,prerender:i}):s==="visible"?u.observe(l):(l.addEventListener("mouseover",n()),l.addEventListener("mouseout",a),l.addEventListener("focus",n()),l.addEventListener("focusout",a),l.addEventListener("touchstart",n(0),{passive:!0}))}mount(){this.#e&&this.appendTag({url:this.#e,prerender:this.#n}),this.prefetch()}};var L=class extends f{constructor(){super()}async share(t=this.value){if(navigator.canShare&&navigator.canShare({url:t}))try{await navigator.share({url:t})}catch(e){e?.name!=="AbortError"&&console.error(e)}else this.copy()}mount(){this.triggerListener(async()=>await this.share())}};var C=class extends c{constructor(){super()}#t(t){let e="data-asc",i="data-desc";for(let s of this.getTrigger())s!==t&&(s.removeAttribute(e),s.removeAttribute(i));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(i,""),!1):(t.removeAttribute(i),t.setAttribute(e,""),!0)}mount(){let t=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(t.querySelectorAll("tr")).sort(K(e,this.#t(e))).forEach(i=>t.appendChild(i))})}},K=(o,t)=>(i,s)=>{let r=Array.from(o.parentNode?.children??[]).indexOf(o);return((a,u)=>{let l=o.dataset.type??"string";if(l==="string")return new Intl.Collator().compare(a,u);if(l==="boolean"){let h=m=>["0","false","null","undefined"].includes(m)?!1:!!m;return h(a)===h(u)?0:h(a)?-1:1}else return Number(a)-Number(u)})(j(t?i:s,r),j(t?s:i,r))},j=(o,t)=>{let e=o.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};var M=class extends c{wakeLock=null;constructor(){super()}#t(){return"wakeLock"in navigator}get#s(){return this.hasAttribute("auto-lock")}async request(){this.#t()&&document.visibilityState==="visible"&&(this.wakeLock=await navigator.wakeLock.request("screen"),this.setAttribute("locked",""),this.swapContent(!1),this.wakeLock.addEventListener("release",()=>{this.removeAttribute("locked"),this.swapContent(!1),this.#s||(this.wakeLock=null)}))}async release(){await this.wakeLock?.release(),this.wakeLock=null}mount(){this.hasAttribute("locked")&&this.request(),this.triggerListener(()=>{this.wakeLock?this.release():this.request()});for(let t of this.getTrigger())!this.#t()&&"disabled"in t&&(t.disabled=!0);this.#s&&this.safeListener("visibilitychange",()=>{this.wakeLock&&this.request()},document)}destroy(){this.release()}};var S=class extends c{static observedAttributes=["autoplay","start","uid"];constructor(){super()}get iframe(){return this.getContent(HTMLIFrameElement)}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(t){t?this.setAttribute("autoplay",""):this.removeAttribute("autoplay")}get start(){return this.getAttribute("start")??"0"}set start(t){this.setAttribute("start",t)}get uid(){let t=this.getAttribute("uid");if(!t)throw new Error("YouTube: missing `uid` attribute.");return t}set uid(t){this.setAttribute("uid",t)}mount(){this.iframe.allowFullscreen=!0,this.iframe.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"}attributeChangedCallback(){queueMicrotask(()=>{this.iframe.src=`https://www.youtube-nocookie.com/embed/${this.uid}?start=${this.start}${this.autoplay?"&autoplay=1":""}`})}};for(let o in H)customElements.define(`drab-${o.toLowerCase()}`,H[o]);})();
|
package/index.iife.js
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
${u}`});else if(u&&l.length===n){t.preventDefault();let m=this.#e,g=m-l.length;for(let b=0;b<l.length;b++)this.text=d(this.text,m-(b+1));setTimeout(async()=>{this.#r(g,g),this.textArea.focus(),await this.#o({type:"inline",value:`
|
7
7
|
`})},0)}}else{let s=Object.values(this.keyPairs).includes(i),r=this.#i!==this.#e;if((t.ctrlKey||t.metaKey)&&this.#i===this.#e&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:n,lineNumber:o,columnNumber:u}=this.#a();if(await navigator.clipboard.writeText(`${o===0&&t.key==="x"?"":`
|
8
8
|
`}${n[o]}`),t.key==="x"){let l=this.#i-u;n.splice(o,1),this.text=n.join(`
|
9
|
-
`),setTimeout(()=>{this.#r(l,l)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#s.find(o=>o.key===t.key);n&&this.#o(n)}else s&&(i===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#r(this.#i+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#o({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#i!==this.#e&&(this.text[this.#i]===" "&&this.#r(this.#i+1,this.#e),this.text[this.#e-1]===" "&&this.#r(this.#i,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#o(this.#l(t))})}},w=a=>{let t=a.match(/^(\d+)\./);return t?Number(t[1]):null},P=(a,t,e)=>a.slice(0,e)+t+a.slice(e),d=(a,t)=>a.slice(0,t)+a.slice(t+1);var T=class extends c{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let t of this.getTrigger())!this.fullscreenSupported()&&"disabled"in t&&(t.disabled=!0)}};var L=class extends c{#t=[];#s=[];constructor(){super()}get#n(){return Number(this.getAttribute("threshold")??0)}onIntersect(t){this.#t.push(t)}onExit(t){this.#s.push(t)}mount(){let t=new IntersectionObserver(e=>{let i="data-intersect";for(let s of e)if(s.isIntersecting){this.getContent().setAttribute(i,"");for(let r of this.#t)r()}else{this.getContent().removeAttribute(i);for(let r of this.#s)r()}},{threshold:this.#n});for(let e of this.getTrigger())t.observe(e)}};var C=class extends p{constructor(){super()}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}async show(){this.getContent().showPopover(),await this.animateElement()}async hide(){await this.animateElement({options:{direction:"reverse"}}),this.getContent().hidePopover()}async toggle(){this.open?this.hide():this.show()}mount(){this.triggerListener(t=>{t.preventDefault(),this.toggle()}),this.getContent().addEventListener("toggle",t=>{t.newState==="open"?this.open=!0:this.open=!1}),this.safeListener("keydown",t=>{t.key==="Escape"&&this.open&&(t.preventDefault(),this.hide())})}};var M=class extends c{#t=[];constructor(){super()}get#s(){return this.getAttribute("strategy")??"hover"}get#n(){return this.hasAttribute("prerender")}get#e(){return this.getAttribute("url")}appendTag(t){let{url:e,prerender:i}=t;if(e!==window.location.href&&!this.#t.includes(e))
|
9
|
+
`),setTimeout(()=>{this.#r(l,l)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#s.find(o=>o.key===t.key);n&&this.#o(n)}else s&&(i===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#r(this.#i+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#o({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#i!==this.#e&&(this.text[this.#i]===" "&&this.#r(this.#i+1,this.#e),this.text[this.#e-1]===" "&&this.#r(this.#i,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#o(this.#l(t))})}},w=a=>{let t=a.match(/^(\d+)\./);return t?Number(t[1]):null},P=(a,t,e)=>a.slice(0,e)+t+a.slice(e),d=(a,t)=>a.slice(0,t)+a.slice(t+1);var T=class extends c{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let t of this.getTrigger())!this.fullscreenSupported()&&"disabled"in t&&(t.disabled=!0)}};var L=class extends c{#t=[];#s=[];constructor(){super()}get#n(){return Number(this.getAttribute("threshold")??0)}onIntersect(t){this.#t.push(t)}onExit(t){this.#s.push(t)}mount(){let t=new IntersectionObserver(e=>{let i="data-intersect";for(let s of e)if(s.isIntersecting){this.getContent().setAttribute(i,"");for(let r of this.#t)r()}else{this.getContent().removeAttribute(i);for(let r of this.#s)r()}},{threshold:this.#n});for(let e of this.getTrigger())t.observe(e)}};var C=class extends p{constructor(){super()}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}async show(){this.getContent().showPopover(),await this.animateElement()}async hide(){await this.animateElement({options:{direction:"reverse"}}),this.getContent().hidePopover()}async toggle(){this.open?this.hide():this.show()}mount(){this.triggerListener(t=>{t.preventDefault(),this.toggle()}),this.getContent().addEventListener("toggle",t=>{t.newState==="open"?this.open=!0:this.open=!1}),this.safeListener("keydown",t=>{t.key==="Escape"&&this.open&&(t.preventDefault(),this.hide())})}};var M=class extends c{#t=[];constructor(){super()}get#s(){return this.getAttribute("strategy")??"hover"}get#n(){return this.hasAttribute("prerender")}get#e(){return this.getAttribute("url")}appendTag(t){let{url:e,prerender:i}=t;if(e!==window.location.href&&!this.#t.includes(e))if(this.#t.push(e),HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){let s={prefetch:[{source:"list",urls:[e]}]};i&&(s.prerender=s.prefetch);let r=document.createElement("script");r.type="speculationrules",r.textContent=JSON.stringify(s),document.head.append(r)}else{let s=document.createElement("link");s.rel="prefetch",s.as="document",s.href=e,document.head.append(s)}}prefetch(t={anchors:this.getTrigger(),prerender:this.#n,strategy:this.#s}){let{anchors:e=this.getTrigger(),prerender:i=this.#n,strategy:s=this.#s}=t,r,n=(l=200)=>h=>{let{href:m}=h.currentTarget;r=setTimeout(()=>this.appendTag({url:m,prerender:i}),l)},o=()=>clearTimeout(r),u=new IntersectionObserver(l=>{for(let h of l)h.isIntersecting&&this.appendTag({url:h.target.href,prerender:i})});for(let l of e)s==="load"?this.appendTag({url:l.href,prerender:i}):s==="visible"?u.observe(l):(l.addEventListener("mouseover",n()),l.addEventListener("mouseout",o),l.addEventListener("focus",n()),l.addEventListener("focusout",o),l.addEventListener("touchstart",n(0),{passive:!0}))}mount(){this.#e&&this.appendTag({url:this.#e,prerender:this.#n}),this.prefetch()}};var S=class extends f{constructor(){super()}async share(t=this.value){if(navigator.canShare&&navigator.canShare({url:t}))try{await navigator.share({url:t})}catch(e){e?.name!=="AbortError"&&console.error(e)}else this.copy()}mount(){this.triggerListener(async()=>await this.share())}};var H=class extends c{constructor(){super()}#t(t){let e="data-asc",i="data-desc";for(let s of this.getTrigger())s!==t&&(s.removeAttribute(e),s.removeAttribute(i));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(i,""),!1):(t.removeAttribute(i),t.setAttribute(e,""),!0)}mount(){let t=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(t.querySelectorAll("tr")).sort(j(e,this.#t(e))).forEach(i=>t.appendChild(i))})}},j=(a,t)=>(i,s)=>{let r=Array.from(a.parentNode?.children??[]).indexOf(a);return((o,u)=>{let l=a.dataset.type??"string";if(l==="string")return new Intl.Collator().compare(o,u);if(l==="boolean"){let h=m=>["0","false","null","undefined"].includes(m)?!1:!!m;return h(o)===h(u)?0:h(o)?-1:1}else return Number(o)-Number(u)})(B(t?i:s,r),B(t?s:i,r))},B=(a,t)=>{let e=a.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};var N=class extends c{wakeLock=null;constructor(){super()}#t(){return"wakeLock"in navigator}get#s(){return this.hasAttribute("auto-lock")}async request(){this.#t()&&document.visibilityState==="visible"&&(this.wakeLock=await navigator.wakeLock.request("screen"),this.setAttribute("locked",""),this.swapContent(!1),this.wakeLock.addEventListener("release",()=>{this.removeAttribute("locked"),this.swapContent(!1),this.#s||(this.wakeLock=null)}))}async release(){await this.wakeLock?.release(),this.wakeLock=null}mount(){this.hasAttribute("locked")&&this.request(),this.triggerListener(()=>{this.wakeLock?this.release():this.request()});for(let t of this.getTrigger())!this.#t()&&"disabled"in t&&(t.disabled=!0);this.#s&&this.safeListener("visibilitychange",()=>{this.wakeLock&&this.request()},document)}destroy(){this.release()}};var D=class extends c{static observedAttributes=["autoplay","start","uid"];constructor(){super()}get iframe(){return this.getContent(HTMLIFrameElement)}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(t){t?this.setAttribute("autoplay",""):this.removeAttribute("autoplay")}get start(){return this.getAttribute("start")??"0"}set start(t){this.setAttribute("start",t)}get uid(){let t=this.getAttribute("uid");if(!t)throw new Error("YouTube: missing `uid` attribute.");return t}set uid(t){this.setAttribute("uid",t)}mount(){this.iframe.allowFullscreen=!0,this.iframe.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"}attributeChangedCallback(){queueMicrotask(()=>{this.iframe.src=`https://www.youtube-nocookie.com/embed/${this.uid}?start=${this.start}${this.autoplay?"&autoplay=1":""}`})}};})();
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "drab",
|
3
3
|
"description": "A headless custom element library",
|
4
|
-
"version": "5.3.
|
4
|
+
"version": "5.3.6",
|
5
5
|
"homepage": "https://drab.robino.dev",
|
6
6
|
"license": "MIT",
|
7
7
|
"author": {
|
@@ -184,19 +184,19 @@
|
|
184
184
|
},
|
185
185
|
"devDependencies": {
|
186
186
|
"@tailwindcss/typography": "^0.5.10",
|
187
|
-
"@types/node": "^20.11.
|
187
|
+
"@types/node": "^20.11.24",
|
188
188
|
"@vercel/analytics": "^1.2.2",
|
189
|
-
"autoprefixer": "^10.4.
|
190
|
-
"domco": "^0.5.
|
189
|
+
"autoprefixer": "^10.4.18",
|
190
|
+
"domco": "^0.5.3",
|
191
191
|
"prettier": "^3.2.5",
|
192
192
|
"prettier-plugin-tailwindcss": "^0.5.11",
|
193
193
|
"robino": "^0.1.0",
|
194
194
|
"tailwindcss": "^3.4.1",
|
195
195
|
"tsup": "^8.0.2",
|
196
|
-
"typedoc": "^0.25.
|
196
|
+
"typedoc": "^0.25.10",
|
197
197
|
"typedoc-plugin-markdown": "^3.17.1",
|
198
198
|
"typescript": "^5.3.3",
|
199
199
|
"uico": "^0.2.2",
|
200
|
-
"vite": "^5.1.
|
200
|
+
"vite": "^5.1.5"
|
201
201
|
}
|
202
202
|
}
|
package/prefetch/define.iife.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(()=>{var
|
1
|
+
"use strict";(()=>{var a=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(n){this.setAttribute("event",n)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(n=HTMLElement){let t=this.querySelector(this.getAttribute("content")??"[data-content]");if(t instanceof n)return t;throw new Error("Content not found")}swapContent(n=!0,t=800){let r=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(r){let e=Array.from(this.getContent().childNodes),o=[];r instanceof HTMLTemplateElement?(o.push(r.content.cloneNode(!0)),r.content.replaceChildren(...e)):(o.push(...r.childNodes),r.replaceChildren(...e)),this.getContent().replaceChildren(...o),n&&setTimeout(()=>this.swapContent(!1),t)}}safeListener(n,t,r=document.body,e={}){e.signal=this.#e.signal,r.addEventListener(n,t,e)}triggerListener(n,t=this.event,r){for(let e of this.getTrigger())e.addEventListener(t,n,r)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var c=class extends a{#e=[];constructor(){super()}get#r(){return this.getAttribute("strategy")??"hover"}get#t(){return this.hasAttribute("prerender")}get#n(){return this.getAttribute("url")}appendTag(n){let{url:t,prerender:r}=n;if(t!==window.location.href&&!this.#e.includes(t))if(this.#e.push(t),HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){let e={prefetch:[{source:"list",urls:[t]}]};r&&(e.prerender=e.prefetch);let o=document.createElement("script");o.type="speculationrules",o.textContent=JSON.stringify(e),document.head.append(o)}else{let e=document.createElement("link");e.rel="prefetch",e.as="document",e.href=t,document.head.append(e)}}prefetch(n={anchors:this.getTrigger(),prerender:this.#t,strategy:this.#r}){let{anchors:t=this.getTrigger(),prerender:r=this.#t,strategy:e=this.#r}=n,o,l=(s=200)=>i=>{let{href:p}=i.currentTarget;o=setTimeout(()=>this.appendTag({url:p,prerender:r}),s)},u=()=>clearTimeout(o),h=new IntersectionObserver(s=>{for(let i of s)i.isIntersecting&&this.appendTag({url:i.target.href,prerender:r})});for(let s of t)e==="load"?this.appendTag({url:s.href,prerender:r}):e==="visible"?h.observe(s):(s.addEventListener("mouseover",l()),s.addEventListener("mouseout",u),s.addEventListener("focus",l()),s.addEventListener("focusout",u),s.addEventListener("touchstart",l(0),{passive:!0}))}mount(){this.#n&&this.appendTag({url:this.#n,prerender:this.#t}),this.prefetch()}};customElements.define("drab-prefetch",c);})();
|
package/prefetch/index.iife.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(()=>{var
|
1
|
+
"use strict";(()=>{var a=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(n){this.setAttribute("event",n)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(n=HTMLElement){let t=this.querySelector(this.getAttribute("content")??"[data-content]");if(t instanceof n)return t;throw new Error("Content not found")}swapContent(n=!0,t=800){let r=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(r){let e=Array.from(this.getContent().childNodes),o=[];r instanceof HTMLTemplateElement?(o.push(r.content.cloneNode(!0)),r.content.replaceChildren(...e)):(o.push(...r.childNodes),r.replaceChildren(...e)),this.getContent().replaceChildren(...o),n&&setTimeout(()=>this.swapContent(!1),t)}}safeListener(n,t,r=document.body,e={}){e.signal=this.#e.signal,r.addEventListener(n,t,e)}triggerListener(n,t=this.event,r){for(let e of this.getTrigger())e.addEventListener(t,n,r)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var u=class extends a{#e=[];constructor(){super()}get#r(){return this.getAttribute("strategy")??"hover"}get#t(){return this.hasAttribute("prerender")}get#n(){return this.getAttribute("url")}appendTag(n){let{url:t,prerender:r}=n;if(t!==window.location.href&&!this.#e.includes(t))if(this.#e.push(t),HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){let e={prefetch:[{source:"list",urls:[t]}]};r&&(e.prerender=e.prefetch);let o=document.createElement("script");o.type="speculationrules",o.textContent=JSON.stringify(e),document.head.append(o)}else{let e=document.createElement("link");e.rel="prefetch",e.as="document",e.href=t,document.head.append(e)}}prefetch(n={anchors:this.getTrigger(),prerender:this.#t,strategy:this.#r}){let{anchors:t=this.getTrigger(),prerender:r=this.#t,strategy:e=this.#r}=n,o,l=(s=200)=>i=>{let{href:p}=i.currentTarget;o=setTimeout(()=>this.appendTag({url:p,prerender:r}),s)},c=()=>clearTimeout(o),h=new IntersectionObserver(s=>{for(let i of s)i.isIntersecting&&this.appendTag({url:i.target.href,prerender:r})});for(let s of t)e==="load"?this.appendTag({url:s.href,prerender:r}):e==="visible"?h.observe(s):(s.addEventListener("mouseover",l()),s.addEventListener("mouseout",c),s.addEventListener("focus",l()),s.addEventListener("focusout",c),s.addEventListener("touchstart",l(0),{passive:!0}))}mount(){this.#n&&this.appendTag({url:this.#n,prerender:this.#t}),this.prefetch()}};})();
|
package/prefetch/index.js
CHANGED
@@ -55,28 +55,34 @@ export class Prefetch extends Base {
|
|
55
55
|
if (!(url === window.location.href) &&
|
56
56
|
!this.#prefetchedUrls.includes(url)) {
|
57
57
|
this.#prefetchedUrls.push(url);
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
if (prerender &&
|
66
|
-
HTMLScriptElement.supports &&
|
67
|
-
HTMLScriptElement.supports(speculationrules)) {
|
68
|
-
const script = document.createElement("script");
|
69
|
-
script.type = speculationrules;
|
70
|
-
script.textContent = JSON.stringify({
|
71
|
-
prerender: [
|
58
|
+
if (HTMLScriptElement.supports &&
|
59
|
+
HTMLScriptElement.supports("speculationrules")) {
|
60
|
+
const rules = {
|
61
|
+
// Currently, adding `prefetch` is required to fallback if `prerender` fails.
|
62
|
+
// Possibly will be automatic in the future, in which case it can be removed.
|
63
|
+
// https://github.com/WICG/nav-speculation/issues/162#issuecomment-1977818473
|
64
|
+
prefetch: [
|
72
65
|
{
|
73
66
|
source: "list",
|
74
67
|
urls: [url],
|
75
68
|
},
|
76
69
|
],
|
77
|
-
}
|
70
|
+
};
|
71
|
+
if (prerender) {
|
72
|
+
rules.prerender = rules.prefetch;
|
73
|
+
}
|
74
|
+
const script = document.createElement("script");
|
75
|
+
script.type = "speculationrules";
|
76
|
+
script.textContent = JSON.stringify(rules);
|
78
77
|
document.head.append(script);
|
79
78
|
}
|
79
|
+
else {
|
80
|
+
const link = document.createElement("link");
|
81
|
+
link.rel = "prefetch";
|
82
|
+
link.as = "document";
|
83
|
+
link.href = url;
|
84
|
+
document.head.append(link);
|
85
|
+
}
|
80
86
|
}
|
81
87
|
}
|
82
88
|
/**
|