@miyaoka/miyaoka-components
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -31,3 +31,3 @@ 'use strict'; | ||
return patchEsm().then(() => { | ||
return index.bootstrapLazy([["miyaoka-embed-tweet_4.cjs",[[0,"miyaoka-embed-tweet",{"src":[1]}],[1,"miyaoka-img-loader",{"src":[1],"alt":[1],"loading":[1],"scale":[2],"rotate":[2],"opacity":[2],"duration":[2],"delay":[2],"img":[32],"isLoaded":[32]}],[1,"miyaoka-lightbox",{"src":[1],"visible":[32]}],[1,"miyaoka-prefetch"]]]], options); | ||
return index.bootstrapLazy([["miyaoka-embed-tweet_4.cjs",[[0,"miyaoka-embed-tweet",{"src":[1]}],[1,"miyaoka-img-loader",{"src":[1],"alt":[1],"loading":[1],"scale":[2],"rotate":[2],"opacity":[2],"duration":[2],"delay":[2],"img":[32],"isLoaded":[32]}],[1,"miyaoka-lightbox",{"src":[1],"visible":[32]}],[1,"miyaoka-prefetch",{"appendedLinks":[32]}]]]], options); | ||
}); | ||
@@ -34,0 +34,0 @@ }; |
@@ -82,3 +82,3 @@ 'use strict'; | ||
patchBrowser().then(options => { | ||
return index.bootstrapLazy([["miyaoka-embed-tweet_4.cjs",[[0,"miyaoka-embed-tweet",{"src":[1]}],[1,"miyaoka-img-loader",{"src":[1],"alt":[1],"loading":[1],"scale":[2],"rotate":[2],"opacity":[2],"duration":[2],"delay":[2],"img":[32],"isLoaded":[32]}],[1,"miyaoka-lightbox",{"src":[1],"visible":[32]}],[1,"miyaoka-prefetch"]]]], options); | ||
return index.bootstrapLazy([["miyaoka-embed-tweet_4.cjs",[[0,"miyaoka-embed-tweet",{"src":[1]}],[1,"miyaoka-img-loader",{"src":[1],"alt":[1],"loading":[1],"scale":[2],"rotate":[2],"opacity":[2],"duration":[2],"delay":[2],"img":[32],"isLoaded":[32]}],[1,"miyaoka-lightbox",{"src":[1],"visible":[32]}],[1,"miyaoka-prefetch",{"appendedLinks":[32]}]]]], options); | ||
}); |
@@ -132,15 +132,7 @@ 'use strict'; | ||
index.registerInstance(this, hostRef); | ||
this.appendedLinks = {}; | ||
} | ||
componentDidLoad() { | ||
const host = location.host; | ||
const linkList = Array.from(document.querySelectorAll('a[data-prefetch]')); | ||
const hrefMap = {}; | ||
const sameHostLinks = linkList.filter(({ href }) => { | ||
const url = new URL(href); | ||
if (url.host !== host || hrefMap[href]) | ||
return false; | ||
hrefMap[href] = true; | ||
return true; | ||
}); | ||
sameHostLinks.forEach((link) => { | ||
linkList.forEach((link) => { | ||
const observer = new IntersectionObserver((entryList) => { | ||
@@ -158,2 +150,5 @@ entryList.forEach((entry) => { | ||
addPrefetch(href) { | ||
if (this.appendedLinks[href]) | ||
return; | ||
this.appendedLinks[href] = true; | ||
const el = document.createElement('link'); | ||
@@ -160,0 +155,0 @@ el.rel = 'prefetch'; |
@@ -1,15 +0,9 @@ | ||
import { Component } from '@stencil/core'; | ||
import { Component, State } from '@stencil/core'; | ||
export class MiyaokaPrefetch { | ||
constructor() { | ||
this.appendedLinks = {}; | ||
} | ||
componentDidLoad() { | ||
const host = location.host; | ||
const linkList = Array.from(document.querySelectorAll('a[data-prefetch]')); | ||
const hrefMap = {}; | ||
const sameHostLinks = linkList.filter(({ href }) => { | ||
const url = new URL(href); | ||
if (url.host !== host || hrefMap[href]) | ||
return false; | ||
hrefMap[href] = true; | ||
return true; | ||
}); | ||
sameHostLinks.forEach((link) => { | ||
linkList.forEach((link) => { | ||
const observer = new IntersectionObserver((entryList) => { | ||
@@ -27,2 +21,5 @@ entryList.forEach((entry) => { | ||
addPrefetch(href) { | ||
if (this.appendedLinks[href]) | ||
return; | ||
this.appendedLinks[href] = true; | ||
const el = document.createElement('link'); | ||
@@ -35,2 +32,5 @@ el.rel = 'prefetch'; | ||
static get encapsulation() { return "shadow"; } | ||
static get states() { return { | ||
"appendedLinks": {} | ||
}; } | ||
} |
@@ -1,1 +0,1 @@ | ||
import{C as CSS,p as plt,w as win,a as promiseResolve,b as bootstrapLazy}from"./index-a4c6996c.js";var patchEsm=function(){if(!(CSS&&CSS.supports&&CSS.supports("color","var(--c)"))){return import("./css-shim-8d75038b.js").then((function(){if(plt.$cssShim$=win.__cssshim){return plt.$cssShim$.i()}else{return 0}}))}return promiseResolve()};var defineCustomElements=function(e,t){if(typeof window==="undefined")return Promise.resolve();return patchEsm().then((function(){return bootstrapLazy([["miyaoka-embed-tweet_4",[[0,"miyaoka-embed-tweet",{src:[1]}],[1,"miyaoka-img-loader",{src:[1],alt:[1],loading:[1],scale:[2],rotate:[2],opacity:[2],duration:[2],delay:[2],img:[32],isLoaded:[32]}],[1,"miyaoka-lightbox",{src:[1],visible:[32]}],[1,"miyaoka-prefetch"]]]],t)}))};export{defineCustomElements}; | ||
import{C as CSS,p as plt,w as win,a as promiseResolve,b as bootstrapLazy}from"./index-a4c6996c.js";var patchEsm=function(){if(!(CSS&&CSS.supports&&CSS.supports("color","var(--c)"))){return import("./css-shim-8d75038b.js").then((function(){if(plt.$cssShim$=win.__cssshim){return plt.$cssShim$.i()}else{return 0}}))}return promiseResolve()};var defineCustomElements=function(e,s){if(typeof window==="undefined")return Promise.resolve();return patchEsm().then((function(){return bootstrapLazy([["miyaoka-embed-tweet_4",[[0,"miyaoka-embed-tweet",{src:[1]}],[1,"miyaoka-img-loader",{src:[1],alt:[1],loading:[1],scale:[2],rotate:[2],opacity:[2],duration:[2],delay:[2],img:[32],isLoaded:[32]}],[1,"miyaoka-lightbox",{src:[1],visible:[32]}],[1,"miyaoka-prefetch",{appendedLinks:[32]}]]]],s)}))};export{defineCustomElements}; |
@@ -1,1 +0,1 @@ | ||
import{p as plt,w as win,d as doc,N as NAMESPACE,a as promiseResolve,b as bootstrapLazy}from"./index-a4c6996c.js";var getDynamicImportFunction=function(r){return"__sc_import_"+r.replace(/\s|-/g,"_")};var patchBrowser=function(){{plt.$cssShim$=win.__cssshim}var r=Array.from(doc.querySelectorAll("script")).find((function(r){return new RegExp("/"+NAMESPACE+"(\\.esm)?\\.js($|\\?|#)").test(r.src)||r.getAttribute("data-stencil-namespace")===NAMESPACE}));var t=r["data-opts"]||{};if("onbeforeload"in r&&!history.scrollRestoration){return{then:function(){}}}{t.resourcesUrl=new URL(".",new URL(r.getAttribute("data-resources-url")||r.src,win.location.href)).href;{patchDynamicImport(t.resourcesUrl,r)}if(!win.customElements){return import("./dom-1b195079.js").then((function(){return t}))}}return promiseResolve(t)};var patchDynamicImport=function(r,t){var e=getDynamicImportFunction(NAMESPACE);try{win[e]=new Function("w","return import(w);//"+Math.random())}catch(a){var o=new Map;win[e]=function(a){var n=new URL(a,r).href;var i=o.get(n);if(!i){var c=doc.createElement("script");c.type="module";c.crossOrigin=t.crossOrigin;c.src=URL.createObjectURL(new Blob(["import * as m from '"+n+"'; window."+e+".m = m;"],{type:"application/javascript"}));i=new Promise((function(r){c.onload=function(){r(win[e].m);c.remove()}}));o.set(n,i);doc.head.appendChild(c)}return i}}};patchBrowser().then((function(r){return bootstrapLazy([["miyaoka-embed-tweet_4",[[0,"miyaoka-embed-tweet",{src:[1]}],[1,"miyaoka-img-loader",{src:[1],alt:[1],loading:[1],scale:[2],rotate:[2],opacity:[2],duration:[2],delay:[2],img:[32],isLoaded:[32]}],[1,"miyaoka-lightbox",{src:[1],visible:[32]}],[1,"miyaoka-prefetch"]]]],r)})); | ||
import{p as plt,w as win,d as doc,N as NAMESPACE,a as promiseResolve,b as bootstrapLazy}from"./index-a4c6996c.js";var getDynamicImportFunction=function(e){return"__sc_import_"+e.replace(/\s|-/g,"_")};var patchBrowser=function(){{plt.$cssShim$=win.__cssshim}var e=Array.from(doc.querySelectorAll("script")).find((function(e){return new RegExp("/"+NAMESPACE+"(\\.esm)?\\.js($|\\?|#)").test(e.src)||e.getAttribute("data-stencil-namespace")===NAMESPACE}));var r=e["data-opts"]||{};if("onbeforeload"in e&&!history.scrollRestoration){return{then:function(){}}}{r.resourcesUrl=new URL(".",new URL(e.getAttribute("data-resources-url")||e.src,win.location.href)).href;{patchDynamicImport(r.resourcesUrl,e)}if(!win.customElements){return import("./dom-1b195079.js").then((function(){return r}))}}return promiseResolve(r)};var patchDynamicImport=function(e,r){var t=getDynamicImportFunction(NAMESPACE);try{win[t]=new Function("w","return import(w);//"+Math.random())}catch(o){var n=new Map;win[t]=function(o){var a=new URL(o,e).href;var i=n.get(a);if(!i){var c=doc.createElement("script");c.type="module";c.crossOrigin=r.crossOrigin;c.src=URL.createObjectURL(new Blob(["import * as m from '"+a+"'; window."+t+".m = m;"],{type:"application/javascript"}));i=new Promise((function(e){c.onload=function(){e(win[t].m);c.remove()}}));n.set(a,i);doc.head.appendChild(c)}return i}}};patchBrowser().then((function(e){return bootstrapLazy([["miyaoka-embed-tweet_4",[[0,"miyaoka-embed-tweet",{src:[1]}],[1,"miyaoka-img-loader",{src:[1],alt:[1],loading:[1],scale:[2],rotate:[2],opacity:[2],duration:[2],delay:[2],img:[32],isLoaded:[32]}],[1,"miyaoka-lightbox",{src:[1],visible:[32]}],[1,"miyaoka-prefetch",{appendedLinks:[32]}]]]],e)})); |
@@ -1,1 +0,1 @@ | ||
var __awaiter=this&&this.__awaiter||function(t,e,r,i){function n(t){return t instanceof r?t:new r((function(e){e(t)}))}return new(r||(r=Promise))((function(r,o){function a(t){try{c(i.next(t))}catch(e){o(e)}}function s(t){try{c(i["throw"](t))}catch(e){o(e)}}function c(t){t.done?r(t.value):n(t.value).then(a,s)}c((i=i.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,n,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return c([t,e])}}function c(a){if(i)throw new TypeError("Generator is already executing.");while(r)try{if(i=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;n=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(o=r.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1];o=a;break}if(o&&r.label<o[2]){r.label=o[2];r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=e.call(t,r)}catch(s){a=[6,s];n=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host,g as getElement}from"./index-a4c6996c.js";function loadScript(t){var e=t.src,r=t.id;var i=r?document.getElementById(r):null;return new Promise((function(t,n){if(i){t()}var o=document.createElement("script");o.setAttribute("src",e);document.head.appendChild(o);o.onload=function(){if(r)o.setAttribute("id",r);t()};o.onerror=function(t){return n(t)}}))}var miyaokaEmbedTweetCss=":host{display:block}";var twReg=new RegExp("https://twitter.com/[^/]+/status/(\\d+)");var twWidgetSrc="https://platform.twitter.com/widgets.js";var MiyaokaEmbedTweet=function(){function t(t){registerInstance(this,t);this.src=""}t.prototype.connectedCallback=function(){var t=this;var e=this.src.match(twReg);if(!e)return;var r=e[1];var i=new IntersectionObserver((function(e){e.forEach((function(e){if(!e.isIntersecting)return;i.unobserve(t.el);t.embedTweet(r)}))}),{rootMargin:"200%"});i.observe(this.el)};t.prototype.embedTweet=function(t){return __awaiter(this,void 0,void 0,(function(){var e,r,i,n;return __generator(this,(function(o){switch(o.label){case 0:n=window;if(!!((e=n.twttr)===null||e===void 0?void 0:e.ready))return[3,2];return[4,loadScript({src:twWidgetSrc,id:"twitter-widgets"})];case 1:o.sent();o.label=2;case 2:return[4,(i=(r=n.twttr)===null||r===void 0?void 0:r.widgets)===null||i===void 0?void 0:i.createTweet(t,this.el,{align:"center"})];case 3:o.sent();this.el.children[0].remove();this.el.classList.add("embedTweetLoaded");return[2]}}))}))};t.prototype.render=function(){return h(Host,null,h("p",null,h("a",{href:this.src,target:"_blank",rel:"noopener noreferrer"},this.src)))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();MiyaokaEmbedTweet.style=miyaokaEmbedTweetCss;var miyaokaImgLoaderCss=":host{width:100%;height:100%;overflow:hidden}img{width:100%;height:100%}";var MiyaokaImgLoader=function(){function t(t){registerInstance(this,t);this.alt="image";this.loading="lazy";this.scale=.5;this.rotate=90;this.opacity=0;this.duration=200;this.delay=50;this.isLoaded=false}t.prototype.componentDidLoad=function(){var t=this;if(!this.img)return;if(this.img.complete){requestAnimationFrame((function(){return t.resetTransform()}));return}this.img.onload=function(){t.resetTransform()}};t.prototype.resetTransform=function(){this.isLoaded=true};t.prototype.render=function(){var t=this;var e=this.isLoaded?{}:{transform:"scale("+this.scale+") rotate("+this.rotate+"deg)",opacity:""+this.opacity};return h(Host,null,h("img",{ref:function(e){t.img=e},src:this.src,alt:this.alt,loading:this.loading,style:Object.assign(Object.assign({},e),{transitionDuration:this.duration+"ms",transitionDelay:this.delay+"ms"})}))};return t}();MiyaokaImgLoader.style=miyaokaImgLoaderCss;var miyaokaLightboxCss=":host{display:block}.container{cursor:pointer;display:inline}.backdrop{position:fixed;top:0;right:0;left:0;bottom:0;z-index:100;background-color:rgba(64, 62, 62, 0.9)}.backdrop img{width:100%;height:100%;-o-object-fit:contain;object-fit:contain}";var MiyaokaLightbox=function(){function t(t){registerInstance(this,t);this.visible=false}t.prototype.render=function(){var t=this;return h(Host,null,h("div",{onClick:function(){return t.visible=true},class:"container"},this.visible&&h("div",{onClick:function(e){e.stopPropagation();t.visible=false},class:"backdrop"},h("img",{src:this.src})),h("slot",null)))};return t}();MiyaokaLightbox.style=miyaokaLightboxCss;var MiyaokaPrefetch=function(){function t(t){registerInstance(this,t)}t.prototype.componentDidLoad=function(){var t=this;var e=location.host;var r=Array.from(document.querySelectorAll("a[data-prefetch]"));var i={};var n=r.filter((function(t){var r=t.href;var n=new URL(r);if(n.host!==e||i[r])return false;i[r]=true;return true}));n.forEach((function(e){var r=new IntersectionObserver((function(i){i.forEach((function(i){if(!i.isIntersecting)return;r.unobserve(e);t.addPrefetch(e.href)}))}));r.observe(e)}))};t.prototype.addPrefetch=function(t){var e=document.createElement("link");e.rel="prefetch";e.href=t;document.head.appendChild(e)};return t}();export{MiyaokaEmbedTweet as miyaoka_embed_tweet,MiyaokaImgLoader as miyaoka_img_loader,MiyaokaLightbox as miyaoka_lightbox,MiyaokaPrefetch as miyaoka_prefetch}; | ||
var __awaiter=this&&this.__awaiter||function(t,e,r,i){function n(t){return t instanceof r?t:new r((function(e){e(t)}))}return new(r||(r=Promise))((function(r,o){function a(t){try{c(i.next(t))}catch(e){o(e)}}function s(t){try{c(i["throw"](t))}catch(e){o(e)}}function c(t){t.done?r(t.value):n(t.value).then(a,s)}c((i=i.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,n,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return c([t,e])}}function c(a){if(i)throw new TypeError("Generator is already executing.");while(r)try{if(i=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;n=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(o=r.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1];o=a;break}if(o&&r.label<o[2]){r.label=o[2];r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=e.call(t,r)}catch(s){a=[6,s];n=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host,g as getElement}from"./index-a4c6996c.js";function loadScript(t){var e=t.src,r=t.id;var i=r?document.getElementById(r):null;return new Promise((function(t,n){if(i){t()}var o=document.createElement("script");o.setAttribute("src",e);document.head.appendChild(o);o.onload=function(){if(r)o.setAttribute("id",r);t()};o.onerror=function(t){return n(t)}}))}var miyaokaEmbedTweetCss=":host{display:block}";var twReg=new RegExp("https://twitter.com/[^/]+/status/(\\d+)");var twWidgetSrc="https://platform.twitter.com/widgets.js";var MiyaokaEmbedTweet=function(){function t(t){registerInstance(this,t);this.src=""}t.prototype.connectedCallback=function(){var t=this;var e=this.src.match(twReg);if(!e)return;var r=e[1];var i=new IntersectionObserver((function(e){e.forEach((function(e){if(!e.isIntersecting)return;i.unobserve(t.el);t.embedTweet(r)}))}),{rootMargin:"200%"});i.observe(this.el)};t.prototype.embedTweet=function(t){return __awaiter(this,void 0,void 0,(function(){var e,r,i,n;return __generator(this,(function(o){switch(o.label){case 0:n=window;if(!!((e=n.twttr)===null||e===void 0?void 0:e.ready))return[3,2];return[4,loadScript({src:twWidgetSrc,id:"twitter-widgets"})];case 1:o.sent();o.label=2;case 2:return[4,(i=(r=n.twttr)===null||r===void 0?void 0:r.widgets)===null||i===void 0?void 0:i.createTweet(t,this.el,{align:"center"})];case 3:o.sent();this.el.children[0].remove();this.el.classList.add("embedTweetLoaded");return[2]}}))}))};t.prototype.render=function(){return h(Host,null,h("p",null,h("a",{href:this.src,target:"_blank",rel:"noopener noreferrer"},this.src)))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();MiyaokaEmbedTweet.style=miyaokaEmbedTweetCss;var miyaokaImgLoaderCss=":host{width:100%;height:100%;overflow:hidden}img{width:100%;height:100%}";var MiyaokaImgLoader=function(){function t(t){registerInstance(this,t);this.alt="image";this.loading="lazy";this.scale=.5;this.rotate=90;this.opacity=0;this.duration=200;this.delay=50;this.isLoaded=false}t.prototype.componentDidLoad=function(){var t=this;if(!this.img)return;if(this.img.complete){requestAnimationFrame((function(){return t.resetTransform()}));return}this.img.onload=function(){t.resetTransform()}};t.prototype.resetTransform=function(){this.isLoaded=true};t.prototype.render=function(){var t=this;var e=this.isLoaded?{}:{transform:"scale("+this.scale+") rotate("+this.rotate+"deg)",opacity:""+this.opacity};return h(Host,null,h("img",{ref:function(e){t.img=e},src:this.src,alt:this.alt,loading:this.loading,style:Object.assign(Object.assign({},e),{transitionDuration:this.duration+"ms",transitionDelay:this.delay+"ms"})}))};return t}();MiyaokaImgLoader.style=miyaokaImgLoaderCss;var miyaokaLightboxCss=":host{display:block}.container{cursor:pointer;display:inline}.backdrop{position:fixed;top:0;right:0;left:0;bottom:0;z-index:100;background-color:rgba(64, 62, 62, 0.9)}.backdrop img{width:100%;height:100%;-o-object-fit:contain;object-fit:contain}";var MiyaokaLightbox=function(){function t(t){registerInstance(this,t);this.visible=false}t.prototype.render=function(){var t=this;return h(Host,null,h("div",{onClick:function(){return t.visible=true},class:"container"},this.visible&&h("div",{onClick:function(e){e.stopPropagation();t.visible=false},class:"backdrop"},h("img",{src:this.src})),h("slot",null)))};return t}();MiyaokaLightbox.style=miyaokaLightboxCss;var MiyaokaPrefetch=function(){function t(t){registerInstance(this,t);this.appendedLinks={}}t.prototype.componentDidLoad=function(){var t=this;var e=Array.from(document.querySelectorAll("a[data-prefetch]"));e.forEach((function(e){var r=new IntersectionObserver((function(i){i.forEach((function(i){if(!i.isIntersecting)return;r.unobserve(e);t.addPrefetch(e.href)}))}));r.observe(e)}))};t.prototype.addPrefetch=function(t){if(this.appendedLinks[t])return;this.appendedLinks[t]=true;var e=document.createElement("link");e.rel="prefetch";e.href=t;document.head.appendChild(e)};return t}();export{MiyaokaEmbedTweet as miyaoka_embed_tweet,MiyaokaImgLoader as miyaoka_img_loader,MiyaokaLightbox as miyaoka_lightbox,MiyaokaPrefetch as miyaoka_prefetch}; |
@@ -27,3 +27,3 @@ import { C as CSS, p as plt, w as win, a as promiseResolve, b as bootstrapLazy } from './index-a4c6996c.js'; | ||
return patchEsm().then(() => { | ||
return bootstrapLazy([["miyaoka-embed-tweet_4",[[0,"miyaoka-embed-tweet",{"src":[1]}],[1,"miyaoka-img-loader",{"src":[1],"alt":[1],"loading":[1],"scale":[2],"rotate":[2],"opacity":[2],"duration":[2],"delay":[2],"img":[32],"isLoaded":[32]}],[1,"miyaoka-lightbox",{"src":[1],"visible":[32]}],[1,"miyaoka-prefetch"]]]], options); | ||
return bootstrapLazy([["miyaoka-embed-tweet_4",[[0,"miyaoka-embed-tweet",{"src":[1]}],[1,"miyaoka-img-loader",{"src":[1],"alt":[1],"loading":[1],"scale":[2],"rotate":[2],"opacity":[2],"duration":[2],"delay":[2],"img":[32],"isLoaded":[32]}],[1,"miyaoka-lightbox",{"src":[1],"visible":[32]}],[1,"miyaoka-prefetch",{"appendedLinks":[32]}]]]], options); | ||
}); | ||
@@ -30,0 +30,0 @@ }; |
@@ -80,3 +80,3 @@ import { p as plt, w as win, d as doc, N as NAMESPACE, a as promiseResolve, b as bootstrapLazy } from './index-a4c6996c.js'; | ||
patchBrowser().then(options => { | ||
return bootstrapLazy([["miyaoka-embed-tweet_4",[[0,"miyaoka-embed-tweet",{"src":[1]}],[1,"miyaoka-img-loader",{"src":[1],"alt":[1],"loading":[1],"scale":[2],"rotate":[2],"opacity":[2],"duration":[2],"delay":[2],"img":[32],"isLoaded":[32]}],[1,"miyaoka-lightbox",{"src":[1],"visible":[32]}],[1,"miyaoka-prefetch"]]]], options); | ||
return bootstrapLazy([["miyaoka-embed-tweet_4",[[0,"miyaoka-embed-tweet",{"src":[1]}],[1,"miyaoka-img-loader",{"src":[1],"alt":[1],"loading":[1],"scale":[2],"rotate":[2],"opacity":[2],"duration":[2],"delay":[2],"img":[32],"isLoaded":[32]}],[1,"miyaoka-lightbox",{"src":[1],"visible":[32]}],[1,"miyaoka-prefetch",{"appendedLinks":[32]}]]]], options); | ||
}); |
@@ -128,15 +128,7 @@ import { r as registerInstance, h, H as Host, g as getElement } from './index-a4c6996c.js'; | ||
registerInstance(this, hostRef); | ||
this.appendedLinks = {}; | ||
} | ||
componentDidLoad() { | ||
const host = location.host; | ||
const linkList = Array.from(document.querySelectorAll('a[data-prefetch]')); | ||
const hrefMap = {}; | ||
const sameHostLinks = linkList.filter(({ href }) => { | ||
const url = new URL(href); | ||
if (url.host !== host || hrefMap[href]) | ||
return false; | ||
hrefMap[href] = true; | ||
return true; | ||
}); | ||
sameHostLinks.forEach((link) => { | ||
linkList.forEach((link) => { | ||
const observer = new IntersectionObserver((entryList) => { | ||
@@ -154,2 +146,5 @@ entryList.forEach((entry) => { | ||
addPrefetch(href) { | ||
if (this.appendedLinks[href]) | ||
return; | ||
this.appendedLinks[href] = true; | ||
const el = document.createElement('link'); | ||
@@ -156,0 +151,0 @@ el.rel = 'prefetch'; |
@@ -1,1 +0,1 @@ | ||
import{p as a,w as e,d as t,N as o,a as s,b as r}from"./p-45677803.js";(()=>{a.t=e.__cssshim;const r=Array.from(t.querySelectorAll("script")).find((a=>new RegExp(`/${o}(\\.esm)?\\.js($|\\?|#)`).test(a.src)||a.getAttribute("data-stencil-namespace")===o)),i=r["data-opts"]||{};return"onbeforeload"in r&&!history.scrollRestoration?{then(){}}:(i.resourcesUrl=new URL(".",new URL(r.getAttribute("data-resources-url")||r.src,e.location.href)).href,((a,s)=>{const r=`__sc_import_${o.replace(/\s|-/g,"_")}`;try{e[r]=new Function("w",`return import(w);//${Math.random()}`)}catch(i){const o=new Map;e[r]=i=>{const n=new URL(i,a).href;let c=o.get(n);if(!c){const a=t.createElement("script");a.type="module",a.crossOrigin=s.crossOrigin,a.src=URL.createObjectURL(new Blob([`import * as m from '${n}'; window.${r}.m = m;`],{type:"application/javascript"})),c=new Promise((t=>{a.onload=()=>{t(e[r].m),a.remove()}})),o.set(n,c),t.head.appendChild(a)}return c}}})(i.resourcesUrl,r),e.customElements?s(i):__sc_import_miyaoka_components("./p-db46d0d3.js").then((()=>i)))})().then((a=>r([["p-28e30639",[[0,"miyaoka-embed-tweet",{src:[1]}],[1,"miyaoka-img-loader",{src:[1],alt:[1],loading:[1],scale:[2],rotate:[2],opacity:[2],duration:[2],delay:[2],img:[32],isLoaded:[32]}],[1,"miyaoka-lightbox",{src:[1],visible:[32]}],[1,"miyaoka-prefetch"]]]],a))); | ||
import{p as a,w as e,d as t,N as o,a as s,b as i}from"./p-45677803.js";(()=>{a.t=e.__cssshim;const i=Array.from(t.querySelectorAll("script")).find((a=>new RegExp(`/${o}(\\.esm)?\\.js($|\\?|#)`).test(a.src)||a.getAttribute("data-stencil-namespace")===o)),r=i["data-opts"]||{};return"onbeforeload"in i&&!history.scrollRestoration?{then(){}}:(r.resourcesUrl=new URL(".",new URL(i.getAttribute("data-resources-url")||i.src,e.location.href)).href,((a,s)=>{const i=`__sc_import_${o.replace(/\s|-/g,"_")}`;try{e[i]=new Function("w",`return import(w);//${Math.random()}`)}catch(r){const o=new Map;e[i]=r=>{const n=new URL(r,a).href;let c=o.get(n);if(!c){const a=t.createElement("script");a.type="module",a.crossOrigin=s.crossOrigin,a.src=URL.createObjectURL(new Blob([`import * as m from '${n}'; window.${i}.m = m;`],{type:"application/javascript"})),c=new Promise((t=>{a.onload=()=>{t(e[i].m),a.remove()}})),o.set(n,c),t.head.appendChild(a)}return c}}})(r.resourcesUrl,i),e.customElements?s(r):__sc_import_miyaoka_components("./p-db46d0d3.js").then((()=>r)))})().then((a=>i([["p-8b774b22",[[0,"miyaoka-embed-tweet",{src:[1]}],[1,"miyaoka-img-loader",{src:[1],alt:[1],loading:[1],scale:[2],rotate:[2],opacity:[2],duration:[2],delay:[2],img:[32],isLoaded:[32]}],[1,"miyaoka-lightbox",{src:[1],visible:[32]}],[1,"miyaoka-prefetch",{appendedLinks:[32]}]]]],a))); |
@@ -1,1 +0,1 @@ | ||
System.register(["./p-154d9dcb.system.js"],(function(e,r){"use strict";var t,n,i,o,s,a;return{setters:[function(e){t=e.p;n=e.w;i=e.d;o=e.N;s=e.a;a=e.b}],execute:function(){var e=function(e){return"__sc_import_"+e.replace(/\s|-/g,"_")};var c=function(){{t.$cssShim$=n.__cssshim}var e=Array.from(i.querySelectorAll("script")).find((function(e){return new RegExp("/"+o+"(\\.esm)?\\.js($|\\?|#)").test(e.src)||e.getAttribute("data-stencil-namespace")===o}));var a=e["data-opts"]||{};if("onbeforeload"in e&&!history.scrollRestoration){return{then:function(){}}}{a.resourcesUrl=new URL(".",new URL(e.getAttribute("data-resources-url")||e.src,n.location.href)).href;{u(a.resourcesUrl,e)}if(!n.customElements){return r.import("./p-9b1d8162.system.js").then((function(){return a}))}}return s(a)};var u=function(r,t){var s=e(o);try{n[s]=new Function("w","return import(w);//"+Math.random())}catch(c){var a=new Map;n[s]=function(e){var o=new URL(e,r).href;var c=a.get(o);if(!c){var u=i.createElement("script");u.type="module";u.crossOrigin=t.crossOrigin;u.src=URL.createObjectURL(new Blob(["import * as m from '"+o+"'; window."+s+".m = m;"],{type:"application/javascript"}));c=new Promise((function(e){u.onload=function(){e(n[s].m);u.remove()}}));a.set(o,c);i.head.appendChild(u)}return c}}};c().then((function(e){return a([["p-c5f465f9.system",[[0,"miyaoka-embed-tweet",{src:[1]}],[1,"miyaoka-img-loader",{src:[1],alt:[1],loading:[1],scale:[2],rotate:[2],opacity:[2],duration:[2],delay:[2],img:[32],isLoaded:[32]}],[1,"miyaoka-lightbox",{src:[1],visible:[32]}],[1,"miyaoka-prefetch"]]]],e)}))}}})); | ||
System.register(["./p-154d9dcb.system.js"],(function(e,r){"use strict";var t,n,i,s,a,o;return{setters:[function(e){t=e.p;n=e.w;i=e.d;s=e.N;a=e.a;o=e.b}],execute:function(){var e=function(e){return"__sc_import_"+e.replace(/\s|-/g,"_")};var c=function(){{t.$cssShim$=n.__cssshim}var e=Array.from(i.querySelectorAll("script")).find((function(e){return new RegExp("/"+s+"(\\.esm)?\\.js($|\\?|#)").test(e.src)||e.getAttribute("data-stencil-namespace")===s}));var o=e["data-opts"]||{};if("onbeforeload"in e&&!history.scrollRestoration){return{then:function(){}}}{o.resourcesUrl=new URL(".",new URL(e.getAttribute("data-resources-url")||e.src,n.location.href)).href;{u(o.resourcesUrl,e)}if(!n.customElements){return r.import("./p-9b1d8162.system.js").then((function(){return o}))}}return a(o)};var u=function(r,t){var a=e(s);try{n[a]=new Function("w","return import(w);//"+Math.random())}catch(c){var o=new Map;n[a]=function(e){var s=new URL(e,r).href;var c=o.get(s);if(!c){var u=i.createElement("script");u.type="module";u.crossOrigin=t.crossOrigin;u.src=URL.createObjectURL(new Blob(["import * as m from '"+s+"'; window."+a+".m = m;"],{type:"application/javascript"}));c=new Promise((function(e){u.onload=function(){e(n[a].m);u.remove()}}));o.set(s,c);i.head.appendChild(u)}return c}}};c().then((function(e){return o([["p-c29ef7e4.system",[[0,"miyaoka-embed-tweet",{src:[1]}],[1,"miyaoka-img-loader",{src:[1],alt:[1],loading:[1],scale:[2],rotate:[2],opacity:[2],duration:[2],delay:[2],img:[32],isLoaded:[32]}],[1,"miyaoka-lightbox",{src:[1],visible:[32]}],[1,"miyaoka-prefetch",{appendedLinks:[32]}]]]],e)}))}}})); |
export declare class MiyaokaPrefetch { | ||
appendedLinks: {}; | ||
componentDidLoad(): void; | ||
addPrefetch(href: string): void; | ||
} |
{ | ||
"name": "@miyaoka/miyaoka-components", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Stencil Component Starter", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
748719
8148