weapp-tailwindcss 5.0.12 → 5.1.0

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 (205) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/auto-Ba6hDrse.mjs +13 -0
  4. package/dist/auto-DtU6f3X6.js +18 -0
  5. package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
  6. package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
  7. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +27 -10
  8. package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
  9. package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -0
  10. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +6 -0
  11. package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +7 -0
  12. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +3 -0
  13. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +15 -0
  14. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +12 -0
  15. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +22 -0
  16. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +6 -23
  17. package/dist/bundlers/shared/generator-css/types.d.ts +15 -1
  18. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
  19. package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
  20. package/dist/bundlers/shared/run-tasks.d.ts +1 -0
  21. package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
  22. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  23. package/dist/bundlers/vite/css-memory.d.ts +37 -0
  24. package/dist/bundlers/vite/generate-bundle/bundle-file-names.d.ts +2 -0
  25. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
  26. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +8 -0
  27. package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +4 -0
  28. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -0
  29. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +9 -7
  30. package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +6 -0
  31. package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +12 -0
  32. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +63 -0
  33. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +31 -0
  34. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +80 -0
  35. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +53 -0
  36. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
  37. package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +4 -0
  38. package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +21 -0
  39. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +5 -2
  40. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +30 -0
  41. package/dist/bundlers/vite/generate-bundle/timing.d.ts +1 -0
  42. package/dist/bundlers/vite/generate-bundle/types.d.ts +3 -1
  43. package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +20 -0
  44. package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +6 -0
  45. package/dist/bundlers/vite/generate-bundle.d.ts +4 -1
  46. package/dist/bundlers/vite/hot-css-modules.d.ts +5 -0
  47. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
  48. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
  49. package/dist/bundlers/vite/map-cache.d.ts +2 -0
  50. package/dist/bundlers/vite/processed-css-assets.d.ts +16 -0
  51. package/dist/bundlers/vite/resolve-app-type.d.ts +1 -2
  52. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  53. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -5
  54. package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +13 -0
  55. package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
  56. package/dist/bundlers/vite/source-candidates.d.ts +12 -2
  57. package/dist/bundlers/vite/source-scan/css-entries.d.ts +3 -6
  58. package/dist/bundlers/vite/source-scan.d.ts +3 -3
  59. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
  60. package/dist/bundlers/vite/utils.d.ts +1 -0
  61. package/dist/bundlers/vite/weapp-vite-config.d.ts +3 -1
  62. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +24 -0
  63. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -10
  64. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
  65. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +5 -1
  66. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +15 -1
  67. package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
  68. package/dist/cache/index.d.ts +1 -0
  69. package/dist/cli/mount-options.d.ts +2 -2
  70. package/dist/cli.js +126 -439
  71. package/dist/cli.mjs +121 -434
  72. package/dist/context/index.d.ts +3 -3
  73. package/dist/context/style-options.d.ts +4 -1
  74. package/dist/context/tailwindcss.d.ts +1 -1
  75. package/dist/{precheck-30zNPRlI.js → context-BHxLe743.js} +484 -175
  76. package/dist/{precheck-CsFr1q2l.mjs → context-Mbzkek1q.mjs} +461 -159
  77. package/dist/core.js +15 -12
  78. package/dist/core.mjs +10 -7
  79. package/dist/css-macro.js +2 -2
  80. package/dist/css-macro.mjs +2 -2
  81. package/dist/{defaults-Boc26eel.js → defaults-CVcKbXBG.js} +6 -50
  82. package/dist/{defaults-DH0ZQRhy.mjs → defaults-ZElj1zKc.mjs} +7 -45
  83. package/dist/defaults.d.ts +1 -7
  84. package/dist/defaults.js +1 -2
  85. package/dist/defaults.mjs +2 -2
  86. package/dist/framework/index.d.ts +59 -0
  87. package/dist/framework.d.ts +1 -0
  88. package/dist/framework.js +198 -0
  89. package/dist/framework.mjs +180 -0
  90. package/dist/generator/index.d.ts +6 -7
  91. package/dist/generator/options.d.ts +3 -3
  92. package/dist/generator/types.d.ts +9 -10
  93. package/dist/generator-9rUz4Hcb.js +170 -0
  94. package/dist/generator-Dc4qaPmT.mjs +123 -0
  95. package/dist/generator.js +10 -16
  96. package/dist/generator.mjs +3 -3
  97. package/dist/{gulp-CxGZU0-v.js → gulp-B_sdP6dx.js} +80 -92
  98. package/dist/{gulp-BfZpaYSQ.mjs → gulp-uM36oIJs.mjs} +73 -85
  99. package/dist/gulp.js +1 -1
  100. package/dist/gulp.mjs +1 -1
  101. package/dist/{hmr-timing-DNjF8bWA.mjs → hmr-timing-BXMLsF4b.mjs} +1289 -909
  102. package/dist/{hmr-timing-DFR51wgo.js → hmr-timing-CogqkFaF.js} +1397 -939
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.js +20 -4
  105. package/dist/index.mjs +6 -5
  106. package/dist/js/fast-path/oxc.d.ts +4 -0
  107. package/dist/js/precheck.d.ts +1 -0
  108. package/dist/postcss.js +3 -4
  109. package/dist/postcss.mjs +2 -3
  110. package/dist/presets.js +10 -20
  111. package/dist/presets.mjs +9 -19
  112. package/dist/runtime-branch/create-branch.d.ts +2 -0
  113. package/dist/runtime-branch/generator-target-env.d.ts +4 -0
  114. package/dist/runtime-branch/index.d.ts +6 -0
  115. package/dist/runtime-branch/mini-program.d.ts +2 -0
  116. package/dist/runtime-branch/native-app.d.ts +2 -0
  117. package/dist/runtime-branch/platform.d.ts +6 -0
  118. package/dist/runtime-branch/tailwind-version.d.ts +2 -0
  119. package/dist/runtime-branch/types.d.ts +37 -0
  120. package/dist/runtime-branch/web.d.ts +2 -0
  121. package/dist/runtime-branch.d.ts +1 -0
  122. package/dist/{bundle-state-DU2ATDhw.js → source-candidate-scan-signature-2ybpptAK.js} +262 -20
  123. package/dist/{bundle-state-BxMNKjBV.mjs → source-candidate-scan-signature-Cvb5z1ha.mjs} +187 -17
  124. package/dist/tailwindcss/candidates.d.ts +7 -0
  125. package/dist/tailwindcss/index.d.ts +2 -2
  126. package/dist/tailwindcss/runtime/cache.d.ts +6 -6
  127. package/dist/tailwindcss/runtime-factory.d.ts +12 -0
  128. package/dist/tailwindcss/runtime-options.d.ts +8 -0
  129. package/dist/tailwindcss/runtime-types.d.ts +86 -0
  130. package/dist/tailwindcss/runtime.d.ts +6 -6
  131. package/dist/tailwindcss/source-scan.d.ts +1 -1
  132. package/dist/tailwindcss/targets.d.ts +2 -2
  133. package/dist/tailwindcss/v4/config.d.ts +3 -3
  134. package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
  135. package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
  136. package/dist/tailwindcss/v4/index.d.ts +1 -1
  137. package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
  138. package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
  139. package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
  140. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
  141. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
  142. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
  143. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
  144. package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
  145. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  146. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
  147. package/dist/tailwindcss/v4-engine/source.d.ts +23 -6
  148. package/dist/tailwindcss/v4-engine/types.d.ts +8 -9
  149. package/dist/tailwindcss/version.d.ts +1 -1
  150. package/dist/tailwindcss-DHIYcqXT.js +1523 -0
  151. package/dist/tailwindcss-wyUHrfil.mjs +1418 -0
  152. package/dist/{transform-CaVEBOuR.js → transform-CQVOgmzM.js} +45 -37
  153. package/dist/{transform-Cju08-aJ.mjs → transform-tExdt40m.mjs} +30 -22
  154. package/dist/typedoc.export.d.ts +1 -1
  155. package/dist/types/index.d.ts +16 -17
  156. package/dist/types/shared.d.ts +1 -1
  157. package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
  158. package/dist/types/user-defined-options/general.d.ts +8 -4
  159. package/dist/types/user-defined-options/important.d.ts +2 -2
  160. package/dist/uni-app-x/style-asset.d.ts +1 -0
  161. package/dist/{utils-Dolmt8EO.js → utils-BCa37Wqj.js} +2 -17
  162. package/dist/{utils-DsaS975I.mjs → utils-DodxWHGz.mjs} +2 -17
  163. package/dist/v4-engine-CF9zt4Cw.mjs +2396 -0
  164. package/dist/v4-engine-D4ubP7N5.js +2778 -0
  165. package/dist/{vite-BBGOjh9e.js → vite-CP0ylSxZ.js} +2887 -1683
  166. package/dist/{vite-CS5DE-HD.mjs → vite-CPO83EhA.mjs} +2753 -1548
  167. package/dist/vite.js +1 -1
  168. package/dist/vite.mjs +1 -1
  169. package/dist/weapp-tw-css-import-rewrite-loader.js +5741 -4396
  170. package/dist/weapp-tw-runtime-classset-loader.js +36 -0
  171. package/dist/webpack-Bsek8VhR.js +2094 -0
  172. package/dist/webpack-BzqhJ8yK.mjs +2082 -0
  173. package/dist/webpack.js +1 -1
  174. package/dist/webpack.mjs +1 -1
  175. package/package.json +11 -7
  176. package/dist/auto-CTp6wE5a.js +0 -33
  177. package/dist/auto-Cl8_hsG6.mjs +0 -22
  178. package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
  179. package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
  180. package/dist/context/tailwindcss/rax.d.ts +0 -2
  181. package/dist/generator-Cb1Zp3Al.js +0 -92
  182. package/dist/generator-mvNFUvns.mjs +0 -67
  183. package/dist/tailwindcss/patcher-options.d.ts +0 -8
  184. package/dist/tailwindcss/patcher.d.ts +0 -12
  185. package/dist/tailwindcss/runtime-patch.d.ts +0 -5
  186. package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
  187. package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
  188. package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
  189. package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
  190. package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
  191. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
  192. package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
  193. package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
  194. package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
  195. package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
  196. package/dist/tailwindcss/v4/patcher.d.ts +0 -15
  197. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
  198. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
  199. package/dist/tailwindcss-CK84uGBp.mjs +0 -556
  200. package/dist/tailwindcss-Clpkz1oR.js +0 -613
  201. package/dist/v3-engine-CQE5JJNZ.js +0 -4639
  202. package/dist/v3-engine-DKBaKWGL.mjs +0 -4231
  203. package/dist/webpack-DIWrcpRo.js +0 -1066
  204. package/dist/webpack-SPcri_D8.mjs +0 -1054
  205. /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
