weapp-tailwindcss 2.4.1 → 2.4.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.
@@ -6,14 +6,15 @@ 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-823d1fc1.js');
9
+ var shared = require('./shared-28d43730.js');
10
10
  var postcss = require('postcss');
11
- var postcss$1 = require('./postcss-06f57f3f.js');
11
+ var postcss$1 = require('./postcss-e0e5739b.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');
15
15
  var semver = require('semver');
16
16
  var tailwindcssPatch = require('tailwindcss-patch');
17
+ var tailwindcssMangleShared = require('tailwindcss-mangle-shared');
17
18
 
18
19
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
20
 
@@ -85,12 +86,152 @@ function createDefu(merger) {
85
86
  }
86
87
  const defu = createDefu();
87
88
 
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 } = 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)) {
126
+ return 'js';
127
+ }
128
+ else {
129
+ return 'other';
130
+ }
131
+ });
132
+ return groupedEntries;
133
+ }
134
+
135
+ function escapeStringRegexp(str) {
136
+ if (typeof str !== 'string') {
137
+ throw new TypeError('Expected a string');
138
+ }
139
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d');
140
+ }
141
+ const templateClassExactRegexp = /(?<=^|\s)(?:hover-)?class=(?:["']\W+\s*\w+\()?["']([^"]+)["']/gs;
142
+ const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?clas{2}="[^"]*"[^>]*?\/?>/g;
143
+ function handleRegexp(reg) {
144
+ return `(?:${reg.source})`;
145
+ }
146
+ function getSourceString(input) {
147
+ let result;
148
+ if (typeof input === 'string') {
149
+ result = input;
150
+ }
151
+ else if (isRegexp(input)) {
152
+ result = input.source;
153
+ }
154
+ else {
155
+ result = input.toString();
156
+ }
157
+ return result;
158
+ }
159
+ function makePattern(arr) {
160
+ let pattern = '';
161
+ if (Array.isArray(arr)) {
162
+ pattern = arr
163
+ .reduce((acc, cur) => {
164
+ if (typeof cur === 'string') {
165
+ acc.push(cur);
166
+ }
167
+ else if (isRegexp(cur)) {
168
+ acc.push(handleRegexp(cur));
169
+ }
170
+ return acc;
171
+ }, [])
172
+ .join('|');
173
+ }
174
+ else if (typeof arr === 'string') {
175
+ pattern = arr;
176
+ }
177
+ else if (isRegexp(arr)) {
178
+ pattern = handleRegexp(arr);
179
+ }
180
+ return pattern;
181
+ }
182
+ function createTempleteHandlerMatchRegexp(tag, attrs, options = {}) {
183
+ const { exact = true } = options;
184
+ const prefix = exact ? '(?<=^|\\s)' : '';
185
+ const pattern = makePattern(attrs);
186
+ let tagPattern = getSourceString(tag);
187
+ if (tagPattern === '*') {
188
+ tagPattern = '[a-z][-a-z]*[a-z]*';
189
+ }
190
+ const source = `<(${tagPattern})\\s+[^>]*?(?:${prefix}(${pattern})="(?:[^"]*)")[^>]*?\\/?>`;
191
+ return new RegExp(source, 'g');
192
+ }
193
+ function createTemplateClassRegexp(attrs, options = {}) {
194
+ const { exact = true } = options;
195
+ const prefix = exact ? '(?<=^|\\s)' : '';
196
+ const pattern = makePattern(attrs);
197
+ const source = `(?:${prefix}${pattern})=(?:["']\\W+\\s*(?:\\w+)\\()?["']([^"]+)['"]`;
198
+ return new RegExp(source, 'gs');
199
+ }
200
+ function makeCustomAttributes(entries) {
201
+ if (Array.isArray(entries)) {
202
+ return entries.map(([k, v]) => {
203
+ return {
204
+ tagRegexp: createTempleteHandlerMatchRegexp(k, v),
205
+ attrRegexp: createTemplateClassRegexp(v),
206
+ tag: getSourceString(k),
207
+ attrs: v
208
+ };
209
+ });
210
+ }
211
+ }
212
+ const variableRegExp = /{{(.*?)}}/gs;
213
+ function variableMatch(original) {
214
+ return variableRegExp.exec(original);
215
+ }
216
+
217
+ const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
218
+ function isValidSelector(selector = '') {
219
+ return validateFilterRE.test(selector);
220
+ }
221
+ const splitCode = (code, allowDoubleQuotes = false) => {
222
+ const splitter = allowDoubleQuotes ? /\s+/ : /\s+|"/;
223
+ return code.split(splitter).filter((element) => isValidSelector(element));
224
+ };
225
+
88
226
  const isProd = () => process.env.NODE_ENV === 'production';
