weapp-tailwindcss 5.5.7 → 5.5.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.
- 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/{compiler-DkGY5Nmh.cjs → compiler-TvqqdOMD.cjs} +15894 -15804
- 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/{generated-css-marker-jMNbQHpy.cjs → generated-css-marker-C21q8hGM.cjs} +48 -20
- 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-CVvBpIlq.cjs → gulp-BhQhrDCx.cjs} +5 -5
- package/dist/{gulp-DhddVxGA.js → gulp-ComuY3KW.js} +4 -4
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-xPpat-km.js → hmr-timing-CNo2hmaX.js} +48 -20
- package/dist/{hmr-timing-DfMbbZ1E.cjs → hmr-timing-CXBDn0dl.cjs} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-zMPmp5F3.cjs → pipeline-helpers-B9ZqLXma.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/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{scoped-generator-BIZ7N_J-.cjs → scoped-generator-BAiZDC_4.cjs} +4 -4
- package/dist/{scoped-generator-DlQrVbuC.js → scoped-generator-CF0ROe7B.js} +4 -4
- 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-D2KFdA3C.cjs → transform-DJkkjruV.cjs} +3 -3
- package/dist/{transform-BAon9ykq.js → transform-I-mzwoiv.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-BxW0qd7J.cjs → vite-BVcj7Ht9.cjs} +18 -14
- package/dist/{vite-D-RGkmOE.js → vite-Bd-Ig5Dy.js} +17 -13
- 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--kA4HUTm.js → web-BsFZOq3g.js} +296 -85
- package/dist/{web-Y-H6I1k6.cjs → web-Dq2PzKKQ.cjs} +307 -84
- package/dist/{webpack-DxrWatNB.cjs → webpack-CWMoTWzF.cjs} +8 -8
- package/dist/{webpack-BB-kw4Qr.js → webpack-DtAZoEth.js} +7 -7
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +6 -5
|
@@ -6,7 +6,7 @@ import fs, { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import process from "node:process";
|
|
8
8
|
import { createTailwindGenerationSession, createTailwindV4Engine, extractRawCandidates, loadTailwindV4DesignSystem, resolveTailwindV4Source, resolveValidTailwindV4Candidates as resolveValidTailwindV4Candidates$1 } from "@weapp-tailwindcss/engine";
|
|
9
|
-
import { collectCustomPropertyValues, collectRpxThemeVariables, describeCssSources, insertTailwindThemeCss, mergeCustomPropertyValues, normalizeConfigDirective, normalizeEmptyTailwindCustomVariants, normalizeRpxLengthCandidates, normalizeTailwindConfigDirectives, parseCssImportSpecifier, postcss, removeTailwindV4PreflightImports, removeUnsupportedThemeVendorKeyframes, resolveCssEntrySource, resolveCssScanSources, restoreRpxLengthCandidates, restoreRpxLengthCssSelectors, rewriteCssImportSpecifiers, transformTailwindV4CssToWeapp, transformTailwindV4GeneratedCss } from "@weapp-tailwindcss/postcss/transform";
|
|
9
|
+
import { analyzeCssCalcContext, collectCustomPropertyValues, collectRpxThemeVariables, createCssRuntimeAffectingSignature, describeCssSources, insertTailwindThemeCss, isCssCalcCustomPropertySelected, mergeCustomPropertyValues, normalizeConfigDirective, normalizeEmptyTailwindCustomVariants, normalizeRpxLengthCandidates, normalizeTailwindConfigDirectives, parseCssImportSpecifier, postcss, removeTailwindV4PreflightImports, removeUnsupportedThemeVendorKeyframes, resolveCssEntrySource, resolveCssScanSources, restoreRpxLengthCandidates, restoreRpxLengthCssSelectors, rewriteCssImportSpecifiers, transformTailwindV4CssToWeapp, transformTailwindV4GeneratedCss } from "@weapp-tailwindcss/postcss/transform";
|
|
10
10
|
import { LRUCache } from "lru-cache";
|
|
11
11
|
import { LEGACY_SOURCE_IGNORED_PATTERNS } from "@weapp-tailwindcss/source-scan";
|
|
12
12
|
//#region src/runtime-branch/generator-target-env.ts
|
|
@@ -52,6 +52,23 @@ function inferGeneratorTargetFromEnv() {
|
|
|
52
52
|
return inferGeneratorTargetFromExplicitEnv() ?? (shouldUseWebGeneratorTargetFromEnv() ? "web" : "weapp");
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
|
+
//#region src/utils/stable-serialize.ts
|
|
56
|
+
/** 统一生成缓存的配置身份;映射顺序和正则游标不改变配置语义。 */
|
|
57
|
+
function stableSerialize(value, stack = /* @__PURE__ */ new WeakSet()) {
|
|
58
|
+
if (value == null || typeof value === "number" || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
|
|
59
|
+
if (typeof value === "function") return `[Function:${value.name}]`;
|
|
60
|
+
if (typeof value !== "object") return String(value);
|
|
61
|
+
if (stack.has(value)) return "[Circular]";
|
|
62
|
+
if (value instanceof RegExp) return `RegExp(${JSON.stringify(value.source)},${JSON.stringify(value.flags)})`;
|
|
63
|
+
stack.add(value);
|
|
64
|
+
let serialized;
|
|
65
|
+
if (value instanceof Map) serialized = `Map(${[...value].map(([key, item]) => `[${stableSerialize(key, stack)},${stableSerialize(item, stack)}]`).sort().join(",")})`;
|
|
66
|
+
else if (Array.isArray(value)) serialized = `[${value.map((item) => stableSerialize(item, stack)).join(",")}]`;
|
|
67
|
+
else serialized = `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize(value[key], stack)}`).join(",")}}`;
|
|
68
|
+
stack.delete(value);
|
|
69
|
+
return serialized;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
55
72
|
//#region src/tailwindcss/v4-engine/candidates.ts
|
|
56
73
|
const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:has-)?(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:has-)?(?:in|not-in)-\[/;
|
|
57
74
|
function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
|
|
@@ -72,15 +89,6 @@ function hasRemovedCandidates(previousCandidates, nextCandidates) {
|
|
|
72
89
|
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
73
90
|
return false;
|
|
74
91
|
}
|
|
75
|
-
function createStableJson(value) {
|
|
76
|
-
if (value === void 0) return "undefined";
|
|
77
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
78
|
-
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
79
|
-
return `{${Object.keys(value).sort().map((key) => {
|
|
80
|
-
const record = value;
|
|
81
|
-
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
82
|
-
}).join(",")}}`;
|
|
83
|
-
}
|
|
84
92
|
function createDependencyFingerprint(files) {
|
|
85
93
|
return files.map((file) => {
|
|
86
94
|
try {
|
|
@@ -95,7 +103,7 @@ function createTailwindV4SourceCacheKey(source) {
|
|
|
95
103
|
return [
|
|
96
104
|
source.projectRoot,
|
|
97
105
|
source.base,
|
|
98
|
-
|
|
106
|
+
stableSerialize(source.baseFallbacks),
|
|
99
107
|
source.css,
|
|
100
108
|
createDependencyFingerprint(source.dependencies)
|
|
101
109
|
].join("\0");
|
|
@@ -104,7 +112,7 @@ function createIncrementalGenerateCacheKey(source, target, styleOptions) {
|
|
|
104
112
|
return [
|
|
105
113
|
createTailwindV4SourceCacheKey(source),
|
|
106
114
|
target,
|
|
107
|
-
|
|
115
|
+
stableSerialize(styleOptions)
|
|
108
116
|
].join("\0");
|
|
109
117
|
}
|
|
110
118
|
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
@@ -137,7 +145,7 @@ function resolveTargetCandidates(candidates, target) {
|
|
|
137
145
|
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
138
146
|
}
|
|
139
147
|
function collectSeenCandidates(generated) {
|
|
140
|
-
return new Set(generated.classSet);
|
|
148
|
+
return /* @__PURE__ */ new Set([...generated.rawCandidates, ...generated.classSet]);
|
|
141
149
|
}
|
|
142
150
|
function createIncrementalStyleOptions(styleOptions) {
|
|
143
151
|
return {
|
|
@@ -171,8 +179,7 @@ function shouldAdmitIncrementalEntry(requestedCandidates, generated) {
|
|
|
171
179
|
function seedIncrementalGenerateCache(options) {
|
|
172
180
|
if (!shouldAdmitIncrementalEntry(options.requestedCandidates, options.generated)) return false;
|
|
173
181
|
const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions);
|
|
174
|
-
const customPropertyValues =
|
|
175
|
-
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
182
|
+
const customPropertyValues = new Map(options.generated.customPropertyValues ?? []);
|
|
176
183
|
incrementalGenerateCache.set(cacheKey, {
|
|
177
184
|
seenCandidates: collectSeenCandidates(options.generated),
|
|
178
185
|
classSet: new Set(options.generated.classSet),
|
|
@@ -781,91 +788,133 @@ function resolveCompiledSourceRoot(source) {
|
|
|
781
788
|
}
|
|
782
789
|
//#endregion
|
|
783
790
|
//#region src/tailwindcss/v4-engine/generator/style-context.ts
|
|
784
|
-
function
|
|
791
|
+
function hasCssCalcVariables(options) {
|
|
785
792
|
const calc = options?.cssOptions?.cssCalc ?? options?.cssCalc;
|
|
786
793
|
const include = Array.isArray(calc) ? calc : calc && typeof calc === "object" ? calc.includeCustomProperties : void 0;
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
794
|
+
return calc === true || Boolean(include?.length);
|
|
795
|
+
}
|
|
796
|
+
function resolveGenerationStyleContext(sourceCss, generatedCss, options) {
|
|
797
|
+
if (!hasCssCalcVariables(options)) return options;
|
|
791
798
|
return {
|
|
792
799
|
...options,
|
|
793
|
-
|
|
800
|
+
customPropertyContextCss: [
|
|
801
|
+
options?.customPropertyContextCss,
|
|
802
|
+
sourceCss,
|
|
803
|
+
generatedCss
|
|
804
|
+
].filter(Boolean).join("\n")
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
/** 增量 utility 不带主题声明;兼容转换单独补齐主题值,不能将其升级成 calc 常量。 */
|
|
808
|
+
function resolveIncrementalStyleContext(sourceCss, generatedCss, options) {
|
|
809
|
+
const customPropertyCompatibilityValues = collectCustomPropertyValues(sourceCss);
|
|
810
|
+
mergeCustomPropertyValues(customPropertyCompatibilityValues, generatedCss);
|
|
811
|
+
return {
|
|
812
|
+
...resolveGenerationStyleContext(sourceCss, generatedCss, options),
|
|
813
|
+
customPropertyCompatibilityValues
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
/** 新增候选改变静态变量资格时,需要重算已有规则,不能只追加新 CSS。 */
|
|
817
|
+
function hasChangedCssCalcContext(previousCss, nextCss, options) {
|
|
818
|
+
if (!hasCssCalcVariables(options)) return false;
|
|
819
|
+
const calc = options?.cssOptions?.cssCalc ?? options?.cssCalc;
|
|
820
|
+
const include = Array.isArray(calc) ? calc : calc && typeof calc === "object" ? calc.includeCustomProperties : void 0;
|
|
821
|
+
const selected = (name) => calc === true || isCssCalcCustomPropertySelected(name, include);
|
|
822
|
+
const values = (css) => {
|
|
823
|
+
const context = [options?.customPropertyContextCss, css].filter(Boolean).join("\n");
|
|
824
|
+
return new Map([...analyzeCssCalcContext(context, options?.customPropertyValues ?? (calc && typeof calc === "object" && !Array.isArray(calc) ? calc.customPropertyValues : void 0)).customPropertyValues].filter(([name]) => selected(name)));
|
|
794
825
|
};
|
|
826
|
+
const previous = values(previousCss);
|
|
827
|
+
const next = values(nextCss);
|
|
828
|
+
return previous.size !== next.size || [...previous].some(([name, value]) => next.get(name) !== value);
|
|
795
829
|
}
|
|
796
830
|
//#endregion
|
|
797
|
-
//#region src/tailwindcss/v4-engine/generator/
|
|
831
|
+
//#region src/tailwindcss/v4-engine/generator/raw-generation.ts
|
|
798
832
|
function isCssSyntaxError(error) {
|
|
799
833
|
return error instanceof Error && error.name === "CssSyntaxError";
|
|
800
834
|
}
|
|
835
|
+
/** 原生生成会话负责按当前候选产出完整主题、utility 和运行时依赖。 */
|
|
836
|
+
async function generateRawArtifact(generationSessions, generateSource, options = {}) {
|
|
837
|
+
const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
|
|
838
|
+
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
839
|
+
const compatibleSource = createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target);
|
|
840
|
+
const compiledScan = options.scanMode === "compiled";
|
|
841
|
+
const resolvedScanSources = compiledScan ? void 0 : await resolveScanSources(generateSource, scanSources);
|
|
842
|
+
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await extractRawCandidates(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
843
|
+
const resolvedCandidates = resolveTargetCandidates(/* @__PURE__ */ new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target);
|
|
844
|
+
let normalizedCandidates = normalizeTargetRpxLengthCandidates(resolvedCandidates, target, resolvedStyleOptions);
|
|
845
|
+
const sourceId = compatibleSource.dependencies[0] ?? compatibleSource.base;
|
|
846
|
+
const generationRequest = {
|
|
847
|
+
...compiledScan ? {
|
|
848
|
+
scanSources,
|
|
849
|
+
excludeFiles: options.excludeFiles ?? [],
|
|
850
|
+
prepareCandidates: (candidates) => {
|
|
851
|
+
normalizedCandidates = normalizeTargetRpxLengthCandidates(resolveTargetCandidates(candidates, target), target, resolvedStyleOptions);
|
|
852
|
+
return normalizedCandidates.candidates;
|
|
853
|
+
}
|
|
854
|
+
} : {},
|
|
855
|
+
...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues },
|
|
856
|
+
...patchOptions.sources === void 0 ? {} : { sourceEntries: createEngineSourceEntries(patchOptions.sources, sourceId) },
|
|
857
|
+
candidates: compiledScan ? resolvedCandidates : normalizedCandidates.candidates
|
|
858
|
+
};
|
|
859
|
+
let generatedCss;
|
|
860
|
+
let classSet;
|
|
861
|
+
let rawCandidates;
|
|
862
|
+
let dependencies;
|
|
863
|
+
try {
|
|
864
|
+
const artifact = await generationSessions.generate(target, createTailwindV4SourceCacheKey(compatibleSource), compatibleSource, generationRequest);
|
|
865
|
+
generatedCss = serializeTailwindGenerationArtifact(artifact);
|
|
866
|
+
classSet = artifact.classSet;
|
|
867
|
+
rawCandidates = artifact.rawCandidates;
|
|
868
|
+
dependencies = artifact.dependencies;
|
|
869
|
+
} catch (error) {
|
|
870
|
+
if (compiledScan || !isCssSyntaxError(error)) throw error;
|
|
871
|
+
const legacyEngine = createTailwindV4Engine(compatibleSource);
|
|
872
|
+
try {
|
|
873
|
+
const legacyResult = await legacyEngine.generate({
|
|
874
|
+
...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues },
|
|
875
|
+
...patchOptions.sources === void 0 ? {} : { sources: patchOptions.sources },
|
|
876
|
+
candidates: normalizedCandidates.candidates,
|
|
877
|
+
scanSources: false
|
|
878
|
+
});
|
|
879
|
+
generatedCss = legacyResult.css;
|
|
880
|
+
classSet = legacyResult.classSet;
|
|
881
|
+
rawCandidates = legacyResult.rawCandidates;
|
|
882
|
+
dependencies = legacyResult.dependencies;
|
|
883
|
+
} finally {
|
|
884
|
+
legacyEngine.dispose?.();
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
const sources = Array.isArray(resolvedScanSources) ? resolvedScanSources : [];
|
|
888
|
+
const rawCss = restoreRpxLengthCssSelectors(generatedCss, normalizedCandidates.restoreCandidates);
|
|
889
|
+
return {
|
|
890
|
+
classSet: restoreRpxLengthCandidates(classSet, normalizedCandidates.restoreCandidates),
|
|
891
|
+
rawCandidates: restoreRpxLengthCandidates(rawCandidates, normalizedCandidates.restoreCandidates),
|
|
892
|
+
dependencies,
|
|
893
|
+
root: resolveCompiledSourceRoot(compatibleSource),
|
|
894
|
+
sources,
|
|
895
|
+
rawCss,
|
|
896
|
+
target,
|
|
897
|
+
styleContext: resolveGenerationStyleContext(compatibleSource.css, rawCss, resolvedStyleOptions)
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
async function transformGeneratedArtifact(artifact) {
|
|
901
|
+
const { styleContext, ...generated } = artifact;
|
|
902
|
+
const css = await transformTailwindV4CssByTarget(generated.rawCss, generated.target, styleContext);
|
|
903
|
+
return {
|
|
904
|
+
...generated,
|
|
905
|
+
css,
|
|
906
|
+
customPropertyContextCss: styleContext?.customPropertyContextCss,
|
|
907
|
+
...styleContext?.customPropertyValues ? { customPropertyValues: new Map(styleContext.customPropertyValues) } : {}
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
//#endregion
|
|
911
|
+
//#region src/tailwindcss/v4-engine/generator/engine.ts
|
|
801
912
|
function createTailwindV4Engine$1(source) {
|
|
802
913
|
const generationSessions = new TailwindV4NativeSessionPool();
|
|
803
914
|
const incrementalCacheKeys = /* @__PURE__ */ new Set();
|
|
804
915
|
const validationEngine = createTailwindV4Engine(source);
|
|
805
916
|
async function generateOnce(generateSource, options = {}) {
|
|
806
|
-
|
|
807
|
-
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
808
|
-
const compatibleSource = createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target);
|
|
809
|
-
const compiledScan = options.scanMode === "compiled";
|
|
810
|
-
const resolvedScanSources = compiledScan ? void 0 : await resolveScanSources(generateSource, scanSources);
|
|
811
|
-
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await extractRawCandidates(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
812
|
-
const resolvedCandidates = resolveTargetCandidates(/* @__PURE__ */ new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target);
|
|
813
|
-
let normalizedCandidates = normalizeTargetRpxLengthCandidates(resolvedCandidates, target, resolvedStyleOptions);
|
|
814
|
-
const sourceId = compatibleSource.dependencies[0] ?? compatibleSource.base;
|
|
815
|
-
const generationRequest = {
|
|
816
|
-
...compiledScan ? {
|
|
817
|
-
scanSources,
|
|
818
|
-
excludeFiles: options.excludeFiles ?? [],
|
|
819
|
-
prepareCandidates: (candidates) => {
|
|
820
|
-
normalizedCandidates = normalizeTargetRpxLengthCandidates(resolveTargetCandidates(candidates, target), target, resolvedStyleOptions);
|
|
821
|
-
return normalizedCandidates.candidates;
|
|
822
|
-
}
|
|
823
|
-
} : {},
|
|
824
|
-
...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues },
|
|
825
|
-
...patchOptions.sources === void 0 ? {} : { sourceEntries: createEngineSourceEntries(patchOptions.sources, sourceId) },
|
|
826
|
-
candidates: compiledScan ? resolvedCandidates : normalizedCandidates.candidates
|
|
827
|
-
};
|
|
828
|
-
let generatedCss;
|
|
829
|
-
let classSet;
|
|
830
|
-
let rawCandidates;
|
|
831
|
-
let dependencies;
|
|
832
|
-
try {
|
|
833
|
-
const artifact = await generationSessions.generate(target, createTailwindV4SourceCacheKey(compatibleSource), compatibleSource, generationRequest);
|
|
834
|
-
generatedCss = serializeTailwindGenerationArtifact(artifact);
|
|
835
|
-
classSet = artifact.classSet;
|
|
836
|
-
rawCandidates = artifact.rawCandidates;
|
|
837
|
-
dependencies = artifact.dependencies;
|
|
838
|
-
} catch (error) {
|
|
839
|
-
if (compiledScan || !isCssSyntaxError(error)) throw error;
|
|
840
|
-
const legacyEngine = createTailwindV4Engine(compatibleSource);
|
|
841
|
-
try {
|
|
842
|
-
const legacyResult = await legacyEngine.generate({
|
|
843
|
-
...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues },
|
|
844
|
-
...patchOptions.sources === void 0 ? {} : { sources: patchOptions.sources },
|
|
845
|
-
candidates: normalizedCandidates.candidates,
|
|
846
|
-
scanSources: false
|
|
847
|
-
});
|
|
848
|
-
generatedCss = legacyResult.css;
|
|
849
|
-
classSet = legacyResult.classSet;
|
|
850
|
-
rawCandidates = legacyResult.rawCandidates;
|
|
851
|
-
dependencies = legacyResult.dependencies;
|
|
852
|
-
} finally {
|
|
853
|
-
legacyEngine.dispose?.();
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
const sources = Array.isArray(resolvedScanSources) ? resolvedScanSources : [];
|
|
857
|
-
const rawCss = restoreRpxLengthCssSelectors(generatedCss, normalizedCandidates.restoreCandidates);
|
|
858
|
-
const css = await transformTailwindV4CssByTarget(rawCss, target, resolveGenerationStyleContext(compatibleSource.css, rawCss, resolvedStyleOptions));
|
|
859
|
-
return {
|
|
860
|
-
classSet: restoreRpxLengthCandidates(classSet, normalizedCandidates.restoreCandidates),
|
|
861
|
-
rawCandidates: restoreRpxLengthCandidates(rawCandidates, normalizedCandidates.restoreCandidates),
|
|
862
|
-
dependencies,
|
|
863
|
-
root: resolveCompiledSourceRoot(compatibleSource),
|
|
864
|
-
sources,
|
|
865
|
-
css,
|
|
866
|
-
rawCss,
|
|
867
|
-
target
|
|
868
|
-
};
|
|
917
|
+
return transformGeneratedArtifact(await generateRawArtifact(generationSessions, generateSource, options));
|
|
869
918
|
}
|
|
870
919
|
async function generateWithIncrementalCache(options = {}) {
|
|
871
920
|
const target = options.target ?? "weapp";
|
|
@@ -908,6 +957,8 @@ function createTailwindV4Engine$1(source) {
|
|
|
908
957
|
incrementalRawCss: "",
|
|
909
958
|
classSet: new Set(cached.classSet),
|
|
910
959
|
rawCandidates: new Set(cached.seenCandidates),
|
|
960
|
+
customPropertyValues: new Map(cached.customPropertyValues),
|
|
961
|
+
customPropertyContextCss: resolveGenerationStyleContext(compatibleSource.css, cached.rawCss, styleOptions)?.customPropertyContextCss,
|
|
911
962
|
dependencies: cached.dependencies,
|
|
912
963
|
sources: cached.sources,
|
|
913
964
|
root: cached.root,
|
|
@@ -940,15 +991,25 @@ function createTailwindV4Engine$1(source) {
|
|
|
940
991
|
}
|
|
941
992
|
}
|
|
942
993
|
const rawCss = rawCssParts.join("\n");
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
994
|
+
const fullRawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
|
|
995
|
+
const artifact = await generateRawArtifact(generationSessions, cssMacroSource, options);
|
|
996
|
+
if (createCssRuntimeAffectingSignature(fullRawCss) !== createCssRuntimeAffectingSignature(artifact.rawCss) || hasChangedCssCalcContext(cached.rawCss, artifact.rawCss, styleOptions)) {
|
|
997
|
+
const generated = await transformGeneratedArtifact(artifact);
|
|
998
|
+
if (!seedIncrementalGenerateCache({
|
|
999
|
+
compatibleSource,
|
|
1000
|
+
generated,
|
|
1001
|
+
requestedCandidates,
|
|
1002
|
+
styleOptions,
|
|
1003
|
+
target
|
|
1004
|
+
})) incrementalGenerateCache.delete(cacheKey);
|
|
1005
|
+
return generated;
|
|
1006
|
+
}
|
|
1007
|
+
const styleContext = target === "weapp" ? resolveIncrementalStyleContext(compatibleSource.css, fullRawCss, styleOptions) : resolveGenerationStyleContext(compatibleSource.css, fullRawCss, styleOptions);
|
|
1008
|
+
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, { ...createIncrementalStyleOptions(styleContext) }) : "";
|
|
947
1009
|
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
948
1010
|
for (const className of classSet) cached.classSet.add(className);
|
|
949
1011
|
cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
|
|
950
|
-
cached.rawCss =
|
|
951
|
-
mergeCustomPropertyValues(cached.customPropertyValues, incrementalCss);
|
|
1012
|
+
cached.rawCss = fullRawCss;
|
|
952
1013
|
return {
|
|
953
1014
|
css: cached.css,
|
|
954
1015
|
rawCss: cached.rawCss,
|
|
@@ -956,6 +1017,8 @@ function createTailwindV4Engine$1(source) {
|
|
|
956
1017
|
incrementalRawCss: rawCss,
|
|
957
1018
|
classSet: new Set(cached.classSet),
|
|
958
1019
|
rawCandidates: new Set(cached.seenCandidates),
|
|
1020
|
+
customPropertyValues: new Map(cached.customPropertyValues),
|
|
1021
|
+
customPropertyContextCss: styleContext?.customPropertyContextCss,
|
|
959
1022
|
dependencies: cached.dependencies,
|
|
960
1023
|
sources: cached.sources,
|
|
961
1024
|
root: cached.root,
|
|
@@ -1634,4 +1697,4 @@ async function createWeappTailwindcssGeneratorFromRuntime(tailwindRuntime) {
|
|
|
1634
1697
|
return createWeappTailwindcssGenerator(await resolveTailwindSourceFromRuntime(tailwindRuntime));
|
|
1635
1698
|
}
|
|
1636
1699
|
//#endregion
|
|
1637
|
-
export { normalizeStringListOption as A,
|
|
1700
|
+
export { normalizeStringListOption as A, stableSerialize as B, findWorkspacePackageDir as C, normalizeTailwindcssRuntimeOptions as D, normalizeExtendLengthUnits as E, transformTailwindV4CssByTarget as F, loadTailwindV4DesignSystem as H, transformTailwindV4CssToWeapp as I, resolveCssMacroTailwindV4Source as L, createTailwindV4Engine$1 as M, hasCssCalcVariables as N, resolveRuntimeBareArbitraryValues as O, _defineProperty as P, getTailwindV4IncrementalGenerateCacheStats as R, findNearestPackageRoot as S, omitUndefined as T, resolveValidTailwindV4Candidates$1 as U, shouldUseUniAppWebRpxCompatibility as V, upsertTailwindV4CssSource as _, resolveGeneratorRuntimeBranch as a, isTailwindV4CssEntry as b, shouldUseNativeAppCssBranch as c, resolveTailwindV4SourceFromRuntime as d, resolveTailwindV4SourceFromRuntimeOptions as f, removeTailwindV4CssSource as g, hasConfiguredTailwindV4CssRoots as h, normalizeWeappTailwindcssGeneratorOptions as i, resolveBooleanObjectOption as j, resolveTailwindcssOptions as k, resolveUniUtsPlatform as l, filterTailwindV4CssSourceRoots as m, createWeappTailwindcssGeneratorFromRuntime as n, resolveRuntimeBranch as o, resolveTailwindV4SourceOptionsFromRuntime as p, resolveTailwindSourceFromRuntime as r, shouldUseMiniProgramCssBranch as s, createWeappTailwindcssGenerator as t, resolveTailwindV4Source$1 as u, groupCssEntriesByBase as v, findWorkspaceRoot as w, normalizeCssEntries as x, guessBasedirFromEntries as y, filterUnsupportedMiniProgramTailwindV4Candidates as z };
|
package/dist/generator.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-B1sYQpWu.cjs");
|
|
3
3
|
let _weapp_tailwindcss_engine = require("@weapp-tailwindcss/engine");
|
|
4
4
|
let _weapp_tailwindcss_postcss_transform = require("@weapp-tailwindcss/postcss/transform");
|
|
5
5
|
exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
|
package/dist/generator.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as transformTailwindV4CssByTarget, H as loadTailwindV4DesignSystem, I as transformTailwindV4CssToWeapp, d as resolveTailwindV4SourceFromRuntime, f as resolveTailwindV4SourceFromRuntimeOptions, i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromRuntime, p as resolveTailwindV4SourceOptionsFromRuntime, r as resolveTailwindSourceFromRuntime, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source } from "./generator-LqofzXgr.js";
|
|
2
2
|
export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromRuntime, loadTailwindV4DesignSystem, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromRuntime, resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-fg3euq-1.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
3
|
-
const require_compiler = require("./compiler-
|
|
2
|
+
const require_generator = require("./generator-B1sYQpWu.cjs");
|
|
3
|
+
const require_compiler = require("./compiler-TvqqdOMD.cjs");
|
|
4
4
|
const require_runtime_state = require("./runtime-state-BOzuVoKl.cjs");
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
6
|
-
const require_generated_css_marker = require("./generated-css-marker-
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-uf04Iolj.cjs");
|
|
6
|
+
const require_generated_css_marker = require("./generated-css-marker-C21q8hGM.cjs");
|
|
7
7
|
const require_cache = require("./cache-CzvIGfwS.cjs");
|
|
8
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
8
|
+
const require_hmr_timing = require("./hmr-timing-CXBDn0dl.cjs");
|
|
9
9
|
require("./final-css-cleanup-B6FUJC3z.cjs");
|
|
10
10
|
let node_fs = require("node:fs");
|
|
11
11
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as resolveSourceScanEntries, l as getRuntimeClassSetSignature } from "./tailwindcss-
|
|
2
|
-
import {
|
|
3
|
-
import { A as createTailwindRuntimeReadyPromise, B as invalidateCompilationScope, G as createCompilationDependencyChanges, I as AssetEmissionPlan, N as createDebug, V as recordCompilationDependencyChanges, a as beginCompilerShadowRun, c as getCompilerShadowRunSnapshot, f as getCompilerContext, i as disposeCompilerOwner, j as ensureRuntimeClassSet, n as createRuntimeAffectingSourceSignature, p as normalizeStyleHandlerMajorVersion, t as createCompilerRuntimeState, y as shouldSkipJsTransform, z as getCompilationScopeDependencyRevision } from "./compiler-
|
|
4
|
-
import { J as splitLocalCssImports, R as finalizeMiniProgramGeneratorCss, U as createRuntimeClassSetManager, Y as createSourceCandidateCollector, a as hasBundlerGeneratedCssMarker, c as annotateCssSourceTrace, dt as finalizeCompilerShadowRun, f as generateTailwindV4Css, i as createBundlerGeneratedCssMarker, it as hasTailwindRootDirectives, l as createCssSourceTraceCacheSignature, n as emitHmrTiming, ot as normalizeTailwindConfigDirectives, q as rewriteLocalCssImportRequestsForOutput, s as stripBundlerGeneratedCssMarkers, st as normalizeTailwindSourceForGenerator, u as createCssTokenSourceMap, ut as prependConfigDirective } from "./hmr-timing-
|
|
1
|
+
import { f as resolveSourceScanEntries, l as getRuntimeClassSetSignature } from "./tailwindcss-XNfJSlhp.js";
|
|
2
|
+
import { R as getTailwindV4IncrementalGenerateCacheStats, _ as upsertTailwindV4CssSource, g as removeTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots } from "./generator-LqofzXgr.js";
|
|
3
|
+
import { A as createTailwindRuntimeReadyPromise, B as invalidateCompilationScope, G as createCompilationDependencyChanges, I as AssetEmissionPlan, N as createDebug, V as recordCompilationDependencyChanges, a as beginCompilerShadowRun, c as getCompilerShadowRunSnapshot, f as getCompilerContext, i as disposeCompilerOwner, j as ensureRuntimeClassSet, n as createRuntimeAffectingSourceSignature, p as normalizeStyleHandlerMajorVersion, t as createCompilerRuntimeState, y as shouldSkipJsTransform, z as getCompilationScopeDependencyRevision } from "./compiler-v9sYta8W.js";
|
|
4
|
+
import { J as splitLocalCssImports, R as finalizeMiniProgramGeneratorCss, U as createRuntimeClassSetManager, Y as createSourceCandidateCollector, a as hasBundlerGeneratedCssMarker, c as annotateCssSourceTrace, dt as finalizeCompilerShadowRun, f as generateTailwindV4Css, i as createBundlerGeneratedCssMarker, it as hasTailwindRootDirectives, l as createCssSourceTraceCacheSignature, n as emitHmrTiming, ot as normalizeTailwindConfigDirectives, q as rewriteLocalCssImportRequestsForOutput, s as stripBundlerGeneratedCssMarkers, st as normalizeTailwindSourceForGenerator, u as createCssTokenSourceMap, ut as prependConfigDirective } from "./hmr-timing-CNo2hmaX.js";
|
|
5
5
|
import { a as createRuntimeCompilationBuildState, c as updateRuntimeCompilationBuildState, n as processCachedTask, o as removeRuntimeCompilationBuildStateFiles, r as buildRuntimeCompilationSnapshot, t as finalizeMiniProgramCssStructure } from "./final-css-cleanup-BOzhuhGz.js";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
package/dist/gulp.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_gulp = require("./gulp-
|
|
2
|
+
const require_gulp = require("./gulp-BhQhrDCx.cjs");
|
|
3
3
|
exports.WeappTailwindcss = require_gulp.createPlugins;
|
|
4
4
|
exports.createPlugins = require_gulp.createPlugins;
|
|
5
5
|
exports.weappTailwindcss = require_gulp.createPlugins;
|
package/dist/gulp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createPlugins } from "./gulp-
|
|
1
|
+
import { t as createPlugins } from "./gulp-ComuY3KW.js";
|
|
2
2
|
export { createPlugins as WeappTailwindcss, createPlugins, createPlugins as weappTailwindcss };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as resolveTailwindV4CssSourceBase, h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as source_scan_exports } from "./tailwindcss-
|
|
2
|
-
import { B as loadTailwindV4DesignSystem,
|
|
1
|
+
import { _ as resolveTailwindV4CssSourceBase, h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as source_scan_exports } from "./tailwindcss-XNfJSlhp.js";
|
|
2
|
+
import { B as stableSerialize, F as transformTailwindV4CssByTarget, H as loadTailwindV4DesignSystem, N as hasCssCalcVariables, T as omitUndefined, a as resolveGeneratorRuntimeBranch, d as resolveTailwindV4SourceFromRuntime, i as normalizeWeappTailwindcssGeneratorOptions, p as resolveTailwindV4SourceOptionsFromRuntime, s as shouldUseMiniProgramCssBranch, u as resolveTailwindV4Source$1, z as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-LqofzXgr.js";
|
|
3
3
|
import { o as transformCssMacroCss, r as hasCssMacroTailwindV4InternalAtRules, t as hasCssMacroStyleOptions } from "./auto-ENr4xzzw.js";
|
|
4
|
-
import { C as babelParse, H as getTailwindGenerationSessionPool, J as createCssFragment, K as mergeCompilationDependencyChanges, L as composeGenerationArtifact, N as createDebug, P as normalizeFrameworkStylePlatform, R as consumeCompilationScopeChanges, S as replaceWxml, T as traverse, U as getCompilationSessionPool, W as runCompilerOwnerActivity, Y as createGenerationArtifact, l as recordCompilerShadowReport, m as resolveStyleOptionsFromContext, o as completeCompilerShadowReportRun, q as md5Hash, r as createStylePlatformAdapter, s as getCompilerShadowRunRevision, u as getFrameworkCompilerSession, v as createAttributeMatcher } from "./compiler-
|
|
4
|
+
import { C as babelParse, H as getTailwindGenerationSessionPool, J as createCssFragment, K as mergeCompilationDependencyChanges, L as composeGenerationArtifact, N as createDebug, P as normalizeFrameworkStylePlatform, R as consumeCompilationScopeChanges, S as replaceWxml, T as traverse, U as getCompilationSessionPool, W as runCompilerOwnerActivity, Y as createGenerationArtifact, l as recordCompilerShadowReport, m as resolveStyleOptionsFromContext, o as completeCompilerShadowReportRun, q as md5Hash, r as createStylePlatformAdapter, s as getCompilerShadowRunRevision, u as getFrameworkCompilerSession, v as createAttributeMatcher } from "./compiler-v9sYta8W.js";
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import process from "node:process";
|
|
@@ -1389,15 +1389,24 @@ function mergeGeneratorResults(generatedResults) {
|
|
|
1389
1389
|
if (generatedResults.length === 1) return firstGenerated;
|
|
1390
1390
|
const incrementalCssResults = generatedResults.map((item) => item.incrementalCss).filter((css) => typeof css === "string");
|
|
1391
1391
|
const incrementalRawCssResults = generatedResults.map((item) => item.incrementalRawCss).filter((css) => typeof css === "string");
|
|
1392
|
+
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
1393
|
+
const conflictingProperties = /* @__PURE__ */ new Set();
|
|
1394
|
+
for (const result of generatedResults) for (const [name, value] of result.customPropertyValues ?? []) {
|
|
1395
|
+
if (customPropertyValues.has(name) && customPropertyValues.get(name) !== value) conflictingProperties.add(name);
|
|
1396
|
+
customPropertyValues.set(name, value);
|
|
1397
|
+
}
|
|
1398
|
+
for (const name of conflictingProperties) customPropertyValues.delete(name);
|
|
1392
1399
|
return {
|
|
1393
1400
|
...firstGenerated,
|
|
1394
1401
|
css: deduplicateGeneratedCssRules(generatedResults.map((item) => item.css).join("\n")),
|
|
1395
1402
|
rawCss: deduplicateGeneratedCssRules(generatedResults.map((item) => item.rawCss).join("\n")),
|
|
1403
|
+
customPropertyContextCss: generatedResults.map((item) => item.customPropertyContextCss ?? item.rawCss).join("\n"),
|
|
1396
1404
|
incrementalCss: incrementalCssResults.length === generatedResults.length ? incrementalCssResults.filter(Boolean).join("\n") : void 0,
|
|
1397
1405
|
incrementalRawCss: incrementalRawCssResults.length === generatedResults.length ? incrementalRawCssResults.filter(Boolean).join("\n") : void 0,
|
|
1398
1406
|
classSet: new Set(generatedResults.flatMap((item) => [...item.classSet])),
|
|
1399
1407
|
dependencies: [...new Set(generatedResults.flatMap((item) => item.dependencies))],
|
|
1400
|
-
sources: generatedResults.flatMap((item) => item.sources)
|
|
1408
|
+
sources: generatedResults.flatMap((item) => item.sources),
|
|
1409
|
+
customPropertyValues
|
|
1401
1410
|
};
|
|
1402
1411
|
}
|
|
1403
1412
|
//#endregion
|
|
@@ -1462,12 +1471,12 @@ function collectRpxThemeRiskSources(sources) {
|
|
|
1462
1471
|
for (const css of new Set(sources)) for (const name of collectRpxThemeVariables(css)) variables.add(name);
|
|
1463
1472
|
return [...variables];
|
|
1464
1473
|
}
|
|
1465
|
-
function warnRpxThemeRisk(session, variables,
|
|
1474
|
+
function warnRpxThemeRisk(session, variables, generatedCss) {
|
|
1466
1475
|
if (warnedSessions.has(session) || variables.length === 0) return;
|
|
1467
|
-
const usage = inspectRpxCalcUsage(
|
|
1468
|
-
const
|
|
1476
|
+
const usage = inspectRpxCalcUsage(generatedCss, new Set(variables));
|
|
1477
|
+
const generationHint = usage === void 0 ? "当前生成阶段的 CSS 无法完成诊断,请检查最终 WXSS。" : usage.variables.length > 0 || usage.inlineRpx ? `当前生成阶段仍含 calc:${[...usage.variables, ...usage.inlineRpx ? ["内联 rpx"] : []].join(", ")};后续构建处理可能将其静态化,最终状态以 WXSS 为准。` : "当前生成阶段未检测到相关 calc;这不代表已验证最终产物、所有作用域和设备。";
|
|
1469
1478
|
warnedSessions.add(session);
|
|
1470
|
-
logger.warn(`[tailwindcss@4][rpx-theme] @theme 中使用 rpx 的主题变量:${variables.join(", ")}。${
|
|
1479
|
+
logger.warn(`[tailwindcss@4][rpx-theme] @theme 中使用 rpx 的主题变量:${variables.join(", ")}。${generationHint} 微信 WXSS 可能先独立换算或量化基数再乘法,造成尺寸偏差,具体取整算法尚未确认。固定像素尺寸优先使用 px,需要缩放时在构建期输出最终静态 rpx;偶数或较大 rpx 也不保证准确。请检查最终 WXSS 并在目标设备验证:https://tw.weapp.dev/docs/issues/spacing-rpx`);
|
|
1471
1480
|
}
|
|
1472
1481
|
//#endregion
|
|
1473
1482
|
//#region src/generation/framework-postcss.ts
|
|
@@ -2549,17 +2558,8 @@ function setLimitedCacheValue(cache, key, value) {
|
|
|
2549
2558
|
}
|
|
2550
2559
|
cache.set(key, value);
|
|
2551
2560
|
}
|
|
2552
|
-
function createStableJson(value) {
|
|
2553
|
-
if (value === void 0) return "undefined";
|
|
2554
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
2555
|
-
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
2556
|
-
return `{${Object.keys(value).sort().map((key) => {
|
|
2557
|
-
const record = value;
|
|
2558
|
-
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
2559
|
-
}).join(",")}}`;
|
|
2560
|
-
}
|
|
2561
2561
|
function createLegacyCompatTransformCacheKey(source, options) {
|
|
2562
|
-
return `${
|
|
2562
|
+
return `${stableSerialize(options)}\0${source}`;
|
|
2563
2563
|
}
|
|
2564
2564
|
function resolveLegacyCompatCssSource(rawSource) {
|
|
2565
2565
|
const cached = legacyCompatSourceCache.get(rawSource);
|
|
@@ -2753,6 +2753,10 @@ async function finalizeDeferredGeneratorCss(context) {
|
|
|
2753
2753
|
const rawCss = stripTailwindBanner(css);
|
|
2754
2754
|
const generationCss = generated.target === "weapp" && (hasCssMacroStyleOptions(generatorStyleOptions) || hasCssMacroTailwindV4InternalAtRules(rawCss)) ? await transformCssMacroCss(rawCss, generatorStyleOptions) : rawCss;
|
|
2755
2755
|
const normalizedCss = generated.target === "weapp" ? await normalizeMiniProgramGeneratedCssForPostcss(generationCss, {
|
|
2756
|
+
cssCalc: generatorStyleOptions.cssCalc,
|
|
2757
|
+
cssOptions: generatorStyleOptions.cssOptions,
|
|
2758
|
+
customPropertyValues: generatorStyleOptions.customPropertyValues,
|
|
2759
|
+
contextCss: generated.customPropertyContextCss ?? generated.rawCss,
|
|
2756
2760
|
preservePreflight: true,
|
|
2757
2761
|
preserveRawClassRules: true
|
|
2758
2762
|
}) : generationCss;
|
|
@@ -3191,6 +3195,23 @@ async function prepareGeneratorInputs(context) {
|
|
|
3191
3195
|
};
|
|
3192
3196
|
}
|
|
3193
3197
|
//#endregion
|
|
3198
|
+
//#region src/generation/pipeline/style-context.ts
|
|
3199
|
+
/** 先确定同一输出的完整级联,再从原始声明生成兼容 CSS。 */
|
|
3200
|
+
async function mergeGeneratorResultsForOutput(results, options) {
|
|
3201
|
+
const merged = mergeGeneratorResults(results);
|
|
3202
|
+
if (!merged || results.length < 2 || merged.target === "tailwind" || !hasCssCalcVariables(options)) return merged;
|
|
3203
|
+
const css = await transformTailwindV4CssByTarget(merged.rawCss, merged.target, {
|
|
3204
|
+
...options,
|
|
3205
|
+
customPropertyContextCss: [options.customPropertyContextCss, merged.customPropertyContextCss].filter(Boolean).join("\n")
|
|
3206
|
+
});
|
|
3207
|
+
return {
|
|
3208
|
+
...merged,
|
|
3209
|
+
css,
|
|
3210
|
+
incrementalCss: void 0,
|
|
3211
|
+
incrementalRawCss: void 0
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3214
|
+
//#endregion
|
|
3194
3215
|
//#region src/generation/pipeline/execution.ts
|
|
3195
3216
|
async function executeGeneratorPipeline(context) {
|
|
3196
3217
|
return runCompilerOwnerActivity(context.runtimeState, () => executeGeneratorPipelineWithOwner(context, getCompilationSessionPool(context.runtimeState), getTailwindGenerationSessionPool(context.runtimeState)));
|
|
@@ -3200,6 +3221,12 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
3200
3221
|
await runtimeState.readyPromise;
|
|
3201
3222
|
const compilerSession = options.compilation?.enabled ? getFrameworkCompilerSession(runtimeState, opts) : void 0;
|
|
3202
3223
|
const { isolateCurrentCssCandidates, runtimeWithCurrentCss, generatorSourceRecords, generatorStyleOptions, configuredContainerCompat, sourceConcurrency, preparedGenerationInputs } = await prepareGeneratorInputs(context);
|
|
3224
|
+
if (hasCssCalcVariables(generatorStyleOptions)) generatorStyleOptions.customPropertyContextCss = [
|
|
3225
|
+
generatorStyleOptions.customPropertyContextCss,
|
|
3226
|
+
context.generatedUserCssRawSource,
|
|
3227
|
+
options.frameworkProcessedUserCss,
|
|
3228
|
+
...preparedGenerationInputs.map((input) => input.generatorSource.css)
|
|
3229
|
+
].filter(Boolean).join("\n");
|
|
3203
3230
|
const generatePreparedInputs = async (candidateSets) => {
|
|
3204
3231
|
return runWithConcurrency(preparedGenerationInputs.map((input) => async () => {
|
|
3205
3232
|
const projectedCandidates = candidateSets?.get(input.sourceId);
|
|
@@ -3245,7 +3272,7 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
3245
3272
|
if (compilerSession && options.compilation?.changes) compilerSession.invalidate(options.compilation.changes.map((change) => change.id));
|
|
3246
3273
|
await compilerSession?.syncScope(options.compilation?.scope.id ?? options.outputFile ?? file, preparedGenerationInputs.map((input) => input.sourceId));
|
|
3247
3274
|
const results = await generatePreparedInputs(compilation.candidatesBySource);
|
|
3248
|
-
const merged =
|
|
3275
|
+
const merged = await mergeGeneratorResultsForOutput(results.map((result) => result.generated), generatorStyleOptions);
|
|
3249
3276
|
return merged ? {
|
|
3250
3277
|
classSet: merged.classSet,
|
|
3251
3278
|
dependenciesBySource: results.map((result) => [result.sourceId, resolveCompilationDependencies(result.generated.dependencies)]),
|
|
@@ -3266,8 +3293,9 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
3266
3293
|
snapshot: execution.value.snapshot
|
|
3267
3294
|
};
|
|
3268
3295
|
compilationRevision = execution.compilation.revision;
|
|
3269
|
-
} else generated =
|
|
3296
|
+
} else generated = await mergeGeneratorResultsForOutput((await generatePreparedInputs()).map((result) => result.generated), generatorStyleOptions);
|
|
3270
3297
|
if (!generated) return;
|
|
3298
|
+
if (generated.customPropertyContextCss) generatorStyleOptions.customPropertyContextCss = generated.customPropertyContextCss;
|
|
3271
3299
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
3272
3300
|
const hasMatchedCssSourceFile = generatorSourceRecords.some((record) => record.metadata.matchedCssSourceFile);
|
|
3273
3301
|
const hasExplicitCssSource = generatorSourceRecords.some(({ metadata }) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-fg3euq-1.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
3
|
-
const require_compiler = require("./compiler-
|
|
4
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
5
|
-
const require_generated_css_marker = require("./generated-css-marker-
|
|
2
|
+
const require_generator = require("./generator-B1sYQpWu.cjs");
|
|
3
|
+
const require_compiler = require("./compiler-TvqqdOMD.cjs");
|
|
4
|
+
const require_tailwindcss = require("./tailwindcss-uf04Iolj.cjs");
|
|
5
|
+
const require_generated_css_marker = require("./generated-css-marker-C21q8hGM.cjs");
|
|
6
6
|
let node_process = require("node:process");
|
|
7
7
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
8
8
|
let _weapp_tailwindcss_engine = require("@weapp-tailwindcss/engine");
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_gulp = require("./gulp-
|
|
3
|
+
const require_generator = require("./generator-B1sYQpWu.cjs");
|
|
4
|
+
const require_gulp = require("./gulp-BhQhrDCx.cjs");
|
|
5
5
|
const require_postcss = require("./postcss.cjs");
|
|
6
|
-
const require_vite = require("./vite-
|
|
7
|
-
const require_webpack = require("./webpack-
|
|
6
|
+
const require_vite = require("./vite-BVcj7Ht9.cjs");
|
|
7
|
+
const require_webpack = require("./webpack-CWMoTWzF.cjs");
|
|
8
8
|
require("./webpack.cjs");
|
|
9
9
|
let _weapp_tailwindcss_postcss_transform = require("@weapp-tailwindcss/postcss/transform");
|
|
10
10
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveMpxPlatform, resolvePlatform, resolveTaroPlatform, resolveUniAppXPlatform, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform } from "./framework.js";
|
|
2
|
-
import { t as createWeappTailwindcssGenerator } from "./generator-
|
|
3
|
-
import { t as createPlugins } from "./gulp-
|
|
2
|
+
import { t as createWeappTailwindcssGenerator } from "./generator-LqofzXgr.js";
|
|
3
|
+
import { t as createPlugins } from "./gulp-ComuY3KW.js";
|
|
4
4
|
import weappTailwindcssPostcssPlugin from "./postcss.js";
|
|
5
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
6
|
-
import { n as weappTailwindcssPackageDir } from "./webpack-
|
|
5
|
+
import { t as WeappTailwindcss } from "./vite-Bd-Ig5Dy.js";
|
|
6
|
+
import { n as weappTailwindcssPackageDir } from "./webpack-DtAZoEth.js";
|
|
7
7
|
import "./webpack.js";
|
|
8
8
|
import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss/transform";
|
|
9
9
|
export { WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveMpxPlatform, resolvePlatform, resolveTaroPlatform, resolveUniAppXPlatform, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform, unitConversionComposeRules, unitConversionPresets, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-fg3euq-1.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
3
|
-
const require_compiler = require("./compiler-
|
|
2
|
+
const require_generator = require("./generator-B1sYQpWu.cjs");
|
|
3
|
+
const require_compiler = require("./compiler-TvqqdOMD.cjs");
|
|
4
4
|
const require_defaults = require("./defaults-CyX5iO9y.cjs");
|
|
5
|
-
const require_generated_css_marker = require("./generated-css-marker-
|
|
5
|
+
const require_generated_css_marker = require("./generated-css-marker-C21q8hGM.cjs");
|
|
6
6
|
require("./final-css-cleanup-B6FUJC3z.cjs");
|
|
7
7
|
require("./css-cleanup-B6FUJC3z.cjs");
|
|
8
8
|
let node_path = require("node:path");
|
package/dist/postcss.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_generator = require("./generator-
|
|
5
|
+
const require_generator = require("./generator-B1sYQpWu.cjs");
|
|
6
6
|
const weappTailwindcssPostcssPlugin = (0, require("@weapp-tailwindcss/postcss/plugin").createWeappTailwindcssPostcssPlugin)({
|
|
7
7
|
compiledSourceScan: true,
|
|
8
8
|
createGenerator: (source) => {
|