@@ -1,10 +1,12 @@
1
1
  const require_chunk = require("./chunk-emK7D4bc.js");
2
- const require_precheck = require("./precheck-30zNPRlI.js");
3
- let node_module = require("node:module");
2
+ const require_context = require("./context-BHxLe743.js");
3
+ const require_tailwindcss = require("./tailwindcss-DHIYcqXT.js");
4
+ const require_hmr_timing = require("./hmr-timing-CogqkFaF.js");
4
5
  let node_path = require("node:path");
5
6
  node_path = require_chunk.__toESM(node_path);
6
7
  let node_process = require("node:process");
7
8
  node_process = require_chunk.__toESM(node_process);
9
+ let node_module = require("node:module");
8
10
  let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
9
11
  let node_buffer = require("node:buffer");
10
12
  //#region src/bundlers/shared/module-graph.ts
@@ -80,10 +82,14 @@ function slash(p) {
80
82
  return (0, _weapp_tailwindcss_shared.ensurePosix)(p);
81
83
  }
82
84
  const isWindows = node_process.default.platform === "win32";
83
- const cssLangRE = new RegExp(`\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`);
85
+ const cssLangRE = new RegExp(`\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)`);
86
+ const htmlLangRE = /\.html?(?:$|\?)/;
84
87
  function isCSSRequest(request) {
85
88
  return cssLangRE.test(request) || isSourceStyleRequest(request);
86
89
  }
