weapp-tailwindcss 5.2.8 → 5.2.10
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.
- package/dist/bundlers/shared/generator-css/class-selectors.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +4 -1
- package/dist/bundlers/vite/generate-bundle/types.d.ts +6 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +3 -2
- package/dist/bundlers/vite/shared/framework-hmr-runtime-signature.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +2 -0
- package/dist/bundlers/vite/utils.d.ts +2 -0
- package/dist/cli.cjs +4 -30
- package/dist/cli.js +4 -30
- package/dist/{context-CByXWyhQ.cjs → context-C3TryIjF.cjs} +8 -13
- package/dist/{context-BMkbwnH8.js → context-DbL0d-zB.js} +8 -13
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{gulp-BWhCahA2.js → gulp-CB_GZky7.js} +3 -3
- package/dist/{gulp-BdoorWb5.cjs → gulp-G6af_vyo.cjs} +4 -4
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-CJocHeZr.js → hmr-timing-CZu2ITV8.js} +8 -3
- package/dist/{hmr-timing-DiYnyg_W.cjs → hmr-timing-gbPzjYTj.cjs} +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/js/literal-transform.d.ts +1 -1
- package/dist/{pipeline-helpers-CsNLoEX1.cjs → pipeline-helpers-CtIXw85G.cjs} +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/shared/classname-transform.d.ts +2 -3
- package/dist/{source-candidate-scan-signature-D9FXTD9a.cjs → source-candidate-scan-signature-CTX7eBJX.cjs} +1 -1
- package/dist/{source-candidate-scan-signature-of-TmeOs.js → source-candidate-scan-signature-DFZlYd3t.js} +1 -1
- package/dist/{transform-DzVJW6Dp.cjs → transform-9wbmvHcC.cjs} +107 -8
- package/dist/{transform-DVGsr8cV.js → transform-BlsDWgjt.js} +107 -8
- package/dist/uni-app-x/component-local-style-binding.d.ts +6 -0
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
- package/dist/uni-app-x/vite/style-request.d.ts +12 -0
- package/dist/{v4-generation-core-BjHT6qGC.cjs → v4-generation-core-BVd_4348.cjs} +12 -1
- package/dist/{vite-V86H6PZa.cjs → vite-DjU_5LY6.cjs} +216 -59
- package/dist/{vite-BJJqWc_F.js → vite-cIvaBul_.js} +215 -58
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +2 -2
- package/dist/{webpack-CzQrloDg.cjs → webpack-B9lRT1no.cjs} +6 -6
- package/dist/{webpack-CkeFhPY2.js → webpack-CvKV7U7L.js} +4 -4
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/{wxml-IBzZSaQC.js → wxml-CWJc0yY-.js} +5 -31
- package/dist/{wxml-DSMNuUaP.cjs → wxml-DUIdXCVa.cjs} +4 -36
- package/package.json +2 -2
|
@@ -4,13 +4,13 @@ const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
|
4
4
|
const require_object = require("./object-C_Vr6_S5.cjs");
|
|
5
5
|
const require_options = require("./options-zpZez7qe.cjs");
|
|
6
6
|
require("./utils-CuKLf1Zv.cjs");
|
|
7
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
8
|
-
const require_wxml = require("./wxml-
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
10
|
-
const require_context = require("./context-
|
|
7
|
+
const require_v4_generation_core = require("./v4-generation-core-BVd_4348.cjs");
|
|
8
|
+
const require_wxml = require("./wxml-DUIdXCVa.cjs");
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-gbPzjYTj.cjs");
|
|
10
|
+
const require_context = require("./context-C3TryIjF.cjs");
|
|
11
11
|
const require_tailwindcss = require("./tailwindcss-LtnGCxF0.cjs");
|
|
12
12
|
const require_style_options = require("./style-options-COpQc8fr.cjs");
|
|
13
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
13
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-CTX7eBJX.cjs");
|
|
14
14
|
require("./logger-TlKT3xmR.cjs");
|
|
15
15
|
const require_css_imports = require("./css-imports-DfNC3e6a.cjs");
|
|
16
16
|
let node_fs = require("node:fs");
|
|
@@ -1746,6 +1746,16 @@ const htmlLangRE = /\.html?(?:$|\?)/;
|
|
|
1746
1746
|
function isCSSRequest(request) {
|
|
1747
1747
|
return cssLangRE.test(request) || require_v4_generation_core.isSourceStyleRequest(request);
|
|
1748
1748
|
}
|
|
1749
|
+
function isWeappViteSidecarRequest(request) {
|
|
1750
|
+
const queryIndex = request.indexOf("?");
|
|
1751
|
+
if (queryIndex < 0) return false;
|
|
1752
|
+
const hashIndex = request.indexOf("#", queryIndex);
|
|
1753
|
+
const query = request.slice(queryIndex + 1, hashIndex < 0 ? void 0 : hashIndex);
|
|
1754
|
+
return new URLSearchParams(query).has("weapp-vite-sidecar");
|
|
1755
|
+
}
|
|
1756
|
+
function resolveViteCssPipelineRequestFile(request) {
|
|
1757
|
+
return isWeappViteSidecarRequest(request) ? (0, _weapp_tailwindcss_shared.cleanUrl)(request) : request;
|
|
1758
|
+
}
|
|
1749
1759
|
function isHTMLRequest(request) {
|
|
1750
1760
|
return htmlLangRE.test(request);
|
|
1751
1761
|
}
|
|
@@ -5273,13 +5283,14 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
5273
5283
|
//#endregion
|
|
5274
5284
|
//#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
|
|
5275
5285
|
async function finalizeGenerateBundle(options) {
|
|
5276
|
-
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;
|
|
5286
|
+
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, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
|
|
5277
5287
|
const tasksStart = performance.now();
|
|
5278
5288
|
if (cssTaskFactories.length > 0) {
|
|
5279
5289
|
const cssTask = require_v4_generation_core.runWithConcurrency(cssTaskFactories, resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion)).then(() => void 0);
|
|
5280
5290
|
if (jsAfterCss) await cssTask;
|
|
5281
5291
|
else tasks.push(cssTask);
|
|
5282
5292
|
}
|
|
5293
|
+
prepareJsTransformRuntime?.();
|
|
5283
5294
|
if (jsTaskFactories.length > 0) tasks.push(require_v4_generation_core.runWithConcurrency(jsTaskFactories).then(() => void 0));
|
|
5284
5295
|
await Promise.all(tasks);
|
|
5285
5296
|
recordTimingDetail("tasks", tasksStart);
|
|
@@ -5319,7 +5330,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
5319
5330
|
});
|
|
5320
5331
|
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
5321
5332
|
const injectStartedAt = performance.now();
|
|
5322
|
-
|
|
5333
|
+
let injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
5323
5334
|
opts,
|
|
5324
5335
|
cssPipelineStrategy,
|
|
5325
5336
|
createCssPipelineContext,
|
|
@@ -5336,6 +5347,26 @@ async function finalizeGenerateBundle(options) {
|
|
|
5336
5347
|
onUpdate,
|
|
5337
5348
|
recordTimingDetail
|
|
5338
5349
|
});
|
|
5350
|
+
if (pendingRememberedCssReplayUpdates.length > 0) {
|
|
5351
|
+
for (const update of pendingRememberedCssReplayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
5352
|
+
injected += injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
5353
|
+
opts,
|
|
5354
|
+
cssPipelineStrategy,
|
|
5355
|
+
createCssPipelineContext,
|
|
5356
|
+
getViteProcessedCssAssetResults: () => pendingRememberedCssReplayUpdates.map((update) => [update.file, {
|
|
5357
|
+
css: update.css,
|
|
5358
|
+
injectIntoMain: update.injectIntoMain,
|
|
5359
|
+
outputFile: update.outputFile
|
|
5360
|
+
}]),
|
|
5361
|
+
markCssAssetProcessed,
|
|
5362
|
+
recordCssAssetResult,
|
|
5363
|
+
transformCss: transformWebTargetCss,
|
|
5364
|
+
debug,
|
|
5365
|
+
onUpdate,
|
|
5366
|
+
recordTimingDetail
|
|
5367
|
+
});
|
|
5368
|
+
debug("inject remembered css replay updates after framework css collection: %d", pendingRememberedCssReplayUpdates.length);
|
|
5369
|
+
}
|
|
5339
5370
|
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
5340
5371
|
return injected;
|
|
5341
5372
|
};
|
|
@@ -6143,11 +6174,22 @@ function resolveUniAppXCssTarget(id) {
|
|
|
6143
6174
|
function isCssModuleExport(code) {
|
|
6144
6175
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
6145
6176
|
}
|
|
6177
|
+
function resolvePreprocessorTransform(code, id, lang, options) {
|
|
6178
|
+
if (!isPreprocessorRequest(id, lang)) return;
|
|
6179
|
+
if (options.isIosPlatform) {
|
|
6180
|
+
const normalizedCode = (0, _weapp_tailwindcss_postcss.normalizeTailwindcssV4InfinityCalcCss)(code);
|
|
6181
|
+
return { result: normalizedCode === code ? void 0 : {
|
|
6182
|
+
code: normalizedCode,
|
|
6183
|
+
map: null
|
|
6184
|
+
} };
|
|
6185
|
+
}
|
|
6186
|
+
if (options.isWebGeneratorTarget && !options.isNativeAppStyleTarget) return { result: void 0 };
|
|
6187
|
+
}
|
|
6146
6188
|
//#endregion
|
|
6147
6189
|
//#region src/uni-app-x/vite.ts
|
|
6148
6190
|
let transformUVuePromise;
|
|
6149
6191
|
function loadTransformUVue() {
|
|
6150
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
6192
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-9wbmvHcC.cjs")).then((mod) => mod.transformUVue));
|
|
6151
6193
|
return transformUVuePromise;
|
|
6152
6194
|
}
|
|
6153
6195
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -6156,7 +6198,7 @@ function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
|
6156
6198
|
return uniAppX === void 0 ? true : require_options.isUniAppXEnabled(uniAppX);
|
|
6157
6199
|
}
|
|
6158
6200
|
function createUniAppXPlugins(options) {
|
|
6159
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6201
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6160
6202
|
const resolvedUniAppXOptions = require_options.resolveUniAppXOptions(uniAppX);
|
|
6161
6203
|
const utsPlatform = require_generator.resolveUniUtsPlatform();
|
|
6162
6204
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
@@ -6272,14 +6314,12 @@ function createUniAppXPlugins(options) {
|
|
|
6272
6314
|
if (!isEnabled()) return;
|
|
6273
6315
|
await runtimeState.readyPromise;
|
|
6274
6316
|
const { query } = parseVueRequest(id);
|
|
6275
|
-
const
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
};
|
|
6282
|
-
}
|
|
6317
|
+
const preprocessor = resolvePreprocessorTransform(code, id, query.lang, {
|
|
6318
|
+
isIosPlatform,
|
|
6319
|
+
isNativeAppStyleTarget: isNativeAppStyleTarget(),
|
|
6320
|
+
isWebGeneratorTarget: isWebGeneratorTarget()
|
|
6321
|
+
});
|
|
6322
|
+
if (preprocessor) return preprocessor.result;
|
|
6283
6323
|
return transformStyle(code, id, query, this);
|
|
6284
6324
|
}
|
|
6285
6325
|
}];
|
|
@@ -6564,10 +6604,33 @@ function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
|
|
|
6564
6604
|
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
6565
6605
|
return SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
6566
6606
|
}
|
|
6607
|
+
function resolveRememberedCssReplayOutputFile(outputFile, targetByFile) {
|
|
6608
|
+
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
6609
|
+
for (const [shellFile, targetFile] of targetByFile ?? []) if (require_source_candidate_scan_signature.normalizeOutputPathKey(shellFile) === outputKey) return targetFile;
|
|
6610
|
+
return outputFile;
|
|
6611
|
+
}
|
|
6612
|
+
function createRememberedCssReplayUpdates(css, sourceFile, outputFile, injectIntoMain) {
|
|
6613
|
+
const updates = [{
|
|
6614
|
+
css,
|
|
6615
|
+
file: sourceFile,
|
|
6616
|
+
injectIntoMain,
|
|
6617
|
+
outputFile
|
|
6618
|
+
}];
|
|
6619
|
+
if (outputFile !== sourceFile) updates.push({
|
|
6620
|
+
css,
|
|
6621
|
+
file: outputFile,
|
|
6622
|
+
injectIntoMain,
|
|
6623
|
+
outputFile
|
|
6624
|
+
});
|
|
6625
|
+
return updates;
|
|
6626
|
+
}
|
|
6567
6627
|
async function processRememberedCssReplay(options) {
|
|
6568
|
-
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;
|
|
6628
|
+
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;
|
|
6569
6629
|
const rememberedReplayGroups = collectRememberedCssReplayGroups(getRememberedCssSources?.(), opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
6570
|
-
|
|
6630
|
+
const normalizedBundleFiles = new Set(bundleFiles.map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
6631
|
+
for (const [rememberedOutputFile, rememberedGroup] of rememberedReplayGroups) {
|
|
6632
|
+
const outputFile = resolveRememberedCssReplayOutputFile(rememberedOutputFile, frameworkRootImportShellTargetByFile);
|
|
6633
|
+
if (outputFile !== rememberedOutputFile) debug("css replay use framework root import shell target: %s -> %s", rememberedOutputFile, outputFile);
|
|
6571
6634
|
if (isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
|
|
6572
6635
|
const replayableRememberedGroup = rememberedGroup.filter(({ remembered }) => {
|
|
6573
6636
|
const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
|
|
@@ -6581,7 +6644,7 @@ async function processRememberedCssReplay(options) {
|
|
|
6581
6644
|
const generatorRawSource = isWebGeneratorTarget ? rawSource : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
|
|
6582
6645
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
6583
6646
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
6584
|
-
const outputCssHandlerOptions = getCssHandlerOptions(
|
|
6647
|
+
const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
|
|
6585
6648
|
const cssHandlerOptions = {
|
|
6586
6649
|
...getCssHandlerOptions(sourceFile),
|
|
6587
6650
|
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
@@ -6600,7 +6663,19 @@ async function processRememberedCssReplay(options) {
|
|
|
6600
6663
|
const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
|
|
6601
6664
|
const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
|
|
6602
6665
|
const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
|
|
6603
|
-
if (bundleFiles.includes(
|
|
6666
|
+
if (bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
|
|
6667
|
+
const shouldMergeReplayIntoFrameworkRootTarget = outputFile !== rememberedOutputFile && normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile));
|
|
6668
|
+
if (allRememberedSignaturesFresh) if (!shouldMergeReplayIntoFrameworkRootTarget) continue;
|
|
6669
|
+
else {
|
|
6670
|
+
const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
|
|
6671
|
+
if (cachedCss != null) {
|
|
6672
|
+
pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
|
|
6673
|
+
metrics.css.cacheHits++;
|
|
6674
|
+
debug("css replay cached result into framework root target: %s", outputFile);
|
|
6675
|
+
continue;
|
|
6676
|
+
}
|
|
6677
|
+
debug("css replay framework root target cache miss, regenerate: %s", outputFile);
|
|
6678
|
+
}
|
|
6604
6679
|
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await require_source_candidate_scan_signature.createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
6605
6680
|
const sourceTraceTokenSources = sourceTraceSources ? require_v4_generation_core.createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
6606
6681
|
const annotateCss = (css) => require_v4_generation_core.annotateCssSourceTrace(css, {
|
|
@@ -6608,7 +6683,7 @@ async function processRememberedCssReplay(options) {
|
|
|
6608
6683
|
tokenSources: sourceTraceTokenSources
|
|
6609
6684
|
});
|
|
6610
6685
|
const shouldRecordRememberedReplayCss = useIncrementalMode || isNativeAppStyleTarget;
|
|
6611
|
-
const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss;
|
|
6686
|
+
const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss && !shouldMergeReplayIntoFrameworkRootTarget;
|
|
6612
6687
|
if (!shouldRecordRememberedReplayCss) continue;
|
|
6613
6688
|
const shouldPreserveLocalImportWrapper = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
6614
6689
|
css: rawSource,
|
|
@@ -6676,14 +6751,10 @@ async function processRememberedCssReplay(options) {
|
|
|
6676
6751
|
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
6677
6752
|
recordCssAssetResult?.(outputFile, css);
|
|
6678
6753
|
const shouldInjectReplayCssIntoMain = shouldInjectCssIntoMainFromOutput(outputFile, sourceFile, outputCssHandlerOptions);
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
if (outputFile !== sourceFile) recordViteProcessedCssAssetResult?.(outputFile, css, {
|
|
6684
|
-
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain,
|
|
6685
|
-
outputFile
|
|
6686
|
-
});
|
|
6754
|
+
const injectIntoMain = shouldMergeReplayIntoFrameworkRootTarget ? true : outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain;
|
|
6755
|
+
const replayUpdates = createRememberedCssReplayUpdates(css, sourceFile, outputFile, injectIntoMain);
|
|
6756
|
+
if (shouldMergeReplayIntoFrameworkRootTarget) pendingRememberedCssReplayUpdates.push(...replayUpdates);
|
|
6757
|
+
else for (const update of replayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
6687
6758
|
debug("css replay generated result: %s bytes=%d", outputFile, css.length);
|
|
6688
6759
|
}
|
|
6689
6760
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
@@ -7451,7 +7522,8 @@ function createGenerateBundleHook$1(context) {
|
|
|
7451
7522
|
const collectedGeneratorCandidates = /* @__PURE__ */ new Set([...runtime, ...sourceCandidates]);
|
|
7452
7523
|
const filteredGeneratorCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_generator.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
7453
7524
|
const filteredSourceCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_generator.filterUnsupportedMiniProgramTailwindV4Candidates(sourceCandidates) : sourceCandidates;
|
|
7454
|
-
const
|
|
7525
|
+
const shouldTransformJsBundle = !isWebGeneratorTarget || context.cssPipelineStrategy?.shouldTransformServeJs?.(cssPipelineContext) === true;
|
|
7526
|
+
const transformRuntime = isWebGeneratorTarget ? /* @__PURE__ */ new Set() : shouldFilterTailwindV4MiniProgramCandidates ? new Set(runtime) : new Set(filteredGeneratorCandidates);
|
|
7455
7527
|
const generatorRuntime = filteredGeneratorCandidates;
|
|
7456
7528
|
await validateRuntimeCandidates({
|
|
7457
7529
|
cssEntries: snapshot.entries.filter((entry) => entry.type === "css" && entry.output.type === "asset"),
|
|
@@ -7540,7 +7612,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7540
7612
|
if (forceRuntimeRefreshBySource) debug("runtimeSet forced refresh due to source changes: html=%d js=%d", snapshot.runtimeAffectingChangedByType.html.size, snapshot.runtimeAffectingChangedByType.js.size);
|
|
7541
7613
|
debug("get runtimeSet, class count: %d, transform class count: %d", runtime.size, transformRuntime.size);
|
|
7542
7614
|
const runtimeSignature = require_tailwindcss.getRuntimeClassSetSignature(runtimeState.tailwindRuntime) ?? "runtime:missing";
|
|
7543
|
-
const transformRuntimeSignature = require_source_candidate_scan_signature.createCandidateSignature(transformRuntime);
|
|
7615
|
+
const transformRuntimeSignature = isWebGeneratorTarget ? generatorCandidateSignature : require_source_candidate_scan_signature.createCandidateSignature(transformRuntime);
|
|
7544
7616
|
const shouldProcessTailwindGeneration = !useIncrementalMode || hasRuntimeAffectingChanges || generatorCandidatesChanged || snapshot.processFiles.css.size > 0;
|
|
7545
7617
|
const { applyLinkedUpdates, pendingLinkedUpdates } = createLinkedUpdateHelpers({
|
|
7546
7618
|
jsEntries,
|
|
@@ -7563,7 +7635,6 @@ function createGenerateBundleHook$1(context) {
|
|
|
7563
7635
|
...extra
|
|
7564
7636
|
} : void 0);
|
|
7565
7637
|
};
|
|
7566
|
-
const shouldTransformJsBundle = !isWebGeneratorTarget || context.cssPipelineStrategy?.shouldTransformServeJs?.(cssPipelineContext) === true;
|
|
7567
7638
|
const linkedByEntry = useIncrementalMode ? /* @__PURE__ */ new Map() : void 0;
|
|
7568
7639
|
const sharedCssResultCache = /* @__PURE__ */ new Map();
|
|
7569
7640
|
const activeProcessCacheKeys = /* @__PURE__ */ new Set();
|
|
@@ -7575,6 +7646,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7575
7646
|
const tasks = [];
|
|
7576
7647
|
const cssTaskFactories = [];
|
|
7577
7648
|
const jsTaskFactories = [];
|
|
7649
|
+
const pendingRememberedCssReplayUpdates = [];
|
|
7578
7650
|
const entryPlanningStartedAt = performance.now();
|
|
7579
7651
|
for (const entry of snapshot.entries) {
|
|
7580
7652
|
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
@@ -7800,6 +7872,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7800
7872
|
debug,
|
|
7801
7873
|
defaultStyleOutputExtension,
|
|
7802
7874
|
emitOrReplayCssAsset,
|
|
7875
|
+
frameworkRootImportShellTargetByFile,
|
|
7803
7876
|
generatorPlatform,
|
|
7804
7877
|
generatorRuntime,
|
|
7805
7878
|
getCssHandlerOptions,
|
|
@@ -7816,6 +7889,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7816
7889
|
normalizeViteCssCacheKey,
|
|
7817
7890
|
onUpdate,
|
|
7818
7891
|
opts,
|
|
7892
|
+
pendingRememberedCssReplayUpdates,
|
|
7819
7893
|
recordCssAssetResult,
|
|
7820
7894
|
recordViteProcessedCssAssetResult,
|
|
7821
7895
|
rootDir,
|
|
@@ -7829,6 +7903,17 @@ function createGenerateBundleHook$1(context) {
|
|
|
7829
7903
|
useIncrementalMode
|
|
7830
7904
|
});
|
|
7831
7905
|
recordTimingDetail("rememberedCss.plan", rememberedCssStartedAt);
|
|
7906
|
+
const prepareJsTransformRuntime = isWebGeneratorTarget && shouldTransformJsBundle ? () => {
|
|
7907
|
+
transformRuntime.clear();
|
|
7908
|
+
const cssSources = /* @__PURE__ */ new Set();
|
|
7909
|
+
for (const output of Object.values(bundle)) {
|
|
7910
|
+
if (output.type !== "asset" || !opts.cssMatcher(output.fileName)) continue;
|
|
7911
|
+
cssSources.add(typeof output.source === "string" ? output.source : node_buffer.Buffer.from(output.source).toString());
|
|
7912
|
+
}
|
|
7913
|
+
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) cssSources.add(typeof record === "string" ? record : record.css);
|
|
7914
|
+
for (const candidate of require_v4_generation_core.collectGeneratedRawSourceCandidatesFromCss(generatorRuntime, cssSources, opts.escapeMap)) transformRuntime.add(candidate);
|
|
7915
|
+
debug("rebuild webview JS transform class set from generated CSS: %d", transformRuntime.size);
|
|
7916
|
+
} : void 0;
|
|
7832
7917
|
await finalizeGenerateBundle({
|
|
7833
7918
|
activeProcessCacheKeys,
|
|
7834
7919
|
activeProcessHashKeys,
|
|
@@ -7855,7 +7940,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7855
7940
|
isNativeAppStyleTarget,
|
|
7856
7941
|
isViteProcessedCssAsset,
|
|
7857
7942
|
isWebGeneratorTarget,
|
|
7858
|
-
jsAfterCss: shouldFilterTailwindV4MiniProgramCandidates && cssTaskFactories.length > 0,
|
|
7943
|
+
jsAfterCss: (shouldFilterTailwindV4MiniProgramCandidates || isWebGeneratorTarget && shouldTransformJsBundle) && cssTaskFactories.length > 0,
|
|
7859
7944
|
jsTaskFactories,
|
|
7860
7945
|
lastCssResultByFile,
|
|
7861
7946
|
lastCssSourceHashByFile,
|
|
@@ -7867,6 +7952,8 @@ function createGenerateBundleHook$1(context) {
|
|
|
7867
7952
|
opts,
|
|
7868
7953
|
outDir,
|
|
7869
7954
|
pendingLinkedUpdates,
|
|
7955
|
+
pendingRememberedCssReplayUpdates,
|
|
7956
|
+
prepareJsTransformRuntime,
|
|
7870
7957
|
pruneViteCssCaches,
|
|
7871
7958
|
recordCssAssetResult,
|
|
7872
7959
|
recordTimingDetail,
|
|
@@ -8355,6 +8442,7 @@ function normalizeKnownSfcSourceKey(file) {
|
|
|
8355
8442
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file)));
|
|
8356
8443
|
}
|
|
8357
8444
|
function shouldCollectTransformedSourceCandidates(id) {
|
|
8445
|
+
if (isWeappViteSidecarRequest(id)) return false;
|
|
8358
8446
|
if (id.search(/[?#]/) < 0) return true;
|
|
8359
8447
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
8360
8448
|
return !SFC_COMPONENT_FILE_RE.test(file);
|
|
@@ -8931,24 +9019,27 @@ function wrapViteCssPostTransform(config, transformCss) {
|
|
|
8931
9019
|
}
|
|
8932
9020
|
//#endregion
|
|
8933
9021
|
//#region src/bundlers/vite/shared/framework-hmr-candidate-state.ts
|
|
8934
|
-
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
8935
9022
|
function createViteHmrCandidateState(options) {
|
|
8936
9023
|
let pendingChange;
|
|
8937
9024
|
let pendingCssTargetFiles;
|
|
9025
|
+
let pendingTargetsArmed = false;
|
|
8938
9026
|
let pendingFullRegeneration = false;
|
|
8939
9027
|
const normalizeCssTargetFile = (file) => normalizeVitePersistentCacheKey((0, _weapp_tailwindcss_shared.cleanUrl)(file));
|
|
8940
9028
|
const clear = () => {
|
|
8941
9029
|
pendingChange = void 0;
|
|
8942
9030
|
pendingCssTargetFiles = void 0;
|
|
9031
|
+
pendingTargetsArmed = false;
|
|
8943
9032
|
pendingFullRegeneration = false;
|
|
8944
9033
|
};
|
|
8945
9034
|
const queueFullRegeneration = () => {
|
|
8946
9035
|
pendingChange = void 0;
|
|
8947
9036
|
pendingCssTargetFiles = void 0;
|
|
9037
|
+
pendingTargetsArmed = false;
|
|
8948
9038
|
pendingFullRegeneration = true;
|
|
8949
9039
|
};
|
|
8950
9040
|
const queueChange = (change) => {
|
|
8951
9041
|
var _pendingChange;
|
|
9042
|
+
if (pendingFullRegeneration) return;
|
|
8952
9043
|
pendingFullRegeneration = false;
|
|
8953
9044
|
if (!pendingChange) {
|
|
8954
9045
|
pendingChange = {
|
|
@@ -8970,7 +9061,7 @@ function createViteHmrCandidateState(options) {
|
|
|
8970
9061
|
const createChange = (file, change, changeOptions = {}) => ({
|
|
8971
9062
|
...change,
|
|
8972
9063
|
file,
|
|
8973
|
-
runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || require_v4_generation_core.isSourceStyleRequest(file)
|
|
9064
|
+
runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || require_v4_generation_core.isSourceStyleRequest(file)
|
|
8974
9065
|
});
|
|
8975
9066
|
const apply = (change) => {
|
|
8976
9067
|
if (require_v4_generation_core.isSourceStyleRequest(change.file)) {
|
|
@@ -8984,7 +9075,7 @@ function createViteHmrCandidateState(options) {
|
|
|
8984
9075
|
const preserveDeletedCss = options.getGeneratorOptions().hmr.preserveDeletedCss;
|
|
8985
9076
|
if (preserveDeletedCss) {
|
|
8986
9077
|
if (change.addedCandidates.size > 0) queueChange(change);
|
|
8987
|
-
else if (!pendingChange) clear();
|
|
9078
|
+
else if (!pendingChange && !pendingFullRegeneration) clear();
|
|
8988
9079
|
return change;
|
|
8989
9080
|
}
|
|
8990
9081
|
clear();
|
|
@@ -8993,28 +9084,26 @@ function createViteHmrCandidateState(options) {
|
|
|
8993
9084
|
};
|
|
8994
9085
|
const resolve = (generatorCode, file) => {
|
|
8995
9086
|
const fileKey = normalizeCssTargetFile(file);
|
|
8996
|
-
if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && require_generator.hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) ||
|
|
9087
|
+
if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && require_generator.hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) || pendingTargetsArmed && !pendingCssTargetFiles?.has(fileKey)) return;
|
|
8997
9088
|
return pendingChange;
|
|
8998
9089
|
};
|
|
8999
9090
|
const finishTarget = (file) => {
|
|
9000
|
-
if (!pendingChange) return;
|
|
9001
|
-
if (!pendingCssTargetFiles)
|
|
9002
|
-
clear();
|
|
9003
|
-
return;
|
|
9004
|
-
}
|
|
9091
|
+
if (!pendingChange && !pendingFullRegeneration) return;
|
|
9092
|
+
if (!pendingTargetsArmed || !pendingCssTargetFiles) return;
|
|
9005
9093
|
pendingCssTargetFiles.delete(normalizeCssTargetFile(file));
|
|
9006
9094
|
if (pendingCssTargetFiles.size === 0) clear();
|
|
9007
9095
|
};
|
|
9008
9096
|
const armTargets = (cssModules, fallbackCssIds) => {
|
|
9009
|
-
if (!pendingChange) {
|
|
9097
|
+
if (!pendingChange && !pendingFullRegeneration) {
|
|
9010
9098
|
pendingCssTargetFiles = void 0;
|
|
9099
|
+
pendingTargetsArmed = false;
|
|
9011
9100
|
return;
|
|
9012
9101
|
}
|
|
9013
9102
|
const targets = /* @__PURE__ */ new Set();
|
|
9014
9103
|
const addTarget = (file) => {
|
|
9015
9104
|
if (!file) return;
|
|
9016
9105
|
const key = normalizeCssTargetFile(file);
|
|
9017
|
-
if (options.cleanGeneratedCssByFile.has(key)) targets.add(key);
|
|
9106
|
+
if (pendingFullRegeneration || options.cleanGeneratedCssByFile.has(key)) targets.add(key);
|
|
9018
9107
|
};
|
|
9019
9108
|
for (const module of cssModules) {
|
|
9020
9109
|
addTarget(module.id);
|
|
@@ -9022,7 +9111,28 @@ function createViteHmrCandidateState(options) {
|
|
|
9022
9111
|
addTarget(module.url);
|
|
9023
9112
|
}
|
|
9024
9113
|
for (const id of fallbackCssIds) addTarget(id);
|
|
9025
|
-
pendingCssTargetFiles = targets
|
|
9114
|
+
pendingCssTargetFiles = targets;
|
|
9115
|
+
pendingTargetsArmed = true;
|
|
9116
|
+
};
|
|
9117
|
+
const reconcileRuntimeCandidates = (file, candidates, rootCssIds) => {
|
|
9118
|
+
if (options.getCommand() !== "serve" || pendingFullRegeneration) return;
|
|
9119
|
+
const generatedClassSets = [];
|
|
9120
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
9121
|
+
for (const id of rootCssIds) {
|
|
9122
|
+
const fileKey = normalizeCssTargetFile(id);
|
|
9123
|
+
if (seenFiles.has(fileKey)) continue;
|
|
9124
|
+
seenFiles.add(fileKey);
|
|
9125
|
+
const classSet = options.generatedClassSetByFile.get(fileKey);
|
|
9126
|
+
if (classSet) generatedClassSets.push(classSet);
|
|
9127
|
+
}
|
|
9128
|
+
if (generatedClassSets.length === 0) return;
|
|
9129
|
+
const addedCandidates = /* @__PURE__ */ new Set();
|
|
9130
|
+
for (const candidate of candidates) if (generatedClassSets.some((classSet) => !classSet.has(candidate))) addedCandidates.add(candidate);
|
|
9131
|
+
if (addedCandidates.size === 0) return;
|
|
9132
|
+
apply(createChange(file, {
|
|
9133
|
+
addedCandidates,
|
|
9134
|
+
removedCandidates: /* @__PURE__ */ new Set()
|
|
9135
|
+
}));
|
|
9026
9136
|
};
|
|
9027
9137
|
return {
|
|
9028
9138
|
apply,
|
|
@@ -9031,13 +9141,19 @@ function createViteHmrCandidateState(options) {
|
|
|
9031
9141
|
createChange,
|
|
9032
9142
|
finishTarget,
|
|
9033
9143
|
hasPendingCandidateAppend: () => pendingChange != null && !pendingChange.runtimeAffecting && pendingChange.addedCandidates.size > 0,
|
|
9034
|
-
hasPendingChange: () => pendingChange != null,
|
|
9144
|
+
hasPendingChange: () => pendingChange != null || pendingFullRegeneration,
|
|
9035
9145
|
queueFullRegeneration,
|
|
9146
|
+
reconcileRuntimeCandidates,
|
|
9036
9147
|
resolve,
|
|
9037
|
-
shouldForceFullRegeneration: (resolved) =>
|
|
9148
|
+
shouldForceFullRegeneration: (file, resolved) => {
|
|
9149
|
+
if (options.getCommand() !== "serve") return false;
|
|
9150
|
+
if (pendingFullRegeneration) return pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
|
|
9151
|
+
return pendingChange != null && !resolved && pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
|
|
9152
|
+
},
|
|
9038
9153
|
snapshotDebugState: () => ({
|
|
9039
9154
|
pendingAddedCandidates: pendingChange?.addedCandidates.size ?? 0,
|
|
9040
|
-
pendingCssTargets: pendingCssTargetFiles?.size ?? 0
|
|
9155
|
+
pendingCssTargets: pendingCssTargetFiles?.size ?? 0,
|
|
9156
|
+
pendingFullRegeneration
|
|
9041
9157
|
})
|
|
9042
9158
|
};
|
|
9043
9159
|
}
|
|
@@ -9267,7 +9383,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9267
9383
|
let transformedCode = code;
|
|
9268
9384
|
if (options.shouldOwnTailwindGeneration && !options.resolveCurrentGeneratorBranch().isWeb && isCSSRequest(id)) transformedCode = options.transformEarlyMiniProgramCss(code);
|
|
9269
9385
|
const shouldReturnTransformedCode = transformedCode !== code;
|
|
9270
|
-
if (options.shouldOwnTailwindGeneration) {
|
|
9386
|
+
if (options.shouldOwnTailwindGeneration && shouldCollectTransformedSourceCandidates(id)) {
|
|
9271
9387
|
options.cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
9272
9388
|
if (isCSSRequest(id) && require_generator.hasTailwindRootDirectives(transformedCode, { importFallback: options.resolveCurrentGeneratorOptions().importFallback })) options.rememberTailwindRootCssModule(id);
|
|
9273
9389
|
}
|
|
@@ -9331,6 +9447,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9331
9447
|
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
9332
9448
|
}
|
|
9333
9449
|
const sourceCandidateChange = await options.sourceScanSession.syncChangedFile(ctx.file, hotSource);
|
|
9450
|
+
options.sourceScanSession.consumeHotUpdateChange(ctx.file);
|
|
9334
9451
|
const isWebLikeHotUpdate = options.isCurrentWebLikeStylePlatform();
|
|
9335
9452
|
let canUseHmrCandidateAppend = false;
|
|
9336
9453
|
if (isSourceCandidateHotUpdate) {
|
|
@@ -9349,6 +9466,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9349
9466
|
}
|
|
9350
9467
|
}
|
|
9351
9468
|
if (isSourceCandidateHotUpdate) await options.sourceScanSession.waitForPendingSyncs();
|
|
9469
|
+
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) options.hmrCandidateState.reconcileRuntimeCandidates(ctx.file, options.sourceCandidateCollector.values(), options.tailwindRootCssModuleIds);
|
|
9352
9470
|
const cssModules = await resolveHotTailwindCssModules(ctx, require_v4_generation_core.isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds);
|
|
9353
9471
|
const hotRoot = ctx.server.config?.root ?? node_process.default.cwd();
|
|
9354
9472
|
const sourceModules = isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
@@ -9367,7 +9485,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9367
9485
|
}
|
|
9368
9486
|
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
|
|
9369
9487
|
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles]);
|
|
9370
|
-
if (
|
|
9488
|
+
if (options.hmrCandidateState.hasPendingChange()) options.hmrCandidateState.armTargets(cssModules, supplementalCssFallbackIds);
|
|
9371
9489
|
if (shouldSendSupplementalCssHotUpdates) sendSupplementalCssHotUpdates(ctx, cssModules, supplementalCssFallbackIds);
|
|
9372
9490
|
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules) : hasDifferentHotModules(sourceModules, ctx.modules) ? sourceModules : void 0;
|
|
9373
9491
|
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && cssModules.length > 0) return mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules);
|
|
@@ -9382,6 +9500,16 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9382
9500
|
};
|
|
9383
9501
|
}
|
|
9384
9502
|
//#endregion
|
|
9503
|
+
//#region src/bundlers/vite/shared/framework-hmr-runtime-signature.ts
|
|
9504
|
+
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
9505
|
+
function createFrameworkHmrRuntimeSignature(file, source) {
|
|
9506
|
+
if (!source || !WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(source)) return "";
|
|
9507
|
+
return (isSfcStyleSourceFile((0, _weapp_tailwindcss_shared.cleanUrl)(file)) ? extractSfcStyleSources(source).filter((styleSource) => WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(styleSource)) : [source]).map((styleSource) => require_v4_generation_core.createRuntimeAffectingSourceSignature(styleSource, "css")).join("\0");
|
|
9508
|
+
}
|
|
9509
|
+
function hasFrameworkHmrRuntimeSourceChange(file, previousSource, nextSource) {
|
|
9510
|
+
return createFrameworkHmrRuntimeSignature(file, previousSource) !== createFrameworkHmrRuntimeSignature(file, nextSource);
|
|
9511
|
+
}
|
|
9512
|
+
//#endregion
|
|
9385
9513
|
//#region src/bundlers/vite/shared/framework-source-scan-session.ts
|
|
9386
9514
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
9387
9515
|
const sourceCandidateScanSnapshotCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
@@ -9400,6 +9528,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9400
9528
|
let sourceCandidateScanInvalidated = true;
|
|
9401
9529
|
const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
|
|
9402
9530
|
const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
|
|
9531
|
+
const pendingHotUpdateChangeByFile = /* @__PURE__ */ new Map();
|
|
9403
9532
|
const normalizeDependency = (file) => node_path.default.normalize(node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file)));
|
|
9404
9533
|
const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
|
|
9405
9534
|
const invalidate = () => {
|
|
@@ -9501,6 +9630,26 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9501
9630
|
const waitForPendingSyncs = async () => {
|
|
9502
9631
|
while (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
|
|
9503
9632
|
};
|
|
9633
|
+
const rememberHotUpdateChange = (change) => {
|
|
9634
|
+
if (!change) return;
|
|
9635
|
+
const previous = pendingHotUpdateChangeByFile.get(change.file);
|
|
9636
|
+
if (!previous) {
|
|
9637
|
+
const remembered = {
|
|
9638
|
+
...change,
|
|
9639
|
+
addedCandidates: new Set(change.addedCandidates),
|
|
9640
|
+
removedCandidates: new Set(change.removedCandidates)
|
|
9641
|
+
};
|
|
9642
|
+
pendingHotUpdateChangeByFile.set(change.file, remembered);
|
|
9643
|
+
return remembered;
|
|
9644
|
+
}
|
|
9645
|
+
for (const candidate of change.addedCandidates) {
|
|
9646
|
+
previous.addedCandidates.add(candidate);
|
|
9647
|
+
previous.removedCandidates.delete(candidate);
|
|
9648
|
+
}
|
|
9649
|
+
for (const candidate of change.removedCandidates) if (!previous.addedCandidates.delete(candidate)) previous.removedCandidates.add(candidate);
|
|
9650
|
+
previous.runtimeAffecting || (previous.runtimeAffecting = change.runtimeAffecting);
|
|
9651
|
+
return previous;
|
|
9652
|
+
};
|
|
9504
9653
|
const syncChangedFile = (id, sourceOverride) => {
|
|
9505
9654
|
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return Promise.resolve(void 0);
|
|
9506
9655
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
@@ -9511,15 +9660,18 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9511
9660
|
cacheCurrent();
|
|
9512
9661
|
return (require_v4_generation_core.isSourceStyleRequest(file) ? (0, node_fs_promises.readFile)(file, "utf8").then((source) => options.cssMemory.refreshRememberedCssSourceBySourceFile(file, source)).catch((error) => {
|
|
9513
9662
|
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);
|
|
9514
|
-
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true })));
|
|
9663
|
+
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => rememberHotUpdateChange(options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true }))));
|
|
9515
9664
|
}
|
|
9516
9665
|
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
9517
9666
|
if (existingTask) return existingTask.then(() => syncChangedFile(id, sourceOverride));
|
|
9667
|
+
const previousSource = options.sourceCandidateCollector.source(file);
|
|
9518
9668
|
const task = (sourceOverride === void 0 ? options.sourceCandidateCollector.syncCurrentFile(id) : options.sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
|
|
9519
9669
|
options.debug("source candidate watch sync failed: %s %O", id, error);
|
|
9520
9670
|
}).then((change) => {
|
|
9521
9671
|
cacheCurrent();
|
|
9522
|
-
|
|
9672
|
+
const runtimeAffectingBySource = hasFrameworkHmrRuntimeSourceChange(file, previousSource, options.sourceCandidateCollector.source(file));
|
|
9673
|
+
const appliedChange = change ? options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency || runtimeAffectingBySource })) : void 0;
|
|
9674
|
+
return rememberHotUpdateChange(appliedChange) ?? pendingHotUpdateChangeByFile.get(file);
|
|
9523
9675
|
}).finally(() => {
|
|
9524
9676
|
pendingSourceCandidateSyncs.delete(task);
|
|
9525
9677
|
pendingSourceCandidateSyncByFile.delete(file);
|
|
@@ -9533,9 +9685,11 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9533
9685
|
};
|
|
9534
9686
|
return {
|
|
9535
9687
|
cacheCurrent,
|
|
9688
|
+
consumeHotUpdateChange: (id) => pendingHotUpdateChangeByFile.delete((0, _weapp_tailwindcss_shared.cleanUrl)(id)),
|
|
9536
9689
|
getStats: () => ({
|
|
9537
9690
|
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size,
|
|
9538
9691
|
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
9692
|
+
pendingHotUpdateChangeByFile: pendingHotUpdateChangeByFile.size,
|
|
9539
9693
|
sourceCandidateScanCache: sourceCandidateScanCache.size
|
|
9540
9694
|
}),
|
|
9541
9695
|
invalidate,
|
|
@@ -9861,8 +10015,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9861
10015
|
generatedClassSetByFile,
|
|
9862
10016
|
getCommand: () => resolvedConfig?.command,
|
|
9863
10017
|
getGeneratorOptions: resolveCurrentGeneratorOptions,
|
|
9864
|
-
|
|
9865
|
-
isRuntimeAffectingSource: (file) => uniAppXEnabled && /\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(file))
|
|
10018
|
+
isRuntimeAffectingSource: (file) => uniAppXEnabled && !resolveCurrentGeneratorBranch().isWeb && /\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(file))
|
|
9866
10019
|
});
|
|
9867
10020
|
const sourceScanSession = createFrameworkSourceScanSession({
|
|
9868
10021
|
cssMemory,
|
|
@@ -9952,7 +10105,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9952
10105
|
await sourceScanSession.waitForPendingSyncs();
|
|
9953
10106
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
9954
10107
|
const inferredSfcStyleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : file;
|
|
9955
|
-
const requestFile = isCSSRequest(id) ? inferredSfcStyleRequest === file ? id : inferredSfcStyleRequest : inferredSfcStyleRequest;
|
|
10108
|
+
const requestFile = isCSSRequest(id) ? inferredSfcStyleRequest === file ? resolveViteCssPipelineRequestFile(id) : inferredSfcStyleRequest : inferredSfcStyleRequest;
|
|
9956
10109
|
if (!isCSSRequest(requestFile) || opts.htmlMatcher(file) || isHTMLRequest(file)) return;
|
|
9957
10110
|
const generatorCode = require_generator.normalizeEmptyTailwindCustomVariants(code);
|
|
9958
10111
|
const rootDir = resolvedConfig?.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
|
|
@@ -9970,7 +10123,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9970
10123
|
const fullRuntime = getSourceCandidates() ?? getRecordedGeneratorCandidates() ?? await ensureRuntimeClassSet();
|
|
9971
10124
|
const transient = hookContext?.transient === true;
|
|
9972
10125
|
const pendingHmrChange = transient ? void 0 : hmrCandidateState.resolve(generatorCode, file);
|
|
9973
|
-
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(pendingHmrChange !== void 0);
|
|
10126
|
+
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(file, pendingHmrChange !== void 0);
|
|
9974
10127
|
const runtime = hookContext?.sourceCandidates === void 0 ? fullRuntime : new Set(hookContext.sourceCandidates);
|
|
9975
10128
|
const importShellCss = resolveViteServeRootMiniProgramImportShell({
|
|
9976
10129
|
css: generatorTransformCode,
|
|
@@ -9990,7 +10143,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9990
10143
|
markViteProcessedCssSource(file);
|
|
9991
10144
|
rememberTailwindRootCssModule(id);
|
|
9992
10145
|
recordGeneratorCandidates(fullRuntime);
|
|
9993
|
-
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
10146
|
+
if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
|
|
9994
10147
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
9995
10148
|
cssMemory.rememberCssSource({
|
|
9996
10149
|
outputFile,
|
|
@@ -10101,7 +10254,7 @@ ${previousTracedCss}`;
|
|
|
10101
10254
|
markViteProcessedCssSource(file);
|
|
10102
10255
|
if (require_generator.hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback })) rememberTailwindRootCssModule(id);
|
|
10103
10256
|
recordGeneratorCandidates(fullRuntime);
|
|
10104
|
-
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
10257
|
+
if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
|
|
10105
10258
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
10106
10259
|
cssMemory.rememberCssSource({
|
|
10107
10260
|
outputFile,
|
|
@@ -10220,6 +10373,8 @@ ${tracedCss}`;
|
|
|
10220
10373
|
getResolvedConfig,
|
|
10221
10374
|
isEnabled: shouldEnableFrameworkExtraPlugins,
|
|
10222
10375
|
isIosPlatform: extraPluginPlatform.isIosPlatform === true,
|
|
10376
|
+
isNativeAppStyleTarget: () => frameworkCssPipelineStrategy?.isNativeAppStyleTarget?.(createCssPipelineContext()) === true,
|
|
10377
|
+
isWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
10223
10378
|
jsHandler,
|
|
10224
10379
|
mainCssChunkMatcher,
|
|
10225
10380
|
runtimeState,
|
|
@@ -10638,6 +10793,8 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10638
10793
|
getResolvedConfig: context.getResolvedConfig,
|
|
10639
10794
|
isEnabled: context.isEnabled,
|
|
10640
10795
|
isIosPlatform: context.isIosPlatform,
|
|
10796
|
+
isNativeAppStyleTarget: context.isNativeAppStyleTarget,
|
|
10797
|
+
isWebGeneratorTarget: context.isWebGeneratorTarget,
|
|
10641
10798
|
jsHandler: context.jsHandler,
|
|
10642
10799
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10643
10800
|
runtimeState: context.runtimeState,
|