89
227
 
90
228
  function handleValue(str, node, options) {
229
+ var _a;
91
230
  const set = options.classNameSet;
92
231
  const escapeMap = options.escapeMap;
93
- const arr = shared.splitCode(str);
232
+ const allowDoubleQuotes = (_a = options.arbitraryValues) === null || _a === void 0 ? void 0 : _a.allowDoubleQuotes;
233
+ const ctx = options.mangleContext;
234
+ const arr = splitCode(str, allowDoubleQuotes);
94
235
  let rawStr = str;
95
236
  for (const v of arr) {
96
237
  if (set.has(v)) {
@@ -99,9 +240,10 @@ function handleValue(str, node, options) {
99
240
  ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes('weapp-tw') && x.value.includes('ignore')) > -1;
100
241
  }
101
242
  if (!ignoreFlag) {
102
- const { jsHandler } = shared.useStore();
103
- rawStr = jsHandler(rawStr);
104
- rawStr = rawStr.replaceAll(new RegExp(shared.escapeStringRegexp(v), 'g'), replace.replaceJs(v, {
243
+ if (ctx) {
244
+ rawStr = ctx.jsHandler(rawStr);
245
+ }
246
+ rawStr = rawStr.replaceAll(new RegExp(escapeStringRegexp(v), 'g'), replace.replaceJs(v, {
105
247
  escapeMap
106
248
  }));
107
249
  }
@@ -146,11 +288,14 @@ function jsHandler(rawSource, options) {
146
288
  });
147
289
  }
148
290
  function createjsHandler(options) {
291
+ const { mangleContext, arbitraryValues, minifiedJs, escapeMap } = options;
149
292
  return (rawSource, set) => {
150
293
  return jsHandler(rawSource, {
151
294
  classNameSet: set,
152
- minifiedJs: options.minifiedJs,
153
- escapeMap: options.escapeMap
295
+ minifiedJs,
296
+ escapeMap,
297
+ arbitraryValues,
298
+ mangleContext
154
299
  });
155
300
  };
156
301
  }
@@ -204,11 +349,11 @@ const defaultOptions = {
204
349
  cssPreflightRange: 'view',
205
350
  replaceUniversalSelectorWith: 'view',
206
351
  disabled: false,
207
- customRuleCallback: shared.noop,
208
- onLoad: shared.noop,
209
- onStart: shared.noop,
210
- onEnd: shared.noop,
211
- onUpdate: shared.noop,
352
+ customRuleCallback: noop,
353
+ onLoad: noop,
354
+ onStart: noop,
355
+ onEnd: noop,
356
+ onUpdate: noop,
212
357
  customAttributes: {},
213
358
  customReplaceDictionary: shared.SimpleMappingChars2String,
214
359
  supportCustomLengthUnitsPatch: {
@@ -221,7 +366,10 @@ const defaultOptions = {
221
366
  overwrite: true
222
367
  }
223
368
  },
224
- appType: undefined
369
+ appType: undefined,
370
+ arbitraryValues: {
371
+ allowDoubleQuotes: false
372
+ }
225
373
  };
226
374
 
227
375
  function generateCode(match, options = {}) {
@@ -250,11 +398,11 @@ function generateCode(match, options = {}) {
250
398
  return code;
251
399
  }
252
400
  function extractSource(original) {
253
- let match = shared.variableMatch(original);
401
+ let match = variableMatch(original);
254
402
  const sources = [];
255
403
  while (match !== null) {
256
404
  const start = match.index;
257
- const end = shared.variableRegExp.lastIndex;
405
+ const end = variableRegExp.lastIndex;
258
406
  sources.push({
259
407
  start,
260
408
  end,
@@ -262,7 +410,7 @@ function extractSource(original) {
262
410
  prevConcatenated: !/\s/.test(original[start - 1]),
263
411
  nextConcatenated: !/\s/.test(original[end])
264
412
  });
265
- match = shared.variableMatch(original);
413
+ match = variableMatch(original);
266
414
  }
267
415
  return sources;
268
416
  }
@@ -276,7 +424,8 @@ function templeteReplacer(original, options = {}) {
276
424
  const before = original.slice(p, m.start);
277
425
  resultArray.push(replace.replaceJs(before, {
278
426
  keepEOL: true,
279
- escapeMap: options.escapeMap
427
+ escapeMap: options.escapeMap,
428
+ mangleContext: options.mangleContext
280
429
  }));
281
430
  p = m.start;
282
431
  if (m.raw.trim().length > 0) {
@@ -293,7 +442,8 @@ function templeteReplacer(original, options = {}) {
293
442
  const after = original.slice(m.end);
294
443
  resultArray.push(replace.replaceJs(after, {
295
444
  keepEOL: true,
296
- escapeMap: options.escapeMap
445
+ escapeMap: options.escapeMap,
446
+ mangleContext: options.mangleContext
297
447
  }));
298
448
  }
299
449
  }
@@ -305,20 +455,21 @@ function templeteReplacer(original, options = {}) {
305
455
  else {
306
456
  return replace.replaceJs(original, {
307
457
  keepEOL: false,
308
- escapeMap: options.escapeMap
458
+ escapeMap: options.escapeMap,
459
+ mangleContext: options.mangleContext
309
460
  });
310
461
  }
311
462
  }
312
463
  function templeteHandler(rawSource, options = {}) {
313
- return rawSource.replace(shared.tagWithEitherClassAndHoverClassRegexp, (m0) => {
314
- return m0.replace(shared.templateClassExactRegexp, (m1, className) => {
464
+ return rawSource.replace(tagWithEitherClassAndHoverClassRegexp, (m0) => {
465
+ return m0.replace(templateClassExactRegexp, (m1, className) => {
315
466
  return m1.replace(className, templeteReplacer(className, options));
316
467
  });
317
468
  });
318
469
  }
319
470
  function customTempleteHandler(rawSource, options = {}) {
320
471
  let source = templeteHandler(rawSource, options);
321
- const regexps = shared.makeCustomAttributes(options.customAttributesEntities);
472
+ const regexps = makeCustomAttributes(options.customAttributesEntities);
322
473
  if (regexps) {
323
474
  if (Array.isArray(regexps)) {
324
475
  for (const regexp of regexps) {
@@ -423,7 +574,7 @@ function getInstalledPkgJsonPath(options) {
423
574
  }
424
575
  function createPatch(options) {
425
576
  if (options === false) {
426
- return shared.noop;
577
+ return noop;
427
578
  }
428
579
  return () => {
429
580
  try {
@@ -483,6 +634,72 @@ function createTailwindcssPatcher() {
483
634
  });
484
635
  }
485
636
 
637
+ function getSelf(x) {
638
+ return x;
639
+ }
640
+ const defaultMangleContext = {
641
+ rawOptions: false,
642
+ runtimeSet: new Set(),
643
+ classGenerator: new tailwindcssMangleShared.ClassGenerator(),
644
+ filter: tailwindcssMangleShared.defaultMangleClassFilter,
645
+ cssHandler: getSelf,
646
+ jsHandler: getSelf,
647
+ wxmlHandler: getSelf
648
+ };
649
+ function useMangleStore() {
650
+ const ctx = Object.assign({}, defaultMangleContext);
651
+ function resetMangle() {
652
+ return Object.assign(ctx, defaultMangleContext);
653
+ }
654
+ function handleValue(rawSource) {
655
+ const arr = splitCode(rawSource);
656
+ for (const x of arr) {
657
+ if (ctx.runtimeSet.has(x)) {
658
+ rawSource = rawSource.replaceAll(new RegExp(escapeStringRegexp(x), 'g'), ctx.classGenerator.generateClassName(x).name);
659
+ }
660
+ }
661
+ return rawSource;
662
+ }
663
+ function initMangle(options) {
664
+ var _a;
665
+ ctx.rawOptions = options;
666
+ if (options) {
667
+ if (options === true) {
668
+ options = {
669
+ classGenerator: {},
670
+ mangleClassFilter: tailwindcssMangleShared.defaultMangleClassFilter
671
+ };
672
+ }
673
+ ctx.classGenerator = new tailwindcssMangleShared.ClassGenerator(options.classGenerator);
674
+ ctx.filter = (_a = options.mangleClassFilter) !== null && _a !== void 0 ? _a : tailwindcssMangleShared.defaultMangleClassFilter;
675
+ ctx.jsHandler = (rawSource) => {
676
+ return handleValue(rawSource);
677
+ };
678
+ ctx.cssHandler = (rawSource) => {
679
+ return handleValue(rawSource);
680
+ };
681
+ ctx.wxmlHandler = (rawSource) => {
682
+ return handleValue(rawSource);
683
+ };
684
+ }
685
+ }
686
+ function setMangleRuntimeSet(runtimeSet) {
687
+ const newSet = new Set();
688
+ for (const c of runtimeSet) {
689
+ if (ctx.filter(c)) {
690
+ newSet.add(c);
691
+ }
692
+ }
693
+ ctx.runtimeSet = newSet;
694
+ }
695
+ return {
696
+ mangleContext: ctx,
697
+ resetMangle,
698
+ initMangle,
699
+ setMangleRuntimeSet
700
+ };
701
+ }
702
+
486
703
  function createGlobMatcher(pattern) {
487
704
  return function (file) {
488
705
  return micromatch.isMatch(file, pattern);
@@ -493,18 +710,7 @@ function normalizeMatcher(options, key) {
493
710
  options[key] = createGlobMatcher(options[key]);
494
711
  }
495
712
  }
496
- function getOptions(options = {}, modules = ['style', 'templete', 'patch', 'js']) {
497
- const registerModules = modules.reduce((acc, cur) => {
498
- if (acc[cur] !== undefined) {
499
- acc[cur] = true;
500
- }
501
- return acc;
502
- }, {
503
- templete: false,
504
- style: false,
505
- patch: false,
506
- js: false
507
- });
713
+ function getOptions(options = {}) {
508
714
  if (options.supportCustomLengthUnitsPatch === true) {
509
715
  options.supportCustomLengthUnitsPatch = undefined;
510
716
  }
@@ -521,38 +727,38 @@ function getOptions(options = {}, modules = ['style', 'templete', 'patch', 'js']
521
727
  const result = defu(options, defaultOptions, {
522
728
  minifiedJs: isProd()
523
729
  });
524
- const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch } = result;
730
+ const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues } = result;
525
731
  result.escapeMap = customReplaceDictionary;
526
732
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
527
- const customAttributesEntities = shared.isMap(options.customAttributes) ? [...options.customAttributes.entries()] : Object.entries(customAttributes);
733
+ const customAttributesEntities = isMap(options.customAttributes) ? [...options.customAttributes.entries()] : Object.entries(customAttributes);
528
734
  const { escapeMap, minifiedJs } = result;
529
- if (registerModules.templete) {
530
- result.templeteHandler = createTempleteHandler({
531
- customAttributesEntities,
532
- escapeMap
533
- });
534
- }
535
- if (registerModules.style) {
536
- result.styleHandler = createStyleHandler({
537
- cssInjectPreflight,
538
- customRuleCallback,
539
- cssPreflightRange,
540
- replaceUniversalSelectorWith,
541
- escapeMap
542
- });
543
- }
544
- if (registerModules.js) {
545
- result.jsHandler = createjsHandler({
546
- minifiedJs,
547
- escapeMap
548
- });
549
- }
550
- if (registerModules.patch) {
551
- result.patch = createPatch(supportCustomLengthUnitsPatch);
552
- }
735
+ const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
736
+ initMangle(options.mangle);
737
+ result.templeteHandler = createTempleteHandler({
738
+ customAttributesEntities,
739
+ escapeMap,
740
+ mangleContext,
741
+ });
742
+ result.styleHandler = createStyleHandler({
743
+ cssInjectPreflight,
744
+ customRuleCallback,
745
+ cssPreflightRange,
746
+ replaceUniversalSelectorWith,
747
+ escapeMap,
748
+ mangleContext,
749
+ });
750
+ result.jsHandler = createjsHandler({
751
+ minifiedJs,
752
+ escapeMap,
753
+ mangleContext,
754
+ arbitraryValues
755
+ });
756
+ result.patch = createPatch(supportCustomLengthUnitsPatch);
757
+ result.setMangleRuntimeSet = setMangleRuntimeSet;
553
758
  return result;
554
759
  }
555
760
 
556
761
  exports.createPatch = createPatch;
557
762
  exports.createTailwindcssPatcher = createTailwindcssPatcher;
763
+ exports.getGroupedEntries = getGroupedEntries;
558
764
  exports.getOptions = getOptions;
package/dist/options.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  import type { InternalUserDefinedOptions, UserDefinedOptions } from './types';
2
- type IModules = readonly ('js' | 'style' | 'templete' | 'patch')[];
3
- export declare function getOptions(options?: UserDefinedOptions, modules?: IModules): InternalUserDefinedOptions;
4
- export {};
2
+ export declare function getOptions(options?: UserDefinedOptions): InternalUserDefinedOptions;
@@ -1 +1,2 @@
1
- export declare function internalCssSelectorReplacer(selectors: string, map?: Record<string, string>): string;
1
+ import { InternalCssSelectorReplacerOptions } from "../types";
2
+ export declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
@@ -1,21 +1,25 @@
1
1
  import selectorParser from 'postcss-selector-parser';
2
- import { f as internalCssSelectorReplacer } from './shared-497eda3c.mjs';
2
+ import { i as internalCssSelectorReplacer } from './shared-31001503.mjs';
3
3
  import { Rule, Declaration } from 'postcss';
4
4
  import '@csstools/postcss-is-pseudo-class';
5
5
 
6
6
  const createTransform = (rule, options) => {
7
- const replaceFlag = options.replaceUniversalSelectorWith !== false;
7
+ const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
8
+ const replaceFlag = replaceUniversalSelectorWith !== false;
8
9
  const transform = (selectors) => {
9
10
  selectors.walk((selector) => {
10
11
  if (selector.type === 'universal' && replaceFlag) {
11
- selector.value = options.replaceUniversalSelectorWith;
12
+ selector.value = replaceUniversalSelectorWith;
12
13
  }
13
14
  if (selector.type === 'selector') {
14
15
  const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
15
16
  node && selector.remove();
16
17
  }
17
18
  if (selector.type === 'class') {
18
- selector.value = internalCssSelectorReplacer(selector.value, options.escapeMap);
19
+ selector.value = internalCssSelectorReplacer(selector.value, {
20
+ escapeMap,
21
+ mangleContext
22
+ });
19
23
  }
20
24
  });
21
25
  if (selectors.length === 0) {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var selectorParser = require('postcss-selector-parser');
4
- var shared = require('./shared-823d1fc1.js');
4
+ var shared = require('./shared-28d43730.js');
5
5
  var postcss = require('postcss');
6
6
  require('@csstools/postcss-is-pseudo-class');
7
7
 
@@ -10,18 +10,22 @@ 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 replaceFlag = options.replaceUniversalSelectorWith !== false;
13
+ const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
14
+ const replaceFlag = replaceUniversalSelectorWith !== false;
14
15
  const transform = (selectors) => {
15
16
  selectors.walk((selector) => {
16
17
  if (selector.type === 'universal' && replaceFlag) {
17
- selector.value = options.replaceUniversalSelectorWith;
18
+ selector.value = replaceUniversalSelectorWith;
18
19
  }
19
20
  if (selector.type === 'selector') {
20
21
  const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
21
22
  node && selector.remove();
22
23
  }
23
24
  if (selector.type === 'class') {
24
- selector.value = shared.internalCssSelectorReplacer(selector.value, options.escapeMap);
25
+ selector.value = shared.internalCssSelectorReplacer(selector.value, {
26
+ escapeMap,
27
+ mangleContext
28
+ });
25
29
  }
26
30
  });
27
31
  if (selectors.length === 0) {
package/dist/postcss.js CHANGED
@@ -2,11 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var postcss = require('./postcss-06f57f3f.js');
5
+ var postcss = require('./postcss-e0e5739b.js');
6
6
  var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
7
7
  require('postcss-selector-parser');
8
- require('./shared-823d1fc1.js');
9
- require('tailwindcss-mangle-shared');
8
+ require('./shared-28d43730.js');
10
9
  require('postcss');
11
10
 
12
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
package/dist/postcss.mjs CHANGED
@@ -1,6 +1,5 @@
1
- export { p as postcssWeappTailwindcss } from './postcss-564aef44.mjs';
1
+ export { p as postcssWeappTailwindcss } from './postcss-b4e0e1ac.mjs';
2
2
  export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
3
3
  import 'postcss-selector-parser';
4
- import './shared-497eda3c.mjs';
5
- import 'tailwindcss-mangle-shared';
4
+ import './shared-31001503.mjs';
6
5
  import 'postcss';
package/dist/replace.js CHANGED
@@ -2,27 +2,23 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var shared = require('./shared-823d1fc1.js');
6
- require('tailwindcss-mangle-shared');
5
+ var shared = require('./shared-28d43730.js');
7
6
 
8
7
  function replaceWxml(original, options = {
9
8
  keepEOL: false,
10
- escapeMap: shared.SimpleMappingChars2String
9
+ escapeMap: shared.SimpleMappingChars2String,
11
10
  }) {
12
- if (typeof options === 'boolean') {
13
- options = {
14
- keepEOL: options
15
- };
16
- }
11
+ const { keepEOL, escapeMap, mangleContext } = options;
17
12
  let res = original;
18
- if (!options.keepEOL) {
13
+ if (!keepEOL) {
19
14
  res = res
20
15
  .replaceAll(/[\n\r]+/g, '');
21
16
  }
22
- const { wxmlHandler } = shared.useStore();
23
- res = wxmlHandler(res);
17
+ if (mangleContext) {
18
+ res = mangleContext.wxmlHandler(res);
19
+ }
24
20
  res = shared.escape(res, {
25
- map: options.escapeMap
21
+ map: escapeMap
26
22
  });
27
23
  return res;
28
24
  }
package/dist/replace.mjs CHANGED
@@ -1,25 +1,21 @@
1
- import { h as escape, S as SimpleMappingChars2String, u as useStore } from './shared-497eda3c.mjs';
2
- export { M as MappingChars2String, k as MappingChars2StringEntries, j as SYMBOL_TABLE, l as SimpleMappingChars2StringEntries, f as replaceCss } from './shared-497eda3c.mjs';
3
- import 'tailwindcss-mangle-shared';
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';
4
3
 
5
4
  function replaceWxml(original, options = {
6
5
  keepEOL: false,
7
- escapeMap: SimpleMappingChars2String
6
+ escapeMap: SimpleMappingChars2String,
8
7
  }) {
9
- if (typeof options === 'boolean') {
10
- options = {
11
- keepEOL: options
12
- };
13
- }
8
+ const { keepEOL, escapeMap, mangleContext } = options;
14
9
  let res = original;
15
- if (!options.keepEOL) {
10
+ if (!keepEOL) {
16
11
  res = res
17
12
  .replaceAll(/[\n\r]+/g, '');
18
13
  }
19
- const { wxmlHandler } = useStore();
20
- res = wxmlHandler(res);
14
+ if (mangleContext) {
15
+ res = mangleContext.wxmlHandler(res);
16
+ }
21
17
  res = escape(res, {
22
- map: options.escapeMap
18
+ map: escapeMap
23
19
  });
24
20
  return res;
25
21
  }