weapp-tailwindcss 5.0.11 → 5.0.13

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 (109) hide show
  1. package/dist/{bundle-state-BwtEqxvU.js → bundle-state-CKWeTEhv.js} +2 -40
  2. package/dist/{bundle-state-CXzPknlT.mjs → bundle-state-zQ2MrDdi.mjs} +2 -34
  3. package/dist/bundlers/gulp/vinyl-transform.d.ts +1 -1
  4. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +7 -2
  5. package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -0
  6. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
  7. package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +7 -0
  8. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +4 -0
  9. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +15 -0
  10. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +12 -0
  11. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +22 -0
  12. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +5 -22
  13. package/dist/bundlers/shared/generator-css/types.d.ts +2 -0
  14. package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
  15. package/dist/bundlers/shared/hmr-timing.d.ts +1 -0
  16. package/dist/bundlers/vite/css-memory.d.ts +27 -0
  17. package/dist/bundlers/vite/generate-bundle/bundle-file-names.d.ts +2 -0
  18. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +8 -0
  19. package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +4 -0
  20. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -0
  21. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +9 -7
  22. package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +7 -0
  23. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +58 -0
  24. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +31 -0
  25. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +77 -0
  26. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +53 -0
  27. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
  28. package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +4 -0
  29. package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +21 -0
  30. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
  31. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +29 -0
  32. package/dist/bundlers/vite/generate-bundle/timing.d.ts +1 -0
  33. package/dist/bundlers/vite/generate-bundle/types.d.ts +7 -0
  34. package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +20 -0
  35. package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +6 -0
  36. package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
  37. package/dist/bundlers/vite/hot-css-modules.d.ts +5 -0
  38. package/dist/bundlers/vite/map-cache.d.ts +2 -0
  39. package/dist/bundlers/vite/processed-css-assets.d.ts +16 -0
  40. package/dist/bundlers/vite/resolve-app-type.d.ts +1 -2
  41. package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +13 -0
  42. package/dist/bundlers/vite/source-candidates.d.ts +9 -0
  43. package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
  44. package/dist/bundlers/vite/source-scan.d.ts +1 -1
  45. package/dist/bundlers/vite/weapp-vite-config.d.ts +3 -0
  46. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +11 -8
  47. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
  48. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +5 -0
  49. package/dist/cache/index.d.ts +4 -0
  50. package/dist/cli.js +9 -2
  51. package/dist/cli.mjs +8 -1
  52. package/dist/core.d.ts +7 -0
  53. package/dist/core.js +8 -5
  54. package/dist/core.mjs +8 -5
  55. package/dist/css-macro.js +1 -1
  56. package/dist/css-macro.mjs +1 -1
  57. package/dist/{defaults-DH0ZQRhy.mjs → defaults-Bqx18S1f.mjs} +2 -35
  58. package/dist/{defaults-Boc26eel.js → defaults-C_J_kBpw.js} +2 -35
  59. package/dist/defaults.js +1 -1
  60. package/dist/defaults.mjs +1 -1
  61. package/dist/framework/index.d.ts +59 -0
  62. package/dist/framework.d.ts +1 -0
  63. package/dist/framework.js +198 -0
  64. package/dist/framework.mjs +180 -0
  65. package/dist/{generator-ChgOWNOj.js → generator-CzpArpCL.js} +1 -1
  66. package/dist/{generator-h2XRiJ9-.mjs → generator-ITLd7PTl.mjs} +1 -1
  67. package/dist/generator.js +2 -2
  68. package/dist/generator.mjs +2 -2
  69. package/dist/{gulp-Be88jhoY.mjs → gulp-DfOQERcV.mjs} +137 -23
  70. package/dist/{gulp-CHtZF-oT.js → gulp-XT8Jc7lH.js} +137 -23
  71. package/dist/gulp.js +1 -1
  72. package/dist/gulp.mjs +1 -1
  73. package/dist/{hmr-timing-BkivBZvN.js → hmr-timing-BMftW7Us.js} +354 -225
  74. package/dist/{hmr-timing-Ct5w4hdM.mjs → hmr-timing-DQIP_8qP.mjs} +341 -225
  75. package/dist/index.d.ts +1 -0
  76. package/dist/index.js +20 -4
  77. package/dist/index.mjs +6 -5
  78. package/dist/postcss.js +9 -10
  79. package/dist/postcss.mjs +7 -5
  80. package/dist/{precheck-CY9oaH49.js → precheck-B0Z8yW7E.js} +108 -27
  81. package/dist/{precheck-BpHxsWRd.mjs → precheck-CRI90iL1.mjs} +109 -28
  82. package/dist/presets.js +3 -3
  83. package/dist/presets.mjs +3 -3
  84. package/dist/tailwindcss/source-scan.d.ts +1 -0
  85. package/dist/tailwindcss/v3-engine/generator.d.ts +17 -0
  86. package/dist/tailwindcss/v3-engine/index.d.ts +1 -1
  87. package/dist/tailwindcss/v3-engine/types.d.ts +1 -0
  88. package/dist/tailwindcss/v4-engine/generator.d.ts +19 -0
  89. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  90. package/dist/{tailwindcss-Bfy2egdX.mjs → tailwindcss-DTq3uYBK.mjs} +2 -2
  91. package/dist/{tailwindcss-DbbAKAZP.js → tailwindcss-DZEwT3C_.js} +3 -3
  92. package/dist/{transform-r5evL6Hn.mjs → transform-DfcEjsZF.mjs} +29 -21
  93. package/dist/{transform-Cd634UZV.js → transform-YmrmxuF3.js} +29 -21
  94. package/dist/types/user-defined-options/general.d.ts +3 -1
  95. package/dist/{utils-Dolmt8EO.js → utils-BCa37Wqj.js} +2 -17
  96. package/dist/{utils-DsaS975I.mjs → utils-DodxWHGz.mjs} +2 -17
  97. package/dist/{v3-engine-D0yA9ZkF.js → v3-engine-2rrgylhn.js} +194 -34
  98. package/dist/{v3-engine-CFkP6dWF.mjs → v3-engine-C6eJ0YzK.mjs} +176 -34
  99. package/dist/{vite-j9cB2Ff1.js → vite-CXHVsHmX.js} +2071 -1160
  100. package/dist/{vite-Bd8qf9dK.mjs → vite-DjI09vVN.mjs} +2071 -1160
  101. package/dist/vite.js +1 -1
  102. package/dist/vite.mjs +1 -1
  103. package/dist/weapp-tw-css-import-rewrite-loader.js +476 -217
  104. package/dist/weapp-tw-runtime-classset-loader.js +25 -0
  105. package/dist/{webpack-DPdrcC2X.mjs → webpack-BcPpnT90.mjs} +251 -40
  106. package/dist/{webpack-CJAOcYEO.js → webpack-CfkUkMXG.js} +254 -43
  107. package/dist/webpack.js +1 -1
  108. package/dist/webpack.mjs +1 -1
  109. package/package.json +10 -5
