weapp-tailwindcss 5.2.8 → 5.2.9

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.
@@ -5264,7 +5264,7 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
5264
5264
  //#endregion
5265
5265
  //#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
5266
5266
  async function finalizeGenerateBundle(options) {
5267
- const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
5267
+ const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pendingRememberedCssReplayUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
5268
5268
  const tasksStart = performance.now();
5269
5269
  if (cssTaskFactories.length > 0) {
5270
5270
  const cssTask = runWithConcurrency(cssTaskFactories, resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion)).then(() => void 0);
@@ -5310,7 +5310,7 @@ async function finalizeGenerateBundle(options) {
5310
5310
  });
5311
5311
  recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
5312
5312
  const injectStartedAt = performance.now();
5313
- const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
5313
+ let injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
5314
5314
  opts,
5315
5315
  cssPipelineStrategy,
5316
5316
  createCssPipelineContext,
@@ -5327,6 +5327,26 @@ async function finalizeGenerateBundle(options) {
5327
5327
  onUpdate,
5328
5328
  recordTimingDetail
5329
5329
  });
5330
+ if (pendingRememberedCssReplayUpdates.length > 0) {
5331
+ for (const update of pendingRememberedCssReplayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
5332
+ injected += injectViteProcessedCssIntoMainCssAssets(bundle, {
5333
+ opts,
5334
+ cssPipelineStrategy,
5335
+ createCssPipelineContext,
5336
+ getViteProcessedCssAssetResults: () => pendingRememberedCssReplayUpdates.map((update) => [update.file, {
5337
+ css: update.css,
5338
+ injectIntoMain: update.injectIntoMain,
5339
+ outputFile: update.outputFile
5340
+ }]),
5341
+ markCssAssetProcessed,
5342
+ recordCssAssetResult,
5343
+ transformCss: transformWebTargetCss,
5344
+ debug,
5345
+ onUpdate,
5346
+ recordTimingDetail
5347
+ });
5348
+ debug("inject remembered css replay updates after framework css collection: %d", pendingRememberedCssReplayUpdates.length);
5349
+ }
5330
5350
  recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
5331
5351
  return injected;
5332
5352
  };
@@ -6134,11 +6154,22 @@ function resolveUniAppXCssTarget(id) {
6134
6154
  function isCssModuleExport(code) {
6135
6155
  return CSS_MODULE_EXPORT_RE.test(code);
6136
6156
  }
6157
+ function resolvePreprocessorTransform(code, id, lang, options) {
6158
+ if (!isPreprocessorRequest(id, lang)) return;
6159
+ if (options.isIosPlatform) {
6160
+ const normalizedCode = normalizeTailwindcssV4InfinityCalcCss(code);
6161
+ return { result: normalizedCode === code ? void 0 : {
6162
+ code: normalizedCode,
6163
+ map: null
6164
+ } };
6165
+ }
6166
+ if (options.isWebGeneratorTarget && !options.isNativeAppStyleTarget) return { result: void 0 };
6167
+ }
6137
6168
  //#endregion
6138
6169
  //#region src/uni-app-x/vite.ts
6139
6170
  let transformUVuePromise;
6140
6171
  function loadTransformUVue() {
6141
- transformUVuePromise ?? (transformUVuePromise = import("./transform-DVGsr8cV.js").then((mod) => mod.transformUVue));
6172
+ transformUVuePromise ?? (transformUVuePromise = import("./transform-DhDe9eSf.js").then((mod) => mod.transformUVue));
6142
6173
  return transformUVuePromise;
6143
6174
  }
6144
6175
  const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
@@ -6147,7 +6178,7 @@ function resolveUniAppXJsTransformEnabled(uniAppX) {
6147
6178
  return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
6148
6179
  }
6149
6180
  function createUniAppXPlugins(options) {
6150
- const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
6181
+ const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
6151
6182
  const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
6152
6183
  const utsPlatform = resolveUniUtsPlatform();
6153
6184
  const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
@@ -6263,14 +6294,12 @@ function createUniAppXPlugins(options) {
6263
6294
  if (!isEnabled()) return;
6264
6295
  await runtimeState.readyPromise;
6265
6296
  const { query } = parseVueRequest(id);
6266
- const lang = query.lang;
6267
- if (isIosPlatform && isPreprocessorRequest(id, lang)) {
6268
- const normalizedCode = normalizeTailwindcssV4InfinityCalcCss(code);
6269
- return normalizedCode === code ? void 0 : {
6270
- code: normalizedCode,
6271
- map: null
6272
- };
6273
- }
6297
+ const preprocessor = resolvePreprocessorTransform(code, id, query.lang, {
6298
+ isIosPlatform,
6299
+ isNativeAppStyleTarget: isNativeAppStyleTarget(),
6300
+ isWebGeneratorTarget: isWebGeneratorTarget()
6301
+ });
6302
+ if (preprocessor) return preprocessor.result;
6274
6303
  return transformStyle(code, id, query, this);
6275
6304
  }
6276
6305
  }];
