weapp-tailwindcss 3.0.11 → 3.1.0

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.
@@ -60,12 +60,23 @@ const splitCode = (code, allowDoubleQuotes = false) => {
60
60
  return code.split(splitter).filter((element) => isValidSelector(element));
61
61
  };
62
62
 
63
+ function decodeUnicode(s) {
64
+ return unescape(s.replaceAll(/\\(u[\dA-Fa-f]{4})/gm, '%$1'));
65
+ }
63
66
  function replaceHandleValue(str, node, options, ms, offset = 0) {
64
- const { classNameSet: set, escapeMap, mangleContext: ctx, needEscaped = false, jsPreserveClass, arbitraryValues, always } = options;
67
+ const { classNameSet: set, escapeMap, mangleContext: ctx, needEscaped = false, jsPreserveClass, arbitraryValues, always, unescapeUnicode } = options;
65
68
  const allowDoubleQuotes = arbitraryValues === null || arbitraryValues === void 0 ? void 0 : arbitraryValues.allowDoubleQuotes;
66
69
  const arr = splitCode(str, allowDoubleQuotes);
67
70
  let rawStr = str;
68
- for (const v of arr) {
71
+ let needDecodeUnicode = false;
72
+ if (unescapeUnicode && rawStr.includes('\\')) {
73
+ rawStr = decodeUnicode(rawStr);
74
+ needDecodeUnicode = true;
75
+ }
76
+ for (let v of arr) {
77
+ if (needDecodeUnicode && v.includes('\\')) {
78
+ v = decodeUnicode(v);
79
+ }
69
80
  if (always || (set && set.has(v) && !(jsPreserveClass === null || jsPreserveClass === void 0 ? void 0 : jsPreserveClass(v)))) {
70
81
  let ignoreFlag = false;
71
82
  if (Array.isArray(node.leadingComments)) {
@@ -99,7 +110,46 @@ function isEvalPath(p) {
99
110
  }
100
111
  return false;
101
112
  }
113
+ function getAstGrep() {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ try {
116
+ const { js } = yield import('@ast-grep/napi');
117
+ return js;
118
+ }
119
+ catch (error) {
120
+ console.warn('请先安装 `@ast-grep/napi` , 安装完成后再尝试运行!');
121
+ throw error;
122
+ }
123
+ });
124
+ }
125
+ function astGrepUpdateString(ast, options, ms) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ const js = yield getAstGrep();
128
+ const nodes = ast.findAll(js.kind('string'));
129
+ for (const node of nodes) {
130
+ const range = node.range();
131
+ const text = node.text();
132
+ replaceHandleValue(text.slice(1, -1), {
133
+ end: range.end.index - 1,
134
+ start: range.start.index + 1
135
+ }, Object.assign(Object.assign({}, options), { unescapeUnicode: true }), ms, 0);
136
+ }
137
+ const templateNodes = ast.findAll(js.kind('template_string'));
138
+ for (const node of templateNodes) {
139
+ const fragments = node.findAll(js.kind('string_fragment'));
140
+ for (const fragment of fragments) {
141
+ const range = fragment.range();
142
+ const text = fragment.text();
143
+ replaceHandleValue(text, {
144
+ end: range.end.index,
145
+ start: range.start.index
146
+ }, Object.assign(Object.assign({}, options), { unescapeUnicode: true }), ms, 0);
147
+ }
148
+ }
149
+ });
150
+ }
102
151
  function jsHandler(rawSource, options) {
152
+ const ms = new MagicString(rawSource);
103
153
  let ast;
104
154
  try {
105
155
  ast = parse(rawSource, {
@@ -111,8 +161,7 @@ function jsHandler(rawSource, options) {
111
161
  code: rawSource
112
162
  };
113
163
  }
114
- const ms = new MagicString(rawSource);
115
- const ropt = {
164
+ const traverseOptions = {
116
165
  StringLiteral: {
117
166
  enter(p) {
118
167
  var _a;
@@ -173,14 +222,33 @@ function jsHandler(rawSource, options) {
173
222
  }
174
223
  }
175
224
  };
176
- traverse(ast, ropt);
177
- const result = {
225
+ traverse(ast, traverseOptions);
226
+ return {
178
227
  code: ms.toString()
179
228
  };
180
- return result;
229
+ }
230
+ function jsHandlerAsync(rawSource, options) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ const ms = new MagicString(rawSource);
233
+ const js = yield getAstGrep();
234
+ let ast;
235
+ try {
236
+ const root = yield js.parseAsync(rawSource);
237
+ ast = root.root();
238
+ }
239
+ catch (_a) {
240
+ return {
241
+ code: rawSource
242
+ };
243
+ }
244
+ yield astGrepUpdateString(ast, options, ms);
245
+ return {
246
+ code: ms.toString()
247
+ };
248
+ });
181
249
  }
182
250
  function createJsHandler(options) {
183
- const { mangleContext, arbitraryValues, escapeMap, jsPreserveClass, generateMap } = options;
251
+ const { mangleContext, arbitraryValues, escapeMap, jsPreserveClass, generateMap, jsAstTool } = options;
184
252
  return (rawSource, set, options) => {
185
253
  const opts = defuOverrideArray(options, {
186
254
  classNameSet: set,
@@ -188,8 +256,12 @@ function createJsHandler(options) {
188
256
  arbitraryValues,
189
257
  mangleContext,
190
258
  jsPreserveClass,
191
- generateMap
259
+ generateMap,
260
+ jsAstTool
192
261
  });
262
+ if (opts.jsAstTool === 'ast-grep') {
263
+ return jsHandlerAsync(rawSource, opts);
264
+ }
193
265
  return jsHandler(rawSource, opts);
194
266
  };
195
267
  }
@@ -307,53 +379,63 @@ function isPropsMatch(props, attr) {
307
379
  }
308
380
  }
309
381
  function customTemplateHandler(rawSource, options) {
310
- const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler } = options !== null && options !== void 0 ? options : {};
311
- const s = new MagicString(rawSource);
312
- let tag = '';
313
- const parser = new Parser({
314
- onopentagname(name) {
315
- tag = name;
316
- },
317
- onattribute(name, value, quote) {
318
- if (value) {
319
- function update() {
320
- s.update(parser.startIndex + name.length + 2, parser.endIndex - 1, templateReplacer(value, Object.assign(Object.assign({}, options), { quote })));
321
- }
322
- if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class' || name === 'virtualHostClass' || name === 'virtualhostclass')) {
323
- update();
324
- }
325
- for (const [t, props] of customAttributesEntities) {
326
- if (t === '*') {
327
- if (isPropsMatch(props, name)) {
328
- update();
329
- }
382
+ return __awaiter(this, void 0, void 0, function* () {
383
+ const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler } = options !== null && options !== void 0 ? options : {};
384
+ const s = new MagicString(rawSource);
385
+ let tag = '';
386
+ const wxsArray = [];
387
+ const parser = new Parser({
388
+ onopentagname(name) {
389
+ tag = name;
390
+ },
391
+ onattribute(name, value, quote) {
392
+ if (value) {
393
+ function update() {
394
+ s.update(parser.startIndex + name.length + 2, parser.endIndex - 1, templateReplacer(value, Object.assign(Object.assign({}, options), { quote })));
330
395
  }
331
- else if (typeof t === 'string') {
332
- if (t === tag && isPropsMatch(props, name)) {
396
+ if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class' || name === 'virtualHostClass' || name === 'virtualhostclass')) {
397
+ update();
398
+ }
399
+ for (const [t, props] of customAttributesEntities) {
400
+ if (t === '*') {
401
+ if (isPropsMatch(props, name)) {
402
+ update();
403
+ }
404
+ }
405
+ else if (typeof t === 'string') {
406
+ if (t === tag && isPropsMatch(props, name)) {
407
+ update();
408
+ }
409
+ }
410
+ else if (regTest(t, tag) && isPropsMatch(props, name)) {
333
411
  update();
334
412
  }
335
413
  }
336
- else if (regTest(t, tag) && isPropsMatch(props, name)) {
337
- update();
338
- }
339
414
  }
415
+ },
416
+ ontext(data) {
417
+ if (inlineWxs && tag === 'wxs') {
418
+ wxsArray.push({
419
+ data,
420
+ endIndex: parser.endIndex + 1,
421
+ startIndex: parser.startIndex
422
+ });
423
+ }
424
+ },
425
+ onclosetag() {
426
+ tag = '';
340
427
  }
341
- },
342
- ontext(data) {
343
- if (inlineWxs && tag === 'wxs') {
344
- const code = jsHandler(data, runtimeSet).code;
345
- s.update(parser.startIndex, parser.endIndex + 1, code);
346
- }
347
- },
348
- onclosetag() {
349
- tag = '';
428
+ }, {
429
+ xmlMode: true
430
+ });
431
+ parser.write(s.original);
432
+ parser.end();
433
+ for (const { data, endIndex, startIndex } of wxsArray) {
434
+ const { code } = yield jsHandler(data, runtimeSet);
435
+ s.update(startIndex, endIndex, code);
350
436
  }
351
- }, {
352
- xmlMode: true
437
+ return s.toString();
353
438
  });
354
- parser.write(s.original);
355
- parser.end();
356
- return s.toString();
357
439
  }
358
440
  function createTemplateHandler(options = {}) {
359
441
  return (rawSource, opt = {}) => {
@@ -652,7 +734,7 @@ function getOptions(options = {}) {
652
734
  options.customReplaceDictionary = SimpleMappingChars2String;
653
735
  }
654
736
  const result = defuOverrideArray(options, defaultOptions, {});
655
- const { cssPreflight, customRuleCallback, cssPreflightRange, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler, cssSelectorReplacement, rem2rpx, cache } = result;
737
+ const { cssPreflight, customRuleCallback, cssPreflightRange, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler, cssSelectorReplacement, rem2rpx, cache, jsAstTool } = result;
656
738
  result.escapeMap = customReplaceDictionary;
657
739
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
658
740
  const customAttributesEntities = isMap(options.customAttributes)
@@ -678,7 +760,8 @@ function getOptions(options = {}) {
678
760
  mangleContext,
679
761
  arbitraryValues,
680
762
  jsPreserveClass,
681
- generateMap: true
763
+ generateMap: true,
764
+ jsAstTool
682
765
  });
683
766
  result.jsHandler = jsHandler;
684
767
  const templateHandler = createTemplateHandler({
package/dist/types.d.ts CHANGED
@@ -47,6 +47,8 @@ export type IJsHandlerOptions = {
47
47
  needEscaped?: boolean;
48
48
  generateMap?: boolean;
49
49
  always?: boolean;
50
+ jsAstTool?: 'babel' | 'ast-grep';
51
+ unescapeUnicode?: boolean;
50
52
  };
51
53
  export interface RawSource {
52
54
  start: number;
@@ -108,8 +110,9 @@ export interface UserDefinedOptions {
108
110
  tailwindcssBasedir?: string;
109
111
  rem2rpx?: boolean | rem2rpxOptions;
110
112
  cache?: boolean | ICreateCacheReturnType;
113
+ jsAstTool?: 'babel' | 'ast-grep';
111
114
  }
112
- export type JsHandler = (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult;
115
+ export type JsHandler = (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult | Promise<JsHandlerResult>;
113
116
  export interface IMangleScopeContext {
114
117
  rawOptions: UserDefinedOptions['mangle'];
115
118
  runtimeSet: Set<string>;
@@ -135,7 +138,7 @@ export interface ITemplateHandlerOptions extends ICommonReplaceOptions {
135
138
  }
136
139
  export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, 'supportCustomLengthUnitsPatch' | 'customReplaceDictionary' | 'cache'> & {
137
140
  supportCustomLengthUnitsPatch: ILengthUnitsPatchOptions | false;
138
- templateHandler: (rawSource: string, options?: ITemplateHandlerOptions) => string;
141
+ templateHandler: (rawSource: string, options?: ITemplateHandlerOptions) => Promise<string>;
139
142
  styleHandler: (rawSource: string, options: IStyleHandlerOptions) => Promise<string>;
140
143
  jsHandler: JsHandler;
141
144
  escapeMap: Record<string, string>;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var options = require('./options-Zf1-GLWG.js');
3
+ var options = require('./options-AIjWBFPo.js');
4
4
  var path = require('node:path');
5
5
  var fs = require('node:fs');
6
6
  var index = require('./index-CarwQa1I.js');
@@ -88,8 +88,8 @@ class UnifiedWebpackPluginV5 {
88
88
  else {
89
89
  return false;
90
90
  }
91
- }, () => {
92
- const wxml = templateHandler(rawSource, {
91
+ }, () => options.__awaiter(this, void 0, void 0, function* () {
92
+ const wxml = yield templateHandler(rawSource, {
93
93
  runtimeSet
94
94
  });
95
95
  const source = new ConcatSource(wxml);
@@ -101,7 +101,7 @@ class UnifiedWebpackPluginV5 {
101
101
  key: cacheKey,
102
102
  source
103
103
  };
104
- });
104
+ }));
105
105
  }
106
106
  debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
107
107
  }
@@ -119,11 +119,11 @@ class UnifiedWebpackPluginV5 {
119
119
  else {
120
120
  return false;
121
121
  }
122
- }, () => {
122
+ }, () => options.__awaiter(this, void 0, void 0, function* () {
123
123
  const rawSource = originalSource.source().toString();
124
124
  const mapFilename = file + '.map';
125
125
  const hasMap = Boolean(assets[mapFilename]);
126
- const { code, map } = jsHandler(rawSource, runtimeSet, {
126
+ const { code, map } = yield jsHandler(rawSource, runtimeSet, {
127
127
  generateMap: hasMap
128
128
  });
129
129
  const source = new ConcatSource(code);
@@ -139,7 +139,7 @@ class UnifiedWebpackPluginV5 {
139
139
  key: cacheKey,
140
140
  source
141
141
  };
142
- });
142
+ }));
143
143
  }
144
144
  debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
145
145
  }
@@ -1,4 +1,4 @@
1
- import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-D8LYG9j8.mjs';
1
+ import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-D6Mza941.mjs';
2
2
  import path from 'node:path';
3
3
  import fs from 'node:fs';
4
4
  import { b as pluginName } from './index-DKNUquoz.mjs';
@@ -81,8 +81,8 @@ class UnifiedWebpackPluginV5 {
81
81
  else {
82
82
  return false;
83
83
  }
84
- }, () => {
85
- const wxml = templateHandler(rawSource, {
84
+ }, () => __awaiter(this, void 0, void 0, function* () {
85
+ const wxml = yield templateHandler(rawSource, {
86
86
  runtimeSet
87
87
  });
88
88
  const source = new ConcatSource(wxml);
@@ -94,7 +94,7 @@ class UnifiedWebpackPluginV5 {
94
94
  key: cacheKey,
95
95
  source
96
96
  };
97
- });
97
+ }));
98
98
  }
99
99
  debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
100
100
  }
@@ -112,11 +112,11 @@ class UnifiedWebpackPluginV5 {
112
112
  else {
113
113
  return false;
114
114
  }
115
- }, () => {
115
+ }, () => __awaiter(this, void 0, void 0, function* () {
116
116
  const rawSource = originalSource.source().toString();
117
117
  const mapFilename = file + '.map';
118
118
  const hasMap = Boolean(assets[mapFilename]);
119
- const { code, map } = jsHandler(rawSource, runtimeSet, {
119
+ const { code, map } = yield jsHandler(rawSource, runtimeSet, {
120
120
  generateMap: hasMap
121
121
  });
122
122
  const source = new ConcatSource(code);
@@ -132,7 +132,7 @@ class UnifiedWebpackPluginV5 {
132
132
  key: cacheKey,
133
133
  source
134
134
  };
135
- });
135
+ }));
136
136
  }
137
137
  debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
138
138
  }
package/dist/vite.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-BgWX0vrB.js');
6
- require('./options-Zf1-GLWG.js');
5
+ var index = require('./index-jf-1m663.js');
6
+ require('./options-AIjWBFPo.js');
7
7
  require('magic-string');
8
8
  require('./replace.js');
9
9
  require('@weapp-core/escape');
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { U as UnifiedViteWeappTailwindcssPlugin } from './index-DG4lzarS.mjs';
2
- import './options-D8LYG9j8.mjs';
1
+ export { U as UnifiedViteWeappTailwindcssPlugin } from './index-BatBMY3C.mjs';
2
+ import './options-D6Mza941.mjs';
3
3
  import 'magic-string';
4
4
  import './replace.mjs';
5
5
  import '@weapp-core/escape';
package/dist/webpack.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var v5 = require('./v5-eVqDacrp.js');
6
- require('./options-Zf1-GLWG.js');
5
+ var v5 = require('./v5-BV64BMJS.js');
6
+ require('./options-AIjWBFPo.js');
7
7
  require('magic-string');
8
8
  require('./replace.js');
9
9
  require('@weapp-core/escape');
package/dist/webpack.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { U as UnifiedWebpackPluginV5 } from './v5-B8nkZNYC.mjs';
2
- import './options-D8LYG9j8.mjs';
1
+ export { U as UnifiedWebpackPluginV5 } from './v5-CH-EIloz.mjs';
2
+ import './options-D6Mza941.mjs';
3
3
  import 'magic-string';
4
4
  import './replace.mjs';
5
5
  import '@weapp-core/escape';
package/dist/webpack4.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-Zf1-GLWG.js');
5
+ var options = require('./options-AIjWBFPo.js');
6
6
  var path = require('node:path');
7
7
  var fs = require('node:fs');
8
8
  var webpackSources = require('webpack-sources');
@@ -110,8 +110,8 @@ class UnifiedWebpackPluginV4 {
110
110
  else {
111
111
  return false;
112
112
  }
113
- }, () => {
114
- const wxml = templateHandler(rawSource, {
113
+ }, () => options.__awaiter(this, void 0, void 0, function* () {
114
+ const wxml = yield templateHandler(rawSource, {
115
115
  runtimeSet
116
116
  });
117
117
  const source = new webpackSources.ConcatSource(wxml);
@@ -123,7 +123,7 @@ class UnifiedWebpackPluginV4 {
123
123
  key: cacheKey,
124
124
  source
125
125
  };
126
- });
126
+ }));
127
127
  }