@@ -1,11 +1,12 @@
1
1
  import { a as transformCssMacroCss, n as hasCssMacroTailwindPlugin, o as withCssMacroStyleOptions, r as hasCssMacroTailwindV4Directive, t as hasCssMacroStyleOptions } from "./auto-Cl8_hsG6.mjs";
2
2
  import { createRequire } from "node:module";
3
- import { createStyleHandler, postcss, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss } from "@weapp-tailwindcss/postcss";
4
- import * as tailwindcssPatch from "tailwindcss-patch";
5
- import { TailwindcssPatcher, createTailwindV4Engine, extractRawCandidates, extractSourceCandidates, isBareArbitraryValuesEnabled, loadTailwindV4DesignSystem, resolveBareArbitraryValueCandidate, resolveProjectSourceFiles, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions } from "tailwindcss-patch";
6
3
  import fs, { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
7
4
  import path from "node:path";
8
5
  import process from "node:process";
6
+ import { createStyleHandler, postcss, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss } from "@weapp-tailwindcss/postcss";
7
+ import { LRUCache } from "lru-cache";
8
+ import * as tailwindcssPatch from "tailwindcss-patch";
9
+ import { TailwindcssPatcher, createTailwindV4Engine, extractRawCandidates, extractSourceCandidates, isBareArbitraryValuesEnabled, loadTailwindV4DesignSystem, resolveBareArbitraryValueCandidate, resolveProjectSourceFiles, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions } from "tailwindcss-patch";
9
10
  import { logger } from "@weapp-tailwindcss/logger";
10
11
  import { defuOverrideArray } from "@weapp-tailwindcss/shared";
11
12
  import { fileURLToPath } from "node:url";
@@ -1877,8 +1878,12 @@ async function transformTailwindV4CssByTarget(css, target, options) {
1877
1878
  }
1878
1879
  //#endregion
1879
1880
  //#region src/tailwindcss/v4-engine/generator.ts
1880
- const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
1881
- const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
1881
+ const INCREMENTAL_GENERATE_CACHE_MAX$1 = 8;
1882
+ const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
1883
+ const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1 = 128;
1884
+ const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1 = 256 * 1024;
1885
+ const incrementalGenerateCache$1 = new LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX$1 });
1886
+ const incrementalGenerateTaskCache = new LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
1882
1887
  function collectCandidates(candidates) {
1883
1888
  return new Set(candidates ?? []);
1884
1889
  }
