weapp-tailwindcss 5.1.9 → 5.1.10

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 (55) hide show
  1. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +1 -0
  2. package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +4 -0
  3. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -0
  4. package/dist/bundlers/shared/generator-css/types.d.ts +2 -0
  5. package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +1 -1
  6. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +2 -0
  7. package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +1 -0
  8. package/dist/bundlers/vite/hot-css-modules.d.ts +1 -1
  9. package/dist/bundlers/vite/source-candidates.d.ts +7 -2
  10. package/dist/bundlers/vite/web-css-compat.d.ts +3 -0
  11. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +9 -0
  12. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +3 -0
  13. package/dist/cli.js +3 -2
  14. package/dist/cli.mjs +2 -1
  15. package/dist/{context-CfXr3hWz.mjs → context-DzkSFEVL.mjs} +4 -4
  16. package/dist/{context-CRhUs_5e.js → context-y2BGCok4.js} +10 -10
  17. package/dist/core.js +1 -1
  18. package/dist/core.mjs +1 -1
  19. package/dist/generator/options.d.ts +8 -1
  20. package/dist/{v4-engine-BZP2462H.js → generator-Bz94KTkH.js} +229 -17
  21. package/dist/{v4-engine-CjjWONB0.mjs → generator-ROzBodj6.mjs} +185 -9
  22. package/dist/generator.js +7 -8
  23. package/dist/generator.mjs +1 -2
  24. package/dist/{gulp-CRjkPsbX.mjs → gulp-BKqMb_Ds.mjs} +4 -4
  25. package/dist/{gulp-JUfnhOOo.js → gulp-DfOLvYLs.js} +10 -10
  26. package/dist/gulp.js +1 -1
  27. package/dist/gulp.mjs +1 -1
  28. package/dist/{hmr-timing-DcIEXnf8.js → hmr-timing-DOTdH18A.js} +556 -170
  29. package/dist/{hmr-timing-BecOXMd8.mjs → hmr-timing-DwtYJdwb.mjs} +430 -56
  30. package/dist/index.js +4 -4
  31. package/dist/index.mjs +4 -4
  32. package/dist/postcss.js +2 -3
  33. package/dist/postcss.mjs +1 -2
  34. package/dist/presets.js +7 -6
  35. package/dist/presets.mjs +5 -4
  36. package/dist/rspack.js +1 -1
  37. package/dist/rspack.mjs +1 -1
  38. package/dist/{source-candidate-scan-signature-10tvdJVC.js → source-candidate-scan-signature-BrWuBTjY.js} +34 -6
  39. package/dist/{source-candidate-scan-signature-DAg8QSgh.mjs → source-candidate-scan-signature-CQ04hiox.mjs} +29 -7
  40. package/dist/{tailwindcss-BZjZZi60.js → tailwindcss-Dn5DVlkI.js} +55 -47
  41. package/dist/{tailwindcss-PA2jHHpx.mjs → tailwindcss-hzy_WaC9.mjs} +14 -6
  42. package/dist/{transform-wNEbcZeQ.mjs → transform-BgnNYkIG.mjs} +1 -1
  43. package/dist/{transform-B0BxX3XB.js → transform-DZQETx51.js} +1 -1
  44. package/dist/{vite-ClpyoD9e.mjs → vite-BimHmlSp.mjs} +824 -207
  45. package/dist/{vite-CHk7V9EA.js → vite-bztpcI8_.js} +871 -254
  46. package/dist/vite.js +1 -1
  47. package/dist/vite.mjs +1 -1
  48. package/dist/weapp-tw-css-import-rewrite-loader.js +613 -63
  49. package/dist/{webpack-2s-TFhgm.mjs → webpack-CCapGlNg.mjs} +235 -38
  50. package/dist/{webpack-BhM4Hqla.js → webpack-XxBCIrBp.js} +276 -79
  51. package/dist/webpack.js +1 -1
  52. package/dist/webpack.mjs +1 -1
  53. package/package.json +6 -6
  54. package/dist/generator-DaaFxR5V.js +0 -174
  55. package/dist/generator-DugIHBgl.mjs +0 -127
@@ -1,8 +1,7 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
2
- const require_v4_engine = require("./v4-engine-BZP2462H.js");
3
- const require_generator = require("./generator-DaaFxR5V.js");
4
- const require_context = require("./context-CRhUs_5e.js");
5
- const require_tailwindcss = require("./tailwindcss-BZjZZi60.js");
2
+ const require_generator = require("./generator-Bz94KTkH.js");
3
+ const require_context = require("./context-y2BGCok4.js");
4
+ const require_tailwindcss = require("./tailwindcss-Dn5DVlkI.js");
6
5
  let node_fs = require("node:fs");
7
6
  let node_path = require("node:path");
8
7
  node_path = require_rolldown_runtime.__toESM(node_path);
@@ -261,7 +260,7 @@ function shouldIsolateScopedCssSource(_majorVersion, source, sourceEntries, opti
261
260
  return sourceEntries !== void 0 && options.cssHandlerOptions?.isMainChunk !== true;
262
261
  }
263
262
  function shouldIsolateCurrentTailwindV4CssCandidates(_majorVersion, cssHandlerOptions, options) {
264
- return !cssHandlerOptions.isMainChunk && require_v4_engine.hasTailwindApplyDirective(options.rawSource) && !require_v4_engine.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
263
+ return !cssHandlerOptions.isMainChunk && require_generator.hasTailwindApplyDirective(options.rawSource) && !require_generator.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
265
264
  }
