weapp-tailwindcss 5.5.1 → 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 (77) hide show
  1. package/dist/bundlers/shared/css-imports.d.ts +1 -0
  2. package/dist/bundlers/shared/framework-user-css.d.ts +3 -0
  3. package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +6 -2
  4. package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -1
  5. package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
  6. package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -1
  7. package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +3 -2
  8. package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +1 -0
  9. package/dist/bundlers/vite/generate-bundle/entry-style-graph.d.ts +6 -0
  10. package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +1 -0
  11. package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
  12. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
  13. package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +1 -1
  14. package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +3 -1
  15. package/dist/bundlers/webpack/shared/loader-anchors.d.ts +1 -0
  16. package/dist/compiler/runtime-snapshot.d.ts +4 -1
  17. package/dist/{compiler-D2ZJc3uA.cjs → compiler-BSMSbVVt.cjs} +6 -6
  18. package/dist/{compiler-B0YSc0DY.js → compiler-tHMcW3BT.js} +3 -3
  19. package/dist/core.cjs +1 -1
  20. package/dist/core.js +1 -1
  21. package/dist/{css-imports-BFMU7Hpd.cjs → css-imports-DsCSPIj2.cjs} +29 -0
  22. package/dist/{css-loader-runtime-CSv0lKqV.cjs → css-loader-runtime-DGqsWVua.cjs} +2 -1
  23. package/dist/{defaults-B5ep0ojb.js → defaults-CKx-4LcW.js} +1 -1
  24. package/dist/{defaults-BI9j1znS.cjs → defaults-CiGsr8Xq.cjs} +1 -1
  25. package/dist/defaults.cjs +1 -1
  26. package/dist/defaults.js +1 -1
  27. package/dist/{generator-DsrQ9txU.cjs → generator-CCw17l0G.cjs} +72 -67
  28. package/dist/{generator-DyXTBPmE.js → generator-DxEsInLz.js} +61 -68
  29. package/dist/generator.cjs +1 -1
  30. package/dist/generator.js +1 -1
  31. package/dist/{gulp-C9ENAx3f.cjs → gulp-C1r36Y_f.cjs} +5 -5
  32. package/dist/{gulp-DXeQfvVC.js → gulp-qGXKwQMZ.js} +4 -4
  33. package/dist/gulp.cjs +1 -1
  34. package/dist/gulp.js +1 -1
  35. package/dist/{hmr-timing-DNxQm-bN.js → hmr-timing-DixZjtTS.js} +245 -183
  36. package/dist/{hmr-timing-Cz4IesEM.cjs → hmr-timing-DuIbach8.cjs} +5 -5
  37. package/dist/index.cjs +4 -4
  38. package/dist/index.js +4 -4
  39. package/dist/{pipeline-helpers-CSGnR5gh.cjs → pipeline-helpers-CUwwOFt3.cjs} +4 -4
  40. package/dist/postcss.cjs +1 -1
  41. package/dist/postcss.js +1 -1
  42. package/dist/presets.cjs +2 -2
  43. package/dist/presets.js +2 -2
  44. package/dist/rspack.cjs +6 -3
  45. package/dist/rspack.js +6 -3
  46. package/dist/{scoped-generator-kRj_5Axx.js → scoped-generator-BJvL2CKZ.js} +3 -3
  47. package/dist/{scoped-generator-TVjEaOeP.cjs → scoped-generator-CO9xZ06m.cjs} +3 -3
  48. package/dist/{source-candidate-scan-signature-CsP4BQNa.js → source-candidate-scan-signature-CgJi--lh.js} +2 -2
  49. package/dist/{source-candidate-scan-signature-B7cUxqqX.cjs → source-candidate-scan-signature-_UPwg8oJ.cjs} +2 -2
  50. package/dist/tailwindcss/v4-engine/css-import.d.ts +14 -0
  51. package/dist/{tailwindcss-BK9S7zuq.js → tailwindcss-D2joPNdN.js} +1 -1
  52. package/dist/{tailwindcss-C-jBBQfw.cjs → tailwindcss-DhaLV5a2.cjs} +1 -1
  53. package/dist/{transform-CfOzh007.js → transform-BNtyKkZi.js} +14 -14
  54. package/dist/{transform-DUPOPZ54.cjs → transform-DAg85t9Z.cjs} +14 -14
  55. package/dist/uni-app-x/border-preflight.d.ts +18 -0
  56. package/dist/uni-app-x/style-asset/source-parser.d.ts +2 -0
  57. package/dist/uni-app-x/transform.d.ts +2 -0
  58. package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
  59. package/dist/uni-app-x/vite/style-source.d.ts +14 -4
  60. package/dist/{v4-generation-core-CRNUU_Rr.cjs → v4-generation-core-bOm8k4AY.cjs} +243 -181
  61. package/dist/vite/web.cjs +1 -1
  62. package/dist/vite/web.js +1 -1
  63. package/dist/{vite-BXe-axax.js → vite-C_JJxZWl.js} +271 -66
  64. package/dist/{vite-D_mAIfTU.cjs → vite-bJZi1V-l.cjs} +287 -63
  65. package/dist/vite.cjs +1 -1
  66. package/dist/vite.js +1 -1
  67. package/dist/{watch-dependencies-DLZDrWdH.cjs → watch-dependencies-GbC14Rlt.cjs} +14 -11
  68. package/dist/weapp-tw-css-generation-loader.cjs +3 -2
  69. package/dist/weapp-tw-css-import-rewrite-loader.cjs +11 -10
  70. package/dist/weapp-tw-runtime-classset-loader.cjs +16 -11
  71. package/dist/{web-B2Ea9K4B.cjs → web-B4wa3xrE.cjs} +9 -8
  72. package/dist/{web-Cv7ualrU.js → web-BiubXhxs.js} +7 -6
  73. package/dist/{webpack-7Um2GFtx.js → webpack-BDOQUv3J.js} +38 -23
  74. package/dist/{webpack-Ce04-btG.cjs → webpack-CsBe1G_1.cjs} +37 -23
  75. package/dist/webpack.cjs +1 -1
  76. package/dist/webpack.js +1 -1
  77. package/package.json +6 -4
