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,15 +1,16 @@
1
1
  const require_chunk = require("./chunk-emK7D4bc.js");
2
2
  const require_auto = require("./auto-CTp6wE5a.js");
3
- let node_module = require("node:module");
4
- let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
5
- let tailwindcss_patch = require("tailwindcss-patch");
6
- tailwindcss_patch = require_chunk.__toESM(tailwindcss_patch);
7
3
  let node_fs = require("node:fs");
8
4
  node_fs = require_chunk.__toESM(node_fs);
9
5
  let node_path = require("node:path");
10
6
  node_path = require_chunk.__toESM(node_path);
11
7
  let node_process = require("node:process");
12
8
  node_process = require_chunk.__toESM(node_process);
9
+ let node_module = require("node:module");
10
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
11
+ let lru_cache = require("lru-cache");
12
+ let tailwindcss_patch = require("tailwindcss-patch");
13
+ tailwindcss_patch = require_chunk.__toESM(tailwindcss_patch);
13
14
  let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
14
15
  let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
15
16
  let node_url = require("node:url");
@@ -1884,8 +1885,12 @@ async function transformTailwindV4CssByTarget(css, target, options) {
1884
1885
  }
1885
1886
  //#endregion
1886
1887
  //#region src/tailwindcss/v4-engine/generator.ts
1887
- const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
1888
- const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
1888
+ const INCREMENTAL_GENERATE_CACHE_MAX$1 = 8;
1889
+ const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
1890
+ const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1 = 128;
1891
+ const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1 = 256 * 1024;
1892
+ const incrementalGenerateCache$1 = new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX$1 });
1893
+ const incrementalGenerateTaskCache = new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
1889
1894
  function collectCandidates(candidates) {
1890
1895
  return new Set(candidates ?? []);
1891
1896
  }
