weapp-tailwindcss 2.8.1 → 2.8.3

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/dist/cli.js CHANGED
@@ -1,20 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var options = require('./options-4284d635.js');
3
+ var options = require('./options-92c91aaa.js');
4
4
  require('micromatch');
5
5
  require('magic-string');
6
6
  require('./replace.js');
7
7
  require('@weapp-core/escape');
8
- require('./shared-df9de23f.js');
8
+ require('@ast-core/escape');
9
+ require('./shared-8b9be5f0.js');
9
10
  require('@weapp-core/regex');
10
11
  require('@babel/generator');
11
12
  require('@babel/parser');
12
13
  require('@babel/traverse');
13
- require('./defaults-c6437917.js');
14
+ require('./defaults-263271f9.js');
14
15
  require('@babel/types');
15
16
  require('htmlparser2');
16
17
  require('postcss');
17
- require('./postcss-4e99a8e8.js');
18
+ require('./postcss-8d7f67b4.js');
18
19
  require('postcss-selector-parser');
19
20
  require('@csstools/postcss-is-pseudo-class');
20
21
  require('node:path');
package/dist/cli.mjs CHANGED
@@ -1,18 +1,19 @@
1
- import { g as getOptions, c as createPatch } from './options-ad0be036.mjs';
1
+ import { g as getOptions, c as createPatch } from './options-673b7a98.mjs';
2
2
  import 'micromatch';
3
3
  import 'magic-string';
4
4
  import './replace.mjs';
5
5
  import '@weapp-core/escape';
6
- import './shared-fd149084.mjs';
6
+ import '@ast-core/escape';
7
+ import './shared-283aac78.mjs';
7
8
  import '@weapp-core/regex';
8
9
  import '@babel/generator';
9
10
  import '@babel/parser';
10
11
  import '@babel/traverse';
11
- import './defaults-72ea9566.mjs';
12
+ import './defaults-dc8a0e3d.mjs';
12
13
  import '@babel/types';
13
14
  import 'htmlparser2';
14
15
  import 'postcss';
15
- import './postcss-a551ddc0.mjs';
16
+ import './postcss-55ed4d42.mjs';
16
17
  import 'postcss-selector-parser';
17
18
  import '@csstools/postcss-is-pseudo-class';
18
19
  import 'node:path';
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var escape = require('@weapp-core/escape');
4
+ require('@ast-core/escape');
4
5
 
5
6
  function isMap(value) {
6
7
  return Object.prototype.toString.call(value) === '[object Map]';
@@ -128,7 +129,11 @@ const defaultOptions = {
128
129
  return false;
129
130
  },
130
131
  disabledDefaultTemplateHandler: false,
131
- jsEscapeStrategy: 'replace'
132
+ jsEscapeStrategy: 'replace',
133
+ cssSelectorReplacement: {
134
+ root: 'page',
135
+ universal: 'view'
136
+ }
132
137
  };
133
138
 
134
139
  exports.defaultOptions = defaultOptions;
@@ -1,4 +1,5 @@
1
1
  import { SimpleMappingChars2String } from '@weapp-core/escape';
2
+ import '@ast-core/escape';
2
3
 
3
4
  function isMap(value) {
4
5
  return Object.prototype.toString.call(value) === '[object Map]';
@@ -126,7 +127,11 @@ const defaultOptions = {
126
127
  return false;
127
128
  },
128
129
  disabledDefaultTemplateHandler: false,
129
- jsEscapeStrategy: 'replace'
130
+ jsEscapeStrategy: 'replace',
131
+ cssSelectorReplacement: {
132
+ root: 'page',
133
+ universal: 'view'
134
+ }
130
135
  };
131
136
 
132
137
  export { defaultOptions as d, getGroupedEntries as g, isMap as i, noop as n };
package/dist/defaults.js CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var defaults = require('./defaults-c6437917.js');
5
+ var defaults = require('./defaults-263271f9.js');
6
6
  require('@weapp-core/escape');
7
+ require('@ast-core/escape');
7
8
 
8
9
 
9
10
 
package/dist/defaults.mjs CHANGED
@@ -1,2 +1,3 @@
1
- export { d as defaultOptions } from './defaults-72ea9566.mjs';
1
+ export { d as defaultOptions } from './defaults-dc8a0e3d.mjs';
2
2
  import '@weapp-core/escape';
3
+ import '@ast-core/escape';
package/dist/escape.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from '@weapp-core/escape';
2
+ export { jsStringEscape } from '@ast-core/escape';
package/dist/gulp.js CHANGED
@@ -3,21 +3,22 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var stream = require('node:stream');
6
- var options = require('./options-4284d635.js');
6
+ var options = require('./options-92c91aaa.js');
7
7
  require('micromatch');
8
8
  require('magic-string');
9
9
  require('./replace.js');
10
10
  require('@weapp-core/escape');
11
- require('./shared-df9de23f.js');
11
+ require('@ast-core/escape');
12
+ require('./shared-8b9be5f0.js');
12
13
  require('@weapp-core/regex');
13
14
  require('@babel/generator');
14
15
  require('@babel/parser');
15
16
  require('@babel/traverse');
16
- require('./defaults-c6437917.js');
17
+ require('./defaults-263271f9.js');
17
18
  require('@babel/types');
18
19
  require('htmlparser2');
19
20
  require('postcss');
20
- require('./postcss-4e99a8e8.js');
21
+ require('./postcss-8d7f67b4.js');
21
22
  require('postcss-selector-parser');
22
23
  require('@csstools/postcss-is-pseudo-class');
23
24
  require('node:path');
package/dist/gulp.mjs CHANGED
@@ -1,19 +1,20 @@
1
1
  import stream from 'node:stream';
2
- import { g as getOptions, a as createTailwindcssPatcher } from './options-ad0be036.mjs';
2
+ import { g as getOptions, a as createTailwindcssPatcher } from './options-673b7a98.mjs';
3
3
  import 'micromatch';
4
4
  import 'magic-string';
5
5
  import './replace.mjs';
6
6
  import '@weapp-core/escape';
7
- import './shared-fd149084.mjs';
7
+ import '@ast-core/escape';
8
+ import './shared-283aac78.mjs';
8
9
  import '@weapp-core/regex';
9
10
  import '@babel/generator';
10
11
  import '@babel/parser';
11
12
  import '@babel/traverse';
12
- import './defaults-72ea9566.mjs';
13
+ import './defaults-dc8a0e3d.mjs';
13
14
  import '@babel/types';
14
15
  import 'htmlparser2';
15
16
  import 'postcss';
16
- import './postcss-a551ddc0.mjs';
17
+ import './postcss-55ed4d42.mjs';
17
18
  import 'postcss-selector-parser';
18
19
  import '@csstools/postcss-is-pseudo-class';
19
20
  import 'node:path';
package/dist/index.js CHANGED
@@ -7,21 +7,22 @@ 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-4284d635.js');
10
+ require('./options-92c91aaa.js');
11
11
  require('micromatch');
12
12
  require('magic-string');
13
13
  require('./replace.js');
14
14
  require('@weapp-core/escape');
