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.
Files changed (77) hide show
  1. package/dist/bundlers/vite/css-calc-stage.d.ts +8 -0
  2. package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +1 -0
  3. package/dist/bundlers/vite/css-finalizer/css-scope-graph.d.ts +5 -0
  4. package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +1 -1
  5. package/dist/bundlers/vite/css-finalizer/options.d.ts +1 -0
  6. package/dist/bundlers/vite/generate-bundle/css-cache-task.d.ts +1 -0
  7. package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +2 -0
  8. package/dist/bundlers/vite/generate-bundle/css-transform-result.d.ts +1 -0
  9. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +3 -3
  10. package/dist/bundlers/vite/generate-bundle/scoped-generator-runtime-cache.d.ts +5 -0
  11. package/dist/bundlers/vite/generate-bundle/scoped-generator-sources.d.ts +36 -0
  12. package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +6 -1
  13. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +2 -2
  14. package/dist/bundlers/vite/generate-bundle/source-trace.d.ts +2 -0
  15. package/dist/bundlers/vite/runtime-class-set/cache.d.ts +14 -0
  16. package/dist/bundlers/vite/runtime-class-set/invalidation-plugin.d.ts +6 -0
  17. package/dist/bundlers/vite/runtime-class-set/lifecycle.d.ts +12 -0
  18. package/dist/bundlers/vite/runtime-class-set.d.ts +1 -0
  19. package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +1 -2
  20. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +1 -0
  21. package/dist/{compiler-DbwS3329.cjs → compiler-TvqqdOMD.cjs} +50 -38
  22. package/dist/{compiler-CThodfGH.js → compiler-v9sYta8W.js} +35 -30
  23. package/dist/core/compiler/generation-cache.d.ts +4 -2
  24. package/dist/core/compiler/root-store.d.ts +1 -1
  25. package/dist/core/compiler/source.d.ts +7 -0
  26. package/dist/core.cjs +1 -1
  27. package/dist/core.js +1 -1
  28. package/dist/{scoped-generator-DlQrVbuC.js → css-cleanup-B3xP5Qph.js} +26 -23
  29. package/dist/{generated-css-marker-B0RyziOH.cjs → generated-css-marker-nqjR6ntO.cjs} +102 -26
  30. package/dist/generation/pipeline/style-context.d.ts +3 -0
  31. package/dist/{generator-CxauQbx3.cjs → generator-B1sYQpWu.cjs} +165 -90
  32. package/dist/{generator-oKZ5mCJ5.js → generator-LqofzXgr.js} +155 -92
  33. package/dist/generator.cjs +1 -1
  34. package/dist/generator.js +1 -1
  35. package/dist/{gulp-DhddVxGA.js → gulp-BCV0gOMb.js} +4 -4
  36. package/dist/{gulp-CngHA9cU.cjs → gulp-DrX6QS3N.cjs} +5 -5
  37. package/dist/gulp.cjs +1 -1
  38. package/dist/gulp.js +1 -1
  39. package/dist/{hmr-timing-Dc4c1VRg.cjs → hmr-timing-B56wp7y-.cjs} +4 -4
  40. package/dist/{hmr-timing-xPpat-km.js → hmr-timing-Bb54exB0.js} +102 -26
  41. package/dist/index.cjs +4 -4
  42. package/dist/index.js +4 -4
  43. package/dist/{pipeline-helpers-EUud9R2K.cjs → pipeline-helpers-DJ3VZ01J.cjs} +3 -3
  44. package/dist/postcss.cjs +1 -1
  45. package/dist/postcss.js +1 -1
  46. package/dist/presets.cjs +2 -2
  47. package/dist/presets.js +2 -2
  48. package/dist/project-sources/candidates/view-memo.d.ts +7 -0
  49. package/dist/rspack.cjs +2 -2
  50. package/dist/rspack.js +2 -2
  51. package/dist/{scoped-generator-lbTwL6mD.cjs → scoped-generator-DqNb8nJG.cjs} +31 -24
  52. package/dist/{source-candidate-scan-signature-BjVQYL-C.js → source-candidate-scan-signature-BWLf4tuO.js} +2 -2
  53. package/dist/{source-candidate-scan-signature-nG-rg809.cjs → source-candidate-scan-signature-_ohG0ePd.cjs} +2 -2
  54. package/dist/tailwindcss/v4/rpx-theme-warning.d.ts +1 -1
  55. package/dist/tailwindcss/v4-engine/generator/raw-generation.d.ts +30 -0
  56. package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +3 -0
  57. package/dist/tailwindcss/v4-engine/types.d.ts +2 -0
  58. package/dist/{tailwindcss-kSd0ykiX.js → tailwindcss-XNfJSlhp.js} +2 -2
  59. package/dist/{tailwindcss-U3KIUegn.cjs → tailwindcss-uf04Iolj.cjs} +2 -2
  60. package/dist/{transform-DVg4q8hh.cjs → transform-CxVM0PfA.cjs} +3 -3
  61. package/dist/{transform-BAon9ykq.js → transform-D0NXKPmD.js} +3 -3
  62. package/dist/utils/stable-serialize.d.ts +1 -0
  63. package/dist/vite/web.cjs +1 -1
  64. package/dist/vite/web.js +1 -1
  65. package/dist/{vite-IX83wh_L.cjs → vite-C3Zh6iYK.cjs} +434 -209
  66. package/dist/{vite-D-RGkmOE.js → vite-D6_FxvdM.js} +434 -209
  67. package/dist/vite.cjs +1 -1
  68. package/dist/vite.js +1 -1
  69. package/dist/weapp-tw-css-generation-loader.cjs +1 -1
  70. package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
  71. package/dist/{web-DHfZ_KC9.cjs → web-BzeWG_XO.cjs} +442 -155
  72. package/dist/{web--kA4HUTm.js → web-K3qAX4sN.js} +431 -156
  73. package/dist/{webpack-Bhkd27Rs.js → webpack-BZBqKB4Y.js} +6 -6
  74. package/dist/{webpack-BetjemzT.cjs → webpack-Dbj2uykF.cjs} +8 -8
  75. package/dist/webpack.cjs +1 -1
  76. package/dist/webpack.js +1 -1
  77. package/package.json +5 -4