@@ -1974,6 +1979,9 @@ function collectCustomPropertyValues(css) {
1974
1979
  function mergeCustomPropertyValues(target, css) {
1975
1980
  for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
1976
1981
  }
1982
+ function shouldRebuildIncrementalEntry$1(cached, requestedCandidates, missingCandidates) {
1983
+ return cached.seenCandidates.size + missingCandidates.length > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1 || cached.css.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1 || cached.rawCss.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1 || requestedCandidates.size > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1;
1984
+ }
1977
1985
  function seedIncrementalGenerateCache(options) {
1978
1986
  const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
1979
1987
  const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
@@ -2061,6 +2069,18 @@ function createTailwindV4Engine$1(source) {
2061
2069
  root: cached.root,
2062
2070
  target: cached.target
2063
2071
  };
2072
+ if (shouldRebuildIncrementalEntry$1(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2073
+ const generated = await generateOnce(source, options);
2074
+ seedIncrementalGenerateCache({
2075
+ compatibleSource,
2076
+ generated,
2077
+ requestedCandidates,
2078
+ styleOptions,
2079
+ tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
2080
+ target
2081
+ });
2082
+ return generated;
2083
+ });
2064
2084
  return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2065
2085
  const designSystem = await cached.designSystemPromise;
2066
2086
  const normalizedMissing = normalizeRpxTextCandidates(missingCandidates);
@@ -2123,6 +2143,25 @@ function createTailwindV4Engine$1(source) {
2123
2143
  generate
2124
2144
  };
2125
2145
  }
2146
+ function getTailwindV4IncrementalGenerateCacheStats() {
2147
+ return {
2148
+ max: INCREMENTAL_GENERATE_CACHE_MAX$1,
2149
+ entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1,
2150
+ entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1,
2151
+ size: incrementalGenerateCache$1.size,
2152
+ taskMax: INCREMENTAL_GENERATE_TASK_CACHE_MAX,
2153
+ taskSize: incrementalGenerateTaskCache.size,
2154
+ entries: [...incrementalGenerateCache$1.entries()].map(([key, entry]) => ({
2155
+ key,
2156
+ candidates: entry.seenCandidates.size,
2157
+ classSet: entry.classSet.size,
2158
+ cssBytes: entry.css.length,
2159
+ rawCssBytes: entry.rawCss.length
2160
+ })),
2161
+ keys: [...incrementalGenerateCache$1.keys()],
2162
+ taskKeys: [...incrementalGenerateTaskCache.keys()]
2163
+ };
2164
+ }
2126
2165
  //#endregion
2127
2166
  //#region src/bundlers/shared/generator-css/config-directive.ts
2128
2167
  function quoteCssString(value) {
@@ -3046,6 +3085,7 @@ function addSourceScanDependencies(dependencies, files) {
3046
3085
  const VITE_SOURCE_CANDIDATE_PATTERN = FULL_SOURCE_SCAN_PATTERN;
3047
3086
  const VITE_TAILWIND_CSS_ENTRY_PATTERN = "**/*.{css,less,sass,scss,styl,stylus,pcss,postcss}";
3048
3087
  const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
3088
+ const tailwindConfigCssEntriesCache = /* @__PURE__ */ new Map();
3049
3089
  function parseImportSourceParam(params) {
3050
3090
  const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
3051
3091
  if (!match) return;
@@ -3079,6 +3119,13 @@ function createCssEntriesCacheKey(css, base, dependencies) {
3079
3119
  dependencies
3080
3120
  });
3081
3121
  }
3122
+ function createDependencyExcludeEntries(files) {
3123
+ return [...files].map((file) => ({
3124
+ base: path.dirname(file),
3125
+ negated: true,
3126
+ pattern: path.basename(file)
3127
+ }));
3128
+ }
3082
3129
  async function statConfigDependency(file) {
3083
3130
  try {
3084
3131
  const stats = await stat(file);
@@ -3227,6 +3274,12 @@ async function resolveTailwindV3CssEntryScan(options, patcher) {
3227
3274
  } catch {
3228
3275
  return;
3229
3276
  }
3277
+ const cssConfigEntries = await resolveTailwindConfigEntriesFromCssCached(css, path.dirname(cssEntry));
3278
+ if (cssConfigEntries) {
3279
+ addSourceScanDependencies(dependencies, cssConfigEntries.dependencies);
3280
+ entries.push(...cssConfigEntries.entries);
3281
+ return;
3282
+ }
3230
3283
  const source = await resolveTailwindV3Source({
3231
3284
  ...sourceOptions,
3232
3285
  base: path.dirname(cssEntry),
@@ -3262,6 +3315,32 @@ async function resolveTailwindV4EntriesFromCssCached(css, base) {
3262
3315
  tailwindV4CssEntriesCache.set(cacheKey, task);
3263
3316
  return task;
3264
3317
  }
3318
+ async function resolveTailwindConfigEntriesFromCssCached(css, base) {
3319
+ let root;
3320
+ try {
3321
+ root = postcss.parse(css);
3322
+ } catch {
3323
+ return;
3324
+ }
3325
+ const dependencies = await collectConfigDependencySignatures(root, base);
3326
+ if (dependencies.length === 0) return;
3327
+ const cacheKey = createCssEntriesCacheKey(css, base, dependencies);
3328
+ const cached = tailwindConfigCssEntriesCache.get(cacheKey);
3329
+ if (cached) return cached;
3330
+ const task = resolveConfigContentEntries(root, base).then((resolved) => {
3331
+ return {
3332
+ entries: [...resolved.entries, ...createDependencyExcludeEntries(resolved.dependencies)],
3333
+ explicit: true,
3334
+ inlineCandidates: {
3335
+ excluded: /* @__PURE__ */ new Set(),
3336
+ included: /* @__PURE__ */ new Set()
3337
+ },
3338
+ dependencies: resolved.dependencies
3339
+ };
3340
+ });
3341
+ tailwindConfigCssEntriesCache.set(cacheKey, task);
3342
+ return task;
3343
+ }
3265
3344
  async function discoverTailwindV4CssEntries(root, outDir) {
3266
3345
  const resolvedRoot = path.resolve(root);
3267
3346
  const ignore = ["**/node_modules/**", "**/.git/**"];
@@ -3390,10 +3469,11 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
3390
3469
  addSourceScanDependency(dependencies, source.file);
3391
3470
  addSourceScanDependencies(dependencies, source.dependencies);
3392
3471
  const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
3393
- return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set([...dependencies, ...resolved.dependencies])) : void 0;
3472
+ return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries.length > 0 ? resolved.entries : [], resolved.inlineCandidates, resolved.entries.length > 0 ? resolved.explicit : false), new Set([...dependencies, ...resolved.dependencies])) : void 0;
3394
3473
  }
3395
3474
  }
3396
3475
  function createViteSourceScanMatcher(entries) {
3476
+ if (entries?.length === 0) return;
3397
3477
  return createTailwindSourceEntryMatcher(entries);
3398
3478
  }
3399
3479
  //#endregion
@@ -3719,7 +3799,10 @@ async function transformTailwindV3CssByTarget(css, target, options) {
3719
3799
  }
3720
3800
  //#endregion
3721
3801
  //#region src/tailwindcss/v3-engine/generator.ts
3722
- const incrementalGenerateCache = /* @__PURE__ */ new Map();
3802
+ const INCREMENTAL_GENERATE_CACHE_MAX = 8;
3803
+ const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 128;
3804
+ const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 256 * 1024;
3805
+ const incrementalGenerateCache = new LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX });
3723
3806
  const patchRawStyleGenerator = typeof tailwindcssPatch.generateTailwindV3RawStyle === "function" ? tailwindcssPatch.generateTailwindV3RawStyle : void 0;
