weapp-tailwindcss 2.7.1 → 2.8.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.
package/README.md CHANGED
@@ -24,7 +24,7 @@
24
24
  > `小程序` + `tailwindcss` 全方面解决方案
25
25
  > 想试试在小程序里使用 `CSS-in-JS` 思想? 👉🏻👉🏻试试 [`weapp-pandacss`](https://github.com/sonofmagic/weapp-pandacss)
26
26
 
27
- \[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档]('./v1.md')\]
27
+ \[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档](./v1.md)\]
28
28
 
29
29
  - [Tips](#tips)
30
30
  - [特性](#特性)
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var options = require('./options-b7411c31.js');
3
+ var options = require('./options-7b804be0.js');
4
4
  require('micromatch');
5
5
  require('magic-string');
6
6
  require('./replace.js');
@@ -10,8 +10,9 @@ require('@weapp-core/regex');
10
10
  require('@babel/generator');
11
11
  require('@babel/parser');
12
12
  require('@babel/traverse');
13
- require('./defaults-344ba6d9.js');
13
+ require('./defaults-c6437917.js');
14
14
  require('@babel/types');
15
+ require('htmlparser2');
15
16
  require('postcss');
16
17
  require('./postcss-4e99a8e8.js');
17
18
  require('postcss-selector-parser');
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { g as getOptions, c as createPatch } from './options-8805cf56.mjs';
1
+ import { g as getOptions, c as createPatch } from './options-70759e98.mjs';
2
2
  import 'micromatch';
3
3
  import 'magic-string';
4
4
  import './replace.mjs';
@@ -8,8 +8,9 @@ import '@weapp-core/regex';
8
8
  import '@babel/generator';
9
9
  import '@babel/parser';
10
10
  import '@babel/traverse';
11
- import './defaults-0743f523.mjs';
11
+ import './defaults-72ea9566.mjs';
12
12
  import '@babel/types';
13
+ import 'htmlparser2';
13
14
  import 'postcss';
14
15
  import './postcss-a551ddc0.mjs';
15
16
  import 'postcss-selector-parser';
@@ -126,7 +126,7 @@ const defaultOptions = {
126
126
  return false;
127
127
  },
128
128
  disabledDefaultTemplateHandler: false,
129
- jsEscapeStrategy: 'regenerate'
129
+ jsEscapeStrategy: 'replace'
130
130
  };
131
131
 
132
132
  export { defaultOptions as d, getGroupedEntries as g, isMap as i, noop as n };
@@ -128,7 +128,7 @@ const defaultOptions = {
128
128
  return false;
129
129
  },
130
130
  disabledDefaultTemplateHandler: false,
131
- jsEscapeStrategy: 'regenerate'
131
+ jsEscapeStrategy: 'replace'
132
132
  };
133
133
 
134
134
  exports.defaultOptions = defaultOptions;
package/dist/defaults.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var defaults = require('./defaults-344ba6d9.js');
5
+ var defaults = require('./defaults-c6437917.js');
6
6
  require('@weapp-core/escape');
7
7
 
8
8
 
package/dist/defaults.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { d as defaultOptions } from './defaults-0743f523.mjs';
1
+ export { d as defaultOptions } from './defaults-72ea9566.mjs';
2
2
  import '@weapp-core/escape';
package/dist/gulp.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var stream = require('node:stream');
6
- var options = require('./options-b7411c31.js');
6
+ var options = require('./options-7b804be0.js');
7
7
  require('micromatch');
8
8
  require('magic-string');
9
9
  require('./replace.js');
@@ -13,8 +13,9 @@ require('@weapp-core/regex');
13
13
  require('@babel/generator');
14
14
  require('@babel/parser');
15
15
  require('@babel/traverse');
16
- require('./defaults-344ba6d9.js');
16
+ require('./defaults-c6437917.js');
17
17
  require('@babel/types');
18
+ require('htmlparser2');
18
19
  require('postcss');
19
20
  require('./postcss-4e99a8e8.js');
20
21
  require('postcss-selector-parser');
package/dist/gulp.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import stream from 'node:stream';
2
- import { g as getOptions, a as createTailwindcssPatcher } from './options-8805cf56.mjs';
2
+ import { g as getOptions, a as createTailwindcssPatcher } from './options-70759e98.mjs';
3
3
  import 'micromatch';
4
4
  import 'magic-string';
5
5
  import './replace.mjs';
