weapp-tailwindcss 4.4.0-alpha.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -146,11 +146,31 @@ function _interopDefaultCompat(e) {
146
146
  var traverse = _interopDefaultCompat(_babelTraverse);
147
147
 
148
148
  // src/utils/nameMatcher.ts
149
+ import { escapeStringRegexp } from "@weapp-core/regex";
150
+ function buildFuzzyMatcher(fuzzyStrings) {
151
+ if (fuzzyStrings.length === 0) {
152
+ return void 0;
153
+ }
154
+ if (fuzzyStrings.length === 1) {
155
+ const [needle] = fuzzyStrings;
156
+ return (value) => value.includes(needle);
157
+ }
158
+ const unique = [...new Set(fuzzyStrings)];
159
+ const pattern = new RegExp(unique.map(escapeStringRegexp).join("|"));
160
+ return (value) => pattern.test(value);
161
+ }
162
+ function normaliseRegex(regex) {
163
+ const { source, flags } = regex;
164
+ if (!flags.includes("g")) {
165
+ return regex;
166
+ }
167
+ return new RegExp(source, flags.replace(/g/g, ""));
168
+ }
149
169
  function createNameMatcher(list, { exact = false } = {}) {
150
170
  if (!list || list.length === 0) {
151
171
  return () => false;
152
172
  }
153
- const exactStrings = /* @__PURE__ */ new Set();
173
+ const exactStrings = exact ? /* @__PURE__ */ new Set() : void 0;
154
174
  const fuzzyStrings = [];
155
175
  const regexList = [];
156
176
  for (const item of list) {
@@ -161,44 +181,46 @@ function createNameMatcher(list, { exact = false } = {}) {
161
181
  fuzzyStrings.push(item);
162
182
  }
163
183
  } else {
164
- regexList.push(item);
184
+ regexList.push(normaliseRegex(item));
165
185
  }
166
186
  }
187
+ const fuzzyMatcher = exact ? void 0 : buildFuzzyMatcher(fuzzyStrings);
188
+ const hasRegex = regexList.length > 0;
167
189
  return (value) => {
168
- if (exact && exactStrings.has(value)) {
190
+ if (exact && exactStrings?.has(value)) {
169
191
  return true;
170
192
  }
171
- if (!exact) {
172
- for (const candidate of fuzzyStrings) {
173
- if (value.includes(candidate)) {
174
- return true;
175
- }
176
- }
193
+ if (fuzzyMatcher?.(value)) {
194
+ return true;
177
195
  }
178
- for (const regex of regexList) {
179
- regex.lastIndex = 0;
180
- if (regex.test(value)) {
181
- return true;
182
- }
196
+ if (!hasRegex) {
197
+ return false;
183
198
  }
184
- return false;
199
+ return regexList.some((regex) => regex.test(value));
185
200
  };
186
201
  }
187
202
 
188
203
  // src/js/handlers.ts
189
204
  import { jsStringEscape } from "@ast-core/escape";
190
- import { escapeStringRegexp } from "@weapp-core/regex";
205
+ import { escapeStringRegexp as escapeStringRegexp2 } from "@weapp-core/regex";
191
206
  import { splitCode } from "@weapp-tailwindcss/shared/extractors";
192
207
 
193
208
  // src/utils/decode.ts
194
209
  var unicodeEscapeRE = /\\u([\dA-Fa-f]{4})/g;
210
+ var unicodeEscapeTestRE = /\\u[\dA-Fa-f]{4}/;
195
211
  function decodeUnicode(value) {
212
+ if (!unicodeEscapeTestRE.test(value)) {
213
+ return value;
214
+ }
196
215
  return value.replace(unicodeEscapeRE, (_match, hex) => {
197
216
  const codePoint = Number.parseInt(hex, 16);
198
217
  return Number.isNaN(codePoint) ? _match : String.fromCharCode(codePoint);
199
218
  });
200
219
  }
201
220
  function decodeUnicode2(input) {
221
+ if (!unicodeEscapeTestRE.test(input)) {
222
+ return input;
223
+ }
202
224
  try {
203
225
  return JSON.parse(`"${input}"`);
204
226
  } catch (_error) {
@@ -207,6 +229,38 @@ function decodeUnicode2(input) {
207
229
  }
208
230
 
209
231
  // src/js/handlers.ts
232
+ var patternCache = /* @__PURE__ */ new Map();
233
+ var replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
234
+ var defaultReplacementCache = /* @__PURE__ */ new Map();
235
+ function getPattern(candidate) {
236
+ let cached = patternCache.get(candidate);
237
+ if (!cached) {
238
+ cached = new RegExp(escapeStringRegexp2(candidate));
239
+ patternCache.set(candidate, cached);
240
+ }
241
+ return cached;
242
+ }
243
+ function getReplacement(candidate, escapeMap) {
244
+ if (!escapeMap) {
245
+ let cached2 = defaultReplacementCache.get(candidate);
246
+ if (cached2 === void 0) {
247
+ cached2 = replaceWxml(candidate, { escapeMap });
248
+ defaultReplacementCache.set(candidate, cached2);
249
+ }
250
+ return cached2;
251
+ }
252
+ let store = replacementCacheByEscapeMap.get(escapeMap);
253
+ if (!store) {
254
+ store = /* @__PURE__ */ new Map();
255
+ replacementCacheByEscapeMap.set(escapeMap, store);
256
+ }
257
+ let cached = store.get(candidate);
258
+ if (cached === void 0) {
259
+ cached = replaceWxml(candidate, { escapeMap });
260
+ store.set(candidate, cached);
261
+ }
262
+ return cached;
263
+ }
210
264
  function hasIgnoreComment(node) {
211
265
  return Array.isArray(node.leadingComments) && node.leadingComments.some((comment) => comment.value.includes("weapp-tw") && comment.value.includes("ignore"));
212
266
  }
@@ -255,6 +309,10 @@ function replaceHandleValue(path2, options) {
255
309
  mangleContext,
256
310
  needEscaped = false
257
311
  } = options;
312
+ const { classNameSet, alwaysEscape } = options;
313
+ if (!alwaysEscape && (!classNameSet || classNameSet.size === 0)) {
314
+ return void 0;
315
+ }
258
316
  const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path2, options);
259
317
  if (hasIgnoreComment(path2.node)) {
260
318
  return void 0;
@@ -265,30 +323,24 @@ function replaceHandleValue(path2, options) {
265
323
  }
266
324
  let transformed = literal;
267
325
  let mutated = false;
268
- const replacementCache = /* @__PURE__ */ new Map();
326
+ let normalised = false;
269
327
  for (const candidate of candidates) {
270
328
  if (!shouldTransformClassName(candidate, options)) {
271
329
  continue;
272
330
  }
273
- if (mangleContext) {
331
+ if (mangleContext && !normalised) {
274
332
  const mangled = mangleContext.jsHandler(transformed);
275
333
  if (mangled !== transformed) {
276
334
  transformed = mangled;
277
335
  mutated = true;
278
336
  }
337
+ normalised = true;
279
338
  }
280
339
  if (!transformed.includes(candidate)) {
281
340
  continue;
282
341
  }
283
- let cached = replacementCache.get(candidate);
284
- if (!cached) {
285
- cached = {
286
- pattern: new RegExp(escapeStringRegexp(candidate)),
287
- replacement: replaceWxml(candidate, { escapeMap })
288
- };
289
- replacementCache.set(candidate, cached);
290
- }
291
- const { pattern, replacement } = cached;
342
+ const pattern = getPattern(candidate);
343
+ const replacement = getReplacement(candidate, escapeMap);
292
344
  const replaced = transformed.replace(pattern, replacement);
293
345
  if (replaced !== transformed) {
294
346
  transformed = replaced;
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-H4JTYYOI.mjs";
5
5
  import {
6
6
  getCompilerContext
7
- } from "./chunk-WCIVXE2D.mjs";
7
+ } from "./chunk-D25XJJMP.mjs";
8
8
 
9
9
  // src/bundlers/gulp/index.ts
10
10
  import { Buffer } from "buffer";
@@ -149,11 +149,31 @@ function _interopDefaultCompat(e) {
149
149
  var traverse = _interopDefaultCompat(_traverse2.default);
150
150
 
151
151
  // src/utils/nameMatcher.ts
152
+ var _regex = require('@weapp-core/regex');
153
+ function buildFuzzyMatcher(fuzzyStrings) {
154
+ if (fuzzyStrings.length === 0) {
155
+ return void 0;
156
+ }
157
+ if (fuzzyStrings.length === 1) {
158
+ const [needle] = fuzzyStrings;
159
+ return (value) => value.includes(needle);
160
+ }
161
+ const unique = [...new Set(fuzzyStrings)];
162
+ const pattern = new RegExp(unique.map(_regex.escapeStringRegexp).join("|"));
163
+ return (value) => pattern.test(value);
164
+ }
165
+ function normaliseRegex(regex) {
166
+ const { source, flags } = regex;
167
+ if (!flags.includes("g")) {
168
+ return regex;
169
+ }
170
+ return new RegExp(source, flags.replace(/g/g, ""));
171
+ }
152
172
  function createNameMatcher(list, { exact = false } = {}) {
153
173
  if (!list || list.length === 0) {
154
174
  return () => false;
155
175
  }
156
- const exactStrings = /* @__PURE__ */ new Set();
176
+ const exactStrings = exact ? /* @__PURE__ */ new Set() : void 0;
157
177
  const fuzzyStrings = [];
158
178
  const regexList = [];
159
179
  for (const item of list) {
@@ -164,44 +184,46 @@ function createNameMatcher(list, { exact = false } = {}) {
164
184
  fuzzyStrings.push(item);
165
185
  }
166
186
  } else {
167
- regexList.push(item);
187
+ regexList.push(normaliseRegex(item));
168
188
  }
169
189
  }
190
+ const fuzzyMatcher = exact ? void 0 : buildFuzzyMatcher(fuzzyStrings);
191
+ const hasRegex = regexList.length > 0;
170
192
  return (value) => {
171
- if (exact && exactStrings.has(value)) {
193
+ if (exact && _optionalChain([exactStrings, 'optionalAccess', _4 => _4.has, 'call', _5 => _5(value)])) {
172
194
  return true;
173
195
  }
174
- if (!exact) {
175
- for (const candidate of fuzzyStrings) {
176
- if (value.includes(candidate)) {
177
- return true;
178
- }
179
- }
196
+ if (_optionalChain([fuzzyMatcher, 'optionalCall', _6 => _6(value)])) {
197
+ return true;
180
198
  }
181
- for (const regex of regexList) {
182
- regex.lastIndex = 0;
183
- if (regex.test(value)) {
184
- return true;
185
- }
199
+ if (!hasRegex) {
200
+ return false;
186
201
  }
187
- return false;
202
+ return regexList.some((regex) => regex.test(value));
188
203
  };
189
204
  }
190
205
 
191
206
  // src/js/handlers.ts
192
207
 
193
- var _regex = require('@weapp-core/regex');
208
+
194
209
  var _extractors = require('@weapp-tailwindcss/shared/extractors');
195
210
 
196
211
  // src/utils/decode.ts
197
212
  var unicodeEscapeRE = /\\u([\dA-Fa-f]{4})/g;
213
+ var unicodeEscapeTestRE = /\\u[\dA-Fa-f]{4}/;
198
214
  function decodeUnicode(value) {
215
+ if (!unicodeEscapeTestRE.test(value)) {
216
+ return value;
217
+ }
199
218
  return value.replace(unicodeEscapeRE, (_match, hex) => {
200
219
  const codePoint = Number.parseInt(hex, 16);
201
220
  return Number.isNaN(codePoint) ? _match : String.fromCharCode(codePoint);
202
221
  });
203
222
  }
204
223
  function decodeUnicode2(input) {
224
+ if (!unicodeEscapeTestRE.test(input)) {
225
+ return input;
226
+ }
205
227
  try {
206
228
  return JSON.parse(`"${input}"`);
207
229
  } catch (_error) {
@@ -210,6 +232,38 @@ function decodeUnicode2(input) {
210
232
  }
211
233
 
212
234
  // src/js/handlers.ts
235
+ var patternCache = /* @__PURE__ */ new Map();
236
+ var replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
237
+ var defaultReplacementCache = /* @__PURE__ */ new Map();
238
+ function getPattern(candidate) {
239
+ let cached = patternCache.get(candidate);
240
+ if (!cached) {
241
+ cached = new RegExp(_regex.escapeStringRegexp.call(void 0, candidate));
242
+ patternCache.set(candidate, cached);
243
+ }
244
+ return cached;
245
+ }
246
+ function getReplacement(candidate, escapeMap) {
247
+ if (!escapeMap) {
248
+ let cached2 = defaultReplacementCache.get(candidate);
249
+ if (cached2 === void 0) {
250
+ cached2 = _chunkPLMJW644js.replaceWxml.call(void 0, candidate, { escapeMap });
251
+ defaultReplacementCache.set(candidate, cached2);
252
+ }
253
+ return cached2;
254
+ }
255
+ let store = replacementCacheByEscapeMap.get(escapeMap);
256
+ if (!store) {
257
+ store = /* @__PURE__ */ new Map();
258
+ replacementCacheByEscapeMap.set(escapeMap, store);
259
+ }
260
+ let cached = store.get(candidate);
261
+ if (cached === void 0) {
262
+ cached = _chunkPLMJW644js.replaceWxml.call(void 0, candidate, { escapeMap });
263
+ store.set(candidate, cached);
264
+ }
265
+ return cached;
266
+ }
213
267
  function hasIgnoreComment(node) {
214
268
  return Array.isArray(node.leadingComments) && node.leadingComments.some((comment) => comment.value.includes("weapp-tw") && comment.value.includes("ignore"));
215
269
  }
@@ -227,10 +281,10 @@ function shouldTransformClassName(candidate, {
227
281
  if (!classNameSet.has(candidate)) {
228
282
  return false;
229
283
  }
230
- return !_optionalChain([jsPreserveClass, 'optionalCall', _4 => _4(candidate)]);
284
+ return !_optionalChain([jsPreserveClass, 'optionalCall', _7 => _7(candidate)]);
231
285
  }
232
286
  function extractLiteralValue(path2, { unescapeUnicode, arbitraryValues }) {
233
- const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _5 => _5.allowDoubleQuotes]);
287
+ const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _8 => _8.allowDoubleQuotes]);
234
288
  let offset = 0;
235
289
  let original;
236
290
  if (path2.isStringLiteral()) {
@@ -258,6 +312,10 @@ function replaceHandleValue(path2, options) {
258
312
  mangleContext,
259
313
  needEscaped = false
260
314
  } = options;
315
+ const { classNameSet, alwaysEscape } = options;
316
+ if (!alwaysEscape && (!classNameSet || classNameSet.size === 0)) {
317
+ return void 0;
318
+ }
261
319
  const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path2, options);
262
320
  if (hasIgnoreComment(path2.node)) {
263
321
  return void 0;
@@ -268,30 +326,24 @@ function replaceHandleValue(path2, options) {
268
326
  }
269
327
  let transformed = literal;
270
328
  let mutated = false;
271
- const replacementCache = /* @__PURE__ */ new Map();
329
+ let normalised = false;
272
330
  for (const candidate of candidates) {
273
331
  if (!shouldTransformClassName(candidate, options)) {
274
332
  continue;
275
333
  }
276
- if (mangleContext) {
334
+ if (mangleContext && !normalised) {
277
335
  const mangled = mangleContext.jsHandler(transformed);
278
336
  if (mangled !== transformed) {
279
337
  transformed = mangled;
280
338
  mutated = true;
281
339
  }
340
+ normalised = true;
282
341
  }
283
342
  if (!transformed.includes(candidate)) {
284
343
  continue;
285
344
  }
286
- let cached = replacementCache.get(candidate);
287
- if (!cached) {
288
- cached = {
289
- pattern: new RegExp(_regex.escapeStringRegexp.call(void 0, candidate)),
290
- replacement: _chunkPLMJW644js.replaceWxml.call(void 0, candidate, { escapeMap })
291
- };
292
- replacementCache.set(candidate, cached);
293
- }
294
- const { pattern, replacement } = cached;
345
+ const pattern = getPattern(candidate);
346
+ const replacement = getReplacement(candidate, escapeMap);
295
347
  const replaced = transformed.replace(pattern, replacement);
296
348
  if (replaced !== transformed) {
297
349
  transformed = replaced;
@@ -951,7 +1003,7 @@ function generateCode(match, options = {}) {
951
1003
  if (t.isMemberExpression(path2.parent)) {
952
1004
  return;
953
1005
  }
954
- if (t.isBinaryExpression(path2.parent) && (t.isConditionalExpression(_optionalChain([path2, 'access', _6 => _6.parentPath, 'optionalAccess', _7 => _7.parent])) || t.isLogicalExpression(_optionalChain([path2, 'access', _8 => _8.parentPath, 'optionalAccess', _9 => _9.parent])))) {
1006
+ if (t.isBinaryExpression(path2.parent) && (t.isConditionalExpression(_optionalChain([path2, 'access', _9 => _9.parentPath, 'optionalAccess', _10 => _10.parent])) || t.isLogicalExpression(_optionalChain([path2, 'access', _11 => _11.parentPath, 'optionalAccess', _12 => _12.parent])))) {
955
1007
  return;
956
1008
  }
957
1009
  jsTokenUpdater.addToken(
@@ -4,7 +4,7 @@
4
4
  var _chunk2NRTWL47js = require('./chunk-2NRTWL47.js');
5
5
 
6
6
 
7
- var _chunkAEJDBNAXjs = require('./chunk-AEJDBNAX.js');
7
+ var _chunkGQAB52GEjs = require('./chunk-GQAB52GE.js');
8
8
 
9
9
  // src/bundlers/gulp/index.ts
10
10
  var _buffer = require('buffer');
@@ -12,7 +12,7 @@ var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
12
12
  var debug = _chunk2NRTWL47js.createDebug.call(void 0, );
13
13
  var Transform = _stream2.default.Transform;
14
14
  function createPlugins(options = {}) {
15
- const opts = _chunkAEJDBNAXjs.getCompilerContext.call(void 0, options);
15
+ const opts = _chunkGQAB52GEjs.getCompilerContext.call(void 0, options);
16
16
  const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
17
17
  let runtimeSet = /* @__PURE__ */ new Set();
18
18
  twPatcher.patch();
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-CMUA5KCO.mjs";
11
11
  import {
12
12
  getCompilerContext
13
- } from "./chunk-WCIVXE2D.mjs";
13
+ } from "./chunk-D25XJJMP.mjs";
14
14
  import {
15
15
  getGroupedEntries
16
16
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  generateCode,
10
10
  getCompilerContext
11
- } from "./chunk-WCIVXE2D.mjs";
11
+ } from "./chunk-D25XJJMP.mjs";
12
12
  import {
13
13
  replaceWxml
14
14
  } from "./chunk-Q67IXIAH.mjs";
@@ -10,7 +10,7 @@ var _chunk2NRTWL47js = require('./chunk-2NRTWL47.js');
10
10
  var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
11
11
 
12
12
 
13
- var _chunkAEJDBNAXjs = require('./chunk-AEJDBNAX.js');
13
+ var _chunkGQAB52GEjs = require('./chunk-GQAB52GE.js');
14
14
 
15
15
 
16
16
  var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
@@ -21,7 +21,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
21
21
  var debug = _chunk2NRTWL47js.createDebug.call(void 0, );
22
22
  var UnifiedWebpackPluginV5 = class {
23
23
  constructor(options = {}) {
24
- this.options = _chunkAEJDBNAXjs.getCompilerContext.call(void 0, options);
24
+ this.options = _chunkGQAB52GEjs.getCompilerContext.call(void 0, options);
25
25
  this.appType = this.options.appType;
26
26
  }
27
27
  apply(compiler) {
@@ -8,7 +8,7 @@ var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
8
8
 
9
9
 
10
10
 
11
- var _chunkAEJDBNAXjs = require('./chunk-AEJDBNAX.js');
11
+ var _chunkGQAB52GEjs = require('./chunk-GQAB52GE.js');
12
12
 
13
13
 
14
14
  var _chunkPLMJW644js = require('./chunk-PLMJW644.js');
@@ -43,7 +43,7 @@ function createClassAttributeUpdater(ms) {
43
43
  function createClassDirectiveUpdater(ms, jsHandler, runtimeSet) {
44
44
  return (prop) => {
45
45
  if (_optionalChain([prop, 'access', _ => _.arg, 'optionalAccess', _2 => _2.type]) === _compilerdom.NodeTypes.SIMPLE_EXPRESSION && prop.arg.content === "class" && _optionalChain([prop, 'access', _3 => _3.exp, 'optionalAccess', _4 => _4.type]) === _compilerdom.NodeTypes.SIMPLE_EXPRESSION) {
46
- const generated = _chunkAEJDBNAXjs.generateCode.call(void 0, prop.exp.content, {
46
+ const generated = _chunkGQAB52GEjs.generateCode.call(void 0, prop.exp.content, {
47
47
  jsHandler,
48
48
  runtimeSet
49
49
  });
@@ -165,7 +165,7 @@ async function formatPostcssSourceMap(rawMap, file) {
165
165
  // src/bundlers/vite/index.ts
166
166
  var debug = _chunk2NRTWL47js.createDebug.call(void 0, );
167
167
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
168
- const opts = _chunkAEJDBNAXjs.getCompilerContext.call(void 0, options);
168
+ const opts = _chunkGQAB52GEjs.getCompilerContext.call(void 0, options);
169
169
  const {
170
170
  disabled,
171
171
  onEnd,
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ var _chunkOXASK55Qjs = require('./chunk-OXASK55Q.js');
6
6
  var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
7
7
 
8
8
 
9
- var _chunkAEJDBNAXjs = require('./chunk-AEJDBNAX.js');
9
+ var _chunkGQAB52GEjs = require('./chunk-GQAB52GE.js');
10
10
  require('./chunk-PLMJW644.js');
11
11
  require('./chunk-FOSGDQZ7.js');
12
12
  require('./chunk-UW3WHSZ5.js');
@@ -24,6 +24,6 @@ if (_semver2.default.lt(_process2.default.versions.node, _chunkOGROHM4Ljs.WEAPP_
24
24
  }
25
25
  var command = args[0];
26
26
  if (command === "patch") {
27
- const ctx = _chunkAEJDBNAXjs.getCompilerContext.call(void 0, );
27
+ const ctx = _chunkGQAB52GEjs.getCompilerContext.call(void 0, );
28
28
  ctx.twPatcher.patch();
29
29
  }
package/dist/cli.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-CMUA5KCO.mjs";
7
7
  import {
8
8
  getCompilerContext
9
- } from "./chunk-WCIVXE2D.mjs";
9
+ } from "./chunk-D25XJJMP.mjs";
10
10
  import "./chunk-Q67IXIAH.mjs";
11
11
  import "./chunk-IHKVNALD.mjs";
12
12
  import "./chunk-ZNKIYZRQ.mjs";
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkAEJDBNAXjs = require('./chunk-AEJDBNAX.js');
3
+ var _chunkGQAB52GEjs = require('./chunk-GQAB52GE.js');
4
4
  require('./chunk-PLMJW644.js');
5
5
  require('./chunk-FOSGDQZ7.js');
6
6
  require('./chunk-UW3WHSZ5.js');
@@ -9,7 +9,7 @@ require('./chunk-RBRSMHFS.js');
9
9
  // src/core.ts
10
10
  var _shared = require('@weapp-tailwindcss/shared');
11
11
  function createContext(options = {}) {
12
- const opts = _chunkAEJDBNAXjs.getCompilerContext.call(void 0, options);
12
+ const opts = _chunkGQAB52GEjs.getCompilerContext.call(void 0, options);
13
13
  const { templateHandler, styleHandler, jsHandler, twPatcher } = opts;
14
14
  let runtimeSet = /* @__PURE__ */ new Set();
15
15
  twPatcher.patch();
package/dist/core.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getCompilerContext
3
- } from "./chunk-WCIVXE2D.mjs";
3
+ } from "./chunk-D25XJJMP.mjs";
4
4
  import "./chunk-Q67IXIAH.mjs";
5
5
  import "./chunk-IHKVNALD.mjs";
6
6
  import "./chunk-ZNKIYZRQ.mjs";
@@ -8,7 +8,7 @@ interface Options {
8
8
  dynamic?: boolean;
9
9
  }
10
10
  declare const cssMacro: {
11
- (options: Options): {
11
+ (options: Options | undefined): {
12
12
  handler: tailwindcss_types_config.PluginCreator;
13
13
  config?: Partial<tailwindcss_types_config.Config>;
14
14
  };
@@ -8,7 +8,7 @@ interface Options {
8
8
  dynamic?: boolean;
9
9
  }
10
10
  declare const cssMacro: {
11
- (options: Options): {
11
+ (options: Options | undefined): {
12
12
  handler: tailwindcss_types_config.PluginCreator;
13
13
  config?: Partial<tailwindcss_types_config.Config>;
14
14
  };
package/dist/css-macro.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
3
 
4
4
  var _chunkNS3NEDWDjs = require('./chunk-NS3NEDWD.js');
@@ -9,25 +9,37 @@ require('./chunk-RBRSMHFS.js');
9
9
 
10
10
  // src/css-macro/index.ts
11
11
  var _plugin = require('tailwindcss/plugin'); var _plugin2 = _interopRequireDefault(_plugin);
12
+ var defaultOptions = {
13
+ dynamic: true,
14
+ variantsMap: {}
15
+ };
12
16
  var cssMacro = _plugin2.default.withOptions((options) => {
13
- const { dynamic: dynamicMode, variantsMap } = _chunkUW3WHSZ5js.defu.call(void 0, options, {
14
- dynamic: true,
15
- variantsMap: {}
17
+ const { dynamic, variantsMap } = _chunkUW3WHSZ5js.defu.call(void 0, _nullishCoalesce(options, () => ( {})), defaultOptions);
18
+ const staticVariants = Object.entries(variantsMap).map(([name, config]) => {
19
+ if (typeof config === "string") {
20
+ return {
21
+ name,
22
+ negative: false,
23
+ value: config
24
+ };
25
+ }
26
+ return {
27
+ name,
28
+ negative: Boolean(config.negative),
29
+ value: config.value
30
+ };
16
31
  });
17
- return ({ matchVariant, addVariant }) => {
18
- if (dynamicMode) {
19
- matchVariant("ifdef", (value) => {
20
- return _chunkNS3NEDWDjs.createMediaQuery.call(void 0, value);
21
- });
22
- matchVariant("ifndef", (value) => {
23
- return _chunkNS3NEDWDjs.createNegativeMediaQuery.call(void 0, value);
24
- });
32
+ return (api) => {
33
+ const { matchVariant, addVariant } = api;
34
+ const supportsDynamic = typeof matchVariant === "function";
35
+ if (dynamic && supportsDynamic) {
36
+ matchVariant("ifdef", (value) => _chunkNS3NEDWDjs.createMediaQuery.call(void 0, value));
37
+ matchVariant("ifndef", (value) => _chunkNS3NEDWDjs.createNegativeMediaQuery.call(void 0, value));
25
38
  }
26
- for (const [name, obj] of Object.entries(variantsMap)) {
27
- if (typeof obj === "string") {
28
- addVariant(name, _chunkNS3NEDWDjs.createMediaQuery.call(void 0, obj));
29
- } else {
30
- addVariant(name, obj.negative ? _chunkNS3NEDWDjs.createNegativeMediaQuery.call(void 0, obj.value) : _chunkNS3NEDWDjs.createMediaQuery.call(void 0, obj.value));
39
+ if (typeof addVariant === "function") {
40
+ for (const variant of staticVariants) {
41
+ const query = variant.negative ? _chunkNS3NEDWDjs.createNegativeMediaQuery.call(void 0, variant.value) : _chunkNS3NEDWDjs.createMediaQuery.call(void 0, variant.value);
42
+ addVariant(variant.name, query);
31
43
  }
32
44
  }
33
45
  };
@@ -9,25 +9,37 @@ import "./chunk-FBGUUXQV.mjs";
9
9
 
10
10
  // src/css-macro/index.ts
11
11
  import plugin from "tailwindcss/plugin";
12
+ var defaultOptions = {
13
+ dynamic: true,
14
+ variantsMap: {}
15
+ };
12
16
  var cssMacro = plugin.withOptions((options) => {
13
- const { dynamic: dynamicMode, variantsMap } = defu(options, {
14
- dynamic: true,
15
- variantsMap: {}
17
+ const { dynamic, variantsMap } = defu(options ?? {}, defaultOptions);
18
+ const staticVariants = Object.entries(variantsMap).map(([name, config]) => {
19
+ if (typeof config === "string") {
20
+ return {
21
+ name,
22
+ negative: false,
23
+ value: config
24
+ };
25
+ }
26
+ return {
27
+ name,
28
+ negative: Boolean(config.negative),
29
+ value: config.value
30
+ };
16
31
  });
17
- return ({ matchVariant, addVariant }) => {
18
- if (dynamicMode) {
19
- matchVariant("ifdef", (value) => {
20
- return createMediaQuery(value);
21
- });
22
- matchVariant("ifndef", (value) => {
23
- return createNegativeMediaQuery(value);
24
- });
32
+ return (api) => {
33
+ const { matchVariant, addVariant } = api;
34
+ const supportsDynamic = typeof matchVariant === "function";
35
+ if (dynamic && supportsDynamic) {
36
+ matchVariant("ifdef", (value) => createMediaQuery(value));
37
+ matchVariant("ifndef", (value) => createNegativeMediaQuery(value));
25
38
  }
26
- for (const [name, obj] of Object.entries(variantsMap)) {
27
- if (typeof obj === "string") {
28
- addVariant(name, createMediaQuery(obj));
29
- } else {
30
- addVariant(name, obj.negative ? createNegativeMediaQuery(obj.value) : createMediaQuery(obj.value));
39
+ if (typeof addVariant === "function") {
40
+ for (const variant of staticVariants) {
41
+ const query = variant.negative ? createNegativeMediaQuery(variant.value) : createMediaQuery(variant.value);
42
+ addVariant(variant.name, query);
31
43
  }
32
44
  }
33
45
  };
package/dist/gulp.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkE2LRXNZ3js = require('./chunk-E2LRXNZ3.js');
3
+ var _chunkH2Y5VNOJjs = require('./chunk-H2Y5VNOJ.js');
4
4
  require('./chunk-2NRTWL47.js');
5
- require('./chunk-AEJDBNAX.js');
5
+ require('./chunk-GQAB52GE.js');
6
6
  require('./chunk-PLMJW644.js');
7
7
  require('./chunk-FOSGDQZ7.js');
8
8
  require('./chunk-UW3WHSZ5.js');
9
9
  require('./chunk-RBRSMHFS.js');
10
10
 
11
11
 
12
- exports.createPlugins = _chunkE2LRXNZ3js.createPlugins;
12
+ exports.createPlugins = _chunkH2Y5VNOJjs.createPlugins;
package/dist/gulp.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createPlugins
3
- } from "./chunk-KAKRCCPX.mjs";
3
+ } from "./chunk-D2AKCBDU.mjs";
4
4
  import "./chunk-H4JTYYOI.mjs";
5
- import "./chunk-WCIVXE2D.mjs";
5
+ import "./chunk-D25XJJMP.mjs";
6
6
  import "./chunk-Q67IXIAH.mjs";
7
7
  import "./chunk-IHKVNALD.mjs";
8
8
  import "./chunk-ZNKIYZRQ.mjs";
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-O2IOQ3BD.js');
2
2
 
3
3
 
4
- var _chunkPPTSD6TQjs = require('./chunk-PPTSD6TQ.js');
4
+ var _chunkQXCC745Gjs = require('./chunk-QXCC745G.js');
5
5
  require('./chunk-6GP37C26.js');
6
6
 
7
7
 
8
- var _chunkE2LRXNZ3js = require('./chunk-E2LRXNZ3.js');
8
+ var _chunkH2Y5VNOJjs = require('./chunk-H2Y5VNOJ.js');
9
9
 
10
10
 
11
- var _chunkNZ7VALIMjs = require('./chunk-NZ7VALIM.js');
11
+ var _chunkVN2BU7ONjs = require('./chunk-VN2BU7ON.js');
12
12
  require('./chunk-2NRTWL47.js');
13
13
  require('./chunk-OGROHM4L.js');
14
- require('./chunk-AEJDBNAX.js');
14
+ require('./chunk-GQAB52GE.js');
15
15
  require('./chunk-PLMJW644.js');
16
16
  require('./chunk-FOSGDQZ7.js');
17
17
  require('./chunk-UW3WHSZ5.js');
@@ -20,4 +20,4 @@ require('./chunk-RBRSMHFS.js');
20
20
 
21
21
 
22
22
 
23
- exports.UnifiedViteWeappTailwindcssPlugin = _chunkNZ7VALIMjs.UnifiedViteWeappTailwindcssPlugin; exports.UnifiedWebpackPluginV5 = _chunkPPTSD6TQjs.UnifiedWebpackPluginV5; exports.createPlugins = _chunkE2LRXNZ3js.createPlugins;
23
+ exports.UnifiedViteWeappTailwindcssPlugin = _chunkVN2BU7ONjs.UnifiedViteWeappTailwindcssPlugin; exports.UnifiedWebpackPluginV5 = _chunkQXCC745Gjs.UnifiedWebpackPluginV5; exports.createPlugins = _chunkH2Y5VNOJjs.createPlugins;
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  import "./chunk-YAN7TO2B.mjs";
2
2
  import {
3
3
  UnifiedWebpackPluginV5
4
- } from "./chunk-AXYGCCZW.mjs";
4
+ } from "./chunk-L3HOZDIV.mjs";
5
5
  import "./chunk-2F7HOQQY.mjs";
6
6
  import {
7
7
  createPlugins
8
- } from "./chunk-KAKRCCPX.mjs";
8
+ } from "./chunk-D2AKCBDU.mjs";
9
9
  import {
10
10
  UnifiedViteWeappTailwindcssPlugin
11
- } from "./chunk-3MSGCIVH.mjs";
11
+ } from "./chunk-NDHL3P32.mjs";
12
12
  import "./chunk-H4JTYYOI.mjs";
13
13
  import "./chunk-CMUA5KCO.mjs";
14
- import "./chunk-WCIVXE2D.mjs";
14
+ import "./chunk-D25XJJMP.mjs";
15
15
  import "./chunk-Q67IXIAH.mjs";
16
16
  import "./chunk-IHKVNALD.mjs";
17
17
  import "./chunk-ZNKIYZRQ.mjs";
package/dist/vite.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkNZ7VALIMjs = require('./chunk-NZ7VALIM.js');
3
+ var _chunkVN2BU7ONjs = require('./chunk-VN2BU7ON.js');
4
4
  require('./chunk-2NRTWL47.js');
5
5
  require('./chunk-OGROHM4L.js');
6
- require('./chunk-AEJDBNAX.js');
6
+ require('./chunk-GQAB52GE.js');
7
7
  require('./chunk-PLMJW644.js');
8
8
  require('./chunk-FOSGDQZ7.js');
9
9
  require('./chunk-UW3WHSZ5.js');
10
10
  require('./chunk-RBRSMHFS.js');
11
11
 
12
12
 
13
- exports.UnifiedViteWeappTailwindcssPlugin = _chunkNZ7VALIMjs.UnifiedViteWeappTailwindcssPlugin;
13
+ exports.UnifiedViteWeappTailwindcssPlugin = _chunkVN2BU7ONjs.UnifiedViteWeappTailwindcssPlugin;
package/dist/vite.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  UnifiedViteWeappTailwindcssPlugin
3
- } from "./chunk-3MSGCIVH.mjs";
3
+ } from "./chunk-NDHL3P32.mjs";
4
4
  import "./chunk-H4JTYYOI.mjs";
5
5
  import "./chunk-CMUA5KCO.mjs";
6
- import "./chunk-WCIVXE2D.mjs";
6
+ import "./chunk-D25XJJMP.mjs";
7
7
  import "./chunk-Q67IXIAH.mjs";
8
8
  import "./chunk-IHKVNALD.mjs";
9
9
  import "./chunk-ZNKIYZRQ.mjs";
package/dist/webpack.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPPTSD6TQjs = require('./chunk-PPTSD6TQ.js');
3
+ var _chunkQXCC745Gjs = require('./chunk-QXCC745G.js');
4
4
  require('./chunk-6GP37C26.js');
5
5
  require('./chunk-2NRTWL47.js');
6
6
  require('./chunk-OGROHM4L.js');
7
- require('./chunk-AEJDBNAX.js');
7
+ require('./chunk-GQAB52GE.js');
8
8
  require('./chunk-PLMJW644.js');
9
9
  require('./chunk-FOSGDQZ7.js');
10
10
  require('./chunk-UW3WHSZ5.js');
11
11
  require('./chunk-RBRSMHFS.js');
12
12
 
13
13
 
14
- exports.UnifiedWebpackPluginV5 = _chunkPPTSD6TQjs.UnifiedWebpackPluginV5;
14
+ exports.UnifiedWebpackPluginV5 = _chunkQXCC745Gjs.UnifiedWebpackPluginV5;
package/dist/webpack.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  UnifiedWebpackPluginV5
3
- } from "./chunk-AXYGCCZW.mjs";
3
+ } from "./chunk-L3HOZDIV.mjs";
4
4
  import "./chunk-2F7HOQQY.mjs";
5
5
  import "./chunk-H4JTYYOI.mjs";
6
6
  import "./chunk-CMUA5KCO.mjs";
7
- import "./chunk-WCIVXE2D.mjs";
7
+ import "./chunk-D25XJJMP.mjs";
8
8
  import "./chunk-Q67IXIAH.mjs";
9
9
  import "./chunk-IHKVNALD.mjs";
10
10
  import "./chunk-ZNKIYZRQ.mjs";
package/dist/webpack4.js CHANGED
@@ -10,7 +10,7 @@ var _chunk2NRTWL47js = require('./chunk-2NRTWL47.js');
10
10
  var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
11
11
 
12
12
 
13
- var _chunkAEJDBNAXjs = require('./chunk-AEJDBNAX.js');
13
+ var _chunkGQAB52GEjs = require('./chunk-GQAB52GE.js');
14
14
  require('./chunk-PLMJW644.js');
15
15
  require('./chunk-FOSGDQZ7.js');
16
16
 
@@ -25,7 +25,7 @@ var _webpacksources = require('webpack-sources');
25
25
  var debug = _chunk2NRTWL47js.createDebug.call(void 0, );
26
26
  var UnifiedWebpackPluginV4 = class {
27
27
  constructor(options = {}) {
28
- this.options = _chunkAEJDBNAXjs.getCompilerContext.call(void 0, options);
28
+ this.options = _chunkGQAB52GEjs.getCompilerContext.call(void 0, options);
29
29
  this.appType = this.options.appType;
30
30
  }
31
31
  apply(compiler) {
package/dist/webpack4.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-CMUA5KCO.mjs";
11
11
  import {
12
12
  getCompilerContext
13
- } from "./chunk-WCIVXE2D.mjs";
13
+ } from "./chunk-D25XJJMP.mjs";
14
14
  import "./chunk-Q67IXIAH.mjs";
15
15
  import "./chunk-IHKVNALD.mjs";
16
16
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "4.4.0-alpha.0",
3
+ "version": "4.4.0",
4
4
  "description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -177,7 +177,7 @@
177
177
  "webpack-sources": "3.3.3",
178
178
  "@weapp-tailwindcss/logger": "1.1.0",
179
179
  "@weapp-tailwindcss/mangle": "1.0.5",
180
- "@weapp-tailwindcss/postcss": "1.3.2-alpha.0",
180
+ "@weapp-tailwindcss/postcss": "1.3.2",
181
181
  "@weapp-tailwindcss/shared": "1.0.3"
182
182
  },
183
183
  "devDependencies": {