weapp-tailwindcss 4.12.0-alpha.1 → 4.12.0-alpha.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.
Files changed (35) hide show
  1. package/bin/weapp-tailwindcss.js +21 -1
  2. package/dist/{chunk-CTGWJGKJ.js → chunk-2A4NRLSY.js} +3 -3
  3. package/dist/{chunk-4LBAL3RE.js → chunk-6JBFHYFM.js} +44 -36
  4. package/dist/{chunk-V34LWQTS.mjs → chunk-CMNCGACY.mjs} +18 -10
  5. package/dist/{chunk-JRLWGMVZ.mjs → chunk-CQMHHQRN.mjs} +1 -1
  6. package/dist/{chunk-OYSABARD.js → chunk-E7I5TW5K.js} +3 -2
  7. package/dist/{chunk-ZABCOAAS.mjs → chunk-LWEVOVRD.mjs} +14 -5
  8. package/dist/{chunk-CAZQZPMY.js → chunk-PAAX4FDD.js} +29 -29
  9. package/dist/{chunk-5CF3HTTN.mjs → chunk-SHDJA4GG.mjs} +1 -1
  10. package/dist/{chunk-IUYO6NQO.js → chunk-SRAG3FST.js} +7 -7
  11. package/dist/{chunk-RQWWSU4U.js → chunk-YVRX3F6S.js} +14 -5
  12. package/dist/{chunk-2LH6PZH3.mjs → chunk-ZCH4YINE.mjs} +3 -2
  13. package/dist/{chunk-C2E5ZLNI.mjs → chunk-ZGIN2OAY.mjs} +2 -2
  14. package/dist/cli.js +2229 -161
  15. package/dist/cli.mjs +2234 -166
  16. package/dist/core.js +7 -7
  17. package/dist/core.mjs +1 -1
  18. package/dist/css-macro/postcss.js +3 -3
  19. package/dist/css-macro/postcss.mjs +1 -1
  20. package/dist/css-macro.js +4 -4
  21. package/dist/css-macro.mjs +1 -1
  22. package/dist/gulp.js +3 -3
  23. package/dist/gulp.mjs +2 -2
  24. package/dist/index.js +6 -6
  25. package/dist/index.mjs +5 -5
  26. package/dist/vite.js +3 -3
  27. package/dist/vite.mjs +2 -2
  28. package/dist/weapp-tw-css-import-rewrite-loader.js +10 -5
  29. package/dist/weapp-tw-runtime-classset-loader.js +9 -4
  30. package/dist/webpack.js +4 -4
  31. package/dist/webpack.mjs +3 -3
  32. package/dist/webpack4.js +49 -45
  33. package/dist/webpack4.mjs +25 -21
  34. package/package.json +6 -5
  35. package/scripts/postinstall.mjs +59 -0
@@ -1,8 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('node:fs')
3
3
  const path = require('node:path')
4
+ const process = require('node:process')
5
+
6
+ function isInstallLifecycle() {
7
+ return process.env.npm_lifecycle_event === 'postinstall' || process.env.npm_lifecycle_event === 'prepare'
8
+ }
9
+
10
+ function isMissingRuntimeModuleError(error) {
11
+ return error && error.code === 'MODULE_NOT_FOUND'
12
+ }
4
13
 
5
14
  const cliPath = path.resolve(__dirname, '../dist/cli.js')
6
15
  if (fs.existsSync(cliPath)) {
7
- require(cliPath)
16
+ try {
17
+ require(cliPath)
18
+ }
19
+ catch (error) {
20
+ if (isInstallLifecycle() && isMissingRuntimeModuleError(error)) {
21
+ console.error('[weapp-tailwindcss] install lifecycle patch skipped because a runtime module is missing.')
22
+ console.error('Run `pnpm --filter weapp-tailwindcss build` before strict CLI validation.')
23
+ }
24
+ else {
25
+ throw error
26
+ }
27
+ }
8
28
  }
@@ -3,7 +3,7 @@
3
3
  var _chunkGMKSBLNYjs = require('./chunk-GMKSBLNY.js');
4
4
 
5
5
 
6
- var _chunkRQWWSU4Ujs = require('./chunk-RQWWSU4U.js');
6
+ var _chunkYVRX3F6Sjs = require('./chunk-YVRX3F6S.js');
7
7
 
