weapp-tailwindcss 5.5.0 → 5.5.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 (83) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/bundlers/shared/css-imports.d.ts +1 -0
  4. package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -1
  5. package/dist/bundlers/shared/framework-user-css.d.ts +3 -0
  6. package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +6 -2
  7. package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -1
  8. package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
  9. package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -1
  10. package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +3 -2
  11. package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +1 -0
  12. package/dist/bundlers/vite/generate-bundle/entry-style-graph.d.ts +6 -0
  13. package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +1 -0
  14. package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
  15. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
  16. package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +1 -1
  17. package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +3 -1
  18. package/dist/bundlers/webpack/shared/loader-anchors.d.ts +1 -0
  19. package/dist/compiler/runtime-snapshot.d.ts +4 -1
  20. package/dist/{compiler-SwMb3lOX.cjs → compiler-BSMSbVVt.cjs} +6 -6
  21. package/dist/{compiler-B0YSc0DY.js → compiler-tHMcW3BT.js} +3 -3
  22. package/dist/core.cjs +1 -1
  23. package/dist/core.js +1 -1
  24. package/dist/{css-imports-BFMU7Hpd.cjs → css-imports-DsCSPIj2.cjs} +29 -0
  25. package/dist/{css-loader-runtime-CSv0lKqV.cjs → css-loader-runtime-DGqsWVua.cjs} +2 -1
  26. package/dist/{defaults-B5ep0ojb.js → defaults-CKx-4LcW.js} +1 -1
  27. package/dist/{defaults-BI9j1znS.cjs → defaults-CiGsr8Xq.cjs} +1 -1
  28. package/dist/defaults.cjs +1 -1
  29. package/dist/defaults.js +1 -1
  30. package/dist/{final-css-cleanup-CmVYbXPr.js → final-css-cleanup-B0HUBtiE.js} +63 -37
  31. package/dist/final-css-cleanup-DSjczga3.cjs +138 -0
  32. package/dist/{generator-DsrQ9txU.cjs → generator-CCw17l0G.cjs} +72 -67
  33. package/dist/{generator-DyXTBPmE.js → generator-DxEsInLz.js} +61 -68
  34. package/dist/generator.cjs +1 -1
  35. package/dist/generator.js +1 -1
  36. package/dist/{gulp-Dtc01FdI.cjs → gulp-C1r36Y_f.cjs} +6 -6
  37. package/dist/{gulp-CVUiPXPy.js → gulp-qGXKwQMZ.js} +5 -5
  38. package/dist/gulp.cjs +1 -1
  39. package/dist/gulp.js +1 -1
  40. package/dist/{hmr-timing-DNxQm-bN.js → hmr-timing-DixZjtTS.js} +245 -183
  41. package/dist/{hmr-timing-3SdRVfZx.cjs → hmr-timing-DuIbach8.cjs} +5 -5
  42. package/dist/index.cjs +4 -4
  43. package/dist/index.js +4 -4
  44. package/dist/{pipeline-helpers-DVrgv1HS.cjs → pipeline-helpers-CUwwOFt3.cjs} +5 -5
  45. package/dist/postcss.cjs +1 -1
  46. package/dist/postcss.js +1 -1
  47. package/dist/presets.cjs +2 -2
  48. package/dist/presets.js +2 -2
  49. package/dist/rspack.cjs +6 -3
  50. package/dist/rspack.js +6 -3
  51. package/dist/{scoped-generator-kRj_5Axx.js → scoped-generator-BJvL2CKZ.js} +3 -3
  52. package/dist/{scoped-generator-B7thnzzm.cjs → scoped-generator-CO9xZ06m.cjs} +3 -3
  53. package/dist/{source-candidate-scan-signature-CsP4BQNa.js → source-candidate-scan-signature-CgJi--lh.js} +2 -2
  54. package/dist/{source-candidate-scan-signature-B7cUxqqX.cjs → source-candidate-scan-signature-_UPwg8oJ.cjs} +2 -2
  55. package/dist/tailwindcss/v4-engine/css-import.d.ts +14 -0
  56. package/dist/{tailwindcss-BK9S7zuq.js → tailwindcss-D2joPNdN.js} +1 -1
  57. package/dist/{tailwindcss-C-jBBQfw.cjs → tailwindcss-DhaLV5a2.cjs} +1 -1
  58. package/dist/{transform-C0rWZblB.js → transform-BNtyKkZi.js} +14 -14
  59. package/dist/{transform-C7QxW-fV.cjs → transform-DAg85t9Z.cjs} +14 -14
  60. package/dist/uni-app-x/border-preflight.d.ts +18 -0
  61. package/dist/uni-app-x/style-asset/source-parser.d.ts +2 -0
  62. package/dist/uni-app-x/transform.d.ts +2 -0
  63. package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
  64. package/dist/uni-app-x/vite/style-source.d.ts +21 -0
  65. package/dist/{v4-generation-core-DuIVZvRz.cjs → v4-generation-core-bOm8k4AY.cjs} +243 -181
  66. package/dist/vite/web.cjs +1 -1
  67. package/dist/vite/web.js +1 -1
  68. package/dist/{vite-0PsttwuR.js → vite-C_JJxZWl.js} +290 -69
  69. package/dist/{vite-CJbO-7AQ.cjs → vite-bJZi1V-l.cjs} +306 -66
  70. package/dist/vite.cjs +1 -1
  71. package/dist/vite.js +1 -1
  72. package/dist/{watch-dependencies-DLZDrWdH.cjs → watch-dependencies-GbC14Rlt.cjs} +14 -11
  73. package/dist/weapp-tw-css-generation-loader.cjs +3 -2
  74. package/dist/weapp-tw-css-import-rewrite-loader.cjs +11 -10
  75. package/dist/weapp-tw-runtime-classset-loader.cjs +16 -11
  76. package/dist/{web-BFOkkJ-8.cjs → web-B4wa3xrE.cjs} +13 -8
  77. package/dist/{web-D8HSs56R.js → web-BiubXhxs.js} +11 -6
  78. package/dist/{webpack-DVtKeBq1.js → webpack-BDOQUv3J.js} +39 -24
  79. package/dist/{webpack-BWknqSDV.cjs → webpack-CsBe1G_1.cjs} +37 -23
  80. package/dist/webpack.cjs +1 -1
  81. package/dist/webpack.js +1 -1
  82. package/package.json +7 -5
  83. package/dist/final-css-cleanup-BMlUDzik.cjs +0 -112
@@ -1,16 +1,16 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
2
  const require_framework = require("./framework.cjs");
3
- const require_generator = require("./generator-DsrQ9txU.cjs");
4
- const require_tailwindcss = require("./tailwindcss-C-jBBQfw.cjs");
3
+ const require_generator = require("./generator-CCw17l0G.cjs");
4
+ const require_tailwindcss = require("./tailwindcss-DhaLV5a2.cjs");
5
5
  require("./utils-CuKLf1Zv.cjs");
6
- const require_v4_generation_core = require("./v4-generation-core-DuIVZvRz.cjs");
7
- const require_compiler = require("./compiler-SwMb3lOX.cjs");
6
+ const require_v4_generation_core = require("./v4-generation-core-bOm8k4AY.cjs");
7
+ const require_compiler = require("./compiler-BSMSbVVt.cjs");
8
8
  const require_cache = require("./cache-CBJFB1HN.cjs");
9
- const require_hmr_timing = require("./hmr-timing-3SdRVfZx.cjs");
10
- const require_final_css_cleanup = require("./final-css-cleanup-BMlUDzik.cjs");
11
- const require_scoped_generator = require("./scoped-generator-B7thnzzm.cjs");
12
- const require_web = require("./web-BFOkkJ-8.cjs");
13
- const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-B7cUxqqX.cjs");
9
+ const require_hmr_timing = require("./hmr-timing-DuIbach8.cjs");
10
+ const require_final_css_cleanup = require("./final-css-cleanup-DSjczga3.cjs");
11
+ const require_scoped_generator = require("./scoped-generator-CO9xZ06m.cjs");
12
+ const require_web = require("./web-B4wa3xrE.cjs");
13
+ const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-_UPwg8oJ.cjs");
14
14
  require("./logger-TlKT3xmR.cjs");
