@empjs/plugin-lightningcss 3.11.0 → 4.0.0-alpha.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/dist/index.d.ts +6 -137
- package/dist/index.js +1 -1
- package/dist/loader.d.ts +3 -6
- package/dist/loader.js +1 -1
- package/dist/minimizer.d.ts +11 -0
- package/dist/minimizer.js +1 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/{index.d.cts → postcss-polyfill.d.ts} +8 -59
- package/dist/px-to-base.d.ts +53 -0
- package/dist/{types-Dysn9mp1.d.cts → types.d.ts} +8 -7
- package/dist/unit-tramsform.d.ts +59 -0
- package/package.json +10 -15
- package/dist/index.cjs +0 -1
- package/dist/loader.cjs +0 -1
- package/dist/loader.d.cts +0 -7
- package/dist/types-Dysn9mp1.d.ts +0 -45
package/dist/index.d.ts
CHANGED
|
@@ -1,137 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 };
|
|
1
|
+
import { composeVisitors } from 'lightningcss';
|
|
2
|
+
import empLightningcssPlugin from './plugin.js';
|
|
3
|
+
import postcss from './postcss-polyfill.js';
|
|
4
|
+
export default empLightningcssPlugin;
|
|
5
|
+
export { postcss, composeVisitors };
|
|
6
|
+
export type { PxToRemOptions, PxToVwOptions } from './px-to-base.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import"node:module";import{browserslistToTargets as e,composeVisitors as t}from"lightningcss";import l from"browserslist";import a from"path";import{fileURLToPath as r}from"node:url";import{dirname as i}from"node:path";var s=i(r(import.meta.url));let n=async(t,r={})=>{if(!r.transform)return;r.transform="boolean"!=typeof r.transform?r.transform:{},r.enablePostcss=void 0!==r.enablePostcss&&r.enablePostcss;let{chain:i}=t,n={targets:e(l(t.empConfig.build.polyfill.browserslist)),...r.transform};for(let e of["sass","less","css"]){let t=i.module.rule(e),l=t.use("lightningcss").loader(a.resolve(s,"loader.js")).options(n);["sass","less"].includes(e)&&l.before(`${e}Loader`),!1===r.enablePostcss&&t.uses.delete("postcss")}},o=async(t,a={})=>{if(!a.minify)return;a.minify="boolean"!=typeof a.minify?a.minify:{},a.minify.targets||(a.minify.targets=e(l(t.empConfig.build.polyfill.browserslist)));let{chain:r}=t,{LightningCSSMinifyPlugin:i}=await import("./minimizer.js");r.optimization.minimizer("minCss").use(i,[a.minify])},u=new class{skipSelector=!1;skipVal=!1;skipMedia=0;isExclude;isDebug=!1;op={designWidth:320,minPixelValue:1,excludeSelectors:[],transformUnit:"",excludeUnit:"ipx",rootValue:16};debug(...e){this.isDebug&&console.log(...e)}Selector=e=>{for(let t of(this.skipSelector=!1,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,"skipMedia",this.skipMedia);let t={unit:"px",value:e.value};if("px"!==e.unit||this.skipSelector)this.skipVal=!1;else{if(Math.abs(e.value)>this.op.minPixelValue){if(!this.skipVal&&0==this.skipMedia)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}}this.skipMedia>0&&this.skipMedia--}return this.skipVal=!1,t}};Rule={media:e=>{let{conditions:t}=e.value.query.mediaQueries[0].condition;t?this.skipMedia=t.length:this.skipMedia=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,Rule:this.Rule,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 t=>{if(this.debug(t,e),!t.name)return!1;for(let l of e)if(t.type===l.type&&("string"==typeof l.name&&l.name===t.name||"object"==typeof l.name&&l.name.test(t.name)))return!0;return!1}}};class p{px_to_rem(e={}){return t([u.pxToRem(e)])}pxtorem=this.px_to_rem;pxtovw=this.px_to_viewport;px_to_viewport(e={}){return t([u.pxToVw(e)])}apply(e){return e=e||new Map,{Rule:{style(t){for(let l of t.value.selectors)if(1===l.length&&"type"===l[0].type&&l[0].name.startsWith("--"))return e.set(l[0].name,t.value.declarations),{type:"ignored",value:null};return t.value.rules=t.value.rules.filter(l=>{if("unknown"===l.type&&"apply"===l.value.name){for(let a of l.value.prelude)if("dashed-ident"===a.type&&e.has(a.value)){let l=e.get(a.value),r=t.value.declarations;r.declarations.push(...l.declarations),r.importantDeclarations.push(...l.importantDeclarations)}return!1}return!0}),t}}}}selector_prefix(){return{Selector:e=>[{type:"class",name:"prefix"},{type:"combinator",value:"descendant"},...e]}}static_vars(e){return e=e||new Map,{Rule:{unknown:t=>(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=>(t.url=e+t.url,t)}}specific_environment_variables(e){let t={};for(let l in e)t[l]=()=>e[l];return{EnvironmentVariable:t}}env_function(e){return{EnvironmentVariable(t){if("custom"===t.name.type)return e[t.name.ident]}}}design_tokens(e){return{Function:{"design-token"(t){if(1===t.arguments.length&&"token"===t.arguments[0].type&&"string"===t.arguments[0].value.type)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 l of e.value.declarations.declarations){let e=l.property;"unparsed"===l.property&&(e=l.value.propertyId.property),t.set(e,l)}return e.value.declarations.declarations=e.value.declarations.declarations.map(e=>{if("unparsed"===e.property&&1===e.value.value.length){let l=e.value.value[0];if("token"===l.type&&"at-keyword"===l.value.type&&t.has(l.value.value)){let a=t.get(l.value.value);return{property:e.value.propertyId.property,value:a.value}}}return e}),e}}}}focus_visible(){return{Rule:{style(e){let t=null;for(let l of e.value.selectors)for(let[a,r]of l.entries())"pseudo-class"===r.type&&"focus-visible"===r.kind&&(null==t&&(t=[...e.value.selectors.map(e=>[...e])]),l[a]={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"&&"plain"===t.condition.value.type&&"prefers-color-scheme"===t.condition.value.name&&"dark"===t.condition.value.value.value){let t=[e];for(let l of e.value.rules)if("style"===l.type){let e=[];for(let t of l.value.selectors)e.push([{type:"type",name:"html"},{type:"attribute",name:"theme",operation:{operator:"equal",value:"dark"}},{type:"combinator",value:"descendant"},...t]),t.unshift({type:"type",name:"html"},{type:"pseudo-class",kind:"not",selectors:[[{type:"attribute",name:"theme",operation:{operator:"equal",value:"light"}}]]},{type:"combinator",value:"descendant"});t.push({type:"style",value:{...l.value,selectors:e}})}return t}}}}}fix_100vh(){return{Rule:{style(e){let t;for(let l of e.value.declarations.declarations)"height"===l.property&&"length-percentage"===l.value.type&&"dimension"===l.value.value.type&&"vh"===l.value.value.value.unit&&100===l.value.value.value.value&&(t||((t=structuredClone(e)).value.declarations.declarations=[]),t.value.declarations.declarations.push({...l,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 l of e.value.declarations.declarations)if("transform"===l.property){let a=l.value.map(l=>{let a;if("translateX"!==l.type)return l;switch(!t&&((t=structuredClone(e)).value.declarations.declarations=[]),l.value.type){case"dimension":a={type:"dimension",value:{unit:l.value.value.unit,value:-l.value.value.value}};break;case"percentage":a={type:"percentage",value:-l.value.value};break;case"calc":a={type:"calc",value:{type:"product",value:[-1,l.value.value]}}}return{type:"translateX",value:a}});t&&(t.value.selectors.at(-1).push({type:"pseudo-class",kind:"dir",direction:"rtl"}),t.value.declarations.declarations.push({...l,value:a}))}if(t)return[e,t]}}}}hover_media_query(){return{Rule:{media(e){let t=e.value.query.mediaQueries;if(1===t.length&&t[0].condition&&"feature"===t[0].condition.type&&"boolean"===t[0].condition.value.type&&"hover"===t[0].condition.value.name){for(let t of e.value.rules)if("style"===t.type)for(let e of t.value.selectors)e.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("length"===e.value[0].type){let t={type:"length-percentage",value:{type:"dimension",value:e.value[0].value}};return[{property:"width",value:t},{property:"height",value:t}]}}}}}}}let c=new p;export default((e={})=>(e.transform&&void 0===e.minify&&(e.minify=!0),{name:"@empjs/plugin-lightningcss",async rsConfig(t){await Promise.all([n(t,e),o(t,e)])}}));export{t as composeVisitors,c as postcss};
|
package/dist/loader.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { LoaderContext } from '@empjs/cli';
|
|
2
|
-
import {
|
|
3
|
-
import 'lightningcss';
|
|
4
|
-
|
|
1
|
+
import type { LoaderContext } from '@empjs/cli';
|
|
2
|
+
import type { LightningCSSLoaderOptions } from './types';
|
|
5
3
|
declare function LightningCSSLoader(this: LoaderContext<LightningCSSLoaderOptions>, source: string, prevMap?: Record<string, any>): Promise<void>;
|
|
6
|
-
|
|
7
|
-
export { LightningCSSLoader as default };
|
|
4
|
+
export default LightningCSSLoader;
|
package/dist/loader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Buffer as
|
|
1
|
+
import"node:module";import{Buffer as r}from"node:buffer";import{composeVisitors as o,transform as t}from"lightningcss";async function e(e,i){let n=this.async(),s=this.getOptions(),{implementation:a,targets:c,...f}=s;if(a&&"function"!=typeof a.transform)return void n(TypeError(`[lightningcss-loader]: options.implementation.transform must be an 'lightningcss' transform function. Received ${typeof a.transform}`));let m=a?.transform??t;f.visitor&&(f.visitor=o([f.visitor]));try{let{code:o,map:t}=m({filename:this.resourcePath,code:r.from(e),sourceMap:this.sourceMap,targets:c,inputSourceMap:this.sourceMap&&i?JSON.stringify(i):void 0,errorRecovery:void 0===s.errorRecovery||s.errorRecovery,nonStandard:{deepSelectorCombinator:!0},...f}),a=o.toString();n(null,a,t&&JSON.parse(t.toString()))}catch(r){n(r)}}export default e;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Compiler } from '@empjs/cli';
|
|
2
|
+
import type { LightningCSSMinifyPluginOptions } from './types';
|
|
3
|
+
export declare class LightningCSSMinifyPlugin {
|
|
4
|
+
private readonly options;
|
|
5
|
+
private readonly transform;
|
|
6
|
+
name: string;
|
|
7
|
+
constructor(opts?: LightningCSSMinifyPluginOptions);
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
9
|
+
private transformAssets;
|
|
10
|
+
}
|
|
11
|
+
export default LightningCSSMinifyPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:module";import{Buffer as s}from"node:buffer";import{transform as t}from"lightningcss";let i="lightningcss-minify-plugin",o=/\.css(?:\?.*)?$/i;class n{options;transform;name="LightningCSSMinifyPlugin";constructor(s={}){let{implementation:o}=s;if(o&&"function"!=typeof o.transform)throw TypeError(`[${i}]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof o.transform}`);this.transform=o?.transform??t,this.options=s}apply(s){s.hooks.compilation.tap(i,s=>{s.hooks.processAssets.tapPromise({name:i,stage:s?.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(i,s=>{s.hooks.print.for("asset.info.minimized").tap(i,(s,{green:t,formatFlag:i})=>s&&t&&i?t(i("minimized")):"")})})}async transformAssets(t){let{options:{devtool:i},webpack:{sources:{SourceMapSource:n,RawSource:e}}}=t.compiler,r=void 0===this.options.sourceMap?i&&i.includes("source-map"):this.options.sourceMap,{targets:a,...m}=this.options,p=t.getAssets().filter(s=>!s.info.minimized&&o.test(s.name));await Promise.all(p.map(async i=>{let{source:o,map:p}=i.source.sourceAndMap(),f=o.toString(),c="string"==typeof o?s.from(o):o,l=this.transform({filename:i.name,code:c,minify:!0,sourceMap:r,...m,targets:a}),g=l.code.toString();t.updateAsset(i.name,r?new n(g,i.name,JSON.parse(l.map.toString()),f,p,!0):new e(g),{...i.info,minimized:!0})}))}}export{n as LightningCSSMinifyPlugin};
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -1,37 +1,6 @@
|
|
|
1
|
-
import { Visitor
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { P as PluginLightningcssOptions } from './types-Dysn9mp1.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
|
-
|
|
1
|
+
import type { Visitor } from 'lightningcss';
|
|
2
|
+
import { type CustomAtRules } from 'lightningcss';
|
|
3
|
+
import { type remOptions, type vwOptions } from './unit-tramsform.js';
|
|
35
4
|
/**
|
|
36
5
|
* // 插件编写 https://github.com/parcel-bundler/lightningcss/blob/master/node/test/visitor.test.mjs
|
|
37
6
|
*/
|
|
@@ -39,13 +8,13 @@ declare class PostcssConfig {
|
|
|
39
8
|
/**
|
|
40
9
|
* https://github.com/cuth/postcss-pxtorem
|
|
41
10
|
*/
|
|
42
|
-
px_to_rem(op?: remOptions): Visitor<CustomAtRules>;
|
|
43
|
-
pxtorem: (op?: remOptions) => Visitor<CustomAtRules>;
|
|
44
|
-
pxtovw: (op?: vwOptions) => Visitor<CustomAtRules>;
|
|
11
|
+
px_to_rem(op?: remOptions): Visitor<CustomAtRules> | import("lightningcss").VisitorFunction<CustomAtRules>;
|
|
12
|
+
pxtorem: (op?: remOptions) => Visitor<CustomAtRules> | import("lightningcss").VisitorFunction<CustomAtRules>;
|
|
13
|
+
pxtovw: (op?: vwOptions) => Visitor<CustomAtRules> | import("lightningcss").VisitorFunction<CustomAtRules>;
|
|
45
14
|
/**
|
|
46
15
|
* https://github.com/evrone/postcss-px-to-viewport
|
|
47
16
|
*/
|
|
48
|
-
px_to_viewport(op?: vwOptions): Visitor<CustomAtRules>;
|
|
17
|
+
px_to_viewport(op?: vwOptions): Visitor<CustomAtRules> | import("lightningcss").VisitorFunction<CustomAtRules>;
|
|
49
18
|
/**
|
|
50
19
|
* https://www.npmjs.com/package/postcss-apply
|
|
51
20
|
*/
|
|
@@ -114,24 +83,4 @@ declare class PostcssConfig {
|
|
|
114
83
|
size(): any;
|
|
115
84
|
}
|
|
116
85
|
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 };
|
|
86
|
+
export default _default;
|
|
@@ -0,0 +1,53 @@
|
|
|
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: import("lightningcss").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 {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type LightningCSSTransformOptions = Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'inputSourceMap'>;
|
|
1
|
+
import type { CustomAtRules, TransformOptions } from 'lightningcss';
|
|
2
|
+
export type LightningCSSTransformOptions = Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'inputSourceMap'>;
|
|
4
3
|
type Implementation = unknown;
|
|
5
|
-
type LightningCSSLoaderOptions = LightningCSSTransformOptions & {
|
|
4
|
+
export type LightningCSSLoaderOptions = LightningCSSTransformOptions & {
|
|
6
5
|
implementation?: Implementation;
|
|
7
6
|
};
|
|
8
|
-
type
|
|
7
|
+
export type LightningCSSMinifyPluginOptions = Omit<LightningCSSTransformOptions, 'minify'> & {
|
|
8
|
+
implementation?: Implementation;
|
|
9
|
+
};
|
|
10
|
+
export type PluginLightningcssOptions = {
|
|
9
11
|
/**
|
|
10
12
|
* @see https://github.com/parcel-bundler/lightningcss/blob/master/node/index.d.ts
|
|
11
13
|
* @default
|
|
@@ -41,5 +43,4 @@ type PluginLightningcssOptions = {
|
|
|
41
43
|
*/
|
|
42
44
|
enablePostcss?: boolean;
|
|
43
45
|
};
|
|
44
|
-
|
|
45
|
-
export type { LightningCSSLoaderOptions as L, PluginLightningcssOptions as P };
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
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 skipMedia;
|
|
33
|
+
private isExclude;
|
|
34
|
+
private isDebug;
|
|
35
|
+
op: Options;
|
|
36
|
+
debug(...args: any[]): void;
|
|
37
|
+
Selector: (selectors: Selector) => void;
|
|
38
|
+
Token: any;
|
|
39
|
+
Length: Visitor<CustomAtRules>['Length'];
|
|
40
|
+
Rule: {
|
|
41
|
+
media: (rule: any) => void;
|
|
42
|
+
};
|
|
43
|
+
pxToRem(options?: remOptions): {
|
|
44
|
+
Selector: (selectors: Selector) => void;
|
|
45
|
+
Token: any;
|
|
46
|
+
Rule: {
|
|
47
|
+
media: (rule: any) => void;
|
|
48
|
+
};
|
|
49
|
+
Length: ((length: LengthValue) => LengthValue | void) | undefined;
|
|
50
|
+
};
|
|
51
|
+
pxToVw(options?: vwOptions): {
|
|
52
|
+
Selector: (selectors: Selector) => void;
|
|
53
|
+
Token: any;
|
|
54
|
+
Length: ((length: LengthValue) => LengthValue | void) | undefined;
|
|
55
|
+
};
|
|
56
|
+
excludeFilter(excludes: ExcludeSelectorsType[]): (item: ExcludeItemType) => boolean;
|
|
57
|
+
}
|
|
58
|
+
declare const _default: UnitTramsform;
|
|
59
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/plugin-lightningcss",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "emp v3 lightningcss",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -18,22 +18,17 @@
|
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
|
-
"main": "dist/index.js",
|
|
22
|
-
"types": "dist/index.d.ts",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
"require": {
|
|
30
|
-
"types": "./dist/index.d.cts",
|
|
31
|
-
"default": "./dist/index.cjs"
|
|
32
|
-
}
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
33
28
|
}
|
|
34
29
|
},
|
|
35
30
|
"engines": {
|
|
36
|
-
"node": "
|
|
31
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
37
32
|
},
|
|
38
33
|
"keywords": [],
|
|
39
34
|
"author": "",
|
|
@@ -43,10 +38,10 @@
|
|
|
43
38
|
"lightningcss": "^1.30.2"
|
|
44
39
|
},
|
|
45
40
|
"devDependencies": {
|
|
46
|
-
"@empjs/cli": "
|
|
41
|
+
"@empjs/cli": "4.0.0-alpha.1"
|
|
47
42
|
},
|
|
48
43
|
"scripts": {
|
|
49
|
-
"build": "
|
|
50
|
-
"dev": "
|
|
44
|
+
"build": "rslib build --env-mode production",
|
|
45
|
+
"dev": "rslib build --watch --env-mode development"
|
|
51
46
|
}
|
|
52
47
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var z=Object.create;var m=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var R=(n,e)=>()=>(n&&(e=n(n=0)),e);var V=(n,e)=>{for(var t in e)m(n,t,{get:e[t],enumerable:!0})},_=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!$.call(n,i)&&i!==t&&m(n,i,{get:()=>e[i],enumerable:!(s=G(e,i))||s.enumerable});return n};var C=(n,e,t)=>(t=n!=null?z(W(n)):{},_(e||!n||!n.__esModule?m(t,"default",{value:n,enumerable:!0}):t,n)),N=n=>_(m({},"__esModule",{value:!0}),n);var a=R(()=>{"use strict"});var M={};V(M,{LightningCSSMinifyPlugin:()=>f,default:()=>F});var A,P,u,Q,f,F,O=R(()=>{"use strict";a();A=require("buffer"),P=require("lightningcss"),u="lightningcss-minify-plugin",Q=/\.css(?:\?.*)?$/i,f=class{options;transform;name="LightningCSSMinifyPlugin";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??P.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,(i,{green:r,formatFlag:o})=>i&&r&&o?r(o("minimized")):"")})})}async transformAssets(e){let{options:{devtool:t},webpack:{sources:{SourceMapSource:s,RawSource:i}}}=e.compiler,r=this.options.sourceMap===void 0?t&&t.includes("source-map"):this.options.sourceMap,{targets:o,...p}=this.options,v=e.getAssets().filter(l=>!l.info.minimized&&Q.test(l.name));await Promise.all(v.map(async l=>{let{source:c,map:I}=l.source.sourceAndMap(),j=c.toString(),q=typeof c=="string"?A.Buffer.from(c):c,S=this.transform({filename:l.name,code:q,minify:!0,sourceMap:r,...p,targets:o}),w=S.code.toString();e.updateAsset(l.name,r?new s(w,l.name,JSON.parse(S.map.toString()),j,I,!0):new i(w),{...l.info,minimized:!0})}))}},F=f});var H={};V(H,{composeVisitors:()=>U.composeVisitors,default:()=>J,postcss:()=>L});module.exports=N(H);a();var U=require("lightningcss");a();var d=C(require("browserslist"),1),h=require("lightningcss"),T=C(require("path"),1),X=async(n,e={})=>{if(!e.transform)return;e.transform=typeof e.transform!="boolean"?e.transform:{},e.enablePostcss=e.enablePostcss!==void 0?e.enablePostcss:!1;let{chain:t}=n,s=["sass","less","css"],r={targets:(0,h.browserslistToTargets)((0,d.default)(n.empConfig.build.polyfill.browserslist)),...e.transform};for(let o of s){let p=t.module.rule(o),v=p.use("lightningcss").loader(T.default.resolve(__dirname,"loader.cjs")).options(r);["sass","less"].includes(o)&&v.before(`${o}Loader`),e.enablePostcss===!1&&p.uses.delete("postcss")}},B=async(n,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)(n.empConfig.build.polyfill.browserslist)));let{chain:t}=n,{LightningCSSMinifyPlugin:s}=await Promise.resolve().then(()=>(O(),M));t.optimization.minimizer("minCss").use(s,[e.minify])},Z=(n={})=>(n.transform&&typeof n.minify>"u"&&(n.minify=!0),{name:"@empjs/plugin-lightningcss",async rsConfig(e){await Promise.all([X(e,n),B(e,n)])}}),E=Z;a();var b=require("lightningcss");a();var g=class{skipSelector=!1;skipVal=!1;skipMedia=0;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,"skipMedia",this.skipMedia);let t={unit:"px",value:e.value};if(e.unit==="px"&&!this.skipSelector){if(Math.abs(e.value)>this.op.minPixelValue){if(!this.skipVal&&this.skipMedia==0)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}this.skipMedia>0&&this.skipMedia--}return this.skipVal=!1,t}else this.skipVal=!1};Rule={media:e=>{let t=e.value.query.mediaQueries[0],{conditions:s}=t.condition;s?this.skipMedia=s.length:this.skipMedia=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,Rule:this.Rule,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 i of e)if(s.type===i.type&&(typeof i.name=="string"&&i.name===s.name||typeof i.name=="object"&&i.name.test(s.name)))return!0;return!1}}},x=new g;var k=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 i of s.value.prelude)if(i.type==="dashed-ident"&&e.has(i.value)){let r=e.get(i.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 i=s.property;s.property==="unparsed"&&(i=s.value.propertyId.property),t.set(i,s)}return e.value.declarations.declarations=e.value.declarations.declarations.map(s=>{if(s.property==="unparsed"&&s.value.value.length===1){let i=s.value.value[0];if(i.type==="token"&&i.value.type==="at-keyword"&&t.has(i.value.value)){let r=t.get(i.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[i,r]of s.entries())r.type==="pseudo-class"&&r.kind==="focus-visible"&&(t==null&&(t=[...e.value.selectors.map(o=>[...o])]),s[i]={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 i of e.value.rules)if(i.type==="style"){let r=[];for(let o of i.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:{...i.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 i=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:i}))}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 i of s.value.selectors)i.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}]}}}}}}},L=new k;var J=E;0&&(module.exports={composeVisitors,postcss});
|
package/dist/loader.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 m=require("buffer"),i=require("lightningcss"),v="lightningcss-loader";async function C(t,o){let n=this.async(),e=this.getOptions(),{implementation:r,targets:p,...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:m.Buffer.from(t),sourceMap:this.sourceMap,targets:p,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;
|
package/dist/loader.d.cts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LoaderContext } from '@empjs/cli';
|
|
2
|
-
import { L as LightningCSSLoaderOptions } from './types-Dysn9mp1.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/types-Dysn9mp1.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
* enable postcss config
|
|
40
|
-
* @default false
|
|
41
|
-
*/
|
|
42
|
-
enablePostcss?: boolean;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type { LightningCSSLoaderOptions as L, PluginLightningcssOptions as P };
|