weapp-tailwindcss 5.5.8 → 5.5.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/vite/css-calc-stage.d.ts +8 -0
- package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/css-scope-graph.d.ts +5 -0
- package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +1 -1
- package/dist/bundlers/vite/css-finalizer/options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-cache-task.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-transform-result.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +3 -3
- package/dist/bundlers/vite/generate-bundle/scoped-generator-runtime-cache.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator-sources.d.ts +36 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +6 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/source-trace.d.ts +2 -0
- package/dist/bundlers/vite/runtime-class-set/cache.d.ts +14 -0
- package/dist/bundlers/vite/runtime-class-set/invalidation-plugin.d.ts +6 -0
- package/dist/bundlers/vite/runtime-class-set/lifecycle.d.ts +12 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +1 -2
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +1 -0
- package/dist/{compiler-DbwS3329.cjs → compiler-TvqqdOMD.cjs} +50 -38
- package/dist/{compiler-CThodfGH.js → compiler-v9sYta8W.js} +35 -30
- package/dist/core/compiler/generation-cache.d.ts +4 -2
- package/dist/core/compiler/root-store.d.ts +1 -1
- package/dist/core/compiler/source.d.ts +7 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{scoped-generator-DlQrVbuC.js → css-cleanup-B3xP5Qph.js} +26 -23
- package/dist/{generated-css-marker-B0RyziOH.cjs → generated-css-marker-nqjR6ntO.cjs} +102 -26
- package/dist/generation/pipeline/style-context.d.ts +3 -0
- package/dist/{generator-CxauQbx3.cjs → generator-B1sYQpWu.cjs} +165 -90
- package/dist/{generator-oKZ5mCJ5.js → generator-LqofzXgr.js} +155 -92
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-DhddVxGA.js → gulp-BCV0gOMb.js} +4 -4
- package/dist/{gulp-CngHA9cU.cjs → gulp-DrX6QS3N.cjs} +5 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-Dc4c1VRg.cjs → hmr-timing-B56wp7y-.cjs} +4 -4
- package/dist/{hmr-timing-xPpat-km.js → hmr-timing-Bb54exB0.js} +102 -26
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-EUud9R2K.cjs → pipeline-helpers-DJ3VZ01J.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/project-sources/candidates/view-memo.d.ts +7 -0
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{scoped-generator-lbTwL6mD.cjs → scoped-generator-DqNb8nJG.cjs} +31 -24
- package/dist/{source-candidate-scan-signature-BjVQYL-C.js → source-candidate-scan-signature-BWLf4tuO.js} +2 -2
- package/dist/{source-candidate-scan-signature-nG-rg809.cjs → source-candidate-scan-signature-_ohG0ePd.cjs} +2 -2
- package/dist/tailwindcss/v4/rpx-theme-warning.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/raw-generation.d.ts +30 -0
- package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +3 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +2 -0
- package/dist/{tailwindcss-kSd0ykiX.js → tailwindcss-XNfJSlhp.js} +2 -2
- package/dist/{tailwindcss-U3KIUegn.cjs → tailwindcss-uf04Iolj.cjs} +2 -2
- package/dist/{transform-DVg4q8hh.cjs → transform-CxVM0PfA.cjs} +3 -3
- package/dist/{transform-BAon9ykq.js → transform-D0NXKPmD.js} +3 -3
- package/dist/utils/stable-serialize.d.ts +1 -0
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-IX83wh_L.cjs → vite-C3Zh6iYK.cjs} +434 -209
- package/dist/{vite-D-RGkmOE.js → vite-D6_FxvdM.js} +434 -209
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/{web-DHfZ_KC9.cjs → web-BzeWG_XO.cjs} +442 -155
- package/dist/{web--kA4HUTm.js → web-K3qAX4sN.js} +431 -156
- package/dist/{webpack-Bhkd27Rs.js → webpack-BZBqKB4Y.js} +6 -6
- package/dist/{webpack-BetjemzT.cjs → webpack-Dbj2uykF.cjs} +8 -8
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +5 -4
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions } from "./tailwindcss-
|
|
1
|
+
import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions } from "./tailwindcss-XNfJSlhp.js";
|
|
2
2
|
import { detectAppType } from "./framework.js";
|
|
3
|
-
import { T as omitUndefined } from "./generator-
|
|
3
|
+
import { T as omitUndefined } from "./generator-LqofzXgr.js";
|
|
4
4
|
import { n as hasCssMacroTailwindV4CustomVariantConditionalComments } from "./auto-ENr4xzzw.js";
|
|
5
|
-
import { V as isSourceStyleRequest } from "./hmr-timing-
|
|
6
|
-
import { c as getViteHookHandler, o as normalizeStyleInjectorOptions, s as resolveStyleInjectorSubPackages } from "./source-candidate-scan-signature-
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
5
|
+
import { V as isSourceStyleRequest } from "./hmr-timing-Bb54exB0.js";
|
|
6
|
+
import { c as getViteHookHandler, o as normalizeStyleInjectorOptions, s as resolveStyleInjectorSubPackages } from "./source-candidate-scan-signature-BWLf4tuO.js";
|
|
7
|
+
import { analyzeTailwindV4EntrySource, finalizeMiniProgramCss as finalizeMiniProgramCss$1, hasMiniProgramCssSpecificityPlaceholders, pruneMiniProgramGeneratedCss, stripMiniProgramCssSpecificityPlaceholders } from "@weapp-tailwindcss/postcss/transform";
|
|
8
|
+
import { sourcePathApi } from "@weapp-tailwindcss/source-scan";
|
|
9
9
|
import { weappStyleInjector } from "weapp-style-injector/vite";
|
|
10
10
|
import { StyleInjector } from "weapp-style-injector/vite/taro";
|
|
11
11
|
import { StyleInjector as StyleInjector$1 } from "weapp-style-injector/vite/uni-app";
|
|
@@ -282,12 +282,15 @@ function hasRuntimeAffectingSourceChanges(changedByType) {
|
|
|
282
282
|
}
|
|
283
283
|
//#endregion
|
|
284
284
|
//#region src/bundlers/vite/generate-bundle/scoped-generator.ts
|
|
285
|
-
function hasOwnSourceDirectives(rawSource) {
|
|
286
|
-
|
|
285
|
+
function hasOwnSourceDirectives(rawSource, scopeToSource = false) {
|
|
286
|
+
const analysis = analyzeTailwindV4EntrySource(rawSource);
|
|
287
|
+
if (!analysis) return false;
|
|
288
|
+
const directives = analysis.getSourceDirectives();
|
|
289
|
+
return analysis.configRequests.length > 0 || scopeToSource && directives.hasSourceNone || Boolean(directives.importSourcePath) || directives.sourceRequests.length > 0 || directives.inlineCandidates.included.size > 0 || directives.inlineCandidates.excluded.size > 0;
|
|
287
290
|
}
|
|
288
291
|
function createLocalSourceEntries(sourceFile) {
|
|
289
292
|
return [{
|
|
290
|
-
base:
|
|
293
|
+
base: sourcePathApi(sourceFile).dirname(sourcePathApi(sourceFile).resolve(sourceFile.replace(/[?#].*$/, ""))),
|
|
291
294
|
negated: false,
|
|
292
295
|
pattern: "**/*"
|
|
293
296
|
}];
|
|
@@ -305,36 +308,36 @@ function mergeCandidates(first, second) {
|
|
|
305
308
|
function canFallbackToOutputCandidates(rawSource, entries) {
|
|
306
309
|
return rawSource.includes("@source") && entries.length > 0 && entries.every((entry) => !entry.negated);
|
|
307
310
|
}
|
|
308
|
-
function resolveScopedSourceEntries(rawSource, sourceFile, resolvedEntries) {
|
|
309
|
-
if (!hasOwnSourceDirectives(rawSource)) return {
|
|
311
|
+
function resolveScopedSourceEntries(rawSource, sourceFile, resolvedEntries, scopeToSource = false) {
|
|
312
|
+
if (!hasOwnSourceDirectives(rawSource, scopeToSource)) return {
|
|
310
313
|
entries: resolvedEntries,
|
|
311
314
|
localEntries: void 0
|
|
312
315
|
};
|
|
313
316
|
if (resolvedEntries !== void 0) return { entries: resolvedEntries };
|
|
314
317
|
return { entries: createLocalSourceEntries(sourceFile) };
|
|
315
318
|
}
|
|
316
|
-
async function resolveScopedGeneratorSourceEntries(rawSource, sourceFile) {
|
|
317
|
-
const sourceBase =
|
|
318
|
-
return resolveScopedSourceEntries(rawSource, sourceFile, (await resolveTailwindV4EntriesFromCssCached(rawSource, sourceBase))?.entries);
|
|
319
|
+
async function resolveScopedGeneratorSourceEntries(rawSource, sourceFile, scopeToSource = false) {
|
|
320
|
+
const sourceBase = sourcePathApi(sourceFile).dirname(sourcePathApi(sourceFile).resolve(sourceFile.replace(/[?#].*$/, "")));
|
|
321
|
+
return resolveScopedSourceEntries(rawSource, sourceFile, (await resolveTailwindV4EntriesFromCssCached(rawSource, sourceBase))?.entries, scopeToSource);
|
|
319
322
|
}
|
|
320
323
|
async function createScopedGeneratorCandidateSignature(rawSource, sourceFile, fallbackSignature, getSourceCandidatesForEntries, options = {}) {
|
|
321
|
-
if (!getSourceCandidatesForEntries || !hasOwnSourceDirectives(rawSource)) return fallbackSignature;
|
|
322
|
-
const { entries } = await resolveScopedGeneratorSourceEntries(rawSource, sourceFile);
|
|
324
|
+
if (!getSourceCandidatesForEntries || !hasOwnSourceDirectives(rawSource, options.scopeToSource)) return fallbackSignature;
|
|
325
|
+
const { entries } = await resolveScopedGeneratorSourceEntries(rawSource, sourceFile, options.scopeToSource);
|
|
323
326
|
if (entries === void 0) return fallbackSignature;
|
|
324
327
|
const scopedSignature = createCandidateSignature(getSourceCandidatesForEntries(entries));
|
|
325
328
|
return options.includeFallbackSignature === true ? `${scopedSignature}:${fallbackSignature}` : scopedSignature;
|
|
326
329
|
}
|
|
327
|
-
async function createScopedGeneratorSourceTraceMap(rawSource, sourceFile, getSourceCandidateSourcesForEntries) {
|
|
328
|
-
if (!getSourceCandidateSourcesForEntries || !hasOwnSourceDirectives(rawSource)) return getSourceCandidateSourcesForEntries?.(void 0);
|
|
329
|
-
const { entries } = await resolveScopedGeneratorSourceEntries(rawSource, sourceFile);
|
|
330
|
+
async function createScopedGeneratorSourceTraceMap(rawSource, sourceFile, getSourceCandidateSourcesForEntries, options = {}) {
|
|
331
|
+
if (!getSourceCandidateSourcesForEntries || !hasOwnSourceDirectives(rawSource, options.scopeToSource)) return getSourceCandidateSourcesForEntries?.(void 0);
|
|
332
|
+
const { entries } = await resolveScopedGeneratorSourceEntries(rawSource, sourceFile, options.scopeToSource);
|
|
330
333
|
if (entries === void 0) return getSourceCandidateSourcesForEntries(void 0);
|
|
331
334
|
return getSourceCandidateSourcesForEntries(entries);
|
|
332
335
|
}
|
|
333
336
|
async function createScopedGeneratorRuntime(options) {
|
|
334
|
-
const { cssHandlerOptions, fallbackRuntime, getSourceCandidatesForEntries, outputFile, rawSource, shouldExcludeSubpackageSourceCandidates, sourceFile, scopedSourceCandidateGetter } = options;
|
|
337
|
+
const { cssHandlerOptions, fallbackRuntime, getSourceCandidatesForEntries, outputFile, rawSource, shouldExcludeSubpackageSourceCandidates, sourceFile, scopeToSource, scopedSourceCandidateGetter } = options;
|
|
335
338
|
if (getSourceCandidatesForEntries && rawSource && sourceFile) {
|
|
336
|
-
const { entries } = await resolveScopedGeneratorSourceEntries(rawSource, sourceFile);
|
|
337
|
-
if (entries !== void 0 && (entries.length > 0 || hasOwnSourceDirectives(rawSource))) {
|
|
339
|
+
const { entries } = await resolveScopedGeneratorSourceEntries(rawSource, sourceFile, scopeToSource);
|
|
340
|
+
if (entries !== void 0 && (entries.length > 0 || hasOwnSourceDirectives(rawSource, scopeToSource))) {
|
|
338
341
|
const explicitCandidates = getSourceCandidatesForEntries(entries);
|
|
339
342
|
const outputCandidates = scopedSourceCandidateGetter?.(void 0);
|
|
340
343
|
const scopedCandidates = outputCandidates ? explicitCandidates.size === 0 && canFallbackToOutputCandidates(rawSource, entries) ? outputCandidates : intersectCandidates(explicitCandidates, outputCandidates) : explicitCandidates;
|
|
@@ -347,4 +350,4 @@ async function createScopedGeneratorRuntime(options) {
|
|
|
347
350
|
return fallbackRuntime;
|
|
348
351
|
}
|
|
349
352
|
//#endregion
|
|
350
|
-
export {
|
|
353
|
+
export { resolveWebpackFrameworkProfile as S, createBuiltinViteStyleInjectorPlugins as _, createScopedGeneratorCandidateSignature as a, webpackStyleInjectorDelegates as b, hasOwnSourceDirectives as c, createLinkedImpactSignature as d, getSnapshotHash as f, resolvePluginDisabledState as g, classifyRuntimeEntry as h, stripMiniProgramCssSpecificityPlaceholders as i, createCandidateSignature as l, summarizeStringDiff as m, hasMiniProgramCssSpecificityPlaceholders as n, createScopedGeneratorRuntime as o, hasRuntimeAffectingSourceChanges as p, pruneMiniProgramGeneratedCss as r, createScopedGeneratorSourceTraceMap as s, finalizeMiniProgramCss$1 as t, createJsHashSalt as u, createBuiltinWebpackStyleInjectorPlugin as v, resolveViteFrameworkProfile as x, viteStyleInjectorDelegates as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-fg3euq-1.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-B1sYQpWu.cjs");
|
|
3
3
|
require("./auto-B1OyRrE8.cjs");
|
|
4
|
-
const require_compiler = require("./compiler-
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
4
|
+
const require_compiler = require("./compiler-TvqqdOMD.cjs");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-uf04Iolj.cjs");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
@@ -461,6 +461,30 @@ function diffCandidateSets(previous, next) {
|
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
463
|
//#endregion
|
|
464
|
+
//#region src/project-sources/candidates/view-memo.ts
|
|
465
|
+
/** 按候选版本和来源范围缓存视图,限制历史版本的驻留数量。 */
|
|
466
|
+
function createCandidateViewMemo() {
|
|
467
|
+
const memo = /* @__PURE__ */ new Map();
|
|
468
|
+
return (kind, revision, entries, excludeEntries, collect) => {
|
|
469
|
+
if (entries === void 0 && !excludeEntries?.length) return collect();
|
|
470
|
+
const key = `${revision}\0${JSON.stringify(entries ?? null)}\0${JSON.stringify(excludeEntries ?? null)}`;
|
|
471
|
+
const cached = memo.get(key);
|
|
472
|
+
const view = cached?.[kind];
|
|
473
|
+
if (view) return view;
|
|
474
|
+
const result = collect();
|
|
475
|
+
const next = cached ?? {};
|
|
476
|
+
next[kind] = result;
|
|
477
|
+
memo.delete(key);
|
|
478
|
+
memo.set(key, next);
|
|
479
|
+
while (memo.size > 64) {
|
|
480
|
+
const oldest = memo.keys().next().value;
|
|
481
|
+
if (oldest === void 0) break;
|
|
482
|
+
memo.delete(oldest);
|
|
483
|
+
}
|
|
484
|
+
return result;
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
//#endregion
|
|
464
488
|
//#region src/project-sources/candidates/views.ts
|
|
465
489
|
function isIncludedFile(id, isActiveModule, entries, excludeEntries) {
|
|
466
490
|
if (entries !== void 0 && (isActiveModule ? (0, require_tailwindcss.source_scan_exports.isFileExcludedByTailwindSourceEntries)(id, entries) : entries.length === 0 || !(0, require_tailwindcss.source_scan_exports.isFileMatchedByTailwindSourceEntries)(id, entries))) return false;
|
|
@@ -520,6 +544,7 @@ function createSourceCandidateStore(options = {}) {
|
|
|
520
544
|
const moduleSourceById = /* @__PURE__ */ new Map();
|
|
521
545
|
const candidateCount = /* @__PURE__ */ new Map();
|
|
522
546
|
const fileCandidateMemo = /* @__PURE__ */ new Map();
|
|
547
|
+
const candidateViewMemo = createCandidateViewMemo();
|
|
523
548
|
let inlineIncludedCandidates = /* @__PURE__ */ new Set();
|
|
524
549
|
let inlineExcludedCandidates = /* @__PURE__ */ new Set();
|
|
525
550
|
let revision = 0;
|
|
@@ -728,22 +753,22 @@ function createSourceCandidateStore(options = {}) {
|
|
|
728
753
|
});
|
|
729
754
|
}
|
|
730
755
|
function valuesForEntries(entries, options = {}) {
|
|
731
|
-
return collectCandidateValues({
|
|
756
|
+
return candidateViewMemo("values", revision, entries, options.excludeEntries, () => collectCandidateValues({
|
|
732
757
|
candidatesById,
|
|
733
758
|
moduleCandidatesById,
|
|
734
759
|
candidateCount,
|
|
735
760
|
inlineIncludedCandidates,
|
|
736
761
|
inlineExcludedCandidates
|
|
737
|
-
}, entries, options.excludeEntries);
|
|
762
|
+
}, entries, options.excludeEntries));
|
|
738
763
|
}
|
|
739
764
|
function sourcesForEntries(entries, options = {}) {
|
|
740
|
-
return collectCandidateSources({
|
|
765
|
+
return candidateViewMemo("sources", revision, entries, options.excludeEntries, () => collectCandidateSources({
|
|
741
766
|
candidatesById,
|
|
742
767
|
moduleCandidatesById,
|
|
743
768
|
candidateCount,
|
|
744
769
|
inlineIncludedCandidates,
|
|
745
770
|
inlineExcludedCandidates
|
|
746
|
-
}, entries, options.excludeEntries);
|
|
771
|
+
}, entries, options.excludeEntries));
|
|
747
772
|
}
|
|
748
773
|
function clear() {
|
|
749
774
|
if (candidateCount.size > 0 || fileCandidateMemo.size > 0 || inlineIncludedCandidates.size > 0 || inlineExcludedCandidates.size > 0) revision++;
|
|
@@ -1171,15 +1196,24 @@ function mergeGeneratorResults(generatedResults) {
|
|
|
1171
1196
|
if (generatedResults.length === 1) return firstGenerated;
|
|
1172
1197
|
const incrementalCssResults = generatedResults.map((item) => item.incrementalCss).filter((css) => typeof css === "string");
|
|
1173
1198
|
const incrementalRawCssResults = generatedResults.map((item) => item.incrementalRawCss).filter((css) => typeof css === "string");
|
|
1199
|
+
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
1200
|
+
const conflictingProperties = /* @__PURE__ */ new Set();
|
|
1201
|
+
for (const result of generatedResults) for (const [name, value] of result.customPropertyValues ?? []) {
|
|
1202
|
+
if (customPropertyValues.has(name) && customPropertyValues.get(name) !== value) conflictingProperties.add(name);
|
|
1203
|
+
customPropertyValues.set(name, value);
|
|
1204
|
+
}
|
|
1205
|
+
for (const name of conflictingProperties) customPropertyValues.delete(name);
|
|
1174
1206
|
return {
|
|
1175
1207
|
...firstGenerated,
|
|
1176
1208
|
css: (0, _weapp_tailwindcss_postcss_transform.deduplicateGeneratedCssRules)(generatedResults.map((item) => item.css).join("\n")),
|
|
1177
1209
|
rawCss: (0, _weapp_tailwindcss_postcss_transform.deduplicateGeneratedCssRules)(generatedResults.map((item) => item.rawCss).join("\n")),
|
|
1210
|
+
customPropertyContextCss: generatedResults.map((item) => item.customPropertyContextCss ?? item.rawCss).join("\n"),
|
|
1178
1211
|
incrementalCss: incrementalCssResults.length === generatedResults.length ? incrementalCssResults.filter(Boolean).join("\n") : void 0,
|
|
1179
1212
|
incrementalRawCss: incrementalRawCssResults.length === generatedResults.length ? incrementalRawCssResults.filter(Boolean).join("\n") : void 0,
|
|
1180
1213
|
classSet: new Set(generatedResults.flatMap((item) => [...item.classSet])),
|
|
1181
1214
|
dependencies: [...new Set(generatedResults.flatMap((item) => item.dependencies))],
|
|
1182
|
-
sources: generatedResults.flatMap((item) => item.sources)
|
|
1215
|
+
sources: generatedResults.flatMap((item) => item.sources),
|
|
1216
|
+
customPropertyValues
|
|
1183
1217
|
};
|
|
1184
1218
|
}
|
|
1185
1219
|
//#endregion
|
|
@@ -1244,12 +1278,12 @@ function collectRpxThemeRiskSources(sources) {
|
|
|
1244
1278
|
for (const css of new Set(sources)) for (const name of (0, _weapp_tailwindcss_postcss_transform.collectRpxThemeVariables)(css)) variables.add(name);
|
|
1245
1279
|
return [...variables];
|
|
1246
1280
|
}
|
|
1247
|
-
function warnRpxThemeRisk(session, variables,
|
|
1281
|
+
function warnRpxThemeRisk(session, variables, generatedCss) {
|
|
1248
1282
|
if (warnedSessions.has(session) || variables.length === 0) return;
|
|
1249
|
-
const usage = (0, _weapp_tailwindcss_postcss_transform.inspectRpxCalcUsage)(
|
|
1250
|
-
const
|
|
1283
|
+
const usage = (0, _weapp_tailwindcss_postcss_transform.inspectRpxCalcUsage)(generatedCss, new Set(variables));
|
|
1284
|
+
const generationHint = usage === void 0 ? "当前生成阶段的 CSS 无法完成诊断,请检查最终 WXSS。" : usage.variables.length > 0 || usage.inlineRpx ? `当前生成阶段仍含 calc:${[...usage.variables, ...usage.inlineRpx ? ["内联 rpx"] : []].join(", ")};后续构建处理可能将其静态化,最终状态以 WXSS 为准。` : "当前生成阶段未检测到相关 calc;这不代表已验证最终产物、所有作用域和设备。";
|
|
1251
1285
|
warnedSessions.add(session);
|
|
1252
|
-
_weapp_tailwindcss_logger.logger.warn(`[tailwindcss@4][rpx-theme] @theme 中使用 rpx 的主题变量:${variables.join(", ")}。${
|
|
1286
|
+
_weapp_tailwindcss_logger.logger.warn(`[tailwindcss@4][rpx-theme] @theme 中使用 rpx 的主题变量:${variables.join(", ")}。${generationHint} 微信 WXSS 可能先独立换算或量化基数再乘法,造成尺寸偏差,具体取整算法尚未确认。固定像素尺寸优先使用 px,需要缩放时在构建期输出最终静态 rpx;偶数或较大 rpx 也不保证准确。请检查最终 WXSS 并在目标设备验证:https://tw.weapp.dev/docs/issues/spacing-rpx`);
|
|
1253
1287
|
}
|
|
1254
1288
|
//#endregion
|
|
1255
1289
|
//#region src/generation/framework-postcss.ts
|
|
@@ -2197,6 +2231,28 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
2197
2231
|
//#endregion
|
|
2198
2232
|
//#region src/generation/source-resolver/resolve-sources.ts
|
|
2199
2233
|
async function resolveGeneratorResolvedSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
2234
|
+
const ownedSources = resolveCssHandlerSourceOptions(cssHandlerOptions)?.cssSources;
|
|
2235
|
+
if (ownedSources?.length) {
|
|
2236
|
+
const sourceOptions = {
|
|
2237
|
+
...require_generator.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime),
|
|
2238
|
+
cssEntries: [],
|
|
2239
|
+
cssSources: ownedSources
|
|
2240
|
+
};
|
|
2241
|
+
return Promise.all(ownedSources.map(async (source, index) => {
|
|
2242
|
+
const resolved = await resolveSingleTailwindV4CssSource(source, sourceOptions, {
|
|
2243
|
+
index,
|
|
2244
|
+
matched: true,
|
|
2245
|
+
primary: index === 0
|
|
2246
|
+
});
|
|
2247
|
+
return normalizeResolvedTailwindV4SourceConfig(withGeneratorSourceMetadata(generatorOptions?.config ? {
|
|
2248
|
+
...resolved,
|
|
2249
|
+
css: (0, _weapp_tailwindcss_postcss_transform.prependConfigDirective)(resolved.css, generatorOptions.config)
|
|
2250
|
+
} : resolved, {
|
|
2251
|
+
...getGeneratorSourceMetadata(resolved),
|
|
2252
|
+
isolateCssSource: ownedSources.length > 1 || /source\(\s*none\s*\)/i.test(source.css)
|
|
2253
|
+
}), source.file, sourceOptions);
|
|
2254
|
+
}));
|
|
2255
|
+
}
|
|
2200
2256
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
2201
2257
|
const cssEntrySource = (0, _weapp_tailwindcss_postcss_transform.resolveCssEntrySource)(rawSource, base, {
|
|
2202
2258
|
importFallback: generatorOptions?.importFallback ?? false,
|
|
@@ -2331,17 +2387,8 @@ function setLimitedCacheValue(cache, key, value) {
|
|
|
2331
2387
|
}
|
|
2332
2388
|
cache.set(key, value);
|
|
2333
2389
|
}
|
|
2334
|
-
function createStableJson(value) {
|
|
2335
|
-
if (value === void 0) return "undefined";
|
|
2336
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
2337
|
-
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
2338
|
-
return `{${Object.keys(value).sort().map((key) => {
|
|
2339
|
-
const record = value;
|
|
2340
|
-
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
2341
|
-
}).join(",")}}`;
|
|
2342
|
-
}
|
|
2343
2390
|
function createLegacyCompatTransformCacheKey(source, options) {
|
|
2344
|
-
return `${
|
|
2391
|
+
return `${require_generator.stableSerialize(options)}\0${source}`;
|
|
2345
2392
|
}
|
|
2346
2393
|
function resolveLegacyCompatCssSource(rawSource) {
|
|
2347
2394
|
const cached = legacyCompatSourceCache.get(rawSource);
|
|
@@ -2535,6 +2582,10 @@ async function finalizeDeferredGeneratorCss(context) {
|
|
|
2535
2582
|
const rawCss = (0, _weapp_tailwindcss_postcss_transform.stripTailwindBanner)(css);
|
|
2536
2583
|
const generationCss = generated.target === "weapp" && ((0, _weapp_tailwindcss_postcss_transform.hasCssMacroStyleOptions)(generatorStyleOptions) || (0, _weapp_tailwindcss_postcss_transform.hasCssMacroTailwindV4InternalAtRules)(rawCss)) ? await (0, _weapp_tailwindcss_postcss_transform.transformCssMacroCss)(rawCss, generatorStyleOptions) : rawCss;
|
|
2537
2584
|
const normalizedCss = generated.target === "weapp" ? await (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramGeneratedCssForPostcss)(generationCss, {
|
|
2585
|
+
cssCalc: generatorStyleOptions.cssCalc,
|
|
2586
|
+
cssOptions: generatorStyleOptions.cssOptions,
|
|
2587
|
+
customPropertyValues: generatorStyleOptions.customPropertyValues,
|
|
2588
|
+
contextCss: generated.customPropertyContextCss ?? generated.rawCss,
|
|
2538
2589
|
preservePreflight: true,
|
|
2539
2590
|
preserveRawClassRules: true
|
|
2540
2591
|
}) : generationCss;
|
|
@@ -2943,8 +2994,9 @@ async function prepareGeneratorInputs(context) {
|
|
|
2943
2994
|
...source,
|
|
2944
2995
|
css: sourceCss
|
|
2945
2996
|
};
|
|
2997
|
+
const entryCssCandidates = Boolean(cssHandlerOptions.sourceOptions?.cssSources?.length) ? (0, _weapp_tailwindcss_postcss_transform.collectGeneratorCssCandidates)(sourceMetadata.sourceCss ?? source.css) : currentCssCandidates;
|
|
2946
2998
|
const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(record, runtimeState) : void 0;
|
|
2947
|
-
const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
2999
|
+
const sourceScopedRuntime = sourceEntries !== void 0 && (sourceEntries.length > 0 || sourceMetadata.isolateCssSource === true) ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
2948
3000
|
const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
|
|
2949
3001
|
const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, record, sourceEntries, {
|
|
2950
3002
|
cssHandlerOptions,
|
|
@@ -2956,7 +3008,7 @@ async function prepareGeneratorInputs(context) {
|
|
|
2956
3008
|
return;
|
|
2957
3009
|
}
|
|
2958
3010
|
const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) || isolateCssSource ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime ?? /* @__PURE__ */ new Set(), runtimeWithCurrentCss, {
|
|
2959
|
-
currentCssCandidates,
|
|
3011
|
+
currentCssCandidates: entryCssCandidates,
|
|
2960
3012
|
cssHandlerOptions,
|
|
2961
3013
|
isolateCssSource,
|
|
2962
3014
|
majorVersion,
|
|
@@ -2973,6 +3025,23 @@ async function prepareGeneratorInputs(context) {
|
|
|
2973
3025
|
};
|
|
2974
3026
|
}
|
|
2975
3027
|
//#endregion
|
|
3028
|
+
//#region src/generation/pipeline/style-context.ts
|
|
3029
|
+
/** 先确定同一输出的完整级联,再从原始声明生成兼容 CSS。 */
|
|
3030
|
+
async function mergeGeneratorResultsForOutput(results, options) {
|
|
3031
|
+
const merged = mergeGeneratorResults(results);
|
|
3032
|
+
if (!merged || results.length < 2 || merged.target === "tailwind" || !require_generator.hasCssCalcVariables(options)) return merged;
|
|
3033
|
+
const css = await require_generator.transformTailwindV4CssByTarget(merged.rawCss, merged.target, {
|
|
3034
|
+
...options,
|
|
3035
|
+
customPropertyContextCss: [options.customPropertyContextCss, merged.customPropertyContextCss].filter(Boolean).join("\n")
|
|
3036
|
+
});
|
|
3037
|
+
return {
|
|
3038
|
+
...merged,
|
|
3039
|
+
css,
|
|
3040
|
+
incrementalCss: void 0,
|
|
3041
|
+
incrementalRawCss: void 0
|
|
3042
|
+
};
|
|
3043
|
+
}
|
|
3044
|
+
//#endregion
|
|
2976
3045
|
//#region src/generation/pipeline/execution.ts
|
|
2977
3046
|
async function executeGeneratorPipeline(context) {
|
|
2978
3047
|
return require_compiler.runCompilerOwnerActivity(context.runtimeState, () => executeGeneratorPipelineWithOwner(context, require_compiler.getCompilationSessionPool(context.runtimeState), require_compiler.getTailwindGenerationSessionPool(context.runtimeState)));
|
|
@@ -2982,6 +3051,12 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
2982
3051
|
await runtimeState.readyPromise;
|
|
2983
3052
|
const compilerSession = options.compilation?.enabled ? require_compiler.getFrameworkCompilerSession(runtimeState, opts) : void 0;
|
|
2984
3053
|
const { isolateCurrentCssCandidates, runtimeWithCurrentCss, generatorSourceRecords, generatorStyleOptions, configuredContainerCompat, sourceConcurrency, preparedGenerationInputs } = await prepareGeneratorInputs(context);
|
|
3054
|
+
if (require_generator.hasCssCalcVariables(generatorStyleOptions)) generatorStyleOptions.customPropertyContextCss = [
|
|
3055
|
+
generatorStyleOptions.customPropertyContextCss,
|
|
3056
|
+
context.generatedUserCssRawSource,
|
|
3057
|
+
options.frameworkProcessedUserCss,
|
|
3058
|
+
...preparedGenerationInputs.map((input) => input.generatorSource.css)
|
|
3059
|
+
].filter(Boolean).join("\n");
|
|
2985
3060
|
const generatePreparedInputs = async (candidateSets) => {
|
|
2986
3061
|
return runWithConcurrency(preparedGenerationInputs.map((input) => async () => {
|
|
2987
3062
|
const projectedCandidates = candidateSets?.get(input.sourceId);
|
|
@@ -3027,7 +3102,7 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
3027
3102
|
if (compilerSession && options.compilation?.changes) compilerSession.invalidate(options.compilation.changes.map((change) => change.id));
|
|
3028
3103
|
await compilerSession?.syncScope(options.compilation?.scope.id ?? options.outputFile ?? file, preparedGenerationInputs.map((input) => input.sourceId));
|
|
3029
3104
|
const results = await generatePreparedInputs(compilation.candidatesBySource);
|
|
3030
|
-
const merged =
|
|
3105
|
+
const merged = await mergeGeneratorResultsForOutput(results.map((result) => result.generated), generatorStyleOptions);
|
|
3031
3106
|
return merged ? {
|
|
3032
3107
|
classSet: merged.classSet,
|
|
3033
3108
|
dependenciesBySource: results.map((result) => [result.sourceId, resolveCompilationDependencies(result.generated.dependencies)]),
|
|
@@ -3048,8 +3123,9 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
3048
3123
|
snapshot: execution.value.snapshot
|
|
3049
3124
|
};
|
|
3050
3125
|
compilationRevision = execution.compilation.revision;
|
|
3051
|
-
} else generated =
|
|
3126
|
+
} else generated = await mergeGeneratorResultsForOutput((await generatePreparedInputs()).map((result) => result.generated), generatorStyleOptions);
|
|
3052
3127
|
if (!generated) return;
|
|
3128
|
+
if (generated.customPropertyContextCss) generatorStyleOptions.customPropertyContextCss = generated.customPropertyContextCss;
|
|
3053
3129
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
3054
3130
|
const hasMatchedCssSourceFile = generatorSourceRecords.some((record) => record.metadata.matchedCssSourceFile);
|
|
3055
3131
|
const hasExplicitCssSource = generatorSourceRecords.some(({ metadata }) => {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
|
|
2
|
+
import type { GeneratorResult } from '../generation-helpers/results.js';
|
|
3
|
+
export declare function mergeGeneratorResultsForOutput(results: GeneratorResult[], options: Partial<IStyleHandlerOptions>): Promise<GeneratorResult | undefined>;
|