15
15
  let node_fs = require("node:fs");
16
16
  node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
@@ -28,7 +28,22 @@ let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
28
28
  let node_buffer = require("node:buffer");
29
29
  let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
30
30
  let node_async_hooks = require("node:async_hooks");
31
+ let postcss_scss = require("postcss-scss");
32
+ postcss_scss = require_rolldown_runtime.__toESM(postcss_scss, 1);
33
+ let _vue_compiler_dom = require("@vue/compiler-dom");
31
34
  let comment_json = require("comment-json");
35
+ //#region src/uni-app-x/style-asset/source-parser.ts
36
+ function parseUniAppXStyleSource(source) {
37
+ return postcss_scss.default.parse(source, { from: void 0 });
38
+ }
39
+ function isUniAppXStyleSourceEmpty(source) {
40
+ try {
41
+ return parseUniAppXStyleSource(source).nodes.every((node) => node.type === "comment");
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+ //#endregion
32
47
  //#region src/uni-app-x/style-asset/harmony-apply.ts
33
48
  const SFC_STYLE_BLOCK_RE$1 = /(<style\b[^>]*>)([\s\S]*?)(<\/style>)/gi;
34
49
  function createGeneratedRuleMap(css) {
@@ -52,7 +67,7 @@ function expandUniAppXHarmonyApplyStyles(source, generatedCss) {
52
67
  if (!styleSource.includes("@apply")) return block;
53
68
  let root;
54
69
  try {
55
- root = _weapp_tailwindcss_postcss.postcss.parse(styleSource);
70
+ root = parseUniAppXStyleSource(styleSource);
56
71
  } catch {
57
72
  return block;
58
73
  }
@@ -244,7 +259,7 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
244
259
  for (const styleSource of styleSources) {
245
260
  let root;
246
261
  try {
247
- root = _weapp_tailwindcss_postcss.postcss.parse(styleSource);
262
+ root = parseUniAppXStyleSource(styleSource);
248
263
  } catch {
249
264
  continue;
250
265
  }
@@ -273,13 +288,13 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
273
288
  return Object.keys(result).length > 0 ? result : void 0;
274
289
  }
275
290
  function resolveReferencePaths(styleSource, sourceId) {
276
- if (!sourceId || !styleSource.includes("@reference")) return styleSource;
277
291
  let root;
278
292
  try {
279
- root = _weapp_tailwindcss_postcss.postcss.parse(styleSource);
293
+ root = parseUniAppXStyleSource(styleSource);
280
294
  } catch {
281
295
  return styleSource;
282
296
  }
297
+ if (!sourceId || !styleSource.includes("@reference")) return root.toString();
283
298
  const cleanSourceId = sourceId.replace(/\?.*$/, "");
284
299
  const pathApi = /^[a-z]:[\\/]/i.test(cleanSourceId) ? node_path.default.win32 : node_path.default;
285
300
  root.walkAtRules("reference", (rule) => {
@@ -301,7 +316,7 @@ function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
301
316
  for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) {
302
317
  let root;
303
318
  try {
304
- root = _weapp_tailwindcss_postcss.postcss.parse(styleSource);
319
+ root = parseUniAppXStyleSource(styleSource);
305
320
  } catch {
306
321
  continue;
307
322
  }
@@ -525,7 +540,7 @@ function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtili
525
540
  return applyStyleSources.map((source) => {
526
541
  let root;
527
542
  try {
528
- root = _weapp_tailwindcss_postcss.postcss.parse(source);
543
+ root = parseUniAppXStyleSource(source);
529
544
  } catch {
530
545
  return source;
531
546
  }
@@ -847,7 +862,7 @@ function restoreCssImportAtRules(source, filtered, file) {
847
862
  return require_web.appendCss(missingImports.join("\n"), filtered);
848
863
  }
849
864
  function removeCommentOnlyAtRules(css) {
850
- if (!require_final_css_cleanup.hasEmptyAtRuleBlockCandidate(css)) return css;
865
+ if (!require_final_css_cleanup.hasEmptyCssBlockCandidate(css)) return css;
851
866
  try {
852
867
  const root = _weapp_tailwindcss_postcss.postcss.parse(css);
853
868
  let changed = false;
@@ -1463,7 +1478,7 @@ function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
1463
1478
  return enabled === true;
1464
1479
  }
1465
1480
  function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
1466
- return !options.isWebGeneratorTarget && options.matchesCss && isRootMiniProgramStyleOutputFile$1(options.file) && (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
1481
+ return !options.isWebGeneratorTarget && options.matchesCss && require_web.isRootStyleOutputFile(options.file) && (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
1467
1482
  }
1468
1483
  function resolveFrameworkRootImportShellPlan(options) {
1469
1484
  const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
@@ -1478,7 +1493,7 @@ function resolveFrameworkRootImportShellPlan(options) {
1478
1493
  return {
1479
1494
  isCurrentImportShell,
1480
1495
  reusableTarget: options.rememberedTarget,
1481
- targetToRemember: importedFile && isRootMiniProgramStyleOutputFile$1(importedFile) ? importedFile : void 0
1496
+ targetToRemember: importedFile && require_web.isRootStyleOutputFile(importedFile) ? importedFile : void 0
1482
1497
  };
1483
1498
  }
1484
1499
  if (options.rememberedTarget) return {
@@ -1505,7 +1520,7 @@ function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
1505
1520
  const writeTargets = /* @__PURE__ */ new Map();
1506
1521
  let restored = 0;
1507
1522
  for (const [sourceFile, targetFile] of options.targetByFile) {
1508
- if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !isRootMiniProgramStyleOutputFile$1(sourceFile) || !isRootMiniProgramStyleOutputFile$1(targetFile) || require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile)) continue;
1523
+ if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !require_web.isRootStyleOutputFile(sourceFile) || !require_web.isRootStyleOutputFile(targetFile) || require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile)) continue;
1509
1524
  const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(candidate.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile))?.[1];
1510
1525
  if (output?.type !== "asset") continue;
1511
1526
  const rawSource = output.source.toString();
@@ -1675,6 +1690,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
1675
1690
  if (removableRecords.length === 0) return 0;
1676
1691
  const recordFileKeys = new Set(removableRecords.map((record) => require_source_candidate_scan_signature.normalizeOutputPathKey(record.file)));
1677
1692
  const recordCss = new Set(removableRecords.map((record) => record.css.trim()));
1693
+ const targetMatcher = (0, _weapp_tailwindcss_postcss.createCssRuleMatcher)(targetCss);
1678
1694
  let removed = 0;
1679
1695
  for (const [candidateFile, candidateOutput] of Object.entries(bundle)) {
1680
1696
  if (candidateOutput.type !== "asset") continue;
@@ -1683,7 +1699,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
1683
1699
  const candidateIsRootWebStyle = require_web.isRootStyleOutputFile(candidateKey) && !require_web.isMiniProgramStyleOutputFile(candidateKey);
1684
1700
  if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
1685
1701
  const candidateSource = require_web.readAssetSource(candidateOutput).trim();
1686
- if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(targetCss, candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !require_web.hasNonCommentCss((0, _weapp_tailwindcss_postcss.filterExistingCssRules)(targetCss, candidateSource).trim())))) continue;
1702
+ if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || targetMatcher.contains(candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !require_web.hasNonCommentCss(targetMatcher.filter(candidateSource).trim())))) continue;
1687
1703
  if (candidateIsRootWebStyle) delete bundle[candidateFile];
1688
1704
  else require_web.clearAssetSource(candidateOutput);
1689
1705
  options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
@@ -2069,15 +2085,22 @@ function createTransformFilterSignature(options) {
2069
2085
  //#region src/bundlers/vite/generate-bundle/bundle-markup-candidates.ts
2070
2086
  async function collectBundleMarkupCandidates(options) {
2071
2087
  const { extractSourceCandidates, previousCandidatesByFile, preserveMissingFiles, resolveSourceCandidateFile, rootDir, snapshot, transformFilter } = options;
2072
- const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file, candidates]) => [file, new Set(candidates)])) : /* @__PURE__ */ new Map();
2088
+ const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file, entry]) => [file, {
2089
+ ...entry,
2090
+ candidates: new Set(entry.candidates)
2091
+ }])) : /* @__PURE__ */ new Map();
2092
+ for (const file of snapshot.removedFiles) candidatesByFile.delete(file);
2073
2093
  await Promise.all(snapshot.entries.map(async (entry) => {
2074
2094
  if (!extractSourceCandidates || entry.type !== "html" || entry.output.type !== "asset" || shouldSkipViteAssetTransform(entry.output, entry.file, rootDir, transformFilter)) return;
2075
2095
  const sourceFile = resolveSourceCandidateFile(entry.file) ?? node_path.default.resolve(rootDir, entry.file);
2076
- candidatesByFile.set(sourceFile, await extractSourceCandidates(sourceFile, entry.source));
2096
+ candidatesByFile.set(entry.file, {
2097
+ sourceFile,
2098
+ candidates: await extractSourceCandidates(sourceFile, entry.source)
2099
+ });
2077
2100
  }));
