weapp-tailwindcss 4.11.0 → 4.11.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 (49) hide show
  1. package/dist/{chunk-2PXISDSY.js → chunk-3QHYEMEW.js} +28 -28
  2. package/dist/{chunk-LL3QUKJI.js → chunk-A5PB4KZT.js} +2 -0
  3. package/dist/{chunk-KWSWZP5H.mjs → chunk-AB2RGZQO.mjs} +92 -46
  4. package/dist/{chunk-ZQAWDXIW.js → chunk-AV3XB6EQ.js} +3 -3
  5. package/dist/{chunk-MAIS4SDW.mjs → chunk-JIERVBTX.mjs} +1 -1
  6. package/dist/{chunk-C4CWDYUP.js → chunk-SUKOZ6OG.js} +6 -6
  7. package/dist/{chunk-Z6RS5OPN.js → chunk-TT5WHNGS.js} +61 -15
  8. package/dist/{chunk-Y75XZ6KA.mjs → chunk-VGPAKLMZ.mjs} +2 -2
  9. package/dist/{chunk-UO725AHQ.mjs → chunk-W3DXDWYC.mjs} +154 -38
  10. package/dist/{chunk-GVYD6TY7.js → chunk-WJIRXC26.js} +172 -56
  11. package/dist/{chunk-23K4XDKF.mjs → chunk-XAKAD2CR.mjs} +2 -0
  12. package/dist/{chunk-FTFADUJ4.mjs → chunk-ZZ36BKM5.mjs} +1 -1
  13. package/dist/cli.js +115 -82
  14. package/dist/cli.mjs +115 -82
  15. package/dist/core.d.mts +1 -1
  16. package/dist/core.d.ts +1 -1
  17. package/dist/core.js +7 -7
  18. package/dist/core.mjs +2 -2
  19. package/dist/defaults.d.mts +1 -1
  20. package/dist/defaults.d.ts +1 -1
  21. package/dist/defaults.js +2 -2
  22. package/dist/defaults.mjs +1 -1
  23. package/dist/gulp.d.mts +1 -1
  24. package/dist/gulp.d.ts +1 -1
  25. package/dist/gulp.js +4 -4
  26. package/dist/gulp.mjs +3 -3
  27. package/dist/{index-D8E0GGqB.d.mts → index-CoXntW_P.d.mts} +1 -1
  28. package/dist/{index-D8E0GGqB.d.ts → index-CoXntW_P.d.ts} +1 -1
  29. package/dist/index.d.mts +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.js +7 -7
  32. package/dist/index.mjs +6 -6
  33. package/dist/presets.d.mts +1 -1
  34. package/dist/presets.d.ts +1 -1
  35. package/dist/types.d.mts +2 -2
  36. package/dist/types.d.ts +2 -2
  37. package/dist/vite.d.mts +2 -2
  38. package/dist/vite.d.ts +2 -2
  39. package/dist/vite.js +4 -4
  40. package/dist/vite.mjs +3 -3
  41. package/dist/webpack.d.mts +1 -1
  42. package/dist/webpack.d.ts +1 -1
  43. package/dist/webpack.js +5 -5
  44. package/dist/webpack.mjs +4 -4
  45. package/dist/webpack4.d.mts +1 -1
  46. package/dist/webpack4.d.ts +1 -1
  47. package/dist/webpack4.js +25 -25
  48. package/dist/webpack4.mjs +3 -3
  49. package/package.json +3 -3
@@ -26,7 +26,7 @@ var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
26
26
 
27
27
 
28
28
 
29
- var _chunkZ6RS5OPNjs = require('./chunk-Z6RS5OPN.js');
29
+ var _chunkTT5WHNGSjs = require('./chunk-TT5WHNGS.js');
30
30
 
31
31
 
32
32
 
@@ -46,6 +46,7 @@ var _chunkCRDOWYG4js = require('./chunk-CRDOWYG4.js');
46
46
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
47
47
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
48
48
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
49
+ var _logger = require('@weapp-tailwindcss/logger');
49
50
  var _htmltransform = require('@weapp-tailwindcss/postcss/html-transform'); var _htmltransform2 = _interopRequireDefault(_htmltransform);
