weapp-tailwindcss 5.0.0-next.2 → 5.0.0-next.21

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 (221) hide show
  1. package/README.md +6 -7
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundle-state-BnV8o2Yn.js +530 -0
  4. package/dist/bundle-state-CLnuf2CW.mjs +414 -0
  5. package/dist/bundlers/shared/cache.d.ts +6 -6
  6. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
  7. package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
  8. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  9. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  10. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  11. package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
  12. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  13. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  14. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  15. package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
  16. package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
  17. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
  18. package/dist/bundlers/shared/generator-css.d.ts +16 -22
  19. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  20. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  21. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  22. package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
  23. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  24. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
  25. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
  26. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  27. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  28. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  29. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  30. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  31. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  32. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  33. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  34. package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
  35. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  36. package/dist/bundlers/vite/index.d.ts +1 -1
  37. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  38. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  39. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  40. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
  41. package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
  42. package/dist/bundlers/vite/source-candidates.d.ts +16 -1
  43. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  44. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  45. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  46. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  47. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
  48. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
  49. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
  50. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  51. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
  52. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  53. package/dist/cache/index.d.ts +6 -6
  54. package/dist/cli/context.d.ts +1 -14
  55. package/dist/cli/doctor/types.d.ts +11 -11
  56. package/dist/cli/helpers.d.ts +1 -2
  57. package/dist/cli/mount-options.d.ts +2 -0
  58. package/dist/cli/types.d.ts +0 -2
  59. package/dist/cli/vscode-entry.d.ts +3 -3
  60. package/dist/cli.js +605 -611
  61. package/dist/cli.mjs +614 -620
  62. package/dist/constants.d.ts +1 -2
  63. package/dist/core.js +13 -20
  64. package/dist/core.mjs +8 -14
  65. package/dist/css-macro/postcss.js +3 -2
  66. package/dist/css-macro/postcss.mjs +3 -2
  67. package/dist/css-macro.d.ts +1 -0
  68. package/dist/css-macro.js +2 -2
  69. package/dist/css-macro.mjs +2 -2
  70. package/dist/defaults-B1igPF_e.mjs +150 -0
  71. package/dist/defaults-IHhYxNeU.js +193 -0
  72. package/dist/defaults.d.ts +15 -1
  73. package/dist/defaults.js +6 -131
  74. package/dist/defaults.mjs +2 -129
  75. package/dist/escape.js +10 -2
  76. package/dist/escape.mjs +10 -2
  77. package/dist/generator/index.d.ts +1 -1
  78. package/dist/generator/options.d.ts +9 -8
  79. package/dist/generator/types.d.ts +3 -3
  80. package/dist/generator-B4RNgMLx.js +55 -0
  81. package/dist/generator-DvyhmC76.mjs +32 -0
  82. package/dist/generator.js +12 -11
  83. package/dist/generator.mjs +2 -1
  84. package/dist/gulp.js +185 -47
  85. package/dist/gulp.mjs +179 -41
  86. package/dist/incremental-runtime-class-set-C7Q7fC5u.mjs +1863 -0
  87. package/dist/incremental-runtime-class-set-DZsbM0-a.js +1926 -0
  88. package/dist/index.d.ts +1 -1
  89. package/dist/index.js +6 -6
  90. package/dist/index.mjs +5 -5
  91. package/dist/js/babel/cache-options.d.ts +3 -0
  92. package/dist/js/babel/parse.d.ts +7 -4
  93. package/dist/js/index.d.ts +1 -0
  94. package/dist/js/literal-transform.d.ts +2 -0
  95. package/dist/js/precheck.d.ts +2 -2
  96. package/dist/logger-CZUxvJJD.mjs +2 -0
  97. package/dist/logger-EVNB9z7i.js +1 -0
  98. package/dist/postcss/config-directive.d.ts +1 -0
  99. package/dist/postcss/context.d.ts +9 -0
  100. package/dist/postcss/source-files.d.ts +8 -0
  101. package/dist/postcss/tailwind-version.d.ts +3 -0
  102. package/dist/postcss-CFa6-qO9.js +237 -0
  103. package/dist/postcss-Drpy7j-g.mjs +228 -0
  104. package/dist/postcss.d.ts +2 -2
  105. package/dist/postcss.js +3 -276
  106. package/dist/postcss.mjs +1 -269
  107. package/dist/{recorder-gYSNLfOP.js → precheck-8pQbjqpq.js} +218 -314
  108. package/dist/{recorder-zsgatmkB.mjs → precheck-D1O5AWzy.mjs} +186 -281
  109. package/dist/presets.js +13 -11
  110. package/dist/presets.mjs +11 -9
  111. package/dist/reset.d.ts +1 -0
  112. package/dist/runtime-registry-CdCV3Opt.js +5496 -0
  113. package/dist/shared/mpx.d.ts +1 -0
  114. package/dist/source-candidates-CUTNdsiz.js +222 -0
  115. package/dist/source-candidates-CnD4vyic.mjs +209 -0
  116. package/dist/tailwindcss/miniprogram.d.ts +1 -1
  117. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  118. package/dist/tailwindcss/patcher.d.ts +1 -2
  119. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  120. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  121. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  122. package/dist/tailwindcss/runtime.d.ts +11 -12
  123. package/dist/tailwindcss/source-scan.d.ts +35 -0
  124. package/dist/tailwindcss/targets.d.ts +1 -5
  125. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  126. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  127. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  128. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  129. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  130. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  131. package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
  132. package/dist/tailwindcss/version.d.ts +4 -0
  133. package/dist/tailwindcss-B_JAdOQf.mjs +600 -0
  134. package/dist/tailwindcss-whZE3HpL.js +651 -0
  135. package/dist/typedoc.export.d.ts +0 -2
  136. package/dist/types/index.d.ts +51 -48
  137. package/dist/types/shared.d.ts +3 -0
  138. package/dist/types/user-defined-options/general.d.ts +23 -23
  139. package/dist/types/user-defined-options/important.d.ts +31 -28
  140. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  141. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  142. package/dist/uni-app-x/vite.d.ts +1 -1
  143. package/dist/utils/disabled.d.ts +2 -3
  144. package/dist/utils/object.d.ts +9 -0
  145. package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
  146. package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
  147. package/dist/v3-engine-CCwvhRrQ.js +3473 -0
  148. package/dist/v3-engine-DyIcbpZm.mjs +3190 -0
  149. package/dist/{vite-CrlzCNqz.mjs → vite-B8IiXgVD.mjs} +1256 -1088
  150. package/dist/vite-BcnwgJMt.js +2368 -0
  151. package/dist/vite.d.ts +1 -2
  152. package/dist/vite.js +3 -4
  153. package/dist/vite.mjs +2 -2
  154. package/dist/weapp-tw-css-import-rewrite-loader.js +4533 -16
  155. package/dist/weapp-tw-runtime-classset-loader.js +33 -7
  156. package/dist/webpack-C4zI624R.js +846 -0
  157. package/dist/webpack-DTkshAtp.mjs +836 -0
  158. package/dist/webpack.js +1 -1
  159. package/dist/webpack.mjs +1 -1
  160. package/package.json +27 -37
  161. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  162. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  163. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  164. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  165. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  166. package/dist/cli/config.d.ts +0 -5
  167. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  168. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  169. package/dist/cli/patch-options.d.ts +0 -6
  170. package/dist/cli/tokens.d.ts +0 -4
  171. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  172. package/dist/cli/workspace/patch-package.d.ts +0 -3
  173. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  174. package/dist/cli/workspace/types.d.ts +0 -11
  175. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  176. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  177. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  178. package/dist/cli/workspace.d.ts +0 -2
  179. package/dist/css-imports-BbrbluP9.js +0 -177
  180. package/dist/css-imports-CSdPq_Sc.mjs +0 -128
  181. package/dist/experimental/index.d.ts +0 -2
  182. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  183. package/dist/experimental/oxc/index.d.ts +0 -2
  184. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  185. package/dist/experimental/shared/cache.d.ts +0 -3
  186. package/dist/experimental/shared/transform.d.ts +0 -3
  187. package/dist/experimental/shared.d.ts +0 -8
  188. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  189. package/dist/experimental/swc/index.d.ts +0 -2
  190. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  191. package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
  192. package/dist/generator-css-B5ejWUMv.mjs +0 -1098
  193. package/dist/generator-css-D3OdPRiS.js +0 -1125
  194. package/dist/generator-mmhXzZnv.js +0 -1276
  195. package/dist/js/syntax.d.ts +0 -10
  196. package/dist/lightningcss/index.d.ts +0 -8
  197. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  198. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  199. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  200. package/dist/lightningcss/style-handler.d.ts +0 -17
  201. package/dist/loader-anchors-CNkWT8hx.js +0 -273
  202. package/dist/loader-anchors-TrU7EUr7.mjs +0 -205
  203. package/dist/logger-BZ45DZJT.js +0 -1003
  204. package/dist/logger-BoVx1Dbt.mjs +0 -935
  205. package/dist/patcher-options-6gJN2EXy.js +0 -115
  206. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  207. package/dist/tailwindcss/recorder.d.ts +0 -13
  208. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  209. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  210. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  211. package/dist/tailwindcss/targets/types.d.ts +0 -35
  212. package/dist/types/disabled-options.d.ts +0 -4
  213. package/dist/vite-BC9U7ahn.js +0 -2199
  214. package/dist/webpack-Bu6M-Hbw.mjs +0 -441
  215. package/dist/webpack-DD7A6V0u.js +0 -456
  216. package/dist/webpack4.d.ts +0 -4
  217. package/dist/webpack4.js +0 -387
  218. package/dist/webpack4.mjs +0 -379
  219. package/scripts/postinstall.mjs +0 -59
  220. /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
  221. /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
