weapp-tailwindcss 2.4.2 → 2.4.4

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
@@ -20,16 +20,16 @@
20
20
  </a>
21
21
  <br> -->
22
22
 
23
- ![star](https://badgen.net/github/stars/sonofmagic/weapp-tailwindcss-webpack-plugin)
23
+ ![star](https://badgen.net/github/stars/sonofmagic/weapp-tailwindcss)
24
24
  ![dm0](https://badgen.net/npm/dm/weapp-tailwindcss)
25
25
  ![dm1](https://badgen.net/npm/dm/weapp-tailwindcss-webpack-plugin)
26
- ![license](https://badgen.net/npm/license/weapp-tailwindcss-webpack-plugin)
27
- [![test](https://github.com/sonofmagic/weapp-tailwindcss-webpack-plugin/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sonofmagic/weapp-tailwindcss-webpack-plugin/actions/workflows/test.yml)
28
- [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss-webpack-plugin/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss-webpack-plugin)
26
+ ![license](https://badgen.net/npm/license/weapp-tailwindcss)
27
+ [![test](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml)
28
+ [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
29
29
 
30
30
  > `小程序` + `tailwindcss` 全方面解决方案
31
31
 
32
- \[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss-webpack-plugin/)\] \| \[[1.x文档]('./v1.md')\]
32
+ \[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档]('./v1.md')\]
33
33
 
34
34
  - [Tips](#tips)
35
35
  - [特性](#特性)
@@ -122,7 +122,7 @@
122
122
 
123
123
  #### 原生小程序开发模板
124
124
 
125
- [weapp-tailwindcss-gulp-template(gulp打包)](https://github.com/sonofmagic/weapp-tailwindcss-webpack-plugin/tree/main/demo/gulp-app)
125
+ [weapp-tailwindcss-gulp-template(gulp打包)](https://github.com/sonofmagic/weapp-tailwindcss/tree/main/demo/gulp-app)
126
126
 
127
127
  [weapp-native-mina-tailwindcss-template(webpack打包)](https://github.com/sonofmagic/weapp-native-mina-tailwindcss-template)
128
128
 
@@ -138,4 +138,4 @@
138
138
 
139
139
  目前这个插件正在快速的开发中,如果遇到 `Bug` 或者想提出 `Issue`
140
140
 
141
- [欢迎提交到此处](https://github.com/sonofmagic/weapp-tailwindcss-webpack-plugin/issues)
141
+ [欢迎提交到此处](https://github.com/sonofmagic/weapp-tailwindcss/issues)
package/dist/cli.js CHANGED
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var options = require('./options-3a20e9d4.js');
3
+ var options = require('./options-887b74ca.js');
4
4
  require('micromatch');
5
5
  require('@babel/types');
6
6
  require('@babel/generator');
7
7
  require('@babel/parser');
8
8
  require('@babel/traverse');
9
9
  require('./replace.js');
10
- require('./shared-28d43730.js');
10
+ require('./shared-ae7dd073.js');
11
11
  require('postcss');
12
- require('./postcss-e0e5739b.js');
12
+ require('./postcss-33ef0bd0.js');
13
13
  require('postcss-selector-parser');
14
14
  require('@csstools/postcss-is-pseudo-class');
15
15
  require('node:path');
package/dist/cli.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { g as getOptions, c as createPatch } from './options-2a6f14b8.mjs';
1
+ import { g as getOptions, c as createPatch } from './options-879de0a2.mjs';
2
2
  import 'micromatch';
3
3
  import '@babel/types';
4
4
  import '@babel/generator';
5
5
  import '@babel/parser';
6
6
  import '@babel/traverse';
7
7
  import './replace.mjs';
8
- import './shared-31001503.mjs';
8
+ import './shared-7c88fb94.mjs';
9
9
  import 'postcss';
10
- import './postcss-b4e0e1ac.mjs';
10
+ import './postcss-ea625621.mjs';
11
11
  import 'postcss-selector-parser';
12
12
  import '@csstools/postcss-is-pseudo-class';
13
13
  import 'node:path';
package/dist/gulp.js CHANGED
@@ -3,16 +3,16 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var stream = require('node:stream');
6
- var options = require('./options-3a20e9d4.js');
6
+ var options = require('./options-887b74ca.js');
7
7
  require('micromatch');
8
8
  require('@babel/types');
9
9
  require('@babel/generator');
10
10
  require('@babel/parser');
11
11
  require('@babel/traverse');
12
12
  require('./replace.js');
13
- require('./shared-28d43730.js');
13
+ require('./shared-ae7dd073.js');
14
14
  require('postcss');
15
- require('./postcss-e0e5739b.js');
15
+ require('./postcss-33ef0bd0.js');
16
16
  require('postcss-selector-parser');
17
17
  require('@csstools/postcss-is-pseudo-class');
18
18
  require('node:path');
package/dist/gulp.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import stream from 'node:stream';
2
- import { g as getOptions, a as createTailwindcssPatcher } from './options-2a6f14b8.mjs';
2
+ import { g as getOptions, a as createTailwindcssPatcher } from './options-879de0a2.mjs';
3
3
  import 'micromatch';
4
4
  import '@babel/types';
5
5
  import '@babel/generator';
6
6
  import '@babel/parser';
7
7
  import '@babel/traverse';
8
8
  import './replace.mjs';
9
- import './shared-31001503.mjs';
9
+ import './shared-7c88fb94.mjs';
10
10
  import 'postcss';
11
- import './postcss-b4e0e1ac.mjs';
11
+ import './postcss-ea625621.mjs';
12
12
  import 'postcss-selector-parser';
13
13
  import '@csstools/postcss-is-pseudo-class';
14
14
  import 'node:path';
package/dist/index.js CHANGED
@@ -5,16 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var webpack = require('./webpack.js');
6
6
  var vite = require('./vite.js');
7
7
  var gulp = require('./gulp.js');
8
- require('./options-3a20e9d4.js');
8
+ require('./options-887b74ca.js');
9
9
  require('micromatch');
10
10
  require('@babel/types');
11
11
  require('@babel/generator');
12
12
  require('@babel/parser');
13
13
  require('@babel/traverse');
14
14
  require('./replace.js');
15
- require('./shared-28d43730.js');
15
+ require('./shared-ae7dd073.js');
16
16
  require('postcss');
17
- require('./postcss-e0e5739b.js');
17
+ require('./postcss-33ef0bd0.js');
18
18
  require('postcss-selector-parser');
19
19
  require('@csstools/postcss-is-pseudo-class');
20
20
  require('node:path');
package/dist/index.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  export { UnifiedWebpackPluginV5 } from './webpack.mjs';
2
2
  export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
3
3
  export { createPlugins } from './gulp.mjs';
4
- import './options-2a6f14b8.mjs';
4
+ import './options-879de0a2.mjs';
5
5
  import 'micromatch';
6
6
  import '@babel/types';
7
7
  import '@babel/generator';
8
8
  import '@babel/parser';
9
9
  import '@babel/traverse';
10
10
  import './replace.mjs';
11
- import './shared-31001503.mjs';
11
+ import './shared-7c88fb94.mjs';
12
12
  import 'postcss';
13
- import './postcss-b4e0e1ac.mjs';
13
+ import './postcss-ea625621.mjs';
14
14
  import 'postcss-selector-parser';
15
15
  import '@csstools/postcss-is-pseudo-class';
16
16
  import 'node:path';
@@ -4,9 +4,9 @@ import generate from '@babel/generator';
4
4
  import { parse, parseExpression } from '@babel/parser';
5
5
  import traverse from '@babel/traverse';
6
6
  import { replaceJs as replaceWxml } from './replace.mjs';
7
- import { S as SimpleMappingChars2String, M as MappingChars2String } from './shared-31001503.mjs';
7
+ import { S as SimpleMappingChars2String, M as MappingChars2String } from './shared-7c88fb94.mjs';
8
8
  import postcss from 'postcss';
9
- import { p as postcssWeappTailwindcss } from './postcss-b4e0e1ac.mjs';
9
+ import { p as postcssWeappTailwindcss } from './postcss-ea625621.mjs';
10
10
  import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
11
11
  import path from 'node:path';
12
12
  import fs from 'node:fs';
@@ -339,7 +339,8 @@ const defaultOptions = {
339
339
  appType: undefined,
340
340
  arbitraryValues: {
341
341
  allowDoubleQuotes: false
342
- }
342
+ },
343
+ cssChildCombinatorReplaceValue: 'view + view'
343
344
  };
344
345
 
345
346
  function generateCode(match, options = {}) {
@@ -417,10 +418,7 @@ function templeteReplacer(original, options = {}) {
417
418
  }));
418
419
  }
419
420
  }
420
- return resultArray
421
- .filter(Boolean)
422
- .join('')
423
- .trim();
421
+ return resultArray.filter(Boolean).join('').trim();
424
422
  }
425
423
  else {
426
424
  return replaceWxml(original, {
@@ -697,17 +695,19 @@ function getOptions(options = {}) {
697
695
  const result = defu(options, defaultOptions, {
698
696
  minifiedJs: isProd()
699
697
  });
700
- const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues } = result;
698
+ const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue } = result;
701
699
  result.escapeMap = customReplaceDictionary;
702
700
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
703
- const customAttributesEntities = isMap(options.customAttributes) ? [...options.customAttributes.entries()] : Object.entries(customAttributes);
701
+ const customAttributesEntities = isMap(options.customAttributes)
702
+ ? [...options.customAttributes.entries()]
703
+ : Object.entries(customAttributes);
704
704
  const { escapeMap, minifiedJs } = result;
705
705
  const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
706
706
  initMangle(options.mangle);
707
707
  result.templeteHandler = createTempleteHandler({
708
708
  customAttributesEntities,
709
709
  escapeMap,
710
- mangleContext,
710
+ mangleContext
711
711
  });
712
712
  result.styleHandler = createStyleHandler({
713
713
  cssInjectPreflight,
@@ -716,6 +716,7 @@ function getOptions(options = {}) {
716
716
  replaceUniversalSelectorWith,
717
717
  escapeMap,
718
718
  mangleContext,
719
+ cssChildCombinatorReplaceValue
719
720
  });
720
721
  result.jsHandler = createjsHandler({
721
722
  minifiedJs,
@@ -6,9 +6,9 @@ var generate = require('@babel/generator');
6
6
  var parser = require('@babel/parser');
7
7
  var traverse = require('@babel/traverse');
8
8
  var replace = require('./replace.js');
9
- var shared = require('./shared-28d43730.js');
9
+ var shared = require('./shared-ae7dd073.js');
10
10
  var postcss = require('postcss');
11
- var postcss$1 = require('./postcss-e0e5739b.js');
11
+ var postcss$1 = require('./postcss-33ef0bd0.js');
12
12
  var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
13
13
  var path = require('node:path');
14
14
  var fs = require('node:fs');
@@ -369,7 +369,8 @@ const defaultOptions = {
369
369
  appType: undefined,
370
370
  arbitraryValues: {
371
371
  allowDoubleQuotes: false
372
- }
372
+ },
373
+ cssChildCombinatorReplaceValue: 'view + view'
373
374
  };
374
375
 
375
376
  function generateCode(match, options = {}) {
@@ -447,10 +448,7 @@ function templeteReplacer(original, options = {}) {
447
448
  }));
448
449
  }
449
450
  }
450
- return resultArray
451
- .filter(Boolean)
452
- .join('')
453
- .trim();
451
+ return resultArray.filter(Boolean).join('').trim();
454
452
  }
455
453
  else {
456
454
  return replace.replaceJs(original, {
@@ -727,17 +725,19 @@ function getOptions(options = {}) {
727
725
  const result = defu(options, defaultOptions, {
728
726
  minifiedJs: isProd()
729
727
  });
730
- const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues } = result;
728
+ const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue } = result;
731
729
  result.escapeMap = customReplaceDictionary;
732
730
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
733
- const customAttributesEntities = isMap(options.customAttributes) ? [...options.customAttributes.entries()] : Object.entries(customAttributes);
731
+ const customAttributesEntities = isMap(options.customAttributes)
732
+ ? [...options.customAttributes.entries()]
733
+ : Object.entries(customAttributes);
734
734
  const { escapeMap, minifiedJs } = result;
735
735
  const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
736
736
  initMangle(options.mangle);
737
737
  result.templeteHandler = createTempleteHandler({
738
738
  customAttributesEntities,
739
739
  escapeMap,
740
- mangleContext,
740
+ mangleContext
741
741
  });
742
742
  result.styleHandler = createStyleHandler({
743
743
  cssInjectPreflight,
@@ -746,6 +746,7 @@ function getOptions(options = {}) {
746
746
  replaceUniversalSelectorWith,
747
747
  escapeMap,
748
748
  mangleContext,
749
+ cssChildCombinatorReplaceValue
749
750
  });
750
751
  result.jsHandler = createjsHandler({
751
752
  minifiedJs,
@@ -1,3 +1,3 @@
1
1
  import type { IStyleHandlerOptions } from "../types";
2
2
  export declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): string;
3
- export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt: IStyleHandlerOptions) => string;
3
+ export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => string;
@@ -2,5 +2,5 @@ import type { PluginCreator } from 'postcss';
2
2
  import type { IStyleHandlerOptions } from "../types";
3
3
  export type PostcssWeappTailwindcssRenamePlugin = PluginCreator<IStyleHandlerOptions>;
4
4
  declare const postcssWeappTailwindcss: PostcssWeappTailwindcssRenamePlugin;
5
- export { postcssWeappTailwindcss, };
5
+ export { postcssWeappTailwindcss };
6
6
  export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
@@ -1,2 +1,3 @@
1
1
  import { InternalCssSelectorReplacerOptions } from "../types";
2
2
  export declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
3
+ export declare const cssUnescape: (str: string) => string;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var selectorParser = require('postcss-selector-parser');
4
- var shared = require('./shared-28d43730.js');
4
+ var shared = require('./shared-ae7dd073.js');
5
5
  var postcss = require('postcss');
6
6
  require('@csstools/postcss-is-pseudo-class');
7
7
 
@@ -63,7 +63,15 @@ function testIfVariablesScope(node, count = 1) {
63
63
  return false;
64
64
  }
65
65
  function commonChunkPreflight(node, options) {
66
- node.selector = node.selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, 'view + view');
66
+ let childCombinatorReplaceValue = 'view + view';
67
+ if (Array.isArray(options.cssChildCombinatorReplaceValue)) {
68
+ const part = options.cssChildCombinatorReplaceValue.join(',');
69
+ childCombinatorReplaceValue = [part, ' + ', part].join('');
70
+ }
71
+ else if (typeof options.cssChildCombinatorReplaceValue === 'string') {
72
+ childCombinatorReplaceValue = options.cssChildCombinatorReplaceValue;
73
+ }
74
+ node.selector = node.selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
67
75
  if (testIfVariablesScope(node)) {
68
76
  const selectorParts = node.selector.split(',');
69
77
  if (!selectorParts.includes('view')) {
@@ -1,5 +1,5 @@
1
1
  import selectorParser from 'postcss-selector-parser';
2
- import { i as internalCssSelectorReplacer } from './shared-31001503.mjs';
2
+ import { i as internalCssSelectorReplacer } from './shared-7c88fb94.mjs';
3
3
  import { Rule, Declaration } from 'postcss';
4
4
  import '@csstools/postcss-is-pseudo-class';
5
5
 
@@ -57,7 +57,15 @@ function testIfVariablesScope(node, count = 1) {
57
57
  return false;
58
58
  }
59
59
  function commonChunkPreflight(node, options) {
60
- node.selector = node.selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, 'view + view');
60
+ let childCombinatorReplaceValue = 'view + view';
61
+ if (Array.isArray(options.cssChildCombinatorReplaceValue)) {
62
+ const part = options.cssChildCombinatorReplaceValue.join(',');
63
+ childCombinatorReplaceValue = [part, ' + ', part].join('');
64
+ }
65
+ else if (typeof options.cssChildCombinatorReplaceValue === 'string') {
66
+ childCombinatorReplaceValue = options.cssChildCombinatorReplaceValue;
67
+ }
68
+ node.selector = node.selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
61
69
  if (testIfVariablesScope(node)) {
62
70
  const selectorParts = node.selector.split(',');
63
71
  if (!selectorParts.includes('view')) {
package/dist/postcss.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var postcss = require('./postcss-e0e5739b.js');
5
+ var postcss = require('./postcss-33ef0bd0.js');
6
6
  var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
7
7
  require('postcss-selector-parser');
8
- require('./shared-28d43730.js');
8
+ require('./shared-ae7dd073.js');
9
9
  require('postcss');
10
10
 
11
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
package/dist/postcss.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { p as postcssWeappTailwindcss } from './postcss-b4e0e1ac.mjs';
1
+ export { p as postcssWeappTailwindcss } from './postcss-ea625621.mjs';
2
2
  export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
3
3
  import 'postcss-selector-parser';
4
- import './shared-31001503.mjs';
4
+ import './shared-7c88fb94.mjs';
5
5
  import 'postcss';
package/dist/replace.js CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var shared = require('./shared-28d43730.js');
5
+ var shared = require('./shared-ae7dd073.js');
6
6
 
7
7
  function replaceWxml(original, options = {
8
8
  keepEOL: false,
9
- escapeMap: shared.SimpleMappingChars2String,
9
+ escapeMap: shared.SimpleMappingChars2String
10
10
  }) {
11
11
  const { keepEOL, escapeMap, mangleContext } = options;
12
12
  let res = original;
package/dist/replace.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { e as escape, S as SimpleMappingChars2String } from './shared-31001503.mjs';
2
- export { M as MappingChars2String, b as MappingChars2StringEntries, a as SYMBOL_TABLE, c as SimpleMappingChars2StringEntries, i as replaceCss } from './shared-31001503.mjs';
1
+ import { e as escape, S as SimpleMappingChars2String } from './shared-7c88fb94.mjs';
2
+ export { M as MappingChars2String, b as MappingChars2StringEntries, a as SYMBOL_TABLE, c as SimpleMappingChars2StringEntries, i as replaceCss } from './shared-7c88fb94.mjs';
3
3
 
4
4
  function replaceWxml(original, options = {
5
5
  keepEOL: false,
6
- escapeMap: SimpleMappingChars2String,
6
+ escapeMap: SimpleMappingChars2String
7
7
  }) {
8
8
  const { keepEOL, escapeMap, mangleContext } = options;
9
9
  let res = original;
@@ -103,6 +103,9 @@ const SimpleMappingChars2String = {
103
103
  const SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
104
104
 
105
105
  const MAX_ASCII_CHAR_CODE = 127;
106
+ function isAsciiNumber(code) {
107
+ return code >= 48 && code <= 57;
108
+ }
106
109
  function escape(selectors, options = {
107
110
  map: SimpleMappingChars2String
108
111
  }) {
@@ -111,14 +114,32 @@ function escape(selectors, options = {
111
114
  for (let i = 0; i < sb.length; i++) {
112
115
  const char = sb[i];
113
116
  const code = char.codePointAt(0);
114
- if (code !== undefined && code > MAX_ASCII_CHAR_CODE) {
115
- sb[i] = 'u' + Number(code).toString(16);
116
- }
117
- else {
118
- const hit = map[char];
119
- if (hit) {
117
+ const isCodeExisted = code !== undefined;
118
+ const hit = map[char];
119
+ if (isCodeExisted) {
120
+ if (code > MAX_ASCII_CHAR_CODE) {
121
+ sb[i] = 'u' + Number(code).toString(16);
122
+ }
123
+ else if (hit) {
120
124
  sb[i] = hit;
121
125
  }
126
+ else if (i === 0) {
127
+ if (isAsciiNumber(code)) {
128
+ sb[i] = '_' + char;
129
+ }
130
+ else if (char === '-') {
131
+ const nextChar = sb[i + 1];
132
+ if (nextChar) {
133
+ const nextCharCode = nextChar.codePointAt(0);
134
+ if (nextCharCode && isAsciiNumber(nextCharCode)) {
135
+ sb[i] = '_' + char;
136
+ }
137
+ }
138
+ else if (nextChar === undefined) {
139
+ sb[i] = '_' + char;
140
+ }
141
+ }
142
+ }
122
143
  }
123
144
  }
124
145
  const res = sb.join('');
@@ -126,7 +147,7 @@ function escape(selectors, options = {
126
147
  }
127
148
 
128
149
  function internalCssSelectorReplacer(selectors, options = {
129
- escapeMap: SimpleMappingChars2String,
150
+ escapeMap: SimpleMappingChars2String
130
151
  }) {
131
152
  const { mangleContext, escapeMap } = options;
132
153
  if (mangleContext) {
@@ -105,6 +105,9 @@ const SimpleMappingChars2String = {
105
105
  const SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
106
106
 
107
107
  const MAX_ASCII_CHAR_CODE = 127;
108
+ function isAsciiNumber(code) {
109
+ return code >= 48 && code <= 57;
110
+ }
108
111
  function escape(selectors, options = {
109
112
  map: SimpleMappingChars2String
110
113
  }) {
@@ -113,14 +116,32 @@ function escape(selectors, options = {
113
116
  for (let i = 0; i < sb.length; i++) {
114
117
  const char = sb[i];
115
118
  const code = char.codePointAt(0);
116
- if (code !== undefined && code > MAX_ASCII_CHAR_CODE) {
117
- sb[i] = 'u' + Number(code).toString(16);
118
- }
119
- else {
120
- const hit = map[char];
121
- if (hit) {
119
+ const isCodeExisted = code !== undefined;
120
+ const hit = map[char];
121
+ if (isCodeExisted) {
122
+ if (code > MAX_ASCII_CHAR_CODE) {
123
+ sb[i] = 'u' + Number(code).toString(16);
124
+ }
125
+ else if (hit) {
122
126
  sb[i] = hit;
123
127
  }
128
+ else if (i === 0) {
129
+ if (isAsciiNumber(code)) {
130
+ sb[i] = '_' + char;
131
+ }
132
+ else if (char === '-') {
133
+ const nextChar = sb[i + 1];
134
+ if (nextChar) {
135
+ const nextCharCode = nextChar.codePointAt(0);
136
+ if (nextCharCode && isAsciiNumber(nextCharCode)) {
137
+ sb[i] = '_' + char;
138
+ }
139
+ }
140
+ else if (nextChar === undefined) {
141
+ sb[i] = '_' + char;
142
+ }
143
+ }
144
+ }
124
145
  }
125
146
  }
126
147
  const res = sb.join('');
@@ -128,7 +149,7 @@ function escape(selectors, options = {
128
149
  }
129
150
 
130
151
  function internalCssSelectorReplacer(selectors, options = {
131
- escapeMap: SimpleMappingChars2String,
152
+ escapeMap: SimpleMappingChars2String
132
153
  }) {
133
154
  const { mangleContext, escapeMap } = options;
134
155
  if (mangleContext) {
package/dist/types.d.ts CHANGED
@@ -16,6 +16,7 @@ export type RequiredStyleHandlerOptions = {
16
16
  isMainChunk: boolean;
17
17
  cssInjectPreflight?: InjectPreflight;
18
18
  cssPreflightRange?: 'view' | 'all';
19
+ cssChildCombinatorReplaceValue?: string | string[];
19
20
  replaceUniversalSelectorWith?: string | false;
20
21
  escapeMap?: Record<string, string>;
21
22
  };
@@ -87,6 +88,7 @@ export interface UserDefinedOptions {
87
88
  minifiedJs?: boolean;
88
89
  mangle?: boolean | IMangleOptions;
89
90
  arbitraryValues?: IArbitraryValues;
91
+ cssChildCombinatorReplaceValue?: string | string[];
90
92
  }
91
93
  export interface IMangleScopeContext {
92
94
  rawOptions: UserDefinedOptions['mangle'];
package/dist/vite.js CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-3a20e9d4.js');
6
- var postcss = require('./postcss-e0e5739b.js');
5
+ var options = require('./options-887b74ca.js');
6
+ var postcss = require('./postcss-33ef0bd0.js');
7
7
  require('micromatch');
8
8
  require('@babel/types');
9
9
  require('@babel/generator');
10
10
  require('@babel/parser');
11
11
  require('@babel/traverse');
12
12
  require('./replace.js');
13
- require('./shared-28d43730.js');
13
+ require('./shared-ae7dd073.js');
14
14
  require('postcss');
15
15
  require('@csstools/postcss-is-pseudo-class');
16
16
  require('node:path');
package/dist/vite.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-2a6f14b8.mjs';
2
- import { v as vitePluginName } from './postcss-b4e0e1ac.mjs';
1
+ import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-879de0a2.mjs';
2
+ import { v as vitePluginName } from './postcss-ea625621.mjs';
3
3
  import 'micromatch';
4
4
  import '@babel/types';
5
5
  import '@babel/generator';
6
6
  import '@babel/parser';
7
7
  import '@babel/traverse';
8
8
  import './replace.mjs';
9
- import './shared-31001503.mjs';
9
+ import './shared-7c88fb94.mjs';
10
10
  import 'postcss';
11
11
  import '@csstools/postcss-is-pseudo-class';
12
12
  import 'node:path';
package/dist/webpack.js CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-3a20e9d4.js');
6
- var postcss = require('./postcss-e0e5739b.js');
5
+ var options = require('./options-887b74ca.js');
6
+ var postcss = require('./postcss-33ef0bd0.js');
7
7
  require('micromatch');
8
8
  require('@babel/types');
9
9
  require('@babel/generator');
10
10
  require('@babel/parser');
11
11
  require('@babel/traverse');
12
12
  require('./replace.js');
13
- require('./shared-28d43730.js');
13
+ require('./shared-ae7dd073.js');
14
14
  require('postcss');
15
15
  require('@csstools/postcss-is-pseudo-class');
16
16
  require('node:path');
package/dist/webpack.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-2a6f14b8.mjs';
2
- import { a as pluginName, N as NS } from './postcss-b4e0e1ac.mjs';
1
+ import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-879de0a2.mjs';
2
+ import { a as pluginName, N as NS } from './postcss-ea625621.mjs';
3
3
  import 'micromatch';
4
4
  import '@babel/types';
5
5
  import '@babel/generator';
6
6
  import '@babel/parser';
7
7
  import '@babel/traverse';
8
8
  import './replace.mjs';
9
- import './shared-31001503.mjs';
9
+ import './shared-7c88fb94.mjs';
10
10
  import 'postcss';
11
11
  import '@csstools/postcss-is-pseudo-class';
12
12
  import 'node:path';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "description": "把tailwindcss jit引擎,带给小程序开发者们\nbring tailwindcss jit engine to our miniprogram developers!",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -48,7 +48,7 @@
48
48
  "sideEffects": false,
49
49
  "repository": {
50
50
  "type": "git",
51
- "url": "git+https://github.com/sonofmagic/weapp-tailwindcss-webpack-plugin.git"
51
+ "url": "git+https://github.com/sonofmagic/weapp-tailwindcss.git"
52
52
  },
53
53
  "files": [
54
54
  "bin",
@@ -100,37 +100,38 @@
100
100
  "@icebreakers/cli": "^0.1.1",
101
101
  "@icebreakers/readme": "0.1.0",
102
102
  "@rollup/plugin-alias": "^5.0.0",
103
- "@rollup/plugin-commonjs": "^25.0.0",
103
+ "@rollup/plugin-commonjs": "^25.0.1",
104
104
  "@rollup/plugin-json": "^6.0.0",
105
- "@rollup/plugin-node-resolve": "^15.0.2",
105
+ "@rollup/plugin-node-resolve": "^15.1.0",
106
106
  "@rollup/plugin-terser": "^0.4.3",
107
107
  "@rollup/plugin-typescript": "^11.1.1",
108
108
  "@tsconfig/recommended": "^1.0.2",
109
109
  "@types/babel__generator": "^7.6.4",
110
110
  "@types/babel__traverse": "^7.18.5",
111
111
  "@types/fs-extra": "^11.0.1",
112
- "@types/gulp": "^4.0.10",
112
+ "@types/gulp": "^4.0.11",
113
113
  "@types/gulp-postcss": "^8.0.3",
114
- "@types/jest": "^29.5.1",
115
- "@types/lodash": "^4.14.194",
114
+ "@types/jest": "^29.5.2",
115
+ "@types/lodash": "^4.14.195",
116
116
  "@types/micromatch": "^4.0.2",
117
- "@types/node": "^20.2.3",
118
- "@types/react": "^18.2.6",
117
+ "@types/node": "^20.3.1",
119
118
  "@types/semver": "^7.5.0",
120
119
  "@types/vinyl": "^2.0.7",
121
120
  "@types/webpack": "^5.28.1",
122
121
  "@types/webpack-sources": "^3.2.0",
123
- "@vitest/coverage-c8": "^0.31.1",
122
+ "@vitest/coverage-v8": "^0.32.0",
124
123
  "autoprefixer": "^10.4.14",
125
124
  "babel-loader": "^9.1.2",
126
- "bumpp": "^9.1.0",
125
+ "bumpp": "^9.1.1",
127
126
  "chalk": "4.1.2",
128
127
  "cross-env": "^7.0.3",
129
- "css-loader": "^6.7.4",
128
+ "css-loader": "^6.8.1",
130
129
  "defu": "6.1.2",
131
130
  "del": "^6.1.1",
132
- "eslint": "8.41.0",
131
+ "eslint": "8.42.0",
133
132
  "eslint-config-icebreaker": "^1.1.0",
133
+ "eslint-config-prettier": "^8.8.0",
134
+ "eslint-plugin-prettier": "^4.2.1",
134
135
  "execa": "5",
135
136
  "fast-glob": "^3.2.12",
136
137
  "fs-extra": "^11.1.1",
@@ -139,17 +140,15 @@
139
140
  "html-loader": "^4.2.0",
140
141
  "jest": "^29.5.0",
141
142
  "lodash": "^4.17.21",
142
- "memfs": "^3.5.1",
143
143
  "mini-css-extract-plugin": "^2.7.6",
144
144
  "miniprogram-automator": "^0.12.0",
145
145
  "pkg-types": "^1.0.3",
146
146
  "postcss-load-config": "^4.0.1",
147
- "postcss-loader": "^7.3.0",
147
+ "postcss-loader": "^7.3.3",
148
148
  "postcss-rem-to-responsive-pixel": "^5.1.3",
149
149
  "prettier": "^2.8.8",
150
- "rollup": "^3.23.0",
151
- "rollup-plugin-visualizer": "^5.9.0",
152
- "simple-functional-loader": "^1.2.1",
150
+ "rollup": "^3.25.1",
151
+ "rollup-plugin-visualizer": "^5.9.2",
153
152
  "style-loader": "^3.3.3",
154
153
  "tailwind-children": "^0.5.0",
155
154
  "tailwindcss": "^3.3.2",
@@ -157,15 +156,16 @@
157
156
  "ts-node": "^10.9.1",
158
157
  "ts-patch": "^2.1.0",
159
158
  "tsd": "^0.28.1",
160
- "tslib": "^2.5.2",
159
+ "tslib": "^2.5.3",
161
160
  "ttypescript": "^1.5.15",
162
161
  "typescript": "^4.9.5",
163
162
  "typescript-transform-paths": "^3.4.6",
164
163
  "vinyl": "^3.0.0",
165
- "vite": "^4.3.8",
166
- "vitest": "^0.31.1",
164
+ "vite": "^4.3.9",
165
+ "vitest": "^0.32.0",
167
166
  "weapp-tailwindcss-children": "^0.1.0",
168
- "webpack": "^5.83.1"
167
+ "webpack": "^5.86.0",
168
+ "webpack-build-utils": "^0.0.1"
169
169
  },
170
170
  "dependencies": {
171
171
  "@babel/generator": "^7.21.4",
@@ -174,13 +174,13 @@
174
174
  "@babel/types": "^7.21.4",
175
175
  "@csstools/postcss-is-pseudo-class": "^3.2.1",
176
176
  "micromatch": "^4.0.5",
177
- "postcss": "8.4.23",
177
+ "postcss": "8.4.24",
178
178
  "postcss-selector-parser": "^6.0.13",
179
179
  "semver": "^7.5.1",
180
- "tailwindcss-mangle-shared": "^1.2.1",
181
- "tailwindcss-patch": "^1.2.1"
180
+ "tailwindcss-mangle-shared": "^1.2.5",
181
+ "tailwindcss-patch": "^1.2.5"
182
182
  },
183
- "packageManager": "pnpm@8.5.1",
183
+ "packageManager": "pnpm@8.6.1",
184
184
  "scripts": {
185
185
  "dev": "yarn clean && yarn dts && cross-env NODE_ENV=development rollup -c rollup.config.ts --configPlugin typescript -w",
186
186
  "build": "yarn clean && cross-env NODE_ENV=production rollup -c rollup.config.ts --configPlugin typescript && yarn dts",
@@ -189,7 +189,7 @@
189
189
  "dts": "tsc --emitDeclarationOnly -p tsconfig.dts.json",
190
190
  "test": "jest && vitest run",
191
191
  "jest-u": "jest -u",
192
- "vitest:test": "vitest",
192
+ "test:dev": "vitest",
193
193
  "vitest:coverage": "vitest run --coverage",
194
194
  "e2e": "vitest run -c ./vitest.e2e.config.ts",
195
195
  "e2e:dev": "vitest -c ./vitest.e2e.config.ts",