3724
3807
  function isTailwindV3PatchResolutionError(error, packageName) {
3725
3808
  if (!error || typeof error !== "object") return false;
@@ -3843,6 +3926,48 @@ function sortCandidates(candidates) {
3843
3926
  return a < z ? -1 : 1;
3844
3927
  });
3845
3928
  }
3929
+ function createRequestedCandidatesCacheKey(candidates) {
3930
+ return sortCandidates(candidates).join("\n");
3931
+ }
3932
+ function createIncrementalResultsCache() {
3933
+ return new LRUCache({ max: 16 });
3934
+ }
3935
+ function replaceIncrementalEntry(entry, candidates, generated) {
3936
+ if (!generated.context) return;
3937
+ entry.context = generated.context;
3938
+ entry.seenCandidates = new Set(candidates);
3939
+ entry.classSet = new Set(generated.classSet);
3940
+ entry.css = generated.css;
3941
+ entry.rawCss = generated.rawCss;
3942
+ entry.dependencies = generated.dependencies;
3943
+ entry.resultsByCandidates.clear();
3944
+ }
3945
+ function seedIncrementalResult(entry, candidates, result) {
3946
+ entry.resultsByCandidates.set(createRequestedCandidatesCacheKey(candidates), {
3947
+ classSet: new Set(result.classSet),
3948
+ css: result.css,
3949
+ rawCss: result.rawCss,
3950
+ dependencies: result.dependencies
3951
+ });
3952
+ }
3953
+ function createGenerateResultFromCache(cached, result, candidates) {
3954
+ return {
3955
+ css: result.css,
3956
+ rawCss: result.rawCss,
3957
+ incrementalCss: "",
3958
+ incrementalRawCss: "",
3959
+ classSet: new Set(result.classSet),
3960
+ rawCandidates: new Set(candidates),
3961
+ dependencies: result.dependencies,
3962
+ sources: [],
3963
+ root: null,
3964
+ target: cached.target,
3965
+ version: 3
3966
+ };
3967
+ }
3968
+ function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
3969
+ return cached.seenCandidates.size + missingCandidates.length > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX || cached.css.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || cached.rawCss.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || requestedCandidates.size > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX;
3970
+ }
3846
3971
  function appendUtilityRules(root, context, rules) {
3847
3972
  const sortedRules = context.offsets.sort(rules);
3848
3973
  for (const [sort, rule] of sortedRules) {
@@ -3972,38 +4097,31 @@ function createTailwindV3Engine(source) {
3972
4097
  if (cached) {
3973
4098
  if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) {
3974
4099
  const generated = await generateOnce(source, options);
3975
- incrementalGenerateCache.set(cacheKey, {
3976
- context: generated.context,
3977
- seenCandidates: new Set(requestedCandidates),
3978
- classSet: new Set(generated.classSet),
3979
- css: generated.css,
3980
- rawCss: generated.rawCss,
3981
- dependencies: generated.dependencies,
3982
- target: generated.target
3983
- });
4100
+ replaceIncrementalEntry(cached, requestedCandidates, generated);
4101
+ seedIncrementalResult(cached, requestedCandidates, generated);
3984
4102
  return generated;
3985
4103
  }
4104
+ const requestedCacheKey = createRequestedCandidatesCacheKey(requestedCandidates);
4105
+ const cachedResult = cached.resultsByCandidates.get(requestedCacheKey);
4106
+ if (cachedResult) return createGenerateResultFromCache(cached, cachedResult, requestedCandidates);
3986
4107
  const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
3987
- if (missingCandidates.length === 0) return {
3988
- css: cached.css,
3989
- rawCss: cached.rawCss,
3990
- incrementalCss: "",
3991
- incrementalRawCss: "",
3992
- classSet: new Set(cached.classSet),
3993
- rawCandidates: new Set(cached.seenCandidates),
3994
- dependencies: cached.dependencies,
3995
- sources: [],
3996
- root: null,
3997
- target: cached.target,
3998
- version: 3
3999
- };
4108
+ if (missingCandidates.length === 0) {
4109
+ seedIncrementalResult(cached, requestedCandidates, cached);
4110
+ return createGenerateResultFromCache(cached, cached, requestedCandidates);
4111
+ }
4112
+ if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) {
4113
+ const generated = await generateOnce(source, options);
4114
+ replaceIncrementalEntry(cached, requestedCandidates, generated);
4115
+ seedIncrementalResult(cached, requestedCandidates, generated);
4116
+ return generated;
4117
+ }
4000
4118
  const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, styleOptions, options.bareArbitraryValues);
4001
4119
  for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
4002
4120
  for (const className of generated.classSet) cached.classSet.add(className);
4003
4121
  cached.css = [cached.css, generated.css].filter(Boolean).join("\n");
4004
4122
  cached.rawCss = [cached.rawCss, generated.rawCss].filter(Boolean).join("\n");
4005
4123
  cached.dependencies = [...new Set([...cached.dependencies, ...generated.dependencies])];
4006
- return {
4124
+ const result = {
4007
4125
  css: cached.css,
4008
4126
  rawCss: cached.rawCss,
4009
4127
  incrementalCss: generated.css,
@@ -4016,17 +4134,23 @@ function createTailwindV3Engine(source) {
4016
4134
  target: cached.target,
4017
4135
  version: 3
4018
4136
  };
4137
+ seedIncrementalResult(cached, requestedCandidates, result);
4138
+ return result;
4019
4139
  }
4020
4140
  const generated = await generateOnce(source, options);
4021
- incrementalGenerateCache.set(cacheKey, {
4141
+ const resultsByCandidates = createIncrementalResultsCache();
4142
+ const entry = {
4022
4143
  context: generated.context,
4023
4144
  seenCandidates: new Set(requestedCandidates),
4024
4145
  classSet: new Set(generated.classSet),
4025
4146
  css: generated.css,
4026
4147
  rawCss: generated.rawCss,
4027
4148
  dependencies: generated.dependencies,
4149
+ resultsByCandidates,
4028
4150
  target: generated.target
4029
- });
4151
+ };
4152
+ seedIncrementalResult(entry, requestedCandidates, generated);
4153
+ incrementalGenerateCache.set(cacheKey, entry);
4030
4154
  return generated;
4031
4155
  }
4032
4156
  async function generate(options = {}) {
@@ -4044,6 +4168,23 @@ function createTailwindV3Engine(source) {
4044
4168
  generate
4045
4169
  };
4046
4170
  }
4171
+ function getTailwindV3IncrementalGenerateCacheStats() {
4172
+ return {
4173
+ max: INCREMENTAL_GENERATE_CACHE_MAX,
4174
+ entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
4175
+ entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
4176
+ size: incrementalGenerateCache.size,
4177
+ entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
4178
+ key,
4179
+ candidates: entry.seenCandidates.size,
4180
+ classSet: entry.classSet.size,
4181
+ cssBytes: entry.css.length,
4182
+ rawCssBytes: entry.rawCss.length,
4183
+ exactResults: entry.resultsByCandidates.size
4184
+ })),
4185
+ keys: [...incrementalGenerateCache.keys()]
4186
+ };
4187
+ }
4047
4188
  //#endregion
