weapp-tailwindcss 5.0.13 → 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 (178) 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 +21 -9
  8. package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
  9. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
  10. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +0 -1
  11. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -1
  12. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +3 -3
  13. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
  14. package/dist/bundlers/shared/generator-css/types.d.ts +13 -1
  15. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
  16. package/dist/bundlers/shared/run-tasks.d.ts +1 -0
  17. package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
  18. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  19. package/dist/bundlers/vite/css-memory.d.ts +10 -0
  20. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
  21. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
  22. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -0
  23. package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +0 -1
  24. package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +12 -0
  25. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +5 -0
  26. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +21 -18
  27. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +3 -1
  28. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -0
  29. package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
  30. package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +1 -1
  31. package/dist/bundlers/vite/generate-bundle.d.ts +3 -1
  32. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
  33. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
  34. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  35. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -5
  36. package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
  37. package/dist/bundlers/vite/source-candidates.d.ts +9 -2
  38. package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -6
  39. package/dist/bundlers/vite/source-scan.d.ts +2 -2
  40. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
  41. package/dist/bundlers/vite/utils.d.ts +1 -0
  42. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +24 -0
  43. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -11
  44. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
  45. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -2
  46. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +10 -1
  47. package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
  48. package/dist/cache/index.d.ts +1 -0
  49. package/dist/cli/mount-options.d.ts +2 -2
  50. package/dist/cli.js +124 -437
  51. package/dist/cli.mjs +120 -433
  52. package/dist/context/index.d.ts +3 -3
  53. package/dist/context/style-options.d.ts +4 -1
  54. package/dist/context/tailwindcss.d.ts +1 -1
  55. package/dist/{precheck-B0Z8yW7E.js → context-BHxLe743.js} +391 -153
  56. package/dist/{precheck-CRI90iL1.mjs → context-Mbzkek1q.mjs} +368 -137
  57. package/dist/core.js +15 -12
  58. package/dist/core.mjs +10 -7
  59. package/dist/css-macro.js +1 -1
  60. package/dist/css-macro.mjs +1 -1
  61. package/dist/{defaults-C_J_kBpw.js → defaults-CVcKbXBG.js} +4 -15
  62. package/dist/{defaults-Bqx18S1f.mjs → defaults-ZElj1zKc.mjs} +5 -10
  63. package/dist/defaults.d.ts +1 -7
  64. package/dist/defaults.js +1 -2
  65. package/dist/defaults.mjs +2 -2
  66. package/dist/generator/index.d.ts +6 -7
  67. package/dist/generator/options.d.ts +3 -3
  68. package/dist/generator/types.d.ts +9 -10
  69. package/dist/generator-9rUz4Hcb.js +170 -0
  70. package/dist/generator-Dc4qaPmT.mjs +123 -0
  71. package/dist/generator.js +10 -16
  72. package/dist/generator.mjs +3 -3
  73. package/dist/{gulp-XT8Jc7lH.js → gulp-B_sdP6dx.js} +47 -87
  74. package/dist/{gulp-DfOQERcV.mjs → gulp-uM36oIJs.mjs} +40 -80
  75. package/dist/gulp.js +1 -1
  76. package/dist/gulp.mjs +1 -1
  77. package/dist/{hmr-timing-DQIP_8qP.mjs → hmr-timing-BXMLsF4b.mjs} +1145 -842
  78. package/dist/{hmr-timing-BMftW7Us.js → hmr-timing-CogqkFaF.js} +1262 -881
  79. package/dist/index.js +4 -4
  80. package/dist/index.mjs +4 -4
  81. package/dist/js/fast-path/oxc.d.ts +4 -0
  82. package/dist/js/precheck.d.ts +1 -0
  83. package/dist/postcss.js +3 -4
  84. package/dist/postcss.mjs +2 -3
  85. package/dist/presets.js +9 -19
  86. package/dist/presets.mjs +8 -18
  87. package/dist/runtime-branch/create-branch.d.ts +2 -0
  88. package/dist/runtime-branch/generator-target-env.d.ts +4 -0
  89. package/dist/runtime-branch/index.d.ts +6 -0
  90. package/dist/runtime-branch/mini-program.d.ts +2 -0
  91. package/dist/runtime-branch/native-app.d.ts +2 -0
  92. package/dist/runtime-branch/platform.d.ts +6 -0
  93. package/dist/runtime-branch/tailwind-version.d.ts +2 -0
  94. package/dist/runtime-branch/types.d.ts +37 -0
  95. package/dist/runtime-branch/web.d.ts +2 -0
  96. package/dist/runtime-branch.d.ts +1 -0
  97. package/dist/{bundle-state-CKWeTEhv.js → source-candidate-scan-signature-2ybpptAK.js} +261 -19
  98. package/dist/{bundle-state-zQ2MrDdi.mjs → source-candidate-scan-signature-Cvb5z1ha.mjs} +187 -17
  99. package/dist/tailwindcss/candidates.d.ts +7 -0
  100. package/dist/tailwindcss/index.d.ts +2 -2
  101. package/dist/tailwindcss/runtime/cache.d.ts +6 -6
  102. package/dist/tailwindcss/runtime-factory.d.ts +12 -0
  103. package/dist/tailwindcss/runtime-options.d.ts +8 -0
  104. package/dist/tailwindcss/runtime-types.d.ts +86 -0
  105. package/dist/tailwindcss/runtime.d.ts +6 -6
  106. package/dist/tailwindcss/source-scan.d.ts +1 -1
  107. package/dist/tailwindcss/targets.d.ts +2 -2
  108. package/dist/tailwindcss/v4/config.d.ts +3 -3
  109. package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
  110. package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
  111. package/dist/tailwindcss/v4/index.d.ts +1 -1
  112. package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
  113. package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
  114. package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
  115. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
  116. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
  117. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
  118. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
  119. package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
  120. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  121. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
  122. package/dist/tailwindcss/v4-engine/source.d.ts +23 -6
  123. package/dist/tailwindcss/v4-engine/types.d.ts +8 -9
  124. package/dist/tailwindcss/version.d.ts +1 -1
  125. package/dist/tailwindcss-DHIYcqXT.js +1523 -0
  126. package/dist/tailwindcss-wyUHrfil.mjs +1418 -0
  127. package/dist/{transform-YmrmxuF3.js → transform-CQVOgmzM.js} +17 -17
  128. package/dist/{transform-DfcEjsZF.mjs → transform-tExdt40m.mjs} +2 -2
  129. package/dist/typedoc.export.d.ts +1 -1
  130. package/dist/types/index.d.ts +16 -17
  131. package/dist/types/shared.d.ts +1 -1
  132. package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
  133. package/dist/types/user-defined-options/general.d.ts +5 -3
  134. package/dist/types/user-defined-options/important.d.ts +2 -2
  135. package/dist/uni-app-x/style-asset.d.ts +1 -0
  136. package/dist/v4-engine-CF9zt4Cw.mjs +2396 -0
  137. package/dist/v4-engine-D4ubP7N5.js +2778 -0
  138. package/dist/{vite-CXHVsHmX.js → vite-CP0ylSxZ.js} +1081 -542
  139. package/dist/{vite-DjI09vVN.mjs → vite-CPO83EhA.mjs} +916 -376
  140. package/dist/vite.js +1 -1
  141. package/dist/vite.mjs +1 -1
  142. package/dist/weapp-tw-css-import-rewrite-loader.js +5350 -4165
  143. package/dist/weapp-tw-runtime-classset-loader.js +15 -4
  144. package/dist/webpack-Bsek8VhR.js +2094 -0
  145. package/dist/webpack-BzqhJ8yK.mjs +2082 -0
  146. package/dist/webpack.js +1 -1
  147. package/dist/webpack.mjs +1 -1
  148. package/package.json +4 -5
  149. package/dist/auto-CTp6wE5a.js +0 -33
  150. package/dist/auto-Cl8_hsG6.mjs +0 -22
  151. package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
  152. package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
  153. package/dist/context/tailwindcss/rax.d.ts +0 -2
  154. package/dist/generator-CzpArpCL.js +0 -92
  155. package/dist/generator-ITLd7PTl.mjs +0 -67
  156. package/dist/tailwindcss/patcher-options.d.ts +0 -8
  157. package/dist/tailwindcss/patcher.d.ts +0 -12
  158. package/dist/tailwindcss/runtime-patch.d.ts +0 -5
  159. package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
  160. package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
  161. package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
  162. package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
  163. package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
  164. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
  165. package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
  166. package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
  167. package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
  168. package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
  169. package/dist/tailwindcss/v4/patcher.d.ts +0 -15
  170. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
  171. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
  172. package/dist/tailwindcss-DTq3uYBK.mjs +0 -556
  173. package/dist/tailwindcss-DZEwT3C_.js +0 -613
  174. package/dist/v3-engine-2rrgylhn.js +0 -4686
  175. package/dist/v3-engine-C6eJ0YzK.mjs +0 -4272
  176. package/dist/webpack-BcPpnT90.mjs +0 -1184
  177. package/dist/webpack-CfkUkMXG.js +0 -1196
  178. /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