128
128
  debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
129
129
  }
@@ -141,11 +141,11 @@ class UnifiedWebpackPluginV4 {
141
141
  else {
142
142
  return false;
143
143
  }
144
- }, () => {
144
+ }, () => options.__awaiter(this, void 0, void 0, function* () {
145
145
  const rawSource = originalSource.source().toString();
146
146
  const mapFilename = file + '.map';
147
147
  const hasMap = Boolean(assets[mapFilename]);
148
- const { code, map } = jsHandler(rawSource, runtimeSet, {
148
+ const { code, map } = yield jsHandler(rawSource, runtimeSet, {
149
149
  generateMap: hasMap
150
150
  });
151
151
  const source = new webpackSources.ConcatSource(code);
@@ -161,7 +161,7 @@ class UnifiedWebpackPluginV4 {
161
161
  key: cacheKey,
162
162
  source
163
163
  };
164
- });
164
+ }));
165
165
  }
166
166
  debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
167
167
  }
package/dist/webpack4.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-D8LYG9j8.mjs';
1
+ import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-D6Mza941.mjs';
2
2
  import path from 'node:path';
3
3
  import fs from 'node:fs';
4
4
  import { ConcatSource, RawSource } from 'webpack-sources';
@@ -101,8 +101,8 @@ class UnifiedWebpackPluginV4 {
101
101
  else {
102
102
  return false;
103
103
  }
104
- }, () => {
105
- const wxml = templateHandler(rawSource, {
104
+ }, () => __awaiter(this, void 0, void 0, function* () {
105
+ const wxml = yield templateHandler(rawSource, {
106
106
  runtimeSet
107
107
  });
108
108
  const source = new ConcatSource(wxml);
@@ -114,7 +114,7 @@ class UnifiedWebpackPluginV4 {
114
114
  key: cacheKey,
115
115
  source
116
116
  };
117
- });
117
+ }));
118
118
  }