@@ -1981,6 +1986,9 @@ function collectCustomPropertyValues(css) {
1981
1986
  function mergeCustomPropertyValues(target, css) {
1982
1987
  for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
1983
1988
  }
1989
+ function shouldRebuildIncrementalEntry$1(cached, requestedCandidates, missingCandidates) {
1990
+ 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;
1991
+ }
1984
1992
  function seedIncrementalGenerateCache(options) {
1985
1993
  const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
1986
1994
  const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
@@ -2068,6 +2076,18 @@ function createTailwindV4Engine(source) {
2068
2076
  root: cached.root,
2069
2077
  target: cached.target
2070
2078
  };
2079
+ if (shouldRebuildIncrementalEntry$1(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2080
+ const generated = await generateOnce(source, options);
2081
+ seedIncrementalGenerateCache({
2082
+ compatibleSource,
2083
+ generated,
2084
+ requestedCandidates,
2085
+ styleOptions,
2086
+ tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
2087
+ target
2088
+ });
2089
+ return generated;
2090
+ });
2071
2091
  return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2072
2092
  const designSystem = await cached.designSystemPromise;
2073
2093
  const normalizedMissing = normalizeRpxTextCandidates(missingCandidates);
@@ -2130,6 +2150,25 @@ function createTailwindV4Engine(source) {
2130
2150
  generate
2131
2151
  };
2132
2152
  }
2153
+ function getTailwindV4IncrementalGenerateCacheStats() {
2154
+ return {
2155
+ max: INCREMENTAL_GENERATE_CACHE_MAX$1,
2156
+ entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1,
2157
+ entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1,
2158
+ size: incrementalGenerateCache$1.size,
2159
+ taskMax: INCREMENTAL_GENERATE_TASK_CACHE_MAX,
2160
+ taskSize: incrementalGenerateTaskCache.size,
2161
+ entries: [...incrementalGenerateCache$1.entries()].map(([key, entry]) => ({
2162
+ key,
2163
+ candidates: entry.seenCandidates.size,
2164
+ classSet: entry.classSet.size,
2165
+ cssBytes: entry.css.length,
2166
+ rawCssBytes: entry.rawCss.length
2167
+ })),
2168
+ keys: [...incrementalGenerateCache$1.keys()],
2169
+ taskKeys: [...incrementalGenerateTaskCache.keys()]
2170
+ };
2171
+ }
2133
2172
  //#endregion
2134
2173
  //#region src/bundlers/shared/generator-css/config-directive.ts
2135
2174
  function quoteCssString(value) {
@@ -3053,6 +3092,7 @@ function addSourceScanDependencies(dependencies, files) {
3053
3092
  const VITE_SOURCE_CANDIDATE_PATTERN = FULL_SOURCE_SCAN_PATTERN;
3054
3093
  const VITE_TAILWIND_CSS_ENTRY_PATTERN = "**/*.{css,less,sass,scss,styl,stylus,pcss,postcss}";
3055
3094
  const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
3095
+ const tailwindConfigCssEntriesCache = /* @__PURE__ */ new Map();
3056
3096
  function parseImportSourceParam(params) {
3057
3097
  const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
3058
3098
  if (!match) return;
@@ -3086,6 +3126,13 @@ function createCssEntriesCacheKey(css, base, dependencies) {
3086
3126
  dependencies
3087
3127
  });
3088
3128
  }
3129
+ function createDependencyExcludeEntries(files) {
3130
+ return [...files].map((file) => ({
3131
+ base: node_path.default.dirname(file),
3132
+ negated: true,
3133
+ pattern: node_path.default.basename(file)
3134
+ }));
3135
+ }
3089
3136
  async function statConfigDependency(file) {
3090
3137
  try {
3091
3138
  const stats = await (0, node_fs_promises.stat)(file);
@@ -3234,6 +3281,12 @@ async function resolveTailwindV3CssEntryScan(options, patcher) {
3234
3281
  } catch {
3235
3282
  return;
3236
3283
  }
3284
+ const cssConfigEntries = await resolveTailwindConfigEntriesFromCssCached(css, node_path.default.dirname(cssEntry));
3285
+ if (cssConfigEntries) {
3286
+ addSourceScanDependencies(dependencies, cssConfigEntries.dependencies);
3287
+ entries.push(...cssConfigEntries.entries);
3288
+ return;
3289
+ }
3237
3290
  const source = await resolveTailwindV3Source({
3238
3291
  ...sourceOptions,
3239
3292
  base: node_path.default.dirname(cssEntry),
@@ -3269,6 +3322,32 @@ async function resolveTailwindV4EntriesFromCssCached(css, base) {
3269
3322
  tailwindV4CssEntriesCache.set(cacheKey, task);
3270
3323
  return task;
3271
3324
  }
3325
+ async function resolveTailwindConfigEntriesFromCssCached(css, base) {
3326
+ let root;
3327
+ try {
3328
+ root = _weapp_tailwindcss_postcss.postcss.parse(css);
3329
+ } catch {
3330
+ return;
3331
+ }
3332
+ const dependencies = await collectConfigDependencySignatures(root, base);
3333
+ if (dependencies.length === 0) return;
3334
+ const cacheKey = createCssEntriesCacheKey(css, base, dependencies);
3335
+ const cached = tailwindConfigCssEntriesCache.get(cacheKey);
3336
+ if (cached) return cached;
3337
+ const task = resolveConfigContentEntries(root, base).then((resolved) => {
3338
+ return {
3339
+ entries: [...resolved.entries, ...createDependencyExcludeEntries(resolved.dependencies)],
3340
+ explicit: true,
3341
+ inlineCandidates: {
3342
+ excluded: /* @__PURE__ */ new Set(),
3343
+ included: /* @__PURE__ */ new Set()
3344
+ },
3345
+ dependencies: resolved.dependencies
3346
+ };
3347
+ });
3348
+ tailwindConfigCssEntriesCache.set(cacheKey, task);
3349
+ return task;
3350
+ }
3272
3351
  async function discoverTailwindV4CssEntries(root, outDir) {
3273
3352
  const resolvedRoot = node_path.default.resolve(root);
3274
3353
  const ignore = ["**/node_modules/**", "**/.git/**"];
@@ -3397,10 +3476,11 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
3397
3476
  addSourceScanDependency(dependencies, source.file);
3398
3477
  addSourceScanDependencies(dependencies, source.dependencies);
3399
3478
  const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
3400
- return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set([...dependencies, ...resolved.dependencies])) : void 0;
3479
+ 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;
3401
3480
  }
3402
3481
  }
3403
3482
  function createViteSourceScanMatcher(entries) {
3483
+ if (entries?.length === 0) return;
3404
3484
  return createTailwindSourceEntryMatcher(entries);
3405
3485
  }
3406
3486
  //#endregion
@@ -3726,7 +3806,10 @@ async function transformTailwindV3CssByTarget(css, target, options) {
3726
3806
  }
3727
3807
  //#endregion
3728
3808
  //#region src/tailwindcss/v3-engine/generator.ts
3729
- const incrementalGenerateCache = /* @__PURE__ */ new Map();
3809
+ const INCREMENTAL_GENERATE_CACHE_MAX = 8;
3810
+ const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 128;
3811
+ const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 256 * 1024;
3812
+ const incrementalGenerateCache = new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX });
3730
3813
  const patchRawStyleGenerator = typeof tailwindcss_patch.generateTailwindV3RawStyle === "function" ? tailwindcss_patch.generateTailwindV3RawStyle : void 0;
3731
3814
  function isTailwindV3PatchResolutionError(error, packageName) {
3732
3815
  if (!error || typeof error !== "object") return false;
@@ -3850,6 +3933,48 @@ function sortCandidates(candidates) {
3850
3933
  return a < z ? -1 : 1;
3851
3934
  });
3852
3935
  }
3936
+ function createRequestedCandidatesCacheKey(candidates) {
3937
+ return sortCandidates(candidates).join("\n");
3938
+ }
3939
+ function createIncrementalResultsCache() {
3940
+ return new lru_cache.LRUCache({ max: 16 });
3941
+ }
3942
+ function replaceIncrementalEntry(entry, candidates, generated) {
3943
+ if (!generated.context) return;
3944
+ entry.context = generated.context;
3945
+ entry.seenCandidates = new Set(candidates);
3946
+ entry.classSet = new Set(generated.classSet);
3947
+ entry.css = generated.css;
3948
+ entry.rawCss = generated.rawCss;
3949
+ entry.dependencies = generated.dependencies;
3950
+ entry.resultsByCandidates.clear();
3951
+ }
3952
+ function seedIncrementalResult(entry, candidates, result) {
3953
+ entry.resultsByCandidates.set(createRequestedCandidatesCacheKey(candidates), {
3954
+ classSet: new Set(result.classSet),
3955
+ css: result.css,
3956
+ rawCss: result.rawCss,
3957
+ dependencies: result.dependencies
3958
+ });
3959
+ }
3960
+ function createGenerateResultFromCache(cached, result, candidates) {
3961
+ return {
3962
+ css: result.css,
3963
+ rawCss: result.rawCss,
3964
+ incrementalCss: "",
3965
+ incrementalRawCss: "",
3966
+ classSet: new Set(result.classSet),
3967
+ rawCandidates: new Set(candidates),
3968
+ dependencies: result.dependencies,
3969
+ sources: [],
3970
+ root: null,
3971
+ target: cached.target,
3972
+ version: 3
3973
+ };
3974
+ }
3975
+ function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
3976
+ 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;
3977
+ }
3853
3978
  function appendUtilityRules(root, context, rules) {
3854
3979
  const sortedRules = context.offsets.sort(rules);
3855
3980
  for (const [sort, rule] of sortedRules) {
@@ -3979,38 +4104,31 @@ function createTailwindV3Engine(source) {
3979
4104
  if (cached) {
3980
4105
  if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) {
3981
4106
  const generated = await generateOnce(source, options);
3982
- incrementalGenerateCache.set(cacheKey, {
3983
- context: generated.context,
3984
- seenCandidates: new Set(requestedCandidates),
3985
- classSet: new Set(generated.classSet),
3986
- css: generated.css,
3987
- rawCss: generated.rawCss,
3988
- dependencies: generated.dependencies,
3989
- target: generated.target
3990
- });
4107
+ replaceIncrementalEntry(cached, requestedCandidates, generated);
4108
+ seedIncrementalResult(cached, requestedCandidates, generated);
3991
4109
  return generated;
3992
4110
  }
4111
+ const requestedCacheKey = createRequestedCandidatesCacheKey(requestedCandidates);
4112
+ const cachedResult = cached.resultsByCandidates.get(requestedCacheKey);
4113
+ if (cachedResult) return createGenerateResultFromCache(cached, cachedResult, requestedCandidates);
3993
4114
  const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
3994
- if (missingCandidates.length === 0) return {
3995
- css: cached.css,
3996
- rawCss: cached.rawCss,
3997
- incrementalCss: "",
3998
- incrementalRawCss: "",
3999
- classSet: new Set(cached.classSet),
4000
- rawCandidates: new Set(cached.seenCandidates),
4001
- dependencies: cached.dependencies,
4002
- sources: [],
4003
- root: null,
4004
- target: cached.target,
4005
- version: 3
4006
- };
4115
+ if (missingCandidates.length === 0) {
4116
+ seedIncrementalResult(cached, requestedCandidates, cached);
4117
+ return createGenerateResultFromCache(cached, cached, requestedCandidates);
4118
+ }
4119
+ if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) {
4120
+ const generated = await generateOnce(source, options);
4121
+ replaceIncrementalEntry(cached, requestedCandidates, generated);
4122
+ seedIncrementalResult(cached, requestedCandidates, generated);
4123
+ return generated;
4124
+ }
4007
4125
  const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, styleOptions, options.bareArbitraryValues);
4008
4126
  for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
4009
4127
  for (const className of generated.classSet) cached.classSet.add(className);
4010
4128
  cached.css = [cached.css, generated.css].filter(Boolean).join("\n");
4011
4129
  cached.rawCss = [cached.rawCss, generated.rawCss].filter(Boolean).join("\n");
4012
4130
  cached.dependencies = [...new Set([...cached.dependencies, ...generated.dependencies])];
4013
- return {
4131
+ const result = {
4014
4132
  css: cached.css,
4015
4133
  rawCss: cached.rawCss,
4016
4134
  incrementalCss: generated.css,
@@ -4023,17 +4141,23 @@ function createTailwindV3Engine(source) {
4023
4141
  target: cached.target,
4024
4142
  version: 3
4025
4143
  };
4144
+ seedIncrementalResult(cached, requestedCandidates, result);
4145
+ return result;
4026
4146
  }
4027
4147
  const generated = await generateOnce(source, options);
4028
- incrementalGenerateCache.set(cacheKey, {
4148
+ const resultsByCandidates = createIncrementalResultsCache();
4149
+ const entry = {
4029
4150
  context: generated.context,
4030
4151
  seenCandidates: new Set(requestedCandidates),
4031
4152
  classSet: new Set(generated.classSet),
4032
4153
  css: generated.css,
4033
4154
  rawCss: generated.rawCss,
4034
4155
  dependencies: generated.dependencies,
4156
+ resultsByCandidates,
4035
4157
  target: generated.target
4036
- });
4158
+ };
4159
+ seedIncrementalResult(entry, requestedCandidates, generated);
4160
+ incrementalGenerateCache.set(cacheKey, entry);
4037
4161
  return generated;
4038
4162
  }
4039
4163
  async function generate(options = {}) {
@@ -4051,6 +4175,23 @@ function createTailwindV3Engine(source) {
4051
4175
  generate
4052
4176
  };
4053
4177
  }
4178
+ function getTailwindV3IncrementalGenerateCacheStats() {
4179
+ return {
4180
+ max: INCREMENTAL_GENERATE_CACHE_MAX,
4181
+ entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
4182
+ entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
4183
+ size: incrementalGenerateCache.size,
4184
+ entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
4185
+ key,
4186
+ candidates: entry.seenCandidates.size,
4187
+ classSet: entry.classSet.size,
4188
+ cssBytes: entry.css.length,
4189
+ rawCssBytes: entry.rawCss.length,
4190
+ exactResults: entry.resultsByCandidates.size
4191
+ })),
4192
+ keys: [...incrementalGenerateCache.keys()]
4193
+ };
4194
+ }
4054
4195
  //#endregion
