weapp-tailwindcss 2.6.0 → 2.6.2

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.
@@ -4,10 +4,11 @@ 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-7c88fb94.mjs';
7
+ import { i as isRegexp, n as noop, d as defaultOptions, a as isMap } from './defaults-c397b5f9.mjs';
8
8
  import postcss from 'postcss';
9
- import { p as postcssWeappTailwindcss } from './postcss-760298ba.mjs';
9
+ import { p as postcssWeappTailwindcss } from './postcss-99efb521.mjs';
10
10
  import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
11
+ import { S as SimpleMappingChars2String, M as MappingChars2String } from './dic-3790a3a4.mjs';
11
12
  import path from 'node:path';
12
13
  import fs from 'node:fs';
13
14
  import { gte } from 'semver';
@@ -56,52 +57,6 @@ function createDefu(merger) {
56
57
  }
57
58
  const defu = createDefu();
58
59
 
59
- function isRegexp(value) {
60
- return Object.prototype.toString.call(value) === '[object RegExp]';
61
- }
62
- function isMap(value) {
63
- return Object.prototype.toString.call(value) === '[object Map]';
64
- }
65
- const noop = () => { };
66
- function groupBy(arr, cb) {
67
- if (!Array.isArray(arr)) {
68
- throw new TypeError('expected an array for first argument');
69
- }
70
- if (typeof cb !== 'function') {
71
- throw new TypeError('expected a function for second argument');
72
- }
73
- const result = {};
74
- for (const item of arr) {
75
- const bucketCategory = cb(item);
76
- const bucket = result[bucketCategory];
77
- if (Array.isArray(bucket)) {
78
- result[bucketCategory].push(item);
79
- }
80
- else {
81
- result[bucketCategory] = [item];
82
- }
83
- }
84
- return result;
85
- }
86
- function getGroupedEntries(entries, options) {
87
- const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
88
- const groupedEntries = groupBy(entries, ([file]) => {
89
- if (cssMatcher(file)) {
90
- return 'css';
91
- }
92
- else if (htmlMatcher(file)) {
93
- return 'html';
94
- }
95
- else if (jsMatcher(file) || wxsMatcher(file)) {
96
- return 'js';
97
- }
98
- else {
99
- return 'other';
100
- }
101
- });
102
- return groupedEntries;
103
- }
104
-
105
60
  function escapeStringRegexp(str) {
106
61
  if (typeof str !== 'string') {
107
62
  throw new TypeError('Expected a string');
@@ -109,7 +64,7 @@ function escapeStringRegexp(str) {
109
64
  return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d');
110
65
  }
111
66
  const templateClassExactRegexp = /(?<=^|\s)(?:hover-)?class=(?:["']\W+\s*\w+\()?["']([^"]+)["']/gs;
112
- const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?clas{2}="[^"]*"[^>]*?\/?>/g;
67
+ const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?class="[^"]*"[^>]*?\/?>/g;
113
68
  function handleRegexp(reg) {
114
69
  return `(?:${reg.source})`;
115
70
  }
@@ -149,7 +104,7 @@ function makePattern(arr) {
149
104
  }
150
105
  return pattern;
151
106
  }