119
119
  debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
120
120
  }
@@ -132,11 +132,11 @@ class UnifiedWebpackPluginV4 {
132
132
  else {
133
133
  return false;
134
134
  }
135
- }, () => {
135
+ }, () => __awaiter(this, void 0, void 0, function* () {
136
136
  const rawSource = originalSource.source().toString();
137
137
  const mapFilename = file + '.map';
138
138
  const hasMap = Boolean(assets[mapFilename]);
139
- const { code, map } = jsHandler(rawSource, runtimeSet, {
139
+ const { code, map } = yield jsHandler(rawSource, runtimeSet, {
140
140
  generateMap: hasMap
141
141
  });
142
142
  const source = new ConcatSource(code);
@@ -152,7 +152,7 @@ class UnifiedWebpackPluginV4 {
152
152
  key: cacheKey,
153
153
  source
154
154
  };
155
- });
155
+ }));
156
156
  }
157
157
  debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
158
158
  }
@@ -4,5 +4,5 @@ export declare function generateCode(match: string, options?: ITemplateHandlerOp
4
4
  export declare function extractSource(original: string): RawSource[];
5
5
  export declare function templateReplacer(original: string, options?: ITemplateHandlerOptions): string;
6
6
  export declare function isPropsMatch(props: ItemOrItemArray<string | RegExp>, attr: string): boolean;
7
- export declare function customTemplateHandler(rawSource: string, options: Required<ITemplateHandlerOptions>): string;
8
- export declare function createTemplateHandler(options?: Omit<ITemplateHandlerOptions, 'runtimeSet'>): (rawSource: string, opt?: Pick<ITemplateHandlerOptions, 'runtimeSet'>) => string;
7
+ export declare function customTemplateHandler(rawSource: string, options: Required<ITemplateHandlerOptions>): Promise<string>;
8
+ export declare function createTemplateHandler(options?: Omit<ITemplateHandlerOptions, 'runtimeSet'>): (rawSource: string, opt?: Pick<ITemplateHandlerOptions, 'runtimeSet'>) => Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "3.0.11",
3
+ "version": "3.1.0",
4
4
  "description": "把tailwindcss jit引擎,带给小程序开发者们! bring tailwindcss jit engine to miniprogram developers!",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -122,7 +122,8 @@
122
122
  },
