weapp-tailwindcss 3.4.0-alpha.0 → 3.4.0-alpha.2

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.
Files changed (124) hide show
  1. package/dist/babel/index.d.ts +16 -0
  2. package/dist/bundlers/gulp/index.d.ts +8 -0
  3. package/dist/bundlers/vite/index.d.ts +3 -0
  4. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +8 -0
  5. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +8 -0
  6. package/dist/bundlers/webpack/index.d.ts +1 -0
  7. package/dist/{weapp-tw-runtime-loader.d.ts → bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts} +2 -4
  8. package/dist/cache/index.d.ts +32 -0
  9. package/dist/cli.d.ts +1 -2
  10. package/dist/cli.js +51 -1760
  11. package/dist/cli.mjs +45 -34
  12. package/dist/constants-CFM1J-h1.js +42 -0
  13. package/dist/constants-Dy2Dd3Fz.mjs +36 -0
  14. package/dist/constants.d.ts +7 -0
  15. package/dist/core.d.ts +2 -16
  16. package/dist/core.js +60 -1775
  17. package/dist/core.mjs +60 -46
  18. package/dist/css-macro/constants.d.ts +14 -0
  19. package/dist/css-macro/index.d.ts +4 -7
  20. package/dist/css-macro/index.js +30 -140
  21. package/dist/css-macro/index.mjs +28 -35
  22. package/dist/css-macro/postcss.d.ts +3 -5
  23. package/dist/css-macro/postcss.js +46 -99
  24. package/dist/css-macro/postcss.mjs +45 -54
  25. package/dist/debug/index.d.ts +2 -0
  26. package/dist/defaults-DW-EahCC.js +145 -0
  27. package/dist/defaults-w3rlKQwe.mjs +139 -0
  28. package/dist/defaults.d.ts +2 -16
  29. package/dist/defaults.js +7 -208
  30. package/dist/defaults.mjs +4 -9
  31. package/dist/defu-Cdz2PomB.js +60 -0
  32. package/dist/defu-n46TJT6t.mjs +57 -0
  33. package/dist/env.d.ts +2 -0
  34. package/dist/escape.d.ts +4 -0
  35. package/dist/extractors/split.d.ts +3 -0
  36. package/dist/gulp.d.ts +1 -26
  37. package/dist/gulp.js +38 -1898
  38. package/dist/gulp.mjs +30 -15
  39. package/dist/index-B2TNoaOv.mjs +134 -0
  40. package/dist/index-B5NiRecR.js +130 -0
  41. package/dist/index-BEIjgKpF.mjs +11 -0
  42. package/dist/index-BPzIdybK.mjs +513 -0
  43. package/dist/index-DeW_zXzo.mjs +124 -0
  44. package/dist/index-DmzxhHCX.js +136 -0
  45. package/dist/index-DwZHOkK3.js +526 -0
  46. package/dist/index-HC-Qkn0i.js +17 -0
  47. package/dist/index.d.ts +4 -17
  48. package/dist/index.js +43 -2291
  49. package/dist/index.mjs +33 -23
  50. package/dist/js/handlers.d.ts +13 -0
  51. package/dist/js/index.d.ts +7 -0
  52. package/dist/mangle/index.d.ts +8 -0
  53. package/dist/options-7EjuAISl.mjs +869 -0
  54. package/dist/options-C-rvBixk.js +901 -0
  55. package/dist/options.d.ts +2 -0
  56. package/dist/postcss/cssVars.d.ts +5 -0
  57. package/dist/postcss/index.d.ts +3 -0
  58. package/dist/postcss/mp.d.ts +8 -0
  59. package/dist/postcss/plugins/ctx.d.ts +6 -0
  60. package/dist/postcss/plugins/index.d.ts +7 -0
  61. package/dist/postcss/plugins/post.d.ts +5 -0
  62. package/dist/postcss/plugins/pre.d.ts +5 -0
  63. package/dist/postcss/preflight.d.ts +3 -0
  64. package/dist/postcss/selectorParser.d.ts +6 -0
  65. package/dist/postcss/shared.d.ts +3 -0
  66. package/dist/postcss/symbols.d.ts +1 -0
  67. package/dist/postcss.d.ts +1 -23
  68. package/dist/postcss.js +22 -598
  69. package/dist/postcss.mjs +8 -17
  70. package/dist/reg.d.ts +1 -0
  71. package/dist/replace.d.ts +3 -19
  72. package/dist/replace.js +42 -93
  73. package/dist/replace.mjs +26 -30
  74. package/dist/shared-DbJl6i6a.mjs +25 -0
  75. package/dist/shared-hzYeE1wX.js +28 -0
  76. package/dist/tailwindcss/patcher.d.ts +3 -0
  77. package/dist/types.d.ts +165 -0
  78. package/dist/utils.d.ts +18 -0
  79. package/dist/v5-BD9-sqra.mjs +174 -0
  80. package/dist/v5-Ch6783yy.js +181 -0
  81. package/dist/vite.d.ts +1 -22
  82. package/dist/vite.js +36 -1947
  83. package/dist/vite.mjs +28 -15
  84. package/dist/weapp-tw-runtime-loader.js +14 -41
  85. package/dist/weapp-tw-runtime-loader.mjs +8 -12
  86. package/dist/webpack.d.ts +1 -26
  87. package/dist/webpack.js +37 -1994
  88. package/dist/webpack.mjs +29 -15
  89. package/dist/webpack4.d.ts +1 -27
  90. package/dist/webpack4.js +190 -1979
  91. package/dist/webpack4.mjs +188 -211
  92. package/dist/wxml/Tokenizer.d.ts +31 -0
  93. package/dist/wxml/index.d.ts +2 -0
  94. package/dist/wxml/shared.d.ts +2 -0
  95. package/dist/wxml/utils.d.ts +13 -0
  96. package/package.json +3 -3
  97. package/dist/chunk-257YPDSI.mjs +0 -173
  98. package/dist/chunk-75EWCRQW.mjs +0 -13
  99. package/dist/chunk-AB467PG7.mjs +0 -43
  100. package/dist/chunk-E7XGHGC7.mjs +0 -62
  101. package/dist/chunk-GUE4UCRJ.mjs +0 -126
  102. package/dist/chunk-IOYI6MSW.mjs +0 -533
  103. package/dist/chunk-LDWI65M5.mjs +0 -152
  104. package/dist/chunk-NVFWRLOI.mjs +0 -27
  105. package/dist/chunk-ORMKM6ZA.mjs +0 -30
  106. package/dist/chunk-PC4B5JJB.mjs +0 -953
  107. package/dist/chunk-SRLZU2YE.mjs +0 -95
  108. package/dist/chunk-VECXHWWG.mjs +0 -31
  109. package/dist/chunk-VN37QGSM.mjs +0 -216
  110. package/dist/cli.d.mts +0 -2
  111. package/dist/core.d.mts +0 -22
  112. package/dist/css-macro/index.d.mts +0 -18
  113. package/dist/css-macro/postcss.d.mts +0 -7
  114. package/dist/defaults.d.mts +0 -16
  115. package/dist/gulp.d.mts +0 -26
  116. package/dist/index.d.mts +0 -17
  117. package/dist/postcss.d.mts +0 -23
  118. package/dist/replace.d.mts +0 -19
  119. package/dist/types-DSNuiOhH.d.mts +0 -519
  120. package/dist/types-DSNuiOhH.d.ts +0 -519
  121. package/dist/vite.d.mts +0 -22
  122. package/dist/weapp-tw-runtime-loader.d.mts +0 -7
  123. package/dist/webpack.d.mts +0 -26
  124. package/dist/webpack4.d.mts +0 -27