2078
2101
  const valuesForEntries = (entries, filterOptions = {}) => {
2079
2102
  const values = /* @__PURE__ */ new Set();
2080
- for (const [file, candidates] of candidatesByFile) {
2103
+ for (const { sourceFile: file, candidates } of candidatesByFile.values()) {
2081
2104
  if (entries !== void 0 && !require_generator.isFileMatchedByTailwindSourceEntries(file, entries)) continue;
2082
2105
  if (filterOptions.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(file, filterOptions.excludeEntries)) continue;
2083
2106
  for (const candidate of candidates) values.add(candidate);
@@ -2574,7 +2597,11 @@ async function processViteCssBundleEntry(options) {
2574
2597
  const { activeViteCssCacheFiles, addWatchFile, annotateCssSourceTrace, applyCssResultToBundle, applyViteCssCacheResult, applyViteCssTransformTaskResult, bundle, bundleFiles, cache, collectedBundlerGeneratedCssFiles, configuredTailwindV4CssSourceFileKeysForScope, configuredTailwindV4ExplicitCssEntryFileKeysForScope, context, createCandidateSignature, createCssSourceTraceCacheSignature, createCssTokenSourceMap, createCssTransformShareScopeKey, createInitialCssPipelineContext, createRuntimeAffectingSourceSignature, createScopedGeneratorCandidateSignature, createScopedGeneratorRuntime, createScopedGeneratorSourceTraceMap, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, currentSubpackageRoots, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, envFlags, executeViteCssTransformTask, file, frameworkRootImportShellTargetByFile, generatorCandidatesChanged, generatorPlatform, generatorRuntime, getConfiguredTailwindV4CssSourceEntries, getCssHandlerOptions, getCssSource, getCssUserHandlerOptions, getLastCssResult, getOriginalCssLayerSource, getRememberedCssSources, getSfcSource, getSourceCandidateSources, getViteProcessedCssAssetResult, getViteProcessedCssAssetResults, hasExplicitConfiguredRootCssEntryForOutput, hasRuntimeAffectingChanges, hasViteProcessedCssResultForSource, isCssAssetProcessed, isCssImportOnlyBundleAsset, isMiniProgramStyleOutputFile, isRootMiniProgramStyleOutputFile, isSubpackageOutputFile, isTemporaryCssAssetFile, isViteProcessedCssAsset, isWebGeneratorTarget, lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, measureElapsed, metrics, normalizeConfiguredTailwindV4CssEntryFileKey, normalizeGeneratorUserRawSource, normalizeMiniProgramGeneratorRawSource, normalizeOutputPathKey, normalizeRelativeCssConfigDirectives, normalizeViteCssCacheKey, onUpdate, opts, originalEntrySource, originalSource, outDir, processFiles, processViteCssCacheTask, recordCssAssetResult, recordViteProcessedCssAssetResult, rememberCssSource, rememberProcessCacheKey, removeCssCoveredByRootStyleBundleSources, resolveAssetSourceFile, resolveConfiguredCssEntryRootInjectionTarget, resolveConfiguredRootCssSourceStyle, resolveCssAssetIdentity, resolveCssAssetOutputPlan, resolveFrameworkRootImportShellPlan, resolveMatchedCssSourceOutputFile, resolveReplayCssOutputFile, resolveViteCssCompositionPlan, resolveViteCssLinkedImpactSignature, resolveViteCssPipelineOutputFile, resolveViteCssSourcePlan, resolveViteCssTransformCachePlan, resolveViteCssTransformDecisionPlan, rootDir, runtimeLinkedCssFiles, runtimeSignature, runtimeState, selectConfiguredRootCssSourceEntry, sharedCssResultCache, shouldExcludeSubpackageSourceCandidates, shouldGenerateWebCssByGenerator, shouldInjectCssIntoMainFromOutput, shouldKeepCurrentRootCssOutputForConfiguredSource, shouldKeepCurrentRootMiniProgramStyleOutputAsImportShell, shouldKeepRootMiniProgramStyleAsImportShell, shouldMoveRootMiniProgramStyleToImportShellOrigin, shouldPreserveAppCssExtension, shouldProcessTailwindGeneration, shouldSkipRawRememberedCssSource, shouldSkipRawSourceStyleAsset, shouldSkipViteAssetTransform, snapshot, sourceRoot, state, styleHandler, temporaryCssAssetSourceResolver, timeTask, transformFilter, transformRuntime, transformWebTargetCss, useIncrementalMode, usedConfiguredTailwindV4CssSourceFiles } = options;
2575
2598
  metrics.css.total++;
2576
2599
  const assetSourceFile = resolveAssetSourceFile(originalSource, file);
2577
- const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource, assetSourceFile, outDir, opts);
2600
+ const rawSource = normalizeRelativeCssConfigDirectives(isWebGeneratorTarget ? originalEntrySource : require_v4_generation_core.normalizeMiniProgramImportShell(originalEntrySource, {
2601
+ cssOnly: true,
2602
+ outputFile: originalSource.fileName || file,
2603
+ outputFiles: [...bundleFiles, ...lastCssResultByFile.keys()]
2604
+ }), assetSourceFile, outDir, opts);
2578
2605
  const currentRawSourceHasExplicitScanContext = rawSource.includes("@source") || rawSource.includes("@config");
2579
2606
  const cssPipelineContext2 = {
2580
2607
  ...createInitialCssPipelineContext(file),
@@ -2633,7 +2660,10 @@ async function processViteCssBundleEntry(options) {
2633
2660
  }))
2634
2661
  });
2635
2662
  let outputFile = cssAssetOutputPlan.outputFile;
2636
- const resolveMatchedOutputFileForCurrentAsset = cssAssetOutputPlan.resolveMatchedOutputFile;
2663
+ const resolveMatchedOutputFileForCurrentAsset = (sourceFile) => {
2664
+ const matched = cssAssetOutputPlan.resolveMatchedOutputFile(sourceFile);
2665
+ return matched ? frameworkRootImportShellTargetByFile.get(matched) ?? matched : matched;
2666
+ };
2637
2667
  const resolvedFromConfiguredOriginalCssEntry = cssAssetOutputPlan.resolvedFromConfiguredOriginalCssEntry;