123
123
  "homepage": "https://weapp-tw.icebreaker.top",
124
124
  "devDependencies": {
125
- "@babel/core": "^7.24.0",
125
+ "@ast-grep/napi": "^0.19.4",
126
+ "@babel/core": "^7.24.3",
126
127
  "@icebreakers/cli": "0.1.1",
127
128
  "@icebreakers/readme": "0.1.0",
128
129
  "@rollup/plugin-alias": "^5.1.0",
@@ -142,18 +143,18 @@
142
143
  "@types/js-beautify": "^1.14.3",
143
144
  "@types/klaw": "^3.0.6",
144
145
  "@types/loader-utils": "^2.0.6",
145
- "@types/lodash": "^4.14.202",
146
+ "@types/lodash": "^4.17.0",
146
147
  "@types/md5": "^2.3.5",
147
148
  "@types/micromatch": "^4.0.6",
148
- "@types/node": "^20.11.24",
149
+ "@types/node": "^20.11.30",
149
150
  "@types/semver": "^7.5.8",
150
151
  "@types/vinyl": "^2.0.11",
151
152
  "@types/webpack": "^5.28.5",
152
153
  "@types/webpack-sources": "^3.2.3",
153
154
  "@types/webpack4": "npm:@types/webpack@4",
154
- "@vitest/coverage-v8": "^1.3.1",
155
- "@vitest/ui": "^1.3.1",
156
- "autoprefixer": "^10.4.18",
155
+ "@vitest/coverage-v8": "^1.4.0",
156
+ "@vitest/ui": "^1.4.0",
157
+ "autoprefixer": "^10.4.19",
157
158
  "babel-loader": "^9.1.3",
158
159
  "bumpp": "^9.4.0",
159
160
  "colorette": "^2.0.20",
@@ -169,7 +170,7 @@
169
170
  "eslint-config-icebreaker": "^1.2.3",
170
171
  "eslint-config-prettier": "^9.1.0",
171
172
  "eslint-plugin-prettier": "^5.1.3",
172
- "execa": "^7.2.0",
173
+ "execa": "^8.0.1",
173
174
  "fast-glob": "^3.3.2",
174
175
  "fs-extra": "^11.2.0",
175
176
  "gulp": "^4.0.2",
@@ -185,29 +186,29 @@
185
186
  "postcss-loader": "^8.1.1",
186
187
  "prettier": "^3.2.5",
187
188
  "promisify-loader-runner": "^1.0.1",
188
- "rollup": "^4.12.0",
189
+ "rollup": "^4.13.0",
189
190
  "rollup-plugin-visualizer": "^5.12.0",
190
- "sass": "^1.71.1",
191
+ "sass": "^1.72.0",
191
192
  "style-loader": "^3.3.4",
192
193
  "tailwindcss": "^3.4.1",
193
194
  "ts-node": "^10.9.2",
194
195
  "ts-patch": "^3.1.2",
195
196
  "tsd": "^0.30.7",
196
197
  "tslib": "^2.6.2",
197
- "typescript": "^5.3.3",
198
+ "typescript": "^5.4.3",
198
199
  "typescript-transform-paths": "^3.4.7",
199
200
  "vinyl": "^3.0.0",
200
- "vite": "^5.1.5",
201
- "vitest": "^1.3.1",
201
+ "vite": "^5.2.2",
202
+ "vitest": "^1.4.0",
202
203
  "weapp-tailwindcss-children": "^0.1.0",
203
- "webpack": "^5.90.3",
204
+ "webpack": "^5.91.0",
204
205
  "webpack-build-utils": "^0.0.7"
205
206
  },