package/dist/gulp.mjs CHANGED
@@ -1,9 +1,12 @@
1
- import { _ as refreshTailwindRuntimeState, g as ensureRuntimeClassSet, n as shouldSkipJsTransform, r as getCompilerContext, t as setupPatchRecorder, v as createDebug } from "./recorder-zsgatmkB.mjs";
2
- import { i as processCachedTask, t as generateCssByGenerator } from "./generator-css-B5ejWUMv.mjs";
1
+ import { B as createDebug, _ as resolveViteSourceScanEntries, l as getRuntimeClassSetSignature } from "./v3-engine-DyIcbpZm.mjs";
2
+ import { i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, o as processCachedTask, r as emitHmrTiming, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-C7Q7fC5u.mjs";
3
+ import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-D1O5AWzy.mjs";
4
+ import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-B_JAdOQf.mjs";
5
+ import { t as createSourceCandidateCollector } from "./source-candidates-CnD4vyic.mjs";
6
+ import fs from "node:fs";
3
7
  import path from "node:path";
4
8
  import process from "node:process";
5
9
  import { Buffer } from "node:buffer";
6
- import fs from "node:fs";
7
10
  import stream from "node:stream";
8
11
  //#region src/bundlers/gulp/index.ts
9
12
  const debug = createDebug();
@@ -14,19 +17,18 @@ const Transform = stream.Transform;
14
17
  * @link https://tw.icebreaker.top/docs/quick-start/frameworks/native
15
18
  */
16
19
  function createPlugins(options = {}) {
17
- const opts = getCompilerContext(options);
18
- const hasExplicitGeneratorOptions = options.generator !== void 0;
19
- const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
20
- const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
21
- source: "runtime",
22
- cwd: opts.tailwindcssBasedir ?? process.cwd()
20
+ const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots(options);
21
+ const opts = getCompilerContext({
22
+ ...options,
23
+ __internalDeferMissingCssEntriesWarning: true
23
24
  });
25
+ const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
26
+ const readyPromise = createTailwindRuntimeReadyPromise(initialTwPatcher);
24
27
  let runtimeSet = /* @__PURE__ */ new Set();
25
28
  const runtimeState = {
26
29
  twPatcher: initialTwPatcher,
27
- patchPromise: patchRecorderState.patchPromise,
28
- refreshTailwindcssPatcher,
29
- onPatchCompleted: patchRecorderState.onPatchCompleted
30
+ readyPromise,
31
+ refreshTailwindcssPatcher
30
32
  };
31
33
  const defaultStyleHandlerOptionsCache = /* @__PURE__ */ new Map();
32
34
  let cachedDefaultTemplateHandlerOptions;
@@ -41,20 +43,138 @@ function createPlugins(options = {}) {
41
43
  ".jsx"
42
44
  ];
43
45
  let runtimeSetInitialized = false;
44
- async function refreshRuntimeState(force) {
45
- await refreshTailwindRuntimeState(runtimeState, force);
46
- }
47
- async function refreshRuntimeSet(force = false) {
48
- if (!force && runtimeSetInitialized) return runtimeSet;
46
+ let runtimeSetDirty = false;
47
+ const runtimeSourceHashByFile = /* @__PURE__ */ new Map();
48
+ const runtimeSourcesByFile = /* @__PURE__ */ new Map();
49
+ let cachedGulpSourceCandidates;
50
+ let cachedGulpSourceCandidateSignature;
51
+ const bundleRuntimeClassSetManager = options.__internalGulpRuntimeClassSetManager ?? createBundleRuntimeClassSetManager();
52
+ async function refreshRuntimeSet(options = false) {
53
+ const normalizedOptions = typeof options === "boolean" ? {
54
+ forceRefresh: options,
55
+ forceCollect: options,
56
+ clearCache: options
57
+ } : options;
58
+ const forceRefresh = normalizedOptions.forceRefresh === true;
59
+ const shouldForceCollect = normalizedOptions.forceCollect === true || runtimeSetDirty;
60
+ const clearCache = normalizedOptions.clearCache === true || runtimeSetDirty;
61
+ if (!forceRefresh && !shouldForceCollect && runtimeSetInitialized) return runtimeSet;
49
62
  runtimeSet = await ensureRuntimeClassSet(runtimeState, {
50
- forceRefresh: force,
51
- forceCollect: force,
52
- clearCache: force,
63
+ forceRefresh,
64
+ forceCollect: shouldForceCollect,
65
+ clearCache,
53
66
  allowEmpty: false
54
67
  });
55
68
  runtimeSetInitialized = true;
69
+ runtimeSetDirty = false;
56
70
  return runtimeSet;
57
71
  }
72
+ function createRuntimeSnapshot(changedFiles) {
73
+ const runtimeAffectingChangedByType = {
74
+ html: /* @__PURE__ */ new Set(),
75
+ js: /* @__PURE__ */ new Set(),
76
+ css: /* @__PURE__ */ new Set(),
77
+ other: /* @__PURE__ */ new Set()
78
+ };
79
+ for (const file of changedFiles) {
80
+ const entry = runtimeSourcesByFile.get(file);
81
+ if (entry) runtimeAffectingChangedByType[entry.type].add(file);
82
+ }
83
+ return {
84
+ entries: [...runtimeSourcesByFile.entries()].map(([file, entry]) => ({
85
+ file,
86
+ output: {
87
+ fileName: file,
88
+ source: entry.source,
89
+ type: "asset"
90
+ },
91
+ source: entry.source,
92
+ type: entry.type
93
+ })),
94
+ jsEntries: /* @__PURE__ */ new Map(),
95
+ sourceHashByFile: /* @__PURE__ */ new Map(),
96
+ runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
97
+ runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
98
+ changedByType: {
99
+ html: /* @__PURE__ */ new Set(),
100
+ js: /* @__PURE__ */ new Set(),
101
+ css: /* @__PURE__ */ new Set(),
102
+ other: /* @__PURE__ */ new Set()
103
+ },
104
+ runtimeAffectingChangedByType,
105
+ processFiles: {
106
+ html: /* @__PURE__ */ new Set(),
107
+ js: /* @__PURE__ */ new Set(),
108
+ css: /* @__PURE__ */ new Set()
109
+ },
110
+ linkedImpactsByEntry: /* @__PURE__ */ new Map()
111
+ };
112
+ }
113
+ async function refreshRuntimeSetForSource(file, rawSource, type) {
114
+ const filename = path.resolve(file.path);
115
+ const hash = cache.computeHash(rawSource);
116
+ const changed = runtimeSourceHashByFile.get(filename) !== hash;
117
+ runtimeSourceHashByFile.set(filename, hash);
118
+ runtimeSourcesByFile.set(filename, {
119
+ source: rawSource,
120
+ type
121
+ });
122
+ if (!changed && runtimeSetInitialized) return runtimeSet;
123
+ if (runtimeState.twPatcher.majorVersion === 4 && !runtimeSetDirty) try {
124
+ runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, createRuntimeSnapshot([filename]));
125
+ runtimeSetInitialized = true;
126
+ return runtimeSet;
127
+ } catch (error) {
128
+ debug("gulp incremental runtime set sync failed, fallback to collect: %O", error);
129
+ await bundleRuntimeClassSetManager.reset();
130
+ }
131
+ return refreshRuntimeSet({ forceCollect: true });
132
+ }
133
+ async function refreshGulpSourceCandidates(forceRefresh = false) {
134
+ if (runtimeState.twPatcher.majorVersion !== 3) return /* @__PURE__ */ new Set();
135
+ const root = opts.tailwindcssBasedir ?? process.cwd();
136
+ const sourceScan = await resolveViteSourceScanEntries(opts, runtimeState.twPatcher, { root });
137
+ const nextSignature = cache.computeHash(JSON.stringify({
138
+ root,
139
+ entries: sourceScan?.entries,
140
+ inlineCandidates: sourceScan?.inlineCandidates ? {
141
+ included: [...sourceScan.inlineCandidates.included].sort(),
142
+ excluded: [...sourceScan.inlineCandidates.excluded].sort()
143
+ } : void 0,
144
+ explicit: sourceScan?.explicit ?? false,
145
+ dependencies: [...sourceScan?.dependencies ?? []].sort()
146
+ }));
147
+ if (!forceRefresh && cachedGulpSourceCandidateSignature === nextSignature && cachedGulpSourceCandidates) return cachedGulpSourceCandidates;
148
+ const collector = createSourceCandidateCollector();
149
+ await collector.scanRoot({
150
+ entries: sourceScan?.entries,
151
+ root
152
+ });
153
+ collector.syncInline(sourceScan?.inlineCandidates);
154
+ cachedGulpSourceCandidateSignature = nextSignature;
155
+ cachedGulpSourceCandidates = sourceScan?.entries ? collector.valuesForEntries(sourceScan.entries) : collector.values();
156
+ return cachedGulpSourceCandidates;
157
+ }
158
+ function createRuntimeSetHash(rawSource, nextRuntimeSet) {
159
+ return cache.computeHash([
160
+ rawSource,
161
+ getRuntimeClassSetSignature(runtimeState.twPatcher),
162
+ [...nextRuntimeSet].sort().join("\n")
163
+ ].join("\n\n"));
164
+ }
165
+ async function registerAutoCssSource(file, rawSource) {
166
+ if (hasInitialTailwindCssRoots || (runtimeState.twPatcher.majorVersion ?? 0) < 4 || !file.path || !hasTailwindRootDirectives(rawSource)) return false;
167
+ const sourceCss = normalizeTailwindSourceForGenerator(rawSource, { importFallback: true });
168
+ if (!upsertTailwindV4CssSource(opts, {
169
+ file: path.resolve(file.path),
170
+ css: sourceCss
171
+ })) return false;
172
+ runtimeSetInitialized = false;
173
+ runtimeSetDirty = true;
174
+ await bundleRuntimeClassSetManager.reset();
175
+ debug("detected tailwindcss v4 css source from gulp css file: %s", file.path);
176
+ return true;
177
+ }
58
178
  function resolveWithExtensions(base) {
59
179
  for (const ext of MODULE_EXTENSIONS) {
60
180
  const candidate = `${base}${ext}`;
@@ -101,12 +221,14 @@ function createPlugins(options = {}) {
101
221
  if (!cachedDefaultModuleGraphOptions) cachedDefaultModuleGraphOptions = createModuleGraphOptionsFor();
102
222
  return cachedDefaultModuleGraphOptions;
103
223
  }
104
- function createVinylTransform(handler) {
224
+ function createVinylTransform(phase, handler) {
105
225
  return new Transform({
106
226
  objectMode: true,
107
227
  async transform(file, _encoding, callback) {
228
+ const hmrTimingStartedAt = performance.now();
108
229
  try {
109
230
  await handler(file);
231
+ emitHmrTiming("gulp", phase, performance.now() - hmrTimingStartedAt, { file: file.relative || path.basename(file.path) });
110
232
  callback(null, file);
111
233
  } catch (error) {
112
234
  callback(error, file);
@@ -119,12 +241,12 @@ function createPlugins(options = {}) {
119
241
  if (!options || Object.keys(options).length === 0) {
120
242
  let cached = defaultStyleHandlerOptionsCache.get(majorVersion);
121
243
  if (!cached) {
122
- cached = { majorVersion: runtimeState.twPatcher.majorVersion };
244
+ cached = runtimeState.twPatcher.majorVersion === void 0 ? {} : { majorVersion: runtimeState.twPatcher.majorVersion };
123
245
  defaultStyleHandlerOptionsCache.set(majorVersion, cached);
124
246
  }
125
247
  return cached;
126
248
  }
127
- return {
249
+ return runtimeState.twPatcher.majorVersion === void 0 ? { ...options } : {
128
250
  majorVersion: runtimeState.twPatcher.majorVersion,
129
251
  ...options
130
252
  };
@@ -159,15 +281,28 @@ function createPlugins(options = {}) {
159
281
  ...options
160
282
  };
161
283
  }
162
- const transformWxss = (options = {}) => createVinylTransform(async (file) => {
284
+ const transformWxss = (options = {}) => createVinylTransform("css", async (file) => {
163
285
  if (!file.contents) return;
164
- await refreshRuntimeState(true);
165
- await runtimeState.patchPromise;
166
286
  const rawSource = file.contents.toString();
287
+ const cssSourceChanged = await registerAutoCssSource(file, rawSource);
288
+ const isMainChunk = opts.mainCssChunkMatcher(resolveGulpMatcherName(file), opts.appType);
289
+ const shouldUseGenerator = runtimeState.twPatcher.majorVersion !== 3 || hasTailwindRootDirectives(rawSource);
290
+ let nextRuntimeSet = await refreshRuntimeSet({
291
+ forceRefresh: cssSourceChanged,
292
+ forceCollect: cssSourceChanged || runtimeState.twPatcher.majorVersion !== 4 && isMainChunk,
293
+ clearCache: cssSourceChanged
294
+ });
295
+ if (runtimeState.twPatcher.majorVersion === 3 && isMainChunk && shouldUseGenerator) {
296
+ const sourceCandidates = await refreshGulpSourceCandidates(cssSourceChanged);
297
+ if (sourceCandidates.size > 0) {
298
+ nextRuntimeSet = new Set([...nextRuntimeSet, ...sourceCandidates]);
299
+ runtimeSet = nextRuntimeSet;
300
+ }
301
+ }
167
302
  await processCachedTask({
168
303
  cache,
169
304
  cacheKey: file.path,
170
- rawSource,
305
+ hash: createRuntimeSetHash(rawSource, nextRuntimeSet),
171
306
  applyResult(source) {
172
307
  file.contents = Buffer.from(source);
173
308
  },
@@ -175,12 +310,12 @@ function createPlugins(options = {}) {
175
310
  debug("css cache hit: %s", file.path);
176
311
  },
177
312
  async transform() {
178
- await runtimeState.patchPromise;
313
+ await runtimeState.readyPromise;
179
314
  const cssHandlerOptions = resolveWxssFileHandlerOptions(file, options);
180
- const css = (hasExplicitGeneratorOptions ? await generateCssByGenerator({
315
+ const css = (shouldUseGenerator ? await generateCssByGenerator({
181
316
  opts,
182
317
  runtimeState,
183
- runtime: await refreshRuntimeSet(false),
318
+ runtime: nextRuntimeSet,
184
319
  rawSource,
185
320
  file: file.path,
186
321
  cssHandlerOptions,
@@ -193,23 +328,23 @@ function createPlugins(options = {}) {
193
328
  }
194
329
  });
195
330
  });
196
- const transformJs = (options = {}) => createVinylTransform(async (file) => {
331
+ const transformJs = (options = {}) => createVinylTransform("js", async (file) => {
197
332
  if (!file.contents) return;
198
- await refreshRuntimeSet(false);
199
- await runtimeState.patchPromise;
200
333
  const filename = path.resolve(file.path);
334
+ const rawSource = file.contents.toString();
335
+ await refreshRuntimeSetForSource(file, rawSource, "js");
336
+ await runtimeState.readyPromise;
201
337
  const moduleGraph = resolveModuleGraphOptions(options.moduleGraph);
202
338
  const handlerOptions = {
203
339
  ...options,
204
340
  filename,
205
341
  moduleGraph,
206
- tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
207
342
  babelParserOptions: {
208
343
  ...options?.babelParserOptions ?? {},
209
344
  sourceFilename: filename
210
345
  }
211
346
  };
212
- const rawSource = file.contents.toString();
347
+ if (runtimeState.twPatcher.majorVersion !== void 0) handlerOptions.tailwindcssMajorVersion = runtimeState.twPatcher.majorVersion;
213
348
  await processCachedTask({
214
349
  cache,
215
350
  cacheKey: file.path,
@@ -221,20 +356,23 @@ function createPlugins(options = {}) {
221
356
  debug("js cache hit: %s", file.path);
222
357
  },
223
358
  async transform() {
224
- await runtimeState.patchPromise;
359
+ await runtimeState.readyPromise;
225
360
  const currentSource = file.contents?.toString() ?? rawSource;
226
- if (shouldSkipJsTransform(currentSource, handlerOptions)) return { result: currentSource };
361
+ if (shouldSkipJsTransform(currentSource, {
362
+ ...handlerOptions,
363
+ classNameSet: runtimeSet
364
+ })) return { result: currentSource };
227
365
  const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
228
366
  debug("js handle: %s", file.path);
229
367
  return { result: code };
230
368
  }
231
369
  });
232
370
  });
233
- const transformWxml = (options = {}) => createVinylTransform(async (file) => {
371
+ const transformWxml = (options = {}) => createVinylTransform("html", async (file) => {
234
372
  if (!file.contents) return;
235
- await refreshRuntimeSet(false);
236
- await runtimeState.patchPromise;
237
373
  const rawSource = file.contents.toString();
374
+ await refreshRuntimeSetForSource(file, rawSource, "html");
375
+ await runtimeState.readyPromise;
238
376
  await processCachedTask({
239
377
  cache,
240
378
  cacheKey: file.path,
@@ -246,7 +384,7 @@ function createPlugins(options = {}) {
246
384
  debug("html cache hit: %s", file.path);
247
385
  },
248
386
  async transform() {
249
- await runtimeState.patchPromise;
387
+ await runtimeState.readyPromise;
250
388
  const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options));
251
389
  debug("html handle: %s", file.path);
252
390
  return { result: code };