@unocss/runtime 0.45.26 → 0.45.28
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/attributify.global.js +3 -3
- package/core.global.js +2 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -7
- package/dist/index.mjs +8 -7
- package/full.global.js +3 -3
- package/mini.global.js +3 -3
- package/package.json +4 -4
- package/uno.global.js +3 -3
package/core.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{function vt(e){let t=e.length,r=-1,n,s="",i=e.charCodeAt(0);for(;++r<t;){if(n=e.charCodeAt(r),n===0){s+="\uFFFD";continue}if(n===44){s+="\\,";continue}if(n>=1&&n<=31||n===127||r===0&&n>=48&&n<=57||r===1&&n>=48&&n<=57&&i===45){s+=`\\${n.toString(16)} `;continue}if(r===0&&t===1&&n===45){s+=`\\${e.charAt(r)}`;continue}if(n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122){s+=e.charAt(r);continue}s+=`\\${e.charAt(r)}`}return s}var F=vt;function L(e=[]){return Array.isArray(e)?e:[e]}function
|
|
2
|
-
`,
|
|
1
|
+
"use strict";(()=>{function vt(e){let t=e.length,r=-1,n,s="",i=e.charCodeAt(0);for(;++r<t;){if(n=e.charCodeAt(r),n===0){s+="\uFFFD";continue}if(n===44){s+="\\,";continue}if(n>=1&&n<=31||n===127||r===0&&n>=48&&n<=57||r===1&&n>=48&&n<=57&&i===45){s+=`\\${n.toString(16)} `;continue}if(r===0&&t===1&&n===45){s+=`\\${e.charAt(r)}`;continue}if(n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122){s+=e.charAt(r);continue}s+=`\\${e.charAt(r)}`}return s}var F=vt;function L(e=[]){return Array.isArray(e)?e:[e]}function k(e){return Array.from(new Set(e))}function A(e){return typeof e=="string"}function K(e){return A(e)?e:(Array.isArray(e)?e:Object.entries(e)).filter(t=>t[1]!=null)}function et(e){return Array.isArray(e)?e.find(t=>!Array.isArray(t)||Array.isArray(t[0]))?e.map(t=>K(t)):[e]:[K(e)]}function At(e){return e.filter(([t,r],n)=>{if(t.startsWith("$$"))return!1;for(let s=n-1;s>=0;s--)if(e[s][0]===t&&e[s][1]===r)return!1;return!0})}function G(e){return e==null?"":At(e).map(([t,r])=>r!=null?`${t}:${r};`:void 0).filter(Boolean).join("")}function B(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Y(e,t){let r=e,n=t;if(Array.isArray(r))return[...n];let s={...r};return B(r)&&B(n)&&Object.keys(n).forEach(i=>{B(r[i])&&B(n[i])||Array.isArray(r[i])&&Array.isArray(n[i])?s[i]=Y(r[i],n[i]):Object.assign(s,{[i]:n[i]})}),s}function H(e){let t,r,n;if(Array.isArray(e)){for(r=Array(t=e.length);t--;)r[t]=(n=e[t])&&typeof n=="object"?H(n):n;return r}if(Object.prototype.toString.call(e)==="[object Object]"){r={};for(t in e)t==="__proto__"?Object.defineProperty(r,t,{value:H(e[t]),configurable:!0,enumerable:!0,writable:!0}):r[t]=(n=e[t])&&typeof n=="object"?H(n):n;return r}return e}function rt(e){return A(e[0])}function nt(e){return A(e[0])}var wt=/[\w\u00A0-\uFFFF-_:%-?]/,q="$$shortcut-no-merge";function st(e=""){return wt.test(e)}function it(e){return typeof e=="function"?{match:e}:e}function W(e){return e.length===3}function ot(e){return e!=null}function at(){}var z=class{_map=new Map;get(t,r){let n=this._map.get(t);if(n)return n.get(r)}getFallback(t,r,n){let s=this._map.get(t);return s||(s=new Map,this._map.set(t,s)),s.has(r)||s.set(r,n),s.get(r)}set(t,r,n){let s=this._map.get(t);return s||(s=new Map,this._map.set(t,s)),s.set(r,n),this}has(t,r){var n;return(n=this._map.get(t))==null?void 0:n.has(r)}delete(t,r){var n;return((n=this._map.get(t))==null?void 0:n.delete(r))||!1}deleteTop(t){return this._map.delete(t)}map(t){return Array.from(this._map.entries()).flatMap(([r,n])=>Array.from(n.entries()).map(([s,i])=>t(i,r,s)))}};var ct=/((?:[!\w+:_/-]|\[&?>?:?.*\])+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;function lt(e,t=["-",":"],r=5){ct.lastIndex=0;let n=!1,s=e.toString();do{let i=s;s=s.replace(ct,(o,u,c,a)=>t.includes(c)?a.split(/\s/g).filter(Boolean).map(f=>f==="~"?u:f.replace(/^(!?)(.*)/,`$1${u}${c}$2`)).join(" "):o),n=s!==i,r-=1}while(n&&r);return typeof e=="string"?s:e.length()?e.overwrite(0,e.length(),s):e}var ut=new Set;function ft(e){ut.has(e)||(console.warn("[unocss]",e),ut.add(e))}var Ut=e=>[...new Set(e.split(/\\?[\s'"`;={}]+/g))].filter(st),Z={name:"split",order:0,extract({code:e}){return Ut(e)}};function pt(){return{events:{},emit(e,...t){(this.events[e]||[]).forEach(r=>r(...t))},on(e,t){return(this.events[e]=this.events[e]||[]).push(t),()=>this.events[e]=(this.events[e]||[]).filter(r=>r!==t)}}}var I="default",N="preflights",Vt="shortcuts",dt={[N]:-100,[Vt]:-10,[I]:0};function ht(e){return L(e).flatMap(t=>Array.isArray(t)?[t]:Object.entries(t))}function $t(e){var r;let t=e.shortcuts?ht(e.shortcuts):void 0;if(e.shortcuts=t,e.prefix||e.layer){let n=s=>{s[2]||(s[2]={});let i=s[2];i.prefix==null&&e.prefix&&(i.prefix=e.prefix),i.layer==null&&e.layer&&(i.prefix=e.layer)};t==null||t.forEach(n),(r=e.rules)==null||r.forEach(n)}return e}function J(e={},t={}){let r=Object.assign({},t,e),n=(r.presets||[]).flatMap(L).map($t),s=[...n.filter(p=>p.enforce==="pre"),...n.filter(p=>!p.enforce),...n.filter(p=>p.enforce==="post")],i=Object.assign(dt,...n.map(p=>p.layers),e.layers);function o(p){return k([...s.flatMap(h=>L(h[p]||[])),...L(r[p]||[])])}let u=o("extractors");u.length||u.push(Z),u.sort((p,h)=>(p.order||0)-(h.order||0));let c=o("rules"),a={},f=c.length,l=c.map((p,h)=>{var U;if(rt(p)){let x=((U=p[2])==null?void 0:U.prefix)||"";a[x+p[0]]=[h,p[1],p[2],p];return}return[h,...p]}).filter(Boolean).reverse(),g=H([...s.map(p=>p.theme||{}),r.theme||{}].reduce((p,h)=>Y(p,h),{}));o("extendTheme").forEach(p=>p(g));let m={templates:k(s.map(p=>{var h;return L((h=p.autocomplete)==null?void 0:h.templates)}).flat()),extractors:s.map(p=>{var h;return L((h=p.autocomplete)==null?void 0:h.extractors)}).flat().sort((p,h)=>(p.order||0)-(h.order||0))};return{mergeSelectors:!0,warn:!0,blocklist:[],sortLayers:p=>p,...r,presets:s,envMode:r.envMode||"build",shortcutsLayer:r.shortcutsLayer||"shortcuts",layers:i,theme:g,rulesSize:f,rulesDynamic:l,rulesStaticMap:a,preprocess:o("preprocess"),postprocess:o("postprocess"),preflights:o("preflights"),autocomplete:m,variants:o("variants").map(it),shortcuts:ht(o("shortcuts")),extractors:u,safelist:o("safelist")}}var gt="0.45.28";var Q=class{constructor(t={},r={}){this.userConfig=t;this.defaults=r;this.config=J(t,r),this.events.emit("config",this.config)}version=gt;_cache=new Map;config;blocked=new Set;parentOrders=new Map;events=pt();setConfig(t,r){!t||(r&&(this.defaults=r),this.userConfig=t,this.blocked.clear(),this.parentOrders.clear(),this._cache.clear(),this.config=J(t,this.defaults),this.events.emit("config",this.config))}async applyExtractors(t,r,n=new Set){let s={get original(){return t},code:t,id:r};for(let i of this.config.extractors){let o=await i.extract(s);if(o)for(let u of o)n.add(u)}return n}makeContext(t,r){let n={rawSelector:t,currentSelector:r[1],theme:this.config.theme,generator:this,variantHandlers:r[2],constructCSS:(...s)=>this.constructCustomCSS(n,...s),variantMatch:r};return n}async parseToken(t,r){var a;if(this.blocked.has(t))return;let n=`${t}${r?` ${r}`:""}`;if(this._cache.has(n))return this._cache.get(n);let s=t;for(let f of this.config.preprocess)s=f(t);if(this.isBlocked(s)){this.blocked.add(t),this._cache.set(n,null);return}let i=this.matchVariants(t,s);if(!i||this.isBlocked(i[1])){this.blocked.add(t),this._cache.set(n,null);return}let o=this.makeContext(t,[r||i[0],i[1],i[2],i[3]]);this.config.details&&(o.variants=[...i[3]]);let u=this.expandShortcut(o.currentSelector,o),c=u?await this.stringifyShortcuts(o.variantMatch,o,u[0],u[1]):(a=await this.parseUtil(o.variantMatch,o))==null?void 0:a.map(f=>this.stringifyUtil(f,o)).filter(ot);if(c!=null&&c.length)return this._cache.set(n,c),c;this._cache.set(n,null)}async generate(t,r={}){let{id:n,scope:s,preflights:i=!0,safelist:o=!0,minify:u=!1}=r,c=A(t)?await this.applyExtractors(t,n):Array.isArray(t)?new Set(t):t;o&&this.config.safelist.forEach(y=>c.add(y));let a=u?"":`
|
|
2
|
+
`,f=new Set([I]),l=new Set,g=new Map,m={},p=Array.from(c).map(async y=>{var b;if(l.has(y))return;let C=await this.parseToken(y);if(C!=null){l.add(y);for(let w of C){let V=w[3]||"",d=(b=w[4])==null?void 0:b.layer;g.has(V)||g.set(V,[]),g.get(V).push(w),d&&f.add(d)}}}),h=(async()=>{if(!i)return;let y={generator:this,theme:this.config.theme},C=new Set([]);this.config.preflights.forEach(({layer:b=N})=>{f.add(b),C.add(b)}),m=Object.fromEntries(await Promise.all(Array.from(C).map(async b=>{let V=(await Promise.all(this.config.preflights.filter(d=>(d.layer||N)===b).map(async d=>await d.getCSS(y)))).filter(Boolean).join(a);return[b,V]})))})();await Promise.all([...p,h]);let U=this.config.sortLayers(Array.from(f).sort((y,C)=>(this.config.layers[y]??0)-(this.config.layers[C]??0)||y.localeCompare(C))),x={},E=y=>{if(x[y])return x[y];let C=Array.from(g).sort((w,V)=>{var d;return(this.parentOrders.get(w[0])??0)-(this.parentOrders.get(V[0])??0)||((d=w[0])==null?void 0:d.localeCompare(V[0]||""))||0}).map(([w,V])=>{let d=V.length,R=V.filter(S=>{var v;return(((v=S[4])==null?void 0:v.layer)||I)===y}).sort((S,v)=>{var T,j,D,_;return S[0]-v[0]||(((T=S[4])==null?void 0:T.sort)||0)-(((j=v[4])==null?void 0:j.sort)||0)||((D=S[1])==null?void 0:D.localeCompare(v[1]||""))||((_=S[2])==null?void 0:_.localeCompare(v[2]||""))||0}).map(([,S,v,,T,,j])=>[[[(S&&_t(S,s))??"",(T==null?void 0:T.sort)??0]],v,!!(j??(T==null?void 0:T.noMerge))]);if(!R.length)return;let $=R.reverse().map(([S,v,T],j)=>{if(!T&&this.config.mergeSelectors)for(let _=j+1;_<d;_++){let O=R[_];if(O&&!O[2]&&(S&&O[0]||S==null&&O[0]==null)&&O[1]===v)return S&&O[0]&&O[0].push(...S),null}let D=S?k(S.sort((_,O)=>{var tt;return _[1]-O[1]||((tt=_[0])==null?void 0:tt.localeCompare(O[0]||""))||0}).map(_=>_[0]).filter(Boolean)):[];return D.length?`${D.join(`,${a}`)}{${v}}`:v}).filter(Boolean).reverse().join(a);if(!w)return $;let P=w.split(" $$ ");return`${P.join("{")}{${a}${$}${a}}${P.map(S=>"").join("}")}`}).filter(Boolean).join(a);i&&(C=[m[y],C].filter(Boolean).join(a));let b=u?"":`/* layer: ${y} */${a}`;return x[y]=C?b+C:""},M=(y=U,C)=>y.filter(b=>!(C!=null&&C.includes(b))).map(b=>E(b)||"").filter(Boolean).join(a);return{get css(){return M()},layers:U,matched:l,getLayers:M,getLayer:E}}matchVariants(t,r){let n=new Set,s=[],i=r||t,o=!1,u={rawSelector:t,theme:this.config.theme,generator:this};for(;;){o=!1;for(let c of this.config.variants){if(!c.multiPass&&n.has(c))continue;let a=c.match(i,u);if(!!a){A(a)&&(a={matcher:a}),i=a.matcher,s.unshift(a),n.add(c),o=!0;break}}if(!o)break;if(s.length>500)throw new Error(`Too many variants applied to "${t}"`)}return[t,i,s,n]}applyVariants(t,r=t[4],n=t[1]){let i=[...r].sort((a,f)=>(a.order||0)-(f.order||0)).reverse().reduce((a,f)=>l=>{var p,h;let g=((p=f.body)==null?void 0:p.call(f,l.entries))||l.entries,m=Array.isArray(f.parent)?f.parent:[f.parent,void 0];return(f.handle??Lt)({...l,entries:g,selector:((h=f.selector)==null?void 0:h.call(f,l.selector,g))||l.selector,parent:m[0]||l.parent,parentOrder:m[1]||l.parentOrder,layer:f.layer||l.layer,sort:f.sort||l.sort},a)},a=>a)({prefix:"",selector:Pt(n),pseudo:"",entries:t[2]}),{parent:o,parentOrder:u}=i;o!=null&&u!=null&&this.parentOrders.set(o,u);let c={selector:Ot([i.prefix,i.selector,i.pseudo].join("")),entries:i.entries,parent:o,layer:i.layer,sort:i.sort,noMerge:i.noMerge};for(let a of this.config.postprocess)a(c);return c}constructCustomCSS(t,r,n){let s=K(r);if(A(s))return s;let{selector:i,entries:o,parent:u}=this.applyVariants([0,n||t.rawSelector,s,void 0,t.variantHandlers]),c=`${i}{${G(o)}}`;return u?`${u}{${c}}`:c}async parseUtil(t,r,n=!1){var a;let[s,i,o]=A(t)?this.matchVariants(t):t;this.config.details&&(r.rules=r.rules??[]);let u=this.config.rulesStaticMap[i];if(u&&u[1]&&(n||!((a=u[2])!=null&&a.internal))){this.config.details&&r.rules.push(u[3]);let f=u[0],l=K(u[1]),g=u[2];return A(l)?[[f,l,g]]:[[f,s,l,g,o]]}r.variantHandlers=o;let{rulesDynamic:c}=this.config;for(let[f,l,g,m]of c){if((m==null?void 0:m.internal)&&!n)continue;let p=i;if(m!=null&&m.prefix){if(!i.startsWith(m.prefix))continue;p=i.slice(m.prefix.length)}let h=p.match(l);if(!h)continue;let U=await g(h,r);if(!U)continue;this.config.details&&r.rules.push([l,g,m]);let x=et(U).filter(E=>E.length);if(x.length)return x.map(E=>A(E)?[f,E,m]:[f,s,E,m,o])}}stringifyUtil(t,r){if(!t)return;if(W(t))return[t[0],void 0,t[1],void 0,t[2],this.config.details?r:void 0,void 0];let{selector:n,entries:s,parent:i,layer:o,sort:u,noMerge:c}=this.applyVariants(t),a=G(s);if(!a)return;let{layer:f,sort:l,...g}=t[3]??{},m={...g,layer:o??f,sort:u??l};return[t[0],n,a,i,m,this.config.details?r:void 0,c]}expandShortcut(t,r,n=5){var u;if(n===0)return;let s=this.config.details?c=>{r.shortcuts=r.shortcuts??[],r.shortcuts.push(c)}:at,i,o;for(let c of this.config.shortcuts){let a=(u=c[2])!=null&&u.prefix?t.slice(c[2].prefix.length):t;if(nt(c)){if(c[0]===a){i=i||c[2],o=c[1],s(c);break}}else{let f=a.match(c[0]);if(f&&(o=c[1](f,r)),o){i=i||c[2],s(c);break}}}if(A(o)&&(o=lt(o.trim()).split(/\s+/g)),!o){let[c,a]=A(t)?this.matchVariants(t):t;if(c!==a){let f=this.expandShortcut(a,r,n-1);f&&(o=f[0].map(l=>A(l)?c.replace(a,l):l))}}if(!!o)return[o.flatMap(c=>{var a;return(A(c)?(a=this.expandShortcut(c,r,n-1))==null?void 0:a[0]:void 0)||[c]}).filter(Boolean),i]}async stringifyShortcuts(t,r,n,s={layer:this.config.shortcutsLayer}){var f;let i=new z,o=(await Promise.all(k(n).map(async l=>{let g=A(l)?await this.parseUtil(l,r,!0):[[1/0,"{inline}",K(l),void 0,[]]];return g||ft(`unmatched utility "${l}" in shortcut "${t[1]}"`),g||[]}))).flat(1).filter(Boolean).sort((l,g)=>l[0]-g[0]),[u,,c]=t,a=[];for(let l of o){if(W(l)){a.push([l[0],void 0,l[1],void 0,l[2],r,void 0]);continue}let{selector:g,entries:m,parent:p,sort:h,noMerge:U}=this.applyVariants(l,[...l[4],...c],u);i.getFallback(g,p,[[],l[0]])[0].push([m,!!(U??((f=l[3])==null?void 0:f.noMerge)),h??0])}return a.concat(i.map(([l,g],m,p)=>{let h=(x,E,M)=>{let y=Math.max(...M.map(b=>b[1])),C=M.map(b=>b[0]);return(x?[C.flat(1)]:C).map(b=>{let w=G(b);if(w)return[g,m,w,p,{...s,noMerge:E,sort:y},r,void 0]})};return[[l.filter(([,x])=>x).map(([x,,E])=>[x,E]),!0],[l.filter(([,x])=>!x).map(([x,,E])=>[x,E]),!1]].map(([x,E])=>[...h(!1,E,x.filter(([M])=>M.some(y=>y[0]===q))),...h(!0,E,x.filter(([M])=>M.every(y=>y[0]!==q)))])}).flat(2).filter(Boolean))}isBlocked(t){return!t||this.config.blocklist.some(r=>A(r)?r===t:r.test(t))}};function yt(e,t){return new Q(e,t)}var xt=/ \$\$ /,Tt=e=>e.match(xt);function _t(e,t){return Tt(e)?e.replace(xt,t?` ${t} `:" "):t?`${t} ${e}`:e}function Ot(e){let t=e.match(/::[\w-]+(\([\w-]+\))?/g);if(t){for(let r of t)e=e.replace(r,"");e+=t.join("")}return e}var mt=/^\[(.+?)(~?=)"(.*)"\]$/;function Pt(e){return mt.test(e)?e.replace(mt,(t,r,n,s)=>`[${F(r)}${n}"${F(s)}"]`):`.${F(e)}`}function Lt(e,t){return t(e)}var jt=e=>e.replace(/-(\w)/g,(t,r)=>r?r.toUpperCase():""),St=e=>e.charAt(0).toUpperCase()+e.slice(1),Ct=e=>e.replace(/(?:^|\B)([A-Z])/g,"-$1").toLowerCase(),bt=["Webkit","Moz","ms"];function Et(e){let t={};function r(n){let s=t[n];if(s)return s;let i=jt(n);if(i!=="filter"&&i in e)return t[n]=Ct(i);i=St(i);for(let o=0;o<bt.length;o++){let u=`${bt[o]}${i}`;if(u in e)return t[n]=Ct(St(u))}return n}return({entries:n})=>n.forEach(s=>{s[0].startsWith("--")||(s[0]=r(s[0]))})}function Rt(e){return e.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<")}function X(e={}){var w,V;if(typeof window>"u"){console.warn("@unocss/runtime been used in non-browser environment, skipped.");return}let t=window.__unocss||{},r=t==null?void 0:t.runtime,n=Object.assign(e.defaults||{},r),s=n.cloakAttribute??"un-cloak";if(r!=null&&r.autoPrefix){let d=n.postprocess;d||(d=[]),Array.isArray(d)||(d=[d]),d.unshift(Et(document.createElement("div").style)),n.postprocess=d}(w=r==null?void 0:r.configResolved)==null||w.call(r,t,n);let i,o=!0,u,c=yt(t,n),a=new Set,f,l=[],g=()=>new Promise(d=>{l.push(d),f!=null&&clearTimeout(f),f=setTimeout(()=>p().then(()=>{let R=l;l=[],R.forEach($=>$())}),0)});function m(d=document.body){if(d.nodeType!==1)return;let R=d;R.hasAttribute(s)&&R.removeAttribute(s),R.querySelectorAll(`[${s}]`).forEach($=>{$.removeAttribute(s)})}async function p(){let d=await c.generate(a);i||(i=document.createElement("style"),document.documentElement.prepend(i)),i.innerHTML=d.css,a=d.matched}async function h(d){let R=a.size;await c.applyExtractors(d,void 0,a),R!==a.size&&await g()}async function U(){let d=document.body&&document.body.outerHTML;d&&(await h(`${d} ${Rt(d)}`),m())}let x=new MutationObserver(d=>{o||d.forEach(async R=>{if(R.target.nodeType!==1)return;let $=R.target;if($!==i)if(R.type==="childList")R.addedNodes.forEach(async P=>{if(P.nodeType!==1)return;let S=P;u&&!u(S)||(await h(S.outerHTML),m(S))});else{if(u&&!u($))return;if(R.attributeName!==s){let P=Array.from($.attributes).map(v=>v.value?`${v.name}="${v.value}"`:v.name).join(" "),S=`<${$.tagName.toLowerCase()} ${P}>`;await h(S)}$.hasAttribute(s)&&$.removeAttribute(s)}})}),E=!1;function M(){if(E)return;let d=document.documentElement||document.body;!d||(x.observe(d,{childList:!0,subtree:!0,attributes:!0}),E=!0)}function y(){U(),M()}function C(){document.readyState==="loading"?window.addEventListener("DOMContentLoaded",y):y()}let b=window.__unocss_runtime=window.__unocss_runtime={version:c.version,uno:c,async extract(d){typeof d!="string"&&(d.forEach(R=>a.add(R)),d=""),await h(d)},extractAll:U,inspect(d){u=d},toggleObserver(d){d===void 0?o=!o:o=!!d,!E&&!o&&C()}};((V=r==null?void 0:r.ready)==null?void 0:V.call(r,b))!==!1&&(o=!1,C())}X();})();
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -66,6 +66,7 @@ function init(inlineConfig = {}) {
|
|
|
66
66
|
const config = window.__unocss || {};
|
|
67
67
|
const runtime = config == null ? void 0 : config.runtime;
|
|
68
68
|
const defaultConfig = Object.assign(inlineConfig.defaults || {}, runtime);
|
|
69
|
+
const cloakAttribute = defaultConfig.cloakAttribute ?? "un-cloak";
|
|
69
70
|
if (runtime == null ? void 0 : runtime.autoPrefix) {
|
|
70
71
|
let postprocess = defaultConfig.postprocess;
|
|
71
72
|
if (!postprocess)
|
|
@@ -97,10 +98,10 @@ function init(inlineConfig = {}) {
|
|
|
97
98
|
if (node.nodeType !== 1)
|
|
98
99
|
return;
|
|
99
100
|
const el = node;
|
|
100
|
-
if (el.hasAttribute(
|
|
101
|
-
el.removeAttribute(
|
|
102
|
-
el.querySelectorAll(
|
|
103
|
-
n.removeAttribute(
|
|
101
|
+
if (el.hasAttribute(cloakAttribute))
|
|
102
|
+
el.removeAttribute(cloakAttribute);
|
|
103
|
+
el.querySelectorAll(`[${cloakAttribute}]`).forEach((n) => {
|
|
104
|
+
n.removeAttribute(cloakAttribute);
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
async function updateStyle() {
|
|
@@ -147,13 +148,13 @@ function init(inlineConfig = {}) {
|
|
|
147
148
|
} else {
|
|
148
149
|
if (inspector && !inspector(target))
|
|
149
150
|
return;
|
|
150
|
-
if (mutation.attributeName !==
|
|
151
|
+
if (mutation.attributeName !== cloakAttribute) {
|
|
151
152
|
const attrs = Array.from(target.attributes).map((i) => i.value ? `${i.name}="${i.value}"` : i.name).join(" ");
|
|
152
153
|
const tag = `<${target.tagName.toLowerCase()} ${attrs}>`;
|
|
153
154
|
await extract(tag);
|
|
154
155
|
}
|
|
155
|
-
if (target.hasAttribute(
|
|
156
|
-
target.removeAttribute(
|
|
156
|
+
if (target.hasAttribute(cloakAttribute))
|
|
157
|
+
target.removeAttribute(cloakAttribute);
|
|
157
158
|
}
|
|
158
159
|
});
|
|
159
160
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -42,6 +42,7 @@ function init(inlineConfig = {}) {
|
|
|
42
42
|
const config = window.__unocss || {};
|
|
43
43
|
const runtime = config == null ? void 0 : config.runtime;
|
|
44
44
|
const defaultConfig = Object.assign(inlineConfig.defaults || {}, runtime);
|
|
45
|
+
const cloakAttribute = defaultConfig.cloakAttribute ?? "un-cloak";
|
|
45
46
|
if (runtime == null ? void 0 : runtime.autoPrefix) {
|
|
46
47
|
let postprocess = defaultConfig.postprocess;
|
|
47
48
|
if (!postprocess)
|
|
@@ -73,10 +74,10 @@ function init(inlineConfig = {}) {
|
|
|
73
74
|
if (node.nodeType !== 1)
|
|
74
75
|
return;
|
|
75
76
|
const el = node;
|
|
76
|
-
if (el.hasAttribute(
|
|
77
|
-
el.removeAttribute(
|
|
78
|
-
el.querySelectorAll(
|
|
79
|
-
n.removeAttribute(
|
|
77
|
+
if (el.hasAttribute(cloakAttribute))
|
|
78
|
+
el.removeAttribute(cloakAttribute);
|
|
79
|
+
el.querySelectorAll(`[${cloakAttribute}]`).forEach((n) => {
|
|
80
|
+
n.removeAttribute(cloakAttribute);
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
async function updateStyle() {
|
|
@@ -123,13 +124,13 @@ function init(inlineConfig = {}) {
|
|
|
123
124
|
} else {
|
|
124
125
|
if (inspector && !inspector(target))
|
|
125
126
|
return;
|
|
126
|
-
if (mutation.attributeName !==
|
|
127
|
+
if (mutation.attributeName !== cloakAttribute) {
|
|
127
128
|
const attrs = Array.from(target.attributes).map((i) => i.value ? `${i.name}="${i.value}"` : i.name).join(" ");
|
|
128
129
|
const tag = `<${target.tagName.toLowerCase()} ${attrs}>`;
|
|
129
130
|
await extract(tag);
|
|
130
131
|
}
|
|
131
|
-
if (target.hasAttribute(
|
|
132
|
-
target.removeAttribute(
|
|
132
|
+
if (target.hasAttribute(cloakAttribute))
|
|
133
|
+
target.removeAttribute(cloakAttribute);
|
|
133
134
|
}
|
|
134
135
|
});
|
|
135
136
|
});
|