@empjs/plugin-lightningcss 3.0.0-rc.9 → 3.0.1
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/README.md +2 -37
- package/dist/index.cjs +1 -0
- package/dist/{postcss-polyfill.d.ts → index.d.cts} +59 -6
- package/dist/index.d.ts +137 -5
- 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 -8
- package/dist/loader.js +1 -0
- package/dist/types-Dyx0p7wd.d.cts +40 -0
- package/dist/types-Dyx0p7wd.d.ts +40 -0
- package/package.json +32 -23
- package/dist/minimizer.d.ts +0 -10
- package/dist/plugin.d.ts +0 -11
- package/dist/px-to-base.d.ts +0 -53
- package/dist/unit-tramsform.d.ts +0 -52
package/README.md
CHANGED
|
@@ -5,40 +5,5 @@
|
|
|
5
5
|
pnpm add @empjs/plugin-lightningcss -D
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
import {defineConfig} from '@empjs/cli'
|
|
11
|
-
import pluginLightningcss, {postcss} from '@empjs/plugin-lightningcss'
|
|
12
|
-
const transformUnitFomat = 'vw'
|
|
13
|
-
export default defineConfig(store => {
|
|
14
|
-
const visitor = transformUnitFomat==='rem' ? postcss.px_to_rem() : postcss.px_to_viewport({})
|
|
15
|
-
return {
|
|
16
|
-
plugins:[
|
|
17
|
-
pluginLightningcss({
|
|
18
|
-
transform: {
|
|
19
|
-
visitor,
|
|
20
|
-
},
|
|
21
|
-
})
|
|
22
|
-
],
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## 增加变量
|
|
29
|
-
+ excludeSelectors 屏蔽选择器,如`[{type: 'class', name: 'cssModule'}]`
|
|
30
|
-
+ excludeUnit 防止转换`px`的写法,默认为 `ipx`;
|
|
31
|
-
+ (*) 加上横杠会出现不可预知问题 如 marign 1-px solid #222 会多出一个空格
|
|
32
|
-
+ `--px` 会解析成变量来处理,不会做 ignore 操作
|
|
33
|
-
```js
|
|
34
|
-
/**
|
|
35
|
-
* 屏蔽选择器 [{type: 'class', name: 'cssModule'}]
|
|
36
|
-
* @default []
|
|
37
|
-
*/
|
|
38
|
-
excludeSelectors: ExcludeSelectorsType[]
|
|
39
|
-
/**
|
|
40
|
-
* 屏蔽单位 大小写无法区分 只支持 -px 等横杠
|
|
41
|
-
* @default -px
|
|
42
|
-
*/
|
|
43
|
-
excludeUnit: string
|
|
44
|
-
```
|
|
8
|
+
## 使用
|
|
9
|
+
[使用详情](https://empjs.dev/plugin/tool/lightningcss.html)
|
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 V=(r,e)=>()=>(r&&(e=r(r=0)),e);var R=(r,e)=>{for(var t in e)m(r,t,{get:e[t],enumerable:!0})},_=(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 C=(r,e,t)=>(t=r!=null?G(W(r)):{},_(e||!r||!r.__esModule?m(t,"default",{value:r,enumerable:!0}):t,r)),$=r=>_(m({},"__esModule",{value:!0}),r);var a=V(()=>{"use strict"});var T={};R(T,{LightningCSSMinifyPlugin:()=>f,default:()=>Q});var A,O,u,F,f,Q,P=V(()=>{"use strict";a();A=require("buffer"),O=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??O.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"?A.Buffer.from(c):c,k=this.transform({filename:l.name,code:z,minify:!0,sourceMap:o,...p,targets:i}),w=k.code.toString();e.updateAsset(l.name,o?new s(w,l.name,JSON.parse(k.map.toString()),j,I,!0):new n(w),{...l.info,minimized:!0})}))}},Q=f});var H={};R(H,{composeVisitors:()=>U.composeVisitors,default:()=>J,postcss:()=>M});module.exports=$(H);a();var U=require("lightningcss");a();var E=C(require("path"),1),d=C(require("browserslist"),1),h=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,h.browserslistToTargets)((0,d.default)(r.empConfig.build.browserslist)),...e.transform};for(let i of s){let p=t.module.rule(i),v=p.use("lightningcss").loader(E.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:{},e.minify.targets||(e.minify.targets=(0,h.browserslistToTargets)((0,d.default)(r.empConfig.build.browserslist)));let{chain:t}=r,{LightningCSSMinifyPlugin:s}=await Promise.resolve().then(()=>(P(),T));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 b=require("lightningcss");a();var g=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}}},x=new g;var S=class{px_to_rem(e={}){return(0,b.composeVisitors)([x.pxToRem(e)])}pxtorem=this.px_to_rem;pxtovw=this.px_to_viewport;px_to_viewport(e={}){return(0,b.composeVisitors)([x.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 S;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
|
*/
|
|
@@ -8,11 +39,13 @@ declare class PostcssConfig {
|
|
|
8
39
|
/**
|
|
9
40
|
* https://github.com/cuth/postcss-pxtorem
|
|
10
41
|
*/
|
|
11
|
-
px_to_rem(op
|
|
42
|
+
px_to_rem(op?: remOptions): Visitor<CustomAtRules>;
|
|
43
|
+
pxtorem: (op?: remOptions) => Visitor<CustomAtRules>;
|
|
44
|
+
pxtovw: (op?: vwOptions) => Visitor<CustomAtRules>;
|
|
12
45
|
/**
|
|
13
46
|
* https://github.com/evrone/postcss-px-to-viewport
|
|
14
47
|
*/
|
|
15
|
-
px_to_viewport(op
|
|
48
|
+
px_to_viewport(op?: vwOptions): Visitor<CustomAtRules>;
|
|
16
49
|
/**
|
|
17
50
|
* https://www.npmjs.com/package/postcss-apply
|
|
18
51
|
*/
|
|
@@ -81,4 +114,24 @@ declare class PostcssConfig {
|
|
|
81
114
|
size(): any;
|
|
82
115
|
}
|
|
83
116
|
declare const _default: PostcssConfig;
|
|
84
|
-
|
|
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,5 +1,137 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
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 P=Object.defineProperty;var k=(i,e)=>()=>(i&&(e=i(i=0)),e);var E=(i,e)=>{for(var t in e)P(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as L}from"url";import M from"path";var I,U,u,a=k(()=>{"use strict";I=()=>L(import.meta.url),U=()=>M.dirname(I()),u=U()});var S={};E(S,{LightningCSSMinifyPlugin:()=>f,default:()=>G});import{Buffer as j}from"buffer";import{transform as z}from"lightningcss";var p,D,f,G,w=k(()=>{"use strict";a();p="lightningcss-minify-plugin",D=/\.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??z,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,(n,{green:r,formatFlag:o})=>n&&r&&o?r(o("minimized")):"")})})}async transformAssets(e){let{options:{devtool:t},webpack:{sources:{SourceMapSource:s,RawSource:n}}}=e.compiler,r=this.options.sourceMap===void 0?t&&t.includes("source-map"):this.options.sourceMap,{targets:o,...c}=this.options,v=e.getAssets().filter(l=>!l.info.minimized&&D.test(l.name));await Promise.all(v.map(async l=>{let{source:m,map:A}=l.source.sourceAndMap(),T=m.toString(),O=typeof m=="string"?j.from(m):m,x=this.transform({filename:l.name,code:O,minify:!0,sourceMap:r,...c,targets:o}),b=x.code.toString();e.updateAsset(l.name,r?new s(b,l.name,JSON.parse(x.map.toString()),T,A,!0):new n(b),{...l.info,minimized:!0})}))}},G=f});a();import{composeVisitors as ce}from"lightningcss";a();import q from"path";import V from"browserslist";import{browserslistToTargets as R}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:R(V(i.empConfig.build.browserslist)),...e.transform};for(let o of s){let c=t.module.rule(o),v=c.use("lightningcss").loader(q.resolve(u,"loader.cjs")).options(r);["sass","less"].includes(o)&&v.before(`${o}Loader`),c.uses.delete("postcss")}},F=async(i,e={})=>{if(!e.minify)return;e.minify=typeof e.minify!="boolean"?e.minify:{},e.minify.targets||(e.minify.targets=R(V(i.empConfig.build.browserslist)));let{chain:t}=i,{LightningCSSMinifyPlugin:s}=await Promise.resolve().then(()=>(w(),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)])}}),_=N;a();import{composeVisitors as C}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 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 g=class{px_to_rem(e={}){return C([h.pxToRem(e)])}pxtorem=this.px_to_rem;pxtovw=this.px_to_viewport;px_to_viewport(e={}){return C([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 r=e.get(n.value),o=t.value.declarations;o.declarations.push(...r.declarations),o.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 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 r=t.get(n.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[n,r]of s.entries())r.type==="pseudo-class"&&r.kind==="focus-visible"&&(t==null&&(t=[...e.value.selectors.map(o=>[...o])]),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 r=[];for(let o of n.value.selectors)r.push([{type:"type",name:"html"},{type:"attribute",name:"theme",operation:{operator:"equal",value:"dark"}},{type:"combinator",value:"descendant"},...o]),o.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: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 n=s.value.map(r=>{if(r.type!=="translateX")return r;t||(t=structuredClone(e),t.value.declarations.declarations=[]);let o;switch(r.value.type){case"dimension":o={type:"dimension",value:{unit:r.value.value.unit,value:-r.value.value.value}};break;case"percentage":o={type:"percentage",value:-r.value.value};break;case"calc":o={type:"calc",value:{type:"product",value:[-1,r.value.value]}};break}return{type:"translateX",value:o}});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}]}}}}}}},$=new g;var ye=_;export{ce as composeVisitors,ye as default,$ as postcss};
|
package/dist/loader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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,9 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type LightningCSSLoaderOptions = LightningCSSTransformOptions & {
|
|
6
|
-
implementation?: Implementation;
|
|
7
|
-
};
|
|
1
|
+
import { LoaderContext } from '@rspack/core';
|
|
2
|
+
import { L as LightningCSSLoaderOptions } from './types-Dyx0p7wd.js';
|
|
3
|
+
import 'lightningcss';
|
|
4
|
+
|
|
8
5
|
declare function LightningCSSLoader(this: LoaderContext<LightningCSSLoaderOptions>, source: string, prevMap?: Record<string, any>): Promise<void>;
|
|
9
|
-
|
|
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};
|
|
@@ -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 };
|
|
@@ -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,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/plugin-lightningcss",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "emp v3 lightningcss",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
5
|
"type": "module",
|
|
8
|
-
"files": [
|
|
9
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"maintainers": [
|
|
10
|
+
"xuhongbin",
|
|
11
|
+
"ckken"
|
|
12
|
+
],
|
|
10
13
|
"repository": {
|
|
11
14
|
"type": "git",
|
|
12
15
|
"url": "git+https://github.com/empjs/emp.git",
|
|
@@ -15,31 +18,37 @@
|
|
|
15
18
|
"publishConfig": {
|
|
16
19
|
"access": "public"
|
|
17
20
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": {
|
|
26
|
+
"default": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"default": "./dist/index.cjs",
|
|
31
|
+
"types": "./dist/index.d.cts"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
},
|
|
27
35
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
36
|
+
"node": ">=16.0.0"
|
|
29
37
|
},
|
|
30
38
|
"keywords": [],
|
|
31
39
|
"author": "",
|
|
32
40
|
"license": "ISC",
|
|
33
41
|
"dependencies": {
|
|
34
|
-
"browserslist": "^4.23.
|
|
35
|
-
"lightningcss": "^1.
|
|
42
|
+
"browserslist": "^4.23.1",
|
|
43
|
+
"lightningcss": "^1.25.1"
|
|
36
44
|
},
|
|
37
45
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
46
|
+
"@rspack/core": "0.6.5",
|
|
47
|
+
"tsup": "^8.1.0",
|
|
48
|
+
"@empjs/cli": "3.0.1"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup",
|
|
52
|
+
"dev": "tsup --watch"
|
|
44
53
|
}
|
|
45
|
-
}
|
|
54
|
+
}
|
package/dist/minimizer.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from '@rspack/core';
|
|
2
|
-
type LightningCSSMinifyPluginOptions = any;
|
|
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,11 +0,0 @@
|
|
|
1
|
-
import type { GlobalStore } from '@empjs/cli';
|
|
2
|
-
import type { TransformAttributeOptions } from 'lightningcss';
|
|
3
|
-
export type PluginLightningCssType = {
|
|
4
|
-
transform?: boolean | TransformAttributeOptions;
|
|
5
|
-
minify?: boolean | unknown;
|
|
6
|
-
};
|
|
7
|
-
declare const empLightningcssPlugin: (o?: PluginLightningCssType) => {
|
|
8
|
-
name: string;
|
|
9
|
-
rsConfig(store: GlobalStore): Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
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 vwOptions = Partial<Options>;
|
|
14
|
-
export declare function createPxToVwVisitor(userOptions?: vwOptions): {
|
|
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;
|