15
- require('./shared-df9de23f.js');
15
+ require('@ast-core/escape');
16
+ require('./shared-8b9be5f0.js');
16
17
  require('@weapp-core/regex');
17
18
  require('@babel/generator');
18
19
  require('@babel/parser');
19
20
  require('@babel/traverse');
20
- require('./defaults-c6437917.js');
21
+ require('./defaults-263271f9.js');
21
22
  require('@babel/types');
22
23
  require('htmlparser2');
23
24
  require('postcss');
24
- require('./postcss-4e99a8e8.js');
25
+ require('./postcss-8d7f67b4.js');
25
26
  require('postcss-selector-parser');
26
27
  require('@csstools/postcss-is-pseudo-class');
27
28
  require('semver');
package/dist/index.mjs CHANGED
@@ -3,21 +3,22 @@ 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-ad0be036.mjs';
6
+ import './options-673b7a98.mjs';
7
7
  import 'micromatch';
8
8
  import 'magic-string';
9
9
  import './replace.mjs';
10
10
  import '@weapp-core/escape';
11
- import './shared-fd149084.mjs';
11
+ import '@ast-core/escape';
12
+ import './shared-283aac78.mjs';
12
13
  import '@weapp-core/regex';
13
14
  import '@babel/generator';
14
15
  import '@babel/parser';
15
16
  import '@babel/traverse';
16
- import './defaults-72ea9566.mjs';
17
+ import './defaults-dc8a0e3d.mjs';
17
18
  import '@babel/types';
18
19
  import 'htmlparser2';
19
20
  import 'postcss';
20
- import './postcss-a551ddc0.mjs';
21
+ import './postcss-55ed4d42.mjs';
21
22
  import 'postcss-selector-parser';
22
23
  import '@csstools/postcss-is-pseudo-class';
23
24
  import 'semver';