@@ -9,8 +9,9 @@ import '@weapp-core/regex';
9
9
  import '@babel/generator';
10
10
  import '@babel/parser';
11
11
  import '@babel/traverse';
12
- import './defaults-0743f523.mjs';
12
+ import './defaults-72ea9566.mjs';
13
13
  import '@babel/types';
14
+ import 'htmlparser2';
14
15
  import 'postcss';
15
16
  import './postcss-a551ddc0.mjs';
16
17
  import 'postcss-selector-parser';
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var vite = require('./vite.js');
7
7
  var gulp = require('./gulp.js');
8
8
  require('node:path');
9
9
  require('node:fs');
10
- require('./options-b7411c31.js');
10
+ require('./options-7b804be0.js');
11
11
  require('micromatch');
12
12
  require('magic-string');
13
13
  require('./replace.js');
@@ -17,8 +17,9 @@ require('@weapp-core/regex');
17
17
  require('@babel/generator');
18
18
  require('@babel/parser');
19
19
  require('@babel/traverse');
20
- require('./defaults-344ba6d9.js');
20
+ require('./defaults-c6437917.js');
21
21
  require('@babel/types');
22
+ require('htmlparser2');
22
23
  require('postcss');
23
24
  require('./postcss-4e99a8e8.js');
24
25
  require('postcss-selector-parser');
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
3
3
  export { createPlugins } from './gulp.mjs';
4
4
  import 'node:path';
5
5
  import 'node:fs';
6
- import './options-8805cf56.mjs';
6
+ import './options-70759e98.mjs';
7
7
  import 'micromatch';
8
8
  import 'magic-string';
9
9
  import './replace.mjs';
@@ -13,8 +13,9 @@ import '@weapp-core/regex';
13
13
  import '@babel/generator';
14
14
  import '@babel/parser';
15
15
  import '@babel/traverse';
16
- import './defaults-0743f523.mjs';
16
+ import './defaults-72ea9566.mjs';
17
17
  import '@babel/types';
18
+ import 'htmlparser2';
18
19
  import 'postcss';
19
20
  import './postcss-a551ddc0.mjs';
20
21
  import 'postcss-selector-parser';
@@ -1,6 +1,5 @@
1
1
  import type { StringLiteral, TemplateElement } from '@babel/types';
2
2
  import MagicString from 'magic-string';
3
3
  import type { IJsHandlerOptions } from "../types";
4
- export declare function jsStringEscape(str: unknown): string;
5
4
  export declare function regenerateHandleValue(str: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions): string;
6
5
  export declare function replaceHandleValue(str: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions, ms: MagicString, offset?: number, needEscaped?: boolean): string;
@@ -1,16 +1,17 @@
1
1
  import { isMatch } from 'micromatch';
2
2
  import MagicString from 'magic-string';
3
3
  import { replaceJs as replaceWxml } from './replace.mjs';
4
- import { escapeStringRegexp, makeCustomAttributes, tagWithEitherClassAndHoverClassRegexp, templateClassExactRegexp, wxsTagRegexp, variableRegExp } from '@weapp-core/regex';
4
+ import { escapeStringRegexp, variableRegExp } from '@weapp-core/regex';
5
+ import { jsStringEscape, SimpleMappingChars2String, MappingChars2String } from '@weapp-core/escape';
5
6
  import generate from '@babel/generator';
6
7
  import { parse, parseExpression } from '@babel/parser';
7
8
  import traverse from '@babel/traverse';
8
- import { n as noop, d as defaultOptions, i as isMap } from './defaults-0743f523.mjs';
9
+ import { n as noop, d as defaultOptions, i as isMap } from './defaults-72ea9566.mjs';
9
10
  import * as t from '@babel/types';
11
+ import { Parser } from 'htmlparser2';
10
12
  import postcss from 'postcss';
11
13
  import { p as postcssWeappTailwindcss } from './postcss-a551ddc0.mjs';
12
14
  import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
13
- import { SimpleMappingChars2String, MappingChars2String } from '@weapp-core/escape';
14
15
  import path from 'node:path';
15
16
  import fs from 'node:fs';
16
17
  import { gte } from 'semver';
@@ -26,32 +27,6 @@ const splitCode = (code, allowDoubleQuotes = false) => {
26
27
  return code.split(splitter).filter((element) => isValidSelector(element));
27
28
  };
28
29
 