@@ -1,519 +0,0 @@
1
- import { Rule } from 'postcss';
2
- import { IClassGeneratorOptions, ClassGenerator } from '@tailwindcss-mangle/shared';
3
- import { SourceMap } from 'magic-string';
4
- import { GeneratorResult } from '@babel/generator';
5
- import { ParseError, ParserOptions } from '@babel/parser';
6
- import { UserDefinedOptions as UserDefinedOptions$1 } from 'postcss-rem-to-responsive-pixel';
7
- import { Result } from 'postcss-load-config';
8
- import { ILengthUnitsPatchOptions, TailwindcssPatcher } from 'tailwindcss-patch';
9
- import { Buffer } from 'node:buffer';
10
- import { LRUCache } from 'lru-cache';
11
- import { sources } from 'webpack';
12
-
13
- type InjectPreflight = () => IPropValue[];
14
-
15
- declare function createContext(): {
16
- variablesScopeWeakMap: WeakMap<object, any>;
17
- isVariablesScope: (rule: WeakKey) => boolean;
18
- markVariablesScope: (rule: WeakKey) => void;
19
- };
20
- type IContext = ReturnType<typeof createContext>;
21
-
22
- interface HashMapValue {
23
- hash: string;
24
- changed: boolean;
25
- }
26
- type HashMapKey = string | number;
27
- type CacheValue = sources.Source | string;
28
- interface ICreateCacheReturnType {
29
- hashMap: Map<HashMapKey, HashMapValue>;
30
- instance: LRUCache<string, CacheValue>;
31
- hasHashKey: (key: HashMapKey) => boolean;
32
- getHashValue: (key: HashMapKey) => HashMapValue | undefined;
33
- setHashValue: (key: HashMapKey, value: HashMapValue) => this['hashMap'];
34
- computeHash: (message: string | Buffer) => string;
35
- get: <V extends CacheValue = sources.Source>(key: string) => V | undefined;
36
- set: <V extends CacheValue = sources.Source>(key: string, value: V) => this['instance'];
37
- has: (key: string) => boolean;
38
- calcHashValueChanged: (key: HashMapKey, hash: string) => this;
39
- process: (key: string, callback: () => void | false | Promise<void | false>, fallback: () => void | {
40
- key: string;
41
- source: CacheValue;
42
- } | Promise<void | {
43
- key: string;
44
- source: CacheValue;
45
- }>) => void | Promise<void>;
46
- }
47
-
48
- type PostcssOptions = Partial<Omit<Result, 'file'>>;
49
- type ItemOrItemArray<T> = T | T[];
50
- type AppType = 'uni-app' | 'uni-app-vite' | 'taro' | 'remax' | 'rax' | 'native' | 'kbone' | 'mpx';
51
- interface IPropValue {
52
- prop: string;
53
- value: string;
54
- }
55
- type CssPresetProps = string;
56
- type CssPreflightOptions = {
57
- [key: CssPresetProps]: string | number | boolean;
58
- } | false;
59
- type RequiredStyleHandlerOptions = {
60
- /**
61
- * @description 默认为 true,此时会对样式主文件,进行猜测
62
- */
63
- isMainChunk: boolean;
64
- cssInjectPreflight?: InjectPreflight;
65
- escapeMap?: Record<string, string>;
66
- } & Pick<UserDefinedOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
67
- type CustomRuleCallback = (node: Rule, options: Readonly<RequiredStyleHandlerOptions>) => void;
68
- interface InternalCssSelectorReplacerOptions {
69
- mangleContext?: IMangleScopeContext;
70
- escapeMap?: Record<string, string>;
71
- }
72
- type IStyleHandlerOptions = {
73
- customRuleCallback?: CustomRuleCallback;
74
- mangleContext?: IMangleScopeContext;
75
- ctx?: IContext;
76
- postcssOptions?: PostcssOptions;
77
- cssRemoveHoverPseudoClass?: boolean;
78
- } & RequiredStyleHandlerOptions;
79
- interface JsHandlerReplaceResult {
80
- code: string;
81
- map?: SourceMap;
82
- }
83
- type JsHandlerResult = (JsHandlerReplaceResult | GeneratorResult) & {
84
- error?: ParseError;
85
- };
86
- type ICustomAttributes = Record<string, ItemOrItemArray<string | RegExp>> | Map<string | RegExp, ItemOrItemArray<string | RegExp>>;
87
- type ICustomAttributesEntities = [string | RegExp, ItemOrItemArray<string | RegExp>][];
88
- interface IJsHandlerOptions {
89
- escapeMap?: Record<string, string>;
90
- classNameSet?: Set<string>;
91
- arbitraryValues?: IArbitraryValues;
92
- mangleContext?: IMangleScopeContext;
93
- jsPreserveClass?: (keyword: string) => boolean | undefined;
94
- needEscaped?: boolean;
95
- generateMap?: boolean;
96
- always?: boolean;
97
- jsAstTool?: 'babel' | 'ast-grep';
98
- unescapeUnicode?: boolean;
99
- babelParserOptions?: ParserOptions;
100
- }
101
- interface RawSource {
102
- start: number;
103
- end: number;
104
- raw: string;
105
- source?: string;
106
- }
107
- interface IMangleOptions {
108
- classGenerator?: IClassGeneratorOptions;
109
- mangleClassFilter?: (className: string) => boolean;
110
- }
111
- interface IArbitraryValues {
112
- /**
113
- * 是否允许在类名里,使用双引号。
114
- * 建议不要开启,因为有些框架,比如 `vue3` 它针对有些静态模板会直接编译成 `html` 字符串,此时开启这个配置很有可能导致转义出错
115
- *
116
- * @example
117
- * ```html
118
- * <!-- 开启前默认只允许单引号 -->
119
- * <view class="after:content-['对酒当歌,人生几何']"></view>
120
- * <!-- 开启后 -->
121
- * <view class="after:content-[\"对酒当歌,人生几何\"]"></view>
122
- * ```
123
- *
124
- * @default `false`
125
- */
126
- allowDoubleQuotes?: boolean;
127
- }
128
- interface UserDefinedOptions {
129
- /**
130
- * @group 1.文件匹配
131
- * @description 匹配 `wxml`等等模板进行处理的方法
132
- */
133
- htmlMatcher?: (name: string) => boolean;
134
- /**
135
- * @group 1.文件匹配
136
- * @description 匹配 `wxss` 等等样式文件的方法
137
- */
138
- cssMatcher?: (name: string) => boolean;
139
- /**
140
- * @group 1.文件匹配
141
- * @description 匹配编译后 `js` 文件进行处理的方法
142
- */
143
- jsMatcher?: (name: string) => boolean;
144
- /**
145
- * @group 1.文件匹配
146
- * @description `tailwindcss css var inject scope` 的匹配方法,用于处理原始变量和替换不兼容选择器。可以不传,但是遇到某些 `::before/::after` 选择器注入冲突时,建议传入参数手动指定 css bundle 文件位置
147
- *
148
- */
149
- mainCssChunkMatcher?: (name: string, appType?: AppType) => boolean;
150
- /**
151
- * @group 0.重要配置
152
- * @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/7
153
- * @description 在所有 view节点添加的 css 预设,可根据情况自由的禁用原先的规则,或者添加新的规则。默认预置 `css` 同 `tailwindcss` 类似,详细用法如下:
154
- * ```js
155
- * // default 默认,这代表会添加给所有的 view / text 元素, 受到 cssPreflightRange 配置项影响 :
156
- cssPreflight: {
157
- 'box-sizing': 'border-box',
158
- 'border-width': '0',
159
- 'border-style': 'solid',
160
- 'border-color': 'currentColor'
161
- }
162
- // result
163
- // box-sizing: border-box;
164
- // border-width: 0;
165
- // border-style: solid;
166
- // border-color: currentColor
167
-
168
- // case 禁用所有
169
- cssPreflight: false
170
- // result
171
- // none
172
-
173
- // case 禁用单个属性
174
- cssPreflight: {
175
- 'box-sizing': false
176
- }
177
- // border-width: 0;
178
- // border-style: solid;
179
- // border-color: currentColor
180
-
181
- // case 更改和添加单个属性
182
- cssPreflight: {
183
- 'box-sizing': 'content-box',
184
- 'background': 'black'
185
- }
186
- // result
187
- // box-sizing: content-box;
188
- // border-width: 0;
189
- // border-style: solid;
190
- // border-color: currentColor;
191
- // background: black
192
- * ```
193
- */
194
- cssPreflight?: CssPreflightOptions;
195
- /**
196
- * @group 0.重要配置
197
- * @issue https://github.com/sonofmagic/weapp-tailwindcss/pull/62
198
- * @description 全局`dom`选择器,只有在这个选择器作用范围内的`dom`会被注入 `cssPreflight` 的变量和默认样式。只对所有的 `view`,`text` 和伪元素生效,想要对所有的元素生效,可切换为 `'all'`,此时需要自行处理和客户端默认样式的冲突
199
- */
200
- cssPreflightRange?: 'all';
201
- /**
202
- * @group 0.重要配置
203
- * @description 是否禁用此插件,一般用于构建到多平台时使用,比如小程序时不传,非小程序环境(h5,app)传入一个 `true`
204
- */
205
- disabled?: boolean;
206
- /**
207
- * @group 3.一般配置
208
- * @description 用于自定义处理 css 的回调函数,可根据 Postcss walk 方法自由定制处理方案的 callback 方法
209
- */
210
- customRuleCallback?: CustomRuleCallback;
211
- /**
212
- * @group 2.生命周期
213
- * @description plugin apply 初调用
214
- */
215
- onLoad?: () => void;
216
- /**
217
- * @group 2.生命周期
218
- * @description 开始处理时调用
219
- */
220
- onStart?: () => void;
221
- /**
222
- * @description 匹配成功并修改文件内容前调用
223
- */
224
- /**
225
- * @group 2.生命周期
226
- * @description 匹配成功并修改文件内容后调用
227
- */
228
- onUpdate?: (filename: string, oldVal: string, newVal: string) => void;
229
- /**
230
- * @group 2.生命周期
231
- * @description 结束处理时调用
232
- */
233
- onEnd?: () => void;
234
- /**
235
- * @group 0.重要配置
236
- * @description **这是一个重要的配置!**
237
-
238
- 它可以自定义`wxml`标签上的`attr`转化属性。默认转化所有的`class`和`hover-class`,这个`Map`的 `key`为匹配标签,`value`为属性字符串或者匹配正则数组。
239
-
240
- 如果你想要增加,对于所有标签都生效的转化的属性,你可以添加 `*`: `(string | Regexp)[]` 这样的键值对。(`*` 是一个特殊值,代表所有标签)
241
-
242
- 更复杂的情况,可以传一个 `Map<string | Regex, (string | Regex)[]>`实例。
243
-
244
- 假如你要把 `className` 通过组件的`prop`传递给子组件,又或者想要自定义转化的标签属性时,需要用到此配置,案例详见:[issue#129](https://github.com/sonofmagic/weapp-tailwindcss/issues/129#issuecomment-1340914688),[issue#134](https://github.com/sonofmagic/weapp-tailwindcss/issues/134#issuecomment-1351288238)
245
-
246
- @example
247
-
248
- ```js
249
- const customAttributes = {
250
- // 匹配所有带 Class / class 相关的标签,比如某个组件上的 `a-class`, `testClass` , `custom-class` 里面的值
251
- '*': [ /[A-Za-z]?[A-Za-z-]*[Cc]lass/ ],
252
- // 额外匹配转化 `van-image` 标签上属性为 `custom-class` 的值
253
- 'van-image': ['custom-class'],
254
- // 转化所有 `ice-button` 标签上属性为 `testClass` 的值
255
- 'ice-button': ['testClass']
256
- }
257
- ```
258
-
259
- 当然你可以根据自己的需求,定义单个或者多个正则/字符串。
260
-
261
- 甚至有可能你编写正则表达式,它们匹配的范围,直接包括了插件里自带默认的 `class`/`hover-class`,那么这种情况下,你完全可以取代插件的默认模板转化器,开启 [disabledDefaultTemplateHandler](/docs/api/interfaces/UserDefinedOptions#disableddefaulttemplatehandler) 配置项,禁用默认的模版匹配转化器。
262
- */
263
- customAttributes?: ICustomAttributes;
264
- /**
265
- * @group 0.重要配置
266
- * @description 自定义转化class名称字典,这个配置项用来自定义转化`class`名称字典,你可以使用这个选项来简化生成的`class`
267
-
268
- 插件中默认使用`'simple'`模式:
269
-
270
- - `'simple'`模式: 把小程序中不允许的字符串,转义为**相等长度**的代替字符串,这种情况不追求转化目标字符串的一比一绝对等价,即无法从生成结果,反推原先的`class`
271
-
272
- 当然,你也可以自定义,传一个 `Record<string, string>` 类型,只需保证转化后 css 中的 `class` 选择器,不会和自己定义的 `class` 产生冲突即可,示例见[dic.ts](https://github.com/sonofmagic/weapp-core/blob/main/packages/escape/src/dic.ts)
273
- * @default SimpleMappingChars2String
274
- */
275
- customReplaceDictionary?: Record<string, string>;
276
- /**
277
- * @group 3.一般配置
278
- * @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/110
279
- * @description 自从`tailwindcss 3.2.0`对任意值添加了长度单位的校验后,小程序中的`rpx`这个`wxss`单位,由于不在长度合法名单中,于是被识别成了颜色,导致与预期不符,详见:[issues/110](https://github.com/sonofmagic/weapp-tailwindcss/issues/110)。所以这个选项是用来给`tailwindcss`运行时,自动打上一个支持`rpx`单位的补丁。默认开启,在绝大部分情况下,你都可以忽略这个配置项,除非你需要更高级的自定义。
280
- > 目前自动检索可能存在一定的缺陷,它会在第一次运行的时候不生效,关闭后第二次运行才生效。这是因为 nodejs 运行时先加载好了 `tailwindcss` 模块 ,然后再来运行这个插件,自动给 `tailwindcss` 运行时打上 `patch`。此时由于 `tailwindcss` 模块已经加载,所以 `patch` 在第一次运行时不生效,`ctrl+c` 关闭之后,再次运行才生效。这种情况可以使用:
281
-
282
- ```diff
283
- "scripts": {
284
- + "postinstall": "weapp-tw patch"
285
- }
286
- ```
287
-
288
- 使用 `npm hooks` 的方式来给 `tailwindcss` 自动打 `patch`
289
- */
290
- supportCustomLengthUnitsPatch?: ILengthUnitsPatchOptions | boolean;
291
- /**
292
- * @group 3.一般配置
293
- * @description 使用的框架类型(uni-app,taro...),用于找到主要的 `css bundle` 进行转化,这个配置会影响默认方法 `mainCssChunkMatcher` 的行为,不传会去猜测 `tailwindcss css var inject scope` (tailwindcss 变量注入的位置) 的位置
294
- */
295
- appType?: AppType;
296
- /**
297
- * @group 3.一般配置
298
- * @description 是否压缩混淆 `wxml`,`js` 和 `wxss` 中指定范围的 `class` 以避免选择器过长问题,默认为`false`不开启,详细配置见 [unplugin-tailwindcss-mangle](https://github.com/sonofmagic/tailwindcss-mangle/tree/main/packages/unplugin-tailwindcss-mangle)
299
- * @url https://github.com/sonofmagic/tailwindcss-mangle
300
- */
301
- mangle?: boolean | IMangleOptions;
302
- /**
303
- * @group 3.一般配置
304
- * @description 针对 tailwindcss arbitrary values 的一些配置
305
- */
306
- arbitraryValues?: IArbitraryValues;
307
- /**
308
- * @group 3.一般配置
309
- * @description 用于控制 tailwindcss 子组合器的生效标签范围, 这里我们用一个例子来说明这个配置是干啥用的.
310
- *
311
- * 我们布局的时候往往会使用 `space-x-4`
312
- * 那么实际上会生成这样的css选择器:
313
- * ```css
314
- * .space-x-4>:not([hidden])~:not([hidden]){}
315
- * ```
316
- * 然而很不幸,这个选择器在小程序中是不支持的,写了会报错导致编译失败。
317
- * 所以出于保守起见,我把它替换为了:
318
- * ```css
319
- * .space-x-4>view + view{}
320
- * ```
321
- * 这同时也是默认值, 而这个选项就允许你进行自定义子组合器的行为
322
- *
323
- * 你可以传入一个 字符串,或者字符串数组
324
- * 1. 传入字符串数组,比如 `['view','text']` 生成:
325
- * ```css
326
- * .space-y-4>view + view,text + text{}
327
- * ```
328
- *
329
- * 2. 传入一个字符串,此时行为变成了整个替换,比如 `'view,text,button,input ~ view,text,button,input'` 生成:
330
- * ```css
331
- * .space-y-4>view,text,button,input ~ view,text,button,input{}
332
- * ```
333
- * @default 'view + view'
334
- */
335
- cssChildCombinatorReplaceValue?: string | string[];
336
- /**
337
- * @group 1.文件匹配
338
- * @experiment 实验性质,有可能会改变
339
- * @description 各个平台 `wxs` 文件的匹配方法,可以设置为包括微信的 .wxs,支付宝的 .sjs 和 百度小程序的 .filter.js
340
- * > tip: 记得在 `tailwind.config.js` 中,把 `wxs` 这个格式加入 `content` 配置项,不然不会生效
341
- * @default ()=>false
342
- */
343
- wxsMatcher?: (name: string) => boolean;
344
- /**
345
- * @group 1.文件匹配
346
- * @experiment 实验性质,有可能会改变
347
- * @description 是否转义 `wxml` 中内联的 `wxs`
348
- * > tip: 记得在 `tailwind.config.js` 中,把 `wxs` 这个格式加入 `content` 配置项,不然不会生效
349
- * @example
350
- * ```html
351
- * <!-- index.wxml -->
352
- * <wxs module="inline">
353
- // 我是内联wxs
354
- // 下方的类名会被转义
355
- var className = "after:content-['我是className']"
356
- module.exports = {
357
- className: className
358
- }
359
- </wxs>
360
- <wxs src="./index.wxs" module="outside"/>
361
- <view><view class="{{inline.className}}"></view><view class="{{outside.className}}"></view></view>
362
- * ```
363
- * @default false
364
- */
365
- inlineWxs?: boolean;
366
- /**
367
- * @group 0.重要配置
368
- * @version `^2.6.0`
369
- * @description 是否注入额外的 `tailwindcss css var scope` 区域,这个选项用于这样的场景
370
- *
371
- * 比如 `taro vue3` 使用 [NutUI](https://nutui.jd.com), 需要使用 `@tarojs/plugin-html`,而这个插件会启用 `postcss-html-transform` 从而移除所有带 `*` 选择器
372
- *
373
- * 这会导致 `tailwindcss css var scope` 区域被移除导致一些样式,比如渐变等等功能失效
374
- *
375
- * 这种场景下,启用这个选项会再次重新注入整个 `tailwindcss css var scope`
376
- *
377
- * @default false
378
- */
379
- injectAdditionalCssVarScope?: boolean;
380
- /**
381
- * @group 3.一般配置
382
- * @version `^2.6.1`
383
- * @description 当 `tailwindcss` 和 `js` 处理的字面量撞车的时候,配置此选项可以用来保留js字面量,不进行转义处理。返回值中,想要当前js字面量保留,则返回 `true`。想要转义则返回 `false/undefined`
384
- * @default 保留所有带 `*` js字符串字面量
385
- */
386
- jsPreserveClass?: (keyword: string) => boolean | undefined;
387
- /**
388
- * @group 3.一般配置
389
- * @version `^2.6.2`
390
- * @description 开启此选项,将会禁用默认 `wxml` 模板替换器,此时模板的匹配和转化将完全被 [`customAttributes`](/docs/api/interfaces/UserDefinedOptions#customattributes) 接管,
391
- *
392
- * 此时你需要自己编写匹配之前默认 `class`/`hover-class`,以及新的标签属性的正则表达式`regex`
393
- * @default false
394
- */
395
- disabledDefaultTemplateHandler?: boolean;
396
- /**
397
- * @ignore
398
- * @internal
399
- */
400
- runtimeLoaderPath?: string;
401
- /**
402
- * @group 0.重要配置
403
- * @description 用于处理 css 选择器的替换
404
- */
405
- cssSelectorReplacement?: {
406
- /**
407
- * @default `'page'` <br/>
408
- * @description 把`css`中的全局选择器 **`:root`** 替换为指定值,默认替换为 `'page'`,设置为 `false` 时不进行替换
409
- */
410
- root?: string | string[] | false;
411
- /**
412
- * @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/81 <br/>
413
- * @default `['view','text']` <br/>
414
- * @description 把`css`中的全局选择器 **`*`** 替换为指定值,默认替换为 `'view','text'`,设置为 `false` 时不进行替换,此时小程序会由于不认识`*`选择器而报错
415
- */
416
- universal?: string | string[] | false;
417
- };
418
- /**
419
- * @group 3.一般配置
420
- * @version `^2.9.3`
421
- * @description 用于指定路径来获取 tailwindcss 上下文,一般情况下不用传入,使用 linked / monorepo 可能需要指定具体位置,路径通常是目标项目的 package.json 所在目录
422
- */
423
- tailwindcssBasedir?: string;
424
- /**
425
- * @version `^3.0.0`
426
- * @group 0.重要配置
427
- * @description rem 转 rpx 配置,默认为 `undefined` 不开启,可传入 `true` 启用默认配置项,也可传入自定义配置项,配置项列表见 [postcss-rem-to-responsive-pixel](https://www.npmjs.com/package/postcss-rem-to-responsive-pixel)
428
- */
429
- rem2rpx?: boolean | UserDefinedOptions$1;
430
- /**
431
- * @group 3.一般配置
432
- * @version `^3.0.11`
433
- * @description 缓存策略
434
- */
435
- cache?: boolean | ICreateCacheReturnType;
436
- /**
437
- * @version `^3.1.0`
438
- * @group 0.重要配置
439
- * @description 对解析 js 使用的 ast 工具,默认情况使用 `babel`,可以通过安装 `@ast-grep/napi`,同时启用 `ast-grep` 配置项,来启用 `ast-grep` 来处理 `js`,速度会是 `babel` 的 `2` 倍左右
440
- */
441
- jsAstTool?: 'babel' | 'ast-grep';
442
- /**
443
- * @version `^3.2.0`
444
- * @group 3.一般配置
445
- * @description 对解析 js 使用的 `@babel/parser` 工具的配置
446
- */
447
- babelParserOptions?: ParserOptions;
448
- /**
449
- * @version `^3.2.0`
450
- * @group 3.一般配置
451
- * @description 对解析 css 使用的 `postcss` 工具的配置
452
- */
453
- postcssOptions?: PostcssOptions;
454
- /**
455
- * @version `^3.2.1`
456
- * @group 3.一般配置
457
- * @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/293
458
- * @default `true`
459
- * @description 是否删除 css :hover 选择器节点,默认为 `true`, 原因在于,小程序 css :hover 是不生效的,要使用 view 这种标签的 hover-class 属性
460
- */
461
- cssRemoveHoverPseudoClass?: boolean;
462
- }
463
- interface JsHandler {
464
- (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions): JsHandlerResult | Promise<JsHandlerResult>;
465
- sync: (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult;
466
- }
467
- interface IMangleScopeContext {
468
- rawOptions: UserDefinedOptions['mangle'];
469
- runtimeSet: Set<string>;
470
- classGenerator: ClassGenerator;
471
- filter: (className: string) => boolean;
472
- cssHandler: (rawSource: string) => string;
473
- jsHandler: (rawSource: string) => string;
474
- wxmlHandler: (rawSource: string) => string;
475
- }
476
- interface ICommonReplaceOptions {
477
- keepEOL?: boolean;
478
- escapeMap?: Record<string, string>;
479
- }
480
- interface ITemplateHandlerOptions extends ICommonReplaceOptions {
481
- customAttributesEntities?: ICustomAttributesEntities;
482
- escapeMap?: Record<string, string>;
483
- mangleContext?: IMangleScopeContext;
484
- inlineWxs?: boolean;
485
- jsHandler?: JsHandler;
486
- runtimeSet?: Set<string>;
487
- disabledDefaultTemplateHandler?: boolean;
488
- quote?: string | null;
489
- ignoreHead?: boolean;
490
- }
491
- type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, 'supportCustomLengthUnitsPatch' | 'customReplaceDictionary' | 'cache'> & {
492
- supportCustomLengthUnitsPatch: ILengthUnitsPatchOptions | boolean;
493
- templateHandler: (rawSource: string, options?: ITemplateHandlerOptions) => Promise<string>;
494
- styleHandler: (rawSource: string, options: IStyleHandlerOptions) => Promise<string>;
495
- jsHandler: JsHandler;
496
- escapeMap: Record<string, string>;
497
- patch: () => void;
498
- customReplaceDictionary: Record<string, string>;
499
- setMangleRuntimeSet: (runtimeSet: Set<string>) => void;
500
- cache: ICreateCacheReturnType;
501
- twPatcher: TailwindcssPatcher;
502
- }>;
503
- type InternalPostcssOptions = Pick<UserDefinedOptions, 'cssMatcher' | 'mainCssChunkMatcher' | 'cssPreflight' | 'cssPreflightRange' | 'customRuleCallback' | 'disabled'>;
504
- interface IBaseWebpackPlugin {
505
- options: InternalUserDefinedOptions;
506
- appType?: AppType;
507
- apply: (compiler: any) => void;
508
- }
509
- /**
510
- * @description InternalPatchResult
511
- */
512
- interface InternalPatchResult {
513
- dataTypes?: string;
514
- processTailwindFeatures?: string;
515
- plugin?: string;
516
- }
517
- type CreateJsHandlerOptions = Omit<IJsHandlerOptions, 'classNameSet'>;
518
-
519
- export type { AppType as A, CssPresetProps as C, ItemOrItemArray as I, JsHandlerReplaceResult as J, RequiredStyleHandlerOptions as R, UserDefinedOptions as U, IPropValue as a, CssPreflightOptions as b, CustomRuleCallback as c, InternalCssSelectorReplacerOptions as d, IStyleHandlerOptions as e, JsHandlerResult as f, ICustomAttributes as g, ICustomAttributesEntities as h, IJsHandlerOptions as i, RawSource as j, IMangleOptions as k, IArbitraryValues as l, JsHandler as m, IMangleScopeContext as n, ICommonReplaceOptions as o, ITemplateHandlerOptions as p, InternalUserDefinedOptions as q, InternalPostcssOptions as r, IBaseWebpackPlugin as s, InternalPatchResult as t, CreateJsHandlerOptions as u };
package/dist/vite.d.mts DELETED
@@ -1,22 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { U as UserDefinedOptions } from './types-DSNuiOhH.mjs';
3
- import 'postcss';
4
- import '@tailwindcss-mangle/shared';
5
- import 'magic-string';
6
- import '@babel/generator';
7
- import '@babel/parser';
8
- import 'postcss-rem-to-responsive-pixel';
9
- import 'postcss-load-config';
10
- import 'tailwindcss-patch';
11
- import 'node:buffer';
12
- import 'lru-cache';
13
- import 'webpack';
14
-
15
- /**
16
- * @name UnifiedViteWeappTailwindcssPlugin
17
- * @description uni-app vite vue3 版本插件
18
- * @link https://weapp-tw.icebreaker.top/docs/quick-start/frameworks/uni-app-vite
19
- */
20
- declare function UnifiedViteWeappTailwindcssPlugin(options?: UserDefinedOptions): Plugin | undefined;
21
-
22
- export { UnifiedViteWeappTailwindcssPlugin };
@@ -1,7 +0,0 @@
1
- import webpack from 'webpack';
2
-
3
- declare const WeappTwRuntimeAopLoader: webpack.LoaderDefinitionFunction<{
4
- getClassSet: () => void;
5
- }>;
6
-
7
- export { WeappTwRuntimeAopLoader as default };
@@ -1,26 +0,0 @@
1
- import { Compiler } from 'webpack';
2
- import { s as IBaseWebpackPlugin, q as InternalUserDefinedOptions, A as AppType, U as UserDefinedOptions } from './types-DSNuiOhH.mjs';
3
- import 'postcss';
4
- import '@tailwindcss-mangle/shared';
5
- import 'magic-string';
6
- import '@babel/generator';
7
- import '@babel/parser';
8
- import 'postcss-rem-to-responsive-pixel';
9
- import 'postcss-load-config';
10
- import 'tailwindcss-patch';
11
- import 'node:buffer';
12
- import 'lru-cache';
13
-
14
- /**
15
- * @name UnifiedWebpackPluginV5
16
- * @description webpack5 核心转义插件
17
- * @link https://weapp-tw.icebreaker.top/docs/intro
18
- */
19
- declare class UnifiedWebpackPluginV5 implements IBaseWebpackPlugin {
20
- options: InternalUserDefinedOptions;
21
- appType?: AppType;
22
- constructor(options?: UserDefinedOptions);
23
- apply(compiler: Compiler): void;
24
- }
25
-
26
- export { UnifiedWebpackPluginV5 };
@@ -1,27 +0,0 @@
1
- import { Compiler } from 'webpack4';
2
- import { s as IBaseWebpackPlugin, q as InternalUserDefinedOptions, A as AppType, U as UserDefinedOptions } from './types-DSNuiOhH.mjs';
3
- import 'postcss';
4
- import '@tailwindcss-mangle/shared';
5
- import 'magic-string';
6
- import '@babel/generator';
7
- import '@babel/parser';
8
- import 'postcss-rem-to-responsive-pixel';
9
- import 'postcss-load-config';
10
- import 'tailwindcss-patch';
11
- import 'node:buffer';
12
- import 'lru-cache';
13
- import 'webpack';
14
-
15
- /**
16
- * @name UnifiedWebpackPluginV4
17
- * @description webpack4 核心转义插件
18
- * @link https://weapp-tw.icebreaker.top/docs/intro
19
- */
20
- declare class UnifiedWebpackPluginV4 implements IBaseWebpackPlugin {
21
- options: InternalUserDefinedOptions;
22
- appType?: AppType;
23
- constructor(options?: UserDefinedOptions);
24
- apply(compiler: Compiler): void;
25
- }
26
-
27
- export { UnifiedWebpackPluginV4 };