@empjs/plugin-lightningcss 3.0.0-rc.14 → 3.0.0-rc.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/dist/index.cjs +1 -0
- package/dist/{postcss-polyfill.d.ts → index.d.cts} +55 -4
- package/dist/index.d.ts +137 -6
- package/dist/index.js +1 -1
- package/dist/loader.cjs +1 -1
- package/dist/loader.d.cts +7 -0
- package/dist/loader.d.ts +6 -3
- package/dist/loader.js +1 -0
- package/dist/{types.d.ts → types-Dyx0p7wd.d.cts} +7 -8
- package/dist/types-Dyx0p7wd.d.ts +40 -0
- package/package.json +20 -16
- package/dist/minimizer.d.ts +0 -10
- package/dist/plugin.d.ts +0 -7
- package/dist/px-to-base.d.ts +0 -53
- package/dist/unit-tramsform.d.ts +0 -52
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var G=Object.create;var m=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var k=(r,e)=>()=>(r&&(e=r(r=0)),e);var w=(r,e)=>{for(var t in e)m(r,t,{get:e[t],enumerable:!0})},V=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of D(e))!N.call(r,n)&&n!==t&&m(r,n,{get:()=>e[n],enumerable:!(s=q(e,n))||s.enumerable});return r};var R=(r,e,t)=>(t=r!=null?G(W(r)):{},V(e||!r||!r.__esModule?m(t,"default",{value:r,enumerable:!0}):t,r)),$=r=>V(m({},"__esModule",{value:!0}),r);var a=k(()=>{"use strict"});var A={};w(A,{LightningCSSMinifyPlugin:()=>f,default:()=>Q});var _,C,u,F,f,Q,O=k(()=>{"use strict";a();_=require("buffer"),C=require("lightningcss"),u="lightningcss-minify-plugin",F=/\.css(?:\?.*)?$/i,f=class{options;transform;constructor(e={}){let{implementation:t}=e;if(t&&typeof t.transform!="function")throw new TypeError(`[${u}]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof t.transform}`);this.transform=t?.transform??C.transform,this.options=e}apply(e){e.hooks.compilation.tap(u,t=>{t.hooks.processAssets.tapPromise({name:u,stage:t?.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE},async()=>await this.transformAssets(t)),t.hooks.statsPrinter.tap(u,s=>{s.hooks.print.for("asset.info.minimized").tap(u,(n,{green:o,formatFlag:i})=>n&&o&&i?o(i("minimized")):"")})})}async transformAssets(e){let{options:{devtool:t},webpack:{sources:{SourceMapSource:s,RawSource:n}}}=e.compiler,o=this.options.sourceMap===void 0?t&&t.includes("source-map"):this.options.sourceMap,{targets:i,...p}=this.options,v=e.getAssets().filter(l=>!l.info.minimized&&F.test(l.name));await Promise.all(v.map(async l=>{let{source:c,map:I}=l.source.sourceAndMap(),j=c.toString(),z=typeof c=="string"?_.Buffer.from(c):c,b=this.transform({filename:l.name,code:z,minify:!0,sourceMap:o,...p}),S=b.code.toString();e.updateAsset(l.name,o?new s(S,l.name,JSON.parse(b.map.toString()),j,I,!0):new n(S),{...l.info,minimized:!0})}))}},Q=f});var H={};w(H,{composeVisitors:()=>U.composeVisitors,default:()=>J,postcss:()=>M});module.exports=$(H);a();var U=require("lightningcss");a();var T=R(require("path"),1),P=R(require("browserslist"),1),E=require("lightningcss"),X=async(r,e={})=>{if(!e.transform)return;e.transform=typeof e.transform!="boolean"?e.transform:{};let{chain:t}=r,s=["sass","less","css"],o={targets:(0,E.browserslistToTargets)((0,P.default)(r.empConfig.build.browserslist)),...e.transform};for(let i of s){let p=t.module.rule(i),v=p.use("lightningcss").loader(T.default.resolve(__dirname,"loader.cjs")).options(o);["sass","less"].includes(i)&&v.before(`${i}Loader`),p.uses.delete("postcss")}},B=async(r,e={})=>{if(!e.minify)return;e.minify=typeof e.minify!="boolean"?e.minify:{};let{chain:t}=r,{LightningCSSMinifyPlugin:s}=await Promise.resolve().then(()=>(O(),A));t.optimization.minimizer("minCss").use(s,[e.minify])},Z=(r={})=>(r.transform&&typeof r.minify>"u"&&(r.minify=!0),{name:"@empjs/plugin-lightningcss",async rsConfig(e){await Promise.all([X(e,r),B(e,r)])}}),L=Z;a();var g=require("lightningcss");a();var d=class{skipSelector=!1;skipVal=!1;isExclude;isDebug=!1;op={designWidth:320,minPixelValue:1,excludeSelectors:[],transformUnit:"",excludeUnit:"ipx",rootValue:16};debug(...e){this.isDebug&&console.log(...e)}Selector=e=>{this.skipSelector=!1;for(let t of e)this.isExclude(t)&&(this.skipSelector=!0)};Token={dimension:e=>{if(this.debug("dimension",e),this.skipVal=!1,e.unit===this.op.excludeUnit)return this.skipVal=!0,{type:"length",value:{unit:"px",value:e.value}}}};Length=e=>{this.debug(e,"skipVal",this.skipVal,"skipSelector",this.skipSelector);let t={unit:"px",value:e.value};if(e.unit==="px"&&!this.skipSelector){if(Math.abs(e.value)>this.op.minPixelValue&&!this.skipVal)switch(this.op.transformUnit){case"rem":t={unit:"rem",value:e.value/this.op.rootValue};break;case"vw":t={unit:"vw",value:e.value/this.op.designWidth*100};break;default:break}return this.skipVal=!1,t}else this.skipVal=!1};pxToRem(e={}){return this.op.transformUnit="rem",this.op=Object.assign(this.op,e),this.isExclude=this.excludeFilter(this.op.excludeSelectors),{Selector:this.Selector,Token:this.Token,Length:this.Length}}pxToVw(e={}){return this.op.transformUnit="vw",this.op=Object.assign(this.op,e),this.isExclude=this.excludeFilter(this.op.excludeSelectors),{Selector:this.Selector,Token:this.Token,Length:this.Length}}excludeFilter(e){return s=>{if(this.debug(s,e),!s.name)return!1;for(let n of e)if(s.type===n.type&&(typeof n.name=="string"&&n.name===s.name||typeof n.name=="object"&&n.name.test(s.name)))return!0;return!1}}},h=new d;var x=class{px_to_rem(e={}){return(0,g.composeVisitors)([h.pxToRem(e)])}pxtorem=this.px_to_rem;pxtovw=this.px_to_viewport;px_to_viewport(e={}){return(0,g.composeVisitors)([h.pxToVw(e)])}apply(e){return e=e||new Map,{Rule:{style(t){for(let s of t.value.selectors)if(s.length===1&&s[0].type==="type"&&s[0].name.startsWith("--"))return e.set(s[0].name,t.value.declarations),{type:"ignored",value:null};return t.value.rules=t.value.rules.filter(s=>{if(s.type==="unknown"&&s.value.name==="apply"){for(let n of s.value.prelude)if(n.type==="dashed-ident"&&e.has(n.value)){let o=e.get(n.value),i=t.value.declarations;i.declarations.push(...o.declarations),i.importantDeclarations.push(...o.importantDeclarations)}return!1}return!0}),t}}}}selector_prefix(){return{Selector(e){return[{type:"class",name:"prefix"},{type:"combinator",value:"descendant"},...e]}}}static_vars(e){return e=e||new Map,{Rule:{unknown(t){return e.set(t.name,t.prelude),[]}},Token:{"at-keyword"(t){if(e.has(t.value))return e.get(t.value)}}}}url(e){return{Url(t){return t.url=e+t.url,t}}}specific_environment_variables(e){let t={};for(let s in e)t[s]=()=>e[s];return{EnvironmentVariable:t}}env_function(e){return{EnvironmentVariable(t){if(t.name.type==="custom")return e[t.name.ident]}}}design_tokens(e){return{Function:{"design-token"(t){if(t.arguments.length===1&&t.arguments[0].type==="token"&&t.arguments[0].value.type==="string")return e[t.arguments[0].value.value]}}}}custom_units(){return{Token:{dimension(e){if(e.unit.startsWith("--"))return{type:"function",value:{name:"calc",arguments:[{type:"token",value:{type:"number",value:e.value}},{type:"token",value:{type:"delim",value:"*"}},{type:"var",value:{name:{ident:e.unit}}}]}}}}}}property_lookup(){return{Rule:{style(e){let t=new Map;for(let s of e.value.declarations.declarations){let n=s.property;s.property==="unparsed"&&(n=s.value.propertyId.property),t.set(n,s)}return e.value.declarations.declarations=e.value.declarations.declarations.map(s=>{if(s.property==="unparsed"&&s.value.value.length===1){let n=s.value.value[0];if(n.type==="token"&&n.value.type==="at-keyword"&&t.has(n.value.value)){let o=t.get(n.value.value);return{property:s.value.propertyId.property,value:o.value}}}return s}),e}}}}focus_visible(){return{Rule:{style(e){let t=null;for(let s of e.value.selectors)for(let[n,o]of s.entries())o.type==="pseudo-class"&&o.kind==="focus-visible"&&(t==null&&(t=[...e.value.selectors.map(i=>[...i])]),s[n]={type:"class",name:"focus-visible"});if(t)return[e,{type:"style",value:{...e.value,selectors:t}}]}}}}dark_theme_class(){return{Rule:{media(e){let t=e.value.query.mediaQueries[0];if(t.condition?.type==="feature"&&t.condition.value.type==="plain"&&t.condition.value.name==="prefers-color-scheme"&&t.condition.value.value.value==="dark"){let s=[e];for(let n of e.value.rules)if(n.type==="style"){let o=[];for(let i of n.value.selectors)o.push([{type:"type",name:"html"},{type:"attribute",name:"theme",operation:{operator:"equal",value:"dark"}},{type:"combinator",value:"descendant"},...i]),i.unshift({type:"type",name:"html"},{type:"pseudo-class",kind:"not",selectors:[[{type:"attribute",name:"theme",operation:{operator:"equal",value:"light"}}]]},{type:"combinator",value:"descendant"});s.push({type:"style",value:{...n.value,selectors:o}})}return s}}}}}fix_100vh(){return{Rule:{style(e){let t;for(let s of e.value.declarations.declarations)s.property==="height"&&s.value.type==="length-percentage"&&s.value.value.type==="dimension"&&s.value.value.value.unit==="vh"&&s.value.value.value.value===100&&(t||(t=structuredClone(e),t.value.declarations.declarations=[]),t.value.declarations.declarations.push({...s,value:{type:"stretch",vendorPrefix:["webkit"]}}));if(t)return[e,{type:"supports",value:{condition:{type:"declaration",propertyId:{property:"-webkit-touch-callout"},value:"none"},loc:e.value.loc,rules:[t]}}]}}}}logical_transforms(){return{Rule:{style(e){let t;for(let s of e.value.declarations.declarations)if(s.property==="transform"){let n=s.value.map(o=>{if(o.type!=="translateX")return o;t||(t=structuredClone(e),t.value.declarations.declarations=[]);let i;switch(o.value.type){case"dimension":i={type:"dimension",value:{unit:o.value.value.unit,value:-o.value.value.value}};break;case"percentage":i={type:"percentage",value:-o.value.value};break;case"calc":i={type:"calc",value:{type:"product",value:[-1,o.value.value]}};break}return{type:"translateX",value:i}});t&&(t.value.selectors.at(-1).push({type:"pseudo-class",kind:"dir",direction:"rtl"}),t.value.declarations.declarations.push({...s,value:n}))}if(t)return[e,t]}}}}hover_media_query(){return{Rule:{media(e){let t=e.value.query.mediaQueries;if(t.length===1&&t[0].condition&&t[0].condition.type==="feature"&&t[0].condition.value.type==="boolean"&&t[0].condition.value.name==="hover"){for(let s of e.value.rules)if(s.type==="style")for(let n of s.value.selectors)n.unshift({type:"class",name:"hoverable"},{type:"combinator",value:"descendant"});return e.value.rules}}}}}momentum_scrolling(e){return{Declaration:{overflow:e,"overflow-x":e,"overflow-y":e}}}size(){return{Declaration:{custom:{size(e){if(e.value[0].type==="length"){let t={type:"length-percentage",value:{type:"dimension",value:e.value[0].value}};return[{property:"width",value:t},{property:"height",value:t}]}}}}}}},M=new x;var J=L;0&&(module.exports={composeVisitors,postcss});
|
|
@@ -1,6 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
import { Visitor, CustomAtRules } from 'lightningcss';
|
|
2
|
+
export { composeVisitors } from 'lightningcss';
|
|
3
|
+
import { GlobalStore } from '@empjs/cli';
|
|
4
|
+
import { P as PluginLightningcssOptions } from './types-Dyx0p7wd.cjs';
|
|
5
|
+
|
|
6
|
+
declare const empLightningcssPlugin: (o?: PluginLightningcssOptions) => {
|
|
7
|
+
name: string;
|
|
8
|
+
rsConfig(store: GlobalStore): Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type ExcludeSelectorsType = {
|
|
12
|
+
type: string;
|
|
13
|
+
name: RegExp | string;
|
|
14
|
+
};
|
|
15
|
+
interface Options$1 {
|
|
16
|
+
designWidth: number;
|
|
17
|
+
minPixelValue: number;
|
|
18
|
+
/**
|
|
19
|
+
* 屏蔽选择器 [{type: 'class', name: 'cssModule'}]
|
|
20
|
+
* @default []
|
|
21
|
+
*/
|
|
22
|
+
excludeSelectors: ExcludeSelectorsType[];
|
|
23
|
+
transformUnit: 'vw' | 'rem' | '';
|
|
24
|
+
/**
|
|
25
|
+
* 屏蔽单位 大小写无法区分 只支持 ipx 等纯字母变量
|
|
26
|
+
* 加上横杠会出现不可预知问题 如 marign 1-px solid #222 会多出一个空格
|
|
27
|
+
* @default ipx
|
|
28
|
+
*/
|
|
29
|
+
excludeUnit: string;
|
|
30
|
+
rootValue: number;
|
|
31
|
+
}
|
|
32
|
+
type vwOptions = Partial<Options$1>;
|
|
33
|
+
type remOptions = Partial<Options$1>;
|
|
34
|
+
|
|
4
35
|
/**
|
|
5
36
|
* // 插件编写 https://github.com/parcel-bundler/lightningcss/blob/master/node/test/visitor.test.mjs
|
|
6
37
|
*/
|
|
@@ -83,4 +114,24 @@ declare class PostcssConfig {
|
|
|
83
114
|
size(): any;
|
|
84
115
|
}
|
|
85
116
|
declare const _default: PostcssConfig;
|
|
86
|
-
|
|
117
|
+
|
|
118
|
+
interface Options {
|
|
119
|
+
designWidth: number;
|
|
120
|
+
minPixelValue: number;
|
|
121
|
+
excludeSelectors: {
|
|
122
|
+
type: string;
|
|
123
|
+
name: RegExp | string;
|
|
124
|
+
}[];
|
|
125
|
+
}
|
|
126
|
+
type PxToVwOptions = Partial<Options>;
|
|
127
|
+
type PxToRemOptions = {
|
|
128
|
+
rootValue?: number;
|
|
129
|
+
minPixelValue?: number;
|
|
130
|
+
excludeSelectors?: {
|
|
131
|
+
type: string;
|
|
132
|
+
name: RegExp | string;
|
|
133
|
+
}[];
|
|
134
|
+
excludeUnit?: string;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export { type PxToRemOptions, type PxToVwOptions, empLightningcssPlugin as default, _default as postcss };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,137 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Visitor, CustomAtRules } from 'lightningcss';
|
|
2
|
+
export { composeVisitors } from 'lightningcss';
|
|
3
|
+
import { GlobalStore } from '@empjs/cli';
|
|
4
|
+
import { P as PluginLightningcssOptions } from './types-Dyx0p7wd.js';
|
|
5
|
+
|
|
6
|
+
declare const empLightningcssPlugin: (o?: PluginLightningcssOptions) => {
|
|
7
|
+
name: string;
|
|
8
|
+
rsConfig(store: GlobalStore): Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type ExcludeSelectorsType = {
|
|
12
|
+
type: string;
|
|
13
|
+
name: RegExp | string;
|
|
14
|
+
};
|
|
15
|
+
interface Options$1 {
|
|
16
|
+
designWidth: number;
|
|
17
|
+
minPixelValue: number;
|
|
18
|
+
/**
|
|
19
|
+
* 屏蔽选择器 [{type: 'class', name: 'cssModule'}]
|
|
20
|
+
* @default []
|
|
21
|
+
*/
|
|
22
|
+
excludeSelectors: ExcludeSelectorsType[];
|
|
23
|
+
transformUnit: 'vw' | 'rem' | '';
|
|
24
|
+
/**
|
|
25
|
+
* 屏蔽单位 大小写无法区分 只支持 ipx 等纯字母变量
|
|
26
|
+
* 加上横杠会出现不可预知问题 如 marign 1-px solid #222 会多出一个空格
|
|
27
|
+
* @default ipx
|
|
28
|
+
*/
|
|
29
|
+
excludeUnit: string;
|
|
30
|
+
rootValue: number;
|
|
31
|
+
}
|
|
32
|
+
type vwOptions = Partial<Options$1>;
|
|
33
|
+
type remOptions = Partial<Options$1>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* // 插件编写 https://github.com/parcel-bundler/lightningcss/blob/master/node/test/visitor.test.mjs
|
|
37
|
+
*/
|
|
38
|
+
declare class PostcssConfig {
|
|
39
|
+
/**
|
|
40
|
+
* https://github.com/cuth/postcss-pxtorem
|
|
41
|
+
*/
|
|
42
|
+
px_to_rem(op?: remOptions): Visitor<CustomAtRules>;
|
|
43
|
+
pxtorem: (op?: remOptions) => Visitor<CustomAtRules>;
|
|
44
|
+
pxtovw: (op?: vwOptions) => Visitor<CustomAtRules>;
|
|
45
|
+
/**
|
|
46
|
+
* https://github.com/evrone/postcss-px-to-viewport
|
|
47
|
+
*/
|
|
48
|
+
px_to_viewport(op?: vwOptions): Visitor<CustomAtRules>;
|
|
49
|
+
/**
|
|
50
|
+
* https://www.npmjs.com/package/postcss-apply
|
|
51
|
+
*/
|
|
52
|
+
apply(defined: Map<any, any>): Visitor<CustomAtRules>;
|
|
53
|
+
/**
|
|
54
|
+
* https://www.npmjs.com/package/postcss-prefix-selector
|
|
55
|
+
*/
|
|
56
|
+
selector_prefix(): Visitor<CustomAtRules>;
|
|
57
|
+
/**
|
|
58
|
+
* https://www.npmjs.com/package/postcss-simple-vars
|
|
59
|
+
*/
|
|
60
|
+
static_vars(declared: Map<any, any>): Visitor<CustomAtRules>;
|
|
61
|
+
/**
|
|
62
|
+
* https://www.npmjs.com/package/postcss-url
|
|
63
|
+
*/
|
|
64
|
+
url(hostUrl: string): Visitor<CustomAtRules>;
|
|
65
|
+
/**
|
|
66
|
+
* https://www.npmjs.com/package/postcss-env-function
|
|
67
|
+
*/
|
|
68
|
+
specific_environment_variables(tokens: {
|
|
69
|
+
[k: string]: any;
|
|
70
|
+
}): Visitor<CustomAtRules>;
|
|
71
|
+
/**
|
|
72
|
+
* https://www.npmjs.com/package/postcss-env-function
|
|
73
|
+
*/
|
|
74
|
+
env_function(tokens: any): Visitor<CustomAtRules>;
|
|
75
|
+
/**
|
|
76
|
+
* https://www.npmjs.com/package/@csstools/postcss-design-tokens
|
|
77
|
+
*/
|
|
78
|
+
design_tokens(tokens: any): Visitor<CustomAtRules>;
|
|
79
|
+
/**
|
|
80
|
+
* https://github.com/csstools/custom-units
|
|
81
|
+
*/
|
|
82
|
+
custom_units(): Visitor<CustomAtRules>;
|
|
83
|
+
/**
|
|
84
|
+
* https://www.npmjs.com/package/postcss-property-lookup
|
|
85
|
+
*/
|
|
86
|
+
property_lookup(): Visitor<CustomAtRules>;
|
|
87
|
+
/**
|
|
88
|
+
* https://www.npmjs.com/package/postcss-focus-visible
|
|
89
|
+
*/
|
|
90
|
+
focus_visible(): Visitor<CustomAtRules>;
|
|
91
|
+
/**
|
|
92
|
+
* https://github.com/postcss/postcss-dark-theme-class
|
|
93
|
+
*/
|
|
94
|
+
dark_theme_class(): Visitor<CustomAtRules>;
|
|
95
|
+
/**
|
|
96
|
+
* https://github.com/postcss/postcss-100vh-fix
|
|
97
|
+
*/
|
|
98
|
+
fix_100vh(): Visitor<CustomAtRules>;
|
|
99
|
+
/**
|
|
100
|
+
* https://github.com/MohammadYounes/rtlcss
|
|
101
|
+
*/
|
|
102
|
+
logical_transforms(): Visitor<CustomAtRules>;
|
|
103
|
+
/**
|
|
104
|
+
* https://github.com/twbs/mq4-hover-shim
|
|
105
|
+
*/
|
|
106
|
+
hover_media_query(): Visitor<CustomAtRules>;
|
|
107
|
+
/**
|
|
108
|
+
* https://github.com/yunusga/postcss-momentum-scrolling
|
|
109
|
+
*/
|
|
110
|
+
momentum_scrolling(visitOverflow: any): Visitor<CustomAtRules>;
|
|
111
|
+
/**
|
|
112
|
+
* https://github.com/postcss/postcss-size
|
|
113
|
+
*/
|
|
114
|
+
size(): any;
|
|
115
|
+
}
|
|
116
|
+
declare const _default: PostcssConfig;
|
|
117
|
+
|
|
118
|
+
interface Options {
|
|
119
|
+
designWidth: number;
|
|
120
|
+
minPixelValue: number;
|
|
121
|
+
excludeSelectors: {
|
|
122
|
+
type: string;
|
|
123
|
+
name: RegExp | string;
|
|
124
|
+
}[];
|
|
125
|
+
}
|
|
126
|
+
type PxToVwOptions = Partial<Options>;
|
|
127
|
+
type PxToRemOptions = {
|
|
128
|
+
rootValue?: number;
|
|
129
|
+
minPixelValue?: number;
|
|
130
|
+
excludeSelectors?: {
|
|
131
|
+
type: string;
|
|
132
|
+
name: RegExp | string;
|
|
133
|
+
}[];
|
|
134
|
+
excludeUnit?: string;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export { type PxToRemOptions, type PxToVwOptions, empLightningcssPlugin as default, _default as postcss };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var T=Object.defineProperty;var k=(i,e)=>()=>(i&&(e=i(i=0)),e);var O=(i,e)=>{for(var t in e)T(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as P}from"url";import E from"path";var L,M,u,a=k(()=>{"use strict";L=()=>P(import.meta.url),M=()=>E.dirname(L()),u=M()});var S={};O(S,{LightningCSSMinifyPlugin:()=>f,default:()=>z});import{Buffer as I}from"buffer";import{transform as U}from"lightningcss";var p,j,f,z,V=k(()=>{"use strict";a();p="lightningcss-minify-plugin",j=/\.css(?:\?.*)?$/i,f=class{options;transform;constructor(e={}){let{implementation:t}=e;if(t&&typeof t.transform!="function")throw new TypeError(`[${p}]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof t.transform}`);this.transform=t?.transform??U,this.options=e}apply(e){e.hooks.compilation.tap(p,t=>{t.hooks.processAssets.tapPromise({name:p,stage:t?.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE},async()=>await this.transformAssets(t)),t.hooks.statsPrinter.tap(p,s=>{s.hooks.print.for("asset.info.minimized").tap(p,(o,{green:r,formatFlag:n})=>o&&r&&n?r(n("minimized")):"")})})}async transformAssets(e){let{options:{devtool:t},webpack:{sources:{SourceMapSource:s,RawSource:o}}}=e.compiler,r=this.options.sourceMap===void 0?t&&t.includes("source-map"):this.options.sourceMap,{targets:n,...c}=this.options,v=e.getAssets().filter(l=>!l.info.minimized&&j.test(l.name));await Promise.all(v.map(async l=>{let{source:m,map:_}=l.source.sourceAndMap(),C=m.toString(),A=typeof m=="string"?I.from(m):m,x=this.transform({filename:l.name,code:A,minify:!0,sourceMap:r,...c}),b=x.code.toString();e.updateAsset(l.name,r?new s(b,l.name,JSON.parse(x.map.toString()),C,_,!0):new o(b),{...l.info,minimized:!0})}))}},z=f});a();import{composeVisitors as ce}from"lightningcss";a();import D from"path";import G from"browserslist";import{browserslistToTargets as q}from"lightningcss";var W=async(i,e={})=>{if(!e.transform)return;e.transform=typeof e.transform!="boolean"?e.transform:{};let{chain:t}=i,s=["sass","less","css"],r={targets:q(G(i.empConfig.build.browserslist)),...e.transform};for(let n of s){let c=t.module.rule(n),v=c.use("lightningcss").loader(D.resolve(u,"loader.cjs")).options(r);["sass","less"].includes(n)&&v.before(`${n}Loader`),c.uses.delete("postcss")}},F=async(i,e={})=>{if(!e.minify)return;e.minify=typeof e.minify!="boolean"?e.minify:{};let{chain:t}=i,{LightningCSSMinifyPlugin:s}=await Promise.resolve().then(()=>(V(),S));t.optimization.minimizer("minCss").use(s,[e.minify])},N=(i={})=>(i.transform&&typeof i.minify>"u"&&(i.minify=!0),{name:"@empjs/plugin-lightningcss",async rsConfig(e){await Promise.all([W(e,i),F(e,i)])}}),w=N;a();import{composeVisitors as R}from"lightningcss";a();var d=class{skipSelector=!1;skipVal=!1;isExclude;isDebug=!1;op={designWidth:320,minPixelValue:1,excludeSelectors:[],transformUnit:"",excludeUnit:"ipx",rootValue:16};debug(...e){this.isDebug&&console.log(...e)}Selector=e=>{this.skipSelector=!1;for(let t of e)this.isExclude(t)&&(this.skipSelector=!0)};Token={dimension:e=>{if(this.debug("dimension",e),this.skipVal=!1,e.unit===this.op.excludeUnit)return this.skipVal=!0,{type:"length",value:{unit:"px",value:e.value}}}};Length=e=>{this.debug(e,"skipVal",this.skipVal,"skipSelector",this.skipSelector);let t={unit:"px",value:e.value};if(e.unit==="px"&&!this.skipSelector){if(Math.abs(e.value)>this.op.minPixelValue&&!this.skipVal)switch(this.op.transformUnit){case"rem":t={unit:"rem",value:e.value/this.op.rootValue};break;case"vw":t={unit:"vw",value:e.value/this.op.designWidth*100};break;default:break}return this.skipVal=!1,t}else this.skipVal=!1};pxToRem(e={}){return this.op.transformUnit="rem",this.op=Object.assign(this.op,e),this.isExclude=this.excludeFilter(this.op.excludeSelectors),{Selector:this.Selector,Token:this.Token,Length:this.Length}}pxToVw(e={}){return this.op.transformUnit="vw",this.op=Object.assign(this.op,e),this.isExclude=this.excludeFilter(this.op.excludeSelectors),{Selector:this.Selector,Token:this.Token,Length:this.Length}}excludeFilter(e){return s=>{if(this.debug(s,e),!s.name)return!1;for(let o of e)if(s.type===o.type&&(typeof o.name=="string"&&o.name===s.name||typeof o.name=="object"&&o.name.test(s.name)))return!0;return!1}}},h=new d;var g=class{px_to_rem(e={}){return R([h.pxToRem(e)])}pxtorem=this.px_to_rem;pxtovw=this.px_to_viewport;px_to_viewport(e={}){return R([h.pxToVw(e)])}apply(e){return e=e||new Map,{Rule:{style(t){for(let s of t.value.selectors)if(s.length===1&&s[0].type==="type"&&s[0].name.startsWith("--"))return e.set(s[0].name,t.value.declarations),{type:"ignored",value:null};return t.value.rules=t.value.rules.filter(s=>{if(s.type==="unknown"&&s.value.name==="apply"){for(let o of s.value.prelude)if(o.type==="dashed-ident"&&e.has(o.value)){let r=e.get(o.value),n=t.value.declarations;n.declarations.push(...r.declarations),n.importantDeclarations.push(...r.importantDeclarations)}return!1}return!0}),t}}}}selector_prefix(){return{Selector(e){return[{type:"class",name:"prefix"},{type:"combinator",value:"descendant"},...e]}}}static_vars(e){return e=e||new Map,{Rule:{unknown(t){return e.set(t.name,t.prelude),[]}},Token:{"at-keyword"(t){if(e.has(t.value))return e.get(t.value)}}}}url(e){return{Url(t){return t.url=e+t.url,t}}}specific_environment_variables(e){let t={};for(let s in e)t[s]=()=>e[s];return{EnvironmentVariable:t}}env_function(e){return{EnvironmentVariable(t){if(t.name.type==="custom")return e[t.name.ident]}}}design_tokens(e){return{Function:{"design-token"(t){if(t.arguments.length===1&&t.arguments[0].type==="token"&&t.arguments[0].value.type==="string")return e[t.arguments[0].value.value]}}}}custom_units(){return{Token:{dimension(e){if(e.unit.startsWith("--"))return{type:"function",value:{name:"calc",arguments:[{type:"token",value:{type:"number",value:e.value}},{type:"token",value:{type:"delim",value:"*"}},{type:"var",value:{name:{ident:e.unit}}}]}}}}}}property_lookup(){return{Rule:{style(e){let t=new Map;for(let s of e.value.declarations.declarations){let o=s.property;s.property==="unparsed"&&(o=s.value.propertyId.property),t.set(o,s)}return e.value.declarations.declarations=e.value.declarations.declarations.map(s=>{if(s.property==="unparsed"&&s.value.value.length===1){let o=s.value.value[0];if(o.type==="token"&&o.value.type==="at-keyword"&&t.has(o.value.value)){let r=t.get(o.value.value);return{property:s.value.propertyId.property,value:r.value}}}return s}),e}}}}focus_visible(){return{Rule:{style(e){let t=null;for(let s of e.value.selectors)for(let[o,r]of s.entries())r.type==="pseudo-class"&&r.kind==="focus-visible"&&(t==null&&(t=[...e.value.selectors.map(n=>[...n])]),s[o]={type:"class",name:"focus-visible"});if(t)return[e,{type:"style",value:{...e.value,selectors:t}}]}}}}dark_theme_class(){return{Rule:{media(e){let t=e.value.query.mediaQueries[0];if(t.condition?.type==="feature"&&t.condition.value.type==="plain"&&t.condition.value.name==="prefers-color-scheme"&&t.condition.value.value.value==="dark"){let s=[e];for(let o of e.value.rules)if(o.type==="style"){let r=[];for(let n of o.value.selectors)r.push([{type:"type",name:"html"},{type:"attribute",name:"theme",operation:{operator:"equal",value:"dark"}},{type:"combinator",value:"descendant"},...n]),n.unshift({type:"type",name:"html"},{type:"pseudo-class",kind:"not",selectors:[[{type:"attribute",name:"theme",operation:{operator:"equal",value:"light"}}]]},{type:"combinator",value:"descendant"});s.push({type:"style",value:{...o.value,selectors:r}})}return s}}}}}fix_100vh(){return{Rule:{style(e){let t;for(let s of e.value.declarations.declarations)s.property==="height"&&s.value.type==="length-percentage"&&s.value.value.type==="dimension"&&s.value.value.value.unit==="vh"&&s.value.value.value.value===100&&(t||(t=structuredClone(e),t.value.declarations.declarations=[]),t.value.declarations.declarations.push({...s,value:{type:"stretch",vendorPrefix:["webkit"]}}));if(t)return[e,{type:"supports",value:{condition:{type:"declaration",propertyId:{property:"-webkit-touch-callout"},value:"none"},loc:e.value.loc,rules:[t]}}]}}}}logical_transforms(){return{Rule:{style(e){let t;for(let s of e.value.declarations.declarations)if(s.property==="transform"){let o=s.value.map(r=>{if(r.type!=="translateX")return r;t||(t=structuredClone(e),t.value.declarations.declarations=[]);let n;switch(r.value.type){case"dimension":n={type:"dimension",value:{unit:r.value.value.unit,value:-r.value.value.value}};break;case"percentage":n={type:"percentage",value:-r.value.value};break;case"calc":n={type:"calc",value:{type:"product",value:[-1,r.value.value]}};break}return{type:"translateX",value:n}});t&&(t.value.selectors.at(-1).push({type:"pseudo-class",kind:"dir",direction:"rtl"}),t.value.declarations.declarations.push({...s,value:o}))}if(t)return[e,t]}}}}hover_media_query(){return{Rule:{media(e){let t=e.value.query.mediaQueries;if(t.length===1&&t[0].condition&&t[0].condition.type==="feature"&&t[0].condition.value.type==="boolean"&&t[0].condition.value.name==="hover"){for(let s of e.value.rules)if(s.type==="style")for(let o of s.value.selectors)o.unshift({type:"class",name:"hoverable"},{type:"combinator",value:"descendant"});return e.value.rules}}}}}momentum_scrolling(e){return{Declaration:{overflow:e,"overflow-x":e,"overflow-y":e}}}size(){return{Declaration:{custom:{size(e){if(e.value[0].type==="length"){let t={type:"length-percentage",value:{type:"dimension",value:e.value[0].value}};return[{property:"width",value:t},{property:"height",value:t}]}}}}}}},$=new g;var ye=w;export{ce as composeVisitors,ye as default,$ as postcss};
|
package/dist/loader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var h=(t,o)=>{for(var n in o)c(t,n,{get:o[n],enumerable:!0})},l=(t,o,n,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of g(o))!S.call(t,r)&&r!==n&&c(t,r,{get:()=>o[r],enumerable:!(e=y(o,r))||e.enumerable});return t};var L=t=>l(c({},"__esModule",{value:!0}),t);var R={};h(R,{default:()=>O});module.exports=L(R);var p=require("
|
|
1
|
+
"use strict";var c=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var h=(t,o)=>{for(var n in o)c(t,n,{get:o[n],enumerable:!0})},l=(t,o,n,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of g(o))!S.call(t,r)&&r!==n&&c(t,r,{get:()=>o[r],enumerable:!(e=y(o,r))||e.enumerable});return t};var L=t=>l(c({},"__esModule",{value:!0}),t);var R={};h(R,{default:()=>O});module.exports=L(R);var p=require("buffer"),i=require("lightningcss"),v="lightningcss-loader";async function C(t,o){let n=this.async(),e=this.getOptions(),{implementation:r,targets:m,...s}=e;if(r&&typeof r.transform!="function"){n(new TypeError(`[${v}]: options.implementation.transform must be an 'lightningcss' transform function. Received ${typeof r.transform}`));return}let d=r?.transform??i.transform;s.visitor&&(s.visitor=(0,i.composeVisitors)([s.visitor]));try{let{code:a,map:f}=d({filename:this.resourcePath,code:p.Buffer.from(t),sourceMap:this.sourceMap,targets:m,inputSourceMap:this.sourceMap&&o?JSON.stringify(o):void 0,errorRecovery:typeof e.errorRecovery<"u"?e.errorRecovery:!0,nonStandard:{deepSelectorCombinator:!0},...s}),u=a.toString();n(null,u,f&&JSON.parse(f.toString()))}catch(a){n(a)}}var O=C;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LoaderContext } from '@rspack/core';
|
|
2
|
+
import { L as LightningCSSLoaderOptions } from './types-Dyx0p7wd.cjs';
|
|
3
|
+
import 'lightningcss';
|
|
4
|
+
|
|
5
|
+
declare function LightningCSSLoader(this: LoaderContext<LightningCSSLoaderOptions>, source: string, prevMap?: Record<string, any>): Promise<void>;
|
|
6
|
+
|
|
7
|
+
export { LightningCSSLoader as default };
|
package/dist/loader.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { LoaderContext } from '@rspack/core';
|
|
2
|
+
import { L as LightningCSSLoaderOptions } from './types-Dyx0p7wd.js';
|
|
3
|
+
import 'lightningcss';
|
|
4
|
+
|
|
3
5
|
declare function LightningCSSLoader(this: LoaderContext<LightningCSSLoaderOptions>, source: string, prevMap?: Record<string, any>): Promise<void>;
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
export { LightningCSSLoader as default };
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Buffer as m}from"buffer";import{transform as d,composeVisitors as u}from"lightningcss";var y="lightningcss-loader";async function g(a,s){let t=this.async(),n=this.getOptions(),{implementation:o,targets:c,...r}=n;if(o&&typeof o.transform!="function"){t(new TypeError(`[${y}]: options.implementation.transform must be an 'lightningcss' transform function. Received ${typeof o.transform}`));return}let f=o?.transform??d;r.visitor&&(r.visitor=u([r.visitor]));try{let{code:e,map:i}=f({filename:this.resourcePath,code:m.from(a),sourceMap:this.sourceMap,targets:c,inputSourceMap:this.sourceMap&&s?JSON.stringify(s):void 0,errorRecovery:typeof n.errorRecovery<"u"?n.errorRecovery:!0,nonStandard:{deepSelectorCombinator:!0},...r}),p=e.toString();t(null,p,i&&JSON.parse(i.toString()))}catch(e){t(e)}}var v=g;export{v as default};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { TransformOptions, CustomAtRules } from 'lightningcss';
|
|
2
|
+
|
|
3
|
+
type LightningCSSTransformOptions = Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'inputSourceMap'>;
|
|
3
4
|
type Implementation = unknown;
|
|
4
|
-
|
|
5
|
+
type LightningCSSLoaderOptions = LightningCSSTransformOptions & {
|
|
5
6
|
implementation?: Implementation;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
implementation?: Implementation;
|
|
9
|
-
};
|
|
10
|
-
export type PluginLightningcssOptions = {
|
|
8
|
+
type PluginLightningcssOptions = {
|
|
11
9
|
/**
|
|
12
10
|
* @see https://github.com/parcel-bundler/lightningcss/blob/master/node/index.d.ts
|
|
13
11
|
* @default
|
|
@@ -38,4 +36,5 @@ export type PluginLightningcssOptions = {
|
|
|
38
36
|
*/
|
|
39
37
|
implementation?: Implementation;
|
|
40
38
|
};
|
|
41
|
-
|
|
39
|
+
|
|
40
|
+
export type { LightningCSSLoaderOptions as L, PluginLightningcssOptions as P };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TransformOptions, CustomAtRules } from 'lightningcss';
|
|
2
|
+
|
|
3
|
+
type LightningCSSTransformOptions = Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'inputSourceMap'>;
|
|
4
|
+
type Implementation = unknown;
|
|
5
|
+
type LightningCSSLoaderOptions = LightningCSSTransformOptions & {
|
|
6
|
+
implementation?: Implementation;
|
|
7
|
+
};
|
|
8
|
+
type PluginLightningcssOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* @see https://github.com/parcel-bundler/lightningcss/blob/master/node/index.d.ts
|
|
11
|
+
* @default
|
|
12
|
+
* {
|
|
13
|
+
* targets: browserslistToTargets(browserslist)
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
transform?: LightningCSSTransformOptions | boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @see https://github.com/parcel-bundler/lightningcss/blob/master/node/index.d.ts
|
|
19
|
+
* @default
|
|
20
|
+
* {
|
|
21
|
+
* targets: browserslistToTargets(browserslist)
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
minify?: LightningCSSTransformOptions | boolean;
|
|
25
|
+
/**
|
|
26
|
+
* lightningcss instance
|
|
27
|
+
* @example
|
|
28
|
+
* import { pluginLightningcss } from '@rsbuild/plugin-lightningcss';
|
|
29
|
+
* import lightningcss from 'lightningcss';
|
|
30
|
+
* pluginLightningcss({
|
|
31
|
+
* implementation: lightningcss,
|
|
32
|
+
* minify: {
|
|
33
|
+
* exclude: lightningcss.Features.ColorFunction
|
|
34
|
+
* }
|
|
35
|
+
* })
|
|
36
|
+
*/
|
|
37
|
+
implementation?: Implementation;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type { LightningCSSLoaderOptions as L, PluginLightningcssOptions as P };
|
package/package.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/plugin-lightningcss",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.28",
|
|
4
4
|
"description": "emp v3 lightningcss",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
5
|
"type": "module",
|
|
8
6
|
"files": ["dist"],
|
|
9
7
|
"maintainers": ["xuhongbin", "ckken"],
|
|
@@ -15,31 +13,37 @@
|
|
|
15
13
|
"publishConfig": {
|
|
16
14
|
"access": "public"
|
|
17
15
|
},
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": {
|
|
21
|
+
"default": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"default": "./dist/index.cjs",
|
|
26
|
+
"types": "./dist/index.d.cts"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
18
30
|
"scripts": {
|
|
19
|
-
"
|
|
20
|
-
"dev
|
|
21
|
-
"dev:tsc-alias": "tsc-alias -w",
|
|
22
|
-
"dev:cjs": "cross-env ENV=dev node esbuild.js",
|
|
23
|
-
"build": "rimraf dist && pnpm run /^build:.*/",
|
|
24
|
-
"build:tsc": "tsc && tsc-alias",
|
|
25
|
-
"build:cjs": "cross-env ENV=prod node esbuild.js"
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"dev": "tsup --watch"
|
|
26
33
|
},
|
|
27
34
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
35
|
+
"node": ">=18.0.0"
|
|
29
36
|
},
|
|
30
37
|
"keywords": [],
|
|
31
38
|
"author": "",
|
|
32
39
|
"license": "ISC",
|
|
33
40
|
"dependencies": {
|
|
34
41
|
"browserslist": "^4.23.0",
|
|
35
|
-
"lightningcss": "^1.
|
|
42
|
+
"lightningcss": "^1.25.0"
|
|
36
43
|
},
|
|
37
44
|
"devDependencies": {
|
|
38
45
|
"@empjs/cli": "workspace:*",
|
|
39
46
|
"@rspack/core": "0.6.5",
|
|
40
|
-
"
|
|
41
|
-
"esbuild": "^0.19.5",
|
|
42
|
-
"rimraf": "^5.0.5",
|
|
43
|
-
"tsc-alias": "^1.8.8"
|
|
47
|
+
"tsup": "^8.0.2"
|
|
44
48
|
}
|
|
45
49
|
}
|
package/dist/minimizer.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from '@rspack/core';
|
|
2
|
-
import type { LightningCSSMinifyPluginOptions } from './types';
|
|
3
|
-
export declare class LightningCSSMinifyPlugin {
|
|
4
|
-
private readonly options;
|
|
5
|
-
private readonly transform;
|
|
6
|
-
constructor(opts?: LightningCSSMinifyPluginOptions);
|
|
7
|
-
apply(compiler: Compiler): void;
|
|
8
|
-
private transformAssets;
|
|
9
|
-
}
|
|
10
|
-
export default LightningCSSMinifyPlugin;
|
package/dist/plugin.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { GlobalStore } from '@empjs/cli';
|
|
2
|
-
import type { PluginLightningcssOptions } from './types.js';
|
|
3
|
-
declare const empLightningcssPlugin: (o?: PluginLightningcssOptions) => {
|
|
4
|
-
name: string;
|
|
5
|
-
rsConfig(store: GlobalStore): Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export default empLightningcssPlugin;
|
package/dist/px-to-base.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
interface Options {
|
|
2
|
-
designWidth: number;
|
|
3
|
-
minPixelValue: number;
|
|
4
|
-
excludeSelectors: {
|
|
5
|
-
type: string;
|
|
6
|
-
name: RegExp | string;
|
|
7
|
-
}[];
|
|
8
|
-
}
|
|
9
|
-
export declare function createExcludeFilter(excludes: Options['excludeSelectors']): (testItem: {
|
|
10
|
-
type: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
}) => boolean;
|
|
13
|
-
export type PxToVwOptions = Partial<Options>;
|
|
14
|
-
export declare function createPxToVwVisitor(userOptions?: PxToVwOptions): {
|
|
15
|
-
Selector(selectors: import("lightningcss").Selector): void;
|
|
16
|
-
Length(length: import("lightningcss").LengthValue): {
|
|
17
|
-
unit: "vw";
|
|
18
|
-
value: number;
|
|
19
|
-
} | undefined;
|
|
20
|
-
};
|
|
21
|
-
export type PxToRemOptions = {
|
|
22
|
-
rootValue?: number;
|
|
23
|
-
minPixelValue?: number;
|
|
24
|
-
excludeSelectors?: {
|
|
25
|
-
type: string;
|
|
26
|
-
name: RegExp | string;
|
|
27
|
-
}[];
|
|
28
|
-
excludeUnit?: string;
|
|
29
|
-
};
|
|
30
|
-
export declare function createPxToRemVisitor(options?: PxToRemOptions): {
|
|
31
|
-
Selector(selectors: import("lightningcss").Selector): void;
|
|
32
|
-
Token: {
|
|
33
|
-
dimension(token: {
|
|
34
|
-
type: "dimension";
|
|
35
|
-
unit: string;
|
|
36
|
-
value: number;
|
|
37
|
-
}): {
|
|
38
|
-
type: "length";
|
|
39
|
-
value: {
|
|
40
|
-
unit: "px";
|
|
41
|
-
value: number;
|
|
42
|
-
};
|
|
43
|
-
} | undefined;
|
|
44
|
-
};
|
|
45
|
-
Length(length: import("lightningcss").LengthValue): {
|
|
46
|
-
unit: "rem";
|
|
47
|
-
value: number;
|
|
48
|
-
} | {
|
|
49
|
-
unit: "px";
|
|
50
|
-
value: number;
|
|
51
|
-
} | undefined;
|
|
52
|
-
};
|
|
53
|
-
export {};
|
package/dist/unit-tramsform.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { CustomAtRules, LengthValue, Selector, Visitor } from 'lightningcss';
|
|
2
|
-
export type ExcludeSelectorsType = {
|
|
3
|
-
type: string;
|
|
4
|
-
name: RegExp | string;
|
|
5
|
-
};
|
|
6
|
-
interface Options {
|
|
7
|
-
designWidth: number;
|
|
8
|
-
minPixelValue: number;
|
|
9
|
-
/**
|
|
10
|
-
* 屏蔽选择器 [{type: 'class', name: 'cssModule'}]
|
|
11
|
-
* @default []
|
|
12
|
-
*/
|
|
13
|
-
excludeSelectors: ExcludeSelectorsType[];
|
|
14
|
-
transformUnit: 'vw' | 'rem' | '';
|
|
15
|
-
/**
|
|
16
|
-
* 屏蔽单位 大小写无法区分 只支持 ipx 等纯字母变量
|
|
17
|
-
* 加上横杠会出现不可预知问题 如 marign 1-px solid #222 会多出一个空格
|
|
18
|
-
* @default ipx
|
|
19
|
-
*/
|
|
20
|
-
excludeUnit: string;
|
|
21
|
-
rootValue: number;
|
|
22
|
-
}
|
|
23
|
-
export type vwOptions = Partial<Options>;
|
|
24
|
-
export type remOptions = Partial<Options>;
|
|
25
|
-
export type ExcludeItemType = {
|
|
26
|
-
type: string;
|
|
27
|
-
name?: string;
|
|
28
|
-
};
|
|
29
|
-
export declare class UnitTramsform {
|
|
30
|
-
private skipSelector;
|
|
31
|
-
private skipVal;
|
|
32
|
-
private isExclude;
|
|
33
|
-
private isDebug;
|
|
34
|
-
op: Options;
|
|
35
|
-
debug(...args: any[]): void;
|
|
36
|
-
Selector: (selectors: Selector) => void;
|
|
37
|
-
Token: any;
|
|
38
|
-
Length: Visitor<CustomAtRules>['Length'];
|
|
39
|
-
pxToRem(options?: remOptions): {
|
|
40
|
-
Selector: (selectors: Selector) => void;
|
|
41
|
-
Token: any;
|
|
42
|
-
Length: ((length: LengthValue) => void | LengthValue) | undefined;
|
|
43
|
-
};
|
|
44
|
-
pxToVw(options?: vwOptions): {
|
|
45
|
-
Selector: (selectors: Selector) => void;
|
|
46
|
-
Token: any;
|
|
47
|
-
Length: ((length: LengthValue) => void | LengthValue) | undefined;
|
|
48
|
-
};
|
|
49
|
-
excludeFilter(excludes: ExcludeSelectorsType[]): (item: ExcludeItemType) => boolean;
|
|
50
|
-
}
|
|
51
|
-
declare const _default: UnitTramsform;
|
|
52
|
-
export default _default;
|