4048
4189
  //#region src/tailwindcss/v3-engine/source.ts
4049
4190
  const DEFAULT_TAILWIND_V3_CSS = [
@@ -4095,6 +4236,7 @@ async function resolveTailwindV3Source(options = {}) {
4095
4236
  const cssConfig = resolveCssConfig(options.css, base);
4096
4237
  const config = resolveOptionalPath(options.config, base) ?? cssConfig.config;
4097
4238
  const cwd = options.cwd ?? (config ? path.dirname(config) : projectRoot);
4239
+ const explicitConfigObject = normalizeLoadedConfig(options.configObject);
4098
4240
  const loaded = await loadConfig(omitUndefined({
4099
4241
  config,
4100
4242
  cwd
@@ -4106,7 +4248,7 @@ async function resolveTailwindV3Source(options = {}) {
4106
4248
  base,
4107
4249
  css: cssConfig.css ?? options.css ?? DEFAULT_TAILWIND_V3_CSS,
4108
4250
  config: loaded?.filepath ?? config,
4109
- configObject: normalizeLoadedConfig(loaded?.config),
4251
+ configObject: explicitConfigObject ?? normalizeLoadedConfig(loaded?.config),
4110
4252
  dependencies: loaded?.filepath ? [loaded.filepath] : [],
4111
4253
  packageName: options.packageName ?? "tailwindcss",
4112
4254
  postcssPlugin: options.postcssPlugin ?? options.packageName ?? "tailwindcss"
@@ -4127,4 +4269,4 @@ function resolveTailwindV3SourceFromPatcher(patcher) {
4127
4269
  return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
4128
4270
  }
4129
4271
  //#endregion
4130
- export { normalizeLegacyContentEntries as $, normalizeTailwindV3CssEntrySource as A, splitTailwindV4GeneratedCssBySourceOrder as B, hasLocalCssImport as C, normalizeTailwindConfigDirectives as D, hasTailwindSourceDirectives as E, createCssAppend as F, prependConfigDirective as G, stripTailwindBanner as H, hasTailwindGeneratedCss as I, transformTailwindV4CssToWeapp as J, createTailwindV4Engine$1 as K, hasTailwindGeneratedCssMarkers as L, removeTailwindSourceDirectives as M, resolveCssEntrySource as N, normalizeTailwindSourceDirectives as O, VITE_MARKER_RE as P, isFileMatchedByTailwindSourceEntries as Q, splitGeneratorPlaceholderCssBySourceOrder as R, resolveTailwindV4SourceOptionsFromPatcher as S, hasTailwindRootDirectives as T, stripTailwindBanners as U, stripGeneratorPlaceholderMarkers as V, normalizeConfigDirective as W, loadTailwindV4DesignSystem as X, filterUnsupportedMiniProgramTailwindV4Candidates as Y, FULL_SOURCE_SCAN_EXTENSION_RE as Z, resolveTailwindV4EntriesFromCssCached as _, transformTailwindV3CssByTarget as a, readInstalledPackageMajorVersion as at, resolveTailwindV4SourceFromPatchOptions as b, getRuntimeClassSetCacheEntry as c, normalizeStringListOption as ct, invalidateRuntimeClassSet as d, findWorkspacePackageDir as dt, resolveSourceScanPath as et, runtimeSignaturePatchersSymbol as f, findWorkspaceRoot as ft, resolveTailwindV4EntriesFromCss as g, discoverTailwindV4CssEntries as h, createTailwindV3Engine as i, createTailwindcssPatcher as it, parseImportRequest as j, normalizeTailwindSourceForGenerator as k, getRuntimeClassSetSignature as l, resolveBooleanObjectOption as lt, resolveViteSourceScanEntries as m, resolveTailwindV3SourceFromPatcher as n, toPosixPath as nt, transformTailwindV3CssToWeapp as o, findTailwindConfig as ot, createViteSourceScanMatcher as p, omitUndefined as pt, transformTailwindV4CssByTarget as q, resolveTailwindV3SourceOptionsFromPatcher as r, createDebug as rt, ensureTailwindcssRuntimePatch as s, resolveTailwindcssOptions as st, resolveTailwindV3Source as t, resolveTailwindV4CssSourceBase as tt, getRuntimeClassSetSignatureWithSources as u, findNearestPackageRoot as ut, resolveViteTailwindV4CssDependencies as v, hasTailwindApplyDirective as w, resolveTailwindV4SourceFromPatcher as x, resolveTailwindV4Source$1 as y, splitTailwindGeneratedCssByBanner as z };
4272
+ export { loadTailwindV4DesignSystem as $, normalizeTailwindSourceDirectives as A, splitGeneratorPlaceholderCssBySourceOrder as B, resolveTailwindV4SourceFromPatcher as C, hasTailwindRootDirectives as D, hasTailwindApplyDirective as E, resolveCssEntrySource as F, stripTailwindBanners as G, splitTailwindV4GeneratedCssBySourceOrder as H, VITE_MARKER_RE as I, createTailwindV4Engine$1 as J, normalizeConfigDirective as K, createCssAppend as L, normalizeTailwindV3CssEntrySource as M, parseImportRequest as N, hasTailwindSourceDirectives as O, removeTailwindSourceDirectives as P, filterUnsupportedMiniProgramTailwindV4Candidates as Q, hasTailwindGeneratedCss as R, resolveTailwindV4SourceFromPatchOptions as S, hasLocalCssImport as T, stripGeneratorPlaceholderMarkers as U, splitTailwindGeneratedCssByBanner as V, stripTailwindBanner as W, transformTailwindV4CssByTarget as X, getTailwindV4IncrementalGenerateCacheStats as Y, transformTailwindV4CssToWeapp as Z, resolveTailwindConfigEntriesFromCssCached as _, getTailwindV3IncrementalGenerateCacheStats as a, toPosixPath as at, resolveViteTailwindV4CssDependencies as b, ensureTailwindcssRuntimePatch as c, readInstalledPackageMajorVersion as ct, getRuntimeClassSetSignatureWithSources as d, normalizeStringListOption as dt, FULL_SOURCE_SCAN_EXTENSION_RE as et, invalidateRuntimeClassSet as f, resolveBooleanObjectOption as ft, discoverTailwindV4CssEntries as g, omitUndefined as gt, resolveViteSourceScanEntries as h, findWorkspaceRoot as ht, createTailwindV3Engine as i, resolveTailwindV4CssSourceBase as it, normalizeTailwindSourceForGenerator as j, normalizeTailwindConfigDirectives as k, getRuntimeClassSetCacheEntry as l, findTailwindConfig as lt, createViteSourceScanMatcher as m, findWorkspacePackageDir as mt, resolveTailwindV3SourceFromPatcher as n, normalizeLegacyContentEntries as nt, transformTailwindV3CssByTarget as o, createDebug as ot, runtimeSignaturePatchersSymbol as p, findNearestPackageRoot as pt, prependConfigDirective as q, resolveTailwindV3SourceOptionsFromPatcher as r, resolveSourceScanPath as rt, transformTailwindV3CssToWeapp as s, createTailwindcssPatcher as st, resolveTailwindV3Source as t, isFileMatchedByTailwindSourceEntries as tt, getRuntimeClassSetSignature as u, resolveTailwindcssOptions as ut, resolveTailwindV4EntriesFromCss as v, resolveTailwindV4SourceOptionsFromPatcher as w, resolveTailwindV4Source$1 as x, resolveTailwindV4EntriesFromCssCached as y, hasTailwindGeneratedCssMarkers as z };