206
207
  "dependencies": {
207
208
  "@ast-core/escape": "^1.0.1",
208
- "@babel/generator": "7.23.6",
209
- "@babel/parser": "7.24.0",
210
- "@babel/traverse": "7.24.0",
209
+ "@babel/generator": "7.24.1",
210
+ "@babel/parser": "7.24.1",
211
+ "@babel/traverse": "7.24.1",
211
212
  "@babel/types": "7.24.0",
212
213
  "@csstools/postcss-is-pseudo-class": "4.0.5",
213
214
  "@tailwindcss-mangle/shared": "^2.2.2",
@@ -215,18 +216,21 @@
215
216
  "@weapp-core/regex": "^1.0.1",
216
217
  "debug": "4.3.4",
217
218
  "htmlparser2": "9.1.0",
218
- "loader-utils": "2.0.3",
219
+ "loader-utils": "2.0.4",
219
220
  "lru-cache": "10.2.0",
220
221
  "magic-string": "0.30.8",
221
222
  "md5": "2.3.0",
222
- "postcss": "8.4.35",
223
+ "postcss": "8.4.38",
223
224
  "postcss-rem-to-responsive-pixel": "^6.0.1",
224
- "postcss-selector-parser": "6.0.15",
225
+ "postcss-selector-parser": "6.0.16",
225
226
  "semver": "7.6.0",
226
227
  "tailwindcss-patch": "^2.2.3",
227
228
  "webpack-sources": "3.2.3"
228
229
  },
229
- "packageManager": "pnpm@8.10.2",
230
+ "optionalDependencies": {
231
+ "@ast-grep/napi": "^0.19.4"
232
+ },
233
+ "packageManager": "pnpm@8.15.4",
230
234
  "engines": {
231
235
  "node": ">=16.6.0"
232
236
  },
@@ -250,6 +254,7 @@
250
254
  "get-decl": "ts-node scripts/get-decl.ts",
251
255
  "demo:dev": "node scripts/demo/dev.js",
252
256
  "demo:build": "node scripts/demo/build.js",
257
+ "demo:bench": "node scripts/demo/bench.js",
253
258
  "demo:build:local": "node scripts/demo/build.js --local",
254
259
  "demo:link": "node scripts/demo/link.js",
255
260
  "demo:install": "node scripts/demo/install.js",