@@ -1,5 +1,7 @@
1
1
  const require_chunk = require("./chunk-emK7D4bc.js");
2
- const require_precheck = require("./precheck-B0Z8yW7E.js");
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");
3
5
  let node_path = require("node:path");
4
6
  node_path = require_chunk.__toESM(node_path);
5
7
  let node_process = require("node:process");
@@ -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() {
@@ -1,4 +1,6 @@
1
- import { h as traverse, m as babelParse, o as Parser } from "./precheck-CRI90iL1.mjs";
1
+ import { a as Parser, h as traverse, m as babelParse } from "./context-Mbzkek1q.mjs";
2
+ import { g as resolveTailwindV4EntriesFromCssCached } from "./tailwindcss-wyUHrfil.mjs";
3
+ import { u as generateCssByGenerator } from "./hmr-timing-BXMLsF4b.mjs";
2
4
  import { createRequire } from "node:module";
3
5
  import path from "node:path";
4
6
  import process from "node:process";
@@ -77,10 +79,14 @@ function slash(p) {
77
79
  return ensurePosix(p);
78
80
  }
79
81
  const isWindows = process.platform === "win32";
80
- const cssLangRE = new RegExp(`\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`);
82
+ const cssLangRE = new RegExp(`\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)`);
83
+ const htmlLangRE = /\.html?(?:$|\?)/;
81
84
  function isCSSRequest(request) {
82
85
  return cssLangRE.test(request) || isSourceStyleRequest(request);
83
86
  }
87
+ function isHTMLRequest(request) {
88
+ return htmlLangRE.test(request);
89
+ }
84
90
  function normalizePath(id) {
85
91
  return path.posix.normalize(isWindows ? ensurePosix(id) : id);
86
92
  }
@@ -116,9 +122,9 @@ function resolvePackageDir(name) {
116
122
  }
117
123
  //#endregion
118
124
  //#region src/bundlers/shared/generated-css-marker.ts
119
- const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/i;
120
- const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/gi;
121
- const BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE = /\/\*!\s*weapp-tailwindcss (vite|webpack)-generated-css(?::([^\s*]+))?\s*\*\/\s*/gi;
125
+ const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!?\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/i;
126
+ const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/gi;
127
+ const BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE = /\/\*!?\s*weapp-tailwindcss (vite|webpack)-generated-css(?:\s*:\s*([^\s*]+))?\s*\*\/\s*/gi;
122
128
  function createBundlerGeneratedCssMarker(bundler, file) {
123
129
  return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
124
130
  }
@@ -147,6 +153,25 @@ function parseBundlerGeneratedCssMarkerBlocks(source) {
147
153
  return blocks;
148
154
  }
149
155
  //#endregion
156
+ //#region src/bundlers/shared/v4-generation-core.ts
157
+ async function generateTailwindV4Css(options) {
158
+ const majorVersion = options.runtimeState.tailwindRuntime.majorVersion;
159
+ if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
160
+ const generated = await generateCssByGenerator(options);
161
+ if (!generated) return;
162
+ return {
163
+ ...generated,
164
+ classSet: generated.classSet,
165
+ dependencies: generated.dependencies,
166
+ metadata: {
167
+ file: options.file,
168
+ majorVersion,
169
+ outputFile: options.outputFile,
170
+ ...generated.metadata ?? {}
171
+ }
172
+ };
173
+ }
174
+ //#endregion
150
175
  //#region src/bundlers/vite/bundle-entries.ts
151
176
  function readOutputEntry(entry) {
152
177
  if (entry.output.type === "chunk") return entry.output.code;
@@ -200,6 +225,8 @@ const CSS_BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
200
225
  const CSS_AROUND_PUNCTUATION_RE = /\s*([{}:;,>+~()])\s*/g;
201
226
  const CSS_TRAILING_DECLARATION_SEMICOLON_RE = /;\}/g;
202
227
  const CSS_WHITESPACE_RE = /\s+/g;
228
+ const JS_RUNTIME_AFFECTING_TEXT_HINT_RE = /["'`/]/;
229
+ const JS_INCOMPLETE_TRAILING_OPERATOR_RE = /(?:=>|[=+\-*%&|^!~?:,.({[\]])\s*$/;
203
230
  function createHtmlRuntimeAffectingSignature(source) {
204
231
  try {
205
232
  const parts = [];
@@ -223,9 +250,10 @@ function createHtmlRuntimeAffectingSignature(source) {
223
250
  }
224
251
  }
225
252
  function createJsRuntimeAffectingSignature(source) {
253
+ if (!JS_RUNTIME_AFFECTING_TEXT_HINT_RE.test(source) && !JS_INCOMPLETE_TRAILING_OPERATOR_RE.test(source)) return "";
226
254
  try {
227
255
  const ast = babelParse(source, {
228
- cache: true,
256
+ cache: false,
229
257
  cacheKey: "vite-runtime-affecting:unambiguous",
230
258
  plugins: ["jsx", "typescript"],
231
259
  sourceType: "unambiguous"
@@ -295,8 +323,8 @@ function readEntrySource(output) {
295
323
  return output.source.toString();
296
324
  }
297
325
  function classifyBundleEntry(file, opts) {
326
+ if (opts.htmlMatcher(file) || isHTMLRequest(file)) return "html";
298
327
  if (opts.cssMatcher(file) || isCSSRequest(file)) return "css";
299
- if (opts.htmlMatcher(file)) return "html";
300
328
  if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
301
329
  return "other";
302
330
  }
@@ -331,12 +359,12 @@ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false, opti
331
359
  sourceHashByFile.set(file, hash);
332
360
  const previousHash = state.sourceHashByFile.get(file);
333
361
  const changed = previousHash == null || previousHash !== hash;
334
- const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
335
362
  const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
336
- const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
337
- const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
338
- const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
339
- runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
363
+ const runtimeAffectingHash = !changed && previousRuntimeAffectingHash != null ? previousRuntimeAffectingHash : (() => {
364
+ const runtimeAffectingSignature = createRuntimeAffectingSourceSignature(source, type);
365
+ runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
366
+ return opts.cache.computeHash(runtimeAffectingSignature);
367
+ })();
340
368
  runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
341
369
  if (changed) changedByType[type].add(file);
342
370
  if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
@@ -389,14 +417,156 @@ function invertLinkedByEntry(linkedByEntry) {
389
417
  }
390
418
  return dependentsByLinkedFile;
391
419
  }
420
+ function replaceMapEntries(target, source) {
421
+ target.clear();
422
+ for (const [key, value] of source) target.set(key, value);
423
+ return target;
424
+ }
425
+ function mergeMapEntries(target, source) {
426
+ for (const [key, value] of source) target.set(key, value);
427
+ return target;
428
+ }
392
429
  function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
393
430
  const incremental = options.incremental === true;
394
431
  state.iteration += 1;
395
- state.sourceHashByFile = incremental ? new Map([...state.sourceHashByFile, ...snapshot.sourceHashByFile]) : snapshot.sourceHashByFile;
396
- state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
397
- state.runtimeAffectingHashByFile = incremental ? new Map([...state.runtimeAffectingHashByFile, ...snapshot.runtimeAffectingHashByFile]) : snapshot.runtimeAffectingHashByFile;
398
- state.linkedByEntry = incremental ? new Map([...state.linkedByEntry, ...linkedByEntry]) : linkedByEntry;
432
+ state.sourceHashByFile = incremental ? mergeMapEntries(state.sourceHashByFile, snapshot.sourceHashByFile) : replaceMapEntries(state.sourceHashByFile, snapshot.sourceHashByFile);
433
+ state.runtimeAffectingSignatureByFile.clear();
434
+ state.runtimeAffectingHashByFile = incremental ? mergeMapEntries(state.runtimeAffectingHashByFile, snapshot.runtimeAffectingHashByFile) : replaceMapEntries(state.runtimeAffectingHashByFile, snapshot.runtimeAffectingHashByFile);
435
+ state.linkedByEntry = incremental ? mergeMapEntries(state.linkedByEntry, linkedByEntry) : replaceMapEntries(state.linkedByEntry, linkedByEntry);
399
436
  state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
400
437
  }
401
438
  //#endregion
402
- export { toAbsoluteOutputPath as S, slash as _, applyLinkedResults as a, normalizeOutputPathKey as b, hasBundlerGeneratedCssMarker as c, resolvePackageDir as d, resolvePluginDisabledState as f, normalizePath as g, isCSSRequest as h, createRuntimeAffectingSourceSignature as i, parseBundlerGeneratedCssMarkerBlocks as l, formatPostcssSourceMap as m, createBundleBuildState as n, createBundleModuleGraphOptions as o, cleanUrl as p, updateBundleBuildState as r, createBundlerGeneratedCssMarker as s, buildBundleSnapshot as t, stripBundlerGeneratedCssMarkers as u, isSourceStyleRequest as v, resolveOutputSpecifier as x, stripRequestQuery as y };
439
+ //#region src/bundlers/vite/generate-bundle/signatures.ts
440
+ function summarizeStringDiff(previous, next) {
441
+ if (previous === next) return "same";
442
+ const previousLength = previous.length;
443
+ const nextLength = next.length;
444
+ const minLength = Math.min(previousLength, nextLength);
445
+ let prefixLength = 0;
446
+ while (prefixLength < minLength && previous.charCodeAt(prefixLength) === next.charCodeAt(prefixLength)) prefixLength += 1;
447
+ let previousSuffixCursor = previousLength - 1;
448
+ let nextSuffixCursor = nextLength - 1;
449
+ while (previousSuffixCursor >= prefixLength && nextSuffixCursor >= prefixLength && previous.charCodeAt(previousSuffixCursor) === next.charCodeAt(nextSuffixCursor)) {
450
+ previousSuffixCursor -= 1;
451
+ nextSuffixCursor -= 1;
452
+ }
453
+ const previousChangedLength = previousSuffixCursor >= prefixLength ? previousSuffixCursor - prefixLength + 1 : 0;
454
+ const nextChangedLength = nextSuffixCursor >= prefixLength ? nextSuffixCursor - prefixLength + 1 : 0;
455
+ return `changed@${prefixLength} old=${previousChangedLength} new=${nextChangedLength} len=${previousLength}->${nextLength}`;
456
+ }
457
+ function createLinkedImpactSignature(entry, linkedImpactsByEntry, sourceHashByFile) {
458
+ const changedLinkedFiles = linkedImpactsByEntry.get(entry);
459
+ if (!changedLinkedFiles || changedLinkedFiles.size === 0) return;
460
+ return [...changedLinkedFiles].sort().map((file) => {
461
+ return `${file}:${sourceHashByFile.get(file) ?? "missing"}`;
462
+ }).join(",");
463
+ }
464
+ function createJsHashSalt(runtimeSignature, linkedImpactSignature) {
465
+ if (!linkedImpactSignature) return runtimeSignature;
466
+ return `${runtimeSignature}:linked:${linkedImpactSignature}`;
467
+ }
468
+ function createStableTextSignature(input) {
469
+ let hash = 2166136261;
470
+ for (let i = 0; i < input.length; i++) {
471
+ hash ^= input.charCodeAt(i);
472
+ hash = Math.imul(hash, 16777619);
473
+ }
474
+ return (hash >>> 0).toString(36);
475
+ }
476
+ function createCandidateSignature(candidates) {
477
+ if (candidates.size === 0) return "empty";
478
+ return createStableTextSignature([...candidates].sort().join("\n"));
479
+ }
480
+ function getSnapshotHash(snapshotMap, file, fallback) {
481
+ return snapshotMap.get(file) ?? fallback;
482
+ }
483
+ function hasRuntimeAffectingSourceChanges(changedByType) {
484
+ return changedByType.html.size > 0 || changedByType.js.size > 0;
485
+ }
486
+ //#endregion
487
+ //#region src/bundlers/vite/generate-bundle/scoped-generator.ts
488
+ function hasOwnSourceDirectives(rawSource) {
489
+ return rawSource.includes("@source") || rawSource.includes("@config");
490
+ }
491
+ function createLocalSourceEntries(sourceFile) {
492
+ return [{
493
+ base: path.dirname(path.resolve(sourceFile.replace(/[?#].*$/, ""))),
494
+ negated: false,
495
+ pattern: "**/*"
496
+ }];
497
+ }
498
+ function intersectCandidates(first, second) {
499
+ const scoped = /* @__PURE__ */ new Set();
500
+ const [small, large] = first.size <= second.size ? [first, second] : [second, first];
501
+ for (const candidate of small) if (large.has(candidate)) scoped.add(candidate);
502
+ return scoped;
503
+ }
504
+ function resolveScopedSourceEntries(rawSource, sourceFile, resolvedEntries) {
505
+ if (!hasOwnSourceDirectives(rawSource)) return {
506
+ entries: resolvedEntries,
507
+ localEntries: void 0
508
+ };
509
+ const localEntries = createLocalSourceEntries(sourceFile);
510
+ if (!resolvedEntries || resolvedEntries.length === 0) return {
511
+ entries: localEntries,
512
+ localEntries: void 0
513
+ };
514
+ return {
515
+ entries: resolvedEntries,
516
+ localEntries
517
+ };
518
+ }
519
+ async function createScopedGeneratorCandidateSignature(rawSource, sourceFile, fallbackSignature, getSourceCandidatesForEntries, options = {}) {
520
+ if (!getSourceCandidatesForEntries || !hasOwnSourceDirectives(rawSource)) return fallbackSignature;
521
+ const { entries, localEntries } = resolveScopedSourceEntries(rawSource, sourceFile, (await resolveTailwindV4EntriesFromCssCached(rawSource, path.dirname(path.resolve(sourceFile.replace(/[?#].*$/, "")))))?.entries);
522
+ if (entries === void 0) return fallbackSignature;
523
+ const scopedCandidates = getSourceCandidatesForEntries(entries);
524
+ const scopedSignature = createCandidateSignature(localEntries ? intersectCandidates(scopedCandidates, getSourceCandidatesForEntries(localEntries)) : scopedCandidates);
525
+ return options.includeFallbackSignature === true ? `${scopedSignature}:${fallbackSignature}` : scopedSignature;
526
+ }
527
+ async function createScopedGeneratorRuntime(options) {
528
+ const { cssHandlerOptions, fallbackRuntime, getSourceCandidatesForEntries, outputFile, rawSource, shouldExcludeSubpackageSourceCandidates, sourceFile, scopedSourceCandidateGetter } = options;
529
+ if (getSourceCandidatesForEntries && rawSource && sourceFile) {
530
+ const { entries, localEntries } = resolveScopedSourceEntries(rawSource, sourceFile, (await resolveTailwindV4EntriesFromCssCached(rawSource, path.dirname(path.resolve(sourceFile.replace(/[?#].*$/, "")))))?.entries);
531
+ if (entries !== void 0 && (entries.length > 0 || hasOwnSourceDirectives(rawSource))) {
532
+ const scopedCandidates = scopedSourceCandidateGetter?.(entries) ?? getSourceCandidatesForEntries(entries);
533
+ if (!localEntries) return scopedCandidates;
534
+ return intersectCandidates(scopedCandidates, scopedSourceCandidateGetter?.(localEntries) ?? getSourceCandidatesForEntries(localEntries));
535
+ }
536
+ }
537
+ const scopedCandidates = scopedSourceCandidateGetter?.(void 0);
538
+ if (scopedCandidates && (scopedCandidates.size > 0 || shouldExcludeSubpackageSourceCandidates(outputFile, cssHandlerOptions))) return scopedCandidates;
539
+ if (!shouldExcludeSubpackageSourceCandidates(outputFile, cssHandlerOptions)) return fallbackRuntime;
540
+ return fallbackRuntime;
541
+ }
542
+ //#endregion
543
+ //#region src/bundlers/vite/source-candidate-scan-signature.ts
544
+ function normalizeSignaturePath(value) {
545
+ return slash(path.resolve(value));
546
+ }
547
+ function serializeInlineCandidates(inlineCandidates) {
548
+ return {
549
+ excluded: [...inlineCandidates?.excluded ?? []].sort(),
550
+ included: [...inlineCandidates?.included ?? []].sort()
551
+ };
552
+ }
553
+ function serializeSourceEntries(entries) {
554
+ return (entries ?? []).map((entry) => ({
555
+ base: normalizeSignaturePath(entry.base),
556
+ negated: entry.negated,
557
+ pattern: entry.pattern
558
+ })).sort((a, b) => `${a.base}\0${a.pattern}\0${a.negated}`.localeCompare(`${b.base}\0${b.pattern}\0${b.negated}`));
559
+ }
560
+ function createSourceCandidateScanSignature(input) {
561
+ return JSON.stringify({
562
+ inlineCandidates: serializeInlineCandidates(input.inlineCandidates),
563
+ outDir: input.outDir ? normalizeSignaturePath(input.outDir) : void 0,
564
+ roots: input.roots.map((root) => ({
565
+ entries: serializeSourceEntries(root.entries),
566
+ root: normalizeSignaturePath(root.root)
567
+ })),
568
+ scanAllSources: input.scanAllSources ?? false
569
+ });
570
+ }
571
+ //#endregion
572
+ export { isSourceStyleRequest as A, resolvePluginDisabledState as C, isHTMLRequest as D, isCSSRequest as E, normalizeOutputPathKey as M, resolveOutputSpecifier as N, normalizePath as O, toAbsoluteOutputPath as P, resolvePackageDir as S, formatPostcssSourceMap as T, generateTailwindV4Css as _, createJsHashSalt as a, parseBundlerGeneratedCssMarkerBlocks as b, hasRuntimeAffectingSourceChanges as c, classifyBundleEntry as d, createBundleBuildState as f, createBundleModuleGraphOptions as g, applyLinkedResults as h, createCandidateSignature as i, stripRequestQuery as j, slash as k, summarizeStringDiff as l, createRuntimeAffectingSourceSignature as m, createScopedGeneratorCandidateSignature as n, createLinkedImpactSignature as o, updateBundleBuildState as p, createScopedGeneratorRuntime as r, getSnapshotHash as s, createSourceCandidateScanSignature as t, buildBundleSnapshot as u, createBundlerGeneratedCssMarker as v, cleanUrl as w, stripBundlerGeneratedCssMarkers as x, hasBundlerGeneratedCssMarker as y };