@@ -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
- createStableJson(source.baseFallbacks),
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
- createStableJson(styleOptions)
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 = collectCustomPropertyValues(options.compatibleSource.css);
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 resolveGenerationStyleContext(sourceCss, generatedCss, options) {
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
- if (calc !== true && !include?.length) return options;
788
- const customPropertyValues = collectCustomPropertyValues(sourceCss);
789
- mergeCustomPropertyValues(customPropertyValues, generatedCss);
790
- for (const [name, value] of options?.customPropertyValues ?? []) customPropertyValues.set(name, value);
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
- customPropertyValues
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/engine.ts
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
- const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
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 incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
944
- ...createIncrementalStyleOptions(styleOptions),
945
- customPropertyValues: cached.customPropertyValues
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 = [cached.rawCss, rawCss].filter(Boolean).join("\n");
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, loadTailwindV4DesignSystem as B, findWorkspacePackageDir as C, normalizeTailwindcssRuntimeOptions as D, normalizeExtendLengthUnits as E, transformTailwindV4CssToWeapp as F, resolveCssMacroTailwindV4Source as I, getTailwindV4IncrementalGenerateCacheStats as L, createTailwindV4Engine$1 as M, _defineProperty as N, resolveRuntimeBareArbitraryValues as O, transformTailwindV4CssByTarget as P, filterUnsupportedMiniProgramTailwindV4Candidates as R, findNearestPackageRoot as S, omitUndefined as T, resolveValidTailwindV4Candidates$1 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, shouldUseUniAppWebRpxCompatibility as z };
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 };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_generator = require("./generator-CxauQbx3.cjs");
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 { B as loadTailwindV4DesignSystem, F as transformTailwindV4CssToWeapp, P as transformTailwindV4CssByTarget, 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-oKZ5mCJ5.js";
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,7 +1,7 @@
1
- import { f as resolveSourceScanEntries, l as getRuntimeClassSetSignature } from "./tailwindcss-kSd0ykiX.js";
2
- import { L as getTailwindV4IncrementalGenerateCacheStats, _ as upsertTailwindV4CssSource, g as removeTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots } from "./generator-oKZ5mCJ5.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-CThodfGH.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-xPpat-km.js";
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-Bb54exB0.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";
@@ -1,11 +1,11 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-fg3euq-1.cjs");
2
- const require_generator = require("./generator-CxauQbx3.cjs");
3
- const require_compiler = require("./compiler-DbwS3329.cjs");
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-U3KIUegn.cjs");
6
- const require_generated_css_marker = require("./generated-css-marker-B0RyziOH.cjs");
5
+ const require_tailwindcss = require("./tailwindcss-uf04Iolj.cjs");
6
+ const require_generated_css_marker = require("./generated-css-marker-nqjR6ntO.cjs");
7
7
  const require_cache = require("./cache-CzvIGfwS.cjs");
8
- const require_hmr_timing = require("./hmr-timing-Dc4c1VRg.cjs");
8
+ const require_hmr_timing = require("./hmr-timing-B56wp7y-.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);
package/dist/gulp.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_gulp = require("./gulp-CngHA9cU.cjs");
2
+ const require_gulp = require("./gulp-DrX6QS3N.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-DhddVxGA.js";
1
+ import { t as createPlugins } from "./gulp-BCV0gOMb.js";
2
2
  export { createPlugins as WeappTailwindcss, createPlugins, createPlugins as weappTailwindcss };
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-fg3euq-1.cjs");
2
- const require_generator = require("./generator-CxauQbx3.cjs");
3
- const require_compiler = require("./compiler-DbwS3329.cjs");
4
- const require_tailwindcss = require("./tailwindcss-U3KIUegn.cjs");
5
- const require_generated_css_marker = require("./generated-css-marker-B0RyziOH.cjs");
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-nqjR6ntO.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");