@plotdb/csscope
Advanced tools
Comparing version
@@ -7,3 +7,3 @@ (function(){ | ||
_fetch = function(u, c){ | ||
if ((typeof fs != 'undefined' && fs !== null) && !/^https:/.exec(u)) { | ||
if (csp.__node && (typeof fs != 'undefined' && fs !== null) && !/^https:/.exec(u)) { | ||
return new Promise(function(res, rej){ | ||
@@ -10,0 +10,0 @@ return fs.readFile(u, function(e, b){ |
@@ -1,1 +0,1 @@ | ||
!function(){var t,g,s,f,x=[].slice;function o(e,t){var n,r={}.hasOwnProperty;for(n in t)r.call(t,n)&&(e[n]=t[n]);return e}g=function(e){return/^:scope[ .:\[#]|^:scope$/.exec(e)},s=function(e,t){return"undefined"==typeof fs||null===fs||/^https:/.exec(e)?fetch(e,t).then(function(i){var e;return i&&i.ok?i.text():i?i.clone().text().then(function(e){var t,n=i.status||404,r=new Error(n+" "+e);r.name="lderror",r.id=n,r.message=e,n=r;try{(t=JSON.parse(e))&&"lderror"===t.name&&(o(n,t).json=t)}catch(e){0}return Promise.reject(n)}):Promise.reject(((e=new Error("404")).name="lderror",e.id=404,e))}):new Promise(function(n,r){return fs.readFile(e,function(e,t){return e?r(e):n(t.toString())})})},(f=function(e,t,n,r){return(f.default=f.default?f.default:new f.converter).convert(e,t,n,r)}).env=function(e){e=[e,e.document];return t=e[1],e},f.id=function(e){var t=e.path||("js"===e.type?"index.min.js":"css"===e.type?"index.min.css":"index.html");return e.id||e.url||(e.ns?e.ns+":":"")+e.name+"@"+(e.version||"main")+":"+t},f.scope=function(e){return e.scope||"_"+btoa(f.id(e)).replace(/=/g,"_")},f._cache={},f._ver={map:{},list:{}},f.cache=function(e){var t,l,n,r,i,s,o,c,u,h,a;if((e="string"==typeof e?{url:e}:e).id||(e.id=f.id(e)),t=this._cache[e.id])return t;if(e.id&&!e.name?((i=e.id.split(":")).length<=2?(l=i[0],n=i[1],r=i[2]):(r=i[0],l=i[1],n=i[2]),s=(i=(i=/^(@?[^@]+)(?:@([^:]+))?$/.exec(l))?i:["",e.id,""])[1],o=i[2]):(r=(c=[e.ns,e.name,e.version||"",e.path||""])[0],s=c[1],o=c[2],n=c[3]),/^[0-9.]+$/.exec(o)){if((t=((c=this._ver.map)[s]||(c[s]={}))[o])&&(o=t),t=this._cache[f.id({name:s,version:o,path:n})])return t;for(u=0,h=((c=this._ver.list)[s]||(c[s]=[])).length;u<h;++u)if(a=u,a=this._ver.list[s][a],semver.fit(a,o)&&(this._ver.map[s][o]=a,e.id=f.id({ns:r,name:s,version:a,path:n}),t=this._cache[e.id]))return t}return function(e,t){var n=-1,r=t.length>>>0;for(;++n<r;)if(e===t[n])return!0;return!1}(o,(c=this._ver.list)[s]||(c[s]=[]))||this._ver.list[s].push(o),this._cache[e.id]=e},(f.converter=function(e){return this.scopeTest=(e=null==e?{}:e).scopeTest,this.node=t.createElement("style"),this.iframe=e=t.createElement("iframe"),e.setAttribute("title","for csscope parsing"),e.style.display="none",e.src="about:blank",t.body.appendChild(e),this.iframe.contentDocument.body.appendChild(this.node),this._idx=0,this}).prototype=o(Object.create(Object.prototype),{getNames:function(e,t){var n,r,i;for(null==t&&(t={}),n=0,r=e.length;n<r;++n)(i=e[n]).name?t[i.name]=!0:i.cssRules&&this.getNames(i.cssRules,t);return t},_convert:function(e,i,t,s,n){var r,o,c,u,a,l;for(null==n&&(n={}),r="",o=0,c=e.length;o<c;++o)(u=e[o]).style&&(n[u.style.animationName]?u.style.animationName=t+"__"+u.style.animationName:u.style.animation&&(u.style.animation=u.style.animation.split(" ").map(h).join(" "))),u.selectorText?(r+=(a=(s?u.selectorText.split(",").map(d).map(m):u.selectorText.split(",").map(f).map(p)).join(","))+"{"+u.style.cssText+"}",u.selectorText=a):u.name?(a=u.name.split(",").map(y).map(v).join(","),r+="@keyframes "+(u.name=a)+" {\n "+Array.from(u.cssRules).map(_).join("\n")+"\n}"):u.cssRules&&(l=this._convert(u.cssRules,i,t,s,n),r+="@media "+u.conditionText+" {\n "+l+"\n}");return r;function h(e){return n[e]?t+"__"+e:e}function f(e){return e.trim()}function p(e){return g(e)?e.replace(/^:scope/,i):i+" "+e}function d(e){return e.trim()}function m(e){var t,n,r;return g(e)?e.replace(/^:scope/,i):(n=(r=e.split(" ").map(function(e){return e.trim()}).filter(function(e){return e}))[0],t=x.call(r,1),n=(r=/^[a-zA-Z]/.exec(n)?[n,""]:["",n])[0],r=r[1],/:[a-z-]+$/.exec(e)?i+" :not("+s+") "+e+","+i+" > "+n+r+" "+t.join(" "):i+" :not("+s+") "+e+","+i+" > "+n+":not("+s+")"+r+" "+t.join(" "))}function y(e){return e.trim()}function v(e){return t+"__"+e}function _(e){return e.cssText}},convert:function(e,t,n,r){var i,e="object"==typeof e?e:{name:e,css:t,rule:n,scopeTest:r},t=e.name,n=e.css,r=e.rule,e=e.scopeTest;return r=r||"."+t,t=t||r,e=e||this.scopeTest,n="object"==typeof n?n:(this.node.textContent=(n||"")+("/*"+this._idx++)+"*/",this.node.sheet.cssRules),i=this.getNames(n,{}),this._convert(n,r,t,e,i)||""}}),(f.manager=function(e){return null==e&&(e={}),this.attrName="csscope",this._cache={},this.converter=new f.converter,this.counter=0,this.registry(e.registry||"/assets/lib/"),this.init(),this}).prototype=o(Object.create(Object.prototype),{cache:function(e){var t;return(e="string"==typeof e?{url:e}:e).id||(e.id=f.id(e)),(t=this._cache[e.id])?t:this._cache[e.id]=f.cache(e)},_ref:function(e){var t,n;return"string"==typeof e&&(e={url:e}),"function"==typeof(t=this._reg.url||this._reg)&&((n=o({},e)).url=t(e),e=n),this._reg.fetch?this._reg.fetch(e):e.url},registry:function(e){return"string"==typeof e?("/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),this._reg=(t=e,function(e){return t+"/"+e.name+"/"+(e.version||"main")+"/"+(e.path||"index.min.css")})):this._reg=e;var t},init:function(){if(!this.inited)return this.inited=!0,this.styleNode=t.createElement("style"),this.styleNode.setAttribute("type","text/css"),this.styleNode.setAttribute("data-name","csscope.manager"),this.styleContent=[],t.body.appendChild(this.styleNode)},scope:function(e,t){t=this.get(t=null==t?[]:t);return e.classList.add.apply(e.classList,t.map(function(e){return e.scope})),t},get:function(e){var t=this;return null==e&&(e=[]),(Array.isArray(e)?e:[e]).map(function(e){return t.cache(e)}).filter(function(e){return e.scope})},load:function(e,n,t){var r,i=this;return e=(Array.isArray(e)?e:[e]).map(function(e){return i.cache(e)}),r=[],Promise.all(e.map(function(t){var e;return t.inited?Promise.resolve():t.scope&&t.code?(t.inited=!0,r.push(t.code),Promise.resolve()):((e=i._ref(t)).then?e.then(function(e){return i.cache((t.id=void 0,t.version=e.version,t)),e}):s(e,{method:"GET"}).then(function(e){return{content:e}})).then(function(e){e=e.content;return t.inited=!0,t.scope=f.scope(t),t.code=i.converter.convert({css:e,name:t.scope,scopeTest:n}),r.push(t.code)})})).then(function(){return t?e:(i.styleContent.push.apply(i.styleContent,r),i.styleNode.textContent=i.styleContent.join("\n"),i.get(e))})}}),f.env("undefined"!=typeof self&&null!==self?self:globalThis),f.manager.prototype.bundle=function(e,t){var n,r,i,s,o=this;for(i in e=Array.isArray(e)?e:[e],n={},e.map(function(e){return o.cache(e)}).filter(function(e){return e&&e.id}).map(function(e){return n[e.id]=e}),r=[],n)s=n[i],r.push(s);return e=r,this.load(e,t,!0).then(function(e){return e.map(function(e){return e.code}).join("\n")})},"undefined"!=typeof module&&null!==module?module.exports=f:"undefined"!=typeof window&&null!==window&&(window.csscope=f)}(); | ||
!function(){var t,g,s,f,x=[].slice;function o(e,t){var n,r={}.hasOwnProperty;for(n in t)r.call(t,n)&&(e[n]=t[n]);return e}g=function(e){return/^:scope[ .:\[#]|^:scope$/.exec(e)},s=function(e,t){return f.__node&&"undefined"!=typeof fs&&null!==fs&&!/^https:/.exec(e)?new Promise(function(n,r){return fs.readFile(e,function(e,t){return e?r(e):n(t.toString())})}):fetch(e,t).then(function(i){var e;return i&&i.ok?i.text():i?i.clone().text().then(function(e){var t,n=i.status||404,r=new Error(n+" "+e);r.name="lderror",r.id=n,r.message=e,n=r;try{(t=JSON.parse(e))&&"lderror"===t.name&&(o(n,t).json=t)}catch(e){0}return Promise.reject(n)}):Promise.reject(((e=new Error("404")).name="lderror",e.id=404,e))})},(f=function(e,t,n,r){return f.default||(f.default=new f.converter),f.default.convert(e,t,n,r)}).env=function(e){e=[e,e.document];return t=e[1],e},f.id=function(e){var t=e.path||("js"===e.type?"index.min.js":"css"===e.type?"index.min.css":"index.html");return e.id||e.url||(e.ns?e.ns+":":"")+e.name+"@"+(e.version||"main")+":"+t},f.scope=function(e){return e.scope||"_"+btoa(f.id(e)).replace(/=/g,"_")},f._cache={},f._ver={map:{},list:{}},f.cache=function(e){var t,l,n,r,i,s,o,c,a,h,u;if((e="string"==typeof e?{url:e}:e).id||(e.id=f.id(e)),t=this._cache[e.id])return t;if(e.id&&!e.name?((i=e.id.split(":")).length<=2?(l=i[0],n=i[1],r=i[2]):(r=i[0],l=i[1],n=i[2]),s=(i=(i=/^(@?[^@]+)(?:@([^:]+))?$/.exec(l))?i:["",e.id,""])[1],o=i[2]):(r=(c=[e.ns,e.name,e.version||"",e.path||""])[0],s=c[1],o=c[2],n=c[3]),/^[0-9.]+$/.exec(o)){if((t=((c=this._ver.map)[s]||(c[s]={}))[o])&&(o=t),t=this._cache[f.id({name:s,version:o,path:n})])return t;for(a=0,h=((c=this._ver.list)[s]||(c[s]=[])).length;a<h;++a)if(u=a,u=this._ver.list[s][u],semver.fit(u,o)&&(this._ver.map[s][o]=u,e.id=f.id({ns:r,name:s,version:u,path:n}),t=this._cache[e.id]))return t}return function(e,t){var n=-1,r=t.length>>>0;for(;++n<r;)if(e===t[n])return!0;return!1}(o,(c=this._ver.list)[s]||(c[s]=[]))||this._ver.list[s].push(o),this._cache[e.id]=e},f.converter=function(e){return this.scopeTest=(e=null==e?{}:e).scopeTest,this.node=t.createElement("style"),this.iframe=e=t.createElement("iframe"),e.setAttribute("title","for csscope parsing"),e.style.display="none",e.src="about:blank",t.body.appendChild(e),this.iframe.contentDocument.body.appendChild(this.node),this._idx=0,this},f.converter.prototype=o(Object.create(Object.prototype),{getNames:function(e,t){var n,r,i;for(null==t&&(t={}),n=0,r=e.length;n<r;++n)(i=e[n]).name?t[i.name]=!0:i.cssRules&&this.getNames(i.cssRules,t);return t},_convert:function(e,i,t,s,n){var r,o,c,a,u,l;for(null==n&&(n={}),r="",o=0,c=e.length;o<c;++o)(a=e[o]).style&&(n[a.style.animationName]?a.style.animationName=t+"__"+a.style.animationName:a.style.animation&&(a.style.animation=a.style.animation.split(" ").map(h).join(" "))),a.selectorText?(r+=(u=(s?a.selectorText.split(",").map(d).map(m):a.selectorText.split(",").map(f).map(p)).join(","))+"{"+a.style.cssText+"}",a.selectorText=u):a.name?(u=a.name.split(",").map(y).map(v).join(","),r+="@keyframes "+(a.name=u)+" {\n "+Array.from(a.cssRules).map(_).join("\n")+"\n}"):a.cssRules&&(l=this._convert(a.cssRules,i,t,s,n),r+="@media "+a.conditionText+" {\n "+l+"\n}");return r;function h(e){return n[e]?t+"__"+e:e}function f(e){return e.trim()}function p(e){return g(e)?e.replace(/^:scope/,i):i+" "+e}function d(e){return e.trim()}function m(e){var t,n,r;return g(e)?e.replace(/^:scope/,i):(n=(r=e.split(" ").map(function(e){return e.trim()}).filter(function(e){return e}))[0],t=x.call(r,1),n=(r=/^[a-zA-Z]/.exec(n)?[n,""]:["",n])[0],r=r[1],/:[a-z-]+$/.exec(e)?i+" :not("+s+") "+e+","+i+" > "+n+r+" "+t.join(" "):i+" :not("+s+") "+e+","+i+" > "+n+":not("+s+")"+r+" "+t.join(" "))}function y(e){return e.trim()}function v(e){return t+"__"+e}function _(e){return e.cssText}},convert:function(e,t,n,r){var i,e="object"==typeof e?e:{name:e,css:t,rule:n,scopeTest:r},t=e.name,n=e.css,r=e.rule,e=e.scopeTest;return r=r||"."+t,t=t||r,e=e||this.scopeTest,n="object"==typeof n?n:(this.node.textContent=(n||"")+("/*"+this._idx++)+"*/",this.node.sheet.cssRules),i=this.getNames(n,{}),this._convert(n,r,t,e,i)||""}}),f.manager=function(e){return null==e&&(e={}),this.attrName="csscope",this._cache={},this.converter=new f.converter,this.counter=0,this.registry(e.registry||"/assets/lib/"),this.init(),this},f.manager.prototype=o(Object.create(Object.prototype),{cache:function(e){var t;return(e="string"==typeof e?{url:e}:e).id||(e.id=f.id(e)),(t=this._cache[e.id])?t:this._cache[e.id]=f.cache(e)},_ref:function(e){var t,n;return"string"==typeof e&&(e={url:e}),"function"==typeof(t=this._reg.url||this._reg)&&((n=o({},e)).url=t(e),e=n),this._reg.fetch?this._reg.fetch(e):e.url},registry:function(e){return"string"==typeof e?("/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),this._reg=(t=e,function(e){return t+"/"+e.name+"/"+(e.version||"main")+"/"+(e.path||"index.min.css")})):this._reg=e;var t},init:function(){if(!this.inited)return this.inited=!0,this.styleNode=t.createElement("style"),this.styleNode.setAttribute("type","text/css"),this.styleNode.setAttribute("data-name","csscope.manager"),this.styleContent=[],t.body.appendChild(this.styleNode)},scope:function(e,t){t=this.get(t=null==t?[]:t);return e.classList.add.apply(e.classList,t.map(function(e){return e.scope})),t},get:function(e){var t=this;return null==e&&(e=[]),(Array.isArray(e)?e:[e]).map(function(e){return t.cache(e)}).filter(function(e){return e.scope})},load:function(e,n,t){var r,i=this;return e=(Array.isArray(e)?e:[e]).map(function(e){return i.cache(e)}),r=[],Promise.all(e.map(function(t){var e;return t.inited?Promise.resolve():t.scope&&t.code?(t.inited=!0,r.push(t.code),Promise.resolve()):((e=i._ref(t)).then?e.then(function(e){return i.cache((t.id=void 0,t.version=e.version,t)),e}):s(e,{method:"GET"}).then(function(e){return{content:e}})).then(function(e){e=e.content;return t.inited=!0,t.scope=f.scope(t),t.code=i.converter.convert({css:e,name:t.scope,scopeTest:n}),r.push(t.code)})})).then(function(){return t?e:(i.styleContent.push.apply(i.styleContent,r),i.styleNode.textContent=i.styleContent.join("\n"),i.get(e))})}}),f.env("undefined"!=typeof self&&null!==self?self:globalThis),f.manager.prototype.bundle=function(e,t){var n,r,i,s,o=this;for(i in e=Array.isArray(e)?e:[e],n={},e.map(function(e){return o.cache(e)}).filter(function(e){return e&&e.id}).map(function(e){return n[e.id]=e}),r=[],n)s=n[i],r.push(s);return e=r,this.load(e,t,!0).then(function(e){return e.map(function(e){return e.code}).join("\n")})},"undefined"!=typeof module&&null!==module?module.exports=f:"undefined"!=typeof window&&null!==window&&(window.csscope=f)}(); |
# Change Logs | ||
## v5.0.2 | ||
- fix bug: will try using `fs` once defined even in browser. | ||
## v5.0.1 | ||
@@ -4,0 +9,0 @@ |
@@ -7,3 +7,3 @@ (function(){ | ||
_fetch = function(u, c){ | ||
if ((typeof fs != 'undefined' && fs !== null) && !/^https:/.exec(u)) { | ||
if (csp.__node && (typeof fs != 'undefined' && fs !== null) && !/^https:/.exec(u)) { | ||
return new Promise(function(res, rej){ | ||
@@ -10,0 +10,0 @@ return fs.readFile(u, function(e, b){ |
@@ -1,1 +0,1 @@ | ||
!function(){var t,g,s,f,x=[].slice;function o(e,t){var n,r={}.hasOwnProperty;for(n in t)r.call(t,n)&&(e[n]=t[n]);return e}g=function(e){return/^:scope[ .:\[#]|^:scope$/.exec(e)},s=function(e,t){return"undefined"==typeof fs||null===fs||/^https:/.exec(e)?fetch(e,t).then(function(i){var e;return i&&i.ok?i.text():i?i.clone().text().then(function(e){var t,n=i.status||404,r=new Error(n+" "+e);r.name="lderror",r.id=n,r.message=e,n=r;try{(t=JSON.parse(e))&&"lderror"===t.name&&(o(n,t).json=t)}catch(e){0}return Promise.reject(n)}):Promise.reject(((e=new Error("404")).name="lderror",e.id=404,e))}):new Promise(function(n,r){return fs.readFile(e,function(e,t){return e?r(e):n(t.toString())})})},(f=function(e,t,n,r){return(f.default=f.default?f.default:new f.converter).convert(e,t,n,r)}).env=function(e){e=[e,e.document];return t=e[1],e},f.id=function(e){var t=e.path||("js"===e.type?"index.min.js":"css"===e.type?"index.min.css":"index.html");return e.id||e.url||(e.ns?e.ns+":":"")+e.name+"@"+(e.version||"main")+":"+t},f.scope=function(e){return e.scope||"_"+btoa(f.id(e)).replace(/=/g,"_")},f._cache={},f._ver={map:{},list:{}},f.cache=function(e){var t,l,n,r,i,s,o,c,a,h,u;if((e="string"==typeof e?{url:e}:e).id||(e.id=f.id(e)),t=this._cache[e.id])return t;if(e.id&&!e.name?((i=e.id.split(":")).length<=2?(l=i[0],n=i[1],r=i[2]):(r=i[0],l=i[1],n=i[2]),s=(i=(i=/^(@?[^@]+)(?:@([^:]+))?$/.exec(l))?i:["",e.id,""])[1],o=i[2]):(r=(c=[e.ns,e.name,e.version||"",e.path||""])[0],s=c[1],o=c[2],n=c[3]),/^[0-9.]+$/.exec(o)){if((t=((c=this._ver.map)[s]||(c[s]={}))[o])&&(o=t),t=this._cache[f.id({name:s,version:o,path:n})])return t;for(a=0,h=((c=this._ver.list)[s]||(c[s]=[])).length;a<h;++a)if(u=a,u=this._ver.list[s][u],semver.fit(u,o)&&(this._ver.map[s][o]=u,e.id=f.id({ns:r,name:s,version:u,path:n}),t=this._cache[e.id]))return t}return function(e,t){var n=-1,r=t.length>>>0;for(;++n<r;)if(e===t[n])return!0;return!1}(o,(c=this._ver.list)[s]||(c[s]=[]))||this._ver.list[s].push(o),this._cache[e.id]=e},(f.converter=function(e){return this.scopeTest=(e=null==e?{}:e).scopeTest,this.node=t.createElement("style"),this.iframe=e=t.createElement("iframe"),e.setAttribute("title","for csscope parsing"),e.style.display="none",e.src="about:blank",t.body.appendChild(e),this.iframe.contentDocument.body.appendChild(this.node),this._idx=0,this}).prototype=o(Object.create(Object.prototype),{getNames:function(e,t){var n,r,i;for(null==t&&(t={}),n=0,r=e.length;n<r;++n)(i=e[n]).name?t[i.name]=!0:i.cssRules&&this.getNames(i.cssRules,t);return t},_convert:function(e,i,t,s,n){var r,o,c,a,u,l;for(null==n&&(n={}),r="",o=0,c=e.length;o<c;++o)(a=e[o]).style&&(n[a.style.animationName]?a.style.animationName=t+"__"+a.style.animationName:a.style.animation&&(a.style.animation=a.style.animation.split(" ").map(h).join(" "))),a.selectorText?(r+=(u=(s?a.selectorText.split(",").map(d).map(m):a.selectorText.split(",").map(f).map(p)).join(","))+"{"+a.style.cssText+"}",a.selectorText=u):a.name?(u=a.name.split(",").map(y).map(v).join(","),r+="@keyframes "+(a.name=u)+" {\n "+Array.from(a.cssRules).map(_).join("\n")+"\n}"):a.cssRules&&(l=this._convert(a.cssRules,i,t,s,n),r+="@media "+a.conditionText+" {\n "+l+"\n}");return r;function h(e){return n[e]?t+"__"+e:e}function f(e){return e.trim()}function p(e){return g(e)?e.replace(/^:scope/,i):i+" "+e}function d(e){return e.trim()}function m(e){var t,n,r;return g(e)?e.replace(/^:scope/,i):(n=(r=e.split(" ").map(function(e){return e.trim()}).filter(function(e){return e}))[0],t=x.call(r,1),n=(r=/^[a-zA-Z]/.exec(n)?[n,""]:["",n])[0],r=r[1],/:[a-z-]+$/.exec(e)?i+" :not("+s+") "+e+","+i+" > "+n+r+" "+t.join(" "):i+" :not("+s+") "+e+","+i+" > "+n+":not("+s+")"+r+" "+t.join(" "))}function y(e){return e.trim()}function v(e){return t+"__"+e}function _(e){return e.cssText}},convert:function(e,t,n,r){var i,e="object"==typeof e?e:{name:e,css:t,rule:n,scopeTest:r},t=e.name,n=e.css,r=e.rule,e=e.scopeTest;return r=r||"."+t,t=t||r,e=e||this.scopeTest,n="object"==typeof n?n:(this.node.textContent=(n||"")+("/*"+this._idx++)+"*/",this.node.sheet.cssRules),i=this.getNames(n,{}),this._convert(n,r,t,e,i)||""}}),(f.manager=function(e){return null==e&&(e={}),this.attrName="csscope",this._cache={},this.converter=new f.converter,this.counter=0,this.registry(e.registry||"/assets/lib/"),this.init(),this}).prototype=o(Object.create(Object.prototype),{cache:function(e){var t;return(e="string"==typeof e?{url:e}:e).id||(e.id=f.id(e)),(t=this._cache[e.id])?t:this._cache[e.id]=f.cache(e)},_ref:function(e){var t,n;return"string"==typeof e&&(e={url:e}),"function"==typeof(t=this._reg.url||this._reg)&&((n=o({},e)).url=t(e),e=n),this._reg.fetch?this._reg.fetch(e):e.url},registry:function(e){return"string"==typeof e?("/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),this._reg=(t=e,function(e){return t+"/"+e.name+"/"+(e.version||"main")+"/"+(e.path||"index.min.css")})):this._reg=e;var t},init:function(){if(!this.inited)return this.inited=!0,this.styleNode=t.createElement("style"),this.styleNode.setAttribute("type","text/css"),this.styleNode.setAttribute("data-name","csscope.manager"),this.styleContent=[],t.body.appendChild(this.styleNode)},scope:function(e,t){t=this.get(t=null==t?[]:t);return e.classList.add.apply(e.classList,t.map(function(e){return e.scope})),t},get:function(e){var t=this;return null==e&&(e=[]),(Array.isArray(e)?e:[e]).map(function(e){return t.cache(e)}).filter(function(e){return e.scope})},load:function(e,n,t){var r,i=this;return e=(Array.isArray(e)?e:[e]).map(function(e){return i.cache(e)}),r=[],Promise.all(e.map(function(t){var e;return t.inited?Promise.resolve():t.scope&&t.code?(t.inited=!0,r.push(t.code),Promise.resolve()):((e=i._ref(t)).then?e.then(function(e){return i.cache((t.id=void 0,t.version=e.version,t)),e}):s(e,{method:"GET"}).then(function(e){return{content:e}})).then(function(e){e=e.content;return t.inited=!0,t.scope=f.scope(t),t.code=i.converter.convert({css:e,name:t.scope,scopeTest:n}),r.push(t.code)})})).then(function(){return t?e:(i.styleContent.push.apply(i.styleContent,r),i.styleNode.textContent=i.styleContent.join("\n"),i.get(e))})}}),f.env("undefined"!=typeof self&&null!==self?self:globalThis),"undefined"!=typeof module&&null!==module?module.exports=f:"undefined"!=typeof window&&null!==window&&(window.csscope=f)}(); | ||
!function(){var t,g,s,f,x=[].slice;function o(e,t){var n,r={}.hasOwnProperty;for(n in t)r.call(t,n)&&(e[n]=t[n]);return e}g=function(e){return/^:scope[ .:\[#]|^:scope$/.exec(e)},s=function(e,t){return f.__node&&"undefined"!=typeof fs&&null!==fs&&!/^https:/.exec(e)?new Promise(function(n,r){return fs.readFile(e,function(e,t){return e?r(e):n(t.toString())})}):fetch(e,t).then(function(i){var e;return i&&i.ok?i.text():i?i.clone().text().then(function(e){var t,n=i.status||404,r=new Error(n+" "+e);r.name="lderror",r.id=n,r.message=e,n=r;try{(t=JSON.parse(e))&&"lderror"===t.name&&(o(n,t).json=t)}catch(e){0}return Promise.reject(n)}):Promise.reject(((e=new Error("404")).name="lderror",e.id=404,e))})},(f=function(e,t,n,r){return f.default||(f.default=new f.converter),f.default.convert(e,t,n,r)}).env=function(e){e=[e,e.document];return t=e[1],e},f.id=function(e){var t=e.path||("js"===e.type?"index.min.js":"css"===e.type?"index.min.css":"index.html");return e.id||e.url||(e.ns?e.ns+":":"")+e.name+"@"+(e.version||"main")+":"+t},f.scope=function(e){return e.scope||"_"+btoa(f.id(e)).replace(/=/g,"_")},f._cache={},f._ver={map:{},list:{}},f.cache=function(e){var t,l,n,r,i,s,o,c,a,h,u;if((e="string"==typeof e?{url:e}:e).id||(e.id=f.id(e)),t=this._cache[e.id])return t;if(e.id&&!e.name?((i=e.id.split(":")).length<=2?(l=i[0],n=i[1],r=i[2]):(r=i[0],l=i[1],n=i[2]),s=(i=(i=/^(@?[^@]+)(?:@([^:]+))?$/.exec(l))?i:["",e.id,""])[1],o=i[2]):(r=(c=[e.ns,e.name,e.version||"",e.path||""])[0],s=c[1],o=c[2],n=c[3]),/^[0-9.]+$/.exec(o)){if((t=((c=this._ver.map)[s]||(c[s]={}))[o])&&(o=t),t=this._cache[f.id({name:s,version:o,path:n})])return t;for(a=0,h=((c=this._ver.list)[s]||(c[s]=[])).length;a<h;++a)if(u=a,u=this._ver.list[s][u],semver.fit(u,o)&&(this._ver.map[s][o]=u,e.id=f.id({ns:r,name:s,version:u,path:n}),t=this._cache[e.id]))return t}return function(e,t){var n=-1,r=t.length>>>0;for(;++n<r;)if(e===t[n])return!0;return!1}(o,(c=this._ver.list)[s]||(c[s]=[]))||this._ver.list[s].push(o),this._cache[e.id]=e},f.converter=function(e){return this.scopeTest=(e=null==e?{}:e).scopeTest,this.node=t.createElement("style"),this.iframe=e=t.createElement("iframe"),e.setAttribute("title","for csscope parsing"),e.style.display="none",e.src="about:blank",t.body.appendChild(e),this.iframe.contentDocument.body.appendChild(this.node),this._idx=0,this},f.converter.prototype=o(Object.create(Object.prototype),{getNames:function(e,t){var n,r,i;for(null==t&&(t={}),n=0,r=e.length;n<r;++n)(i=e[n]).name?t[i.name]=!0:i.cssRules&&this.getNames(i.cssRules,t);return t},_convert:function(e,i,t,s,n){var r,o,c,a,u,l;for(null==n&&(n={}),r="",o=0,c=e.length;o<c;++o)(a=e[o]).style&&(n[a.style.animationName]?a.style.animationName=t+"__"+a.style.animationName:a.style.animation&&(a.style.animation=a.style.animation.split(" ").map(h).join(" "))),a.selectorText?(r+=(u=(s?a.selectorText.split(",").map(d).map(m):a.selectorText.split(",").map(f).map(p)).join(","))+"{"+a.style.cssText+"}",a.selectorText=u):a.name?(u=a.name.split(",").map(y).map(v).join(","),r+="@keyframes "+(a.name=u)+" {\n "+Array.from(a.cssRules).map(_).join("\n")+"\n}"):a.cssRules&&(l=this._convert(a.cssRules,i,t,s,n),r+="@media "+a.conditionText+" {\n "+l+"\n}");return r;function h(e){return n[e]?t+"__"+e:e}function f(e){return e.trim()}function p(e){return g(e)?e.replace(/^:scope/,i):i+" "+e}function d(e){return e.trim()}function m(e){var t,n,r;return g(e)?e.replace(/^:scope/,i):(n=(r=e.split(" ").map(function(e){return e.trim()}).filter(function(e){return e}))[0],t=x.call(r,1),n=(r=/^[a-zA-Z]/.exec(n)?[n,""]:["",n])[0],r=r[1],/:[a-z-]+$/.exec(e)?i+" :not("+s+") "+e+","+i+" > "+n+r+" "+t.join(" "):i+" :not("+s+") "+e+","+i+" > "+n+":not("+s+")"+r+" "+t.join(" "))}function y(e){return e.trim()}function v(e){return t+"__"+e}function _(e){return e.cssText}},convert:function(e,t,n,r){var i,e="object"==typeof e?e:{name:e,css:t,rule:n,scopeTest:r},t=e.name,n=e.css,r=e.rule,e=e.scopeTest;return r=r||"."+t,t=t||r,e=e||this.scopeTest,n="object"==typeof n?n:(this.node.textContent=(n||"")+("/*"+this._idx++)+"*/",this.node.sheet.cssRules),i=this.getNames(n,{}),this._convert(n,r,t,e,i)||""}}),f.manager=function(e){return null==e&&(e={}),this.attrName="csscope",this._cache={},this.converter=new f.converter,this.counter=0,this.registry(e.registry||"/assets/lib/"),this.init(),this},f.manager.prototype=o(Object.create(Object.prototype),{cache:function(e){var t;return(e="string"==typeof e?{url:e}:e).id||(e.id=f.id(e)),(t=this._cache[e.id])?t:this._cache[e.id]=f.cache(e)},_ref:function(e){var t,n;return"string"==typeof e&&(e={url:e}),"function"==typeof(t=this._reg.url||this._reg)&&((n=o({},e)).url=t(e),e=n),this._reg.fetch?this._reg.fetch(e):e.url},registry:function(e){return"string"==typeof e?("/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),this._reg=(t=e,function(e){return t+"/"+e.name+"/"+(e.version||"main")+"/"+(e.path||"index.min.css")})):this._reg=e;var t},init:function(){if(!this.inited)return this.inited=!0,this.styleNode=t.createElement("style"),this.styleNode.setAttribute("type","text/css"),this.styleNode.setAttribute("data-name","csscope.manager"),this.styleContent=[],t.body.appendChild(this.styleNode)},scope:function(e,t){t=this.get(t=null==t?[]:t);return e.classList.add.apply(e.classList,t.map(function(e){return e.scope})),t},get:function(e){var t=this;return null==e&&(e=[]),(Array.isArray(e)?e:[e]).map(function(e){return t.cache(e)}).filter(function(e){return e.scope})},load:function(e,n,t){var r,i=this;return e=(Array.isArray(e)?e:[e]).map(function(e){return i.cache(e)}),r=[],Promise.all(e.map(function(t){var e;return t.inited?Promise.resolve():t.scope&&t.code?(t.inited=!0,r.push(t.code),Promise.resolve()):((e=i._ref(t)).then?e.then(function(e){return i.cache((t.id=void 0,t.version=e.version,t)),e}):s(e,{method:"GET"}).then(function(e){return{content:e}})).then(function(e){e=e.content;return t.inited=!0,t.scope=f.scope(t),t.code=i.converter.convert({css:e,name:t.scope,scopeTest:n}),r.push(t.code)})})).then(function(){return t?e:(i.styleContent.push.apply(i.styleContent,r),i.styleNode.textContent=i.styleContent.join("\n"),i.get(e))})}}),f.env("undefined"!=typeof self&&null!==self?self:globalThis),"undefined"!=typeof module&&null!==module?module.exports=f:"undefined"!=typeof window&&null!==window&&(window.csscope=f)}(); |
@@ -13,3 +13,3 @@ var semver, fetch, fs; | ||
_fetch = function(u, c){ | ||
if ((typeof fs != 'undefined' && fs !== null) && !/^https:/.exec(u)) { | ||
if (csp.__node && (typeof fs != 'undefined' && fs !== null) && !/^https:/.exec(u)) { | ||
return new Promise(function(res, rej){ | ||
@@ -448,3 +448,4 @@ return fs.readFile(u, function(e, b){ | ||
}); | ||
};if (typeof module != 'undefined' && module !== null) { | ||
};csp.__node = true; | ||
if (typeof module != 'undefined' && module !== null) { | ||
module.exports = csp; | ||
@@ -451,0 +452,0 @@ } else if (typeof window != 'undefined' && window !== null) { |
@@ -1,1 +0,1 @@ | ||
{"author":"zbryikt","name":"@plotdb/csscope","license":"MIT","description":"add scope to any css code","version":"5.0.1","homepage":"https://github.com/plotdb/csscope","browser":"index.min.js","main":"node.js","repository":{"type":"git","url":"https://github.com/plotdb/csscope"},"engines":{"node":">=10.14.1","npm":">=6.4.1"},"scripts":{"start":"npx server -r web -o true"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.4","@loadingio/debounce.js":"^1.0.1","@loadingio/ldquery":"^3.0.4","@zbryikt/template":"^2.3.42","bootstrap":"^4.5.2","bootstrap.native":"^3.0.13","fedep":"^1.1.7","jsdom":"^19.0.0","ldcover":"^3.0.1","ldview":"^1.0.0","livescript":"^1.6.0","puppeteer-core":"^13.2.0","uglify-js":"^3.13.1"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["bootstrap","bootstrap.native","@loadingio/bootstrap.ext","@loadingio/ldquery","@loadingio/debounce.js","@plotdb/semver","ldview","ldcover"]},"dependencies":{"@plotdb/semver":"^0.0.2","node-fetch":"^2.6.7"}} | ||
{"author":"zbryikt","name":"@plotdb/csscope","license":"MIT","description":"add scope to any css code","version":"5.0.2","homepage":"https://github.com/plotdb/csscope","browser":"index.min.js","main":"node.js","repository":{"type":"git","url":"https://github.com/plotdb/csscope"},"engines":{"node":">=10.14.1","npm":">=6.4.1"},"scripts":{"start":"npx server -r web -o true"},"devDependencies":{"@loadingio/bootstrap.ext":"^0.0.4","@loadingio/debounce.js":"^1.0.1","@loadingio/ldquery":"^3.0.4","@zbryikt/template":"^2.3.42","bootstrap":"^4.5.2","bootstrap.native":"^3.0.13","fedep":"^1.1.7","jsdom":"^19.0.0","ldcover":"^3.0.1","ldview":"^1.0.0","livescript":"^1.6.0","puppeteer-core":"^13.2.0","uglify-js":"^3.13.1"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["bootstrap","bootstrap.native","@loadingio/bootstrap.ext","@loadingio/ldquery","@loadingio/debounce.js","@plotdb/semver","ldview","ldcover"]},"dependencies":{"@plotdb/semver":"^0.0.2","node-fetch":"^2.6.7"}} |
57970
0.35%1368
0.07%