@@ -6555,10 +6584,33 @@ function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
6555
6584
  const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
6556
6585
  return SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
6557
6586
  }
6587
+ function resolveRememberedCssReplayOutputFile(outputFile, targetByFile) {
6588
+ const outputKey = normalizeOutputPathKey(outputFile);
6589
+ for (const [shellFile, targetFile] of targetByFile ?? []) if (normalizeOutputPathKey(shellFile) === outputKey) return targetFile;
6590
+ return outputFile;
6591
+ }
6592
+ function createRememberedCssReplayUpdates(css, sourceFile, outputFile, injectIntoMain) {
6593
+ const updates = [{
6594
+ css,
6595
+ file: sourceFile,
6596
+ injectIntoMain,
6597
+ outputFile
6598
+ }];
6599
+ if (outputFile !== sourceFile) updates.push({
6600
+ css,
6601
+ file: outputFile,
6602
+ injectIntoMain,
6603
+ outputFile
6604
+ });
6605
+ return updates;
6606
+ }
6558
6607
  async function processRememberedCssReplay(options) {
6559
- const { addWatchFile, activeViteCssCacheFiles, bundle, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, cssPipelineContext, cssPipelineStrategy, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssRawSourceHashByFile = /* @__PURE__ */ new Map(), lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
6608
+ const { addWatchFile, activeViteCssCacheFiles, bundle, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, cssPipelineContext, cssPipelineStrategy, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, frameworkRootImportShellTargetByFile, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssRawSourceHashByFile = /* @__PURE__ */ new Map(), lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, pendingRememberedCssReplayUpdates, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
6560
6609
  const rememberedReplayGroups = collectRememberedCssReplayGroups(getRememberedCssSources?.(), opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
6561
- for (const [outputFile, rememberedGroup] of rememberedReplayGroups) {
6610
+ const normalizedBundleFiles = new Set(bundleFiles.map(normalizeOutputPathKey));
6611
+ for (const [rememberedOutputFile, rememberedGroup] of rememberedReplayGroups) {
6612
+ const outputFile = resolveRememberedCssReplayOutputFile(rememberedOutputFile, frameworkRootImportShellTargetByFile);
6613
+ if (outputFile !== rememberedOutputFile) debug("css replay use framework root import shell target: %s -> %s", rememberedOutputFile, outputFile);
6562
6614
  if (isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
6563
6615
  const replayableRememberedGroup = rememberedGroup.filter(({ remembered }) => {
6564
6616
  const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
@@ -6572,7 +6624,7 @@ async function processRememberedCssReplay(options) {
6572
6624
  const generatorRawSource = isWebGeneratorTarget ? rawSource : normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
6573
6625
  activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
6574
6626
  activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
6575
- const outputCssHandlerOptions = getCssHandlerOptions(outputFile);
6627
+ const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
6576
6628
  const cssHandlerOptions = {
6577
6629
  ...getCssHandlerOptions(sourceFile),
6578
6630
  isMainChunk: outputCssHandlerOptions.isMainChunk
@@ -6591,7 +6643,19 @@ async function processRememberedCssReplay(options) {
6591
6643
  const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
6592
6644
  const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
6593
6645
  const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
6594
- if (bundleFiles.includes(outputFile) || bundleFiles.includes(sourceFile) || allRememberedSignaturesFresh) continue;
6646
+ if (bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
6647
+ const shouldMergeReplayIntoFrameworkRootTarget = outputFile !== rememberedOutputFile && normalizedBundleFiles.has(normalizeOutputPathKey(outputFile));
6648
+ if (allRememberedSignaturesFresh) if (!shouldMergeReplayIntoFrameworkRootTarget) continue;
6649
+ else {
6650
+ const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
6651
+ if (cachedCss != null) {
6652
+ pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
6653
+ metrics.css.cacheHits++;
6654
+ debug("css replay cached result into framework root target: %s", outputFile);
6655
+ continue;
6656
+ }
6657
+ debug("css replay framework root target cache miss, regenerate: %s", outputFile);
6658
+ }
6595
6659
  const sourceTraceSources = scopedSourceCandidateSourceGetter ? await createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
6596
6660
  const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
6597
6661
  const annotateCss = (css) => annotateCssSourceTrace(css, {
@@ -6599,7 +6663,7 @@ async function processRememberedCssReplay(options) {
6599
6663
  tokenSources: sourceTraceTokenSources
6600
6664
  });
6601
6665
  const shouldRecordRememberedReplayCss = useIncrementalMode || isNativeAppStyleTarget;
6602
- const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss;
6666
+ const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss && !shouldMergeReplayIntoFrameworkRootTarget;
6603
6667
  if (!shouldRecordRememberedReplayCss) continue;
6604
6668
  const shouldPreserveLocalImportWrapper = shouldPreserveFrameworkRootMiniProgramImportShell({
6605
6669
  css: rawSource,
@@ -6667,14 +6731,10 @@ async function processRememberedCssReplay(options) {
6667
6731
  registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
6668
6732
  recordCssAssetResult?.(outputFile, css);
6669
6733
  const shouldInjectReplayCssIntoMain = shouldInjectCssIntoMainFromOutput(outputFile, sourceFile, outputCssHandlerOptions);
6670
- recordViteProcessedCssAssetResult?.(sourceFile, css, {
6671
- injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain,
6672
- outputFile
6673
- });
6674
- if (outputFile !== sourceFile) recordViteProcessedCssAssetResult?.(outputFile, css, {
6675
- injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain,
6676
- outputFile
6677
- });
6734
+ const injectIntoMain = shouldMergeReplayIntoFrameworkRootTarget ? true : outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain;
6735
+ const replayUpdates = createRememberedCssReplayUpdates(css, sourceFile, outputFile, injectIntoMain);
6736
+ if (shouldMergeReplayIntoFrameworkRootTarget) pendingRememberedCssReplayUpdates.push(...replayUpdates);
6737
+ else for (const update of replayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
6678
6738
  debug("css replay generated result: %s bytes=%d", outputFile, css.length);
6679
6739
  }
6680
6740
  if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
@@ -7566,6 +7626,7 @@ function createGenerateBundleHook$1(context) {
7566
7626
  const tasks = [];
7567
7627
  const cssTaskFactories = [];
7568
7628
  const jsTaskFactories = [];
7629
+ const pendingRememberedCssReplayUpdates = [];
7569
7630
  const entryPlanningStartedAt = performance.now();
7570
7631
  for (const entry of snapshot.entries) {
7571
7632
  const { file, output: originalSource, source: originalEntrySource, type } = entry;
@@ -7791,6 +7852,7 @@ function createGenerateBundleHook$1(context) {
7791
7852
  debug,
7792
7853
  defaultStyleOutputExtension,
7793
7854
  emitOrReplayCssAsset,
7855
+ frameworkRootImportShellTargetByFile,
7794
7856
  generatorPlatform,
7795
7857
  generatorRuntime,
7796
7858
  getCssHandlerOptions,
@@ -7807,6 +7869,7 @@ function createGenerateBundleHook$1(context) {
7807
7869
  normalizeViteCssCacheKey,
7808
7870
  onUpdate,
7809
7871
  opts,
7872
+ pendingRememberedCssReplayUpdates,
7810
7873
  recordCssAssetResult,
7811
7874
  recordViteProcessedCssAssetResult,
7812
7875
  rootDir,
@@ -7858,6 +7921,7 @@ function createGenerateBundleHook$1(context) {
7858
7921
  opts,
7859
7922
  outDir,
7860
7923
  pendingLinkedUpdates,
7924
+ pendingRememberedCssReplayUpdates,
7861
7925
  pruneViteCssCaches,
7862
7926
  recordCssAssetResult,
7863
7927
  recordTimingDetail,
@@ -8950,24 +9014,27 @@ function wrapViteCssPostTransform(config, transformCss) {
8950
9014
  }
8951
9015
  //#endregion
8952
9016
  //#region src/bundlers/vite/shared/framework-hmr-candidate-state.ts
8953
- const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
8954
9017
  function createViteHmrCandidateState(options) {
8955
9018
  let pendingChange;
8956
9019
  let pendingCssTargetFiles;
9020
+ let pendingTargetsArmed = false;
8957
9021
  let pendingFullRegeneration = false;
8958
9022
  const normalizeCssTargetFile = (file) => normalizeVitePersistentCacheKey(cleanUrl(file));
8959
9023
  const clear = () => {
8960
9024
  pendingChange = void 0;
8961
9025
  pendingCssTargetFiles = void 0;
9026
+ pendingTargetsArmed = false;
8962
9027
  pendingFullRegeneration = false;
8963
9028
  };
8964
9029
  const queueFullRegeneration = () => {
8965
9030
  pendingChange = void 0;
8966
9031
  pendingCssTargetFiles = void 0;
9032
+ pendingTargetsArmed = false;
8967
9033
  pendingFullRegeneration = true;
8968
9034
  };
8969
9035
  const queueChange = (change) => {
8970
9036
  var _pendingChange;
9037
+ if (pendingFullRegeneration) return;
8971
9038
  pendingFullRegeneration = false;
8972
9039
  if (!pendingChange) {
8973
9040
  pendingChange = {
@@ -8989,7 +9056,7 @@ function createViteHmrCandidateState(options) {
8989
9056
  const createChange = (file, change, changeOptions = {}) => ({
8990
9057
  ...change,
8991
9058
  file,
8992
- runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || isSourceStyleRequest(file) || WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(options.getSourceCandidate(file) ?? "")
9059
+ runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || isSourceStyleRequest(file)
8993
9060
  });
8994
9061
  const apply = (change) => {
8995
9062
  if (isSourceStyleRequest(change.file)) {
@@ -9003,7 +9070,7 @@ function createViteHmrCandidateState(options) {
9003
9070
  const preserveDeletedCss = options.getGeneratorOptions().hmr.preserveDeletedCss;
9004
9071
  if (preserveDeletedCss) {
9005
9072
  if (change.addedCandidates.size > 0) queueChange(change);
9006
- else if (!pendingChange) clear();
9073
+ else if (!pendingChange && !pendingFullRegeneration) clear();
9007
9074
  return change;
9008
9075
  }
9009
9076
  clear();
@@ -9012,28 +9079,26 @@ function createViteHmrCandidateState(options) {
9012
9079
  };
9013
9080
  const resolve = (generatorCode, file) => {
9014
9081
  const fileKey = normalizeCssTargetFile(file);
9015
- if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) || pendingCssTargetFiles !== void 0 && !pendingCssTargetFiles.has(fileKey)) return;
9082
+ if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) || pendingTargetsArmed && !pendingCssTargetFiles?.has(fileKey)) return;
9016
9083
  return pendingChange;
9017
9084
  };
9018
9085
  const finishTarget = (file) => {
9019
- if (!pendingChange) return;
9020
- if (!pendingCssTargetFiles) {
9021
- clear();
9022
- return;
9023
- }
9086
+ if (!pendingChange && !pendingFullRegeneration) return;
9087
+ if (!pendingTargetsArmed || !pendingCssTargetFiles) return;
9024
9088
  pendingCssTargetFiles.delete(normalizeCssTargetFile(file));
9025
9089
  if (pendingCssTargetFiles.size === 0) clear();
9026
9090
  };
9027
9091
  const armTargets = (cssModules, fallbackCssIds) => {
9028
- if (!pendingChange) {
9092
+ if (!pendingChange && !pendingFullRegeneration) {
9029
9093
  pendingCssTargetFiles = void 0;
9094
+ pendingTargetsArmed = false;
9030
9095
  return;
9031
9096
  }
9032
9097
  const targets = /* @__PURE__ */ new Set();
9033
9098
  const addTarget = (file) => {
9034
9099
  if (!file) return;
9035
9100
  const key = normalizeCssTargetFile(file);
9036
- if (options.cleanGeneratedCssByFile.has(key)) targets.add(key);
9101
+ if (pendingFullRegeneration || options.cleanGeneratedCssByFile.has(key)) targets.add(key);
9037
9102
  };
9038
9103
  for (const module of cssModules) {
9039
9104
  addTarget(module.id);
@@ -9041,7 +9106,28 @@ function createViteHmrCandidateState(options) {
9041
9106
  addTarget(module.url);
9042
9107
  }
9043
9108
  for (const id of fallbackCssIds) addTarget(id);
9044
- pendingCssTargetFiles = targets.size > 0 ? targets : void 0;
9109
+ pendingCssTargetFiles = targets;
9110
+ pendingTargetsArmed = true;
9111
+ };
9112
+ const reconcileRuntimeCandidates = (file, candidates, rootCssIds) => {
9113
+ if (options.getCommand() !== "serve" || pendingFullRegeneration) return;
9114
+ const generatedClassSets = [];
9115
+ const seenFiles = /* @__PURE__ */ new Set();
9116
+ for (const id of rootCssIds) {
9117
+ const fileKey = normalizeCssTargetFile(id);
9118
+ if (seenFiles.has(fileKey)) continue;
9119
+ seenFiles.add(fileKey);
9120
+ const classSet = options.generatedClassSetByFile.get(fileKey);
9121
+ if (classSet) generatedClassSets.push(classSet);
9122
+ }
9123
+ if (generatedClassSets.length === 0) return;
9124
+ const addedCandidates = /* @__PURE__ */ new Set();
9125
+ for (const candidate of candidates) if (generatedClassSets.some((classSet) => !classSet.has(candidate))) addedCandidates.add(candidate);
9126
+ if (addedCandidates.size === 0) return;
9127
+ apply(createChange(file, {
9128
+ addedCandidates,
9129
+ removedCandidates: /* @__PURE__ */ new Set()
9130
+ }));
9045
9131
  };
9046
9132
  return {
9047
9133
  apply,
@@ -9050,13 +9136,19 @@ function createViteHmrCandidateState(options) {
9050
9136
  createChange,
9051
9137
  finishTarget,
9052
9138
  hasPendingCandidateAppend: () => pendingChange != null && !pendingChange.runtimeAffecting && pendingChange.addedCandidates.size > 0,
9053
- hasPendingChange: () => pendingChange != null,
9139
+ hasPendingChange: () => pendingChange != null || pendingFullRegeneration,
9054
9140
  queueFullRegeneration,
9141
+ reconcileRuntimeCandidates,
9055
9142
  resolve,
9056
- shouldForceFullRegeneration: (resolved) => pendingFullRegeneration || options.getCommand() === "serve" && pendingChange != null && !resolved,
9143
+ shouldForceFullRegeneration: (file, resolved) => {
9144
+ if (options.getCommand() !== "serve") return false;
9145
+ if (pendingFullRegeneration) return pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
9146
+ return pendingChange != null && !resolved && pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
9147
+ },
9057
9148
  snapshotDebugState: () => ({
9058
9149
  pendingAddedCandidates: pendingChange?.addedCandidates.size ?? 0,
9059
- pendingCssTargets: pendingCssTargetFiles?.size ?? 0
9150
+ pendingCssTargets: pendingCssTargetFiles?.size ?? 0,
9151
+ pendingFullRegeneration
9060
9152
  })
9061
9153
  };
9062
9154
  }
@@ -9350,6 +9442,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
9350
9442
  await options.refreshTailwindRootCssSource(ctx.file, hotSource);
9351
9443
  }
9352
9444
  const sourceCandidateChange = await options.sourceScanSession.syncChangedFile(ctx.file, hotSource);
9445
+ options.sourceScanSession.consumeHotUpdateChange(ctx.file);
9353
9446
  const isWebLikeHotUpdate = options.isCurrentWebLikeStylePlatform();
9354
9447
  let canUseHmrCandidateAppend = false;
9355
9448
  if (isSourceCandidateHotUpdate) {
@@ -9368,6 +9461,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
9368
9461
  }
9369
9462
  }
9370
9463
  if (isSourceCandidateHotUpdate) await options.sourceScanSession.waitForPendingSyncs();
9464
+ if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) options.hmrCandidateState.reconcileRuntimeCandidates(ctx.file, options.sourceCandidateCollector.values(), options.tailwindRootCssModuleIds);
9371
9465
  const cssModules = await resolveHotTailwindCssModules(ctx, isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds);
9372
9466
  const hotRoot = ctx.server.config?.root ?? process$1.cwd();
9373
9467
  const sourceModules = isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
@@ -9386,7 +9480,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
9386
9480
  }
9387
9481
  const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
9388
9482
  const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles]);
9389
- if (hasHmrCandidateAppend) options.hmrCandidateState.armTargets(cssModules, supplementalCssFallbackIds);
9483
+ if (options.hmrCandidateState.hasPendingChange()) options.hmrCandidateState.armTargets(cssModules, supplementalCssFallbackIds);
9390
9484
  if (shouldSendSupplementalCssHotUpdates) sendSupplementalCssHotUpdates(ctx, cssModules, supplementalCssFallbackIds);
9391
9485
  if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules) : hasDifferentHotModules(sourceModules, ctx.modules) ? sourceModules : void 0;
9392
9486
  if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && cssModules.length > 0) return mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules);
@@ -9401,6 +9495,16 @@ function createFrameworkSourceCandidatesPlugin(options) {
9401
9495
  };
9402
9496
  }
9403
9497
  //#endregion
9498
+ //#region src/bundlers/vite/shared/framework-hmr-runtime-signature.ts
9499
+ const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
9500
+ function createFrameworkHmrRuntimeSignature(file, source) {
9501
+ if (!source || !WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(source)) return "";
9502
+ return (isSfcStyleSourceFile(cleanUrl(file)) ? extractSfcStyleSources(source).filter((styleSource) => WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(styleSource)) : [source]).map((styleSource) => createRuntimeAffectingSourceSignature(styleSource, "css")).join("\0");
9503
+ }
9504
+ function hasFrameworkHmrRuntimeSourceChange(file, previousSource, nextSource) {
9505
+ return createFrameworkHmrRuntimeSignature(file, previousSource) !== createFrameworkHmrRuntimeSignature(file, nextSource);
9506
+ }
9507
+ //#endregion
9404
9508
  //#region src/bundlers/vite/shared/framework-source-scan-session.ts
9405
9509
  const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
9406
9510
  const sourceCandidateScanSnapshotCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
@@ -9419,6 +9523,7 @@ function createFrameworkSourceScanSession(options) {
9419
9523
  let sourceCandidateScanInvalidated = true;
9420
9524
  const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
9421
9525
  const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
9526
+ const pendingHotUpdateChangeByFile = /* @__PURE__ */ new Map();
9422
9527
  const normalizeDependency = (file) => path.normalize(path.resolve(cleanUrl(file)));
9423
9528
  const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
9424
9529
  const invalidate = () => {
@@ -9520,6 +9625,26 @@ function createFrameworkSourceScanSession(options) {
9520
9625
  const waitForPendingSyncs = async () => {
9521
9626
  while (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
9522
9627
  };
9628
+ const rememberHotUpdateChange = (change) => {
9629
+ if (!change) return;
9630
+ const previous = pendingHotUpdateChangeByFile.get(change.file);
9631
+ if (!previous) {
9632
+ const remembered = {
9633
+ ...change,
9634
+ addedCandidates: new Set(change.addedCandidates),
9635
+ removedCandidates: new Set(change.removedCandidates)
9636
+ };
9637
+ pendingHotUpdateChangeByFile.set(change.file, remembered);
9638
+ return remembered;
9639
+ }
9640
+ for (const candidate of change.addedCandidates) {
9641
+ previous.addedCandidates.add(candidate);
9642
+ previous.removedCandidates.delete(candidate);
9643
+ }
9644
+ for (const candidate of change.removedCandidates) if (!previous.addedCandidates.delete(candidate)) previous.removedCandidates.add(candidate);
9645
+ previous.runtimeAffecting || (previous.runtimeAffecting = change.runtimeAffecting);
9646
+ return previous;
9647
+ };
9523
9648
  const syncChangedFile = (id, sourceOverride) => {
9524
9649
  if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return Promise.resolve(void 0);
9525
9650
  const file = cleanUrl(id);
@@ -9530,15 +9655,18 @@ function createFrameworkSourceScanSession(options) {
9530
9655
  cacheCurrent();
9531
9656
  return (isSourceStyleRequest(file) ? readFile(file, "utf8").then((source) => options.cssMemory.refreshRememberedCssSourceBySourceFile(file, source)).catch((error) => {
9532
9657
  if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) !== "ENOENT") options.debug("remembered css source watch refresh failed: %s %O", file, error);
9533
- }) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true })));
9658
+ }) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => rememberHotUpdateChange(options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true }))));
9534
9659
  }
9535
9660
  const existingTask = pendingSourceCandidateSyncByFile.get(file);
9536
9661
  if (existingTask) return existingTask.then(() => syncChangedFile(id, sourceOverride));
9662
+ const previousSource = options.sourceCandidateCollector.source(file);
9537
9663
  const task = (sourceOverride === void 0 ? options.sourceCandidateCollector.syncCurrentFile(id) : options.sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
9538
9664
  options.debug("source candidate watch sync failed: %s %O", id, error);
9539
9665
  }).then((change) => {
9540
9666
  cacheCurrent();
9541
- return change ? options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency })) : void 0;
9667
+ const runtimeAffectingBySource = hasFrameworkHmrRuntimeSourceChange(file, previousSource, options.sourceCandidateCollector.source(file));
9668
+ const appliedChange = change ? options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency || runtimeAffectingBySource })) : void 0;
9669
+ return rememberHotUpdateChange(appliedChange) ?? pendingHotUpdateChangeByFile.get(file);
9542
9670
  }).finally(() => {
9543
9671
  pendingSourceCandidateSyncs.delete(task);
9544
9672
  pendingSourceCandidateSyncByFile.delete(file);
@@ -9552,9 +9680,11 @@ function createFrameworkSourceScanSession(options) {
9552
9680
  };
9553
9681
  return {
9554
9682
  cacheCurrent,
9683
+ consumeHotUpdateChange: (id) => pendingHotUpdateChangeByFile.delete(cleanUrl(id)),
9555
9684
  getStats: () => ({
9556
9685
  pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size,
9557
9686
  pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
9687
+ pendingHotUpdateChangeByFile: pendingHotUpdateChangeByFile.size,
9558
9688
  sourceCandidateScanCache: sourceCandidateScanCache.size
9559
9689
  }),
9560
9690
  invalidate,
@@ -9880,8 +10010,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
9880
10010
  generatedClassSetByFile,
9881
10011
  getCommand: () => resolvedConfig?.command,
9882
10012
  getGeneratorOptions: resolveCurrentGeneratorOptions,
9883
- getSourceCandidate: (file) => sourceCandidateCollector.source(file),
9884
- isRuntimeAffectingSource: (file) => uniAppXEnabled && /\.(?:uvue|nvue)$/i.test(cleanUrl(file))
10013
+ isRuntimeAffectingSource: (file) => uniAppXEnabled && !resolveCurrentGeneratorBranch().isWeb && /\.(?:uvue|nvue)$/i.test(cleanUrl(file))
9885
10014
  });
9886
10015
  const sourceScanSession = createFrameworkSourceScanSession({
9887
10016
  cssMemory,
@@ -9989,7 +10118,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
9989
10118
  const fullRuntime = getSourceCandidates() ?? getRecordedGeneratorCandidates() ?? await ensureRuntimeClassSet();
9990
10119
  const transient = hookContext?.transient === true;
9991
10120
  const pendingHmrChange = transient ? void 0 : hmrCandidateState.resolve(generatorCode, file);
9992
- const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(pendingHmrChange !== void 0);
10121
+ const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(file, pendingHmrChange !== void 0);
9993
10122
  const runtime = hookContext?.sourceCandidates === void 0 ? fullRuntime : new Set(hookContext.sourceCandidates);
9994
10123
  const importShellCss = resolveViteServeRootMiniProgramImportShell({
9995
10124
  css: generatorTransformCode,
@@ -10009,7 +10138,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
10009
10138
  markViteProcessedCssSource(file);
10010
10139
  rememberTailwindRootCssModule(id);
10011
10140
  recordGeneratorCandidates(fullRuntime);
10012
- if (pendingHmrChange) hmrCandidateState.finishTarget(file);
10141
+ if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
10013
10142
  else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
10014
10143
  cssMemory.rememberCssSource({
10015
10144
  outputFile,
@@ -10120,7 +10249,7 @@ ${previousTracedCss}`;
10120
10249
  markViteProcessedCssSource(file);
10121
10250
  if (hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback })) rememberTailwindRootCssModule(id);
10122
10251
  recordGeneratorCandidates(fullRuntime);
10123
- if (pendingHmrChange) hmrCandidateState.finishTarget(file);
10252
+ if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
10124
10253
  else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
10125
10254
  cssMemory.rememberCssSource({
10126
10255
  outputFile,
@@ -10239,6 +10368,8 @@ ${tracedCss}`;
10239
10368
  getResolvedConfig,
10240
10369
  isEnabled: shouldEnableFrameworkExtraPlugins,
10241
10370
  isIosPlatform: extraPluginPlatform.isIosPlatform === true,
10371
+ isNativeAppStyleTarget: () => frameworkCssPipelineStrategy?.isNativeAppStyleTarget?.(createCssPipelineContext()) === true,
10372
+ isWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
10242
10373
  jsHandler,
10243
10374
  mainCssChunkMatcher,
10244
10375
  runtimeState,
@@ -10657,6 +10788,8 @@ function createUniAppXVitePlugins(options = {}) {
10657
10788
  getResolvedConfig: context.getResolvedConfig,
10658
10789
  isEnabled: context.isEnabled,
10659
10790
  isIosPlatform: context.isIosPlatform,
10791
+ isNativeAppStyleTarget: context.isNativeAppStyleTarget,
10792
+ isWebGeneratorTarget: context.isWebGeneratorTarget,
10660
10793
  jsHandler: context.jsHandler,
10661
10794
  mainCssChunkMatcher: context.mainCssChunkMatcher,
10662
10795
  runtimeState: context.runtimeState,