@empjs/plugin-postcss 3.0.0-rc.29 → 3.0.0-rc.30

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var m=Object.create;var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var g=(e,s)=>{for(var t in s)i(e,t,{get:s[t],enumerable:!0})},l=(e,s,t,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of d(s))!x.call(e,o)&&o!==t&&i(e,o,{get:()=>s[o],enumerable:!(r=f(s,o))||r.enumerable});return e};var p=(e,s,t)=>(t=e!=null?m(v(e)):{},l(s||!e||!e.__esModule?i(t,"default",{value:e,enumerable:!0}):t,e)),P=e=>l(i({},"__esModule",{value:!0}),e);var h={};g(h,{default:()=>w,postcss:()=>y});module.exports=P(h);var a=p(require("path"),1),c={autoprefixer(e={}){return[require.resolve("autoprefixer"),e]},pxtorem(e={}){return e={rootValue:16,unitPrecision:5,propList:["*"],selectorBlackList:[],replace:!0,mediaQuery:!1,minPixelValue:0,...e},[require.resolve("postcss-pxtorem"),e]},pxtovw(e={}){return e={unitToConvert:"px",viewportWidth:320,viewportHeight:568,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",selectorBlackList:[],propList:["*"],minPixelValue:1,mediaQuery:!1,replace:!0,landscape:!1,landscapeUnit:"vw",landscapeWidth:568,...e},[a.default.resolve(__dirname,"pxtovw"),e]}};var w=(e={})=>({name:"@empjs/plugin-postcss",async rsConfig(s){let{chain:t}=s,r=["sass","less","css"],o={};e.postcssOptions&&(o.postcssOptions=e.postcssOptions);for(let n of r){let u=t.module.rule(n).use("postcss").loader(require.resolve("postcss-loader")).options(o);["sass","less"].includes(n)&&u.before(`${n}Loader`)}}}),y=c;0&&(module.exports={postcss});
1
+ "use strict";var m=Object.create;var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var g=(e,s)=>{for(var t in s)i(e,t,{get:s[t],enumerable:!0})},l=(e,s,t,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of d(s))!x.call(e,o)&&o!==t&&i(e,o,{get:()=>s[o],enumerable:!(r=f(s,o))||r.enumerable});return e};var p=(e,s,t)=>(t=e!=null?m(v(e)):{},l(s||!e||!e.__esModule?i(t,"default",{value:e,enumerable:!0}):t,e)),P=e=>l(i({},"__esModule",{value:!0}),e);var L={};g(L,{default:()=>y,postcss:()=>h});module.exports=P(L);var a=p(require("path"),1),c={autoprefixer(e={}){return[require.resolve("autoprefixer"),e]},pxtorem(e={}){return e={rootValue:16,unitPrecision:5,propList:["*"],selectorBlackList:[],replace:!0,mediaQuery:!1,minPixelValue:0,...e},[require.resolve("postcss-pxtorem"),e]},pxtovw(e={}){return e={unitToConvert:"px",viewportWidth:320,viewportHeight:568,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",selectorBlackList:[],propList:["*"],minPixelValue:1,mediaQuery:!1,replace:!0,landscape:!1,landscapeUnit:"vw",landscapeWidth:568,...e},[a.default.resolve(__dirname,"pxtovw"),e]}};var y=(e={})=>({name:"@empjs/plugin-postcss",async rsConfig(s){let{chain:t}=s,r=["sass","less","css"],o={};e.postcssOptions&&(o.postcssOptions=e.postcssOptions);for(let n of r){let u=t.module.rule(n).use("postcss").loader(require.resolve("postcss-loader")).options(o);["sass","less"].includes(n)&&u.before(`${n}Loader`)}}}),h=c;0&&(module.exports={postcss});
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var s=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import a from"path";var p={autoprefixer(e={}){return[s.resolve("autoprefixer"),e]},pxtorem(e={}){return e={rootValue:16,unitPrecision:5,propList:["*"],selectorBlackList:[],replace:!0,mediaQuery:!1,minPixelValue:0,...e},[s.resolve("postcss-pxtorem"),e]},pxtovw(e={}){return e={unitToConvert:"px",viewportWidth:320,viewportHeight:568,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",selectorBlackList:[],propList:["*"],minPixelValue:1,mediaQuery:!1,replace:!0,landscape:!1,landscapeUnit:"vw",landscapeWidth:568,...e},[a.resolve(__dirname,"pxtovw"),e]}};var x=(e={})=>({name:"@empjs/plugin-postcss",async rsConfig(t){let{chain:o}=t,n=["sass","less","css"],i={};e.postcssOptions&&(i.postcssOptions=e.postcssOptions);for(let r of n){let l=o.module.rule(r).use("postcss").loader(s.resolve("postcss-loader")).options(i);["sass","less"].includes(r)&&l.before(`${r}Loader`)}}}),g=p;export{x as default,g as postcss};
1
+ var s=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{fileURLToPath as c}from"url";import u from"path";var m=()=>c(import.meta.url),f=()=>u.dirname(m()),i=f();import x from"path";var n={autoprefixer(e={}){return[s.resolve("autoprefixer"),e]},pxtorem(e={}){return e={rootValue:16,unitPrecision:5,propList:["*"],selectorBlackList:[],replace:!0,mediaQuery:!1,minPixelValue:0,...e},[s.resolve("postcss-pxtorem"),e]},pxtovw(e={}){return e={unitToConvert:"px",viewportWidth:320,viewportHeight:568,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",selectorBlackList:[],propList:["*"],minPixelValue:1,mediaQuery:!1,replace:!0,landscape:!1,landscapeUnit:"vw",landscapeWidth:568,...e},[x.resolve(i,"pxtovw"),e]}};var V=(e={})=>({name:"@empjs/plugin-postcss",async rsConfig(t){let{chain:o}=t,l=["sass","less","css"],p={};e.postcssOptions&&(p.postcssOptions=e.postcssOptions);for(let r of l){let a=o.module.rule(r).use("postcss").loader(s.resolve("postcss-loader")).options(p);["sass","less"].includes(r)&&a.before(`${r}Loader`)}}}),_=n;export{V as default,_ as postcss};
package/dist/pxtovw.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var h=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var E=(t,n)=>{for(var i in n)h(t,i,{get:n[i],enumerable:!0})},R=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of W(n))!O.call(t,e)&&e!==i&&h(t,e,{get:()=>n[e],enumerable:!(r=w(n,e))||r.enumerable});return t};var P=t=>R(h({},"__esModule",{value:!0}),t);var A={};E(A,{default:()=>C});module.exports=P(A);var b=require("postcss");function g(t){return new RegExp(`"[^"]+"|'[^']+'|url\\([^\\)]+\\)|(\\d*\\.?\\d+)`+t,"g")}var c={exact:function(t){return t.filter(function(n){return n.match(/^[^\*\!]+$/)})},contain:function(t){return t.filter(function(n){return n.match(/^\*.+\*$/)}).map(function(n){return n.substr(1,n.length-2)})},endWith:function(t){return t.filter(function(n){return n.match(/^\*[^\*]+$/)}).map(function(n){return n.substr(1)})},startWith:function(t){return t.filter(function(n){return n.match(/^[^\*\!]+\*$/)}).map(function(n){return n.substr(0,n.length-1)})},notExact:function(t){return t.filter(function(n){return n.match(/^\![^\*].*$/)}).map(function(n){return n.substr(1)})},notContain:function(t){return t.filter(function(n){return n.match(/^\!\*.+\*$/)}).map(function(n){return n.substr(2,n.length-3)})},notEndWith:function(t){return t.filter(function(n){return n.match(/^\!\*[^\*]+$/)}).map(function(n){return n.substr(2)})},notStartWith:function(t){return t.filter(function(n){return n.match(/^\![^\*]+\*$/)}).map(function(n){return n.substr(1,n.length-2)})}};function x(t){let n=t.indexOf("*")>-1,i=n&&t.length===1,r={exact:c.exact(t),contain:c.contain(t),startWith:c.startWith(t),endWith:c.endWith(t),notExact:c.notExact(t),notContain:c.notContain(t),notStartWith:c.notStartWith(t),notEndWith:c.notEndWith(t)};return function(e){return i?!0:(n||r.exact.indexOf(e)>-1||r.contain.some(function(a){return e.indexOf(a)>-1})||r.startWith.some(function(a){return e.indexOf(a)===0})||r.endWith.some(function(a){return e.indexOf(a)===e.length-a.length}))&&!(r.notExact.indexOf(e)>-1||r.notContain.some(function(a){return e.indexOf(a)>-1})||r.notStartWith.some(function(a){return e.indexOf(a)===0})||r.notEndWith.some(function(a){return e.indexOf(a)===e.length-a.length}))}}var U={unitToConvert:"px",viewportWidth:320,viewportHeight:568,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",selectorBlackList:[],propList:["*"],minPixelValue:1,mediaQuery:!1,replace:!0,landscape:!1,landscapeUnit:"vw",landscapeWidth:568},C=t=>{let n=Object.assign({},U,t),i=g(n.unitToConvert),r=x(n.propList),e=[];return{postcssPlugin:"postcss-px-to-viewport",Once(a){if(a.walkRules(function(u){let f=u.source&&u.source.input.file;if(n.exclude&&f)if(Object.prototype.toString.call(n.exclude)==="[object RegExp]"){if(v(n.exclude,f))return}else if(Object.prototype.toString.call(n.exclude)==="[object Array]"){for(let o=0;o<n.exclude.length;o++)if(v(n.exclude[o],f))return}else throw new Error("options.exclude should be RegExp or Array.");if(!k(n.selectorBlackList,u.selector)){if(n.landscape&&!u.parent.params){let o=u.clone().removeAll();u.walkDecls(function(s){s.value.indexOf(n.unitToConvert)!==-1&&r(s.prop)&&o.append(s.clone({value:s.value.replace(i,m(n,n.landscapeUnit,n.landscapeWidth))}))}),o.nodes.length>0&&e.push(o)}$(u.parent.params,n.mediaQuery)&&u.walkDecls(function(o,s){if(o.value.indexOf(n.unitToConvert)===-1||!r(o.prop))return;let l,p,y=u.parent.params;n.landscape&&y&&y.indexOf("landscape")!==-1?(l=n.landscapeUnit,p=n.landscapeWidth):(l=S(o.prop,n),p=n.viewportWidth);let d=o.value.replace(i,m(n,l,p));V(o.parent,o.prop,d)||(n.replace?o.value=d:o.parent.insertAfter(s,o.clone({value:d})))})}}),e.length>0){let u=(0,b.atRule)({params:"(orientation: landscape)",name:"media"});e.forEach(function(f){u.append(f)}),a.append(u)}}}};function S(t,n){return t.indexOf("font")===-1?n.viewportUnit:n.fontViewportUnit}function m(t,n,i){return function(r,e){if(!e)return r;let a=Number.parseFloat(e);if(a<=t.minPixelValue)return r;let u=j(a/i*100,t.unitPrecision);return u===0?"0":u+n}}function j(t,n){let i=10**(n+1),r=Math.floor(t*i);return Math.round(r/10)*10/i}function k(t,n){if(typeof n=="string")return t.some(function(i){return typeof i=="string"?n.indexOf(i)!==-1:n.match(i)})}function v(t,n){if(Object.prototype.toString.call(t)!=="[object RegExp]")throw new Error("options.exclude should be RegExp.");return n.match(t)!==null}function V(t,n,i){return t.some(function(r){return r.prop===n&&r.value===i})}function $(t,n){return!t||t&&n}
1
+ "use strict";var h=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var R=(t,n)=>{for(var i in n)h(t,i,{get:n[i],enumerable:!0})},P=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of O(n))!E.call(t,e)&&e!==i&&h(t,e,{get:()=>n[e],enumerable:!(r=W(n,e))||r.enumerable});return t};var U=t=>P(h({},"__esModule",{value:!0}),t);var M={};R(M,{default:()=>S});module.exports=U(M);var w=require("postcss");function x(t){return new RegExp(`"[^"]+"|'[^']+'|url\\([^\\)]+\\)|(\\d*\\.?\\d+)`+t,"g")}var c={exact:function(t){return t.filter(function(n){return n.match(/^[^\*\!]+$/)})},contain:function(t){return t.filter(function(n){return n.match(/^\*.+\*$/)}).map(function(n){return n.substr(1,n.length-2)})},endWith:function(t){return t.filter(function(n){return n.match(/^\*[^\*]+$/)}).map(function(n){return n.substr(1)})},startWith:function(t){return t.filter(function(n){return n.match(/^[^\*\!]+\*$/)}).map(function(n){return n.substr(0,n.length-1)})},notExact:function(t){return t.filter(function(n){return n.match(/^\![^\*].*$/)}).map(function(n){return n.substr(1)})},notContain:function(t){return t.filter(function(n){return n.match(/^\!\*.+\*$/)}).map(function(n){return n.substr(2,n.length-3)})},notEndWith:function(t){return t.filter(function(n){return n.match(/^\!\*[^\*]+$/)}).map(function(n){return n.substr(2)})},notStartWith:function(t){return t.filter(function(n){return n.match(/^\![^\*]+\*$/)}).map(function(n){return n.substr(1,n.length-2)})}};function m(t){let n=t.indexOf("*")>-1,i=n&&t.length===1,r={exact:c.exact(t),contain:c.contain(t),startWith:c.startWith(t),endWith:c.endWith(t),notExact:c.notExact(t),notContain:c.notContain(t),notStartWith:c.notStartWith(t),notEndWith:c.notEndWith(t)};return function(e){return i?!0:(n||r.exact.indexOf(e)>-1||r.contain.some(function(a){return e.indexOf(a)>-1})||r.startWith.some(function(a){return e.indexOf(a)===0})||r.endWith.some(function(a){return e.indexOf(a)===e.length-a.length}))&&!(r.notExact.indexOf(e)>-1||r.notContain.some(function(a){return e.indexOf(a)>-1})||r.notStartWith.some(function(a){return e.indexOf(a)===0})||r.notEndWith.some(function(a){return e.indexOf(a)===e.length-a.length}))}}var C={unitToConvert:"px",viewportWidth:320,viewportHeight:568,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",selectorBlackList:[],propList:["*"],minPixelValue:1,mediaQuery:!1,replace:!0,landscape:!1,landscapeUnit:"vw",landscapeWidth:568},S=t=>{let n=Object.assign({},C,t),i=x(n.unitToConvert),r=m(n.propList),e=[];return{postcssPlugin:"postcss-px-to-viewport",Once(a){if(a.walkRules(function(u){let f=u.source&&u.source.input.file;if(n.exclude&&f)if(Object.prototype.toString.call(n.exclude)==="[object RegExp]"){if(b(n.exclude,f))return}else if(Object.prototype.toString.call(n.exclude)==="[object Array]"){for(let o=0;o<n.exclude.length;o++)if(b(n.exclude[o],f))return}else throw new Error("options.exclude should be RegExp or Array.");if(!V(n.selectorBlackList,u.selector)){if(n.landscape&&!u.parent.params){let o=u.clone().removeAll();u.walkDecls(function(s){s.value.indexOf(n.unitToConvert)!==-1&&r(s.prop)&&o.append(s.clone({value:s.value.replace(i,v(n,n.landscapeUnit,n.landscapeWidth))}))}),o.nodes.length>0&&e.push(o)}A(u.parent.params,n.mediaQuery)&&u.walkDecls(function(o,s){if(o.value.indexOf(n.unitToConvert)===-1||!r(o.prop))return;let l,p,y=u.parent.params;n.landscape&&y&&y.indexOf("landscape")!==-1?(l=n.landscapeUnit,p=n.landscapeWidth):(l=j(o.prop,n),p=n.viewportWidth);let d=o.value.replace(i,v(n,l,p));$(o.parent,o.prop,d)||(n.replace?o.value=d:o.parent.insertAfter(s,o.clone({value:d})))})}}),e.length>0){let u=(0,w.atRule)({params:"(orientation: landscape)",name:"media"});e.forEach(function(f){u.append(f)}),a.append(u)}}}};function j(t,n){return t.indexOf("font")===-1?n.viewportUnit:n.fontViewportUnit}function v(t,n,i){return function(r,e){if(!e)return r;let a=Number.parseFloat(e);if(a<=t.minPixelValue)return r;let u=k(a/i*100,t.unitPrecision);return u===0?"0":u+n}}function k(t,n){let i=10**(n+1),r=Math.floor(t*i);return Math.round(r/10)*10/i}function V(t,n){if(typeof n=="string")return t.some(function(i){return typeof i=="string"?n.indexOf(i)!==-1:n.match(i)})}function b(t,n){if(Object.prototype.toString.call(t)!=="[object RegExp]")throw new Error("options.exclude should be RegExp.");return n.match(t)!==null}function $(t,n,i){return t.some(function(r){return r.prop===n&&r.value===i})}function A(t,n){return!t||t&&n}
package/dist/pxtovw.js CHANGED
@@ -1 +1 @@
1
- import{atRule as v}from"postcss";function y(t){return new RegExp(`"[^"]+"|'[^']+'|url\\([^\\)]+\\)|(\\d*\\.?\\d+)`+t,"g")}var c={exact:function(t){return t.filter(function(n){return n.match(/^[^\*\!]+$/)})},contain:function(t){return t.filter(function(n){return n.match(/^\*.+\*$/)}).map(function(n){return n.substr(1,n.length-2)})},endWith:function(t){return t.filter(function(n){return n.match(/^\*[^\*]+$/)}).map(function(n){return n.substr(1)})},startWith:function(t){return t.filter(function(n){return n.match(/^[^\*\!]+\*$/)}).map(function(n){return n.substr(0,n.length-1)})},notExact:function(t){return t.filter(function(n){return n.match(/^\![^\*].*$/)}).map(function(n){return n.substr(1)})},notContain:function(t){return t.filter(function(n){return n.match(/^\!\*.+\*$/)}).map(function(n){return n.substr(2,n.length-3)})},notEndWith:function(t){return t.filter(function(n){return n.match(/^\!\*[^\*]+$/)}).map(function(n){return n.substr(2)})},notStartWith:function(t){return t.filter(function(n){return n.match(/^\![^\*]+\*$/)}).map(function(n){return n.substr(1,n.length-2)})}};function g(t){let n=t.indexOf("*")>-1,o=n&&t.length===1,e={exact:c.exact(t),contain:c.contain(t),startWith:c.startWith(t),endWith:c.endWith(t),notExact:c.notExact(t),notContain:c.notContain(t),notStartWith:c.notStartWith(t),notEndWith:c.notEndWith(t)};return function(i){return o?!0:(n||e.exact.indexOf(i)>-1||e.contain.some(function(r){return i.indexOf(r)>-1})||e.startWith.some(function(r){return i.indexOf(r)===0})||e.endWith.some(function(r){return i.indexOf(r)===i.length-r.length}))&&!(e.notExact.indexOf(i)>-1||e.notContain.some(function(r){return i.indexOf(r)>-1})||e.notStartWith.some(function(r){return i.indexOf(r)===0})||e.notEndWith.some(function(r){return i.indexOf(r)===i.length-r.length}))}}var b={unitToConvert:"px",viewportWidth:320,viewportHeight:568,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",selectorBlackList:[],propList:["*"],minPixelValue:1,mediaQuery:!1,replace:!0,landscape:!1,landscapeUnit:"vw",landscapeWidth:568},k=t=>{let n=Object.assign({},b,t),o=y(n.unitToConvert),e=g(n.propList),i=[];return{postcssPlugin:"postcss-px-to-viewport",Once(r){if(r.walkRules(function(u){let f=u.source&&u.source.input.file;if(n.exclude&&f)if(Object.prototype.toString.call(n.exclude)==="[object RegExp]"){if(m(n.exclude,f))return}else if(Object.prototype.toString.call(n.exclude)==="[object Array]"){for(let a=0;a<n.exclude.length;a++)if(m(n.exclude[a],f))return}else throw new Error("options.exclude should be RegExp or Array.");if(!O(n.selectorBlackList,u.selector)){if(n.landscape&&!u.parent.params){let a=u.clone().removeAll();u.walkDecls(function(s){s.value.indexOf(n.unitToConvert)!==-1&&e(s.prop)&&a.append(s.clone({value:s.value.replace(o,x(n,n.landscapeUnit,n.landscapeWidth))}))}),a.nodes.length>0&&i.push(a)}R(u.parent.params,n.mediaQuery)&&u.walkDecls(function(a,s){if(a.value.indexOf(n.unitToConvert)===-1||!e(a.prop))return;let l,p,h=u.parent.params;n.landscape&&h&&h.indexOf("landscape")!==-1?(l=n.landscapeUnit,p=n.landscapeWidth):(l=w(a.prop,n),p=n.viewportWidth);let d=a.value.replace(o,x(n,l,p));E(a.parent,a.prop,d)||(n.replace?a.value=d:a.parent.insertAfter(s,a.clone({value:d})))})}}),i.length>0){let u=v({params:"(orientation: landscape)",name:"media"});i.forEach(function(f){u.append(f)}),r.append(u)}}}};function w(t,n){return t.indexOf("font")===-1?n.viewportUnit:n.fontViewportUnit}function x(t,n,o){return function(e,i){if(!i)return e;let r=Number.parseFloat(i);if(r<=t.minPixelValue)return e;let u=W(r/o*100,t.unitPrecision);return u===0?"0":u+n}}function W(t,n){let o=10**(n+1),e=Math.floor(t*o);return Math.round(e/10)*10/o}function O(t,n){if(typeof n=="string")return t.some(function(o){return typeof o=="string"?n.indexOf(o)!==-1:n.match(o)})}function m(t,n){if(Object.prototype.toString.call(t)!=="[object RegExp]")throw new Error("options.exclude should be RegExp.");return n.match(t)!==null}function E(t,n,o){return t.some(function(e){return e.prop===n&&e.value===o})}function R(t,n){return!t||t&&n}export{k as default};
1
+ import{atRule as w}from"postcss";function x(t){return new RegExp(`"[^"]+"|'[^']+'|url\\([^\\)]+\\)|(\\d*\\.?\\d+)`+t,"g")}var c={exact:function(t){return t.filter(function(n){return n.match(/^[^\*\!]+$/)})},contain:function(t){return t.filter(function(n){return n.match(/^\*.+\*$/)}).map(function(n){return n.substr(1,n.length-2)})},endWith:function(t){return t.filter(function(n){return n.match(/^\*[^\*]+$/)}).map(function(n){return n.substr(1)})},startWith:function(t){return t.filter(function(n){return n.match(/^[^\*\!]+\*$/)}).map(function(n){return n.substr(0,n.length-1)})},notExact:function(t){return t.filter(function(n){return n.match(/^\![^\*].*$/)}).map(function(n){return n.substr(1)})},notContain:function(t){return t.filter(function(n){return n.match(/^\!\*.+\*$/)}).map(function(n){return n.substr(2,n.length-3)})},notEndWith:function(t){return t.filter(function(n){return n.match(/^\!\*[^\*]+$/)}).map(function(n){return n.substr(2)})},notStartWith:function(t){return t.filter(function(n){return n.match(/^\![^\*]+\*$/)}).map(function(n){return n.substr(1,n.length-2)})}};function m(t){let n=t.indexOf("*")>-1,o=n&&t.length===1,e={exact:c.exact(t),contain:c.contain(t),startWith:c.startWith(t),endWith:c.endWith(t),notExact:c.notExact(t),notContain:c.notContain(t),notStartWith:c.notStartWith(t),notEndWith:c.notEndWith(t)};return function(i){return o?!0:(n||e.exact.indexOf(i)>-1||e.contain.some(function(r){return i.indexOf(r)>-1})||e.startWith.some(function(r){return i.indexOf(r)===0})||e.endWith.some(function(r){return i.indexOf(r)===i.length-r.length}))&&!(e.notExact.indexOf(i)>-1||e.notContain.some(function(r){return i.indexOf(r)>-1})||e.notStartWith.some(function(r){return i.indexOf(r)===0})||e.notEndWith.some(function(r){return i.indexOf(r)===i.length-r.length}))}}var W={unitToConvert:"px",viewportWidth:320,viewportHeight:568,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",selectorBlackList:[],propList:["*"],minPixelValue:1,mediaQuery:!1,replace:!0,landscape:!1,landscapeUnit:"vw",landscapeWidth:568},M=t=>{let n=Object.assign({},W,t),o=x(n.unitToConvert),e=m(n.propList),i=[];return{postcssPlugin:"postcss-px-to-viewport",Once(r){if(r.walkRules(function(u){let f=u.source&&u.source.input.file;if(n.exclude&&f)if(Object.prototype.toString.call(n.exclude)==="[object RegExp]"){if(b(n.exclude,f))return}else if(Object.prototype.toString.call(n.exclude)==="[object Array]"){for(let a=0;a<n.exclude.length;a++)if(b(n.exclude[a],f))return}else throw new Error("options.exclude should be RegExp or Array.");if(!R(n.selectorBlackList,u.selector)){if(n.landscape&&!u.parent.params){let a=u.clone().removeAll();u.walkDecls(function(s){s.value.indexOf(n.unitToConvert)!==-1&&e(s.prop)&&a.append(s.clone({value:s.value.replace(o,v(n,n.landscapeUnit,n.landscapeWidth))}))}),a.nodes.length>0&&i.push(a)}U(u.parent.params,n.mediaQuery)&&u.walkDecls(function(a,s){if(a.value.indexOf(n.unitToConvert)===-1||!e(a.prop))return;let l,p,h=u.parent.params;n.landscape&&h&&h.indexOf("landscape")!==-1?(l=n.landscapeUnit,p=n.landscapeWidth):(l=O(a.prop,n),p=n.viewportWidth);let d=a.value.replace(o,v(n,l,p));P(a.parent,a.prop,d)||(n.replace?a.value=d:a.parent.insertAfter(s,a.clone({value:d})))})}}),i.length>0){let u=w({params:"(orientation: landscape)",name:"media"});i.forEach(function(f){u.append(f)}),r.append(u)}}}};function O(t,n){return t.indexOf("font")===-1?n.viewportUnit:n.fontViewportUnit}function v(t,n,o){return function(e,i){if(!i)return e;let r=Number.parseFloat(i);if(r<=t.minPixelValue)return e;let u=E(r/o*100,t.unitPrecision);return u===0?"0":u+n}}function E(t,n){let o=10**(n+1),e=Math.floor(t*o);return Math.round(e/10)*10/o}function R(t,n){if(typeof n=="string")return t.some(function(o){return typeof o=="string"?n.indexOf(o)!==-1:n.match(o)})}function b(t,n){if(Object.prototype.toString.call(t)!=="[object RegExp]")throw new Error("options.exclude should be RegExp.");return n.match(t)!==null}function P(t,n,o){return t.some(function(e){return e.prop===n&&e.value===o})}function U(t,n){return!t||t&&n}export{M as default};
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@empjs/plugin-postcss",
3
- "version": "3.0.0-rc.29",
3
+ "version": "3.0.0-rc.30",
4
4
  "description": "emp postcss plugin",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "files": ["dist"],
8
- "maintainers": ["xuhongbin", "ckken"],
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "maintainers": [
11
+ "xuhongbin",
12
+ "ckken"
13
+ ],
9
14
  "repository": {
10
15
  "type": "git",
11
16
  "url": "git+https://github.com/empjs/emp.git",
@@ -14,7 +19,9 @@
14
19
  "publishConfig": {
15
20
  "access": "public"
16
21
  },
17
- "keywords": ["postcss"],
22
+ "keywords": [
23
+ "postcss"
24
+ ],
18
25
  "main": "dist/index.js",
19
26
  "types": "dist/index.d.ts",
20
27
  "exports": {
@@ -29,22 +36,22 @@
29
36
  }
30
37
  }
31
38
  },
32
- "scripts": {
33
- "build": "tsup",
34
- "dev": "tsup --watch"
35
- },
36
39
  "engines": {
37
- "node": ">=18.0.0"
40
+ "node": ">=16.0.0"
38
41
  },
39
42
  "author": "Ken",
40
43
  "devDependencies": {
41
- "@empjs/cli": "workspace:*",
42
- "tsup": "^8.0.2"
44
+ "tsup": "^8.0.2",
45
+ "@empjs/cli": "3.0.0-rc.30"
43
46
  },
44
47
  "dependencies": {
45
48
  "postcss": "^8.4.38",
46
49
  "postcss-loader": "^8.1.1",
47
50
  "autoprefixer": "^10.4.19",
48
51
  "postcss-pxtorem": "^6.1.0"
52
+ },
53
+ "scripts": {
54
+ "build": "tsup",
55
+ "dev": "tsup --watch"
49
56
  }
50
- }
57
+ }