8
8
  // src/shared/mpx.ts
9
9
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
@@ -155,8 +155,8 @@ function applyTailwindcssCssImportRewrite(compiler, options) {
155
155
  if (!options.enabled) {
156
156
  return;
157
157
  }
158
- compiler.hooks.normalModuleFactory.tap(_chunkRQWWSU4Ujs.pluginName, (factory) => {
159
- factory.hooks.beforeResolve.tap(_chunkRQWWSU4Ujs.pluginName, (data) => {
158
+ compiler.hooks.normalModuleFactory.tap(_chunkYVRX3F6Sjs.pluginName, (factory) => {
159
+ factory.hooks.beforeResolve.tap(_chunkYVRX3F6Sjs.pluginName, (data) => {
160
160
  rewriteTailwindcssRequestForCss(data, options.pkgDir, options.appType);
161
161
  });
162
162
  });
@@ -27,7 +27,7 @@ var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
27
27
 
28
28
 
29
29
 
30
- var _chunkRQWWSU4Ujs = require('./chunk-RQWWSU4U.js');
30
+ var _chunkYVRX3F6Sjs = require('./chunk-YVRX3F6S.js');
31
31
 
32
32
 
33
33
 
@@ -92,7 +92,7 @@ function isRuntimeCandidate(candidate, runtimeSet) {
92
92
  if (!runtimeSet || runtimeSet.size === 0) {
93
93
  return false;
94
94
  }
95
- return runtimeSet.has(candidate) || runtimeSet.has(_chunkRQWWSU4Ujs.replaceWxml.call(void 0, candidate));
95
+ return runtimeSet.has(candidate) || runtimeSet.has(_chunkYVRX3F6Sjs.replaceWxml.call(void 0, candidate));
96
96
  }
97
97
  function shouldEnableComponentLocalStyle(id) {
98
98
  return COMPONENT_RE.test(id);
@@ -112,7 +112,7 @@ var UniAppXComponentLocalStyleCollector = class {
112
112
  const alias = createAlias(this.fileId, utility, this.aliasByUtility.size);
113
113
  this.aliasByUtility.set(utility, alias);
114
114
  this.aliasByLookup.set(utility, alias);
115
- this.aliasByLookup.set(_chunkRQWWSU4Ujs.replaceWxml.call(void 0, utility), alias);
115
+ this.aliasByLookup.set(_chunkYVRX3F6Sjs.replaceWxml.call(void 0, utility), alias);
116
116
  return alias;
117
117
  }
118
118
  rewriteLiteral(literal, shouldInclude) {
@@ -135,15 +135,15 @@ var UniAppXComponentLocalStyleCollector = class {
135
135
  collectRuntimeClasses(rawSource, options = {}) {
136
136
  const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
137
137
  try {
138
- const ast = _chunkRQWWSU4Ujs.babelParse.call(void 0, wrapped, {
138
+ const ast = _chunkYVRX3F6Sjs.babelParse.call(void 0, wrapped, {
139
139
  plugins: ["typescript"],
140
140
  sourceType: options.wrapExpression ? "module" : "unambiguous"
141
141
  });
142
- const analysis = _chunkRQWWSU4Ujs.analyzeSource.call(void 0, ast, {}, void 0, false);
142
+ const analysis = _chunkYVRX3F6Sjs.analyzeSource.call(void 0, ast, {}, void 0, false);
143
143
  for (const path7 of analysis.targetPaths) {
144
144
  const { literal, allowDoubleQuotes } = extractLiteralValue(path7);
145
145
  const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
146
- const classContext = options.wrapExpression || _chunkRQWWSU4Ujs.isClassContextLiteralPath.call(void 0, path7);
146
+ const classContext = options.wrapExpression || _chunkYVRX3F6Sjs.isClassContextLiteralPath.call(void 0, path7);
147
147
  for (const candidate of candidates) {
148
148
  if (!candidate || !classContext && !isRuntimeCandidate(candidate, this.runtimeSet)) {
149
149
  continue;
@@ -162,15 +162,15 @@ var UniAppXComponentLocalStyleCollector = class {
162
162
  }
163
163
  const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
164
164
  try {
165
- const ast = _chunkRQWWSU4Ujs.babelParse.call(void 0, wrapped, {
165
+ const ast = _chunkYVRX3F6Sjs.babelParse.call(void 0, wrapped, {
166
166
  plugins: ["typescript"],
167
167
  sourceType: options.wrapExpression ? "module" : "unambiguous"
168
168
  });
169
- const analysis = _chunkRQWWSU4Ujs.analyzeSource.call(void 0, ast, {}, void 0, false);
169
+ const analysis = _chunkYVRX3F6Sjs.analyzeSource.call(void 0, ast, {}, void 0, false);
170
170
  if (analysis.targetPaths.length === 0) {
171
171
  return rawSource;
172
172
  }
173
- const updater = new (0, _chunkRQWWSU4Ujs.JsTokenUpdater)();
173
+ const updater = new (0, _chunkYVRX3F6Sjs.JsTokenUpdater)();
174
174
  for (const path7 of analysis.targetPaths) {
175
175
  const { literal, allowDoubleQuotes, offset } = extractLiteralValue(path7);
176
176
  const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
@@ -251,7 +251,7 @@ function updateStaticAttribute(ms, prop, content = _optionalChain([prop, 'access
251
251
  const start = prop.value.loc.start.offset + 1;
252
252
  const end = prop.value.loc.end.offset - 1;
253
253
  if (start < end) {
254
- ms.update(start, end, _chunkRQWWSU4Ujs.replaceWxml.call(void 0, _nullishCoalesce(content, () => ( ""))));
254
+ ms.update(start, end, _chunkYVRX3F6Sjs.replaceWxml.call(void 0, _nullishCoalesce(content, () => ( ""))));
255
255
  }
256
256
  }
257
257
  function updateStaticAttributeWithLocalStyle(ms, prop, collector, content = _optionalChain([prop, 'access', _3 => _3.value, 'optionalAccess', _4 => _4.content])) {
@@ -273,7 +273,7 @@ function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet, expression =
273
273
  if (start >= end) {
274
274
  return;
275
275
  }
276
- const generated = _chunkRQWWSU4Ujs.generateCode.call(void 0, expression, {
276
+ const generated = _chunkYVRX3F6Sjs.generateCode.call(void 0, expression, {
277
277
  jsHandler,
278
278
  runtimeSet,
279
279
  wrapExpression: true
@@ -292,7 +292,7 @@ function updateDirectiveExpressionWithLocalStyle(ms, prop, jsHandler, collector,
292
292
  collector.collectRuntimeClasses(expression, {
293
293
  wrapExpression: true
294
294
  });
295
- const generated = _chunkRQWWSU4Ujs.generateCode.call(void 0, expression, {
295
+ const generated = _chunkYVRX3F6Sjs.generateCode.call(void 0, expression, {
296
296
  jsHandler,
297
297
  runtimeSet,
298
298
  wrapExpression: true
@@ -322,7 +322,7 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
322
322
  return;
323
323
  }
324
324
  const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
325
- const matchCustomAttribute = _chunkRQWWSU4Ujs.createAttributeMatcher.call(void 0, customAttributesEntities);
325
+ const matchCustomAttribute = _chunkYVRX3F6Sjs.createAttributeMatcher.call(void 0, customAttributesEntities);
326
326
  const ms = new (0, _magicstring2.default)(code);
327
327
  const { descriptor, errors } = _compilersfc.parse.call(void 0, code);
328
328
  const localStyleCollector = options.enableComponentLocalStyle && shouldEnableComponentLocalStyle(id) ? new UniAppXComponentLocalStyleCollector(id, runtimeSet) : void 0;
@@ -401,13 +401,17 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
401
401
  ${localStyleCollector.toStyleBlock()}`);
402
402
  }
403
403
  }
404
- return {
405
- code: ms.toString(),
406
- // @ts-ignore
407
- get map() {
404
+ const result = {
405
+ code: ms.toString()
406
+ };
407
+ Object.defineProperty(result, "map", {
408
+ configurable: true,
409
+ enumerable: true,
410
+ get() {
408
411
  return ms.generateMap();
409
412
  }
410
- };
413
+ });
414
+ return result;
411
415
  }
412
416
 
413
417
  // src/bundlers/vite/query.ts
@@ -836,14 +840,14 @@ function createHtmlRuntimeAffectingSignature(source) {
836
840
  }
837
841
  function createJsRuntimeAffectingSignature(source) {
838
842
  try {
839
- const ast = _chunkRQWWSU4Ujs.babelParse.call(void 0, source, {
843
+ const ast = _chunkYVRX3F6Sjs.babelParse.call(void 0, source, {
840
844
  cache: true,
841
845
  cacheKey: "vite-runtime-affecting:unambiguous",
842
846
  plugins: ["jsx", "typescript"],
843
847
  sourceType: "unambiguous"
844
848
  });
845
849
  const parts = [];
846
- _chunkRQWWSU4Ujs.traverse.call(void 0, ast, {
850
+ _chunkYVRX3F6Sjs.traverse.call(void 0, ast, {
847
851
  noScope: true,
848
852
  StringLiteral(path7) {
849
853
  parts.push(`s:${path7.node.value}`);
@@ -1464,7 +1468,7 @@ function createGenerateBundleHook(context) {
1464
1468
  debug3("js cache replay miss, fallback transform: %s", file);
1465
1469
  }
1466
1470
  const handlerOptions = createHandlerOptions(absoluteFile);
1467
- if (!disableJsPrecheck && _chunkRQWWSU4Ujs.shouldSkipJsTransform.call(void 0, rawSource, handlerOptions)) {
1471
+ if (!disableJsPrecheck && _chunkYVRX3F6Sjs.shouldSkipJsTransform.call(void 0, rawSource, handlerOptions)) {
1468
1472
  metrics.js.elapsed += measureElapsed(start);
1469
1473
  metrics.js.transformed++;
1470
1474
  return {
@@ -1550,7 +1554,7 @@ function createGenerateBundleHook(context) {
1550
1554
  sourceType: "unambiguous"
1551
1555
  }
1552
1556
  });
1553
- if (!disableJsPrecheck && _chunkRQWWSU4Ujs.shouldSkipJsTransform.call(void 0, currentSource, precheckOptions)) {
1557
+ if (!disableJsPrecheck && _chunkYVRX3F6Sjs.shouldSkipJsTransform.call(void 0, currentSource, precheckOptions)) {
1554
1558
  metrics.js.elapsed += measureElapsed(start);
1555
1559
  metrics.js.transformed++;
1556
1560
  return;
@@ -1603,7 +1607,7 @@ var _module = require('module');
1603
1607
 
1604
1608
 
1605
1609
  var _tailwindcsspatch = require('tailwindcss-patch');
1606
- var debug = _chunkRQWWSU4Ujs.createDebug.call(void 0, "[vite:runtime-set] ");
1610
+ var debug = _chunkYVRX3F6Sjs.createDebug.call(void 0, "[vite:runtime-set] ");
1607
1611
  var require2 = _module.createRequire.call(void 0, _chunkONLKZIRQjs.importMetaUrl);
1608
1612
  var EXTENSION_DOT_PREFIX_RE = /^\./;
1609
1613
  var VALIDATION_FILE_NAME = "runtime-candidates.html";
@@ -2071,7 +2075,7 @@ function createRewriteCssImportsPlugins(options) {
2071
2075
  const resolveAppType = () => _nullishCoalesce(_optionalChain([getAppType, 'optionalCall', _68 => _68()]), () => ( appType));
2072
2076
  return [
2073
2077
  {
2074
- name: `${_chunkRQWWSU4Ujs.vitePluginName}:rewrite-css-imports`,
2078
+ name: `${_chunkYVRX3F6Sjs.vitePluginName}:rewrite-css-imports`,
2075
2079
  enforce: "pre",
2076
2080
  resolveId: {
2077
2081
  order: "pre",
@@ -2113,10 +2117,17 @@ function createRewriteCssImportsPlugins(options) {
2113
2117
  }
2114
2118
 
2115
2119
  // src/bundlers/vite/index.ts
2116
- var debug2 = _chunkRQWWSU4Ujs.createDebug.call(void 0, );
2120
+ var debug2 = _chunkYVRX3F6Sjs.createDebug.call(void 0, );
2117
2121
  var weappTailwindcssPackageDir = _chunkGMKSBLNYjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
2118
2122
  var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
2119
2123
  var PACKAGE_JSON_FILE2 = "package.json";
2124
+ function getPostcssPluginName(plugin) {
2125
+ if (!plugin || typeof plugin !== "object" || !("postcssPlugin" in plugin)) {
2126
+ return;
2127
+ }
2128
+ const { postcssPlugin } = plugin;
2129
+ return typeof postcssPlugin === "string" ? postcssPlugin : void 0;
2130
+ }
2120
2131
  function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
2121
2132
  const resolvedRoot = _path2.default.resolve(root);
2122
2133
  if (!_fs.existsSync.call(void 0, resolvedRoot)) {
@@ -2146,7 +2157,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2146
2157
  const hasExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
2147
2158
  const rewriteCssImportsSpecified = Object.hasOwn(options, "rewriteCssImports");
2148
2159
  const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
2149
- const opts = _chunkRQWWSU4Ujs.getCompilerContext.call(void 0, options);
2160
+ const opts = _chunkYVRX3F6Sjs.getCompilerContext.call(void 0, options);
2150
2161
  const {
2151
2162
  disabled,
2152
2163
  customAttributes,
@@ -2171,8 +2182,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2171
2182
  if (disabledOptions.plugin) {
2172
2183
  return rewritePlugins.length ? rewritePlugins : void 0;
2173
2184
  }
2174
- const customAttributesEntities = _chunkRQWWSU4Ujs.toCustomAttributesEntities.call(void 0, customAttributes);
2175
- const patchRecorderState = _chunkRQWWSU4Ujs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
2185
+ const customAttributesEntities = _chunkYVRX3F6Sjs.toCustomAttributesEntities.call(void 0, customAttributes);
2186
+ const patchRecorderState = _chunkYVRX3F6Sjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
2176
2187
  source: "runtime",
2177
2188
  cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
2178
2189
  });
@@ -2211,7 +2222,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2211
2222
  async function refreshRuntimeState(force) {
2212
2223
  const invalidation = resolveRuntimeRefreshOptions();
2213
2224
  const shouldRefresh = force || invalidation.changed;
2214
- const refreshed = await _chunkRQWWSU4Ujs.refreshTailwindRuntimeState.call(void 0, runtimeState, {
2225
+ const refreshed = await _chunkYVRX3F6Sjs.refreshTailwindRuntimeState.call(void 0, runtimeState, {
2215
2226
  force: shouldRefresh,
2216
2227
  clearCache: force || invalidation.changed
2217
2228
  });
@@ -2232,7 +2243,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2232
2243
  }
2233
2244
  if (forceRuntimeRefresh || !runtimeSetPromise) {
2234
2245
  const invalidation = resolveRuntimeRefreshOptions();
2235
- const task2 = _chunkRQWWSU4Ujs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
2246
+ const task2 = _chunkYVRX3F6Sjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
2236
2247
  force: forceRuntimeRefresh || invalidation.changed,
2237
2248
  skipRefresh: forceRuntimeRefresh,
2238
2249
  clearCache: forceRuntimeRefresh || invalidation.changed
@@ -2274,7 +2285,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2274
2285
  if (!forceRuntimeRefresh && !invalidation.changed && !forceCollectBySource && runtimeSet) {
2275
2286
  return runtimeSet;
2276
2287
  }
2277
- const task = _chunkRQWWSU4Ujs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
2288
+ const task = _chunkYVRX3F6Sjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
2278
2289
  force: forceRuntimeRefresh || invalidation.changed || forceCollectBySource,
2279
2290
  skipRefresh: forceRuntimeRefresh,
2280
2291
  clearCache: forceRuntimeRefresh || invalidation.changed
@@ -2309,7 +2320,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2309
2320
  const plugins = [
2310
2321
  ...rewritePlugins,
2311
2322
  {
2312
- name: `${_chunkRQWWSU4Ujs.vitePluginName}:post`,
2323
+ name: `${_chunkYVRX3F6Sjs.vitePluginName}:post`,
2313
2324
  enforce: "post",
2314
2325
  async configResolved(config) {
2315
2326
  resolvedConfig = config;
@@ -2347,10 +2358,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2347
2358
  }
2348
2359
  if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
2349
2360
  const postcssPlugins = config.css.postcss.plugins;
2350
- const idx = postcssPlugins.findIndex((x) => (
2351
- // @ts-ignore
2352
- x.postcssPlugin === "postcss-html-transform"
2353
- ));
2361
+ const idx = postcssPlugins.findIndex((x) => getPostcssPluginName(x) === "postcss-html-transform");
2354
2362
  if (idx > -1) {
2355
2363
  postcssPlugins.splice(idx, 1, _htmltransform2.default.call(void 0, ));
2356
2364
  debug2("remove postcss-html-transform plugin from vite config");
@@ -27,7 +27,7 @@ import {
27
27
  toCustomAttributesEntities,
28
28
  traverse,
29
29
  vitePluginName
30
- } from "./chunk-ZABCOAAS.mjs";
30
+ } from "./chunk-LWEVOVRD.mjs";
31
31
  import {
32
32
  findNearestPackageRoot,
33
33
  findTailwindConfig,
@@ -398,13 +398,17 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
398
398
  ${localStyleCollector.toStyleBlock()}`);
399
399
  }
400
400
  }
401
- return {
402
- code: ms.toString(),
403
- // @ts-ignore
404
- get map() {
401
+ const result = {
402
+ code: ms.toString()
403
+ };
404
+ Object.defineProperty(result, "map", {
405
+ configurable: true,
406
+ enumerable: true,
407
+ get() {
405
408
  return ms.generateMap();
406
409
  }
407
- };
410
+ });
411
+ return result;
408
412
  }
409
413
 
410
414
  // src/bundlers/vite/query.ts
@@ -2114,6 +2118,13 @@ var debug2 = createDebug();
2114
2118
  var weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
2115
2119
  var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
2116
2120
  var PACKAGE_JSON_FILE2 = "package.json";
2121
+ function getPostcssPluginName(plugin) {
2122
+ if (!plugin || typeof plugin !== "object" || !("postcssPlugin" in plugin)) {
2123
+ return;
2124
+ }
2125
+ const { postcssPlugin } = plugin;
2126
+ return typeof postcssPlugin === "string" ? postcssPlugin : void 0;
2127
+ }
2117
2128
  function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
2118
2129
  const resolvedRoot = path6.resolve(root);
2119
2130
  if (!existsSync2(resolvedRoot)) {
@@ -2344,10 +2355,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2344
2355
  }
2345
2356
  if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
2346
2357
  const postcssPlugins = config.css.postcss.plugins;
2347
- const idx = postcssPlugins.findIndex((x) => (
2348
- // @ts-ignore
2349
- x.postcssPlugin === "postcss-html-transform"
2350
- ));
2358
+ const idx = postcssPlugins.findIndex((x) => getPostcssPluginName(x) === "postcss-html-transform");
2351
2359
  if (idx > -1) {
2352
2360
  postcssPlugins.splice(idx, 1, postcssHtmlTransform());
2353
2361
  debug2("remove postcss-html-transform plugin from vite config");
@@ -8,7 +8,7 @@ import {
8
8
  refreshTailwindRuntimeState,
9
9
  setupPatchRecorder,
10
10
  shouldSkipJsTransform
11
- } from "./chunk-ZABCOAAS.mjs";
11
+ } from "./chunk-LWEVOVRD.mjs";
12
12
 
13
13
  // src/bundlers/gulp/index.ts
14
14
  import { Buffer } from "buffer";
@@ -33,12 +33,13 @@ function ifndef(text) {
33
33
  }
34
34
  var QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
35
35
  function matchCustomPropertyFromValue(str, cb) {
36
- let arr;
37
36
  let index = 0;
38
37
  QUERY_KEY_REGEX.lastIndex = 0;
39
- while ((arr = QUERY_KEY_REGEX.exec(str)) !== null) {
38
+ let arr = QUERY_KEY_REGEX.exec(str);
39
+ while (arr !== null) {
40
40
  cb(arr, index);
41
41
  index++;
42
+ arr = QUERY_KEY_REGEX.exec(str);
42
43
  }
43
44
  }
44
45
 
@@ -466,7 +466,7 @@ import { logger as logger3 } from "@weapp-tailwindcss/logger";
466
466
  // package.json
467
467
  var package_default = {
468
468
  name: "weapp-tailwindcss",
469
- version: "4.12.0-alpha.1",
469
+ version: "4.12.0-alpha.2",
470
470
  description: "\u628A tailwindcss \u539F\u5B50\u5316\u6837\u5F0F\u601D\u60F3\uFF0C\u5E26\u7ED9\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u4EEC! bring tailwindcss to miniprogram developers!",
471
471
  author: "ice breaker <1324318532@qq.com>",
472
472
  license: "MIT",
@@ -616,13 +616,14 @@ var package_default = {
616
616
  "dist",
617
617
  "index.css",
618
618
  "preflight.css",
619
+ "scripts/postinstall.mjs",
619
620
  "theme.css",
620
621
  "uni-app-x.css",
621
622
  "utilities.css",
622
623
  "with-layer.css"
623
624
  ],
624
625
  engines: {
625
- node: "^18.17.0 || >=20.5.0"
626
+ node: "^20.19.0 || >=22.12.0"
626
627
  },
627
628
  scripts: {
628
629
  dev: "tsup --watch --sourcemap",
@@ -631,7 +632,7 @@ var package_default = {
631
632
  "build:cli": "cd plugins/cli && pnpm run build",
632
633
  "build:css": "tsx scripts/build-css.ts",
633
634
  "build:weapp-theme": "tsx scripts/build-weapp-theme.ts",
634
- test: "npm run postinstall && vitest run",
635
+ test: "pnpm run cli:patch && vitest run",
635
636
  "test:dev": "vitest",
636
637
  "test:ui": "vitest --ui",
637
638
  bench: "vitest bench --config ./vitest.config.ts",
@@ -648,7 +649,7 @@ var package_default = {
648
649
  release: "tsx scripts/release.ts",
649
650
  lint: "eslint .",
650
651
  "lint:fix": "eslint ./src --fix",
651
- postinstall: "node bin/weapp-tailwindcss.js patch",
652
+ postinstall: "node scripts/postinstall.mjs",
652
653
  "bench:vite-dev-hmr": "tsx scripts/vite-dev-hmr-bench.ts",
653
654
  "test:watch-hmr": "node --import tsx scripts/watch-hmr-regression/index.ts"
654
655
  },
@@ -2810,6 +2811,7 @@ var EMPTY_IMPORT_DECLARATIONS = /* @__PURE__ */ new Set();
2810
2811
  var EMPTY_EXPORT_DECLARATIONS = /* @__PURE__ */ new Set();
2811
2812
  var EMPTY_REQUIRE_CALL_PATHS = [];
2812
2813
  var ignoredTaggedTemplateMatcherCache = /* @__PURE__ */ new WeakMap();
2814
+ var defaultEvalHandler;
2813
2815
  function getIgnoredTaggedTemplateMatcher(options) {
2814
2816
  const cached = ignoredTaggedTemplateMatcherCache.get(options);
2815
2817
  if (cached) {
@@ -2819,6 +2821,12 @@ function getIgnoredTaggedTemplateMatcher(options) {
2819
2821
  ignoredTaggedTemplateMatcherCache.set(options, created);
2820
2822
  return created;
2821
2823
  }
2824
+ function getDefaultEvalHandler() {
2825
+ if (!defaultEvalHandler) {
2826
+ throw new Error("Default JS eval handler is not initialized.");
2827
+ }
2828
+ return defaultEvalHandler;
2829
+ }
2822
2830
  function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
2823
2831
  const jsTokenUpdater = new JsTokenUpdater();
2824
2832
  const needScope = Boolean(options.ignoreCallExpressionIdentifiers && options.ignoreCallExpressionIdentifiers.length > 0);
@@ -2846,7 +2854,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
2846
2854
  const importDeclarations = collectModuleMetadata ? /* @__PURE__ */ new Set() : EMPTY_IMPORT_DECLARATIONS;
2847
2855
  const exportDeclarations = collectModuleMetadata ? /* @__PURE__ */ new Set() : EMPTY_EXPORT_DECLARATIONS;
2848
2856
  const requireCallPaths = collectModuleMetadata ? [] : EMPTY_REQUIRE_CALL_PATHS;
2849
- const evalHandler = handler ?? jsHandler;
2857
+ const evalHandler = handler ?? getDefaultEvalHandler();
2850
2858
  const templateElementEnter = hasTaggedTemplateIgnoreIdentifiers ? (p) => {
2851
2859
  const pp = p.parentPath;
2852
2860
  if (pp.isTemplateLiteral()) {
@@ -2987,6 +2995,7 @@ function jsHandler(rawSource, options) {
2987
2995
  }
2988
2996
  return result;
2989
2997
  }
2998
+ defaultEvalHandler = jsHandler;
2990
2999
 
2991
3000
  // src/js/index.ts
2992
3001
  var RESULT_CACHE_MAX = 512;