2638
2668
  if (cssAssetOutputPlan.reusedRootImportShellTarget) debug("css reuse framework root import shell target: %s -> %s", rootImportShellOutputFile, outputFile);
2639
2669
  activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
@@ -2956,7 +2986,7 @@ async function processViteCssBundleEntry(options) {
2956
2986
  function resolveCssBundleOutputFile(options) {
2957
2987
  const { bundleFiles, defaultStyleOutputExtension, file, isWebGeneratorTarget, opts, pipelineContext, cssPipelineStrategy, shouldPreserveAppCssExtension } = options;
2958
2988
  let outputFile = require_web.resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, shouldPreserveAppCssExtension, defaultStyleOutputExtension, bundleFiles);
2959
- if (outputFile === file && isRootMiniProgramStyleOutputFile$1(file) && shouldMoveRootMiniProgramStyleToImportShellOrigin(cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
2989
+ if (outputFile === file && require_source_candidate_scan_signature.normalizeOutputPathKey(options.assetOutputFile ?? file) === require_source_candidate_scan_signature.normalizeOutputPathKey(file) && isRootMiniProgramStyleOutputFile$1(file) && shouldMoveRootMiniProgramStyleToImportShellOrigin(cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
2960
2990
  ...pipelineContext,
2961
2991
  file
2962
2992
  }))) outputFile = createRootMiniProgramOriginStyleOutputFile(file);
@@ -2993,7 +3023,10 @@ function createMatchedCssSourceOutputResolver(options) {
2993
3023
  };
2994
3024
  }