152
- function createTempleteHandlerMatchRegexp(tag, attrs, options = {}) {
107
+ function createTemplateHandlerMatchRegexp(tag, attrs, options = {}) {
153
108
  const { exact = true } = options;
154
109
  const prefix = exact ? '(?<=^|\\s)' : '';
155
110
  const pattern = makePattern(attrs);
@@ -171,7 +126,7 @@ function makeCustomAttributes(entries) {
171
126
  if (Array.isArray(entries)) {
172
127
  return entries.map(([k, v]) => {
173
128
  return {
174
- tagRegexp: createTempleteHandlerMatchRegexp(k, v),
129
+ tagRegexp: createTemplateHandlerMatchRegexp(k, v),
175
130
  attrRegexp: createTemplateClassRegexp(v),
176
131
  tag: getSourceString(k),
177
132
  attrs: v
@@ -199,10 +154,11 @@ function handleValue(str, node, options) {
199
154
  const escapeMap = options.escapeMap;
200
155
  const allowDoubleQuotes = (_a = options.arbitraryValues) === null || _a === void 0 ? void 0 : _a.allowDoubleQuotes;
201
156
  const ctx = options.mangleContext;
157
+ const jsPreserveClass = options.jsPreserveClass;
202
158
  const arr = splitCode(str, allowDoubleQuotes);
203
159
  let rawStr = str;
204
160
  for (const v of arr) {
205
- if (set.has(v)) {
161
+ if (set.has(v) && !(jsPreserveClass === null || jsPreserveClass === void 0 ? void 0 : jsPreserveClass(v))) {
206
162
  let ignoreFlag = false;
207
163
  if (Array.isArray(node.leadingComments)) {
208
164
  ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes('weapp-tw') && x.value.includes('ignore')) > -1;
@@ -256,96 +212,19 @@ function jsHandler(rawSource, options) {
256
212
  });
257
213
  }
258
214
  function createjsHandler(options) {
259
- const { mangleContext, arbitraryValues, minifiedJs, escapeMap } = options;
215
+ const { mangleContext, arbitraryValues, minifiedJs, escapeMap, jsPreserveClass } = options;
260
216
  return (rawSource, set) => {
261
217
  return jsHandler(rawSource, {
262
218
  classNameSet: set,
263
219
  minifiedJs,
264
220
  escapeMap,
265
221
  arbitraryValues,
266
- mangleContext
222
+ mangleContext,
223
+ jsPreserveClass
267
224
  });
268
225
  };
269
226
  }
270
227
 
271
- const defaultOptions = {
272
- cssMatcher: (file) => /.+\.(?:wx|ac|jx|tt|q|c)ss$/.test(file),
273
- htmlMatcher: (file) => /.+\.(?:(?:(?:wx|ax|jx|ks|tt|q)ml)|swan)$/.test(file),
274
- jsMatcher: (file) => {
275
- if (file.includes('node_modules')) {
276
- return false;
277
- }
278
- return /.+\.[cm]?js?$/.test(file);
279
- },
280
- mainCssChunkMatcher: (file, appType) => {
281
- switch (appType) {
282
- case 'uni-app': {
283
- return /^common\/main/.test(file);
284
- }
285
- case 'uni-app-vite': {
286
- return file.startsWith('app') || /^common\/main/.test(file);
287
- }
288
- case 'mpx': {
289
- return file.startsWith('app');
290
- }
291
- case 'taro': {
292
- return file.startsWith('app');
293
- }
294
- case 'remax': {
295
- return file.startsWith('app');
296
- }
297
- case 'rax': {
298
- return file.startsWith('bundle');
299
- }
300
- case 'native': {
301
- return file.startsWith('app');
302
- }
303
- case 'kbone': {
304
- return /^(?:common\/)?miniprogram-app/.test(file);
305
- }
306
- default: {
307
- return true;
308
- }
309
- }
310
- },
311
- wxsMatcher: (file) => {
312
- return false;
313
- },
314
- cssPreflight: {
315
- 'box-sizing': 'border-box',
316
- 'border-width': '0',
317
- 'border-style': 'solid',
318
- 'border-color': 'currentColor'
319
- },
320
- cssPreflightRange: 'view',
321
- replaceUniversalSelectorWith: 'view',
322
- disabled: false,
323
- customRuleCallback: noop,
324
- onLoad: noop,
325
- onStart: noop,
326
- onEnd: noop,
327
- onUpdate: noop,
328
- customAttributes: {},
329
- customReplaceDictionary: SimpleMappingChars2String,
330
- supportCustomLengthUnitsPatch: {
331
- units: ['rpx'],
332
- dangerousOptions: {
333
- gteVersion: '3.0.0',
334
- lengthUnitsFilePath: 'lib/util/dataTypes.js',
335
- packageName: 'tailwindcss',
336
- variableName: 'lengthUnits',
337
- overwrite: true
338
- }
339
- },
340
- appType: undefined,
341
- arbitraryValues: {
342
- allowDoubleQuotes: false
343
- },
344
- cssChildCombinatorReplaceValue: 'view + view',
345
- inlineWxs: false,
346
- injectAdditionalCssVarScope: false
347
- };
348
-
349
228
  function generateCode(match, options = {}) {
350
229
  const ast = parseExpression(match);
351
230
  traverse(ast, {
@@ -389,7 +268,7 @@ function extract(original, reg) {
389
268
  function extractSource(original) {
390
269
  return extract(original, variableRegExp);
391
270
  }
392
- function templeteReplacer(original, options = {}) {
271
+ function templateReplacer(original, options = {}) {
393
272
  const sources = extractSource(original);
394
273
  if (sources.length > 0) {
395
274
  const resultArray = [];
@@ -432,22 +311,25 @@ function templeteReplacer(original, options = {}) {
432
311
  });
433
312
  }
434
313
  }
435
- function templeteHandler(rawSource, options = {}) {
314
+ function templateHandler(rawSource, options = {}) {
315
+ if (options.disabledDefaultTemplateHandler) {
316
+ return rawSource;
317
+ }
436
318
  return rawSource.replace(tagWithEitherClassAndHoverClassRegexp, (m0) => {
437
319
  return m0.replace(templateClassExactRegexp, (m1, className) => {
438
- return m1.replace(className, templeteReplacer(className, options));
320
+ return m1.replace(className, templateReplacer(className, options));
439
321
  });
440
322
  });
441
323
  }
442
- function customTempleteHandler(rawSource, options) {
324
+ function customTemplateHandler(rawSource, options) {
443
325
  const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
444
- let source = templeteHandler(rawSource, options);
326
+ let source = templateHandler(rawSource, options);
445
327
  const regexps = makeCustomAttributes(customAttributesEntities);
446
328
  if (regexps && Array.isArray(regexps)) {
447
329
  for (const regexp of regexps) {
448
330
  source = source.replace(regexp.tagRegexp, (m0) => {
449
331
  return m0.replace(regexp.attrRegexp, (m1, className) => {
450
- return m1.replace(className, templeteReplacer(className, options));
332
+ return m1.replace(className, templateReplacer(className, options));
451
333
  });
452
334
  });
453
335
  }
@@ -461,9 +343,9 @@ function customTempleteHandler(rawSource, options) {
461
343
  }
462
344
  return source;
463
345
  }
464
- function createTempleteHandler(options = {}) {
346
+ function createTemplateHandler(options = {}) {
465
347
  return (rawSource, opt = {}) => {
466
- return customTempleteHandler(rawSource, defu(opt, options));
348
+ return customTemplateHandler(rawSource, defu(opt, options));
467
349
  };
468
350
  }
469
351
 
@@ -593,11 +475,13 @@ function internalPatch(pkgJsonPath, options, overwrite = true) {
593
475
  if (pkgJsonPath) {
594
476
  const pkgJson = require(pkgJsonPath);
595
477
  const dangerousOptions = options.dangerousOptions;
596
- if (gte(pkgJson.version, dangerousOptions.gteVersion)) {
478
+ const version = pkgJson.version;
479
+ if (gte(version, dangerousOptions.gteVersion)) {
597
480
  const rootDir = path.dirname(pkgJsonPath);
598
481
  const dataTypes = monkeyPatchForSupportingCustomUnit(rootDir, options);
599
482
  const result = monkeyPatchForExposingContext(rootDir, {
600
- overwrite
483
+ overwrite,
484
+ version
601
485
  });
602
486
  return Object.assign(Object.assign({}, result), { dataTypes });
603
487
  }
@@ -703,7 +587,7 @@ function getOptions(options = {}) {
703
587
  const result = defu(options, defaultOptions, {
704
588
  minifiedJs: isProd()
705
589
  });
706
- const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope } = result;
590
+ const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler } = result;
707
591
  result.escapeMap = customReplaceDictionary;
708
592
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
709
593
  const customAttributesEntities = isMap(options.customAttributes)
@@ -727,20 +611,22 @@ function getOptions(options = {}) {
727
611
  minifiedJs,
728
612
  escapeMap,
729
613
  mangleContext,
730
- arbitraryValues
614
+ arbitraryValues,
615
+ jsPreserveClass
731
616
  });
732
617
  result.jsHandler = jsHandler;
733
- const templeteHandler = createTempleteHandler({
618
+ const templateHandler = createTemplateHandler({
734
619
  customAttributesEntities,
735
620
  escapeMap,
736
621
  mangleContext,
737
622
  inlineWxs,
738
- jsHandler
623
+ jsHandler,
624
+ disabledDefaultTemplateHandler
739
625
  });
740
- result.templeteHandler = templeteHandler;
626
+ result.templateHandler = templateHandler;
741
627
  result.patch = createPatch(supportCustomLengthUnitsPatch);
742
628
  result.setMangleRuntimeSet = setMangleRuntimeSet;
743
629
  return result;
744
630
  }
745
631
 
746
- export { createTailwindcssPatcher as a, getGroupedEntries as b, createPatch as c, getOptions as g };
632
+ export { createTailwindcssPatcher as a, createPatch as c, getOptions as g };
@@ -6,10 +6,11 @@ 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-ae7dd073.js');
9
+ var defaults = require('./defaults-d79e9245.js');
10
10
  var postcss = require('postcss');
11
- var postcss$1 = require('./postcss-b53e9504.js');
11
+ var postcss$1 = require('./postcss-4c88cd6d.js');
12
12
  var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
13
+ var dic = require('./dic-05980807.js');
13
14
  var path = require('node:path');
14
15
  var fs = require('node:fs');
15
16
  var semver = require('semver');
@@ -86,52 +87,6 @@ function createDefu(merger) {
86
87
  }
87
88
  const defu = createDefu();
88
89
 
89
- function isRegexp(value) {
90
- return Object.prototype.toString.call(value) === '[object RegExp]';
91
- }
92
- function isMap(value) {
93
- return Object.prototype.toString.call(value) === '[object Map]';
94
- }
95
- const noop = () => { };
96
- function groupBy(arr, cb) {
97
- if (!Array.isArray(arr)) {
98
- throw new TypeError('expected an array for first argument');
99
- }
100
- if (typeof cb !== 'function') {
101
- throw new TypeError('expected a function for second argument');
102
- }
103
- const result = {};
104
- for (const item of arr) {
105
- const bucketCategory = cb(item);
106
- const bucket = result[bucketCategory];
107
- if (Array.isArray(bucket)) {
108
- result[bucketCategory].push(item);
109
- }
110
- else {
111
- result[bucketCategory] = [item];
112
- }
113
- }
114
- return result;
115
- }
116
- function getGroupedEntries(entries, options) {
117
- const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
118
- const groupedEntries = groupBy(entries, ([file]) => {
119
- if (cssMatcher(file)) {
120
- return 'css';
121
- }
122
- else if (htmlMatcher(file)) {
123
- return 'html';
124
- }
125
- else if (jsMatcher(file) || wxsMatcher(file)) {
126
- return 'js';
127
- }
128
- else {
129
- return 'other';
130
- }
131
- });
132
- return groupedEntries;
133
- }
134
-
135
90
  function escapeStringRegexp(str) {
136
91
  if (typeof str !== 'string') {
137
92
  throw new TypeError('Expected a string');
@@ -139,7 +94,7 @@ function escapeStringRegexp(str) {
139
94
  return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d');
140
95
  }
141
96
  const templateClassExactRegexp = /(?<=^|\s)(?:hover-)?class=(?:["']\W+\s*\w+\()?["']([^"]+)["']/gs;
142
- const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?clas{2}="[^"]*"[^>]*?\/?>/g;
97
+ const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?class="[^"]*"[^>]*?\/?>/g;
143
98
  function handleRegexp(reg) {
144
99
  return `(?:${reg.source})`;
145
100
  }
@@ -148,7 +103,7 @@ function getSourceString(input) {
148
103
  if (typeof input === 'string') {
149
104
  result = input;
150
105
  }
151
- else if (isRegexp(input)) {
106
+ else if (defaults.isRegexp(input)) {
152
107
  result = input.source;
153
108
  }
154
109
  else {
@@ -164,7 +119,7 @@ function makePattern(arr) {
164
119
  if (typeof cur === 'string') {
165
120
  acc.push(cur);
166
121
  }
167
- else if (isRegexp(cur)) {
122
+ else if (defaults.isRegexp(cur)) {
168
123
  acc.push(handleRegexp(cur));
169
124
  }
170
125
  return acc;
@@ -174,12 +129,12 @@ function makePattern(arr) {
174
129
  else if (typeof arr === 'string') {
175
130
  pattern = arr;
176
131
  }
177
- else if (isRegexp(arr)) {
132
+ else if (defaults.isRegexp(arr)) {
178
133
  pattern = handleRegexp(arr);
179
134
  }
180
135
  return pattern;
181
136
  }
182
- function createTempleteHandlerMatchRegexp(tag, attrs, options = {}) {
137
+ function createTemplateHandlerMatchRegexp(tag, attrs, options = {}) {
183
138
  const { exact = true } = options;
184
139
  const prefix = exact ? '(?<=^|\\s)' : '';
185
140
  const pattern = makePattern(attrs);
@@ -201,7 +156,7 @@ function makeCustomAttributes(entries) {
201
156
  if (Array.isArray(entries)) {
202
157
  return entries.map(([k, v]) => {
203
158
  return {
204
- tagRegexp: createTempleteHandlerMatchRegexp(k, v),
159
+ tagRegexp: createTemplateHandlerMatchRegexp(k, v),
205
160
  attrRegexp: createTemplateClassRegexp(v),
206
161
  tag: getSourceString(k),
207
162
  attrs: v
@@ -229,10 +184,11 @@ function handleValue(str, node, options) {
229
184
  const escapeMap = options.escapeMap;
230
185
  const allowDoubleQuotes = (_a = options.arbitraryValues) === null || _a === void 0 ? void 0 : _a.allowDoubleQuotes;
231
186
  const ctx = options.mangleContext;
187
+ const jsPreserveClass = options.jsPreserveClass;
232
188
  const arr = splitCode(str, allowDoubleQuotes);
233
189
  let rawStr = str;
234
190
  for (const v of arr) {
235
- if (set.has(v)) {
191
+ if (set.has(v) && !(jsPreserveClass === null || jsPreserveClass === void 0 ? void 0 : jsPreserveClass(v))) {
236
192
  let ignoreFlag = false;
237
193
  if (Array.isArray(node.leadingComments)) {
238
194
  ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes('weapp-tw') && x.value.includes('ignore')) > -1;
@@ -286,96 +242,19 @@ function jsHandler(rawSource, options) {
286
242
  });
287
243
  }
288
244
  function createjsHandler(options) {
289
- const { mangleContext, arbitraryValues, minifiedJs, escapeMap } = options;
245
+ const { mangleContext, arbitraryValues, minifiedJs, escapeMap, jsPreserveClass } = options;
290
246
  return (rawSource, set) => {
291
247
  return jsHandler(rawSource, {
292
248
  classNameSet: set,
293
249
  minifiedJs,
294
250
  escapeMap,
295
251
  arbitraryValues,
296
- mangleContext
252
+ mangleContext,
253
+ jsPreserveClass
297
254
  });
298
255
  };
299
256
  }
300
257
 
301
- const defaultOptions = {
302
- cssMatcher: (file) => /.+\.(?:wx|ac|jx|tt|q|c)ss$/.test(file),
303
- htmlMatcher: (file) => /.+\.(?:(?:(?:wx|ax|jx|ks|tt|q)ml)|swan)$/.test(file),
304
- jsMatcher: (file) => {
305
- if (file.includes('node_modules')) {
306
- return false;
307
- }
308
- return /.+\.[cm]?js?$/.test(file);
309
- },
310
- mainCssChunkMatcher: (file, appType) => {
311
- switch (appType) {
312
- case 'uni-app': {
313
- return /^common\/main/.test(file);
314
- }
315
- case 'uni-app-vite': {
316
- return file.startsWith('app') || /^common\/main/.test(file);
317
- }
318
- case 'mpx': {
319
- return file.startsWith('app');
320
- }
321
- case 'taro': {
322
- return file.startsWith('app');
323
- }
324
- case 'remax': {
325
- return file.startsWith('app');
326
- }
327
- case 'rax': {
328
- return file.startsWith('bundle');
329
- }
330
- case 'native': {
331
- return file.startsWith('app');
332
- }
333
- case 'kbone': {
334
- return /^(?:common\/)?miniprogram-app/.test(file);
335
- }
336
- default: {
337
- return true;
338
- }
339
- }
340
- },
341
- wxsMatcher: (file) => {
342
- return false;
343
- },
344
- cssPreflight: {
345
- 'box-sizing': 'border-box',
346
- 'border-width': '0',
347
- 'border-style': 'solid',
348
- 'border-color': 'currentColor'
349
- },
350
- cssPreflightRange: 'view',
351
- replaceUniversalSelectorWith: 'view',
352
- disabled: false,
353
- customRuleCallback: noop,
354
- onLoad: noop,
355
- onStart: noop,
356
- onEnd: noop,
357
- onUpdate: noop,
358
- customAttributes: {},
359
- customReplaceDictionary: shared.SimpleMappingChars2String,
360
- supportCustomLengthUnitsPatch: {
361
- units: ['rpx'],
362
- dangerousOptions: {
363
- gteVersion: '3.0.0',
364
- lengthUnitsFilePath: 'lib/util/dataTypes.js',
365
- packageName: 'tailwindcss',
366
- variableName: 'lengthUnits',
367
- overwrite: true
368
- }
369
- },
370
- appType: undefined,
371
- arbitraryValues: {
372
- allowDoubleQuotes: false
373
- },
374
- cssChildCombinatorReplaceValue: 'view + view',
375
- inlineWxs: false,
376
- injectAdditionalCssVarScope: false
377
- };
378
-
379
258
  function generateCode(match, options = {}) {
380
259
  const ast = parser.parseExpression(match);
381
260
  traverse__default["default"](ast, {
@@ -419,7 +298,7 @@ function extract(original, reg) {
419
298
  function extractSource(original) {
420
299
  return extract(original, variableRegExp);
421
300
  }
422
- function templeteReplacer(original, options = {}) {
301
+ function templateReplacer(original, options = {}) {
423
302
  const sources = extractSource(original);
424
303
  if (sources.length > 0) {
425
304
  const resultArray = [];
@@ -462,22 +341,25 @@ function templeteReplacer(original, options = {}) {
462
341
  });
463
342
  }
464
343
  }
465
- function templeteHandler(rawSource, options = {}) {
344
+ function templateHandler(rawSource, options = {}) {
345
+ if (options.disabledDefaultTemplateHandler) {
346
+ return rawSource;
347
+ }
466
348
  return rawSource.replace(tagWithEitherClassAndHoverClassRegexp, (m0) => {
467
349
  return m0.replace(templateClassExactRegexp, (m1, className) => {
468
- return m1.replace(className, templeteReplacer(className, options));
350
+ return m1.replace(className, templateReplacer(className, options));
469
351
  });
470
352
  });
471
353
  }
472
- function customTempleteHandler(rawSource, options) {
354
+ function customTemplateHandler(rawSource, options) {
473
355
  const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
474
- let source = templeteHandler(rawSource, options);
356
+ let source = templateHandler(rawSource, options);
475
357
  const regexps = makeCustomAttributes(customAttributesEntities);
476
358
  if (regexps && Array.isArray(regexps)) {
477
359
  for (const regexp of regexps) {
478
360
  source = source.replace(regexp.tagRegexp, (m0) => {
479
361
  return m0.replace(regexp.attrRegexp, (m1, className) => {
480
- return m1.replace(className, templeteReplacer(className, options));
362
+ return m1.replace(className, templateReplacer(className, options));
481
363
  });
482
364
  });
483
365
  }
@@ -491,9 +373,9 @@ function customTempleteHandler(rawSource, options) {
491
373
  }
492
374
  return source;
493
375
  }
494
- function createTempleteHandler(options = {}) {
376
+ function createTemplateHandler(options = {}) {
495
377
  return (rawSource, opt = {}) => {
496
- return customTempleteHandler(rawSource, defu(opt, options));
378
+ return customTemplateHandler(rawSource, defu(opt, options));
497
379
  };
498
380
  }
499
381
 
@@ -579,7 +461,7 @@ function getInstalledPkgJsonPath(options) {
579
461
  }
580
462
  function createPatch(options) {
581
463
  if (options === false) {
582
- return noop;
464
+ return defaults.noop;
583
465
  }
584
466
  return () => {
585
467
  try {
@@ -623,11 +505,13 @@ function internalPatch(pkgJsonPath, options, overwrite = true) {
623
505
  if (pkgJsonPath) {
624
506
  const pkgJson = require(pkgJsonPath);
625
507
  const dangerousOptions = options.dangerousOptions;
626
- if (semver.gte(pkgJson.version, dangerousOptions.gteVersion)) {
508
+ const version = pkgJson.version;
509
+ if (semver.gte(version, dangerousOptions.gteVersion)) {
627
510
  const rootDir = path__default["default"].dirname(pkgJsonPath);
628
511
  const dataTypes = monkeyPatchForSupportingCustomUnit(rootDir, options);
629
512
  const result = tailwindcssPatch.monkeyPatchForExposingContext(rootDir, {
630
- overwrite
513
+ overwrite,
514
+ version
631
515
  });
632
516
  return Object.assign(Object.assign({}, result), { dataTypes });
633
517
  }
@@ -720,23 +604,23 @@ function getOptions(options = {}) {
720
604
  options.supportCustomLengthUnitsPatch = undefined;
721
605
  }
722
606
  if (options.customReplaceDictionary === 'simple') {
723
- options.customReplaceDictionary = shared.SimpleMappingChars2String;
607
+ options.customReplaceDictionary = dic.SimpleMappingChars2String;
724
608
  }
725
609
  else if (options.customReplaceDictionary === 'complex') {
726
- options.customReplaceDictionary = shared.MappingChars2String;
610
+ options.customReplaceDictionary = dic.MappingChars2String;
727
611
  }
728
612
  normalizeMatcher(options, 'cssMatcher');
729
613
  normalizeMatcher(options, 'htmlMatcher');
730
614
  normalizeMatcher(options, 'jsMatcher');
731
615
  normalizeMatcher(options, 'wxsMatcher');
732
616
  normalizeMatcher(options, 'mainCssChunkMatcher');
733
- const result = defu(options, defaultOptions, {
617
+ const result = defu(options, defaults.defaultOptions, {
734
618
  minifiedJs: isProd()
735
619
  });
736
- const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope } = result;
620
+ const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler } = result;
737
621
  result.escapeMap = customReplaceDictionary;
738
622
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
739
- const customAttributesEntities = isMap(options.customAttributes)
623
+ const customAttributesEntities = defaults.isMap(options.customAttributes)
740
624
  ? [...options.customAttributes.entries()]
741
625
  : Object.entries(customAttributes);
742
626
  const { escapeMap, minifiedJs } = result;
@@ -757,17 +641,19 @@ function getOptions(options = {}) {
757
641
  minifiedJs,
758
642
  escapeMap,
759
643
  mangleContext,
760
- arbitraryValues
644
+ arbitraryValues,
645
+ jsPreserveClass
761
646
  });
762
647
  result.jsHandler = jsHandler;
763
- const templeteHandler = createTempleteHandler({
648
+ const templateHandler = createTemplateHandler({
764
649
  customAttributesEntities,
765
650
  escapeMap,
766
651
  mangleContext,
767
652
  inlineWxs,
768
- jsHandler
653
+ jsHandler,
654
+ disabledDefaultTemplateHandler
769
655
  });
770
- result.templeteHandler = templeteHandler;
656
+ result.templateHandler = templateHandler;
771
657
  result.patch = createPatch(supportCustomLengthUnitsPatch);
772
658
  result.setMangleRuntimeSet = setMangleRuntimeSet;
773
659
  return result;
@@ -775,5 +661,4 @@ function getOptions(options = {}) {
775
661
 
776
662
  exports.createPatch = createPatch;
777
663
  exports.createTailwindcssPatcher = createTailwindcssPatcher;
778
- exports.getGroupedEntries = getGroupedEntries;
779
664
  exports.getOptions = getOptions;
@@ -1,3 +1,2 @@
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;