50
51
 
51
52
  // src/uni-app-x/transform.ts
@@ -67,18 +68,18 @@ function createStableHash(input) {
67
68
  }
68
69
  return (hash >>> 0).toString(36);
69
70
  }
70
- function extractLiteralValue(path6) {
71
- const allowDoubleQuotes = path6.isTemplateElement();
72
- if (path6.isStringLiteral()) {
71
+ function extractLiteralValue(path7) {
72
+ const allowDoubleQuotes = path7.isTemplateElement();
73
+ if (path7.isStringLiteral()) {
73
74
  return {
74
75
  allowDoubleQuotes,
75
- literal: path6.node.value,
76
+ literal: path7.node.value,
76
77
  offset: 1
77
78
  };
78
79
  }
79
80
  return {
80
81
  allowDoubleQuotes,
81
- literal: path6.node.value.raw,
82
+ literal: path7.node.value.raw,
82
83
  offset: 0
83
84
  };
84
85
  }
@@ -89,7 +90,7 @@ function isRuntimeCandidate(candidate, runtimeSet) {
89
90
  if (!runtimeSet || runtimeSet.size === 0) {
90
91
  return false;
91
92
  }
92
- return runtimeSet.has(candidate) || runtimeSet.has(_chunkZ6RS5OPNjs.replaceWxml.call(void 0, candidate));
93
+ return runtimeSet.has(candidate) || runtimeSet.has(_chunkTT5WHNGSjs.replaceWxml.call(void 0, candidate));
93
94
  }
94
95
  function shouldEnableComponentLocalStyle(id) {
95
96
  return COMPONENT_RE.test(id);
@@ -109,7 +110,7 @@ var UniAppXComponentLocalStyleCollector = class {
109
110
  const alias = createAlias(this.fileId, utility, this.aliasByUtility.size);
110
111
  this.aliasByUtility.set(utility, alias);
111
112
  this.aliasByLookup.set(utility, alias);
112
- this.aliasByLookup.set(_chunkZ6RS5OPNjs.replaceWxml.call(void 0, utility), alias);
113
+ this.aliasByLookup.set(_chunkTT5WHNGSjs.replaceWxml.call(void 0, utility), alias);
113
114
  return alias;
114
115
  }
115
116
  rewriteLiteral(literal, shouldInclude) {
@@ -132,15 +133,15 @@ var UniAppXComponentLocalStyleCollector = class {
132
133
  collectRuntimeClasses(rawSource, options = {}) {
133
134
  const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
134
135
  try {
135
- const ast = _chunkZ6RS5OPNjs.babelParse.call(void 0, wrapped, {
136
+ const ast = _chunkTT5WHNGSjs.babelParse.call(void 0, wrapped, {
136
137
  plugins: ["typescript"],
137
138
  sourceType: options.wrapExpression ? "module" : "unambiguous"
138
139
  });
139
- const analysis = _chunkZ6RS5OPNjs.analyzeSource.call(void 0, ast, {}, void 0, false);
140
- for (const path6 of analysis.targetPaths) {
141
- const { literal, allowDoubleQuotes } = extractLiteralValue(path6);
140
+ const analysis = _chunkTT5WHNGSjs.analyzeSource.call(void 0, ast, {}, void 0, false);
141
+ for (const path7 of analysis.targetPaths) {
142
+ const { literal, allowDoubleQuotes } = extractLiteralValue(path7);
142
143
  const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
143
- const classContext = options.wrapExpression || _chunkZ6RS5OPNjs.isClassContextLiteralPath.call(void 0, path6);
144
+ const classContext = options.wrapExpression || _chunkTT5WHNGSjs.isClassContextLiteralPath.call(void 0, path7);
144
145
  for (const candidate of candidates) {
145
146
  if (!candidate || !classContext && !isRuntimeCandidate(candidate, this.runtimeSet)) {
146
147
  continue;
@@ -159,17 +160,17 @@ var UniAppXComponentLocalStyleCollector = class {
159
160
  }
160
161
  const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
161
162
  try {
162
- const ast = _chunkZ6RS5OPNjs.babelParse.call(void 0, wrapped, {
163
+ const ast = _chunkTT5WHNGSjs.babelParse.call(void 0, wrapped, {
163
164
  plugins: ["typescript"],
164
165
  sourceType: options.wrapExpression ? "module" : "unambiguous"
165
166
  });
166
- const analysis = _chunkZ6RS5OPNjs.analyzeSource.call(void 0, ast, {}, void 0, false);
167
+ const analysis = _chunkTT5WHNGSjs.analyzeSource.call(void 0, ast, {}, void 0, false);
167
168
  if (analysis.targetPaths.length === 0) {
168
169
  return rawSource;
169
170
  }
170
- const updater = new (0, _chunkZ6RS5OPNjs.JsTokenUpdater)();
171
- for (const path6 of analysis.targetPaths) {
172
- const { literal, allowDoubleQuotes, offset } = extractLiteralValue(path6);
171
+ const updater = new (0, _chunkTT5WHNGSjs.JsTokenUpdater)();
172
+ for (const path7 of analysis.targetPaths) {
173
+ const { literal, allowDoubleQuotes, offset } = extractLiteralValue(path7);
173
174
  const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
174
175
  if (candidates.length === 0) {
175
176
  continue;
@@ -187,14 +188,14 @@ var UniAppXComponentLocalStyleCollector = class {
187
188
  mutated = true;
188
189
  }
189
190
  }
190
- if (!mutated || typeof path6.node.start !== "number" || typeof path6.node.end !== "number") {
191
+ if (!mutated || typeof path7.node.start !== "number" || typeof path7.node.end !== "number") {
191
192
  continue;
192
193
  }
193
194
  updater.addToken({
194
- start: path6.node.start + offset,
195
- end: path6.node.end - offset,
195
+ start: path7.node.start + offset,
196
+ end: path7.node.end - offset,
196
197
  value: rewritten,
197
- path: path6
198
+ path: path7
198
199
  });
199
200
  }
200
201
  if (updater.length === 0) {
@@ -248,7 +249,7 @@ function updateStaticAttribute(ms, prop) {
248
249
  const start = prop.value.loc.start.offset + 1;
249
250
  const end = prop.value.loc.end.offset - 1;
250
251
  if (start < end) {
251
- ms.update(start, end, _chunkZ6RS5OPNjs.replaceWxml.call(void 0, prop.value.content));
252
+ ms.update(start, end, _chunkTT5WHNGSjs.replaceWxml.call(void 0, prop.value.content));
252
253
  }
253
254
  }
254
255
  function updateStaticAttributeWithLocalStyle(ms, prop, collector) {
@@ -270,7 +271,7 @@ function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
270
271
  if (start >= end) {
271
272
  return;
272
273
  }
273
- const generated = _chunkZ6RS5OPNjs.generateCode.call(void 0, prop.exp.content, {
274
+ const generated = _chunkTT5WHNGSjs.generateCode.call(void 0, prop.exp.content, {
274
275
  jsHandler,
275
276
  runtimeSet,
276
277
  wrapExpression: true
@@ -289,7 +290,7 @@ function updateDirectiveExpressionWithLocalStyle(ms, prop, jsHandler, collector,
289
290
  collector.collectRuntimeClasses(prop.exp.content, {
290
291
  wrapExpression: true
291
292
  });
292
- const generated = _chunkZ6RS5OPNjs.generateCode.call(void 0, prop.exp.content, {
293
+ const generated = _chunkTT5WHNGSjs.generateCode.call(void 0, prop.exp.content, {
293
294
  jsHandler,
294
295
  runtimeSet,
295
296
  wrapExpression: true
@@ -319,7 +320,7 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
319
320
  return;
320
321
  }
321
322
  const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
322
- const matchCustomAttribute = _chunkZ6RS5OPNjs.createAttributeMatcher.call(void 0, customAttributesEntities);
323
+ const matchCustomAttribute = _chunkTT5WHNGSjs.createAttributeMatcher.call(void 0, customAttributesEntities);
323
324
  const ms = new (0, _magicstring2.default)(code);
324
325
  const { descriptor, errors } = _compilersfc.parse.call(void 0, code);
325
326
  const localStyleCollector = options.enableComponentLocalStyle && shouldEnableComponentLocalStyle(id) ? new UniAppXComponentLocalStyleCollector(id, runtimeSet) : void 0;
@@ -710,7 +711,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
710
711
  // src/bundlers/vite/generate-bundle.ts
711
712
 
712
713
 
713
- var _logger = require('@weapp-tailwindcss/logger');
714
+
714
715
 
715
716
 
716
717
  // src/bundlers/vite/bundle-entries.ts
@@ -818,23 +819,23 @@ function createHtmlRuntimeAffectingSignature(source) {
818
819
  }
819
820
  function createJsRuntimeAffectingSignature(source) {
820
821
  try {
821
- const ast = _chunkZ6RS5OPNjs.babelParse.call(void 0, source, {
822
+ const ast = _chunkTT5WHNGSjs.babelParse.call(void 0, source, {
822
823
  cache: true,
823
824
  cacheKey: "vite-runtime-affecting:unambiguous",
824
825
  plugins: ["jsx", "typescript"],
825
826
  sourceType: "unambiguous"
826
827
  });
827
828
  const parts = [];
828
- _chunkZ6RS5OPNjs.traverse.call(void 0, ast, {
829
+ _chunkTT5WHNGSjs.traverse.call(void 0, ast, {
829
830
  noScope: true,
830
- StringLiteral(path6) {
831
- parts.push(`s:${path6.node.value}`);
831
+ StringLiteral(path7) {
832
+ parts.push(`s:${path7.node.value}`);
832
833
  },
833
- TemplateElement(path6) {
834
- parts.push(`t:${path6.node.value.raw}`);
834
+ TemplateElement(path7) {
835
+ parts.push(`t:${path7.node.value.raw}`);
835
836
  },
836
- JSXText(path6) {
837
- const value = path6.node.value.trim();
837
+ JSXText(path7) {
838
+ const value = path7.node.value.trim();
838
839
  if (value.length > 0) {
839
840
  parts.push(`x:${value}`);
840
841
  }
@@ -1607,7 +1608,7 @@ var _module = require('module');
1607
1608
 
1608
1609
 
1609
1610
  var _tailwindcsspatch = require('tailwindcss-patch');
1610
- var debug = _chunkZ6RS5OPNjs.createDebug.call(void 0, "[vite:runtime-set] ");
1611
+ var debug = _chunkTT5WHNGSjs.createDebug.call(void 0, "[vite:runtime-set] ");
1611
1612
  var require2 = _module.createRequire.call(void 0, _chunkCRDOWYG4js.importMetaUrl);
1612
1613
  var EXTENSION_DOT_PREFIX_RE = /^\./;
1613
1614
  var VALIDATION_FILE_NAME = "runtime-candidates.html";
@@ -1957,6 +1958,102 @@ function createBundleRuntimeClassSetManager(options = {}) {
1957
1958
  };
1958
1959
  }
1959
1960
 
1961
+ // src/bundlers/vite/resolve-app-type.ts
1962
+
1963
+
1964
+ var PACKAGE_JSON_FILE = "package.json";
1965
+ var MPX_SCRIPT_RE = /\bmpx(?:-cli-service)?\b/u;
1966
+ var TARO_SCRIPT_RE = /\btaro\b/u;
1967
+ var TAILWINDCSS_VITE_MARKERS = [
1968
+ ["src/app.mpx", "mpx"],
1969
+ ["app.mpx", "mpx"]
1970
+ ];
1971
+ function resolveDependencyNames(pkg) {
1972
+ return /* @__PURE__ */ new Set([
1973
+ ...Object.keys(_nullishCoalesce(pkg.dependencies, () => ( {}))),
1974
+ ...Object.keys(_nullishCoalesce(pkg.devDependencies, () => ( {}))),
1975
+ ...Object.keys(_nullishCoalesce(pkg.peerDependencies, () => ( {}))),
1976
+ ...Object.keys(_nullishCoalesce(pkg.optionalDependencies, () => ( {})))
1977
+ ]);
1978
+ }
1979
+ function hasScriptMatch(pkg, pattern) {
1980
+ return Object.values(_nullishCoalesce(pkg.scripts, () => ( {}))).some((script) => pattern.test(script));
1981
+ }
1982
+ function resolveAppTypeFromPackageJson(pkg) {
1983
+ const dependencyNames = resolveDependencyNames(pkg);
1984
+ if (dependencyNames.has("weapp-vite") || [...dependencyNames].some((name) => name.startsWith("@weapp-vite/"))) {
1985
+ return "weapp-vite";
1986
+ }
1987
+ if ([...dependencyNames].some((name) => name.startsWith("@mpxjs/")) || hasScriptMatch(pkg, MPX_SCRIPT_RE)) {
1988
+ return "mpx";
1989
+ }
1990
+ if ([...dependencyNames].some((name) => name.startsWith("@tarojs/")) || hasScriptMatch(pkg, TARO_SCRIPT_RE)) {
1991
+ return "taro";
1992
+ }
1993
+ if (dependencyNames.has("@dcloudio/vite-plugin-uni")) {
1994
+ return "uni-app-vite";
1995
+ }
1996
+ if (dependencyNames.has("@dcloudio/vue-cli-plugin-uni") || dependencyNames.has("@dcloudio/uni-app") || Object.hasOwn(pkg, "uni-app")) {
1997
+ return "uni-app";
1998
+ }
1999
+ }
2000
+ function tryReadUniAppManifest(root) {
2001
+ const manifestPath = _path2.default.join(root, "manifest.json");
2002
+ if (!_fs.existsSync.call(void 0, manifestPath)) {
2003
+ return;
2004
+ }
2005
+ try {
2006
+ return JSON.parse(_fs.readFileSync.call(void 0, manifestPath, "utf8"));
2007
+ } catch (e8) {
2008
+ }
2009
+ }
2010
+ function tryReadPackageJson(root) {
2011
+ const packageJsonPath = _path2.default.join(root, PACKAGE_JSON_FILE);
2012
+ if (!_fs.existsSync.call(void 0, packageJsonPath)) {
2013
+ return;
2014
+ }
2015
+ try {
2016
+ return JSON.parse(_fs.readFileSync.call(void 0, packageJsonPath, "utf8"));
2017
+ } catch (e9) {
2018
+ }
2019
+ }
2020
+ function resolveAppTypeFromMarkers(root) {
2021
+ for (const [relativePath, appType] of TAILWINDCSS_VITE_MARKERS) {
2022
+ if (_fs.existsSync.call(void 0, _path2.default.join(root, relativePath))) {
2023
+ return appType;
2024
+ }
2025
+ }
2026
+ }
2027
+ function resolveImplicitAppTypeFromViteRoot(root) {
2028
+ const resolvedRoot = _path2.default.resolve(root);
2029
+ if (!_fs.existsSync.call(void 0, resolvedRoot)) {
2030
+ return;
2031
+ }
2032
+ const markerDetected = resolveAppTypeFromMarkers(resolvedRoot);
2033
+ if (markerDetected) {
2034
+ return markerDetected;
2035
+ }
2036
+ let current = resolvedRoot;
2037
+ while (true) {
2038
+ const manifest = tryReadUniAppManifest(current);
2039
+ if (manifest && Object.hasOwn(manifest, "uni-app-x")) {
2040
+ return "uni-app-x";
2041
+ }
2042
+ const pkg = tryReadPackageJson(current);
2043
+ if (pkg) {
2044
+ const detected = resolveAppTypeFromPackageJson(pkg);
2045
+ if (detected) {
2046
+ return detected;
2047
+ }
2048
+ }
2049
+ const parent = _path2.default.dirname(current);
2050
+ if (parent === current) {
2051
+ break;
2052
+ }
2053
+ current = parent;
2054
+ }
2055
+ }
2056
+
1960
2057
  // src/bundlers/vite/rewrite-css-imports.ts
1961
2058
  function joinPosixPath(base, subpath) {
1962
2059
  if (base.endsWith("/")) {
@@ -1975,17 +2072,18 @@ function createRewriteCssImportsPlugins(options) {
1975
2072
  if (!options.shouldRewrite) {
1976
2073
  return [];
1977
2074
  }
1978
- const { appType, weappTailwindcssDirPosix: weappTailwindcssDirPosix2 } = options;
2075
+ const { appType, getAppType, weappTailwindcssDirPosix: weappTailwindcssDirPosix2 } = options;
2076
+ const resolveAppType = () => _nullishCoalesce(_optionalChain([getAppType, 'optionalCall', _63 => _63()]), () => ( appType));
1979
2077
  return [
1980
2078
  {
1981
- name: `${_chunkZ6RS5OPNjs.vitePluginName}:rewrite-css-imports`,
2079
+ name: `${_chunkTT5WHNGSjs.vitePluginName}:rewrite-css-imports`,
1982
2080
  enforce: "pre",
1983
2081
  resolveId: {
1984
2082
  order: "pre",
1985
2083
  handler(id, importer) {
1986
2084
  const replacement = _chunk7LKMJZD2js.resolveTailwindcssImport.call(void 0, id, weappTailwindcssDirPosix2, {
1987
2085
  join: joinPosixPath,
1988
- appType
2086
+ appType: resolveAppType()
1989
2087
  });
1990
2088
  if (!replacement) {
1991
2089
  return null;
@@ -2004,7 +2102,7 @@ function createRewriteCssImportsPlugins(options) {
2004
2102
  }
2005
2103
  const rewritten = _chunk7LKMJZD2js.rewriteTailwindcssImportsInCode.call(void 0, code, weappTailwindcssDirPosix2, {
2006
2104
  join: joinPosixPath,
2007
- appType
2105
+ appType: resolveAppType()
2008
2106
  });
2009
2107
  if (!rewritten) {
2010
2108
  return null;
@@ -2020,10 +2118,10 @@ function createRewriteCssImportsPlugins(options) {
2020
2118
  }
2021
2119
 
2022
2120
  // src/bundlers/vite/index.ts
2023
- var debug2 = _chunkZ6RS5OPNjs.createDebug.call(void 0, );
2121
+ var debug2 = _chunkTT5WHNGSjs.createDebug.call(void 0, );
2024
2122
  var weappTailwindcssPackageDir = _chunk7LKMJZD2js.resolvePackageDir.call(void 0, "weapp-tailwindcss");
2025
2123
  var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
2026
- var PACKAGE_JSON_FILE = "package.json";
2124
+ var PACKAGE_JSON_FILE2 = "package.json";
2027
2125
  function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
2028
2126
  const resolvedRoot = _path2.default.resolve(root);
2029
2127
  if (!_fs.existsSync.call(void 0, resolvedRoot)) {
@@ -2044,21 +2142,21 @@ function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
2044
2142
  return _path2.default.dirname(tailwindConfigPath);
2045
2143
  }
2046
2144
  const packageRoot = _chunkQK6VNNNLjs.findNearestPackageRoot.call(void 0, resolvedRoot);
2047
- if (packageRoot && _fs.existsSync.call(void 0, _path2.default.join(packageRoot, PACKAGE_JSON_FILE))) {
2145
+ if (packageRoot && _fs.existsSync.call(void 0, _path2.default.join(packageRoot, PACKAGE_JSON_FILE2))) {
2048
2146
  return packageRoot;
2049
2147
  }
2050
2148
  return resolvedRoot;
2051
2149
  }
2052
2150
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2151
+ const hasExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
2053
2152
  const rewriteCssImportsSpecified = Object.hasOwn(options, "rewriteCssImports");
2054
2153
  const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
2055
- const opts = _chunkZ6RS5OPNjs.getCompilerContext.call(void 0, options);
2154
+ const opts = _chunkTT5WHNGSjs.getCompilerContext.call(void 0, options);
2056
2155
  const {
2057
2156
  disabled,
2058
2157
  customAttributes,
2059
2158
  onLoad,
2060
2159
  mainCssChunkMatcher,
2061
- appType,
2062
2160
  styleHandler,
2063
2161
  jsHandler,
2064
2162
  twPatcher: initialTwPatcher,
@@ -2071,15 +2169,15 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2071
2169
  const tailwindcssMajorVersion = _nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0));
2072
2170
  const shouldRewriteCssImports = opts.rewriteCssImports !== false && !disabledOptions.rewriteCssImports && (rewriteCssImportsSpecified || tailwindcssMajorVersion >= 4);
2073
2171
  const rewritePlugins = createRewriteCssImportsPlugins({
2074
- appType,
2172
+ getAppType: () => opts.appType,
2075
2173
  shouldRewrite: shouldRewriteCssImports,
2076
2174
  weappTailwindcssDirPosix
2077
2175
  });
2078
2176
  if (disabledOptions.plugin) {
2079
2177
  return rewritePlugins.length ? rewritePlugins : void 0;
2080
2178
  }
2081
- const customAttributesEntities = _chunkZ6RS5OPNjs.toCustomAttributesEntities.call(void 0, customAttributes);
2082
- const patchRecorderState = _chunkZ6RS5OPNjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
2179
+ const customAttributesEntities = _chunkTT5WHNGSjs.toCustomAttributesEntities.call(void 0, customAttributes);
2180
+ const patchRecorderState = _chunkTT5WHNGSjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
2083
2181
  source: "runtime",
2084
2182
  cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
2085
2183
  });
@@ -2096,10 +2194,10 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2096
2194
  let runtimeRefreshOptionsKey;
2097
2195
  const bundleRuntimeClassSetManager = createBundleRuntimeClassSetManager();
2098
2196
  function resolveRuntimeRefreshOptions() {
2099
- const configPath = _optionalChain([_chunkQK6VNNNLjs.resolveTailwindcssOptions.call(void 0, runtimeState.twPatcher.options), 'optionalAccess', _63 => _63.config]);
2197
+ const configPath = _optionalChain([_chunkQK6VNNNLjs.resolveTailwindcssOptions.call(void 0, runtimeState.twPatcher.options), 'optionalAccess', _64 => _64.config]);
2100
2198
  const signature = _chunkQK6VNNNLjs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
2101
2199
  const optionsKey = JSON.stringify({
2102
- appType,
2200
+ appType: opts.appType,
2103
2201
  uniAppX: uniAppXEnabled,
2104
2202
  customAttributesEntities,
2105
2203
  disabledDefaultTemplateHandler,
@@ -2118,7 +2216,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2118
2216
  async function refreshRuntimeState(force) {
2119
2217
  const invalidation = resolveRuntimeRefreshOptions();
2120
2218
  const shouldRefresh = force || invalidation.changed;
2121
- const refreshed = await _chunkZ6RS5OPNjs.refreshTailwindRuntimeState.call(void 0, runtimeState, {
2219
+ const refreshed = await _chunkTT5WHNGSjs.refreshTailwindRuntimeState.call(void 0, runtimeState, {
2122
2220
  force: shouldRefresh,
2123
2221
  clearCache: force || invalidation.changed
2124
2222
  });
@@ -2139,7 +2237,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2139
2237
  }
2140
2238
  if (forceRuntimeRefresh || !runtimeSetPromise) {
2141
2239
  const invalidation = resolveRuntimeRefreshOptions();
2142
- const task2 = _chunkZ6RS5OPNjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
2240
+ const task2 = _chunkTT5WHNGSjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
2143
2241
  force: forceRuntimeRefresh || invalidation.changed,
2144
2242
  skipRefresh: forceRuntimeRefresh,
2145
2243
  clearCache: forceRuntimeRefresh || invalidation.changed
@@ -2181,7 +2279,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2181
2279
  if (!forceRuntimeRefresh && !invalidation.changed && !forceCollectBySource && runtimeSet) {
2182
2280
  return runtimeSet;
2183
2281
  }
2184
- const task = _chunkZ6RS5OPNjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
2282
+ const task = _chunkTT5WHNGSjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
2185
2283
  force: forceRuntimeRefresh || invalidation.changed || forceCollectBySource,
2186
2284
  skipRefresh: forceRuntimeRefresh,
2187
2285
  clearCache: forceRuntimeRefresh || invalidation.changed
@@ -2201,7 +2299,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2201
2299
  const utsPlatform = _chunkDYLQ6UOIjs.resolveUniUtsPlatform.call(void 0, );
2202
2300
  const isIosPlatform = utsPlatform.isAppIos;
2203
2301
  const uniAppXPlugins = uniAppXEnabled ? createUniAppXPlugins({
2204
- appType,
2302
+ appType: _nullishCoalesce(opts.appType, () => ( "uni-app-x")),
2205
2303
  customAttributesEntities,
2206
2304
  disabledDefaultTemplateHandler,
2207
2305
  isIosPlatform,
@@ -2216,11 +2314,12 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2216
2314
  const plugins = [
2217
2315
  ...rewritePlugins,
2218
2316
  {
2219
- name: `${_chunkZ6RS5OPNjs.vitePluginName}:post`,
2317
+ name: `${_chunkTT5WHNGSjs.vitePluginName}:post`,
2220
2318
  enforce: "post",
2221
2319
  async configResolved(config) {
2222
2320
  resolvedConfig = config;
2223
2321
  const resolvedRoot = config.root ? _path2.default.resolve(config.root) : void 0;
2322
+ let shouldRefreshRuntime = false;
2224
2323
  if (!hasExplicitTailwindcssBasedir && resolvedRoot) {
2225
2324
  const nextTailwindcssBasedir = resolveImplicitTailwindcssBasedirFromViteRoot(resolvedRoot);
2226
2325
  if (opts.tailwindcssBasedir !== nextTailwindcssBasedir) {
@@ -2231,9 +2330,26 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
2231
2330
  _nullishCoalesce(previousBasedir, () => ( "undefined")),
2232
2331
  nextTailwindcssBasedir
2233
2332
  );
2234
- await refreshRuntimeState(true);
2333
+ shouldRefreshRuntime = true;
2235
2334
  }
2236
2335
  }
2336
+ if (!hasExplicitAppType && resolvedRoot) {
2337
+ const nextAppType = resolveImplicitAppTypeFromViteRoot(resolvedRoot);
2338
+ if (nextAppType && opts.appType !== nextAppType) {
2339
+ const previousAppType = opts.appType;
2340
+ opts.appType = nextAppType;
2341
+ _logger.logger.info("\u6839\u636E Vite \u9879\u76EE\u6839\u76EE\u5F55\u81EA\u52A8\u63A8\u65AD appType -> %s", nextAppType);
2342
+ debug2(
2343
+ "align appType with vite root: %s -> %s",
2344
+ _nullishCoalesce(previousAppType, () => ( "undefined")),
2345
+ nextAppType
2346
+ );
2347
+ shouldRefreshRuntime = true;
2348
+ }
2349
+ }
2350
+ if (shouldRefreshRuntime) {
2351
+ await refreshRuntimeState(true);
2352
+ }
2237
2353
  if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
2238
2354
  const postcssPlugins = config.css.postcss.plugins;
2239
2355
  const idx = postcssPlugins.findIndex((x) => (
@@ -17,6 +17,7 @@ var IMPLICIT_MAIN_CSS_RE = /^(?:app|common\/main|bundle)(?:\.|\/|$)/;
17
17
  var MAIN_CSS_CHUNK_MATCHERS = {
18
18
  "uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
19
19
  "uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
20
+ "uni-app-x": (file) => file.startsWith("app") || file.startsWith("common/main"),
20
21
  "mpx": (file) => {
21
22
  const normalized = normalizePath(file);
22
23
  if (normalized.startsWith("app")) {
@@ -28,6 +29,7 @@ var MAIN_CSS_CHUNK_MATCHERS = {
28
29
  "remax": (file) => file.startsWith("app"),
29
30
  "rax": (file) => file.startsWith("bundle"),
30
31
  "native": (file) => file.startsWith("app"),
32
+ "weapp-vite": (file) => file.startsWith("app"),
31
33
  "kbone": (file) => KBONE_MAIN_CSS_RE.test(file)
32
34
  };
33
35
  var alwaysFalse = () => false;
@@ -7,7 +7,7 @@ import {
7
7
  getCompilerContext,
8
8
  refreshTailwindRuntimeState,
9
9
  setupPatchRecorder
10
- } from "./chunk-KWSWZP5H.mjs";
10
+ } from "./chunk-AB2RGZQO.mjs";
11
11
 
12
12
  // src/bundlers/gulp/index.ts
13
13
  import { Buffer } from "buffer";