weapp-tailwindcss 2.7.0 → 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-7a4ffa6a.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-5a3070c1.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-7a4ffa6a.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-5a3070c1.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-7a4ffa6a.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-5a3070c1.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';
@@ -2,4 +2,4 @@ import type { StringLiteral, TemplateElement } from '@babel/types';
2
2
  import MagicString from 'magic-string';
3
3
  import type { IJsHandlerOptions } from "../types";
4
4
  export declare function regenerateHandleValue(str: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions): string;
5
- export declare function replaceHandleValue(str: string, node: StringLiteral | TemplateElement, options: IJsHandlerOptions, ms: MagicString, offset?: number): string;
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';
@@ -53,7 +54,7 @@ function regenerateHandleValue(str, node, options) {
53
54
  }
54
55
  return rawStr;
55
56
  }
56
- function replaceHandleValue(str, node, options, ms, offset = 1) {
57
+ function replaceHandleValue(str, node, options, ms, offset = 0, needEscaped = false) {
57
58
  var _a;
58
59
  const set = options.classNameSet;
59
60
  const escapeMap = options.escapeMap;
@@ -82,7 +83,7 @@ function replaceHandleValue(str, node, options, ms, offset = 1) {
82
83
  const start = node.start + offset;
83
84
  const end = node.end - offset;
84
85
  if (start < end) {
85
- ms.update(node.start + offset, node.end - offset, rawStr);
86
+ ms.update(start, end, needEscaped ? jsStringEscape(rawStr) : rawStr);
86
87
  }
87
88
  }
88
89
  return rawStr;
@@ -101,13 +102,13 @@ function jsHandler(rawSource, options) {
101
102
  StringLiteral: {
102
103
  enter(p) {
103
104
  const n = p.node;
104
- replaceHandleValue(n.value, n, options, ms);
105
+ replaceHandleValue(n.value, n, options, ms, 1, true);
105
106
  }
106
107
  },
107
108
  TemplateElement: {
108
109
  enter(p) {
109
110
  const n = p.node;
110
- replaceHandleValue(n.value.raw, n, options, ms, 0);
111
+ replaceHandleValue(n.value.raw, n, options, ms, 0, false);
111
112
  }
112
113
  },
113
114
  CallExpression: {
@@ -314,37 +315,77 @@ function templateReplacer(original, options = {}) {
314
315
  });
315
316
  }
316
317
  }
317
- function templateHandler(rawSource, options = {}) {
318
- if (options.disabledDefaultTemplateHandler) {
319
- return rawSource;
320
- }
321
- return rawSource.replace(tagWithEitherClassAndHoverClassRegexp, (m0) => {
322
- return m0.replace(templateClassExactRegexp, (m1, className) => {
323
- return m1.replace(className, templateReplacer(className, options));
324
- });
325
- });
318
+ function regTest(reg, str) {
319
+ reg.lastIndex = 0;
320
+ return reg.test(str);
326
321
  }
327
- function customTemplateHandler(rawSource, options) {
328
- const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
329
- let source = templateHandler(rawSource, options);
330
- const regexps = makeCustomAttributes(customAttributesEntities);
331
- if (regexps && Array.isArray(regexps)) {
332
- for (const regexp of regexps) {
333
- source = source.replace(regexp.tagRegexp, (m0) => {
334
- return m0.replace(regexp.attrRegexp, (m1, className) => {
335
- return m1.replace(className, templateReplacer(className, options));
336
- });
337
- });
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
+ }
338
329
  }
330
+ return false;
339
331
  }
340
- if (inlineWxs) {
341
- const wxsTags = extract(source, wxsTagRegexp);
342
- for (const x of wxsTags) {
343
- const code = jsHandler(x.raw, runtimeSet).code;
344
- source = source.replaceAll(x.raw, code);
345
- }
332
+ else if (typeof props === 'string') {
333
+ return props === attr;
334
+ }
335
+ else {
336
+ return regTest(props, attr);
346
337
  }
347
- return source;
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();
348
389
  }
349
390
  function createTemplateHandler(options = {}) {
350
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');
@@ -84,7 +85,7 @@ function regenerateHandleValue(str, node, options) {
84
85
  }
85
86
  return rawStr;
86
87
  }
87
- function replaceHandleValue(str, node, options, ms, offset = 1) {
88
+ function replaceHandleValue(str, node, options, ms, offset = 0, needEscaped = false) {
88
89
  var _a;
89
90
  const set = options.classNameSet;
90
91
  const escapeMap = options.escapeMap;
@@ -113,7 +114,7 @@ function replaceHandleValue(str, node, options, ms, offset = 1) {
113
114
  const start = node.start + offset;
114
115
  const end = node.end - offset;
115
116
  if (start < end) {
116
- ms.update(node.start + offset, node.end - offset, rawStr);
117
+ ms.update(start, end, needEscaped ? escape.jsStringEscape(rawStr) : rawStr);
117
118
  }
118
119
  }
119
120
  return rawStr;
@@ -132,13 +133,13 @@ function jsHandler(rawSource, options) {
132
133
  StringLiteral: {
133
134
  enter(p) {
134
135
  const n = p.node;
135
- replaceHandleValue(n.value, n, options, ms);
136
+ replaceHandleValue(n.value, n, options, ms, 1, true);
136
137
  }
137
138
  },
138
139
  TemplateElement: {
139
140
  enter(p) {
140
141
  const n = p.node;
141
- replaceHandleValue(n.value.raw, n, options, ms, 0);
142
+ replaceHandleValue(n.value.raw, n, options, ms, 0, false);
142
143
  }
143
144
  },
144
145
  CallExpression: {
@@ -345,37 +346,77 @@ function templateReplacer(original, options = {}) {
345
346
  });
346
347
  }
347
348
  }
348
- function templateHandler(rawSource, options = {}) {
349
- if (options.disabledDefaultTemplateHandler) {
350
- return rawSource;
351
- }
352
- return rawSource.replace(regex.tagWithEitherClassAndHoverClassRegexp, (m0) => {
353
- return m0.replace(regex.templateClassExactRegexp, (m1, className) => {
354
- return m1.replace(className, templateReplacer(className, options));
355
- });
356
- });
349
+ function regTest(reg, str) {
350
+ reg.lastIndex = 0;
351
+ return reg.test(str);
357
352
  }
358
- function customTemplateHandler(rawSource, options) {
359
- const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
360
- let source = templateHandler(rawSource, options);
361
- const regexps = regex.makeCustomAttributes(customAttributesEntities);
362
- if (regexps && Array.isArray(regexps)) {
363
- for (const regexp of regexps) {
364
- source = source.replace(regexp.tagRegexp, (m0) => {
365
- return m0.replace(regexp.attrRegexp, (m1, className) => {
366
- return m1.replace(className, templateReplacer(className, options));
367
- });
368
- });
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
+ }
369
360
  }
361
+ return false;
370
362
  }
371
- if (inlineWxs) {
372
- const wxsTags = extract(source, regex.wxsTagRegexp);
373
- for (const x of wxsTags) {
374
- const code = jsHandler(x.raw, runtimeSet).code;
375
- source = source.replaceAll(x.raw, code);
376
- }
363
+ else if (typeof props === 'string') {
364
+ return props === attr;
377
365
  }
378
- return source;
366
+ else {
367
+ return regTest(props, attr);
368
+ }
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();
379
420
  }
380
421
  function createTemplateHandler(options = {}) {
381
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-7a4ffa6a.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-5a3070c1.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-7a4ffa6a.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-5a3070c1.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.0",
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,22 @@
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"
200
+ },
201
+ "packageManager": "pnpm@8.6.12",
202
+ "engines": {
203
+ "node": ">=16.6.0"
198
204
  },
199
- "packageManager": "pnpm@8.6.9",
200
205
  "scripts": {
201
206
  "dev": "yarn clean && yarn dts && cross-env NODE_ENV=development rollup -c rollup.config.ts --configPlugin typescript -w",
202
207
  "build": "yarn clean && cross-env NODE_ENV=production rollup -c rollup.config.ts --configPlugin typescript && yarn dts",