266
265
  function shouldScanTailwindV4Sources(majorVersion, target, generatorRuntime, isolateCssSource) {
267
266
  if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
@@ -297,20 +296,133 @@ function createCssSourceOrderAppend$1(base, extra) {
297
296
  if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
298
297
  return `${base}\n${extra}`;
299
298
  }
299
+ const LEGACY_PSEUDO_ELEMENTS$1 = [
300
+ "before",
301
+ "after",
302
+ "first-letter",
303
+ "first-line"
304
+ ];
305
+ const CSS_STRING_LITERAL_RE = /(["'])((?:\\[\s\S]|(?!\1)[\s\S])*)\1/g;
306
+ function isLegacyPseudoElementAt$1(selector, index) {
307
+ for (const name of LEGACY_PSEUDO_ELEMENTS$1) {
308
+ if (!selector.startsWith(name, index)) continue;
309
+ const next = selector[index + name.length];
310
+ if (next === void 0 || !/[\w-]/.test(next)) return name;
311
+ }
312
+ }
313
+ function normalizeLegacyPseudoElements$1(selector) {
314
+ let result = "";
315
+ let quote;
316
+ let bracketDepth = 0;
317
+ let index = 0;
318
+ while (index < selector.length) {
319
+ const char = selector[index];
320
+ if (char === "\\") {
321
+ result += selector.slice(index, index + 2);
322
+ index += 2;
323
+ continue;
324
+ }
325
+ if (quote !== void 0) {
326
+ result += char;
327
+ if (char === quote) quote = void 0;
328
+ index += 1;
329
+ continue;
330
+ }
331
+ if (char === "\"" || char === "'") {
332
+ quote = char;
333
+ result += char;
334
+ index += 1;
335
+ continue;
336
+ }
337
+ if (char === "[") {
338
+ bracketDepth++;
339
+ result += char;
340
+ index += 1;
341
+ continue;
342
+ }
343
+ if (char === "]") {
344
+ bracketDepth = Math.max(0, bracketDepth - 1);
345
+ result += char;
346
+ index += 1;
347
+ continue;
348
+ }
349
+ if (bracketDepth === 0 && char === ":" && selector[index + 1] === ":") {
350
+ result += "::";
351
+ index += 2;
352
+ continue;
353
+ }
354
+ if (bracketDepth === 0 && char === ":") {
355
+ const name = isLegacyPseudoElementAt$1(selector, index + 1);
356
+ if (name) {
357
+ result += `::${name}`;
358
+ index += name.length + 1;
359
+ continue;
360
+ }
361
+ }
362
+ result += char;
363
+ index += 1;
364
+ }
365
+ return result;
366
+ }
367
+ function normalizeCssRuleDeduplicationSelector(selector) {
368
+ return normalizeLegacyPseudoElements$1(selector).replace(/\s+/g, " ").replace(/\s*([>+~])\s*/g, "$1").replace(/\(\s+/g, "(").replace(/\s+\)/g, ")").trim();
369
+ }
370
+ function normalizeCssRuleDeduplicationValue(value) {
371
+ return value.replace(/\s+/g, " ").replace(CSS_STRING_LITERAL_RE, (_match, _quote, content) => {
372
+ return `'${content.replace(/\\(["'])/g, "$1").replace(/'/g, "\\'")}'`;
373
+ }).trim();
374
+ }
375
+ function createRuleDeduplicationKey(rule) {
376
+ const parents = [];
377
+ let parent = rule.parent;
378
+ while (parent && parent.type !== "root") {
379
+ if (parent.type === "atrule") parents.push(`${parent.name}:${parent.params}`);
380
+ parent = parent.parent;
381
+ }
382
+ const declarations = (rule.nodes ?? []).map((node) => {
383
+ if (node.type === "decl") return `${node.prop}:${normalizeCssRuleDeduplicationValue(node.value)}:${node.important ? "1" : "0"}`;
384
+ if (node.type === "comment") return "";
385
+ return normalizeCssRuleDeduplicationValue(node.toString());
386
+ }).filter(Boolean);
387
+ const selectors = (rule.selectors?.length ? rule.selectors : [rule.selector]).map(normalizeCssRuleDeduplicationSelector);
388
+ return [
389
+ parents.reverse().join("|"),
390
+ selectors.join(","),
391
+ declarations.join(";")
392
+ ].join("\n");
393
+ }
394
+ function deduplicateGeneratedCssRules(css) {
395
+ if (!css) return css;
396
+ try {
397
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
398
+ const seen = /* @__PURE__ */ new Set();
399
+ root.walkRules((rule) => {
400
+ const key = createRuleDeduplicationKey(rule);
401
+ if (seen.has(key)) {
402
+ rule.remove();
403
+ return;
404
+ }
405
+ seen.add(key);
406
+ });
407
+ return root.toString();
408
+ } catch {
409
+ return css;
410
+ }
411
+ }
300
412
  function shouldFinalizeMarkedUserLayerComponentsCss(file) {
301
413
  return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
302
414
  }
303
415
  function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
304
- const placeholderParts = require_v4_engine.splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
416
+ const placeholderParts = require_generator.splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
305
417
  if (placeholderParts) return placeholderParts;
306
- const exactParts = require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
418
+ const exactParts = require_generator.splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
307
419
  if (exactParts) return exactParts;
308
- return require_v4_engine.splitTailwindGeneratedCssByBanner(rawSource);
420
+ return require_generator.splitTailwindGeneratedCssByBanner(rawSource);
309
421
  }
310
422
  function shouldUseGeneratorForCurrentCss(_majorVersion, cssHandlerOptions, options) {
311
- const hasApplyDirectives = require_v4_engine.hasTailwindApplyDirective(options.rawSource);
423
+ const hasApplyDirectives = require_generator.hasTailwindApplyDirective(options.rawSource);
312
424
  const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
313
- const hasSourceCssDirectives = typeof sourceCss === "string" && (require_v4_engine.hasTailwindRootDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(sourceCss));
425
+ const hasSourceCssDirectives = typeof sourceCss === "string" && (require_generator.hasTailwindRootDirectives(sourceCss, { importFallback: true }) || require_generator.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || require_generator.hasTailwindApplyDirective(sourceCss));
314
426
  return options.forceGenerator === true || options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || hasApplyDirectives || hasSourceCssDirectives || cssHandlerOptions.isMainChunk && (options.configuredCssSourceCount ?? 0) > 0 || cssHandlerOptions.isMainChunk && options.rawSource.includes("weapp-tailwindcss") || options.target === "web" && cssHandlerOptions.isMainChunk && (options.runtimeCandidateCount ?? 0) > 0;
315
427
  }
316
428
  function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
@@ -324,8 +436,8 @@ function mergeGeneratorResults(generatedResults) {
324
436
  const incrementalRawCssResults = generatedResults.map((item) => item.incrementalRawCss).filter((css) => typeof css === "string");
325
437
  return {
326
438
  ...firstGenerated,
327
- css: generatedResults.map((item) => item.css).join("\n"),
328
- rawCss: generatedResults.map((item) => item.rawCss).join("\n"),
439
+ css: deduplicateGeneratedCssRules(generatedResults.map((item) => item.css).join("\n")),
440
+ rawCss: deduplicateGeneratedCssRules(generatedResults.map((item) => item.rawCss).join("\n")),
329
441
  incrementalCss: incrementalCssResults.length === generatedResults.length ? incrementalCssResults.filter(Boolean).join("\n") : void 0,
330
442
  incrementalRawCss: incrementalRawCssResults.length === generatedResults.length ? incrementalRawCssResults.filter(Boolean).join("\n") : void 0,
331
443
  classSet: new Set(generatedResults.flatMap((item) => [...item.classSet])),
@@ -344,6 +456,12 @@ const MINI_PROGRAM_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
344
456
  ]);
345
457
  const SPECIFICITY_PLACEHOLDER_RE = /:not\(#(?:\\#|n)\)/g;
346
458
  const SELECTOR_CACHE_LIMIT = 64;
459
+ const LEGACY_PSEUDO_ELEMENTS = [
460
+ "before",
461
+ "after",
462
+ "first-letter",
463
+ "first-line"
464
+ ];
347
465
  const generatedSelectorCache = /* @__PURE__ */ new Map();
348
466
  function setGeneratedSelectorCache(css, selectors) {
349
467
  if (generatedSelectorCache.size >= SELECTOR_CACHE_LIMIT) {
@@ -355,6 +473,67 @@ function setGeneratedSelectorCache(css, selectors) {
355
473
  function normalizeCompatSelector(selector) {
356
474
  return selector.replace(SPECIFICITY_PLACEHOLDER_RE, "").replace(/\s+/g, " ").trim();
357
475
  }
476
+ function isLegacyPseudoElementAt(selector, index) {
477
+ for (const name of LEGACY_PSEUDO_ELEMENTS) {
478
+ if (!selector.startsWith(name, index)) continue;
479
+ const next = selector[index + name.length];
480
+ if (next === void 0 || !/[\w-]/.test(next)) return name;
481
+ }
482
+ }
483
+ function normalizeLegacyPseudoElements(selector) {
484
+ let result = "";
485
+ let quote;
486
+ let bracketDepth = 0;
487
+ let index = 0;
488
+ while (index < selector.length) {
489
+ const char = selector[index];
490
+ if (char === "\\") {
491
+ result += selector.slice(index, index + 2);
492
+ index += 2;
493
+ continue;
494
+ }
495
+ if (quote !== void 0) {
496
+ result += char;
497
+ if (char === quote) quote = void 0;
498
+ index += 1;
499
+ continue;
500
+ }
501
+ if (char === "\"" || char === "'") {
502
+ quote = char;
503
+ result += char;
504
+ index += 1;
505
+ continue;
506
+ }
507
+ if (char === "[") {
508
+ bracketDepth++;
509
+ result += char;
510
+ index += 1;
511
+ continue;
512
+ }
513
+ if (char === "]") {
514
+ bracketDepth = Math.max(0, bracketDepth - 1);
515
+ result += char;
516
+ index += 1;
517
+ continue;
518
+ }
519
+ if (bracketDepth === 0 && char === ":" && selector[index + 1] === ":") {
520
+ result += "::";
521
+ index += 2;
522
+ continue;
523
+ }
524
+ if (bracketDepth === 0 && char === ":") {
525
+ const name = isLegacyPseudoElementAt(selector, index + 1);
526
+ if (name) {
527
+ result += `::${name}`;
528
+ index += name.length + 1;
529
+ continue;
530
+ }
531
+ }
532
+ result += char;
533
+ index += 1;
534
+ }
535
+ return result;
536
+ }
358
537
  function isClassSelectorTerminator(char) {
359
538
  return /[\s>+~#,.:()[\]]/.test(char);
360
539
  }
@@ -405,7 +584,7 @@ function normalizeCompatSelectors(selector) {
405
584
  return [...selectors];
406
585
  }
407
586
  function normalizeCssSelector(selector) {
408
- return selector.trim().replace(/\s+/g, "");
587
+ return normalizeLegacyPseudoElements(selector).trim().replace(/\s+/g, "");
409
588
  }
410
589
  function getCompatSelectorKeys(selector) {
411
590
  return normalizeCompatSelectors(selector).map(normalizeCssSelector);
@@ -567,9 +746,9 @@ function collectDedupedPostTransformCompatCss(css, generatedCss) {
567
746
  }
568
747
  }
569
748
  function removeDuplicatedViteMarkers(css, baseCss) {
570
- if (!require_v4_engine.VITE_MARKER_RE.test(baseCss)) return css;
571
- require_v4_engine.VITE_MARKER_RE.lastIndex = 0;
572
- return css.replace(require_v4_engine.VITE_MARKER_RE, "");
749
+ if (!require_generator.VITE_MARKER_RE.test(baseCss)) return css;
750
+ require_generator.VITE_MARKER_RE.lastIndex = 0;
751
+ return css.replace(require_generator.VITE_MARKER_RE, "");
573
752
  }
574
753
  //#endregion
575
754
  //#region src/bundlers/shared/generator-css/source-files.ts
@@ -685,11 +864,11 @@ function extractStyleDirectiveSources(source) {
685
864
  let match = SFC_STYLE_BLOCK_RE.exec(source);
686
865
  while (match !== null) {
687
866
  const styleSource = match[1] ?? "";
688
- if (require_v4_engine.hasTailwindSourceDirectives(styleSource, { importFallback: true })) styleSources.push(styleSource);
867
+ if (require_generator.hasTailwindSourceDirectives(styleSource, { importFallback: true })) styleSources.push(styleSource);
689
868
  match = SFC_STYLE_BLOCK_RE.exec(source);
690
869
  }
691
870
  if (styleSources.length > 0) return styleSources;
692
- return require_v4_engine.hasTailwindSourceDirectives(source, { importFallback: true }) ? [source] : [];
871
+ return require_generator.hasTailwindSourceDirectives(source, { importFallback: true }) ? [source] : [];
693
872
  }
694
873
  function extractSfcStyleSources(source) {
695
874
  const styleSources = [];
@@ -719,7 +898,7 @@ function collectLocalStyleImportFiles(source, base) {
719
898
  if (sources.length === 0) sources.push(source);
720
899
  for (const styleSource of sources) try {
721
900
  _weapp_tailwindcss_postcss.postcss.parse(styleSource).walkAtRules("import", (rule) => {
722
- const request = require_v4_engine.parseImportRequest(rule.params);
901
+ const request = require_generator.parseImportRequest(rule.params);
723
902
  if (!isLocalStyleImportRequest(request)) return;
724
903
  const file = request ? resolveLocalStyleImportFile(request, base) : void 0;
725
904
  if (file) files.push(file);
@@ -752,7 +931,7 @@ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {
752
931
  if (source === void 0) continue;
753
932
  const directiveSources = extractStyleDirectiveSourcesDeep(source, sourceFile, /* @__PURE__ */ new Set([node_path.default.resolve(sourceFile)]));
754
933
  for (const styleSource of directiveSources) {
755
- const cssEntrySource = require_v4_engine.resolveCssEntrySource(styleSource.source, node_path.default.dirname(styleSource.file), resolveOptions);
934
+ const cssEntrySource = require_generator.resolveCssEntrySource(styleSource.source, node_path.default.dirname(styleSource.file), resolveOptions);
756
935
  if (cssEntrySource) return {
757
936
  ...cssEntrySource,
758
937
  file: styleSource.file
@@ -769,8 +948,8 @@ function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
769
948
  }
770
949
  function createTailwindV4SourceReferenceSource(css, sourceOptions) {
771
950
  if (hasTailwindV4RootImport(css, sourceOptions)) return css;
772
- const hasApplyDirective = require_v4_engine.hasTailwindApplyDirective(css);
773
- if (!hasApplyDirective && !require_v4_engine.hasTailwindSourceDirectives(css, { importFallback: true })) return css;
951
+ const hasApplyDirective = require_generator.hasTailwindApplyDirective(css);
952
+ if (!hasApplyDirective && !require_generator.hasTailwindSourceDirectives(css, { importFallback: true })) return css;
774
953
  const utilities = hasApplyDirective ? collectTailwindApplyUtilities(css) : [];
775
954
  return [
776
955
  `@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
@@ -788,7 +967,7 @@ function hasTailwindV4RootImport(css, sourceOptions) {
788
967
  return false;
789
968
  }
790
969
  if (rule.name !== "import" && rule.name !== "use" && rule.name !== "forward") return;
791
- const request = require_v4_engine.parseImportRequest(rule.params);
970
+ const request = require_generator.parseImportRequest(rule.params);
792
971
  if (request === (sourceOptions.packageName ?? "tailwindcss") || request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/")) {
793
972
  found = true;
794
973
  return false;
@@ -843,7 +1022,7 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
843
1022
  //#endregion
844
1023
  //#region src/bundlers/shared/generator-css/source-resolver/matching.ts
845
1024
  function normalizeCssSourceForCompare(css) {
846
- return require_v4_engine.stripGeneratorPlaceholderMarkers(require_v4_engine.stripTailwindBanners(css)).trim();
1025
+ return require_generator.stripGeneratorPlaceholderMarkers(require_generator.stripTailwindBanners(css)).trim();
847
1026
  }
848
1027
  function getOutputFileWithoutExtension(file) {
849
1028
  const normalized = file.replace(/[?#].*$/, "");
@@ -859,10 +1038,26 @@ function stripBundlerContentHash(name) {
859
1038
  function getMatchBasename(file) {
860
1039
  return stripBundlerContentHash(node_path.default.basename(getOutputFileWithoutExtension(file.replace(/[?#].*$/, ""))));
861
1040
  }
1041
+ function getMatchDirname(file) {
1042
+ const normalized = normalizeMatchPath(file);
1043
+ const dirname = node_path.default.posix.dirname(normalized);
1044
+ return dirname === "." ? "" : dirname;
1045
+ }
862
1046
  function isPathWithinRoot(file, root) {
863
1047
  const relative = node_path.default.relative(root, file);
864
1048
  return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
865
1049
  }
1050
+ function collectParentDirectories(file) {
1051
+ const directories = [];
1052
+ let current = node_path.default.dirname(node_path.default.resolve(file.replace(/[?#].*$/, "")));
1053
+ while (true) {
1054
+ directories.push(current);
1055
+ const parent = node_path.default.dirname(current);
1056
+ if (parent === current) break;
1057
+ current = parent;
1058
+ }
1059
+ return directories;
1060
+ }
866
1061
  function collectCssSourceMatchBases(file, roots) {
867
1062
  const normalizedFile = file.replace(/[?#].*$/, "");
868
1063
  const bases = /* @__PURE__ */ new Set();
@@ -884,13 +1079,18 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
884
1079
  sourceOptions.cwd
885
1080
  ]);
886
1081
  const sourceBases = collectCssSourceMatchBases(cssSourceFile, [sourceOptions.projectRoot, sourceOptions.cwd]);
1082
+ const sourceDirectoryIndexBases = collectCssSourceMatchBases(cssSourceFile, collectParentDirectories(cssSourceFile));
887
1083
  const outputBasename = getMatchBasename(file);
888
1084
  const sourceBasename = getMatchBasename(cssSourceFile);
889
1085
  let bestScore = 0;
890
- for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
891
- else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
892
- else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
893
- if (outputBasename && outputBasename === sourceBasename) bestScore = Math.max(bestScore, 100 + outputBasename.length);
1086
+ for (const outputBase of outputBases) {
1087
+ for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
1088
+ else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
1089
+ else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
1090
+ else if (getMatchBasename(sourceBase) === "index" && getMatchDirname(sourceBase).length > 0 && outputBase.startsWith(`${getMatchDirname(sourceBase)}/`)) bestScore = Math.max(bestScore, 25e3 + getMatchDirname(sourceBase).length);
1091
+ for (const sourceBase of sourceDirectoryIndexBases) if (getMatchBasename(sourceBase) === "index" && getMatchDirname(sourceBase).length > 0 && outputBase.startsWith(`${getMatchDirname(sourceBase)}/`)) bestScore = Math.max(bestScore, 25e3 + getMatchDirname(sourceBase).length);
1092
+ }
1093
+ if (outputBasename && outputBasename === sourceBasename && outputBasename !== "index") bestScore = Math.max(bestScore, 100 + outputBasename.length);
894
1094
  return bestScore;
895
1095
  }
896
1096
  //#endregion
@@ -935,7 +1135,7 @@ function mergeCssSources(cssSources, cssEntrySources) {
935
1135
  return merged.length > 0 ? merged : void 0;
936
1136
  }
937
1137
  function createSingleTailwindV4SourceOptions(sourceOptions, options) {
938
- return require_v4_engine.omitUndefined({
1138
+ return require_generator.omitUndefined({
939
1139
  projectRoot: sourceOptions.projectRoot,
940
1140
  baseFallbacks: sourceOptions.baseFallbacks,
941
1141
  packageName: sourceOptions.packageName,
@@ -946,27 +1146,29 @@ function createSingleTailwindV4SourceOptions(sourceOptions, options) {
946
1146
  }
947
1147
  async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions, options = {}) {
948
1148
  const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
949
- if (!(0, node_fs.existsSync)(cssEntry)) return withGeneratorSourceMetadata(await require_v4_engine.resolveTailwindV4Source({
950
- ...require_v4_engine.omitUndefined(singleEntrySourceOptions),
1149
+ if (!(0, node_fs.existsSync)(cssEntry)) return withGeneratorSourceMetadata(await require_generator.resolveTailwindV4Source({
1150
+ ...require_generator.omitUndefined(singleEntrySourceOptions),
951
1151
  cssEntries: [cssEntry]
952
1152
  }), {
1153
+ candidateMatchedCssSource: options.candidateMatched,
953
1154
  cssEntryIndex: options.index,
954
1155
  includesPreflight: options.includesPreflight,
955
1156
  primaryCssSource: options.index === 0
956
1157
  });
957
1158
  const css = (0, node_fs.readFileSync)(cssEntry, "utf8");
958
1159
  const base = node_path.default.dirname(node_path.default.resolve(cssEntry));
959
- const entrySource = require_v4_engine.resolveCssEntrySource(css, base, { removeConfig: false });
1160
+ const entrySource = require_generator.resolveCssEntrySource(css, base, { removeConfig: false });
960
1161
  const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, cssEntry, {
961
1162
  ...sourceOptions,
962
1163
  sourceFile: sourceOptions.sourceFile ?? cssEntry
963
1164
  });
964
- return withGeneratorSourceMetadata(await require_v4_engine.resolveTailwindV4Source({
965
- ...require_v4_engine.omitUndefined(singleEntrySourceOptions),
1165
+ return withGeneratorSourceMetadata(await require_generator.resolveTailwindV4Source({
1166
+ ...require_generator.omitUndefined(singleEntrySourceOptions),
966
1167
  base,
967
- css: require_v4_engine.normalizeConfigDirective(css, config),
1168
+ css: require_generator.normalizeConfigDirective(css, config),
968
1169
  cssEntries: [cssEntry]
969
1170
  }), {
1171
+ candidateMatchedCssSource: options.candidateMatched,
970
1172
  cssEntryIndex: options.index,
971
1173
  includesPreflight: options.includesPreflight,
972
1174
  matchedCssSourceFile: cssEntry,
@@ -981,7 +1183,7 @@ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
981
1183
  return true;
982
1184
  }
983
1185
  function shouldResolveSourceSideCssEntry(rawSource) {
984
- return rawSource.includes("@apply") || require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_v4_engine.hasTailwindGeneratedCss(rawSource) || require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource);
1186
+ return rawSource.includes("@apply") || require_generator.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_generator.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_generator.hasTailwindGeneratedCss(rawSource) || require_generator.hasTailwindGeneratedCssMarkers(rawSource);
985
1187
  }
986
1188
  async function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
987
1189
  const cssEntries = sourceOptions.cssEntries;
@@ -1017,20 +1219,20 @@ async function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions)
1017
1219
  }
1018
1220
  function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
1019
1221
  if (typeof cssSource.css !== "string" || cssSource.css.length === 0 || !cssSource.css.includes("@config")) return cssSource;
1020
- const entrySource = require_v4_engine.resolveCssEntrySource(cssSource.css, sourceBase, { removeConfig: false });
1222
+ const entrySource = require_generator.resolveCssEntrySource(cssSource.css, sourceBase, { removeConfig: false });
1021
1223
  if (!entrySource?.config) return cssSource;
1022
1224
  return {
1023
1225
  ...cssSource,
1024
- css: require_v4_engine.normalizeConfigDirective(cssSource.css, entrySource.config)
1226
+ css: require_generator.normalizeConfigDirective(cssSource.css, entrySource.config)
1025
1227
  };
1026
1228
  }
1027
1229
  function normalizeResolvedTailwindV4SourceConfig(source, file, sourceOptions) {
1028
1230
  if (!("css" in source) || typeof source.css !== "string" || !source.css.includes("@config")) return source;
1029
1231
  const sourceFile = typeof file === "string" && file.length > 0 ? file : source.__weappTailwindcssMeta?.matchedCssSourceFile;
1030
1232
  if (!sourceFile) return source;
1031
- const entrySource = require_v4_engine.resolveCssEntrySource(source.css, node_path.default.dirname(node_path.default.resolve(sourceFile)), { removeConfig: false });
1233
+ const entrySource = require_generator.resolveCssEntrySource(source.css, node_path.default.dirname(node_path.default.resolve(sourceFile)), { removeConfig: false });
1032
1234
  const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, sourceFile, sourceOptions ?? {});
1033
- const normalizedCss = require_v4_engine.normalizeConfigDirective(source.css, config);
1235
+ const normalizedCss = require_generator.normalizeConfigDirective(source.css, config);
1034
1236
  return normalizedCss === source.css ? source : {
1035
1237
  ...source,
1036
1238
  css: normalizedCss
@@ -1054,7 +1256,7 @@ function normalizeTailwindV4CssSourceConfigs(sourceOptions) {
1054
1256
  let changed = false;
1055
1257
  const cssSources = sourceOptions.cssSources.map((cssSource) => {
1056
1258
  const hydratedCssSource = hydrateTailwindV4CssSource(cssSource);
1057
- const normalizedCssSource = normalizeTailwindV4CssSourceConfig(hydratedCssSource, require_v4_engine.resolveTailwindV4CssSourceBase(hydratedCssSource, sourceBaseFallback));
1259
+ const normalizedCssSource = normalizeTailwindV4CssSourceConfig(hydratedCssSource, require_generator.resolveTailwindV4CssSourceBase(hydratedCssSource, sourceBaseFallback));
1058
1260
  changed || (changed = normalizedCssSource !== cssSource);
1059
1261
  return normalizedCssSource;
1060
1262
  });
@@ -1093,7 +1295,7 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
1093
1295
  }
1094
1296
  function tryResolveTailwindV4SourceOptions(runtimeState) {
1095
1297
  try {
1096
- return require_v4_engine.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
1298
+ return require_generator.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
1097
1299
  } catch {
1098
1300
  return;
1099
1301
  }
@@ -1107,9 +1309,9 @@ function isSameTailwindV4CssSource(a, b) {
1107
1309
  return typeof a.css === "string" && typeof b.css === "string" && normalizeCssSourceForCompare(a.css) === normalizeCssSourceForCompare(b.css);
1108
1310
  }
1109
1311
  async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
1110
- const sourceBase = require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
1312
+ const sourceBase = require_generator.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
1111
1313
  const normalizedCssSource = normalizeTailwindV4CssSourceConfig(cssSource, sourceBase);
1112
- const source = await require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(sourceOptions, {
1314
+ const source = await require_generator.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(sourceOptions, {
1113
1315
  base: sourceBase,
1114
1316
  css: normalizedCssSource.css
1115
1317
  }));
@@ -1125,7 +1327,7 @@ async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, option
1125
1327
  }
1126
1328
  async function resolveTailwindV4CssSourceEntries(cssSource, sourceOptions) {
1127
1329
  if (typeof cssSource.css !== "string" || cssSource.css.length === 0) return;
1128
- const sourceBase = require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
1330
+ const sourceBase = require_generator.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
1129
1331
  return require_tailwindcss.resolveTailwindV4EntriesFromCss(cssSource.css, sourceBase);
1130
1332
  }
1131
1333
  function countRuntimeCandidateHits(candidates, runtime) {
@@ -1200,6 +1402,7 @@ async function resolveCandidateMatchedTailwindV4CssEntry(sourceOptions, selectio
1200
1402
  if (!best) return;
1201
1403
  if (second && second.runtimeHits === best.runtimeHits && second.totalCandidates === best.totalCandidates) return;
1202
1404
  return resolveTailwindV4CssEntrySource(best.cssEntry, sourceOptions, {
1405
+ candidateMatched: true,
1203
1406
  includesPreflight: best.includesPreflight,
1204
1407
  index: best.index
1205
1408
  });
@@ -1207,43 +1410,44 @@ async function resolveCandidateMatchedTailwindV4CssEntry(sourceOptions, selectio
1207
1410
  function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
1208
1411
  return (cssSource, index) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions, { index }).then((source) => generatorOptions?.config ? {
1209
1412
  ...source,
1210
- css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
1413
+ css: require_generator.prependConfigDirective(source.css, generatorOptions.config)
1211
1414
  } : source);
1212
1415
  }
1213
1416
  async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourceOptions, generatorOptions, file) {
1214
1417
  if (!resolvedEntrySource) return;
1215
- const resolvedSourceOptions = require_v4_engine.omitUndefined(sourceOptions);
1418
+ const resolvedSourceOptions = require_generator.omitUndefined(sourceOptions);
1216
1419
  const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, {
1217
1420
  ...resolvedSourceOptions,
1218
1421
  sourceFile: resolvedEntrySource.file
1219
1422
  });
1220
- const css = createTailwindV4SourceReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
1221
- const source = await require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
1423
+ const css = createTailwindV4SourceReferenceSource(require_generator.normalizeConfigDirective(require_generator.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
1424
+ const source = await require_generator.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
1222
1425
  base: resolvedEntrySource.base,
1223
1426
  css,
1224
1427
  cssEntries: [resolvedEntrySource.file]
1225
1428
  }));
1226
- const cssEntryIndex = sourceOptions.cssEntries?.findIndex((cssEntry) => typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
1227
- const cssSourceIndex = sourceOptions.cssSources?.findIndex((cssSource) => typeof cssSource.file === "string" && typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssSource.file.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
1429
+ const matchedCssEntryIndex = sourceOptions.cssEntries?.findIndex((cssEntry) => typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
1430
+ const matchedCssSourceIndex = sourceOptions.cssSources?.findIndex((cssSource) => typeof cssSource.file === "string" && typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssSource.file.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
1431
+ const resolvedEntries = await require_tailwindcss.resolveTailwindV4EntriesFromCss(resolvedEntrySource.css, resolvedEntrySource.base);
1228
1432
  return withMatchedSourceSideMetadata(source, resolvedEntrySource, {
1229
- cssEntryIndex,
1230
- cssSourceIndex,
1231
- includesPreflight: (await require_tailwindcss.resolveTailwindV4EntriesFromCss(resolvedEntrySource.css, resolvedEntrySource.base))?.includesPreflight,
1232
- primaryCssSource: cssEntryIndex === 0 || !sourceOptions.cssEntries?.length && cssSourceIndex === 0
1433
+ cssEntryIndex: matchedCssEntryIndex !== void 0 && matchedCssEntryIndex >= 0 ? matchedCssEntryIndex : void 0,
1434
+ cssSourceIndex: matchedCssSourceIndex !== void 0 && matchedCssSourceIndex >= 0 ? matchedCssSourceIndex : void 0,
1435
+ includesPreflight: resolvedEntries?.includesPreflight,
1436
+ primaryCssSource: matchedCssEntryIndex === 0 || !sourceOptions.cssEntries?.length && matchedCssSourceIndex === 0
1233
1437
  });
1234
1438
  }
1235
1439
  async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
1236
1440
  const base = resolveCssSourceBase(file, cssHandlerOptions);
1237
- const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, base, {
1441
+ const cssEntrySource = require_generator.resolveCssEntrySource(rawSource, base, {
1238
1442
  importFallback: generatorOptions?.importFallback ?? false,
1239
1443
  removeConfig: false
1240
1444
  });
1241
- const applyEntrySource = require_v4_engine.hasTailwindApplyDirective(rawSource) ? {
1445
+ const applyEntrySource = require_generator.hasTailwindApplyDirective(rawSource) ? {
1242
1446
  base,
1243
1447
  css: rawSource
1244
1448
  } : void 0;
1245
1449
  const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
1246
- const resolvedSourceOptions = sourceOptions ? require_v4_engine.omitUndefined({
1450
+ const resolvedSourceOptions = sourceOptions ? require_generator.omitUndefined({
1247
1451
  ...sourceOptions,
1248
1452
  sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
1249
1453
  ...resolveCssHandlerSourceOptions(cssHandlerOptions),
@@ -1251,9 +1455,9 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
1251
1455
  cssSources: mergeCssSources(mergeCssSources(sourceOptions.cssSources, selectionOptions?.cssSources), sourceOptions.cssSources?.length || selectionOptions?.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
1252
1456
  }) : void 0;
1253
1457
  const normalizedSourceOptions = resolvedSourceOptions ? normalizeTailwindV4CssSourceConfigs(resolvedSourceOptions) : void 0;
1254
- if (applyEntrySource && !cssHandlerOptions.isMainChunk && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1255
- const css = createTailwindV4ApplyReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(applyEntrySource.css, generatorOptions?.config), void 0), normalizedSourceOptions ?? {});
1256
- return require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1458
+ if (applyEntrySource && !cssHandlerOptions.isMainChunk && !require_generator.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1459
+ const css = createTailwindV4ApplyReferenceSource(require_generator.normalizeConfigDirective(require_generator.prependConfigDirective(applyEntrySource.css, generatorOptions?.config), void 0), normalizedSourceOptions ?? {});
1460
+ return require_generator.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1257
1461
  base: applyEntrySource.base,
1258
1462
  css
1259
1463
  }));
@@ -1270,51 +1474,51 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
1270
1474
  index: 0,
1271
1475
  matched: true
1272
1476
  }) : void 0;
1273
- const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await require_v4_engine.resolveTailwindV4Source(normalizedSourceOptions) : void 0;
1477
+ const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && require_generator.hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await require_generator.resolveTailwindV4Source(normalizedSourceOptions) : void 0;
1274
1478
  if (configuredCssSource) return generatorOptions?.config ? {
1275
1479
  ...configuredCssSource,
1276
- css: require_v4_engine.prependConfigDirective(configuredCssSource.css, generatorOptions.config)
1480
+ css: require_generator.prependConfigDirective(configuredCssSource.css, generatorOptions.config)
1277
1481
  } : configuredCssSource;
1278
1482
  const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
1279
1483
  const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssEntrySource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
1280
1484
  if (preferredCssEntrySource) return generatorOptions?.config ? {
1281
1485
  ...preferredCssEntrySource,
1282
- css: require_v4_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1486
+ css: require_generator.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1283
1487
  } : preferredCssEntrySource;
1284
1488
  const resolvedEntrySource = sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource;
1285
1489
  if (!resolvedEntrySource) {
1286
- const source = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtimeState.tailwindRuntime);
1490
+ const source = await require_generator.resolveTailwindV4SourceFromRuntime(runtimeState.tailwindRuntime);
1287
1491
  return generatorOptions?.config ? {
1288
1492
  ...source,
1289
- css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
1493
+ css: require_generator.prependConfigDirective(source.css, generatorOptions.config)
1290
1494
  } : source;
1291
1495
  }
1292
- const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, require_v4_engine.omitUndefined({
1496
+ const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, require_generator.omitUndefined({
1293
1497
  ...resolvedSourceOptions ?? {},
1294
1498
  sourceFile: resolvedEntrySource.file ?? resolvedSourceOptions?.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions)
1295
1499
  }));
1296
1500
  const sourceBase = resolvedEntrySource === cssEntrySource && config ? node_path.default.dirname(config) : resolvedEntrySource.base;
1297
- const css = createTailwindV4SourceReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
1298
- return require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1501
+ const css = createTailwindV4SourceReferenceSource(require_generator.normalizeConfigDirective(require_generator.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
1502
+ return require_generator.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1299
1503
  base: sourceBase,
1300
1504
  css
1301
1505
  }));
1302
1506
  }
1303
1507
  async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
1304
- const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), {
1508
+ const cssEntrySource = require_generator.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), {
1305
1509
  importFallback: generatorOptions?.importFallback ?? false,
1306
1510
  removeConfig: false
1307
1511
  });
1308
- if (cssEntrySource && !cssHandlerOptions.isMainChunk || !cssHandlerOptions.isMainChunk && require_v4_engine.hasTailwindApplyDirective(rawSource) && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1512
+ if (cssEntrySource && !cssHandlerOptions.isMainChunk || !cssHandlerOptions.isMainChunk && require_generator.hasTailwindApplyDirective(rawSource) && !require_generator.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1309
1513
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1310
1514
  return resolved ? [resolved] : [];
1311
1515
  }
1312
1516
  let sourceOptions;
1313
1517
  try {
1314
- const sourceOptionsFromRuntime = require_v4_engine.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
1518
+ const sourceOptionsFromRuntime = require_generator.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
1315
1519
  const cssEntries = selectionOptions?.cssEntries ?? sourceOptionsFromRuntime.cssEntries;
1316
1520
  const runtimeCssSources = selectionOptions?.cssEntries ? void 0 : sourceOptionsFromRuntime.cssSources;
1317
- sourceOptions = require_v4_engine.omitUndefined({
1521
+ sourceOptions = require_generator.omitUndefined({
1318
1522
  ...sourceOptionsFromRuntime,
1319
1523
  sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
1320
1524
  ...resolveCssHandlerSourceOptions(cssHandlerOptions),
@@ -1328,7 +1532,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
1328
1532
  const matchedCssEntrySource = sourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) : void 0;
1329
1533
  if (matchedCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
1330
1534
  ...matchedCssEntrySource,
1331
- css: require_v4_engine.prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
1535
+ css: require_generator.prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
1332
1536
  } : matchedCssEntrySource, matchedCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
1333
1537
  const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
1334
1538
  if (sourceSideCssSource) return [sourceSideCssSource];
@@ -1338,25 +1542,25 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
1338
1542
  const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssEntrySource ?? candidateMatchedCssSource;
1339
1543
  if (preferredCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
1340
1544
  ...preferredCssEntrySource,
1341
- css: require_v4_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1545
+ css: require_generator.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1342
1546
  } : preferredCssEntrySource, preferredCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
1343
1547
  if (!sourceOptions.cssEntries || sourceOptions.cssEntries.length <= 1) {
1344
1548
  if (cssHandlerOptions.isMainChunk && sourceOptions.cssEntries?.length === 1) return [await resolveTailwindV4CssEntrySource(sourceOptions.cssEntries[0], normalizeTailwindV4CssSourceConfigs(sourceOptions), { index: 0 }).then((source) => generatorOptions?.config ? {
1345
1549
  ...source,
1346
- css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
1550
+ css: require_generator.prependConfigDirective(source.css, generatorOptions.config)
1347
1551
  } : source)];
1348
1552
  if (sourceOptions.cssSources?.length === 1) return [normalizeResolvedTailwindV4SourceConfig(await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0], 0), sourceOptions.cssSources[0]?.file, sourceOptions)];
1349
1553
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1350
1554
  return resolved ? [resolved] : [];
1351
1555
  }
1352
- if (cssHandlerOptions.isMainChunk && !cssEntrySource && !require_v4_engine.hasTailwindGeneratedCss(rawSource) && !require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) && !require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false }) && !rawSource.includes("weapp-tailwindcss generator-placeholder") && !hasConfiguredTailwindV4CssSource(sourceOptions)) {
1556
+ if (cssHandlerOptions.isMainChunk && !cssEntrySource && !require_generator.hasTailwindGeneratedCss(rawSource) && !require_generator.hasTailwindGeneratedCssMarkers(rawSource) && !require_generator.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false }) && !rawSource.includes("weapp-tailwindcss generator-placeholder") && !hasConfiguredTailwindV4CssSource(sourceOptions)) {
1353
1557
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1354
1558
  return resolved ? [resolved] : [];
1355
1559
  }
1356
1560
  const normalizedCssSourceOptions = normalizeTailwindV4CssSourceConfigs(sourceOptions);
1357
1561
  const cssEntrySources = await Promise.all(sourceOptions.cssEntries.map((cssEntry, index) => resolveTailwindV4CssEntrySource(cssEntry, normalizedCssSourceOptions, { index }).then((source) => generatorOptions?.config ? {
1358
1562
  ...source,
1359
- css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
1563
+ css: require_generator.prependConfigDirective(source.css, generatorOptions.config)
1360
1564
  } : source)));
1361
1565
  const cssSources = sourceOptions.cssSources?.length ? await Promise.all(sourceOptions.cssSources.map(createTailwindV4CssSourceResolver(sourceOptions, generatorOptions))) : [];
1362
1566
  return [...cssEntrySources, ...cssSources];
@@ -1513,7 +1717,7 @@ function removeTailwindApplyRules(rawSource) {
1513
1717
  function resolveLegacyCompatCssSource(rawSource) {
1514
1718
  const cached = legacyCompatSourceCache.get(rawSource);
1515
1719
  if (cached !== void 0) return cached;
1516
- const resolved = closeTrailingUnclosedBlocks(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_v4_engine.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_v4_engine.stripTailwindBanners(rawSource)))))));
1720
+ const resolved = closeTrailingUnclosedBlocks(require_generator.removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_generator.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_generator.stripTailwindBanners(rawSource)))))));
1517
1721
  setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
1518
1722
  return resolved;
1519
1723
  }
@@ -1543,7 +1747,7 @@ function hasContainerConfigToken(rawSource) {
1543
1747
  }
1544
1748
  function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
1545
1749
  if (hasContainerConfigToken(rawSource)) return true;
1546
- const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
1750
+ const cssEntrySource = require_generator.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
1547
1751
  if (!cssEntrySource?.config) return false;
1548
1752
  try {
1549
1753
  return /\bcontainer\b/.test((0, node_fs.readFileSync)(cssEntrySource.config, "utf8"));
@@ -1554,7 +1758,7 @@ function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
1554
1758
  function hasConfiguredContainerCompatSource(source) {
1555
1759
  if (typeof source.css !== "string") return false;
1556
1760
  if (hasContainerConfigToken(source.css)) return true;
1557
- const cssEntrySource = require_v4_engine.resolveCssEntrySource(source.css, source.base);
1761
+ const cssEntrySource = require_generator.resolveCssEntrySource(source.css, source.base);
1558
1762
  if (cssEntrySource?.config) try {
1559
1763
  if (/\bcontainer\b/.test((0, node_fs.readFileSync)(cssEntrySource.config, "utf8"))) return true;
1560
1764
  } catch {}
@@ -1570,7 +1774,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
1570
1774
  const resolvedCompatSource = resolveLegacyCompatCssSource(rawSource);
1571
1775
  const compatSource = removeGeneratedSelectorCompatCss(generatorTarget === "weapp" ? removeMiniProgramContainerCompatCss(resolvedCompatSource) : resolvedCompatSource, css);
1572
1776
  if (compatSource.trim().length === 0) return css;
1573
- if (generatorTarget !== "weapp") return require_v4_engine.createCssAppend(css, compatSource);
1777
+ if (generatorTarget !== "weapp") return require_generator.createCssAppend(css, compatSource);
1574
1778
  const styleOptions = {
1575
1779
  ...cssHandlerOptions,
1576
1780
  ...generatorStyleOptions
@@ -1581,9 +1785,9 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
1581
1785
  compatCss = (await styleHandler(compatSource, styleOptions)).css;
1582
1786
  setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
1583
1787
  }
1584
- const cleanedCompatCss = collectDedupedPostTransformCompatCss(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css)), css);
1788
+ const cleanedCompatCss = collectDedupedPostTransformCompatCss(require_generator.removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css)), css);
1585
1789
  if (cleanedCompatCss.trim().length === 0) return css;
1586
- return require_v4_engine.createCssAppend(css, cleanedCompatCss);
1790
+ return require_generator.createCssAppend(css, cleanedCompatCss);
1587
1791
  }
1588
1792
  async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions) {
1589
1793
  if (generatorTarget === "weapp") return css;
@@ -1602,7 +1806,7 @@ async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, con
1602
1806
  }
1603
1807
  const cleanedCompatCss = collectDedupedPostTransformCompatCss((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css);
1604
1808
  if (cleanedCompatCss.trim().length === 0) return css;
1605
- return require_v4_engine.createCssAppend(css, cleanedCompatCss);
1809
+ return require_generator.createCssAppend(css, cleanedCompatCss);
1606
1810
  }
1607
1811
  //#endregion
1608
1812
  //#region src/bundlers/shared/generator-css/legacy-units.ts
@@ -1649,6 +1853,81 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
1649
1853
  }
1650
1854
  }
1651
1855
  //#endregion
1856
+ //#region src/bundlers/shared/generator-css/output-import-shell.ts
1857
+ const MINI_PROGRAM_OUTPUT_IMPORT_RE = /(@import\s+(?:url\(\s*)?)(["'])([^"']+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:[?#][^"']*)?)\2([^;]*;)/gi;
1858
+ const MINI_PROGRAM_OUTPUT_STYLE_RE = /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
1859
+ function normalizeMiniProgramOutputImportRequest(request) {
1860
+ if (request.startsWith(".") || request.startsWith("/") || /^(?:[a-z][a-z\d+.-]*:|#)/i.test(request)) return request;
1861
+ return `./${request}`;
1862
+ }
1863
+ function normalizeMiniProgramImportShell(css) {
1864
+ return css.replace(MINI_PROGRAM_OUTPUT_IMPORT_RE, (_match, prefix, quote, request, suffix) => {
1865
+ return `${prefix}${quote}${normalizeMiniProgramOutputImportRequest(request)}${quote}${suffix}`;
1866
+ });
1867
+ }
1868
+ function normalizeOutputPath(file) {
1869
+ const segments = [];
1870
+ for (const segment of file.replace(/\\/g, "/").replace(/^\/+/, "").split("/")) {
1871
+ if (!segment || segment === ".") continue;
1872
+ if (segment === "..") {
1873
+ if (segments.length > 0 && segments[segments.length - 1] !== "..") segments.pop();
1874
+ else segments.push(segment);
1875
+ continue;
1876
+ }
1877
+ segments.push(segment);
1878
+ }
1879
+ return segments.join("/");
1880
+ }
1881
+ function splitRequestSuffix(request) {
1882
+ const suffixIndexCandidates = [request.indexOf("?"), request.indexOf("#")].filter((index) => index >= 0);
1883
+ const suffixIndex = suffixIndexCandidates.length > 0 ? Math.min(...suffixIndexCandidates) : -1;
1884
+ return suffixIndex < 0 ? request : request.slice(0, suffixIndex);
1885
+ }
1886
+ function resolveOutputImportRequest(file, request) {
1887
+ const cleanRequest = splitRequestSuffix(request.replace(/\\/g, "/"));
1888
+ if (cleanRequest.startsWith("/")) return normalizeOutputPath(cleanRequest);
1889
+ const normalizedFile = normalizeOutputPath(file);
1890
+ const baseDir = normalizedFile.includes("/") ? normalizedFile.slice(0, normalizedFile.lastIndexOf("/")) : "";
1891
+ return normalizeOutputPath(baseDir ? `${baseDir}/${cleanRequest}` : cleanRequest);
1892
+ }
1893
+ function isMiniProgramOutputImport(node) {
1894
+ if (node.type !== "atrule" || node.name !== "import") return false;
1895
+ const request = require_generator.parseImportRequest(node.params);
1896
+ return request !== void 0 && MINI_PROGRAM_OUTPUT_STYLE_RE.test(request);
1897
+ }
1898
+ function isSelfMiniProgramOutputImport(outputFile, node) {
1899
+ if (!isMiniProgramOutputImport(node) || node.type !== "atrule") return false;
1900
+ const request = require_generator.parseImportRequest(node.params);
1901
+ return request !== void 0 && resolveOutputImportRequest(outputFile, request) === normalizeOutputPath(outputFile);
1902
+ }
1903
+ function removeMiniProgramOutputImportsBy(css, predicate) {
1904
+ if (!css.includes("@import")) return css;
1905
+ try {
1906
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
1907
+ let changed = false;
1908
+ root.walk((node) => {
1909
+ if (predicate(node)) {
1910
+ node.remove();
1911
+ changed = true;
1912
+ }
1913
+ });
1914
+ return changed ? root.toString() : css;
1915
+ } catch {
1916
+ return css;
1917
+ }
1918
+ }
1919
+ function removeSelfMiniProgramOutputImports(css, outputFile) {
1920
+ return removeMiniProgramOutputImportsBy(css, (node) => isSelfMiniProgramOutputImport(outputFile, node));
1921
+ }
1922
+ function removeMiniProgramOutputImports(css) {
1923
+ return removeMiniProgramOutputImportsBy(css, isMiniProgramOutputImport);
1924
+ }
1925
+ function normalizeMiniProgramGeneratorCssSource(css, outputFile) {
1926
+ const normalized = normalizeMiniProgramImportShell(css);
1927
+ if (outputFile) return removeSelfMiniProgramOutputImports(normalized, outputFile);
1928
+ return (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(normalized) ? normalized : removeMiniProgramOutputImports(normalized);
1929
+ }
1930
+ //#endregion
1652
1931
  //#region src/bundlers/shared/generator-css/user-layer-order.ts
1653
1932
  const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
1654
1933
  const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
@@ -1812,19 +2091,22 @@ async function validateCandidatesByGenerator(options) {
1812
2091
  if (majorVersion !== 4 || candidates.size === 0) return /* @__PURE__ */ new Set();
1813
2092
  const classSet = /* @__PURE__ */ new Set();
1814
2093
  try {
1815
- const sources = await resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, {
2094
+ const generatorOptions = {
1816
2095
  ...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator),
1817
2096
  bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
1818
- }, {
1819
- cssEntries: opts.cssEntries,
1820
- runtime: candidates
1821
- });
1822
- const classSets = await Promise.all(sources.map(async (source) => {
1823
- const generator = require_generator.createWeappTailwindcssGenerator(source);
1824
- if (typeof generator.validateCandidates !== "function") return /* @__PURE__ */ new Set();
1825
- return generator.validateCandidates(candidates);
1826
- }));
1827
- for (const candidate of classSets.flatMap((item) => [...item])) classSet.add(candidate);
2097
+ };
2098
+ if (generatorOptions.enabled) {
2099
+ const sources = await resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, {
2100
+ cssEntries: opts.cssEntries,
2101
+ runtime: candidates
2102
+ });
2103
+ const classSets = await Promise.all(sources.map(async (source) => {
2104
+ const generator = require_generator.createWeappTailwindcssGenerator(source);
2105
+ if (typeof generator.validateCandidates !== "function") return /* @__PURE__ */ new Set();
2106
+ return generator.validateCandidates(candidates);
2107
+ }));
2108
+ for (const candidate of classSets.flatMap((item) => [...item])) classSet.add(candidate);
2109
+ }
1828
2110
  } catch {}
1829
2111
  const rawSourceCandidates = collectGeneratedRawSourceCandidates(candidates, rawSource, opts.escapeMap);
1830
2112
  for (const candidate of rawSourceCandidates) classSet.add(candidate);
@@ -1839,6 +2121,15 @@ function resolveGeneratorSourceConcurrency() {
1839
2121
  if (Number.isFinite(configured) && configured > 0) return configured;
1840
2122
  return 1;
1841
2123
  }
2124
+ function hasPostcssUserPlugins(options) {
2125
+ const plugins = options.postcssOptions?.plugins;
2126
+ if (Array.isArray(plugins)) return plugins.length > 0;
2127
+ return typeof plugins === "object" && plugins !== null && Object.keys(plugins).length > 0;
2128
+ }
2129
+ function shouldProcessDisabledGeneratorCss(rawSource, options) {
2130
+ if (!hasPostcssUserPlugins(options)) return false;
2131
+ return /@import\s+(?:url\(\s*)?["']tailwindcss(?:\/[^"')\s]*)?["']/.test(rawSource) || require_generator.hasTailwindApplyDirective(rawSource);
2132
+ }
1842
2133
  function intersectCandidateSets(left, right) {
1843
2134
  if (left.size === 0 || right.size === 0) return /* @__PURE__ */ new Set();
1844
2135
  const [small, large] = left.size <= right.size ? [left, right] : [right, left];
@@ -1894,9 +2185,18 @@ function mergeGeneratedCssClassSet(classSet, candidates, css, escapeMap) {
1894
2185
  for (const candidate of collectGeneratedRawSourceCandidates(candidates, css, escapeMap)) merged.add(candidate);
1895
2186
  return merged;
1896
2187
  }
2188
+ function resolveGeneratedCssClassSet(target, classSet, candidates, css, escapeMap, previousClassSet) {
2189
+ if (target === "web") return /* @__PURE__ */ new Set([...previousClassSet ?? [], ...classSet]);
2190
+ return mergeGeneratedCssClassSet(classSet, candidates, css, escapeMap);
2191
+ }
1897
2192
  function finalizeWebGeneratorCss(css, target, webCompat) {
1898
2193
  return target === "web" ? (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(css, webCompat) : css;
1899
2194
  }
2195
+ function finalizeIncrementalGeneratorCss(previousCss, incrementalCss, target, majorVersion, cssPreflight, options, webCompat) {
2196
+ const finalizedIncrementalCss = finalizeMiniProgramGeneratorCss(incrementalCss, target, majorVersion, cssPreflight, options);
2197
+ if (target === "web") return require_generator.createCssAppend(previousCss, finalizeWebGeneratorCss(finalizedIncrementalCss, target, webCompat));
2198
+ return require_generator.createCssAppend(previousCss, finalizedIncrementalCss);
2199
+ }
1900
2200
  async function generateCssByGenerator(options) {
1901
2201
  const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, generatorPlatform, userRawSource, userRawSourceProcessed, debug } = options;
1902
2202
  const platform = generatorPlatform ?? opts.cssOptions?.platform ?? opts.platform;
@@ -1917,7 +2217,37 @@ async function generateCssByGenerator(options) {
1917
2217
  });
1918
2218
  const majorVersion = runtimeState.tailwindRuntime.majorVersion;
1919
2219
  if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
1920
- const effectiveRawSource = require_v4_engine.stripUnmatchedTailwindSourceMediaCloseFragments(require_v4_engine.stripTailwindSourceMediaFragments(require_v4_engine.normalizeEmptyTailwindCustomVariants(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback }))));
2220
+ const useMiniProgramCssBranch = require_generator.shouldUseMiniProgramCssBranch(generatorBranch);
2221
+ const normalizeGeneratorCssSource = (css) => {
2222
+ return useMiniProgramCssBranch ? normalizeMiniProgramGeneratorCssSource(css, file) : css;
2223
+ };
2224
+ const normalizeGeneratorSource = (source) => {
2225
+ const css = normalizeGeneratorCssSource(source.css);
2226
+ return css === source.css ? source : {
2227
+ ...source,
2228
+ css
2229
+ };
2230
+ };
2231
+ if (!generatorOptions.enabled) {
2232
+ debug("tailwind direct css generation disabled: %s", file);
2233
+ if (shouldProcessDisabledGeneratorCss(rawSource, cssHandlerOptions)) {
2234
+ const handled = await styleHandler(rawSource, cssHandlerOptions);
2235
+ return {
2236
+ css: finalizeWebGeneratorCss(handled.css, generatorOptions.target, generatorOptions.webCompat),
2237
+ classSet: resolveGeneratedCssClassSet(generatorOptions.target, /* @__PURE__ */ new Set(), runtime, handled.css, opts.escapeMap, options.previousClassSet),
2238
+ target: generatorOptions.target,
2239
+ source: "generator",
2240
+ dependencies: [],
2241
+ metadata: {
2242
+ file,
2243
+ majorVersion,
2244
+ rawCss: rawSource
2245
+ }
2246
+ };
2247
+ }
2248
+ return;
2249
+ }
2250
+ const effectiveRawSource = require_generator.stripUnmatchedTailwindSourceMediaCloseFragments(require_generator.stripTailwindSourceMediaFragments(require_generator.normalizeEmptyTailwindCustomVariants(normalizeGeneratorCssSource(require_generator.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })))));
1921
2251
  const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
1922
2252
  const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
1923
2253
  if (cleanedLocalImportWrapper !== void 0) return {
@@ -1938,20 +2268,24 @@ async function generateCssByGenerator(options) {
1938
2268
  return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports, { outputFile: file }), target, generatorOptions.webCompat);
1939
2269
  };
1940
2270
  const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
1941
- const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : require_v4_engine.stripUnmatchedTailwindSourceMediaCloseFragments(require_v4_engine.stripTailwindSourceMediaFragments(require_v4_engine.normalizeEmptyTailwindCustomVariants(require_v4_engine.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback }))));
2271
+ const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : require_generator.stripUnmatchedTailwindSourceMediaCloseFragments(require_generator.stripTailwindSourceMediaFragments(require_generator.normalizeEmptyTailwindCustomVariants(normalizeGeneratorCssSource(require_generator.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })))));
1942
2272
  const userSource = (rawUserSource === generatorRawSource ? void 0 : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawUserSource))?.source ?? rawUserSource;
1943
- const userCssRawSource = require_v4_engine.removeTailwindV4GeneratorAtRules(userSource);
1944
- const generatedUserCssOrderSource = require_v4_engine.hasTailwindGeneratedCss(userSource) ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
1945
- const generatedUserCssRawSource = generatedUserCssOrderSource ? require_v4_engine.createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : require_v4_engine.hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
1946
- const userCssOrderSource = require_v4_engine.GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : require_v4_engine.hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
2273
+ const userCssRawSource = require_generator.removeTailwindV4GeneratorAtRules(userSource);
2274
+ const hasWebUserCssFallbackSource = userCssRawSource.trim().length > 0 && !require_generator.isCommentOnlyCss(userCssRawSource);
2275
+ const generatedUserCssOrderSource = require_generator.hasTailwindGeneratedCss(userSource) ? require_generator.splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
2276
+ const generatedUserCssRawSource = generatedUserCssOrderSource ? require_generator.createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : require_generator.hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
2277
+ const userCssOrderSource = require_generator.GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : require_generator.hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
1947
2278
  const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(generatedUserCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
1948
- const hasGeneratedCss = require_v4_engine.hasTailwindGeneratedCss(generatorRawSource);
1949
- const hasSourceDirectives = require_v4_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
1950
- const hasGeneratedMarkers = require_v4_engine.hasTailwindGeneratedCssMarkers(generatorRawSource);
1951
- const normalizedCssSources = options.cssSources?.map((source) => ({
1952
- ...source,
1953
- css: require_v4_engine.normalizeEmptyTailwindCustomVariants(source.css)
1954
- }));
2279
+ const hasGeneratedCss = require_generator.hasTailwindGeneratedCss(generatorRawSource);
2280
+ const hasSourceDirectives = require_generator.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
2281
+ const hasGeneratedMarkers = require_generator.hasTailwindGeneratedCssMarkers(generatorRawSource);
2282
+ const normalizedCssSources = options.cssSources?.map((source) => {
2283
+ const css = normalizeGeneratorCssSource(require_generator.normalizeEmptyTailwindCustomVariants(source.css));
2284
+ return css === source.css ? source : {
2285
+ ...source,
2286
+ css
2287
+ };
2288
+ });
1955
2289
  if (!shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
1956
2290
  forceGenerator: options.forceGenerator,
1957
2291
  hasGeneratedCss,
@@ -1977,11 +2311,15 @@ async function generateCssByGenerator(options) {
1977
2311
  getSourceCandidatesForEntries,
1978
2312
  runtime: runtimeWithCurrentCss
1979
2313
  });
2314
+ const generatorSources = useMiniProgramCssBranch ? sources.map(normalizeGeneratorSource) : sources;
1980
2315
  const generatorStyleOptions = resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorOptions.styleOptions);
1981
- const configuredContainerCompat = hasConfiguredContainerCompatSources(sources);
2316
+ const configuredContainerCompat = hasConfiguredContainerCompatSources(generatorSources);
1982
2317
  const sourceConcurrency = resolveGeneratorSourceConcurrency();
1983
- const generated = mergeGeneratorResults((await runWithConcurrency(sources.map((source) => async () => {
1984
- const generator = require_generator.createWeappTailwindcssGenerator(source);
2318
+ const generated = mergeGeneratorResults((await runWithConcurrency(generatorSources.map((source) => async () => {
2319
+ const generator = require_generator.createWeappTailwindcssGenerator(options.disableSourceScan === true ? {
2320
+ ...source,
2321
+ css: require_generator.removeTailwindSourceDirectives(source.css, { importFallback: generatorOptions.importFallback })
2322
+ } : source);
1985
2323
  const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
1986
2324
  const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
1987
2325
  const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
@@ -2002,27 +2340,28 @@ async function generateCssByGenerator(options) {
2002
2340
  majorVersion,
2003
2341
  matchedCssSourceFile
2004
2342
  }) : runtimeWithCurrentCss;
2005
- const generatorRuntime = require_generator.shouldUseMiniProgramCssBranch(generatorBranch) ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
2343
+ const generatorRuntime = require_generator.shouldUseMiniProgramCssBranch(generatorBranch) ? require_generator.filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
2006
2344
  return generator.generate({
2007
2345
  bareArbitraryValues: generatorOptions.bareArbitraryValues,
2008
2346
  candidates: generatorRuntime,
2009
2347
  incrementalCache: true,
2010
- scanSources: shouldScanTailwindV4Sources(majorVersion, generatorOptions.target, generatorRuntime, isolateCssSource),
2348
+ scanSources: options.disableSourceScan === true ? false : shouldScanTailwindV4Sources(majorVersion, generatorOptions.target, generatorRuntime, isolateCssSource),
2011
2349
  styleOptions: generatorStyleOptions,
2012
2350
  target: generatorOptions.target
2013
2351
  });
2014
2352
  }), sourceConcurrency)).filter((item) => Boolean(item)));
2015
2353
  if (!generated) return;
2016
2354
  debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
2017
- if ((generated.target !== "weapp" || !require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
2018
- const incrementalCss = require_v4_engine.stripTailwindBanner(generated.incrementalCss);
2019
- const finalCss = finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(incrementalCss.trim().length > 0 ? require_v4_engine.createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
2355
+ if ((generated.target !== "weapp" || !require_generator.hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
2356
+ const incrementalCss = require_generator.stripTailwindBanner(generated.incrementalCss);
2357
+ const css = incrementalCss.trim().length > 0 ? finalizeIncrementalGeneratorCss(options.previousCss, incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
2020
2358
  injectPreflight: false,
2021
2359
  styleOptions: generatorStyleOptions
2022
- })) : options.previousCss, localImports, { outputFile: file }), generated.target, generatorOptions.webCompat);
2360
+ }, generatorOptions.webCompat) : options.previousCss;
2361
+ const finalCss = generated.target === "web" ? (0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(css, localImports, { outputFile: file }) : finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(css, localImports, { outputFile: file }), generated.target, generatorOptions.webCompat);
2023
2362
  return {
2024
2363
  css: finalCss,
2025
- classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
2364
+ classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
2026
2365
  target: generated.target,
2027
2366
  source: "generator",
2028
2367
  dependencies: generated.dependencies,
@@ -2034,27 +2373,34 @@ async function generateCssByGenerator(options) {
2034
2373
  }
2035
2374
  };
2036
2375
  }
2037
- const shouldFilterApplyOnlyCss = require_v4_engine.shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
2376
+ const shouldFilterApplyOnlyCss = require_generator.shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
2038
2377
  hasGeneratedCss,
2039
2378
  hasGeneratedMarkers
2040
2379
  });
2041
- const generatedCssSource = generated.target === "web" ? generated.css : require_v4_engine.stripTailwindBanner(generated.css);
2042
- const generatedCss = shouldFilterApplyOnlyCss ? require_v4_engine.filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource, { preserveVariables: generated.target !== "web" }) : generatedCssSource;
2043
- const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
2044
- const hasExplicitCssSource = sources.some((source) => {
2380
+ const generatedCssSource = generated.target === "web" ? generated.css : require_generator.stripTailwindBanner(generated.css);
2381
+ const generatedCss = shouldFilterApplyOnlyCss ? require_generator.filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource, { preserveVariables: generated.target !== "web" }) : generatedCssSource;
2382
+ const hasMatchedCssSourceFile = generatorSources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
2383
+ const hasExplicitCssSource = generatorSources.some((source) => {
2384
+ const metadata = source.__weappTailwindcssMeta;
2385
+ return metadata?.candidateMatchedCssSource !== true && (metadata?.cssEntryIndex !== void 0 || metadata?.cssSourceIndex !== void 0);
2386
+ });
2387
+ const hasPreflightCssSource = generatorSources.some((source) => {
2045
2388
  const metadata = source.__weappTailwindcssMeta;
2046
- return metadata?.cssEntryIndex !== void 0 || metadata?.cssSourceIndex !== void 0;
2389
+ const appEntryMatchedByCandidates = metadata?.candidateMatchedCssSource === true && metadata.cssEntryIndex === 0 && metadata.cssSourceIndex === void 0;
2390
+ return metadata?.includesPreflight === true && !appEntryMatchedByCandidates;
2047
2391
  });
2048
- const hasPreflightCssSource = sources.some((source) => source.__weappTailwindcssMeta?.includesPreflight === true);
2049
2392
  const hasPreflightRawSource = require_tailwindcss.includesTailwindV4PreflightDirective(generatorRawSource);
2050
2393
  const preflightMode = resolveMiniProgramPreflightModeForGeneratorCss(opts, {
2051
2394
  cssHandlerOptions,
2052
2395
  isolateCurrentCssCandidates,
2053
2396
  localImports,
2054
2397
  explicitCssSource: hasExplicitCssSource,
2055
- primaryCssSource: sources.length > 0 && sources.every((source) => source.__weappTailwindcssMeta?.primaryCssSource === true) || hasPreflightCssSource || hasPreflightRawSource
2398
+ primaryCssSource: generatorSources.length > 0 && generatorSources.every((source) => {
2399
+ const metadata = source.__weappTailwindcssMeta;
2400
+ return metadata?.candidateMatchedCssSource !== true && metadata?.primaryCssSource === true;
2401
+ }) || hasPreflightCssSource || hasPreflightRawSource
2056
2402
  });
2057
- const orderedExtraCss = require_v4_engine.splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
2403
+ const orderedExtraCss = require_generator.splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? require_generator.splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
2058
2404
  const shouldAppendMatchedCssSourceCompat = !hasMatchedCssSourceFile || orderedExtraCss !== void 0;
2059
2405
  if (orderedExtraCss) {
2060
2406
  let css = generatedCss;
@@ -2067,29 +2413,29 @@ async function generateCssByGenerator(options) {
2067
2413
  importFallback: generatorOptions.importFallback,
2068
2414
  processed: userRawSourceProcessed
2069
2415
  };
2070
- const afterLayerParts = generated.target === "weapp" ? require_v4_engine.splitUserCssLayerBlocks(orderedExtraCss.after) : {
2416
+ const afterLayerParts = generated.target === "weapp" ? require_generator.splitUserCssLayerBlocks(orderedExtraCss.after) : {
2071
2417
  layer: "",
2072
2418
  rest: orderedExtraCss.after
2073
2419
  };
2074
- const beforeUserCss = await require_v4_engine.transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
2075
- const afterLayerUserCss = await require_v4_engine.transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
2076
- const afterUserCss = await require_v4_engine.transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
2077
- const fallbackLayerUserCss = generated.target === "weapp" && require_v4_engine.hasUserCssLayerBlocks(userCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(afterLayerUserCss, await require_v4_engine.transformGeneratorUserCss(require_v4_engine.splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions)) : "";
2420
+ const beforeUserCss = await require_generator.transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
2421
+ const afterLayerUserCss = await require_generator.transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
2422
+ const afterUserCss = await require_generator.transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
2423
+ const fallbackLayerUserCss = generated.target === "weapp" && require_generator.hasUserCssLayerBlocks(userCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(afterLayerUserCss, await require_generator.transformGeneratorUserCss(require_generator.splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions)) : "";
2078
2424
  css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
2079
- if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
2425
+ if (hasWebUserCssFallbackSource && isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
2080
2426
  hasSourceDirectives,
2081
2427
  hasMatchedCssSourceFile
2082
2428
  })) {
2083
- const userCss = await require_v4_engine.transformGeneratorUserCss(userCssRawSource, userCssOptions);
2429
+ const userCss = await require_generator.transformGeneratorUserCss(userCssRawSource, userCssOptions);
2084
2430
  css = createCssSourceOrderAppend$1(css, userCss);
2085
2431
  }
2086
- if (generated.target === "web") {
2087
- const userCss = await require_v4_engine.transformGeneratorUserCss(userCssRawSource, userCssOptions);
2088
- const missingUserCss = require_v4_engine.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
2432
+ if (generated.target === "web" && hasWebUserCssFallbackSource) {
2433
+ const userCss = await require_generator.transformGeneratorUserCss(userCssRawSource, userCssOptions);
2434
+ const missingUserCss = require_generator.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
2089
2435
  css = createCssSourceOrderAppend$1(css, missingUserCss);
2090
2436
  }
2091
- if (generated.target === "weapp" && isEmptyCssSourceOrderParts(orderedExtraCss) && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
2092
- const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
2437
+ if (generated.target === "weapp" && isEmptyCssSourceOrderParts(orderedExtraCss) && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_generator.hasTailwindApplyDirective(generatedUserCssRawSource)) {
2438
+ const userCss = await require_generator.transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
2093
2439
  const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
2094
2440
  css = createCssSourceOrderAppend$1(css, missingUserCss);
2095
2441
  }
@@ -2107,7 +2453,7 @@ async function generateCssByGenerator(options) {
2107
2453
  });
2108
2454
  return {
2109
2455
  css: finalCss,
2110
- classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
2456
+ classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
2111
2457
  target: generated.target,
2112
2458
  source: "generator",
2113
2459
  dependencies: generated.dependencies,
@@ -2120,7 +2466,7 @@ async function generateCssByGenerator(options) {
2120
2466
  }
2121
2467
  debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
2122
2468
  let css = generatedCss;
2123
- if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
2469
+ if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !require_generator.hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await require_generator.transformGeneratorUserCss(generatedUserCssRawSource, {
2124
2470
  generatorTarget: generated.target,
2125
2471
  generatorStyleOptions,
2126
2472
  cssUserHandlerOptions,
@@ -2130,9 +2476,9 @@ async function generateCssByGenerator(options) {
2130
2476
  }), css);
2131
2477
  if (generated.target === "weapp") {
2132
2478
  css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
2133
- if (require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) {
2134
- const layerParts = require_v4_engine.splitUserCssLayerBlocks(generatorRawSource);
2135
- const layerUserCss = await require_v4_engine.transformGeneratorUserCss(layerParts.layer, {
2479
+ if (require_generator.hasUserCssLayerBlocks(generatorRawSource)) {
2480
+ const layerParts = require_generator.splitUserCssLayerBlocks(generatorRawSource);
2481
+ const layerUserCss = await require_generator.transformGeneratorUserCss(layerParts.layer, {
2136
2482
  generatorTarget: generated.target,
2137
2483
  generatorStyleOptions,
2138
2484
  cssUserHandlerOptions,
@@ -2140,10 +2486,10 @@ async function generateCssByGenerator(options) {
2140
2486
  importFallback: generatorOptions.importFallback,
2141
2487
  processed: userRawSourceProcessed
2142
2488
  });
2143
- const layerCss = layerUserCss.trim().length > 0 && !require_v4_engine.hasTailwindApplyDirective(layerUserCss) ? {
2489
+ const layerCss = layerUserCss.trim().length > 0 && !require_generator.hasTailwindApplyDirective(layerUserCss) ? {
2144
2490
  layer: layerUserCss,
2145
2491
  rest: css
2146
- } : require_v4_engine.extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
2492
+ } : require_generator.extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
2147
2493
  if (layerCss.layer.trim().length > 0) {
2148
2494
  css = createCssSourceOrderAppend$1(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
2149
2495
  if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
@@ -2152,7 +2498,7 @@ async function generateCssByGenerator(options) {
2152
2498
  }
2153
2499
  if (hasMatchedCssSourceFile || generated.target === "web") {
2154
2500
  if (generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
2155
- const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
2501
+ const userCss = await require_generator.transformGeneratorUserCss(generatedUserCssRawSource, {
2156
2502
  generatorTarget: generated.target,
2157
2503
  generatorStyleOptions,
2158
2504
  cssUserHandlerOptions,
@@ -2163,7 +2509,7 @@ async function generateCssByGenerator(options) {
2163
2509
  const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
2164
2510
  css = createCssSourceOrderAppend$1(css, missingUserCss);
2165
2511
  } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers && !hasGeneratedCss) {
2166
- const userCss = await require_v4_engine.transformGeneratorUserCss(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
2512
+ const userCss = await require_generator.transformGeneratorUserCss(require_generator.removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
2167
2513
  generatorTarget: generated.target,
2168
2514
  generatorStyleOptions,
2169
2515
  cssUserHandlerOptions,
@@ -2173,8 +2519,8 @@ async function generateCssByGenerator(options) {
2173
2519
  });
2174
2520
  const missingUserCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
2175
2521
  css = createCssSourceOrderAppend$1(css, missingUserCss);
2176
- } else if (hasMatchedCssSourceFile && generated.target === "weapp" && require_v4_engine.hasUserCssLayerBlocks(generatedUserCssRawSource)) {
2177
- const layerUserCss = await require_v4_engine.transformGeneratorUserCss(require_v4_engine.splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
2522
+ } else if (hasMatchedCssSourceFile && generated.target === "weapp" && require_generator.hasUserCssLayerBlocks(generatedUserCssRawSource)) {
2523
+ const layerUserCss = await require_generator.transformGeneratorUserCss(require_generator.splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
2178
2524
  generatorTarget: generated.target,
2179
2525
  generatorStyleOptions,
2180
2526
  cssUserHandlerOptions,
@@ -2190,11 +2536,11 @@ async function generateCssByGenerator(options) {
2190
2536
  if (hasMatchedCssSourceFile && generated.target === "weapp") {
2191
2537
  if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss && !userRawSourceProcessed && !hasGeneratedCss && !hasGeneratedMarkers) css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2192
2538
  }
2193
- if (shouldAppendWebBundleCssFallback(generated.target, {
2539
+ if (hasWebUserCssFallbackSource && shouldAppendWebBundleCssFallback(generated.target, {
2194
2540
  hasSourceDirectives,
2195
2541
  hasMatchedCssSourceFile
2196
2542
  })) {
2197
- const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
2543
+ const userCss = await require_generator.transformGeneratorUserCss(generatedUserCssRawSource, {
2198
2544
  generatorTarget: generated.target,
2199
2545
  generatorStyleOptions,
2200
2546
  cssUserHandlerOptions,
@@ -2202,7 +2548,7 @@ async function generateCssByGenerator(options) {
2202
2548
  importFallback: generatorOptions.importFallback,
2203
2549
  processed: userRawSourceProcessed
2204
2550
  });
2205
- const missingUserCss = require_v4_engine.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
2551
+ const missingUserCss = require_generator.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
2206
2552
  css = createCssSourceOrderAppend$1(css, missingUserCss);
2207
2553
  }
2208
2554
  const finalCss = finalizeGeneratorCss(css, generated.target, {
@@ -2212,7 +2558,7 @@ async function generateCssByGenerator(options) {
2212
2558
  });
2213
2559
  return {
2214
2560
  css: finalCss,
2215
- classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
2561
+ classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
2216
2562
  target: generated.target,
2217
2563
  source: "generator",
2218
2564
  dependencies: generated.dependencies,
@@ -2227,8 +2573,8 @@ async function generateCssByGenerator(options) {
2227
2573
  css = await appendLegacyCompatCss(css, generatedUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2228
2574
  css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2229
2575
  }
2230
- if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
2231
- const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
2576
+ if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_generator.hasTailwindApplyDirective(generatedUserCssRawSource)) {
2577
+ const userCss = await require_generator.transformGeneratorUserCss(generatedUserCssRawSource, {
2232
2578
  generatorTarget: generated.target,
2233
2579
  generatorStyleOptions,
2234
2580
  cssUserHandlerOptions,
@@ -2246,7 +2592,7 @@ async function generateCssByGenerator(options) {
2246
2592
  });
2247
2593
  return {
2248
2594
  css: finalCss,
2249
- classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
2595
+ classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
2250
2596
  target: generated.target,
2251
2597
  source: "generator",
2252
2598
  dependencies: generated.dependencies,
@@ -2434,7 +2780,7 @@ function createBundleRuntimeClassSetManager(options = {}) {
2434
2780
  designSystemPromise = void 0;
2435
2781
  }
2436
2782
  async function resolveValidationContextCached(runtime) {
2437
- if (!validationContext) validationContext = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtime);
2783
+ if (!validationContext) validationContext = await require_generator.resolveTailwindV4SourceFromRuntime(runtime);
2438
2784
  return validationContext;
2439
2785
  }
2440
2786
  async function loadDesignSystem(context) {
@@ -2628,7 +2974,7 @@ function resolveOutDirIgnorePattern(root, outDir) {
2628
2974
  if (!outDir) return;
2629
2975
  const relative = node_path.default.relative(root, node_path.default.resolve(root, outDir));
2630
2976
  if (!relative || relative.startsWith("..") || node_path.default.isAbsolute(relative)) return;
2631
- return `${require_v4_engine.toPosixPath(relative)}/**`;
2977
+ return `${require_generator.toPosixPath(relative)}/**`;
2632
2978
  }
2633
2979
  function normalizeScanEntries(root, entries, outDirIgnore) {
2634
2980
  const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
@@ -2676,6 +3022,7 @@ function createDefaultIgnoredSources(root, outDirIgnore, entries, explicit) {
2676
3022
  }
2677
3023
  function resolveSourceCandidateScanFiles(options) {
2678
3024
  const resolvedRoot = node_path.default.resolve(options.root);
3025
+ if (options.explicit && options.entries?.length && options.entries.every((entry) => entry.negated)) return Promise.resolve([]);
2679
3026
  const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, options.outDir);
2680
3027
  const scanEntries = normalizeScanEntries(resolvedRoot, options.entries, outDirIgnore);
2681
3028
  const ignoredSources = createDefaultIgnoredSources(resolvedRoot, outDirIgnore, options.entries, options.explicit);
@@ -2691,7 +3038,7 @@ function resolveSourceCandidateScanFiles(options) {
2691
3038
  const CLEAN_URL_RE = /[?#].*$/;
2692
3039
  const sourceCandidateContentCache = new lru_cache.LRUCache({ max: 128 });
2693
3040
  function cleanUrl(id) {
2694
- return require_v4_engine.resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
3041
+ return require_generator.resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
2695
3042
  }
2696
3043
  function resolveSourceCandidateExtension(id) {
2697
3044
  const normalized = cleanUrl(id);
@@ -2704,7 +3051,7 @@ async function extractCandidates(source, extension, options) {
2704
3051
  return extractCandidatesFromSource(source, extension, options);
2705
3052
  }
2706
3053
  function isSourceCandidateRequest(id) {
2707
- return require_v4_engine.FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
3054
+ return require_generator.FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
2708
3055
  }
2709
3056
  function removeCandidateSet(candidateCount, candidates) {
2710
3057
  for (const candidate of candidates) {
@@ -2720,6 +3067,16 @@ function removeCandidateSet(candidateCount, candidates) {
2720
3067
  function addCandidateSet(candidateCount, candidates) {
2721
3068
  for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
2722
3069
  }
3070
+ function diffCandidateSets(previous, next) {
3071
+ const addedCandidates = /* @__PURE__ */ new Set();
3072
+ const removedCandidates = /* @__PURE__ */ new Set();
3073
+ for (const candidate of next) if (!previous.has(candidate)) addedCandidates.add(candidate);
3074
+ for (const candidate of previous) if (!next.has(candidate)) removedCandidates.add(candidate);
3075
+ return {
3076
+ addedCandidates,
3077
+ removedCandidates
3078
+ };
3079
+ }
2723
3080
  function createSourceCandidateStore(options = {}) {
2724
3081
  const candidatesById = /* @__PURE__ */ new Map();
2725
3082
  const scanCandidatesById = /* @__PURE__ */ new Map();
@@ -2780,11 +3137,25 @@ function createSourceCandidateStore(options = {}) {
2780
3137
  throw error;
2781
3138
  }
2782
3139
  }
2783
- async function syncCurrentFile(id) {
3140
+ async function syncCurrentSource(id, source) {
2784
3141
  const normalizedId = cleanUrl(id);
2785
3142
  transformCandidatesById.delete(normalizedId);
2786
3143
  cssCandidatesById.delete(normalizedId);
2787
- await syncFile(normalizedId);
3144
+ transformSourceById.delete(normalizedId);
3145
+ cssSourceById.delete(normalizedId);
3146
+ recompute(normalizedId);
3147
+ const previousCandidates = values();
3148
+ await sync(normalizedId, source);
3149
+ return diffCandidateSets(previousCandidates, values());
3150
+ }
3151
+ async function syncCurrentFile(id) {
3152
+ const normalizedId = cleanUrl(id);
3153
+ try {
3154
+ return await syncCurrentSource(normalizedId, await (0, node_fs_promises.readFile)(normalizedId, "utf8"));
3155
+ } catch (error) {
3156
+ if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) === "ENOENT") return remove(normalizedId);
3157
+ throw error;
3158
+ }
2788
3159
  }
2789
3160
  async function scanRoot({ entries, explicit, root, outDir }) {
2790
3161
  const files = await resolveSourceCandidateScanFiles({
@@ -2794,7 +3165,7 @@ function createSourceCandidateStore(options = {}) {
2794
3165
  outDir,
2795
3166
  root
2796
3167
  });
2797
- await Promise.all(files.map((file) => syncFile(require_v4_engine.resolveSourceScanPath(file))));
3168
+ await Promise.all(files.map((file) => syncFile(require_generator.resolveSourceScanPath(file))));
2798
3169
  }
2799
3170
  function replaceFinal(id, nextCandidates) {
2800
3171
  const normalizedId = cleanUrl(id);
@@ -2839,6 +3210,7 @@ function createSourceCandidateStore(options = {}) {
2839
3210
  }
2840
3211
  function remove(id) {
2841
3212
  const normalizedId = cleanUrl(id);
3213
+ const previousValues = values();
2842
3214
  scanCandidatesById.delete(normalizedId);
2843
3215
  transformCandidatesById.delete(normalizedId);
2844
3216
  cssCandidatesById.delete(normalizedId);
@@ -2846,9 +3218,10 @@ function createSourceCandidateStore(options = {}) {
2846
3218
  transformSourceById.delete(normalizedId);
2847
3219
  cssSourceById.delete(normalizedId);
2848
3220
  const previousCandidates = candidatesById.get(normalizedId);
2849
- if (!previousCandidates) return;
3221
+ if (!previousCandidates) return diffCandidateSets(previousValues, values());
2850
3222
  removeCandidateSet(candidateCount, previousCandidates);
2851
3223
  candidatesById.delete(normalizedId);
3224
+ return diffCandidateSets(previousValues, values());
2852
3225
  }
2853
3226
  function source(id) {
2854
3227
  const normalizedId = cleanUrl(id);
@@ -2869,8 +3242,8 @@ function createSourceCandidateStore(options = {}) {
2869
3242
  if (entries?.length === 0) return new Set(inlineIncludedCandidates);
2870
3243
  const filtered = /* @__PURE__ */ new Set();
2871
3244
  for (const [id, candidates] of candidatesById) {
2872
- if (entries !== void 0 && !require_v4_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
2873
- if (options.excludeEntries?.length && require_v4_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
3245
+ if (entries !== void 0 && !require_generator.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
3246
+ if (options.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
2874
3247
  for (const candidate of candidates) filtered.add(candidate);
2875
3248
  }
2876
3249
  for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
@@ -2893,8 +3266,8 @@ function createSourceCandidateStore(options = {}) {
2893
3266
  return sources;
2894
3267
  }
2895
3268
  for (const [id, candidates] of candidatesById) {
2896
- if (entries !== void 0 && !require_v4_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
2897
- if (options.excludeEntries?.length && require_v4_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
3269
+ if (entries !== void 0 && !require_generator.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
3270
+ if (options.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
2898
3271
  for (const candidate of candidates) addCandidateSource(candidate, id);
2899
3272
  }
2900
3273
  for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
@@ -2975,6 +3348,7 @@ function createSourceCandidateStore(options = {}) {
2975
3348
  syncCss,
2976
3349
  merge,
2977
3350
  syncFile,
3351
+ syncCurrentSource,
2978
3352
  syncCurrentFile,
2979
3353
  scanRoot,
2980
3354
  syncInline,
@@ -3182,6 +3556,18 @@ Object.defineProperty(exports, "mergeMarkedUserLayerComponentsCss", {
3182
3556
  return mergeMarkedUserLayerComponentsCss;
3183
3557
  }
3184
3558
  });
3559
+ Object.defineProperty(exports, "normalizeMiniProgramGeneratorCssSource", {
3560
+ enumerable: true,
3561
+ get: function() {
3562
+ return normalizeMiniProgramGeneratorCssSource;
3563
+ }
3564
+ });
3565
+ Object.defineProperty(exports, "normalizeMiniProgramImportShell", {
3566
+ enumerable: true,
3567
+ get: function() {
3568
+ return normalizeMiniProgramImportShell;
3569
+ }
3570
+ });
3185
3571
  Object.defineProperty(exports, "processCachedTask", {
3186
3572
  enumerable: true,
3187
3573
  get: function() {