29
- function jsStringEscape(str) {
30
- return ('' + str).replaceAll(/[\n\r"'\\\u2028\u2029]/g, (character) => {
31
- switch (character) {
32
- case '"':
33
- case "'":
34
- case '\\': {
35
- return '\\' + character;
36
- }
37
- case '\n': {
38
- return '\\n';
39
- }
40
- case '\r': {
41
- return '\\r';
42
- }
43
- case '\u2028': {
44
- return '\\u2028';
45
- }
46
- case '\u2029': {
47
- return '\\u2029';
48
- }
49
- default: {
50
- return character;
51
- }
52
- }
53
- });
54
- }
55
30
  function regenerateHandleValue(str, node, options) {
56
31
  var _a;
57
32
  const set = options.classNameSet;
@@ -108,7 +83,7 @@ function replaceHandleValue(str, node, options, ms, offset = 0, needEscaped = fa
108
83
  const start = node.start + offset;
109
84
  const end = node.end - offset;
110
85
  if (start < end) {
111
- ms.update(node.start + offset, node.end - offset, needEscaped ? jsStringEscape(rawStr) : rawStr);
86
+ ms.update(start, end, needEscaped ? jsStringEscape(rawStr) : rawStr);
112
87
  }
113
88
  }
114
89
  return rawStr;
@@ -340,37 +315,77 @@ function templateReplacer(original, options = {}) {
340
315
  });
341
316
  }
342
317
  }