@@ -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-CRNUU_Rr.cjs");
7
- const require_compiler = require("./compiler-D2ZJc3uA.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-Cz4IesEM.cjs");
9
+ const require_hmr_timing = require("./hmr-timing-DuIbach8.cjs");
10
10
  const require_final_css_cleanup = require("./final-css-cleanup-DSjczga3.cjs");
11
- const require_scoped_generator = require("./scoped-generator-TVjEaOeP.cjs");
12
- const require_web = require("./web-B2Ea9K4B.cjs");
13
- const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-B7cUxqqX.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
  }
@@ -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) {
@@ -4566,9 +4655,48 @@ function resolvePreprocessorTransform(code, id, lang, options) {
4566
4655
  //#endregion
4567
4656
  //#region src/uni-app-x/vite/style-source.ts
4568
4657
  const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
4569
- function resolveUniAppXStyleSource(code, query) {
4570
- if (!query.vue || query.type !== "style") return { code };
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) {
4571
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 };
4572
4700
  const styleBlocks = require_web.extractSfcStyleBlocks(code);
4573
4701
  if (styleBlocks.length === 0) return { code };
4574
4702
  const style = styleBlocks[query.index ?? 0];
@@ -4653,7 +4781,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
4653
4781
  //#region src/uni-app-x/vite.ts
4654
4782
  let transformUVuePromise;
4655
4783
  function loadTransformUVue() {
4656
- transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-DUPOPZ54.cjs")).then((mod) => mod.transformUVue));
4784
+ transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-DAg85t9Z.cjs")).then((mod) => mod.transformUVue));
4657
4785
  return transformUVuePromise;
4658
4786
  }
4659
4787
  const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
@@ -4665,7 +4793,7 @@ function createUniAppXPlugins(options) {
4665
4793
  const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
4666
4794
  const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
4667
4795
  const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
4668
- const knownSfcSources = /* @__PURE__ */ new Map();
4796
+ const sfcStyleSources = createUniAppXSfcStyleSources();
4669
4797
  const pendingSfcTransforms = /* @__PURE__ */ new Map();
4670
4798
  const webLocalStyle = createUniAppXWebLocalStyleBridge(isWebGeneratorTarget, hmrCssModuleVersions);
4671
4799
  let componentLocalStyleEnabled;
@@ -4784,14 +4912,8 @@ function createUniAppXPlugins(options) {
4784
4912
  async handler(id) {
4785
4913
  const { filename, query } = require_web.parseVueRequest(id);
4786
4914
  if (!query.vue || query.type !== "style" || !UVUE_NVUE_RE.test(filename)) return;
4787
- const source = knownSfcSources.get(filename);
4788
- const style = source ? require_web.extractSfcStyleBlocks(source)[query.index ?? 0] : void 0;
4789
- if (!style) return;
4790
- const normalized = (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.source);
4791
- return normalized === style.source ? void 0 : {
4792
- code: normalized,
4793
- map: null
4794
- };
4915
+ await pendingSfcTransforms.get((0, _weapp_tailwindcss_shared.cleanUrl)(filename));
4916
+ return sfcStyleSources.load(filename, query.index ?? 0);
4795
4917
  }
4796
4918
  },
4797
4919
  async transform(code, id) {
@@ -4799,9 +4921,9 @@ function createUniAppXPlugins(options) {
4799
4921
  await runtimeState.readyPromise;
4800
4922
  const { filename, query } = require_web.parseVueRequest(id);
4801
4923
  if (query.vue && query.type === "style") await pendingSfcTransforms.get((0, _weapp_tailwindcss_shared.cleanUrl)(filename));
4802
- const resolvedSource = resolveUniAppXStyleSource(code, query);
4924
+ const resolvedSource = resolveUniAppXStyleSource(code, query, sfcStyleSources.getGenerated(filename, query.index ?? 0));
4803
4925
  if (resolvedSource.skip) return;
4804
- const styleCode = query.vue && query.type === "style" ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
4926
+ const styleCode = query.vue && query.type === "style" && !sfcStyleSources.hasGenerated(filename) ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
4805
4927
  const preprocessorCode = query.vue && query.type === "style" ? (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(styleCode) : styleCode;
4806
4928
  const preprocessor = resolvePreprocessorTransform(preprocessorCode, id, query.lang, {
4807
4929
  isIosPlatform,
@@ -4815,7 +4937,7 @@ function createUniAppXPlugins(options) {
4815
4937
  }
4816
4938
  }];
4817
4939
  async function transformSfc(code, id, context) {
4818
- knownSfcSources.set((0, _weapp_tailwindcss_shared.cleanUrl)(id), code);
4940
+ sfcStyleSources.rememberSource(id, code);
4819
4941
  if (isWebGeneratorTarget()) for (const style of require_web.extractSfcStyleBlocks(code)) webCssEntryDiagnostics?.observeSourceImports(style.source, id);
4820
4942
  if (isNativeAppBuildTarget(id)) {
4821
4943
  nativeLocalStyleModuleIds.add(id);
@@ -4838,6 +4960,7 @@ function createUniAppXPlugins(options) {
4838
4960
  ...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
4839
4961
  ...enablePageLocalStyle ? { enablePageLocalStyle } : {},
4840
4962
  native: true,
4963
+ ...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
4841
4964
  pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
4842
4965
  ...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
4843
4966
  ...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => {
@@ -4846,6 +4969,7 @@ function createUniAppXPlugins(options) {
4846
4969
  } } : {}
4847
4970
  });
4848
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 ?? "" : "");
4849
4973
  if (!result?.code) return result;
4850
4974
  harmonyApply.rememberSource(result.code, id);
4851
4975
  const expandedCode = await harmonyApply.expandStyles(result.code, id, context);
@@ -4874,7 +4998,8 @@ function createUniAppXPlugins(options) {
4874
4998
  order: "pre",
4875
4999
  async handler(code, id) {
4876
5000
  if (!isEnabled()) return;
4877
- 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;
4878
5003
  return runTransformSfc(code, id, this);
4879
5004
  }
4880
5005
  },
@@ -4884,6 +5009,7 @@ function createUniAppXPlugins(options) {
4884
5009
  if (!isEnabled() || getResolvedConfig()?.command !== "serve") return;
4885
5010
  if (!UVUE_NVUE_RE.test(ctx.file) && !require_web.isCSSRequest(ctx.file)) return;
4886
5011
  if (isWebGeneratorTarget() && UVUE_NVUE_RE.test(ctx.file) && typeof ctx.read === "function") {
5012
+ hmrCssModuleVersions?.clear();
4887
5013
  const source = await ctx.read();
4888
5014
  if (hasUniAppXImportantApply(source, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)) {
4889
5015
  ctx.server.ws.send({
@@ -5153,8 +5279,13 @@ async function processRememberedCssReplay(options) {
5153
5279
  const rememberedKeys = replayableRememberedGroup.map((item) => item.key);
5154
5280
  const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
5155
5281
  if (!rememberedCssSource) continue;
5156
- const { rawSource, sourceFile } = rememberedCssSource;
5157
- 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()]);
5158
5289
  activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
5159
5290
  activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
5160
5291
  const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
@@ -5235,7 +5366,7 @@ async function processRememberedCssReplay(options) {
5235
5366
  if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
5236
5367
  metrics.css.elapsed += measureElapsed(start);
5237
5368
  metrics.css.transformed++;
5238
- onUpdate(outputFile, rawSource, css);
5369
+ onUpdate(outputFile, rememberedCssSource.rawSource, css);
5239
5370
  debug("css replay preserve local import shell: %s", outputFile);
5240
5371
  }));
5241
5372
  continue;
@@ -5275,7 +5406,7 @@ async function processRememberedCssReplay(options) {
5275
5406
  if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
5276
5407
  metrics.css.elapsed += measureElapsed(start);
5277
5408
  metrics.css.transformed++;
5278
- onUpdate(outputFile, rawSource, css);
5409
+ onUpdate(outputFile, rememberedCssSource.rawSource, css);
5279
5410
  debug("css replay handle: %s", outputFile);
5280
5411
  }));
5281
5412
  }
@@ -5359,7 +5490,7 @@ function createConfiguredCssRootResolvers(options) {
5359
5490
  if (matchedOriginalEntry && outputFile.replace(/[?#].*$/, "").endsWith(".css")) return matchedOriginalEntry;
5360
5491
  const shouldRequireExplicitEntry = !options.cssPipelineContext.currentGeneratorBranch.isWeb && options.opts.cssMatcher(outputFile) && isRootStyleOutputFile(outputFile);
5361
5492
  const generationEntries = entries.filter((entry) => require_web.hasTailwindGenerationSource(entry.source) && (!shouldRequireExplicitEntry || explicitFileKeys.has(normalizeEntryFile(entry.file))));
5362
- 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(/[?#].*$/, "")));
5363
5494
  if (matchedOutputEntries.length === 1) return matchedOutputEntries[0];
5364
5495
  if (!shouldSelectRootOutput(outputFile)) return;
5365
5496
  if (generationEntries.length <= 1) return generationEntries[0];
@@ -5423,7 +5554,7 @@ function createConfiguredCssRootResolvers(options) {
5423
5554
  }
5424
5555
  //#endregion
5425
5556
  //#region src/bundlers/vite/generate-bundle/runtime-linked-css.ts
5426
- 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;
5427
5558
  const JS_STYLE_IMPORT_RE = /\b(?:import|require)\s*(?:\(\s*)?["']([^"']+\.(?:css|less|sass|scss|styl|stylus|pcss|postcss))(?:[?#][^"']*)?["']/g;
5428
5559
  function addSiblingCssFile(files, file, extensionByStem, fallbackExtension) {
5429
5560
  const templateMatch = file.replace(/[?#].*$/, "").match(MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE);
@@ -5904,7 +6035,7 @@ function createGenerateBundleHook$1(context) {
5904
6035
  const outDir = resolvedConfig?.build?.outDir ? node_path.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
5905
6036
  const defaultStyleOutputExtension = require_web.resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) });
5906
6037
  const normalizeMiniProgramGeneratorRawSource = (source, outputFile) => {
5907
- 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()]);
5908
6039
  };
5909
6040
  await runtimeState.readyPromise;
5910
6041
  debug("start");
@@ -5964,6 +6095,7 @@ function createGenerateBundleHook$1(context) {
5964
6095
  currentSubpackageRoots,
5965
6096
  defaultStyleOutputExtension,
5966
6097
  entries: configuredTailwindV4CssSourceEntriesForScope,
6098
+ rootImportShellTargets: frameworkRootImportShellTargetByFile,
5967
6099
  explicitCssEntryFiles: configuredTailwindV4ExplicitCssEntryFiles,
5968
6100
  isWebGeneratorTarget,
5969
6101
  opts,
@@ -6528,6 +6660,55 @@ function createGenerateBundleHook(context) {
6528
6660
  };
6529
6661
  }
6530
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
6531
6712
  //#region src/bundlers/vite/css-finalizer/plugin.ts
6532
6713
  function createViteCssFinalizerOutputPlugin(context) {
6533
6714
  return {
@@ -6614,6 +6795,17 @@ function createViteCssFinalizerOutputPlugin(context) {
6614
6795
  finalCssAssetFiles.add(file);
6615
6796
  opts.onUpdate(file, original, generated);
6616
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
+ };
6617
6809
  restoreFrameworkRootMiniProgramImportShellAssets(bundle, {
6618
6810
  debug,
6619
6811
  isWebGeneratorTarget,
@@ -6720,6 +6912,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6720
6912
  await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
6721
6913
  collectViteProcessedCssAssets();
6722
6914
  injectViteProcessedCssIntoMainCss();
6915
+ linkEntryStyles();
6723
6916
  normalizeRootMiniProgramImportShellAssets(bundle, {
6724
6917
  cssMatcher: opts.cssMatcher,
6725
6918
  debug,
@@ -6844,6 +7037,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6844
7037
  await injectHarmonyBundleStyles();
6845
7038
  collectViteProcessedCssAssets();
6846
7039
  injectViteProcessedCssIntoMainCss();
7040
+ linkEntryStyles();
6847
7041
  normalizeRootMiniProgramImportShellAssets(bundle, {
6848
7042
  cssMatcher: opts.cssMatcher,
6849
7043
  debug,
@@ -6882,7 +7076,7 @@ function createViteServeJsTransformPlugin(options) {
6882
7076
  if (!options.shouldTransform() || !isViteServeJsRequest(id, options.getCommand())) return;
6883
7077
  const handlerOptions = options.createHandlerOptions(id);
6884
7078
  if (require_compiler.shouldSkipJsTransform(code, handlerOptions)) return;
6885
- const runtime = await options.transformRuntime();
7079
+ const runtime = await options.transformRuntime(id, code);
6886
7080
  const { code: transformed } = await options.jsHandler(code, runtime, handlerOptions);
6887
7081
  if (transformed === code) return;
6888
7082
  return {
@@ -7020,9 +7214,9 @@ function createConfiguredCssEntryDiagnostics(options) {
7020
7214
  //#endregion
7021
7215
  //#region src/bundlers/vite/shared/framework-module-candidates.ts
7022
7216
  function createFrameworkModuleCandidateRegistrar(options) {
7023
- return async (id, source) => {
7217
+ return async (id, source, extension) => {
7024
7218
  await options.runtimeState.readyPromise;
7025
- const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source);
7219
+ const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source, extension);
7026
7220
  options.invalidateRecordedGeneratorCandidates();
7027
7221
  options.cacheCurrent();
7028
7222
  const cssHandlerOptions = options.getCssHandlerOptions(id);
@@ -7761,7 +7955,7 @@ ${previousTracedCss}`;
7761
7955
  previousCss: previousGeneratorCss,
7762
7956
  previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
7763
7957
  deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
7764
- deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
7958
+ deferCssAdaptation: resolvedConfig?.command === "build" && !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
7765
7959
  disableSourceScan: hookContext?.disableSourceScan === true,
7766
7960
  cssStage: hookContext?.cssStage,
7767
7961
  restoreLocalCssImports: !currentGeneratorBranch.isWeb
@@ -7954,6 +8148,8 @@ ${tracedCss}`;
7954
8148
  await sourceScanSession.sync();
7955
8149
  };
7956
8150
  const extraPlugins = capability.frameworkExtras ? frameworkBranch.createExtraPlugins?.({
8151
+ cssPreflight: opts.cssPreflight,
8152
+ cssPreflightRange: opts.cssPreflightRange,
7957
8153
  customAttributesEntities,
7958
8154
  disabledDefaultTemplateHandler,
7959
8155
  ensureRuntimeClassSet,
@@ -8058,7 +8254,7 @@ ${tracedCss}`;
8058
8254
  getCommand: () => resolvedConfig?.command,
8059
8255
  jsHandler,
8060
8256
  shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
8061
- transformRuntime: ensureRuntimeClassSet
8257
+ transformRuntime: (id, code) => registerModuleGraphCandidates(id, code, "js")
8062
8258
  }) : void 0;
8063
8259
  const plugins = [
8064
8260
  ...sourceAndRewritePlugins,
@@ -8107,7 +8303,7 @@ function wrapPluginCloseBundle(hook, dispose) {
8107
8303
  try {
8108
8304
  return await hook.apply(this, args);
8109
8305
  } finally {
8110
- dispose();
8306
+ dispose.call(this);
8111
8307
  }
8112
8308
  };
8113
8309
  if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
@@ -8116,7 +8312,7 @@ function wrapPluginCloseBundle(hook, dispose) {
8116
8312
  try {
8117
8313
  return await hook.handler.apply(this, args);
8118
8314
  } finally {
8119
- dispose();
8315
+ dispose.call(this);
8120
8316
  }
8121
8317
  }
8122
8318
  };
@@ -8140,7 +8336,12 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
8140
8336
  })
8141
8337
  }));
8142
8338
  const cleanupPlugin = wrappedPlugins.at(-1);
8143
- 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
+ }
8144
8345
  return wrappedPlugins;
8145
8346
  }
8146
8347
  //#endregion
@@ -8179,11 +8380,13 @@ function createTaroAlipayBrowserslistAssetPlugin() {
8179
8380
  };
8180
8381
  }
8181
8382
  function createTaroVitePlugins(options = {}) {
8182
- return [createTaroAlipayBrowserslistAssetPlugin(), ...createViteFrameworkPlugins(options, {
8383
+ const plugins = createViteFrameworkPlugins(options, {
8183
8384
  frameworkName: "taro",
8184
8385
  cssPipelineStrategy: taroCssPipelineStrategy,
8185
8386
  styleInjectorDelegate: require_scoped_generator.viteStyleInjectorDelegates.taro
8186
- })];
8387
+ });
8388
+ if (!plugins) return;
8389
+ return [createTaroAlipayBrowserslistAssetPlugin(), ...plugins];
8187
8390
  }
8188
8391
  //#endregion
8189
8392
  //#region src/bundlers/vite/frameworks/uni-app/index.ts
@@ -8378,7 +8581,8 @@ const uniAppXCssPipelineStrategy = {
8378
8581
  },
8379
8582
  transformGeneratedCss(css, context) {
8380
8583
  const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
8381
- 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);
8382
8586
  }
8383
8587
  };
8384
8588
  function createUniAppXVitePlugins(options = {}) {
@@ -8392,6 +8596,8 @@ function createUniAppXVitePlugins(options = {}) {
8392
8596
  sourceCandidatesBeforeExtraPlugin: (plugin) => plugin.name === "weapp-tailwindcss:uni-app-x:nvue",
8393
8597
  createExtraPlugins: (context) => createUniAppXPlugins({
8394
8598
  appType: "uni-app-x",
8599
+ cssPreflight: context.cssPreflight,
8600
+ cssPreflightRange: context.cssPreflightRange,
8395
8601
  customAttributesEntities: context.customAttributesEntities,
8396
8602
  disabledDefaultTemplateHandler: context.disabledDefaultTemplateHandler,
8397
8603
  ensureRuntimeClassSet: context.ensureRuntimeClassSet,
@@ -8676,6 +8882,18 @@ Object.defineProperty(exports, "WeappTailwindcss", {
8676
8882
  return WeappTailwindcss;
8677
8883
  }
8678
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
+ });
8679
8897
  Object.defineProperty(exports, "shouldEnableComponentLocalStyle", {
8680
8898
  enumerable: true,
8681
8899
  get: function() {
@@ -8688,3 +8906,9 @@ Object.defineProperty(exports, "shouldEnablePageLocalStyle", {
8688
8906
  return shouldEnablePageLocalStyle;
8689
8907
  }
8690
8908
  });
8909
+ Object.defineProperty(exports, "shouldInjectBorderPreflight", {
8910
+ enumerable: true,
8911
+ get: function() {
8912
+ return shouldInjectBorderPreflight;
8913
+ }
8914
+ });