4055
4196
  //#region src/tailwindcss/v3-engine/source.ts
4056
4197
  const DEFAULT_TAILWIND_V3_CSS = [
@@ -4102,6 +4243,7 @@ async function resolveTailwindV3Source(options = {}) {
4102
4243
  const cssConfig = resolveCssConfig(options.css, base);
4103
4244
  const config = resolveOptionalPath(options.config, base) ?? cssConfig.config;
4104
4245
  const cwd = options.cwd ?? (config ? node_path.default.dirname(config) : projectRoot);
4246
+ const explicitConfigObject = normalizeLoadedConfig(options.configObject);
4105
4247
  const loaded = await (0, tailwindcss_config.loadConfig)(omitUndefined({
4106
4248
  config,
4107
4249
  cwd
@@ -4113,7 +4255,7 @@ async function resolveTailwindV3Source(options = {}) {
4113
4255
  base,
4114
4256
  css: cssConfig.css ?? options.css ?? DEFAULT_TAILWIND_V3_CSS,
4115
4257
  config: loaded?.filepath ?? config,
4116
- configObject: normalizeLoadedConfig(loaded?.config),
4258
+ configObject: explicitConfigObject ?? normalizeLoadedConfig(loaded?.config),
4117
4259
  dependencies: loaded?.filepath ? [loaded.filepath] : [],
4118
4260
  packageName: options.packageName ?? "tailwindcss",
4119
4261
  postcssPlugin: options.postcssPlugin ?? options.packageName ?? "tailwindcss"
@@ -4242,6 +4384,18 @@ Object.defineProperty(exports, "getRuntimeClassSetSignatureWithSources", {
4242
4384
  return getRuntimeClassSetSignatureWithSources;
4243
4385
  }
4244
4386
  });
4387
+ Object.defineProperty(exports, "getTailwindV3IncrementalGenerateCacheStats", {
4388
+ enumerable: true,
4389
+ get: function() {
4390
+ return getTailwindV3IncrementalGenerateCacheStats;
4391
+ }
4392
+ });
4393
+ Object.defineProperty(exports, "getTailwindV4IncrementalGenerateCacheStats", {
4394
+ enumerable: true,
4395
+ get: function() {
4396
+ return getTailwindV4IncrementalGenerateCacheStats;
4397
+ }
4398
+ });
4245
4399
  Object.defineProperty(exports, "hasLocalCssImport", {
4246
4400
  enumerable: true,
4247
4401
  get: function() {
@@ -4380,6 +4534,12 @@ Object.defineProperty(exports, "resolveSourceScanPath", {
4380
4534
  return resolveSourceScanPath;
4381
4535
  }
4382
4536
  });
4537
+ Object.defineProperty(exports, "resolveTailwindConfigEntriesFromCssCached", {
4538
+ enumerable: true,
4539
+ get: function() {
4540
+ return resolveTailwindConfigEntriesFromCssCached;
4541
+ }
4542
+ });
4383
4543
  Object.defineProperty(exports, "resolveTailwindV3Source", {
4384
4544
  enumerable: true,
4385
4545
  get: function() {