@@ -1,7 +1,3 @@
1
- import type { IJsHandlerOptions } from "../types";
2
- export declare function jsHandler(rawSource: string, options: IJsHandlerOptions): import("@babel/generator").GeneratorResult | {
3
- code: string;
4
- };
5
- export declare function createjsHandler(options: Omit<IJsHandlerOptions, 'classNameSet'>): (rawSource: string, set: Set<string>) => import("@babel/generator").GeneratorResult | {
6
- code: string;
7
- };
1
+ import type { CreateJsHandlerOptions, IJsHandlerOptions, JsHandlerResult } from "../types";
2
+ export declare function jsHandler(rawSource: string, options: IJsHandlerOptions): JsHandlerResult;
3
+ export declare function createJsHandler(options: CreateJsHandlerOptions): (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult;
@@ -2,15 +2,16 @@ import { isMatch } from 'micromatch';
2
2
  import MagicString from 'magic-string';
3
3
  import { replaceJs as replaceWxml } from './replace.mjs';
4
4
  import { escapeStringRegexp, variableRegExp } from '@weapp-core/regex';
5
- import { jsStringEscape, SimpleMappingChars2String, MappingChars2String } from '@weapp-core/escape';
5
+ import { SimpleMappingChars2String, MappingChars2String } from '@weapp-core/escape';
6
+ import { jsStringEscape } from '@ast-core/escape';
6
7
  import generate from '@babel/generator';
7
8
  import { parse, parseExpression } from '@babel/parser';
8
9
  import traverse from '@babel/traverse';
9
- import { n as noop, d as defaultOptions, i as isMap } from './defaults-72ea9566.mjs';
10
+ import { n as noop, d as defaultOptions, i as isMap } from './defaults-dc8a0e3d.mjs';
10
11
  import * as t from '@babel/types';
11
12
  import { Parser } from 'htmlparser2';
12
13
  import postcss from 'postcss';
13
- import { p as postcssWeappTailwindcss } from './postcss-a551ddc0.mjs';
14
+ import { p as postcssWeappTailwindcss } from './postcss-55ed4d42.mjs';
14
15
  import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
15
16
  import path from 'node:path';
16
17
  import fs from 'node:fs';
@@ -92,6 +93,48 @@ function replaceHandleValue(str, node, options, ms, offset = 0, needEscaped = fa
92
93
 
93
94
  const isProd = () => process.env.NODE_ENV === 'production';
94
95
 
96
+ function isObject(value) {
97
+ return value !== null && typeof value === "object";
98
+ }
99
+ function _defu(baseObject, defaults, namespace = ".", merger) {
100
+ if (!isObject(defaults)) {
101
+ return _defu(baseObject, {}, namespace, merger);
102
+ }
103
+ const object = Object.assign({}, defaults);
104
+ for (const key in baseObject) {
105
+ if (key === "__proto__" || key === "constructor") {
106
+ continue;
107
+ }
108
+ const value = baseObject[key];
109
+ if (value === null || value === void 0) {
110
+ continue;
111
+ }
112
+ if (merger && merger(object, key, value, namespace)) {
113
+ continue;
114
+ }
115
+ if (Array.isArray(value) && Array.isArray(object[key])) {
116
+ object[key] = [...value, ...object[key]];
117
+ } else if (isObject(value) && isObject(object[key])) {
118
+ object[key] = _defu(
119
+ value,
120
+ object[key],
121
+ (namespace ? `${namespace}.` : "") + key.toString(),
122
+ merger
123
+ );
124
+ } else {
125
+ object[key] = value;
126
+ }
127
+ }
128
+ return object;
129
+ }
130
+ function createDefu(merger) {
131
+ return (...arguments_) => (
132
+ // eslint-disable-next-line unicorn/no-array-reduce
133
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
134
+ );
135
+ }
136
+ const defu = createDefu();
137
+
95
138
  function isEvalPath(p) {
96
139
  if (p.isCallExpression()) {
97
140
  const calleePath = p.get('callee');
@@ -132,7 +175,7 @@ function jsHandler(rawSource, options) {
132
175
  p.traverse({
133
176
  StringLiteral: {
134
177
  enter(s) {
135
- const res = jsHandler(s.node.value, Object.assign(Object.assign({}, options), { needEscaped: false }));
178
+ const res = jsHandler(s.node.value, Object.assign(Object.assign({}, options), { needEscaped: false, generateMap: false }));
136
179
  if (res.code) {
137
180
  const node = s.node;
138
181
  if (typeof node.start === 'number' && typeof node.end === 'number') {
@@ -148,7 +191,7 @@ function jsHandler(rawSource, options) {
148
191
  },
149
192
  TemplateElement: {
150
193
  enter(s) {
151
- const res = jsHandler(s.node.value.raw, options);
194
+ const res = jsHandler(s.node.value.raw, Object.assign(Object.assign({}, options), { generateMap: false }));
152
195
  if (res.code) {
153
196
  const node = s.node;
154
197
  if (typeof node.start === 'number' && typeof node.end === 'number') {
@@ -168,9 +211,10 @@ function jsHandler(rawSource, options) {
168
211
  }
169
212
  };
170
213
  traverse(ast, ropt);
171
- return {
214
+ const result = {
172
215
  code: ms.toString()
173
216
  };
217
+ return result;
174
218
  }
175
219
  else {
176
220
  const gopt = {
@@ -223,63 +267,23 @@ function jsHandler(rawSource, options) {
223
267
  });
224
268
  }
225
269
  }
226
- function createjsHandler(options) {
227
- const { mangleContext, arbitraryValues, minifiedJs, escapeMap, jsPreserveClass, strategy } = options;
228
- return (rawSource, set) => {
229
- return jsHandler(rawSource, {
270
+ function createJsHandler(options) {
271
+ const { mangleContext, arbitraryValues, minifiedJs, escapeMap, jsPreserveClass, strategy, generateMap } = options;
272
+ return (rawSource, set, options) => {
273
+ const opts = defu(options, {
230
274
  classNameSet: set,
231
275
  minifiedJs,
232
276
  escapeMap,
233
277
  arbitraryValues,
234
278
  mangleContext,
235
279
  jsPreserveClass,
236
- strategy
280
+ strategy,
281
+ generateMap
237
282
  });
283
+ return jsHandler(rawSource, opts);
238
284
  };
239
285
  }
240
286
 
241
- function isObject(value) {
242
- return value !== null && typeof value === "object";
243
- }
244
- function _defu(baseObject, defaults, namespace = ".", merger) {
245
- if (!isObject(defaults)) {
246
- return _defu(baseObject, {}, namespace, merger);
247
- }
248
- const object = Object.assign({}, defaults);
249
- for (const key in baseObject) {
250
- if (key === "__proto__" || key === "constructor") {
251
- continue;
252
- }
253
- const value = baseObject[key];
254
- if (value === null || value === void 0) {
255
- continue;
256
- }
257
- if (merger && merger(object, key, value, namespace)) {
258
- continue;
259
- }
260
- if (Array.isArray(value) && Array.isArray(object[key])) {
261
- object[key] = [...value, ...object[key]];
262
- } else if (isObject(value) && isObject(object[key])) {
263
- object[key] = _defu(
264
- value,
265
- object[key],
266
- (namespace ? `${namespace}.` : "") + key.toString(),
267
- merger
268
- );
269
- } else {
270
- object[key] = value;
271
- }
272
- }
273
- return object;
274
- }
275
- function createDefu(merger) {
276
- return (...arguments_) => (
277
- // eslint-disable-next-line unicorn/no-array-reduce
278
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
279
- );
280
- }
281
- const defu = createDefu();
282
-
283
287
  function generateCode(match, options = {}) {
284
288
  const ast = parseExpression(match);
285
289
  traverse(ast, {
@@ -404,7 +408,7 @@ function customTemplateHandler(rawSource, options) {
404
408
  function update() {
405
409
  s.update(parser.startIndex + name.length + 2, parser.endIndex, templateReplacer(value, options));
406
410
  }
407
- if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class')) {
411
+ if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class' || name === 'virtualhostclass')) {
408
412
  update();
409
413
  }
410
414
  for (const [t, props] of customAttributesEntities) {
@@ -445,7 +449,7 @@ function createTemplateHandler(options = {}) {
445
449
  }
446
450
 
447
451
  function styleHandler(rawSource, options) {
448
- return postcss([postcssWeappTailwindcss(options), postcssIsPseudoClass()]).process(rawSource).css;
452
+ return postcss([postcssIsPseudoClass(), postcssWeappTailwindcss(options)]).process(rawSource).css;
449
453
  }
450
454
  function createStyleHandler(options) {
451
455
  return (rawSource, opt) => {
@@ -682,7 +686,7 @@ function getOptions(options = {}) {
682
686
  const result = defu(options, defaultOptions, {
683
687
  minifiedJs: isProd()
684
688
  });
685
- const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler, jsEscapeStrategy } = result;
689
+ const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler, jsEscapeStrategy, cssSelectorReplacement } = result;
686
690
  result.escapeMap = customReplaceDictionary;
687
691
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
688
692
  const customAttributesEntities = isMap(options.customAttributes)
@@ -699,16 +703,18 @@ function getOptions(options = {}) {
699
703
  escapeMap,
700
704
  mangleContext,
701
705
  cssChildCombinatorReplaceValue,
702
- injectAdditionalCssVarScope
706
+ injectAdditionalCssVarScope,
707
+ cssSelectorReplacement
703
708
  });
704
709
  result.styleHandler = styleHandler;
705
- const jsHandler = createjsHandler({
710
+ const jsHandler = createJsHandler({
706
711
  minifiedJs,
707
712
  escapeMap,
708
713
  mangleContext,
709
714
  arbitraryValues,
710
715
  jsPreserveClass,
711
- strategy: jsEscapeStrategy
716
+ strategy: jsEscapeStrategy,
717
+ generateMap: true
712
718
  });
713
719
  result.jsHandler = jsHandler;
714
720
  const templateHandler = createTemplateHandler({
@@ -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
+ var escape$1 = require('@weapp-core/escape');
8
+ var escape = require('@ast-core/escape');
8
9
  var generate = require('@babel/generator');
9
10
  var parser = require('@babel/parser');
10
11
  var traverse = require('@babel/traverse');
11
- var defaults = require('./defaults-c6437917.js');
12
+ var defaults = require('./defaults-263271f9.js');
12
13
  var t = require('@babel/types');
13
14
  var htmlparser2 = require('htmlparser2');
14
15
  var postcss = require('postcss');
15
- var postcss$1 = require('./postcss-4e99a8e8.js');
16
+ var postcss$1 = require('./postcss-8d7f67b4.js');
16
17
  var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
17
18
  var path = require('node:path');
18
19
  var fs = require('node:fs');
@@ -123,6 +124,48 @@ function replaceHandleValue(str, node, options, ms, offset = 0, needEscaped = fa
123
124
 
124
125
  const isProd = () => process.env.NODE_ENV === 'production';
125
126
 
127
+ function isObject(value) {
128
+ return value !== null && typeof value === "object";
129
+ }
130
+ function _defu(baseObject, defaults, namespace = ".", merger) {
131
+ if (!isObject(defaults)) {
132
+ return _defu(baseObject, {}, namespace, merger);
133
+ }
134
+ const object = Object.assign({}, defaults);
135
+ for (const key in baseObject) {
136
+ if (key === "__proto__" || key === "constructor") {
137
+ continue;
138
+ }
139
+ const value = baseObject[key];
140
+ if (value === null || value === void 0) {
141
+ continue;
142
+ }
143
+ if (merger && merger(object, key, value, namespace)) {
144
+ continue;
145
+ }
146
+ if (Array.isArray(value) && Array.isArray(object[key])) {
147
+ object[key] = [...value, ...object[key]];
148
+ } else if (isObject(value) && isObject(object[key])) {
149
+ object[key] = _defu(
150
+ value,
151
+ object[key],
152
+ (namespace ? `${namespace}.` : "") + key.toString(),
153
+ merger
154
+ );
155
+ } else {
156
+ object[key] = value;
157
+ }
158
+ }
159
+ return object;
160
+ }
161
+ function createDefu(merger) {
162
+ return (...arguments_) => (
163
+ // eslint-disable-next-line unicorn/no-array-reduce
164
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
165
+ );
166
+ }
167
+ const defu = createDefu();
168
+
126
169
  function isEvalPath(p) {
127
170
  if (p.isCallExpression()) {
128
171
  const calleePath = p.get('callee');
@@ -163,7 +206,7 @@ function jsHandler(rawSource, options) {
163
206
  p.traverse({
164
207
  StringLiteral: {
165
208
  enter(s) {
166
- const res = jsHandler(s.node.value, Object.assign(Object.assign({}, options), { needEscaped: false }));
209
+ const res = jsHandler(s.node.value, Object.assign(Object.assign({}, options), { needEscaped: false, generateMap: false }));
167
210
  if (res.code) {
168
211
  const node = s.node;
169
212
  if (typeof node.start === 'number' && typeof node.end === 'number') {
@@ -179,7 +222,7 @@ function jsHandler(rawSource, options) {
179
222
  },
180
223
  TemplateElement: {
181
224
  enter(s) {
182
- const res = jsHandler(s.node.value.raw, options);
225
+ const res = jsHandler(s.node.value.raw, Object.assign(Object.assign({}, options), { generateMap: false }));
183
226
  if (res.code) {
184
227
  const node = s.node;
185
228
  if (typeof node.start === 'number' && typeof node.end === 'number') {
@@ -199,9 +242,10 @@ function jsHandler(rawSource, options) {
199
242
  }
200
243
  };
201
244
  traverse__default["default"](ast, ropt);
202
- return {
245
+ const result = {
203
246
  code: ms.toString()
204
247
  };
248
+ return result;
205
249
  }
206
250
  else {
207
251
  const gopt = {
@@ -254,63 +298,23 @@ function jsHandler(rawSource, options) {
254
298
  });
255
299
  }
256
300
  }
257
- function createjsHandler(options) {
258
- const { mangleContext, arbitraryValues, minifiedJs, escapeMap, jsPreserveClass, strategy } = options;
259
- return (rawSource, set) => {
260
- return jsHandler(rawSource, {
301
+ function createJsHandler(options) {
302
+ const { mangleContext, arbitraryValues, minifiedJs, escapeMap, jsPreserveClass, strategy, generateMap } = options;
303
+ return (rawSource, set, options) => {
304
+ const opts = defu(options, {
261
305
  classNameSet: set,
262
306
  minifiedJs,
263
307
  escapeMap,
264
308
  arbitraryValues,
265
309
  mangleContext,
266
310
  jsPreserveClass,
267
- strategy
311
+ strategy,
312
+ generateMap
268
313
  });
314
+ return jsHandler(rawSource, opts);
269
315
  };
270
316
  }
271
317
 
272
- function isObject(value) {
273
- return value !== null && typeof value === "object";
274
- }
275
- function _defu(baseObject, defaults, namespace = ".", merger) {
276
- if (!isObject(defaults)) {
277
- return _defu(baseObject, {}, namespace, merger);
278
- }
279
- const object = Object.assign({}, defaults);
280
- for (const key in baseObject) {
281
- if (key === "__proto__" || key === "constructor") {
282
- continue;
283
- }
284
- const value = baseObject[key];
285
- if (value === null || value === void 0) {
286
- continue;
287
- }
288
- if (merger && merger(object, key, value, namespace)) {
289
- continue;
290
- }
291
- if (Array.isArray(value) && Array.isArray(object[key])) {
292
- object[key] = [...value, ...object[key]];
293
- } else if (isObject(value) && isObject(object[key])) {
294
- object[key] = _defu(
295
- value,
296
- object[key],
297
- (namespace ? `${namespace}.` : "") + key.toString(),
298
- merger
299
- );
300
- } else {
301
- object[key] = value;
302
- }
303
- }
304
- return object;
305
- }
306
- function createDefu(merger) {
307
- return (...arguments_) => (
308
- // eslint-disable-next-line unicorn/no-array-reduce
309
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
310
- );
311
- }
312
- const defu = createDefu();
313
-
314
318
  function generateCode(match, options = {}) {
315
319
  const ast = parser.parseExpression(match);
316
320
  traverse__default["default"](ast, {
@@ -435,7 +439,7 @@ function customTemplateHandler(rawSource, options) {
435
439
  function update() {
436
440
  s.update(parser.startIndex + name.length + 2, parser.endIndex, templateReplacer(value, options));
437
441
  }
438
- if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class')) {
442
+ if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class' || name === 'virtualhostclass')) {
439
443
  update();
440
444
  }
441
445
  for (const [t, props] of customAttributesEntities) {
@@ -476,7 +480,7 @@ function createTemplateHandler(options = {}) {
476
480
  }
477
481
 
478
482
  function styleHandler(rawSource, options) {
479
- return postcss__default["default"]([postcss$1.postcssWeappTailwindcss(options), postcssIsPseudoClass__default["default"]()]).process(rawSource).css;
483
+ return postcss__default["default"]([postcssIsPseudoClass__default["default"](), postcss$1.postcssWeappTailwindcss(options)]).process(rawSource).css;
480
484
  }
481
485
  function createStyleHandler(options) {
482
486
  return (rawSource, opt) => {
@@ -700,10 +704,10 @@ function getOptions(options = {}) {
700
704
  options.supportCustomLengthUnitsPatch = undefined;
701
705
  }
702
706
  if (options.customReplaceDictionary === 'simple') {
703
- options.customReplaceDictionary = escape.SimpleMappingChars2String;
707
+ options.customReplaceDictionary = escape$1.SimpleMappingChars2String;
704
708
  }
705
709
  else if (options.customReplaceDictionary === 'complex') {
706
- options.customReplaceDictionary = escape.MappingChars2String;
710
+ options.customReplaceDictionary = escape$1.MappingChars2String;
707
711
  }
708
712
  normalizeMatcher(options, 'cssMatcher');
709
713
  normalizeMatcher(options, 'htmlMatcher');
@@ -713,7 +717,7 @@ function getOptions(options = {}) {
713
717
  const result = defu(options, defaults.defaultOptions, {
714
718
  minifiedJs: isProd()
715
719
  });
716
- const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler, jsEscapeStrategy } = result;
720
+ const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler, jsEscapeStrategy, cssSelectorReplacement } = result;
717
721
  result.escapeMap = customReplaceDictionary;
718
722
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
719
723
  const customAttributesEntities = defaults.isMap(options.customAttributes)
@@ -730,16 +734,18 @@ function getOptions(options = {}) {
730
734
  escapeMap,
731
735
  mangleContext,
732
736
  cssChildCombinatorReplaceValue,
733
- injectAdditionalCssVarScope
737
+ injectAdditionalCssVarScope,
738
+ cssSelectorReplacement
734
739
  });
735
740
  result.styleHandler = styleHandler;
736
- const jsHandler = createjsHandler({
741
+ const jsHandler = createJsHandler({
737
742
  minifiedJs,
738
743
  escapeMap,
739
744
  mangleContext,
740
745
  arbitraryValues,
741
746
  jsPreserveClass,
742
- strategy: jsEscapeStrategy
747
+ strategy: jsEscapeStrategy,
748
+ generateMap: true
743
749
  });
744
750
  result.jsHandler = jsHandler;
745
751
  const templateHandler = createTemplateHandler({
@@ -1,20 +1,28 @@
1
1
  import selectorParser from 'postcss-selector-parser';
2
- import { i as internalCssSelectorReplacer } from './shared-fd149084.mjs';
2
+ import { i as internalCssSelectorReplacer } from './shared-283aac78.mjs';
3
3
  import { Declaration, Rule } from 'postcss';
4
4
  import '@csstools/postcss-is-pseudo-class';
5
5
 
6
6
  const createTransform = (rule, options) => {
7
- const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
7
+ const { replaceUniversalSelectorWith, escapeMap, mangleContext, cssSelectorReplacement } = options;
8
8
  const replaceFlag = replaceUniversalSelectorWith !== false;
9
9
  const transform = (selectors) => {
10
10
  selectors.walk((selector) => {
11
- if (selector.type === 'universal' && replaceFlag) {
12
- selector.value = replaceUniversalSelectorWith;
11
+ if (selector.type === 'universal') {
12
+ if (replaceFlag) {
13
+ selector.value = replaceUniversalSelectorWith;
14
+ }
15
+ else if (cssSelectorReplacement && cssSelectorReplacement.universal) {
16
+ selector.value = cssSelectorReplacement.universal;
17
+ }
13
18
  }
14
19
  if (selector.type === 'selector') {
15
20
  const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
16
21
  node && selector.remove();
17
22
  }
23
+ if (selector.type === 'pseudo' && selector.value === ':root' && cssSelectorReplacement && cssSelectorReplacement.root) {
24
+ selector.value = cssSelectorReplacement.root;
25
+ }
18
26
  if (selector.type === 'class') {
19
27
  selector.value = internalCssSelectorReplacer(selector.value, {
20
28
  escapeMap,
@@ -295,8 +303,11 @@ function remakeCssVarSelector(selectors, cssPreflightRange) {
295
303
  function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
296
304
  let childCombinatorReplaceValue = 'view + view';
297
305
  if (Array.isArray(cssChildCombinatorReplaceValue)) {
298
- const part = cssChildCombinatorReplaceValue.join(',');
299
- childCombinatorReplaceValue = [part, ' + ', part].join('');
306
+ childCombinatorReplaceValue = cssChildCombinatorReplaceValue
307
+ .map((x) => {
308
+ return x + ' + ' + x;
309
+ })
310
+ .join(',');
300
311
  }
301
312
  else if (typeof cssChildCombinatorReplaceValue === 'string') {
302
313
  childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
@@ -343,6 +354,12 @@ const postcssWeappTailwindcss = (options = {
343
354
  isMainChunk && commonChunkPreflight(rule, options);
344
355
  isCustomRuleCallbackFn && customRuleCallback(rule, options);
345
356
  });
357
+ },
358
+ AtRule(atRule) {
359
+ if (atRule.name === 'media' && /\(hover:\s*hover\)/.test(atRule.params)) {
360
+ atRule.before(atRule.nodes);
361
+ atRule.remove();
362
+ }
346
363
  }
347
364
  };
348
365
  };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var selectorParser = require('postcss-selector-parser');
4
- var shared = require('./shared-df9de23f.js');
4
+ var shared = require('./shared-8b9be5f0.js');
5
5
  var postcss = require('postcss');
6
6
  require('@csstools/postcss-is-pseudo-class');
7
7
 
@@ -10,17 +10,25 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
10
10
  var selectorParser__default = /*#__PURE__*/_interopDefaultCompat(selectorParser);
11
11
 
12
12
  const createTransform = (rule, options) => {
13
- const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
13
+ const { replaceUniversalSelectorWith, escapeMap, mangleContext, cssSelectorReplacement } = options;
14
14
  const replaceFlag = replaceUniversalSelectorWith !== false;
15
15
  const transform = (selectors) => {
16
16
  selectors.walk((selector) => {
17
- if (selector.type === 'universal' && replaceFlag) {
18
- selector.value = replaceUniversalSelectorWith;
17
+ if (selector.type === 'universal') {
18
+ if (replaceFlag) {
19
+ selector.value = replaceUniversalSelectorWith;
20
+ }
21
+ else if (cssSelectorReplacement && cssSelectorReplacement.universal) {
22
+ selector.value = cssSelectorReplacement.universal;
23
+ }
19
24
  }
20
25
  if (selector.type === 'selector') {
21
26
  const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
22
27
  node && selector.remove();
23
28
  }
29
+ if (selector.type === 'pseudo' && selector.value === ':root' && cssSelectorReplacement && cssSelectorReplacement.root) {
30
+ selector.value = cssSelectorReplacement.root;
31
+ }
24
32
  if (selector.type === 'class') {
25
33
  selector.value = shared.internalCssSelectorReplacer(selector.value, {
26
34
  escapeMap,
@@ -301,8 +309,11 @@ function remakeCssVarSelector(selectors, cssPreflightRange) {
301
309
  function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
302
310
  let childCombinatorReplaceValue = 'view + view';
303
311
  if (Array.isArray(cssChildCombinatorReplaceValue)) {
304
- const part = cssChildCombinatorReplaceValue.join(',');
305
- childCombinatorReplaceValue = [part, ' + ', part].join('');
312
+ childCombinatorReplaceValue = cssChildCombinatorReplaceValue
313
+ .map((x) => {
314
+ return x + ' + ' + x;
315
+ })
316
+ .join(',');
306
317
  }
307
318
  else if (typeof cssChildCombinatorReplaceValue === 'string') {
308
319
  childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
@@ -349,6 +360,12 @@ const postcssWeappTailwindcss = (options = {
349
360
  isMainChunk && commonChunkPreflight(rule, options);
350
361
  isCustomRuleCallbackFn && customRuleCallback(rule, options);
351
362
  });
363
+ },
364
+ AtRule(atRule) {
365
+ if (atRule.name === 'media' && /\(hover:\s*hover\)/.test(atRule.params)) {
366
+ atRule.before(atRule.nodes);
367
+ atRule.remove();
368
+ }
352
369
  }
353
370
  };
354
371
  };
package/dist/postcss.js CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var postcss = require('./postcss-4e99a8e8.js');
5
+ var postcss = require('./postcss-8d7f67b4.js');
6
6
  var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
7
7
  require('postcss-selector-parser');
8
- require('./shared-df9de23f.js');
8
+ require('./shared-8b9be5f0.js');
9
9
  require('@weapp-core/escape');
10
+ require('@ast-core/escape');
10
11
  require('postcss');
11
12
 
12
13
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
package/dist/postcss.mjs CHANGED
@@ -1,6 +1,7 @@
1
- export { p as postcssWeappTailwindcss } from './postcss-a551ddc0.mjs';
1
+ export { p as postcssWeappTailwindcss } from './postcss-55ed4d42.mjs';
2
2
  export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
3
3
  import 'postcss-selector-parser';
4
- import './shared-fd149084.mjs';
4
+ import './shared-283aac78.mjs';
5
5
  import '@weapp-core/escape';
6
+ import '@ast-core/escape';
6
7
  import 'postcss';
package/dist/replace.js CHANGED
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var escape = require('@weapp-core/escape');
6
- var shared = require('./shared-df9de23f.js');
6
+ require('@ast-core/escape');
7
+ var shared = require('./shared-8b9be5f0.js');
7
8
 
8
9
  function replaceWxml(original, options = {
9
10
  keepEOL: false,
package/dist/replace.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { escape, SimpleMappingChars2String } from '@weapp-core/escape';
2
2
  export { MappingChars2String, MappingChars2StringEntries, SYMBOL_TABLE, SimpleMappingChars2String, SimpleMappingChars2StringEntries } from '@weapp-core/escape';
3
- export { i as replaceCss } from './shared-fd149084.mjs';
3
+ import '@ast-core/escape';
4
+ export { i as replaceCss } from './shared-283aac78.mjs';
4
5
 
5
6
  function replaceWxml(original, options = {
6
7
  keepEOL: false,
@@ -1,4 +1,5 @@
1
1
  import { escape, SimpleMappingChars2String } from '@weapp-core/escape';
2
+ import '@ast-core/escape';
2
3
 
3
4
  function internalCssSelectorReplacer(selectors, options = {
4
5
  escapeMap: SimpleMappingChars2String
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var escape = require('@weapp-core/escape');
4
+ require('@ast-core/escape');
4
5
 
5
6
  function internalCssSelectorReplacer(selectors, options = {
6
7
  escapeMap: escape.SimpleMappingChars2String
package/dist/types.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { Rule } from 'postcss';
2
2
  import type { IClassGeneratorOptions, ClassGenerator } from '@tailwindcss-mangle/shared';
3
+ import type { SourceMap } from 'magic-string';
4
+ import type { GeneratorResult } from '@babel/generator';
3
5
  import type { InjectPreflight } from './postcss/preflight';
4
6
  export type ItemOrItemArray<T> = T | T[];
5
7
  export type AppType = 'uni-app' | 'uni-app-vite' | 'taro' | 'remax' | 'rax' | 'native' | 'kbone' | 'mpx';
@@ -14,12 +16,8 @@ export type CssPreflightOptions = {
14
16
  export type RequiredStyleHandlerOptions = {
15
17
  isMainChunk: boolean;
16
18
  cssInjectPreflight?: InjectPreflight;
17
- cssPreflightRange?: 'view' | 'all';
18
- cssChildCombinatorReplaceValue?: string | string[];
19
- replaceUniversalSelectorWith?: string | false;
20
19
  escapeMap?: Record<string, string>;
21
- injectAdditionalCssVarScope?: boolean;
22
- };
20
+ } & Pick<UserDefinedOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'replaceUniversalSelectorWith' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement'>;
23
21
  export type CustomRuleCallback = (node: Rule, options: Readonly<RequiredStyleHandlerOptions>) => void;
24
22
  export interface InternalCssSelectorReplacerOptions {
25
23
  mangleContext?: IMangleScopeContext;
@@ -29,6 +27,11 @@ export type IStyleHandlerOptions = {
29
27
  customRuleCallback?: CustomRuleCallback;
30
28
  mangleContext?: IMangleScopeContext;
31
29
  } & RequiredStyleHandlerOptions;
30
+ export type JsHandlerReplaceResult = {
31
+ code: string;
32
+ map?: SourceMap;
33
+ };
34
+ export type JsHandlerResult = JsHandlerReplaceResult | GeneratorResult;
32
35
  export type ICustomAttributes = Record<string, ItemOrItemArray<string | RegExp>> | Map<string | RegExp, ItemOrItemArray<string | RegExp>>;
33
36
  export type ICustomAttributesEntities = [string | RegExp, ItemOrItemArray<string | RegExp>][];
34
37
  export type IJsHandlerOptions = {
@@ -40,6 +43,7 @@ export type IJsHandlerOptions = {
40
43
  jsPreserveClass?: (keyword: string) => boolean | undefined;
41
44
  strategy?: UserDefinedOptions['jsEscapeStrategy'];
42
45
  needEscaped?: boolean;
46
+ generateMap?: boolean;
43
47
  };
44
48
  export interface RawSource {
45
49
  start: number;
@@ -97,7 +101,12 @@ export interface UserDefinedOptions {
97
101
  disabledDefaultTemplateHandler?: boolean;
98
102
  jsEscapeStrategy?: 'regenerate' | 'replace';
99
103
  runtimeLoaderPath?: string;
104
+ cssSelectorReplacement?: {
105
+ root?: string | false;
106
+ universal?: string | false;
107
+ };
100
108
  }
109
+ export type JsHandler = (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult;
101
110
  export interface IMangleScopeContext {
102
111
  rawOptions: UserDefinedOptions['mangle'];
103
112
  runtimeSet: Set<string>;
@@ -116,9 +125,7 @@ export interface ITemplateHandlerOptions extends ICommonReplaceOptions {
116
125
  escapeMap?: Record<string, string>;
117
126
  mangleContext?: IMangleScopeContext;
118
127
  inlineWxs?: boolean;
119
- jsHandler?: (rawSource: string, set: Set<string>) => {
120
- code: string;
121
- };
128
+ jsHandler?: JsHandler;
122
129
  runtimeSet?: Set<string>;
123
130
  disabledDefaultTemplateHandler?: boolean;
124
131
  }
@@ -129,9 +136,7 @@ export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobO
129
136
  supportCustomLengthUnitsPatch: ILengthUnitsPatchOptions | false;
130
137
  templateHandler: (rawSource: string, options?: ITemplateHandlerOptions) => string;
131
138
  styleHandler: (rawSource: string, options: IStyleHandlerOptions) => string;
132
- jsHandler: (rawSource: string, set: Set<string>) => {
133
- code: string;
134
- };
139
+ jsHandler: JsHandler;
135
140
  escapeMap: Record<string, string>;
136
141
  patch: () => void;
137
142
  customReplaceDictionary: Record<string, string>;
@@ -148,3 +153,4 @@ export interface InternalPatchResult {
148
153
  processTailwindFeatures?: string;
149
154
  plugin?: string;
150
155
  }
156
+ export type CreateJsHandlerOptions = Omit<IJsHandlerOptions, 'classNameSet'>;
package/dist/vite.js CHANGED
@@ -2,14 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-4284d635.js');
6
- var postcss = require('./postcss-4e99a8e8.js');
7
- var defaults = require('./defaults-c6437917.js');
5
+ var options = require('./options-92c91aaa.js');
6
+ var postcss = require('./postcss-8d7f67b4.js');
7
+ var defaults = require('./defaults-263271f9.js');
8
8
  require('micromatch');
9
9
  require('magic-string');
10
10
  require('./replace.js');
11
11
  require('@weapp-core/escape');
12
- require('./shared-df9de23f.js');
12
+ require('@ast-core/escape');
13
+ require('./shared-8b9be5f0.js');
13
14
  require('@weapp-core/regex');
14
15
  require('@babel/generator');
15
16
  require('@babel/parser');
@@ -71,9 +72,16 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
71
72
  for (let i = 0; i < groupedEntries.js.length; i++) {
72
73
  const [file, originalSource] = groupedEntries.js[i];
73
74
  const rawSource = originalSource.code;
74
- const { code } = jsHandler(rawSource, runtimeSet);
75
+ const mapFilename = file + '.map';
76
+ const hasMap = Boolean(bundle[mapFilename]);
77
+ const { code, map } = jsHandler(rawSource, runtimeSet, {
78
+ generateMap: hasMap
79
+ });
75
80
  originalSource.code = code;
76
81
  onUpdate(file, rawSource, code);
82
+ if (hasMap && map) {
83
+ bundle[mapFilename].source = map.toString();
84
+ }
77
85
  }
78
86
  }
79
87
  onEnd();
package/dist/vite.mjs CHANGED
@@ -1,11 +1,12 @@
1
- import { g as getOptions, a as createTailwindcssPatcher } from './options-ad0be036.mjs';
2
- import { v as vitePluginName } from './postcss-a551ddc0.mjs';
3
- import { g as getGroupedEntries } from './defaults-72ea9566.mjs';
1
+ import { g as getOptions, a as createTailwindcssPatcher } from './options-673b7a98.mjs';
2
+ import { v as vitePluginName } from './postcss-55ed4d42.mjs';
3
+ import { g as getGroupedEntries } from './defaults-dc8a0e3d.mjs';
4
4
  import 'micromatch';
5
5
  import 'magic-string';
6
6
  import './replace.mjs';
7
7
  import '@weapp-core/escape';
8
- import './shared-fd149084.mjs';
8
+ import '@ast-core/escape';
9
+ import './shared-283aac78.mjs';
9
10
  import '@weapp-core/regex';
10
11
  import '@babel/generator';
11
12
  import '@babel/parser';
@@ -67,9 +68,16 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
67
68
  for (let i = 0; i < groupedEntries.js.length; i++) {
68
69
  const [file, originalSource] = groupedEntries.js[i];
69
70
  const rawSource = originalSource.code;
70
- const { code } = jsHandler(rawSource, runtimeSet);
71
+ const mapFilename = file + '.map';
72
+ const hasMap = Boolean(bundle[mapFilename]);
73
+ const { code, map } = jsHandler(rawSource, runtimeSet, {
74
+ generateMap: hasMap
75
+ });
71
76
  originalSource.code = code;
72
77
  onUpdate(file, rawSource, code);
78
+ if (hasMap && map) {
79
+ bundle[mapFilename].source = map.toString();
80
+ }
73
81
  }
74
82
  }
75
83
  onEnd();
package/dist/webpack.js CHANGED
@@ -4,14 +4,15 @@ 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-4284d635.js');
8
- var postcss = require('./postcss-4e99a8e8.js');
9
- var defaults = require('./defaults-c6437917.js');
7
+ var options = require('./options-92c91aaa.js');
8
+ var postcss = require('./postcss-8d7f67b4.js');
9
+ var defaults = require('./defaults-263271f9.js');
10
10
  require('micromatch');
11
11
  require('magic-string');
12
12
  require('./replace.js');
13
13
  require('@weapp-core/escape');
14
- require('./shared-df9de23f.js');
14
+ require('@ast-core/escape');
15
+ require('./shared-8b9be5f0.js');
15
16
  require('@weapp-core/regex');
16
17
  require('@babel/generator');
17
18
  require('@babel/parser');
@@ -45,7 +46,7 @@ class UnifiedWebpackPluginV5 {
45
46
  }
46
47
  patch === null || patch === void 0 ? void 0 : patch();
47
48
  const { Compilation, sources, NormalModule } = compiler.webpack;
48
- const { ConcatSource } = sources;
49
+ const { ConcatSource, RawSource } = sources;
49
50
  const twPatcher = options.createTailwindcssPatcher();
50
51
  function getClassSet() {
51
52
  return twPatcher.getClassSet();
@@ -95,10 +96,18 @@ class UnifiedWebpackPluginV5 {
95
96
  for (let i = 0; i < groupedEntries.js.length; i++) {
96
97
  const [file, originalSource] = groupedEntries.js[i];
97
98
  const rawSource = originalSource.source().toString();
98
- const { code } = jsHandler(rawSource, runtimeSet);
99
+ const mapFilename = file + '.map';
100
+ const hasMap = Boolean(assets[mapFilename]);
101
+ const { code, map } = jsHandler(rawSource, runtimeSet, {
102
+ generateMap: hasMap
103
+ });
99
104
  const source = new ConcatSource(code);
100
105
  compilation.updateAsset(file, source);
101
106
  onUpdate(file, rawSource, code);
107
+ if (hasMap && map) {
108
+ const source = new RawSource(map.toString());
109
+ compilation.updateAsset(mapFilename, source);
110
+ }
102
111
  }
103
112
  }
104
113
  if (Array.isArray(groupedEntries.css)) {
package/dist/webpack.mjs CHANGED
@@ -1,13 +1,14 @@
1
1
  import path from 'node:path';
2
2
  import fs from 'node:fs';
3
- import { g as getOptions, a as createTailwindcssPatcher } from './options-ad0be036.mjs';
4
- import { a as pluginName } from './postcss-a551ddc0.mjs';
5
- import { g as getGroupedEntries } from './defaults-72ea9566.mjs';
3
+ import { g as getOptions, a as createTailwindcssPatcher } from './options-673b7a98.mjs';
4
+ import { a as pluginName } from './postcss-55ed4d42.mjs';
5
+ import { g as getGroupedEntries } from './defaults-dc8a0e3d.mjs';
6
6
  import 'micromatch';
7
7
  import 'magic-string';
8
8
  import './replace.mjs';
9
9
  import '@weapp-core/escape';
10
- import './shared-fd149084.mjs';
10
+ import '@ast-core/escape';
11
+ import './shared-283aac78.mjs';
11
12
  import '@weapp-core/regex';
12
13
  import '@babel/generator';
13
14
  import '@babel/parser';
@@ -36,7 +37,7 @@ class UnifiedWebpackPluginV5 {
36
37
  }
37
38
  patch === null || patch === void 0 ? void 0 : patch();
38
39
  const { Compilation, sources, NormalModule } = compiler.webpack;
39
- const { ConcatSource } = sources;
40
+ const { ConcatSource, RawSource } = sources;
40
41
  const twPatcher = createTailwindcssPatcher();
41
42
  function getClassSet() {
42
43
  return twPatcher.getClassSet();
@@ -86,10 +87,18 @@ class UnifiedWebpackPluginV5 {
86
87
  for (let i = 0; i < groupedEntries.js.length; i++) {
87
88
  const [file, originalSource] = groupedEntries.js[i];
88
89
  const rawSource = originalSource.source().toString();
89
- const { code } = jsHandler(rawSource, runtimeSet);
90
+ const mapFilename = file + '.map';
91
+ const hasMap = Boolean(assets[mapFilename]);
92
+ const { code, map } = jsHandler(rawSource, runtimeSet, {
93
+ generateMap: hasMap
94
+ });
90
95
  const source = new ConcatSource(code);
91
96
  compilation.updateAsset(file, source);
92
97
  onUpdate(file, rawSource, code);
98
+ if (hasMap && map) {
99
+ const source = new RawSource(map.toString());
100
+ compilation.updateAsset(mapFilename, source);
101
+ }
93
102
  }
94
103
  }
95
104
  if (Array.isArray(groupedEntries.css)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "把tailwindcss jit引擎,带给小程序开发者们! bring tailwindcss jit engine to miniprogram developers!",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -102,33 +102,34 @@
102
102
  },
103
103
  "homepage": "https://weapp-tw.icebreaker.top",
104
104
  "devDependencies": {
105
- "@babel/core": "^7.22.10",
105
+ "@babel/core": "^7.22.17",
106
106
  "@icebreakers/cli": "0.1.1",
107
107
  "@icebreakers/readme": "0.1.0",
108
108
  "@rollup/plugin-alias": "^5.0.0",
109
109
  "@rollup/plugin-commonjs": "^25.0.4",
110
110
  "@rollup/plugin-json": "^6.0.0",
111
- "@rollup/plugin-node-resolve": "^15.2.0",
111
+ "@rollup/plugin-node-resolve": "^15.2.1",
112
112
  "@rollup/plugin-terser": "^0.4.3",
113
- "@rollup/plugin-typescript": "^11.1.2",
113
+ "@rollup/plugin-typescript": "^11.1.3",
114
114
  "@tsconfig/recommended": "^1.0.2",
115
115
  "@types/babel__generator": "^7.6.4",
116
116
  "@types/babel__traverse": "^7.20.1",
117
+ "@types/diff": "^5.0.3",
117
118
  "@types/fs-extra": "^11.0.1",
118
119
  "@types/gulp": "^4.0.13",
119
120
  "@types/gulp-postcss": "^8.0.3",
120
- "@types/jest": "^29.5.3",
121
+ "@types/jest": "^29.5.4",
121
122
  "@types/js-beautify": "^1.14.0",
122
123
  "@types/klaw": "^3.0.3",
123
- "@types/loader-utils": "^2.0.3",
124
- "@types/lodash": "^4.14.197",
124
+ "@types/loader-utils": "^2.0.4",
125
+ "@types/lodash": "^4.14.198",
125
126
  "@types/micromatch": "^4.0.2",
126
- "@types/node": "^20.5.1",
127
- "@types/semver": "^7.5.0",
127
+ "@types/node": "^20.5.9",
128
+ "@types/semver": "^7.5.1",
128
129
  "@types/vinyl": "^2.0.7",
129
- "@types/webpack": "^5.28.1",
130
+ "@types/webpack": "^5.28.2",
130
131
  "@types/webpack-sources": "^3.2.0",
131
- "@vitest/coverage-v8": "^0.34.2",
132
+ "@vitest/coverage-v8": "^0.34.4",
132
133
  "autoprefixer": "^10.4.15",
133
134
  "babel-loader": "^9.1.3",
134
135
  "bumpp": "^9.2.0",
@@ -137,9 +138,10 @@
137
138
  "css-loader": "^6.8.1",
138
139
  "dedent": "^1.5.1",
139
140
  "defu": "6.1.2",
140
- "del": "^7.0.0",
141
+ "del": "^7.1.0",
142
+ "diff": "^5.1.0",
141
143
  "domhandler": "^5.0.3",
142
- "eslint": "8.47.0",
144
+ "eslint": "8.48.0",
143
145
  "eslint-config-icebreaker": "^1.2.2",
144
146
  "eslint-config-prettier": "^9.0.0",
145
147
  "eslint-plugin-prettier": "^5.0.0",
@@ -149,7 +151,7 @@
149
151
  "gulp": "^4.0.2",
150
152
  "gulp-postcss": "^9.0.1",
151
153
  "html-loader": "^4.2.0",
152
- "jest": "^29.6.3",
154
+ "jest": "^29.6.4",
153
155
  "js-beautify": "^1.14.9",
154
156
  "klaw": "^4.1.0",
155
157
  "lodash": "^4.17.21",
@@ -159,9 +161,9 @@
159
161
  "postcss-load-config": "^4.0.1",
160
162
  "postcss-loader": "^7.3.3",
161
163
  "postcss-rem-to-responsive-pixel": "^5.1.3",
162
- "prettier": "^3.0.2",
164
+ "prettier": "^3.0.3",
163
165
  "promisify-loader-runner": "^1.0.0",
164
- "rollup": "^3.28.0",
166
+ "rollup": "^3.29.0",
165
167
  "rollup-plugin-visualizer": "^5.9.2",
166
168
  "style-loader": "^3.3.3",
167
169
  "tailwind-children": "^0.5.0",
@@ -169,31 +171,32 @@
169
171
  "ts-jest": "^29.1.1",
170
172
  "ts-node": "^10.9.1",
171
173
  "ts-patch": "^3.0.2",
172
- "tsd": "^0.28.1",
174
+ "tsd": "^0.29.0",
173
175
  "tslib": "^2.6.2",
174
- "typescript": "^5.1.6",
176
+ "typescript": "^5.2.2",
175
177
  "typescript-transform-paths": "^3.4.6",
176
178
  "vinyl": "^3.0.0",
177
179
  "vite": "^4.4.9",
178
- "vitest": "^0.34.2",
180
+ "vitest": "^0.34.4",
179
181
  "weapp-tailwindcss-children": "^0.1.0",
180
182
  "webpack": "^5.88.2",
181
183
  "webpack-build-utils": "^0.0.4"
182
184
  },
183
185
  "dependencies": {
184
- "@babel/generator": "^7.22.10",
185
- "@babel/parser": "^7.22.10",
186
- "@babel/traverse": "^7.22.10",
187
- "@babel/types": "^7.22.10",
188
- "@csstools/postcss-is-pseudo-class": "^4.0.0",
186
+ "@ast-core/escape": "^1.0.1",
187
+ "@babel/generator": "^7.22.15",
188
+ "@babel/parser": "^7.22.16",
189
+ "@babel/traverse": "^7.22.17",
190
+ "@babel/types": "^7.22.17",
191
+ "@csstools/postcss-is-pseudo-class": "^4.0.1",
189
192
  "@tailwindcss-mangle/shared": "^2.1.0",
190
- "@weapp-core/escape": "^1.1.0",
191
- "@weapp-core/regex": "^1.0.0",
193
+ "@weapp-core/escape": "^2.0.0",
194
+ "@weapp-core/regex": "^1.0.1",
192
195
  "htmlparser2": "^9.0.0",
193
196
  "loader-utils": "^2.0.3",
194
197
  "magic-string": "^0.30.3",
195
198
  "micromatch": "^4.0.5",
196
- "postcss": "8.4.28",
199
+ "postcss": "8.4.29",
197
200
  "postcss-selector-parser": "^6.0.13",
198
201
  "semver": "^7.5.4",
199
202
  "tailwindcss-patch": "^2.1.1"