343
- function templateHandler(rawSource, options = {}) {
344
- if (options.disabledDefaultTemplateHandler) {
345
- return rawSource;
346
- }
347
- return rawSource.replace(tagWithEitherClassAndHoverClassRegexp, (m0) => {
348
- return m0.replace(templateClassExactRegexp, (m1, className) => {
349
- return m1.replace(className, templateReplacer(className, options));
350
- });
351
- });
318
+ function regTest(reg, str) {
319
+ reg.lastIndex = 0;
320
+ return reg.test(str);
352
321
  }
353
- function customTemplateHandler(rawSource, options) {
354
- const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
355
- let source = templateHandler(rawSource, options);
356
- const regexps = makeCustomAttributes(customAttributesEntities);
357
- if (regexps && Array.isArray(regexps)) {
358
- for (const regexp of regexps) {
359
- source = source.replace(regexp.tagRegexp, (m0) => {
360
- return m0.replace(regexp.attrRegexp, (m1, className) => {
361
- return m1.replace(className, templateReplacer(className, options));
362
- });
363
- });
322
+ function isPropsMatch(props, attr) {
323
+ if (Array.isArray(props)) {
324
+ for (const prop of props) {
325
+ const res = typeof prop === 'string' ? prop.toLowerCase() === attr : regTest(prop, attr);
326
+ if (res) {
327
+ return res;
328
+ }
364
329
  }
330
+ return false;
365
331
  }
366
- if (inlineWxs) {
367
- const wxsTags = extract(source, wxsTagRegexp);
368
- for (const x of wxsTags) {
369
- const code = jsHandler(x.raw, runtimeSet).code;
370
- source = source.replaceAll(x.raw, code);
371
- }
332
+ else if (typeof props === 'string') {
333
+ return props === attr;
372
334
  }
373
- return source;
335
+ else {
336
+ return regTest(props, attr);
337
+ }
338
+ }
339
+ function customTemplateHandler(rawSource, options) {
340
+ const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler } = options !== null && options !== void 0 ? options : {};
341
+ const s = new MagicString(rawSource);
342
+ let tag = '';
343
+ const parser = new Parser({
344
+ onopentagname(name) {
345
+ tag = name;
346
+ },
347
+ onattribute(name, value, quote) {
348
+ if (value) {
349
+ if (quote === "'") {
350
+ s.update(parser.startIndex + name.length + 1, parser.startIndex + name.length + 2, '"');
351
+ s.update(parser.startIndex + name.length + value.length + 2, parser.startIndex + name.length + value.length + 3, '"');
352
+ }
353
+ function update() {
354
+ s.update(parser.startIndex + name.length + 2, parser.endIndex, templateReplacer(value, options));
355
+ }
356
+ if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class')) {
357
+ update();
358
+ }
359
+ for (const [t, props] of customAttributesEntities) {
360
+ if (t === '*') {
361
+ if (isPropsMatch(props, name)) {
362
+ update();
363
+ }
364
+ }
365
+ else if (typeof t === 'string') {
366
+ if (t === tag && isPropsMatch(props, name)) {
367
+ update();
368
+ }
369
+ }
370
+ else if (regTest(t, tag) && isPropsMatch(props, name)) {
371
+ update();
372
+ }
373
+ }
374
+ }
375
+ },
376
+ ontext(data) {
377
+ if (inlineWxs && tag === 'wxs') {
378
+ const code = jsHandler(data, runtimeSet).code;
379
+ s.update(parser.startIndex, parser.endIndex + 1, code);
380
+ }
381
+ },
382
+ onclosetag() {
383
+ tag = '';
384
+ }
385
+ });
386
+ parser.write(s.original);
387
+ parser.end();
388
+ return s.toString();
374
389
  }
375
390
  function createTemplateHandler(options = {}) {
376
391
  return (rawSource, opt = {}) => {
@@ -4,15 +4,16 @@ var micromatch = require('micromatch');
4
4
  var MagicString = require('magic-string');
5
5
  var replace = require('./replace.js');
6
6
  var regex = require('@weapp-core/regex');
7
+ var escape = require('@weapp-core/escape');
7
8
  var generate = require('@babel/generator');
8
9
  var parser = require('@babel/parser');
9
10
  var traverse = require('@babel/traverse');
10
- var defaults = require('./defaults-344ba6d9.js');
11
+ var defaults = require('./defaults-c6437917.js');
11
12
  var t = require('@babel/types');
13
+ var htmlparser2 = require('htmlparser2');
12
14
  var postcss = require('postcss');
13
15
  var postcss$1 = require('./postcss-4e99a8e8.js');
14
16
  var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
15
- var escape = require('@weapp-core/escape');
16
17
  var path = require('node:path');
17
18
  var fs = require('node:fs');
18
19
  var semver = require('semver');
@@ -57,32 +58,6 @@ const splitCode = (code, allowDoubleQuotes = false) => {
57
58
  return code.split(splitter).filter((element) => isValidSelector(element));
58
59
  };
59
60
 
60
- function jsStringEscape(str) {
61
- return ('' + str).replaceAll(/[\n\r"'\\\u2028\u2029]/g, (character) => {
62
- switch (character) {
63
- case '"':
64
- case "'":
65
- case '\\': {
66
- return '\\' + character;
67
- }
68
- case '\n': {
69
- return '\\n';
70
- }
71
- case '\r': {
72
- return '\\r';
73
- }
74
- case '\u2028': {
75
- return '\\u2028';
76
- }
77
- case '\u2029': {
78
- return '\\u2029';
79
- }
80
- default: {
81
- return character;
82
- }
83
- }
84
- });
85
- }
86
61
  function regenerateHandleValue(str, node, options) {
87
62
  var _a;
88
63
  const set = options.classNameSet;
@@ -139,7 +114,7 @@ function replaceHandleValue(str, node, options, ms, offset = 0, needEscaped = fa
139
114
  const start = node.start + offset;
140
115
  const end = node.end - offset;
141
116
  if (start < end) {
142
- ms.update(node.start + offset, node.end - offset, needEscaped ? jsStringEscape(rawStr) : rawStr);
117
+ ms.update(start, end, needEscaped ? escape.jsStringEscape(rawStr) : rawStr);
143
118
  }
144
119
  }
145
120
  return rawStr;
@@ -371,37 +346,77 @@ function templateReplacer(original, options = {}) {
371
346
  });
372
347
  }
373
348
  }
374
- function templateHandler(rawSource, options = {}) {
375
- if (options.disabledDefaultTemplateHandler) {
376
- return rawSource;
377
- }
378
- return rawSource.replace(regex.tagWithEitherClassAndHoverClassRegexp, (m0) => {
379
- return m0.replace(regex.templateClassExactRegexp, (m1, className) => {
380
- return m1.replace(className, templateReplacer(className, options));
381
- });
382
- });
349
+ function regTest(reg, str) {
350
+ reg.lastIndex = 0;
351
+ return reg.test(str);
383
352
  }
384
- function customTemplateHandler(rawSource, options) {
385
- const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
386
- let source = templateHandler(rawSource, options);
387
- const regexps = regex.makeCustomAttributes(customAttributesEntities);
388
- if (regexps && Array.isArray(regexps)) {
389
- for (const regexp of regexps) {
390
- source = source.replace(regexp.tagRegexp, (m0) => {
391
- return m0.replace(regexp.attrRegexp, (m1, className) => {
392
- return m1.replace(className, templateReplacer(className, options));
393
- });
394
- });
353
+ function isPropsMatch(props, attr) {
354
+ if (Array.isArray(props)) {
355
+ for (const prop of props) {
356
+ const res = typeof prop === 'string' ? prop.toLowerCase() === attr : regTest(prop, attr);
357
+ if (res) {
358
+ return res;
359
+ }
395
360
  }
361
+ return false;
396
362
  }
397
- if (inlineWxs) {
398
- const wxsTags = extract(source, regex.wxsTagRegexp);
399
- for (const x of wxsTags) {
400
- const code = jsHandler(x.raw, runtimeSet).code;
401
- source = source.replaceAll(x.raw, code);
402
- }
363
+ else if (typeof props === 'string') {
364
+ return props === attr;
365
+ }
366
+ else {
367
+ return regTest(props, attr);
403
368
  }
404
- return source;
369
+ }
370
+ function customTemplateHandler(rawSource, options) {
371
+ const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler } = options !== null && options !== void 0 ? options : {};
372
+ const s = new MagicString__default["default"](rawSource);
373
+ let tag = '';
374
+ const parser = new htmlparser2.Parser({
375
+ onopentagname(name) {
376
+ tag = name;
377
+ },
378
+ onattribute(name, value, quote) {
379
+ if (value) {
380
+ if (quote === "'") {
381
+ s.update(parser.startIndex + name.length + 1, parser.startIndex + name.length + 2, '"');
382
+ s.update(parser.startIndex + name.length + value.length + 2, parser.startIndex + name.length + value.length + 3, '"');
383
+ }
384
+ function update() {
385
+ s.update(parser.startIndex + name.length + 2, parser.endIndex, templateReplacer(value, options));
386
+ }
387
+ if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class')) {
388
+ update();
389
+ }
390
+ for (const [t, props] of customAttributesEntities) {
391
+ if (t === '*') {
392
+ if (isPropsMatch(props, name)) {
393
+ update();
394
+ }
395
+ }
396
+ else if (typeof t === 'string') {
397
+ if (t === tag && isPropsMatch(props, name)) {
398
+ update();
399
+ }
400
+ }
401
+ else if (regTest(t, tag) && isPropsMatch(props, name)) {
402
+ update();
403
+ }
404
+ }
405
+ }
406
+ },
407
+ ontext(data) {
408
+ if (inlineWxs && tag === 'wxs') {
409
+ const code = jsHandler(data, runtimeSet).code;
410
+ s.update(parser.startIndex, parser.endIndex + 1, code);
411
+ }
412
+ },
413
+ onclosetag() {
414
+ tag = '';
415
+ }
416
+ });
417
+ parser.write(s.original);
418
+ parser.end();
419
+ return s.toString();
405
420
  }
406
421
  function createTemplateHandler(options = {}) {
407
422
  return (rawSource, opt = {}) => {
package/dist/vite.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-b7411c31.js');
5
+ var options = require('./options-7b804be0.js');
6
6
  var postcss = require('./postcss-4e99a8e8.js');
7
- var defaults = require('./defaults-344ba6d9.js');
7
+ var defaults = require('./defaults-c6437917.js');
8
8
  require('micromatch');
9
9
  require('magic-string');
10
10
  require('./replace.js');
@@ -15,6 +15,7 @@ require('@babel/generator');
15
15
  require('@babel/parser');
16
16
  require('@babel/traverse');
17
17
  require('@babel/types');
18
+ require('htmlparser2');
18
19
  require('postcss');
19
20
  require('@csstools/postcss-is-pseudo-class');
20
21
  require('node:path');
@@ -39,10 +40,8 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
39
40
  return {
40
41
  name: postcss.vitePluginName,
41
42
  enforce: 'post',
42
- buildStart() {
43
+ generateBundle(opt, bundle) {
43
44
  onStart();
44
- },
45
- generateBundle(opt, bundle, isWrite) {
46
45
  const entries = Object.entries(bundle);
47
46
  const groupedEntries = defaults.getGroupedEntries(entries, opts);
48
47
  const runtimeSet = twPatcher.getClassSet();
@@ -77,8 +76,6 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
77
76
  onUpdate(file, rawSource, code);
78
77
  }
79
78
  }
80
- },
81
- buildEnd() {
82
79
  onEnd();
83
80
  }
84
81
  };
package/dist/vite.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { g as getOptions, a as createTailwindcssPatcher } from './options-8805cf56.mjs';
1
+ import { g as getOptions, a as createTailwindcssPatcher } from './options-70759e98.mjs';
2
2
  import { v as vitePluginName } from './postcss-a551ddc0.mjs';
3
- import { g as getGroupedEntries } from './defaults-0743f523.mjs';
3
+ import { g as getGroupedEntries } from './defaults-72ea9566.mjs';
4
4
  import 'micromatch';
5
5
  import 'magic-string';
6
6
  import './replace.mjs';
@@ -11,6 +11,7 @@ import '@babel/generator';
11
11
  import '@babel/parser';
12
12
  import '@babel/traverse';
13
13
  import '@babel/types';
14
+ import 'htmlparser2';
14
15
  import 'postcss';
15
16
  import '@csstools/postcss-is-pseudo-class';
16
17
  import 'node:path';
@@ -35,10 +36,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
35
36
  return {
36
37
  name: vitePluginName,
37
38
  enforce: 'post',
38
- buildStart() {
39
+ generateBundle(opt, bundle) {
39
40
  onStart();
40
- },
41
- generateBundle(opt, bundle, isWrite) {
42
41
  const entries = Object.entries(bundle);
43
42
  const groupedEntries = getGroupedEntries(entries, opts);
44
43
  const runtimeSet = twPatcher.getClassSet();
@@ -73,8 +72,6 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
73
72
  onUpdate(file, rawSource, code);
74
73
  }
75
74
  }
76
- },
77
- buildEnd() {
78
75
  onEnd();
79
76
  }
80
77
  };
package/dist/webpack.js CHANGED
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var path = require('node:path');
6
6
  var fs = require('node:fs');
7
- var options = require('./options-b7411c31.js');
7
+ var options = require('./options-7b804be0.js');
8
8
  var postcss = require('./postcss-4e99a8e8.js');
9
- var defaults = require('./defaults-344ba6d9.js');
9
+ var defaults = require('./defaults-c6437917.js');
10
10
  require('micromatch');
11
11
  require('magic-string');
12
12
  require('./replace.js');
@@ -17,6 +17,7 @@ require('@babel/generator');
17
17
  require('@babel/parser');
18
18
  require('@babel/traverse');
19
19
  require('@babel/types');
20
+ require('htmlparser2');
20
21
  require('postcss');
21
22
  require('@csstools/postcss-is-pseudo-class');
22
23
  require('semver');
package/dist/webpack.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import path from 'node:path';
2
2
  import fs from 'node:fs';
3
- import { g as getOptions, a as createTailwindcssPatcher } from './options-8805cf56.mjs';
3
+ import { g as getOptions, a as createTailwindcssPatcher } from './options-70759e98.mjs';
4
4
  import { a as pluginName } from './postcss-a551ddc0.mjs';
5
- import { g as getGroupedEntries } from './defaults-0743f523.mjs';
5
+ import { g as getGroupedEntries } from './defaults-72ea9566.mjs';
6
6
  import 'micromatch';
7
7
  import 'magic-string';
8
8
  import './replace.mjs';
@@ -13,6 +13,7 @@ import '@babel/generator';
13
13
  import '@babel/parser';
14
14
  import '@babel/traverse';
15
15
  import '@babel/types';
16
+ import 'htmlparser2';
16
17
  import 'postcss';
17
18
  import '@csstools/postcss-is-pseudo-class';
18
19
  import 'semver';
@@ -1,2 +1,2 @@
1
1
  export { replaceWxml } from './shared';
2
- export { generateCode, templateHandler, templateReplacer, customTemplateHandler, createTemplateHandler, extractSource } from './utils';
2
+ export { generateCode, templateReplacer, customTemplateHandler, createTemplateHandler, extractSource } from './utils';
@@ -1,7 +1,8 @@
1
+ import { ItemOrItemArray } from "../reg";
1
2
  import type { RawSource, ITemplateHandlerOptions } from "../types";
2
3
  export declare function generateCode(match: string, options?: ITemplateHandlerOptions): string;
3
4
  export declare function extractSource(original: string): RawSource[];
4
5
  export declare function templateReplacer(original: string, options?: ITemplateHandlerOptions): string;
5
- export declare function templateHandler(rawSource: string, options?: ITemplateHandlerOptions): string;
6
+ export declare function isPropsMatch(props: ItemOrItemArray<string | RegExp>, attr: string): boolean;
6
7
  export declare function customTemplateHandler(rawSource: string, options: Required<ITemplateHandlerOptions>): string;
7
8
  export declare function createTemplateHandler(options?: Omit<ITemplateHandlerOptions, 'runtimeSet'>): (rawSource: string, opt?: Pick<ITemplateHandlerOptions, 'runtimeSet'>) => string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "2.7.1",
4
- "description": "把tailwindcss jit引擎,带给小程序开发者们\nbring tailwindcss jit engine to our miniprogram developers!",
3
+ "version": "2.8.0",
4
+ "description": "把tailwindcss jit引擎,带给小程序开发者们! bring tailwindcss jit engine to miniprogram developers!",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -106,7 +106,7 @@
106
106
  "@icebreakers/cli": "0.1.1",
107
107
  "@icebreakers/readme": "0.1.0",
108
108
  "@rollup/plugin-alias": "^5.0.0",
109
- "@rollup/plugin-commonjs": "^25.0.3",
109
+ "@rollup/plugin-commonjs": "^25.0.4",
110
110
  "@rollup/plugin-json": "^6.0.0",
111
111
  "@rollup/plugin-node-resolve": "^15.1.0",
112
112
  "@rollup/plugin-terser": "^0.4.3",
@@ -123,13 +123,13 @@
123
123
  "@types/loader-utils": "^2.0.3",
124
124
  "@types/lodash": "^4.14.197",
125
125
  "@types/micromatch": "^4.0.2",
126
- "@types/node": "^20.4.9",
126
+ "@types/node": "^20.5.0",
127
127
  "@types/semver": "^7.5.0",
128
128
  "@types/vinyl": "^2.0.7",
129
129
  "@types/webpack": "^5.28.1",
130
130
  "@types/webpack-sources": "^3.2.0",
131
131
  "@vitest/coverage-v8": "^0.34.1",
132
- "autoprefixer": "^10.4.14",
132
+ "autoprefixer": "^10.4.15",
133
133
  "babel-loader": "^9.1.3",
134
134
  "bumpp": "^9.1.1",
135
135
  "colorette": "^2.0.20",
@@ -138,7 +138,7 @@
138
138
  "dedent": "^1.5.1",
139
139
  "defu": "6.1.2",
140
140
  "del": "^7.0.0",
141
- "eslint": "8.46.0",
141
+ "eslint": "8.47.0",
142
142
  "eslint-config-icebreaker": "^1.2.2",
143
143
  "eslint-config-prettier": "^9.0.0",
144
144
  "eslint-plugin-prettier": "^5.0.0",
@@ -177,7 +177,8 @@
177
177
  "vitest": "^0.34.1",
178
178
  "weapp-tailwindcss-children": "^0.1.0",
179
179
  "webpack": "^5.88.2",
180
- "webpack-build-utils": "^0.0.4"
180
+ "webpack-build-utils": "^0.0.4",
181
+ "domhandler": "^5.0.3"
181
182
  },
182
183
  "dependencies": {
183
184
  "@babel/generator": "^7.22.10",
@@ -185,18 +186,19 @@
185
186
  "@babel/traverse": "^7.22.10",
186
187
  "@babel/types": "^7.22.10",
187
188
  "@csstools/postcss-is-pseudo-class": "^4.0.0",
188
- "@tailwindcss-mangle/shared": "^2.0.4",
189
- "@weapp-core/escape": "^1.0.0",
189
+ "@tailwindcss-mangle/shared": "^2.1.0",
190
+ "@weapp-core/escape": "^1.1.0",
190
191
  "@weapp-core/regex": "^1.0.0",
192
+ "htmlparser2": "^9.0.0",
191
193
  "loader-utils": "^2.0.3",
192
194
  "magic-string": "^0.30.2",
193
195
  "micromatch": "^4.0.5",
194
196
  "postcss": "8.4.27",
195
197
  "postcss-selector-parser": "^6.0.13",
196
198
  "semver": "^7.5.4",
197
- "tailwindcss-patch": "^2.0.4"
199
+ "tailwindcss-patch": "^2.1.0"
198
200
  },
199
- "packageManager": "pnpm@8.6.11",
201
+ "packageManager": "pnpm@8.6.12",
200
202
  "engines": {
201
203
  "node": ">=16.6.0"
202
204
  },