90
+ function isHTMLRequest(request) {
91
+ return htmlLangRE.test(request);
92
+ }
87
93
  function normalizePath(id) {
88
94
  return node_path.default.posix.normalize(isWindows ? (0, _weapp_tailwindcss_shared.ensurePosix)(id) : id);
89
95
  }
@@ -119,9 +125,9 @@ function resolvePackageDir(name) {
119
125
  }
120
126
  //#endregion
121
127
  //#region src/bundlers/shared/generated-css-marker.ts
122
- const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/i;
123
- const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/gi;
124
- const BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE = /\/\*!\s*weapp-tailwindcss (vite|webpack)-generated-css(?::([^\s*]+))?\s*\*\/\s*/gi;
128
+ const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!?\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/i;
129
+ const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/gi;
130
+ const BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE = /\/\*!?\s*weapp-tailwindcss (vite|webpack)-generated-css(?:\s*:\s*([^\s*]+))?\s*\*\/\s*/gi;
125
131
  function createBundlerGeneratedCssMarker(bundler, file) {
126
132
  return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
127
133
  }
@@ -150,6 +156,25 @@ function parseBundlerGeneratedCssMarkerBlocks(source) {
150
156
  return blocks;
151
157
  }
152
158
  //#endregion
159
+ //#region src/bundlers/shared/v4-generation-core.ts
160
+ async function generateTailwindV4Css(options) {
161
+ const majorVersion = options.runtimeState.tailwindRuntime.majorVersion;
162
+ if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
163
+ const generated = await require_hmr_timing.generateCssByGenerator(options);
164
+ if (!generated) return;
165
+ return {
166
+ ...generated,
167
+ classSet: generated.classSet,
168
+ dependencies: generated.dependencies,
169
+ metadata: {
170
+ file: options.file,
171
+ majorVersion,
172
+ outputFile: options.outputFile,
173
+ ...generated.metadata ?? {}
174
+ }
175
+ };
176
+ }
177
+ //#endregion
153
178
  //#region src/bundlers/vite/bundle-entries.ts