2995
3025
  function resolveCssAssetOutputPlan(options) {
2996
- let outputFile = resolveCssBundleOutputFile(options);
3026
+ let outputFile = resolveCssBundleOutputFile({
3027
+ ...options,
3028
+ assetOutputFile: options.rootImportShellOutputFile
3029
+ });
2997
3030
  const reusedRootImportShellTarget = Boolean(options.rootImportShellTarget && !options.isWebGeneratorTarget && (options.opts.cssMatcher(options.rootImportShellOutputFile) || options.opts.cssMatcher(options.file)) && options.shouldReuseRootImportShell());
2998
3031
  if (reusedRootImportShellTarget && options.rootImportShellTarget) outputFile = options.rootImportShellTarget;
2999
3032
  const resolveMatchedOutputFile = createMatchedCssSourceOutputResolver({
@@ -3505,21 +3538,22 @@ function applyViteCssTransformTaskResult(options) {
3505
3538
  }
3506
3539
  //#endregion
3507
3540
  //#region src/bundlers/vite/generate-bundle/css-transform-task.ts
3508
- function resolveGeneratorUserRawSource(options) {
3509
- const bundleUserRawSource = options.vitePipelineCssAsset && !require_v4_generation_core.hasBundlerGeneratedCssMarker(options.rawSource) && require_web.normalizeCssSourceForCompare(options.rawSource) !== require_web.normalizeCssSourceForCompare(options.generatorRawSource) ? options.normalizeMiniProgramGeneratorRawSource(options.normalizeGeneratorUserRawSource(options.rawSource, options.generatorSourceFile, options.assetSourceFile), options.outputFile) : void 0;
3510
- return [options.generatorUserLayerRawSource, bundleUserRawSource].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
3541
+ function resolveBundleUserRawSource(options) {
3542
+ return options.vitePipelineCssAsset && !require_v4_generation_core.hasBundlerGeneratedCssMarker(options.rawSource) && require_web.normalizeCssSourceForCompare(options.rawSource) !== require_web.normalizeCssSourceForCompare(options.generatorRawSource) ? options.normalizeMiniProgramGeneratorRawSource(options.normalizeGeneratorUserRawSource(options.rawSource, options.generatorSourceFile, options.assetSourceFile), options.outputFile) : void 0;
3511
3543
  }
3512
3544
  async function executeViteCssTransformTask(options) {
3513
3545
  await options.runtimeState.readyPromise;
3514
3546
  const previousGeneratorCss = options.previousCss && !options.isWebGeneratorTarget ? options.normalizeMiniProgramGeneratorRawSource(options.previousCss, options.outputFile) : options.previousCss;
3515
3547
  if (require_web.hasTailwindGenerationSource(options.generatorRawSource) || !options.isWebGeneratorTarget && require_v4_generation_core.hasBundlerGeneratedCssMarker(options.rawSource)) {
3516
- const generatorUserRawSource = resolveGeneratorUserRawSource(options);
3548
+ const bundleUserRawSource = resolveBundleUserRawSource(options);
3549
+ const generatorUserRawSource = [options.generatorUserLayerRawSource, options.isWebGeneratorTarget ? bundleUserRawSource : void 0].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
3517
3550
  const generated = await (options.generateCss ?? require_v4_generation_core.generateTailwindV4Css)({
3518
3551
  cssHandlerOptions: options.generatorCssHandlerOptions,
3519
3552
  cssStage: "framework-processed",
3520
3553
  cssUserHandlerOptions: options.cssUserHandlerOptions,
3521
3554
  debug: options.debug,
3522
3555
  file: options.generatorSourceFile,
3556
+ frameworkProcessedUserCss: options.isWebGeneratorTarget ? void 0 : bundleUserRawSource,
3523
3557
  generatorPlatform: options.generatorPlatform,
3524
3558
  getSourceCandidatesForEntries: options.getSourceCandidatesForEntries,
3525
3559
  opts: options.opts,
@@ -4352,6 +4386,61 @@ function isUniAppXNativeAppOutDir(outDir) {
4352
4386
  return typeof outDir === "string" && /(?:^|[/\\-])(?:\.uvue[/\\])?app-(?:android|ios|harmony)(?:[/\\-]|$)/.test(outDir);
4353
4387
  }
4354
4388
  //#endregion
4389
+ //#region src/uni-app-x/border-preflight.ts
4390
+ const BORDER_PREFLIGHT_CLASS = "weapp-tw-border";
4391
+ /** 框架回放组件样式后恢复基础规则的顺序,确保作者 class 可以覆盖重置。 */
4392
+ function hoistUniAppXBorderPreflight(css) {
4393
+ if (!css.includes("weapp-tw-border")) return css;
4394
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
4395
+ const resets = root.nodes.filter((node) => node.type === "rule" && node.selector === `.weapp-tw-border`);
4396
+ const anchor = root.nodes.find((node) => !resets.includes(node) && node.type !== "comment" && !(node.type === "atrule" && ["charset", "import"].includes(node.name)));
4397
+ if (!anchor || resets.length === 0) return css;
4398
+ for (const reset of resets) {
4399
+ reset.remove();
4400
+ root.insertBefore(anchor, reset);
4401
+ }
4402
+ return root.toString();
4403
+ }
4404
+ /** uni-app x 移除通配符 preflight 后,用独立基础类承载用户配置的边框默认值。 */
4405
+ function createUniAppXBorderPreflight(options) {
4406
+ const declarations = (0, _weapp_tailwindcss_postcss.createInjectPreflight)(options)().filter(({ prop }) => prop === "border" || prop.startsWith("border-"));
4407
+ if (declarations.length === 0) return;
4408
+ const rule = _weapp_tailwindcss_postcss.postcss.rule({ selector: `.${BORDER_PREFLIGHT_CLASS}` });
4409
+ for (const declaration of declarations) rule.append(_weapp_tailwindcss_postcss.postcss.decl(declaration));
4410
+ return rule.toString();
4411
+ }
4412
+ function resolveUniAppXBorderPreflightOptions(options, isWeb) {
4413
+ const borderPreflight = isWeb ? void 0 : createUniAppXBorderPreflight(options.cssPreflight);
4414
+ return borderPreflight ? {
4415
+ borderPreflight,
4416
+ borderPreflightRange: options.cssPreflightRange
4417
+ } : {};
4418
+ }
4419
+ function shouldInjectBorderPreflight(node, range) {
4420
+ return range === "all" ? ![
4421
+ "template",
4422
+ "slot",
4423
+ "block"
4424
+ ].includes(node.tag) : node.tag === "view" || node.tag === "text";
4425
+ }
4426
+ /** 在既有 class 转换完成后插入基础类,保持 utility 与动态绑定的原始顺序。 */
4427
+ function injectBorderPreflightClass(ms, node, offset) {
4428
+ const attribute = node.props.find((prop) => prop.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE && prop.name === "class");
4429
+ if (attribute?.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE) {
4430
+ if (attribute.value) {
4431
+ if (attribute.value.content.split(/\s+/).includes("weapp-tw-border")) return;
4432
+ const start = offset + attribute.value.loc.start.offset;
4433
+ if (/^["']/.test(attribute.value.loc.source)) ms.prependRight(start + 1, `${BORDER_PREFLIGHT_CLASS} `);
4434
+ else {
4435
+ ms.prependRight(start, `"${BORDER_PREFLIGHT_CLASS} `);
4436
+ ms.appendLeft(offset + attribute.value.loc.end.offset, "\"");
4437
+ }
4438
+ } else ms.appendLeft(offset + attribute.loc.end.offset, `="${BORDER_PREFLIGHT_CLASS}"`);
4439
+ return;
4440
+ }
4441
+ ms.appendLeft(offset + node.loc.start.offset + node.tag.length + 1, ` class="${BORDER_PREFLIGHT_CLASS}"`);
4442
+ }
4443
+ //#endregion
4355
4444
  //#region src/uni-app-x/style-isolation.ts
4356
4445
  const manifestCache = /* @__PURE__ */ new Map();
4357
4446
  function resolveUniAppXStyleIsolationEnabled(root) {
@@ -4564,6 +4653,59 @@ function resolvePreprocessorTransform(code, id, lang, options) {
4564
4653
  if (!options.isNativeAppStyleTarget) return { result: void 0 };
4565
4654
  }
4566
4655
  //#endregion
4656
+ //#region src/uni-app-x/vite/style-source.ts
4657
+ const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
4658
+ function createUniAppXSfcStyleSources() {
4659
+ const authoredByFile = /* @__PURE__ */ new Map();
4660
+ const generatedByFile = /* @__PURE__ */ new Map();
4661
+ return {
4662
+ rememberSource(id, source) {
4663
+ authoredByFile.set((0, _weapp_tailwindcss_shared.cleanUrl)(id), require_web.extractSfcStyleBlocks(source));
4664
+ },
4665
+ rememberGenerated(id, source) {
4666
+ const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
4667
+ const authoredCount = authoredByFile.get(file)?.length ?? 0;
4668
+ const generated = /* @__PURE__ */ new Map();
4669
+ for (const [index, style] of require_web.extractSfcStyleBlocks(source).entries()) if (index >= authoredCount) generated.set(index, style.source);
4670
+ generatedByFile.set(file, generated);
4671
+ },
4672
+ getGenerated(id, index) {
4673
+ return generatedByFile.get((0, _weapp_tailwindcss_shared.cleanUrl)(id))?.get(index);
4674
+ },
4675
+ hasGenerated(id) {
4676
+ return Boolean(generatedByFile.get((0, _weapp_tailwindcss_shared.cleanUrl)(id))?.size);
4677
+ },
4678
+ load(id, index) {
4679
+ const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
4680
+ const style = authoredByFile.get(file)?.[index];
4681
+ if (!style) {
4682
+ const generated = generatedByFile.get(file)?.get(index);
4683
+ return generated === void 0 ? void 0 : {
4684
+ code: generated,
4685
+ map: null
4686
+ };
4687
+ }
4688
+ const normalized = (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.source);
4689
+ return normalized === style.source ? void 0 : {
4690
+ code: normalized,
4691
+ map: null
4692
+ };
4693
+ }
4694
+ };
4695
+ }
4696
+ function resolveUniAppXStyleSource(code, query, generatedSource) {
4697
+ if (VITE_CSS_HMR_MODULE_RE.test(code)) return { skip: true };
4698
+ if (!query.vue || query.type !== "style") return { code };
4699
+ if (generatedSource !== void 0) return { code: generatedSource };
4700
+ const styleBlocks = require_web.extractSfcStyleBlocks(code);
4701
+ if (styleBlocks.length === 0) return { code };
4702
+ const style = styleBlocks[query.index ?? 0];
4703
+ return style ? { code: style.source } : { skip: true };
4704
+ }
4705
+ function hasUniAppXImportantApply(source, normalize) {
4706
+ return require_web.extractSfcStyleBlocks(source).some((style) => normalize(style.source) !== style.source);
4707
+ }
4708
+ //#endregion
4567
4709
  //#region src/uni-app-x/vite/web-local-style.ts
4568
4710
  function isStyleModule(mod) {
4569
4711
  const request = mod.id ?? mod.url;
@@ -4639,14 +4781,11 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
4639
4781
  //#region src/uni-app-x/vite.ts
4640
4782
  let transformUVuePromise;
4641
4783
  function loadTransformUVue() {
4642
- transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-C7QxW-fV.cjs")).then((mod) => mod.transformUVue));
4784
+ transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-DAg85t9Z.cjs")).then((mod) => mod.transformUVue));
4643
4785
  return transformUVuePromise;
4644
4786
  }
4645
4787
  const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
4646
4788
  const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
4647
- function hasUniAppXImportantApply(source) {
4648
- return require_web.extractSfcStyleBlocks(source).some((style) => (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.source) !== style.source);
4649
- }
4650
4789
  function createUniAppXPlugins(options) {
4651
4790
  const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, registerModuleGraphCandidates, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, hmrCssModuleVersions, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [], webCssEntryDiagnostics } = options;
4652
4791
  const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(uniAppX);
@@ -4654,7 +4793,7 @@ function createUniAppXPlugins(options) {
4654
4793
  const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
4655
4794
  const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
4656
4795
  const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
4657
- const knownSfcSources = /* @__PURE__ */ new Map();
4796
+ const sfcStyleSources = createUniAppXSfcStyleSources();
4658
4797
  const pendingSfcTransforms = /* @__PURE__ */ new Map();
4659
4798
  const webLocalStyle = createUniAppXWebLocalStyleBridge(isWebGeneratorTarget, hmrCssModuleVersions);
4660
4799
  let componentLocalStyleEnabled;
@@ -4718,6 +4857,9 @@ function createUniAppXPlugins(options) {
4718
4857
  async function transformStyle(code, id, query, hookContext) {
4719
4858
  const isNativeStyle = isNativeAppBuildTarget(id);
4720
4859
  const parsed = query ?? require_web.parseVueRequest(id).query;
4860
+ const resolvedSource = resolveUniAppXStyleSource(code, parsed);
4861
+ if (resolvedSource.skip) return;
4862
+ code = resolvedSource.code;
4721
4863
  if (require_web.isCSSRequest(id) || parsed.vue && parsed.type === "style") {
4722
4864
  if (isCssModuleExport(code)) return;
4723
4865
  const sourceCode = normalizeRelativeTailwindReferences((0, _weapp_tailwindcss_postcss.restoreUniAppXImportantApplyMarker)(code), id);
@@ -4770,14 +4912,8 @@ function createUniAppXPlugins(options) {
4770
4912
  async handler(id) {
4771
4913
  const { filename, query } = require_web.parseVueRequest(id);
4772
4914
  if (!query.vue || query.type !== "style" || !UVUE_NVUE_RE.test(filename)) return;
4773
- const source = knownSfcSources.get(filename);
4774
- const style = source ? require_web.extractSfcStyleBlocks(source)[query.index ?? 0] : void 0;
4775
- if (!style) return;
4776
- const normalized = (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.source);
4777
- return normalized === style.source ? void 0 : {
4778
- code: normalized,
4779
- map: null
4780
- };
4915
+ await pendingSfcTransforms.get((0, _weapp_tailwindcss_shared.cleanUrl)(filename));
4916
+ return sfcStyleSources.load(filename, query.index ?? 0);
4781
4917
  }
4782
4918
  },
4783
4919
  async transform(code, id) {
@@ -4785,7 +4921,9 @@ function createUniAppXPlugins(options) {
4785
4921
  await runtimeState.readyPromise;
4786
4922
  const { filename, query } = require_web.parseVueRequest(id);
4787
4923
  if (query.vue && query.type === "style") await pendingSfcTransforms.get((0, _weapp_tailwindcss_shared.cleanUrl)(filename));
4788
- const styleCode = query.vue && query.type === "style" ? webLocalStyle.appendToStyle(code, id) : code;
4924
+ const resolvedSource = resolveUniAppXStyleSource(code, query, sfcStyleSources.getGenerated(filename, query.index ?? 0));
4925
+ if (resolvedSource.skip) return;
4926
+ const styleCode = query.vue && query.type === "style" && !sfcStyleSources.hasGenerated(filename) ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
4789
4927
  const preprocessorCode = query.vue && query.type === "style" ? (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(styleCode) : styleCode;
4790
4928
  const preprocessor = resolvePreprocessorTransform(preprocessorCode, id, query.lang, {
4791
4929
  isIosPlatform,
@@ -4799,7 +4937,7 @@ function createUniAppXPlugins(options) {
4799
4937
  }
4800
4938
  }];
4801
4939
  async function transformSfc(code, id, context) {
4802
- knownSfcSources.set((0, _weapp_tailwindcss_shared.cleanUrl)(id), code);
4940
+ sfcStyleSources.rememberSource(id, code);
4803
4941
  if (isWebGeneratorTarget()) for (const style of require_web.extractSfcStyleBlocks(code)) webCssEntryDiagnostics?.observeSourceImports(style.source, id);
4804
4942
  if (isNativeAppBuildTarget(id)) {
4805
4943
  nativeLocalStyleModuleIds.add(id);
@@ -4822,6 +4960,7 @@ function createUniAppXPlugins(options) {
4822
4960
  ...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
4823
4961
  ...enablePageLocalStyle ? { enablePageLocalStyle } : {},
4824
4962
  native: true,
4963
+ ...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
4825
4964
  pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
4826
4965
  ...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
4827
4966
  ...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => {
@@ -4830,6 +4969,7 @@ function createUniAppXPlugins(options) {
4830
4969
  } } : {}
4831
4970
  });
4832
4971
  const result = Object.keys(transformOptions).length > 0 ? transformUVue(code, id, jsHandler, currentRuntimeSet, transformOptions) : transformUVue(code, id, jsHandler, currentRuntimeSet);
4972
+ sfcStyleSources.rememberGenerated(id, isWebGeneratorTarget() ? result?.code ?? "" : "");
4833
4973
  if (!result?.code) return result;
4834
4974
  harmonyApply.rememberSource(result.code, id);
4835
4975
  const expandedCode = await harmonyApply.expandStyles(result.code, id, context);
@@ -4858,7 +4998,8 @@ function createUniAppXPlugins(options) {
4858
4998
  order: "pre",
4859
4999
  async handler(code, id) {
4860
5000
  if (!isEnabled()) return;
4861
- if (!UVUE_NVUE_QUERY_RE.test(id)) return;
5001
+ const { query } = require_web.parseVueRequest(id);
5002
+ if (!UVUE_NVUE_QUERY_RE.test(id) || query.vue && query.type === "style") return;
4862
5003
  return runTransformSfc(code, id, this);
4863
5004
  }
4864
5005
  },
@@ -4868,8 +5009,9 @@ function createUniAppXPlugins(options) {
4868
5009
  if (!isEnabled() || getResolvedConfig()?.command !== "serve") return;
4869
5010
  if (!UVUE_NVUE_RE.test(ctx.file) && !require_web.isCSSRequest(ctx.file)) return;
4870
5011
  if (isWebGeneratorTarget() && UVUE_NVUE_RE.test(ctx.file) && typeof ctx.read === "function") {
5012
+ hmrCssModuleVersions?.clear();
4871
5013
  const source = await ctx.read();
4872
- if (hasUniAppXImportantApply(source)) {
5014
+ if (hasUniAppXImportantApply(source, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)) {
4873
5015
  ctx.server.ws.send({
4874
5016
  type: "full-reload",
4875
5017
  path: ctx.file
@@ -5137,8 +5279,13 @@ async function processRememberedCssReplay(options) {
5137
5279
  const rememberedKeys = replayableRememberedGroup.map((item) => item.key);
5138
5280
  const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
5139
5281
  if (!rememberedCssSource) continue;
5140
- const { rawSource, sourceFile } = rememberedCssSource;
5141
- const generatorRawSource = isWebGeneratorTarget ? rawSource : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
5282
+ const { sourceFile } = rememberedCssSource;
5283
+ const rawSource = isWebGeneratorTarget ? rememberedCssSource.rawSource : require_v4_generation_core.normalizeMiniProgramImportShell(rememberedCssSource.rawSource, {
5284
+ cssOnly: true,
5285
+ outputFile,
5286
+ outputFiles: [...bundleFiles, ...lastCssResultByFile.keys()]
5287
+ });
5288
+ const generatorRawSource = isWebGeneratorTarget ? rawSource : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(rawSource, outputFile, [...bundleFiles, ...lastCssResultByFile.keys()]);
5142
5289
  activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
5143
5290
  activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
5144
5291
  const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
@@ -5219,7 +5366,7 @@ async function processRememberedCssReplay(options) {
5219
5366
  if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
5220
5367
  metrics.css.elapsed += measureElapsed(start);
5221
5368
  metrics.css.transformed++;
5222
- onUpdate(outputFile, rawSource, css);
5369
+ onUpdate(outputFile, rememberedCssSource.rawSource, css);
5223
5370
  debug("css replay preserve local import shell: %s", outputFile);
5224
5371
  }));
5225
5372
  continue;
@@ -5259,7 +5406,7 @@ async function processRememberedCssReplay(options) {
5259
5406
  if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
5260
5407
  metrics.css.elapsed += measureElapsed(start);
5261
5408
  metrics.css.transformed++;
5262
- onUpdate(outputFile, rawSource, css);
5409
+ onUpdate(outputFile, rememberedCssSource.rawSource, css);
5263
5410
  debug("css replay handle: %s", outputFile);
5264
5411
  }));
5265
5412
  }
@@ -5343,7 +5490,7 @@ function createConfiguredCssRootResolvers(options) {
5343
5490
  if (matchedOriginalEntry && outputFile.replace(/[?#].*$/, "").endsWith(".css")) return matchedOriginalEntry;
5344
5491
  const shouldRequireExplicitEntry = !options.cssPipelineContext.currentGeneratorBranch.isWeb && options.opts.cssMatcher(outputFile) && isRootStyleOutputFile(outputFile);
5345
5492
  const generationEntries = entries.filter((entry) => require_web.hasTailwindGenerationSource(entry.source) && (!shouldRequireExplicitEntry || explicitFileKeys.has(normalizeEntryFile(entry.file))));
5346
- const matchedOutputEntries = generationEntries.filter((entry) => require_source_candidate_scan_signature.normalizeOutputPathKey(resolveEntryOutputFile(entry.file).replace(/[?#].*$/, "")) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")));
5493
+ const matchedOutputEntries = generationEntries.filter((entry) => require_source_candidate_scan_signature.normalizeOutputPathKey(resolveEntryOutputFile(entry.file).replace(/[?#].*$/, "")) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")) || (originalFileNames?.length ?? 0) === 0 && require_source_candidate_scan_signature.normalizeOutputPathKey(options.rootImportShellTargets?.get(resolveEntryOutputFile(entry.file)) ?? "") === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")));
5347
5494
  if (matchedOutputEntries.length === 1) return matchedOutputEntries[0];
5348
5495
  if (!shouldSelectRootOutput(outputFile)) return;
5349
5496
  if (generationEntries.length <= 1) return generationEntries[0];
@@ -5407,7 +5554,7 @@ function createConfiguredCssRootResolvers(options) {
5407
5554
  }
5408
5555
  //#endregion
5409
5556
  //#region src/bundlers/vite/generate-bundle/runtime-linked-css.ts
5410
- const MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE = /\.(?:wxml|axml|jxml|ksml|ttml|qml|tyml|xhsml|swan)$/i;
5557
+ const MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE = /\.(?:wxml|axml|jxml|ksml|ttml|qml|qxml|tyml|xhsml|swan)$/i;
5411
5558
  const JS_STYLE_IMPORT_RE = /\b(?:import|require)\s*(?:\(\s*)?["']([^"']+\.(?:css|less|sass|scss|styl|stylus|pcss|postcss))(?:[?#][^"']*)?["']/g;
5412
5559
  function addSiblingCssFile(files, file, extensionByStem, fallbackExtension) {
5413
5560
  const templateMatch = file.replace(/[?#].*$/, "").match(MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE);
@@ -5888,7 +6035,7 @@ function createGenerateBundleHook$1(context) {
5888
6035
  const outDir = resolvedConfig?.build?.outDir ? node_path.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
5889
6036
  const defaultStyleOutputExtension = require_web.resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) });
5890
6037
  const normalizeMiniProgramGeneratorRawSource = (source, outputFile) => {
5891
- return isWebGeneratorTarget ? source : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(source, outputFile);
6038
+ return isWebGeneratorTarget ? source : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(source, outputFile, [...Object.keys(bundle), ...lastCssResultByFile.keys()]);
5892
6039
  };
5893
6040
  await runtimeState.readyPromise;
5894
6041
  debug("start");
@@ -5948,6 +6095,7 @@ function createGenerateBundleHook$1(context) {
5948
6095
  currentSubpackageRoots,
5949
6096
  defaultStyleOutputExtension,
5950
6097
  entries: configuredTailwindV4CssSourceEntriesForScope,
6098
+ rootImportShellTargets: frameworkRootImportShellTargetByFile,
5951
6099
  explicitCssEntryFiles: configuredTailwindV4ExplicitCssEntryFiles,
5952
6100
  isWebGeneratorTarget,
5953
6101
  opts,
@@ -6512,6 +6660,55 @@ function createGenerateBundleHook(context) {
6512
6660
  };
6513
6661
  }
6514
6662
  //#endregion
6663
+ //#region src/bundlers/vite/generate-bundle/entry-style-graph.ts
6664
+ function linkEntryChunkStyles(bundle, options) {
6665
+ const assets = new Map(Object.entries(bundle).flatMap(([key, output]) => output.type === "asset" ? [[require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || key), output]] : []));
6666
+ const imports = /* @__PURE__ */ new Map();
6667
+ for (const [file, asset] of assets) {
6668
+ if (!options.matchesCss(file)) continue;
6669
+ const targets = /* @__PURE__ */ new Set();
6670
+ _weapp_tailwindcss_postcss.postcss.parse(asset.source.toString()).walkAtRules("import", (rule) => {
6671
+ const request = require_generator.parseCssImportSpecifier(rule.params)?.specifier;
6672
+ if (request && !/^(?:[a-z][a-z\d+.-]*:|\/\/|\/)/i.test(request)) {
6673
+ const target = node_path.default.posix.normalize(node_path.default.posix.join(node_path.default.posix.dirname(file), request));
6674
+ if (assets.has(target)) targets.add(target);
6675
+ }
6676
+ });
6677
+ imports.set(file, targets);
6678
+ }
6679
+ const reaches = (from, target, visited = /* @__PURE__ */ new Set()) => {
6680
+ if (from === target) return true;
6681
+ if (visited.has(from)) return false;
6682
+ visited.add(from);
6683
+ return [...imports.get(from) ?? []].some((next) => reaches(next, target, visited));
6684
+ };
6685
+ for (const chunk of Object.values(bundle)) {
6686
+ if (chunk.type !== "chunk" || !chunk.isEntry) continue;
6687
+ const entry = node_path.default.posix.parse(require_source_candidate_scan_signature.normalizeOutputPathKey(chunk.fileName));
6688
+ const roots = [...assets].filter(([file]) => {
6689
+ const style = node_path.default.posix.parse(file);
6690
+ return options.matchesCss(file) && style.dir === entry.dir && style.name === entry.name;
6691
+ });
6692
+ if (roots.length !== 1) continue;
6693
+ const [file, asset] = roots[0];
6694
+ const original = asset.source.toString();
6695
+ const requests = [];
6696
+ for (const id of Object.keys(chunk.modules ?? {})) {
6697
+ const output = options.resolveOutputFile(id);
6698
+ const target = output && require_source_candidate_scan_signature.normalizeOutputPathKey(output);
6699
+ if (!target || !imports.has(target) || reaches(file, target) || reaches(target, file)) continue;
6700
+ imports.get(file).add(target);
6701
+ const relative = node_path.default.posix.relative(node_path.default.posix.dirname(file), target);
6702
+ requests.push(`@import ${require_generator.quoteCssImportSpecifier(relative.startsWith(".") ? relative : `./${relative}`)};\n`);
6703
+ }
6704
+ if (requests.length > 0) {
6705
+ const next = requests.join("") + original;
6706
+ asset.source = next;
6707
+ options.onUpdate?.(file, original, next);
6708
+ }
6709
+ }
6710
+ }
6711
+ //#endregion
6515
6712
  //#region src/bundlers/vite/css-finalizer/plugin.ts
6516
6713
  function createViteCssFinalizerOutputPlugin(context) {
6517
6714
  return {
@@ -6598,6 +6795,17 @@ function createViteCssFinalizerOutputPlugin(context) {
6598
6795
  finalCssAssetFiles.add(file);
6599
6796
  opts.onUpdate(file, original, generated);
6600
6797
  };
6798
+ const linkEntryStyles = () => {
6799
+ if (isWebGeneratorTarget) return;
6800
+ linkEntryChunkStyles(bundle, {
6801
+ matchesCss: opts.cssMatcher,
6802
+ onUpdate: trackFinalCssAssetUpdate,
6803
+ resolveOutputFile: (id) => {
6804
+ if (!opts.cssMatcher(id) || id.includes("?")) return;
6805
+ return require_web.resolveViteCssPipelineOutputFile(id, opts, rootDir, false, false, sourceRoot, require_web.resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle));
6806
+ }
6807
+ });
6808
+ };
6601
6809
  restoreFrameworkRootMiniProgramImportShellAssets(bundle, {
6602
6810
  debug,
6603
6811
  isWebGeneratorTarget,
@@ -6704,6 +6912,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6704
6912
  await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
6705
6913
  collectViteProcessedCssAssets();
6706
6914
  injectViteProcessedCssIntoMainCss();
6915
+ linkEntryStyles();
6707
6916
  normalizeRootMiniProgramImportShellAssets(bundle, {
6708
6917
  cssMatcher: opts.cssMatcher,
6709
6918
  debug,
@@ -6828,6 +7037,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6828
7037
  await injectHarmonyBundleStyles();
6829
7038
  collectViteProcessedCssAssets();
6830
7039
  injectViteProcessedCssIntoMainCss();
7040
+ linkEntryStyles();
6831
7041
  normalizeRootMiniProgramImportShellAssets(bundle, {
6832
7042
  cssMatcher: opts.cssMatcher,
6833
7043
  debug,
@@ -6866,7 +7076,7 @@ function createViteServeJsTransformPlugin(options) {
6866
7076
  if (!options.shouldTransform() || !isViteServeJsRequest(id, options.getCommand())) return;
6867
7077
  const handlerOptions = options.createHandlerOptions(id);
6868
7078
  if (require_compiler.shouldSkipJsTransform(code, handlerOptions)) return;
6869
- const runtime = await options.transformRuntime();
7079
+ const runtime = await options.transformRuntime(id, code);
6870
7080
  const { code: transformed } = await options.jsHandler(code, runtime, handlerOptions);
6871
7081
  if (transformed === code) return;
6872
7082
  return {
@@ -7004,9 +7214,9 @@ function createConfiguredCssEntryDiagnostics(options) {
7004
7214
  //#endregion
7005
7215
  //#region src/bundlers/vite/shared/framework-module-candidates.ts
7006
7216
  function createFrameworkModuleCandidateRegistrar(options) {
7007
- return async (id, source) => {
7217
+ return async (id, source, extension) => {
7008
7218
  await options.runtimeState.readyPromise;
7009
- const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source);
7219
+ const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source, extension);
7010
7220
  options.invalidateRecordedGeneratorCandidates();
7011
7221
  options.cacheCurrent();
7012
7222
  const cssHandlerOptions = options.getCssHandlerOptions(id);
@@ -7745,7 +7955,7 @@ ${previousTracedCss}`;
7745
7955
  previousCss: previousGeneratorCss,
7746
7956
  previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
7747
7957
  deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
7748
- deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
7958
+ deferCssAdaptation: resolvedConfig?.command === "build" && !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
7749
7959
  disableSourceScan: hookContext?.disableSourceScan === true,
7750
7960
  cssStage: hookContext?.cssStage,
7751
7961
  restoreLocalCssImports: !currentGeneratorBranch.isWeb
@@ -7938,6 +8148,8 @@ ${tracedCss}`;
7938
8148
  await sourceScanSession.sync();
7939
8149
  };
7940
8150
  const extraPlugins = capability.frameworkExtras ? frameworkBranch.createExtraPlugins?.({
8151
+ cssPreflight: opts.cssPreflight,
8152
+ cssPreflightRange: opts.cssPreflightRange,
7941
8153
  customAttributesEntities,
7942
8154
  disabledDefaultTemplateHandler,
7943
8155
  ensureRuntimeClassSet,
@@ -8042,7 +8254,7 @@ ${tracedCss}`;
8042
8254
  getCommand: () => resolvedConfig?.command,
8043
8255
  jsHandler,
8044
8256
  shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
8045
- transformRuntime: ensureRuntimeClassSet
8257
+ transformRuntime: (id, code) => registerModuleGraphCandidates(id, code, "js")
8046
8258
  }) : void 0;
8047
8259
  const plugins = [
8048
8260
  ...sourceAndRewritePlugins,
@@ -8091,7 +8303,7 @@ function wrapPluginCloseBundle(hook, dispose) {
8091
8303
  try {
8092
8304
  return await hook.apply(this, args);
8093
8305
  } finally {
8094
- dispose();
8306
+ dispose.call(this);
8095
8307
  }
8096
8308
  };
8097
8309
  if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
@@ -8100,7 +8312,7 @@ function wrapPluginCloseBundle(hook, dispose) {
8100
8312
  try {
8101
8313
  return await hook.handler.apply(this, args);
8102
8314
  } finally {
8103
- dispose();
8315
+ dispose.call(this);
8104
8316
  }
8105
8317
  }
8106
8318
  };
@@ -8124,7 +8336,12 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
8124
8336
  })
8125
8337
  }));
8126
8338
  const cleanupPlugin = wrappedPlugins.at(-1);
8127
- if (cleanupPlugin) cleanupPlugin.closeBundle = wrapPluginCloseBundle(cleanupPlugin.closeBundle, relationOwner.dispose);
8339
+ if (cleanupPlugin) {
8340
+ cleanupPlugin.closeBundle = wrapPluginCloseBundle(cleanupPlugin.closeBundle, function() {
8341
+ if (!this.meta?.watchMode) relationOwner.dispose();
8342
+ });
8343
+ cleanupPlugin.closeWatcher = wrapPluginCloseBundle(cleanupPlugin.closeWatcher, relationOwner.dispose);
8344
+ }
8128
8345
  return wrappedPlugins;
8129
8346
  }
8130
8347
  //#endregion
@@ -8163,11 +8380,13 @@ function createTaroAlipayBrowserslistAssetPlugin() {
8163
8380
  };
8164
8381
  }
8165
8382
  function createTaroVitePlugins(options = {}) {
8166
- return [createTaroAlipayBrowserslistAssetPlugin(), ...createViteFrameworkPlugins(options, {
8383
+ const plugins = createViteFrameworkPlugins(options, {
8167
8384
  frameworkName: "taro",
8168
8385
  cssPipelineStrategy: taroCssPipelineStrategy,
8169
8386
  styleInjectorDelegate: require_scoped_generator.viteStyleInjectorDelegates.taro
8170
- })];
8387
+ });
8388
+ if (!plugins) return;
8389
+ return [createTaroAlipayBrowserslistAssetPlugin(), ...plugins];
8171
8390
  }
8172
8391
  //#endregion
8173
8392
  //#region src/bundlers/vite/frameworks/uni-app/index.ts
@@ -8362,7 +8581,8 @@ const uniAppXCssPipelineStrategy = {
8362
8581
  },
8363
8582
  transformGeneratedCss(css, context) {
8364
8583
  const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
8365
- return withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
8584
+ const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
8585
+ return context.currentGeneratorBranch.isWeb ? output : hoistUniAppXBorderPreflight(output);
8366
8586
  }
8367
8587
  };
8368
8588
  function createUniAppXVitePlugins(options = {}) {
@@ -8376,6 +8596,8 @@ function createUniAppXVitePlugins(options = {}) {
8376
8596
  sourceCandidatesBeforeExtraPlugin: (plugin) => plugin.name === "weapp-tailwindcss:uni-app-x:nvue",
8377
8597
  createExtraPlugins: (context) => createUniAppXPlugins({
8378
8598
  appType: "uni-app-x",
8599
+ cssPreflight: context.cssPreflight,
8600
+ cssPreflightRange: context.cssPreflightRange,
8379
8601
  customAttributesEntities: context.customAttributesEntities,
8380
8602
  disabledDefaultTemplateHandler: context.disabledDefaultTemplateHandler,
8381
8603
  ensureRuntimeClassSet: context.ensureRuntimeClassSet,
@@ -8660,6 +8882,18 @@ Object.defineProperty(exports, "WeappTailwindcss", {
8660
8882
  return WeappTailwindcss;
8661
8883
  }
8662
8884
  });
8885
+ Object.defineProperty(exports, "injectBorderPreflightClass", {
8886
+ enumerable: true,
8887
+ get: function() {
8888
+ return injectBorderPreflightClass;
8889
+ }
8890
+ });
8891
+ Object.defineProperty(exports, "isUniAppXStyleSourceEmpty", {
8892
+ enumerable: true,
8893
+ get: function() {
8894
+ return isUniAppXStyleSourceEmpty;
8895
+ }
8896
+ });
8663
8897
  Object.defineProperty(exports, "shouldEnableComponentLocalStyle", {
8664
8898
  enumerable: true,
8665
8899
  get: function() {
@@ -8672,3 +8906,9 @@ Object.defineProperty(exports, "shouldEnablePageLocalStyle", {
8672
8906
  return shouldEnablePageLocalStyle;
8673
8907
  }
8674
8908
  });
8909
+ Object.defineProperty(exports, "shouldInjectBorderPreflight", {
8910
+ enumerable: true,
8911
+ get: function() {
8912
+ return shouldInjectBorderPreflight;
8913
+ }
8914
+ });