154
179
  function readOutputEntry(entry) {
155
180
  if (entry.output.type === "chunk") return entry.output.code;
@@ -203,10 +228,12 @@ const CSS_BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
203
228
  const CSS_AROUND_PUNCTUATION_RE = /\s*([{}:;,>+~()])\s*/g;
204
229
  const CSS_TRAILING_DECLARATION_SEMICOLON_RE = /;\}/g;
205
230
  const CSS_WHITESPACE_RE = /\s+/g;
231
+ const JS_RUNTIME_AFFECTING_TEXT_HINT_RE = /["'`/]/;
232
+ const JS_INCOMPLETE_TRAILING_OPERATOR_RE = /(?:=>|[=+\-*%&|^!~?:,.({[\]])\s*$/;
206
233
  function createHtmlRuntimeAffectingSignature(source) {
207
234
  try {
208
235
  const parts = [];
209
- const parser = new require_precheck.Parser({
236
+ const parser = new require_context.Parser({
210
237
  onattribute(name, value) {
211
238
  parts.push(`a:${name}=${value}`);
212
239
  },
@@ -226,15 +253,16 @@ function createHtmlRuntimeAffectingSignature(source) {
226
253
  }
227
254
  }
228
255
  function createJsRuntimeAffectingSignature(source) {
256
+ if (!JS_RUNTIME_AFFECTING_TEXT_HINT_RE.test(source) && !JS_INCOMPLETE_TRAILING_OPERATOR_RE.test(source)) return "";
229
257
  try {
230
- const ast = require_precheck.babelParse(source, {
231
- cache: true,
258
+ const ast = require_context.babelParse(source, {
259
+ cache: false,
232
260
  cacheKey: "vite-runtime-affecting:unambiguous",
233
261
  plugins: ["jsx", "typescript"],
234
262
  sourceType: "unambiguous"
235
263
  });
236
264
  const parts = [];
237
- require_precheck.traverse(ast, {
265
+ require_context.traverse(ast, {
238
266
  noScope: true,
239
267
  StringLiteral(path) {
240
268
  parts.push(`s:${path.node.value}`);
@@ -298,8 +326,8 @@ function readEntrySource(output) {
298
326
  return output.source.toString();
299
327
  }
300
328
  function classifyBundleEntry(file, opts) {
329
+ if (opts.htmlMatcher(file) || isHTMLRequest(file)) return "html";
301
330
  if (opts.cssMatcher(file) || isCSSRequest(file)) return "css";
302
- if (opts.htmlMatcher(file)) return "html";
303
331
  if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
304
332
  return "other";
305
333
  }
@@ -334,12 +362,12 @@ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false, opti
334
362
  sourceHashByFile.set(file, hash);
335
363
  const previousHash = state.sourceHashByFile.get(file);
336
364
  const changed = previousHash == null || previousHash !== hash;
337
- const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
338
365
  const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
339
- const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
340
- const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
341
- const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
342
- runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
366
+ const runtimeAffectingHash = !changed && previousRuntimeAffectingHash != null ? previousRuntimeAffectingHash : (() => {
367
+ const runtimeAffectingSignature = createRuntimeAffectingSourceSignature(source, type);
368
+ runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
369
+ return opts.cache.computeHash(runtimeAffectingSignature);
370
+ })();
343
371
  runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
344
372
  if (changed) changedByType[type].add(file);
345
373
  if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
@@ -392,16 +420,158 @@ function invertLinkedByEntry(linkedByEntry) {
392
420
  }
393
421
  return dependentsByLinkedFile;
394
422
  }
423
+ function replaceMapEntries(target, source) {
424
+ target.clear();
425
+ for (const [key, value] of source) target.set(key, value);
426
+ return target;
427
+ }
428
+ function mergeMapEntries(target, source) {
429
+ for (const [key, value] of source) target.set(key, value);
430
+ return target;
431
+ }
395
432
  function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
396
433
  const incremental = options.incremental === true;
397
434
  state.iteration += 1;
398
- state.sourceHashByFile = incremental ? new Map([...state.sourceHashByFile, ...snapshot.sourceHashByFile]) : snapshot.sourceHashByFile;
399
- state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
400
- state.runtimeAffectingHashByFile = incremental ? new Map([...state.runtimeAffectingHashByFile, ...snapshot.runtimeAffectingHashByFile]) : snapshot.runtimeAffectingHashByFile;
401
- state.linkedByEntry = incremental ? new Map([...state.linkedByEntry, ...linkedByEntry]) : linkedByEntry;
435
+ state.sourceHashByFile = incremental ? mergeMapEntries(state.sourceHashByFile, snapshot.sourceHashByFile) : replaceMapEntries(state.sourceHashByFile, snapshot.sourceHashByFile);
436
+ state.runtimeAffectingSignatureByFile.clear();
437
+ state.runtimeAffectingHashByFile = incremental ? mergeMapEntries(state.runtimeAffectingHashByFile, snapshot.runtimeAffectingHashByFile) : replaceMapEntries(state.runtimeAffectingHashByFile, snapshot.runtimeAffectingHashByFile);
438
+ state.linkedByEntry = incremental ? mergeMapEntries(state.linkedByEntry, linkedByEntry) : replaceMapEntries(state.linkedByEntry, linkedByEntry);
402
439
  state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
403
440
  }
404
441
  //#endregion
442
+ //#region src/bundlers/vite/generate-bundle/signatures.ts
443
+ function summarizeStringDiff(previous, next) {
444
+ if (previous === next) return "same";
445
+ const previousLength = previous.length;
446
+ const nextLength = next.length;
447
+ const minLength = Math.min(previousLength, nextLength);
448
+ let prefixLength = 0;
449
+ while (prefixLength < minLength && previous.charCodeAt(prefixLength) === next.charCodeAt(prefixLength)) prefixLength += 1;
450
+ let previousSuffixCursor = previousLength - 1;
451
+ let nextSuffixCursor = nextLength - 1;
452
+ while (previousSuffixCursor >= prefixLength && nextSuffixCursor >= prefixLength && previous.charCodeAt(previousSuffixCursor) === next.charCodeAt(nextSuffixCursor)) {
453
+ previousSuffixCursor -= 1;
454
+ nextSuffixCursor -= 1;
455
+ }
456
+ const previousChangedLength = previousSuffixCursor >= prefixLength ? previousSuffixCursor - prefixLength + 1 : 0;
457
+ const nextChangedLength = nextSuffixCursor >= prefixLength ? nextSuffixCursor - prefixLength + 1 : 0;
458
+ return `changed@${prefixLength} old=${previousChangedLength} new=${nextChangedLength} len=${previousLength}->${nextLength}`;
459
+ }
460
+ function createLinkedImpactSignature(entry, linkedImpactsByEntry, sourceHashByFile) {
461
+ const changedLinkedFiles = linkedImpactsByEntry.get(entry);
462
+ if (!changedLinkedFiles || changedLinkedFiles.size === 0) return;
463
+ return [...changedLinkedFiles].sort().map((file) => {
464
+ return `${file}:${sourceHashByFile.get(file) ?? "missing"}`;
465
+ }).join(",");
466
+ }
467
+ function createJsHashSalt(runtimeSignature, linkedImpactSignature) {
468
+ if (!linkedImpactSignature) return runtimeSignature;
469
+ return `${runtimeSignature}:linked:${linkedImpactSignature}`;
470
+ }
471
+ function createStableTextSignature(input) {
472
+ let hash = 2166136261;
473
+ for (let i = 0; i < input.length; i++) {
474
+ hash ^= input.charCodeAt(i);
475
+ hash = Math.imul(hash, 16777619);
476
+ }
477
+ return (hash >>> 0).toString(36);
478
+ }
479
+ function createCandidateSignature(candidates) {
480
+ if (candidates.size === 0) return "empty";
481
+ return createStableTextSignature([...candidates].sort().join("\n"));
482
+ }
483
+ function getSnapshotHash(snapshotMap, file, fallback) {
484
+ return snapshotMap.get(file) ?? fallback;
485
+ }
486
+ function hasRuntimeAffectingSourceChanges(changedByType) {
487
+ return changedByType.html.size > 0 || changedByType.js.size > 0;
488
+ }
489
+ //#endregion
490
+ //#region src/bundlers/vite/generate-bundle/scoped-generator.ts
491
+ function hasOwnSourceDirectives(rawSource) {
492
+ return rawSource.includes("@source") || rawSource.includes("@config");
493
+ }
494
+ function createLocalSourceEntries(sourceFile) {
495
+ return [{
496
+ base: node_path.default.dirname(node_path.default.resolve(sourceFile.replace(/[?#].*$/, ""))),
497
+ negated: false,
498
+ pattern: "**/*"
499
+ }];
500
+ }
501
+ function intersectCandidates(first, second) {
502
+ const scoped = /* @__PURE__ */ new Set();
503
+ const [small, large] = first.size <= second.size ? [first, second] : [second, first];
504
+ for (const candidate of small) if (large.has(candidate)) scoped.add(candidate);
505
+ return scoped;
506
+ }
507
+ function resolveScopedSourceEntries(rawSource, sourceFile, resolvedEntries) {
508
+ if (!hasOwnSourceDirectives(rawSource)) return {
509
+ entries: resolvedEntries,
510
+ localEntries: void 0
511
+ };
512
+ const localEntries = createLocalSourceEntries(sourceFile);
513
+ if (!resolvedEntries || resolvedEntries.length === 0) return {
514
+ entries: localEntries,
515
+ localEntries: void 0
516
+ };
517
+ return {
518
+ entries: resolvedEntries,
519
+ localEntries
520
+ };
521
+ }
522
+ async function createScopedGeneratorCandidateSignature(rawSource, sourceFile, fallbackSignature, getSourceCandidatesForEntries, options = {}) {
523
+ if (!getSourceCandidatesForEntries || !hasOwnSourceDirectives(rawSource)) return fallbackSignature;
524
+ const { entries, localEntries } = resolveScopedSourceEntries(rawSource, sourceFile, (await require_tailwindcss.resolveTailwindV4EntriesFromCssCached(rawSource, node_path.default.dirname(node_path.default.resolve(sourceFile.replace(/[?#].*$/, "")))))?.entries);
525
+ if (entries === void 0) return fallbackSignature;
526
+ const scopedCandidates = getSourceCandidatesForEntries(entries);
527
+ const scopedSignature = createCandidateSignature(localEntries ? intersectCandidates(scopedCandidates, getSourceCandidatesForEntries(localEntries)) : scopedCandidates);
528
+ return options.includeFallbackSignature === true ? `${scopedSignature}:${fallbackSignature}` : scopedSignature;
529
+ }
530
+ async function createScopedGeneratorRuntime(options) {
531
+ const { cssHandlerOptions, fallbackRuntime, getSourceCandidatesForEntries, outputFile, rawSource, shouldExcludeSubpackageSourceCandidates, sourceFile, scopedSourceCandidateGetter } = options;
532
+ if (getSourceCandidatesForEntries && rawSource && sourceFile) {
533
+ const { entries, localEntries } = resolveScopedSourceEntries(rawSource, sourceFile, (await require_tailwindcss.resolveTailwindV4EntriesFromCssCached(rawSource, node_path.default.dirname(node_path.default.resolve(sourceFile.replace(/[?#].*$/, "")))))?.entries);
534
+ if (entries !== void 0 && (entries.length > 0 || hasOwnSourceDirectives(rawSource))) {
535
+ const scopedCandidates = scopedSourceCandidateGetter?.(entries) ?? getSourceCandidatesForEntries(entries);
536
+ if (!localEntries) return scopedCandidates;
537
+ return intersectCandidates(scopedCandidates, scopedSourceCandidateGetter?.(localEntries) ?? getSourceCandidatesForEntries(localEntries));
538
+ }
539
+ }
540
+ const scopedCandidates = scopedSourceCandidateGetter?.(void 0);
541
+ if (scopedCandidates && (scopedCandidates.size > 0 || shouldExcludeSubpackageSourceCandidates(outputFile, cssHandlerOptions))) return scopedCandidates;
542
+ if (!shouldExcludeSubpackageSourceCandidates(outputFile, cssHandlerOptions)) return fallbackRuntime;
543
+ return fallbackRuntime;
544
+ }
545
+ //#endregion
546
+ //#region src/bundlers/vite/source-candidate-scan-signature.ts
547
+ function normalizeSignaturePath(value) {
548
+ return slash(node_path.default.resolve(value));
549
+ }
550
+ function serializeInlineCandidates(inlineCandidates) {
551
+ return {
552
+ excluded: [...inlineCandidates?.excluded ?? []].sort(),
553
+ included: [...inlineCandidates?.included ?? []].sort()
554
+ };
555
+ }
556
+ function serializeSourceEntries(entries) {
557
+ return (entries ?? []).map((entry) => ({
558
+ base: normalizeSignaturePath(entry.base),
559
+ negated: entry.negated,
560
+ pattern: entry.pattern
561
+ })).sort((a, b) => `${a.base}\0${a.pattern}\0${a.negated}`.localeCompare(`${b.base}\0${b.pattern}\0${b.negated}`));
562
+ }
563
+ function createSourceCandidateScanSignature(input) {
564
+ return JSON.stringify({
565
+ inlineCandidates: serializeInlineCandidates(input.inlineCandidates),
566
+ outDir: input.outDir ? normalizeSignaturePath(input.outDir) : void 0,
567
+ roots: input.roots.map((root) => ({
568
+ entries: serializeSourceEntries(root.entries),
569
+ root: normalizeSignaturePath(root.root)
570
+ })),
571
+ scanAllSources: input.scanAllSources ?? false
572
+ });
573
+ }
574
+ //#endregion
405
575
  Object.defineProperty(exports, "applyLinkedResults", {
406
576
  enumerable: true,
407
577
  get: function() {
@@ -414,6 +584,12 @@ Object.defineProperty(exports, "buildBundleSnapshot", {
414
584
  return buildBundleSnapshot;
415
585
  }
416
586
  });
587
+ Object.defineProperty(exports, "classifyBundleEntry", {
588
+ enumerable: true,
589
+ get: function() {
590
+ return classifyBundleEntry;
591
+ }
592
+ });
417
593
  Object.defineProperty(exports, "createBundleBuildState", {
418
594
  enumerable: true,
419
595
  get: function() {
@@ -432,30 +608,90 @@ Object.defineProperty(exports, "createBundlerGeneratedCssMarker", {
432
608
  return createBundlerGeneratedCssMarker;
433
609
  }
434
610
  });
611
+ Object.defineProperty(exports, "createCandidateSignature", {
612
+ enumerable: true,
613
+ get: function() {
614
+ return createCandidateSignature;
615
+ }
616
+ });
617
+ Object.defineProperty(exports, "createJsHashSalt", {
618
+ enumerable: true,
619
+ get: function() {
620
+ return createJsHashSalt;
621
+ }
622
+ });
623
+ Object.defineProperty(exports, "createLinkedImpactSignature", {
624
+ enumerable: true,
625
+ get: function() {
626
+ return createLinkedImpactSignature;
627
+ }
628
+ });
435
629
  Object.defineProperty(exports, "createRuntimeAffectingSourceSignature", {
436
630
  enumerable: true,
437
631
  get: function() {
438
632
  return createRuntimeAffectingSourceSignature;
439
633
  }
440
634
  });
635
+ Object.defineProperty(exports, "createScopedGeneratorCandidateSignature", {
636
+ enumerable: true,
637
+ get: function() {
638
+ return createScopedGeneratorCandidateSignature;
639
+ }
640
+ });
641
+ Object.defineProperty(exports, "createScopedGeneratorRuntime", {
642
+ enumerable: true,
643
+ get: function() {
644
+ return createScopedGeneratorRuntime;
645
+ }
646
+ });
647
+ Object.defineProperty(exports, "createSourceCandidateScanSignature", {
648
+ enumerable: true,
649
+ get: function() {
650
+ return createSourceCandidateScanSignature;
651
+ }
652
+ });
441
653
  Object.defineProperty(exports, "formatPostcssSourceMap", {
442
654
  enumerable: true,
443
655
  get: function() {
444
656
  return formatPostcssSourceMap;
445
657
  }
446
658
  });
659
+ Object.defineProperty(exports, "generateTailwindV4Css", {
660
+ enumerable: true,
661
+ get: function() {
662
+ return generateTailwindV4Css;
663
+ }
664
+ });
665
+ Object.defineProperty(exports, "getSnapshotHash", {
666
+ enumerable: true,
667
+ get: function() {
668
+ return getSnapshotHash;
669
+ }
670
+ });
447
671
  Object.defineProperty(exports, "hasBundlerGeneratedCssMarker", {
448
672
  enumerable: true,
449
673
  get: function() {
450
674
  return hasBundlerGeneratedCssMarker;
451
675
  }
452
676
  });
677
+ Object.defineProperty(exports, "hasRuntimeAffectingSourceChanges", {
678
+ enumerable: true,
679
+ get: function() {
680
+ return hasRuntimeAffectingSourceChanges;
681
+ }
682
+ });
453
683
  Object.defineProperty(exports, "isCSSRequest", {
454
684
  enumerable: true,
455
685
  get: function() {
456
686
  return isCSSRequest;
457
687
  }
458
688
  });
689
+ Object.defineProperty(exports, "isHTMLRequest", {
690
+ enumerable: true,
691
+ get: function() {
692
+ return isHTMLRequest;
693
+ }
694
+ });
459
695
  Object.defineProperty(exports, "isSourceStyleRequest", {
460
696
  enumerable: true,
461
697
  get: function() {
@@ -516,6 +752,12 @@ Object.defineProperty(exports, "stripRequestQuery", {
516
752
  return stripRequestQuery;
517
753
  }
518
754
  });
755
+ Object.defineProperty(exports, "summarizeStringDiff", {
756
+ enumerable: true,
757
+ get: function() {
758
+ return summarizeStringDiff;
759
+ }
760
+ });
519
761
  Object.defineProperty(exports, "toAbsoluteOutputPath", {
520
762
  enumerable: true,
521
763
  get: function() {