weapp-tailwindcss 5.1.2 → 5.1.4

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 (75) hide show
  1. package/README.md +1 -1
  2. package/dist/auto-CrJJc5rK.mjs +13 -0
  3. package/dist/bundlers/gulp/index.d.ts +3 -3
  4. package/dist/bundlers/rspack/index.d.ts +20 -0
  5. package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -10
  6. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
  7. package/dist/bundlers/vite/css-memory.d.ts +1 -0
  8. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
  9. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -1
  10. package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +12 -0
  11. package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -0
  12. package/dist/bundlers/vite/processed-css-assets.d.ts +1 -0
  13. package/dist/bundlers/vite/serve-js-transform.d.ts +11 -0
  14. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +4 -1
  15. package/dist/cli.js +8 -8
  16. package/dist/cli.mjs +8 -8
  17. package/dist/{context-C-r8ki7x.mjs → context-Bkpmt3ja.mjs} +62 -36
  18. package/dist/{context-CH4HFZP2.js → context-DCVMkTRj.js} +76 -44
  19. package/dist/core.js +1 -1
  20. package/dist/core.mjs +1 -1
  21. package/dist/css-macro/auto.d.ts +1 -1
  22. package/dist/css-macro/postcss.js +2 -2
  23. package/dist/css-macro.js +3 -3
  24. package/dist/css-macro.mjs +1 -1
  25. package/dist/{defaults-CmFBmxsr.js → defaults-DQhgnnn-.js} +1 -1
  26. package/dist/defaults.js +1 -1
  27. package/dist/framework/index.d.ts +7 -2
  28. package/dist/framework/platform.d.ts +2 -0
  29. package/dist/framework.js +39 -8
  30. package/dist/framework.mjs +33 -6
  31. package/dist/{generator-BsPIaLtV.mjs → generator-24-HgU9F.mjs} +5 -3
  32. package/dist/{generator-B6pUjNdD.js → generator-CilgHtxb.js} +6 -4
  33. package/dist/generator.js +2 -2
  34. package/dist/generator.mjs +2 -2
  35. package/dist/{gulp-CTdcASq8.mjs → gulp-0RsqkF_d.mjs} +4 -4
  36. package/dist/{gulp-BBCeA7ky.js → gulp-Bogfnoki.js} +12 -11
  37. package/dist/gulp.js +1 -1
  38. package/dist/gulp.mjs +1 -1
  39. package/dist/{hmr-timing-BRx-KnBh.mjs → hmr-timing-BRNaz8Od.mjs} +62 -166
  40. package/dist/{hmr-timing-Da1eI8S0.js → hmr-timing-BV6nFPoT.js} +65 -187
  41. package/dist/index.js +9 -4
  42. package/dist/index.mjs +7 -6
  43. package/dist/postcss-html-transform.js +2 -2
  44. package/dist/postcss.js +2 -2
  45. package/dist/postcss.mjs +2 -2
  46. package/dist/presets/shared.d.ts +4 -0
  47. package/dist/presets.js +32 -16
  48. package/dist/presets.mjs +28 -14
  49. package/dist/reset.js +2 -2
  50. package/dist/rspack.d.ts +3 -0
  51. package/dist/rspack.js +68 -0
  52. package/dist/rspack.mjs +62 -0
  53. package/dist/{source-candidate-scan-signature-Dugfplms.mjs → source-candidate-scan-signature-BB1hvW68.mjs} +12 -6
  54. package/dist/{source-candidate-scan-signature-BO6JSskQ.js → source-candidate-scan-signature-CaDT0gkj.js} +16 -9
  55. package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +2 -0
  56. package/dist/{tailwindcss-B5mRo0-M.mjs → tailwindcss-D0JF0fuZ.mjs} +6 -6
  57. package/dist/{tailwindcss-dbrbY4cd.js → tailwindcss-D2xs4OEu.js} +11 -11
  58. package/dist/{transform-DeqFRp1D.mjs → transform-BP86eSZp.mjs} +19 -19
  59. package/dist/{transform-BLleu_bA.js → transform-CXCQ28Tc.js} +47 -47
  60. package/dist/{utils-BCa37Wqj.js → utils-D3h8j7Mk.js} +2 -2
  61. package/dist/{v4-engine-C3qSwQ-e.mjs → v4-engine-BuuYDXt1.mjs} +58 -118
  62. package/dist/{v4-engine-ON_oSLfO.js → v4-engine-CKtsdKxK.js} +66 -120
  63. package/dist/{vite-CXmUiI9f.mjs → vite-B1SlBmqO.mjs} +436 -73
  64. package/dist/{vite-Da4uEG_u.js → vite-BYgT1ir9.js} +443 -80
  65. package/dist/vite.js +1 -1
  66. package/dist/vite.mjs +1 -1
  67. package/dist/weapp-tw-css-import-rewrite-loader.js +143 -216
  68. package/dist/weapp-tw-runtime-classset-loader.js +2 -2
  69. package/dist/{webpack-CrFZmdo7.mjs → webpack-Bg6pefpb.mjs} +109 -18
  70. package/dist/{webpack-Cwqnznng.js → webpack-khSwkXP5.js} +115 -24
  71. package/dist/webpack.js +1 -1
  72. package/dist/webpack.mjs +1 -1
  73. package/package.json +9 -4
  74. package/dist/auto-Ba6hDrse.mjs +0 -13
  75. /package/dist/{chunk-emK7D4bc.js → rolldown-runtime-emK7D4bc.js} +0 -0
@@ -151,14 +151,14 @@ function parseConfigRequest$1(params) {
151
151
  function isPackageJsonImportRequest$2(request) {
152
152
  return typeof request === "string" && request.startsWith("#");
153
153
  }
154
- function isWeappTailwindcssImportRequest$1(request) {
154
+ function isWeappTailwindcssImportRequest(request) {
155
155
  return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
156
156
  }
157
157
  function isTailwindImportRequest$1(request) {
158
158
  return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
159
159
  }
160
160
  function normalizeTailwindImportRequest$1(request, options = {}) {
161
- if (options.importFallback && isWeappTailwindcssImportRequest$1(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
161
+ if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
162
162
  return request;
163
163
  }
164
164
  function replaceImportRequest$1(params, request, replacement) {
@@ -170,7 +170,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
170
170
  const trimmed = line.trimStart();
171
171
  if (/^@(?:use|forward)\b/.test(trimmed)) {
172
172
  const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
173
- if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest$1(request)) {
173
+ if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
174
174
  const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
175
175
  return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
176
176
  }
@@ -178,7 +178,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
178
178
  }
179
179
  if (!options.importFallback || !trimmed.startsWith("@import")) return line;
180
180
  const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
181
- if (!request || !isWeappTailwindcssImportRequest$1(request)) return line;
181
+ if (!request || !isWeappTailwindcssImportRequest(request)) return line;
182
182
  return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
183
183
  }
184
184
  function extractTailwindDirectiveLines(rawSource, options = {}) {
@@ -298,7 +298,7 @@ function extractConfigRequestFromSource(rawSource) {
298
298
  }
299
299
  //#endregion
300
300
  //#region src/bundlers/shared/generator-css/directives.ts
301
- const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
301
+ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
302
302
  "config",
303
303
  "custom-variant",
304
304
  "layer",
@@ -310,32 +310,18 @@ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
310
310
  "utility",
311
311
  "variant"
312
312
  ]);
313
- const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
314
- "config",
315
- "custom-variant",
316
- "plugin",
317
- "source",
318
- "tailwind",
319
- "theme",
320
- "utility",
321
- "variant"
322
- ]);
323
313
  const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
324
314
  function parseImportRequest(params) {
325
- return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
315
+ return (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(params);
326
316
  }
327
317
  function parseConfigRequest(params) {
328
- return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
318
+ return (0, _weapp_tailwindcss_postcss.parseTailwindCssConfigRequest)(params);
329
319
  }
330
320
  function isPackageJsonImportRequest$1(request) {
331
- return typeof request === "string" && request.startsWith("#");
332
- }
333
- function isWeappTailwindcssImportRequest(request) {
334
- return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
321
+ return (0, _weapp_tailwindcss_postcss.isTailwindCssPackageJsonImportRequest)(request);
335
322
  }
336
323
  function normalizeTailwindImportRequest(request, options = {}) {
337
- if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
338
- return request;
324
+ return (0, _weapp_tailwindcss_postcss.normalizeTailwindCssImportRequest)(request, options);
339
325
  }
340
326
  function replaceImportRequest(params, request, replacement) {
341
327
  const index = params.indexOf(request);
@@ -391,12 +377,11 @@ function normalizeTailwindSourceDirectives(rawSource, options = {}) {
391
377
  }
392
378
  }
393
379
  function isTailwindImportRequest(request) {
394
- return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
380
+ const normalized = normalizeTailwindImportRequest(request);
381
+ return normalized === "tailwindcss" || normalized === "tailwindcss4" || normalized?.startsWith("tailwindcss/") === true || normalized?.startsWith("tailwindcss4/") === true;
395
382
  }
396
383
  function isTailwindImportAtRule(node, options = {}) {
397
- if (node.name === "tailwind") return true;
398
- if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
399
- return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
384
+ return (0, _weapp_tailwindcss_postcss.isTailwindCssImportAtRule)(node, options);
400
385
  }
401
386
  function isTailwindSourceDirective(node, options = {}) {
402
387
  if (node.type !== "atrule") return false;
@@ -410,10 +395,18 @@ function hasGeneratedCssArtifacts(rawSource) {
410
395
  return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
411
396
  }
412
397
  function isTailwindGenerationDirective(node, options = {}) {
413
- if (node.type !== "atrule") return false;
414
- const atRule = node;
415
- const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
416
- return isTailwindImportAtRule(atRule, options) || isPackageJsonImportRequest$1(request) || atRule.name === "apply" || !options.ignoreLayer && atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
398
+ return (0, _weapp_tailwindcss_postcss.isTailwindCssGenerationDirective)(node, options);
399
+ }
400
+ function analyzeParseableTailwindDirectives(rawSource, options = {}) {
401
+ try {
402
+ const ignoreLayer = options.ignoreLayer ?? hasGeneratedCssArtifacts(rawSource);
403
+ return (0, _weapp_tailwindcss_postcss.analyzeTailwindCssDirectives)(_weapp_tailwindcss_postcss.postcss.parse(rawSource), {
404
+ ...options,
405
+ ignoreLayer
406
+ });
407
+ } catch {
408
+ return;
409
+ }
417
410
  }
418
411
  function removeTailwindSourceDirectives(rawSource, options = {}) {
419
412
  try {
@@ -433,56 +426,19 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
433
426
  }
434
427
  }
435
428
  function hasTailwindSourceDirectives(rawSource, options = {}) {
436
- try {
437
- if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
438
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
439
- let found = false;
440
- const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
441
- root.walk((node) => {
442
- if (isTailwindGenerationDirective(node, {
443
- ...options,
444
- ignoreLayer
445
- })) {
446
- found = true;
447
- return false;
448
- }
449
- });
450
- return found;
451
- } catch {
452
- return extractTailwindDirectiveLines(rawSource, options).length > 0;
453
- }
429
+ if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
430
+ return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindSourceDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
454
431
  }
455
432
  function hasTailwindRootDirectives(rawSource, options = {}) {
456
433
  if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
457
- try {
458
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
459
- let found = false;
460
- root.walkAtRules((node) => {
461
- const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
462
- if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest$1(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
463
- found = true;
464
- return false;
465
- }
466
- });
467
- return found;
468
- } catch {
469
- return extractTailwindDirectiveLines(rawSource, options).length > 0;
470
- }
434
+ return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindRootDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
471
435
  }
472
436
  function hasTailwindApplyDirective(rawSource) {
473
437
  if (!rawSource.includes("@apply")) return false;
474
- try {
475
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
476
- let found = false;
477
- root.walkAtRules("apply", () => {
478
- found = true;
479
- return false;
480
- });
481
- return found;
482
- } catch {
483
- const fallback = extractTailwindSourceForPostcssFallback(rawSource);
484
- return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
485
- }
438
+ const analysis = analyzeParseableTailwindDirectives(rawSource);
439
+ if (analysis) return analysis.hasTailwindApplyDirective;
440
+ const fallback = extractTailwindSourceForPostcssFallback(rawSource);
441
+ return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
486
442
  }
487
443
  function resolveCssEntrySource(rawSource, base, options = {}) {
488
444
  try {
@@ -598,6 +554,15 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
598
554
  return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
599
555
  }
600
556
  //#endregion
557
+ //#region src/tailwindcss/v4-engine/css-macro-source.ts
558
+ function resolveCssMacroTailwindV4Source(source) {
559
+ const css = (0, _weapp_tailwindcss_postcss.transformCssMacroTailwindV4Source)(source.css);
560
+ return css === source.css ? source : {
561
+ ...source,
562
+ css
563
+ };
564
+ }
565
+ //#endregion
601
566
  //#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
602
567
  const TAILWIND_V4_COLOR_STEPS = [
603
568
  "50",
@@ -1662,7 +1627,7 @@ function createIncrementalStyleOptions(styleOptions) {
1662
1627
  };
1663
1628
  }
1664
1629
  function resolveStyleOptions(source, options) {
1665
- return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Directive)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
1630
+ return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Source)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
1666
1631
  }
1667
1632
  function collectCustomPropertyValues(css) {
1668
1633
  const values = /* @__PURE__ */ new Map();
@@ -1715,11 +1680,11 @@ function createTailwindV4Engine(source) {
1715
1680
  async function generateOnce(generateSource, options = {}) {
1716
1681
  const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
1717
1682
  const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
1718
- const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(generateSource, target));
1683
+ const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target));
1719
1684
  const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
1720
1685
  const delegateSourceScan = shouldDelegateWebSourceScanToTailwind(target, resolvedScanSources);
1721
1686
  const filesystemCandidates = !delegateSourceScan && Array.isArray(resolvedScanSources) ? new Set(await (0, _tailwindcss_mangle_engine.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
1722
- const normalizedCandidates = normalizeTargetRpxLengthCandidates(resolveTargetCandidates(new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target), target, resolvedStyleOptions);
1687
+ const normalizedCandidates = normalizeTargetRpxLengthCandidates(resolveTargetCandidates(/* @__PURE__ */ new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target), target, resolvedStyleOptions);
1723
1688
  const result = await engine.generate(omitUndefined({
1724
1689
  scanSources: delegateSourceScan ? resolvedScanSources : false,
1725
1690
  ...patchOptions,
@@ -1738,13 +1703,14 @@ function createTailwindV4Engine(source) {
1738
1703
  }
1739
1704
  async function generateWithIncrementalCache(options = {}) {
1740
1705
  const target = options.target ?? "weapp";
1741
- const compatibleSource = createCompatibleSource(source, target);
1706
+ const cssMacroSource = resolveCssMacroTailwindV4Source(source);
1707
+ const compatibleSource = createCompatibleSource(cssMacroSource, target);
1742
1708
  const requestedCandidates = resolveTargetCandidates(options.candidates, target);
1743
1709
  const styleOptions = resolveStyleOptions(source, options.styleOptions);
1744
- if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
1710
+ if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(cssMacroSource, options);
1745
1711
  const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
1746
1712
  if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1747
- const generated = await generateOnce(source, options);
1713
+ const generated = await generateOnce(cssMacroSource, options);
1748
1714
  if (!seedIncrementalGenerateCache({
1749
1715
  compatibleSource,
1750
1716
  generated,
@@ -1757,7 +1723,7 @@ function createTailwindV4Engine(source) {
1757
1723
  const cached = incrementalGenerateCache.get(cacheKey);
1758
1724
  if (cached) {
1759
1725
  if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1760
- const generated = await generateOnce(source, options);
1726
+ const generated = await generateOnce(cssMacroSource, options);
1761
1727
  if (!seedIncrementalGenerateCache({
1762
1728
  compatibleSource,
1763
1729
  generated,
@@ -1781,7 +1747,7 @@ function createTailwindV4Engine(source) {
1781
1747
  target: cached.target
1782
1748
  };
1783
1749
  if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1784
- const generated = await generateOnce(source, options);
1750
+ const generated = await generateOnce(cssMacroSource, options);
1785
1751
  if (!seedIncrementalGenerateCache({
1786
1752
  compatibleSource,
1787
1753
  generated,
@@ -1831,7 +1797,7 @@ function createTailwindV4Engine(source) {
1831
1797
  });
1832
1798
  }
1833
1799
  return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1834
- const generated = await generateOnce(source, options);
1800
+ const generated = await generateOnce(cssMacroSource, options);
1835
1801
  seedIncrementalGenerateCache({
1836
1802
  compatibleSource,
1837
1803
  generated,
@@ -1967,7 +1933,7 @@ function quoteCssImportSpecifier(specifier, quote = "\"") {
1967
1933
  return `${quote}${specifier.replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`)}${quote}`;
1968
1934
  }
1969
1935
  function createTailwindV4CssImportSpecifierSet(packageName) {
1970
- const specifiers = new Set(["tailwindcss"]);
1936
+ const specifiers = /* @__PURE__ */ new Set(["tailwindcss"]);
1971
1937
  if (packageName && isBarePackageSpecifier(packageName)) specifiers.add(packageName);
1972
1938
  return specifiers;
1973
1939
  }
@@ -2140,6 +2106,29 @@ function createMiniProgramRuntimeBranch(base) {
2140
2106
  }
2141
2107
  //#endregion
2142
2108
  //#region src/framework/index.ts
2109
+ const MINI_PROGRAM_PLATFORMS = /* @__PURE__ */ new Set([
2110
+ "alipay",
2111
+ "baidu",
2112
+ "jd",
2113
+ "qq",
2114
+ "swan",
2115
+ "tt",
2116
+ "weapp",
2117
+ "wechat",
2118
+ "wx"
2119
+ ]);
2120
+ function getProcessEnv() {
2121
+ return {
2122
+ MPX_CLI_MODE: node_process.default.env["MPX_CLI_MODE"],
2123
+ MPX_CURRENT_TARGET_MODE: node_process.default.env["MPX_CURRENT_TARGET_MODE"],
2124
+ NODE_PATH: node_process.default.env["NODE_PATH"],
2125
+ TARO_ENV: node_process.default.env["TARO_ENV"],
2126
+ UNI_PLATFORM: node_process.default.env["UNI_PLATFORM"],
2127
+ UNI_UTS_PLATFORM: node_process.default.env["UNI_UTS_PLATFORM"],
2128
+ WEAPP_TAILWINDCSS_TARGET: node_process.default.env["WEAPP_TAILWINDCSS_TARGET"],
2129
+ WEAPP_TW_TARGET: node_process.default.env["WEAPP_TW_TARGET"]
2130
+ };
2131
+ }
2143
2132
  function normalizePlatform(value) {
2144
2133
  return value?.trim().toLowerCase() || void 0;
2145
2134
  }
@@ -2155,13 +2144,16 @@ function resolvePlatformInfo(value) {
2155
2144
  isAppAndroid,
2156
2145
  isAppHarmony,
2157
2146
  isAppIos,
2158
- isMp: normalized?.startsWith("mp-") === true,
2147
+ isMp: normalized?.startsWith("mp-") === true || (normalized ? MINI_PROGRAM_PLATFORMS.has(normalized) : false),
2159
2148
  isWeb: normalized?.startsWith("web") === true || normalized === "h5"
2160
2149
  };
2161
2150
  }
2162
- function resolveUniUtsPlatform$1(value) {
2151
+ function resolvePlatform(value) {
2163
2152
  return resolvePlatformInfo(value);
2164
2153
  }
2154
+ function resolveUniUtsPlatform$1(value = getProcessEnv().UNI_UTS_PLATFORM) {
2155
+ return resolvePlatform(value);
2156
+ }
2165
2157
  //#endregion
2166
2158
  //#region src/utils/uni-platform.ts
2167
2159
  function resolveUniUtsPlatform(value = node_process.default.env["UNI_UTS_PLATFORM"]) {
@@ -2236,10 +2228,12 @@ function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
2236
2228
  ...context,
2237
2229
  generatorTarget: target
2238
2230
  });
2231
+ const hasExplicitTarget = options !== void 0 && Object.hasOwn(options, "target");
2232
+ const webCompat = options?.webCompat ?? (!hasExplicitTarget && branch.isWeb ? true : void 0);
2239
2233
  if (options == null) return {
2240
2234
  target,
2241
2235
  branch,
2242
- webCompat: void 0,
2236
+ webCompat,
2243
2237
  importFallback: false,
2244
2238
  bareArbitraryValues: void 0
2245
2239
  };
@@ -2248,7 +2242,7 @@ function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
2248
2242
  branch,
2249
2243
  config: options.config,
2250
2244
  styleOptions: options.styleOptions,
2251
- webCompat: options.webCompat,
2245
+ webCompat,
2252
2246
  importFallback: options.importFallback ?? false,
2253
2247
  bareArbitraryValues: options.bareArbitraryValues
2254
2248
  };
@@ -2403,8 +2397,10 @@ function hasMiniProgramTailwindV4PreflightReset(css) {
2403
2397
  }
2404
2398
  function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
2405
2399
  if (target !== "weapp") return css;
2400
+ const injectPreflight = options.injectPreflight !== false && !hasMiniProgramTailwindV4PreflightReset(css);
2406
2401
  return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
2407
- cssPreflight: options.injectPreflight !== false && !hasMiniProgramTailwindV4PreflightReset(css) ? cssPreflight : void 0,
2402
+ cssPreflight: cssPreflight === false ? false : injectPreflight ? cssPreflight : void 0,
2403
+ cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
2408
2404
  isTailwindcssV4: true,
2409
2405
  tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
2410
2406
  });
@@ -2416,11 +2412,11 @@ function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
2416
2412
  }
2417
2413
  function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
2418
2414
  if (options.isolateCssSource) {
2419
- if (options.matchedCssSourceFile) return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
2420
- return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
2415
+ if (options.matchedCssSourceFile) return /* @__PURE__ */ new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
2416
+ return /* @__PURE__ */ new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
2421
2417
  }
2422
2418
  if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk) return scopedRuntime;
2423
- return new Set([...scopedRuntime, ...runtime]);
2419
+ return /* @__PURE__ */ new Set([...scopedRuntime, ...runtime]);
2424
2420
  }
2425
2421
  function shouldIsolateScopedCssSource(_majorVersion, source, sourceEntries, options) {
2426
2422
  if (options.target !== "weapp") return false;
@@ -2482,7 +2478,7 @@ function shouldUseGeneratorForCurrentCss(_majorVersion, cssHandlerOptions, optio
2482
2478
  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;
2483
2479
  }
2484
2480
  function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
2485
- return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
2481
+ return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? /* @__PURE__ */ new Set([...runtime, ...currentCssCandidates]) : runtime;
2486
2482
  }
2487
2483
  function mergeGeneratorResults(generatedResults) {
2488
2484
  const firstGenerated = generatedResults[0];
@@ -2657,14 +2653,14 @@ function decodeUnicode2(input) {
2657
2653
  }
2658
2654
  //#endregion
2659
2655
  //#region src/js/class-context.ts
2660
- const CLASS_LIKE_KEYWORDS = new Set([
2656
+ const CLASS_LIKE_KEYWORDS = /* @__PURE__ */ new Set([
2661
2657
  "class",
2662
2658
  "classname",
2663
2659
  "hoverclass",
2664
2660
  "virtualhostclass",
2665
2661
  "rootclass"
2666
2662
  ]);
2667
- const CLASS_HELPER_IDENTIFIERS = new Set([
2663
+ const CLASS_HELPER_IDENTIFIERS = /* @__PURE__ */ new Set([
2668
2664
  "cn",
2669
2665
  "clsx",
2670
2666
  "classnames",
@@ -2920,7 +2916,7 @@ function replaceHandleValue(path, options) {
2920
2916
  Object.freeze({ wrapExpression: true });
2921
2917
  //#endregion
2922
2918
  //#region src/wxml/whitespace.ts
2923
- const WHITESPACE_CODES = new Set([
2919
+ const WHITESPACE_CODES = /* @__PURE__ */ new Set([
2924
2920
  9,
2925
2921
  10,
2926
2922
  11,
@@ -3062,7 +3058,7 @@ new Tokenizer();
3062
3058
  //#endregion
3063
3059
  //#region src/bundlers/shared/generator-css/legacy-selectors.ts
3064
3060
  const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
3065
- const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
3061
+ const MINI_PROGRAM_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
3066
3062
  ":host",
3067
3063
  "page",
3068
3064
  ".tw-root",
@@ -3125,7 +3121,7 @@ function escapeCompatSelectorClasses(selector) {
3125
3121
  function normalizeCompatSelectors(selector) {
3126
3122
  const normalized = normalizeCompatSelector(selector);
3127
3123
  if (!normalized) return [];
3128
- const selectors = new Set([normalized]);
3124
+ const selectors = /* @__PURE__ */ new Set([normalized]);
3129
3125
  const escaped = normalizeCompatSelector(escapeCompatSelectorClasses(normalized));
3130
3126
  if (escaped) selectors.add(escaped);
3131
3127
  return [...selectors];
@@ -3806,7 +3802,7 @@ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {
3806
3802
  for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) try {
3807
3803
  const source = sourceOptions.sourceFile && node_path.default.resolve(sourceOptions.sourceFile) === node_path.default.resolve(sourceFile) && typeof sourceOptions.sourceCss === "string" ? sourceOptions.sourceCss : (0, node_fs.existsSync)(sourceFile) ? (0, node_fs.readFileSync)(sourceFile, "utf8") : void 0;
3808
3804
  if (source === void 0) continue;
3809
- const directiveSources = extractStyleDirectiveSourcesDeep(source, sourceFile, new Set([node_path.default.resolve(sourceFile)]));
3805
+ const directiveSources = extractStyleDirectiveSourcesDeep(source, sourceFile, /* @__PURE__ */ new Set([node_path.default.resolve(sourceFile)]));
3810
3806
  for (const styleSource of directiveSources) {
3811
3807
  const cssEntrySource = resolveCssEntrySource(styleSource.source, node_path.default.dirname(styleSource.file), resolveOptions);
3812
3808
  if (cssEntrySource) return {
@@ -4013,7 +4009,8 @@ function createSingleTailwindV4SourceOptions(sourceOptions, options) {
4013
4009
  baseFallbacks: sourceOptions.baseFallbacks,
4014
4010
  packageName: sourceOptions.packageName,
4015
4011
  base: options.base,
4016
- css: options.css
4012
+ css: options.css,
4013
+ cssEntries: options.cssEntries
4017
4014
  });
4018
4015
  }
4019
4016
  async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
@@ -4104,7 +4101,7 @@ function hydrateTailwindV4CssSource(cssSource) {
4104
4101
  file,
4105
4102
  base: cssSource.base ?? node_path.default.dirname(file),
4106
4103
  css: (0, node_fs.readFileSync)(file, "utf8"),
4107
- dependencies: [...new Set([...cssSource.dependencies ?? [], file])]
4104
+ dependencies: [.../* @__PURE__ */ new Set([...cssSource.dependencies ?? [], file])]
4108
4105
  };
4109
4106
  }
4110
4107
  function normalizeTailwindV4CssSourceConfigs(sourceOptions) {
@@ -4220,7 +4217,8 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
4220
4217
  const css = createTailwindV4SourceReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
4221
4218
  return withMatchedSourceSideMetadata(await resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
4222
4219
  base: resolvedEntrySource.base,
4223
- css
4220
+ css,
4221
+ cssEntries: [resolvedEntrySource.file]
4224
4222
  })), resolvedEntrySource);
4225
4223
  }
4226
4224
  async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
@@ -4251,6 +4249,8 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
4251
4249
  }
4252
4250
  const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions?.cssEntries?.length ?? 0) <= 1;
4253
4251
  const sourceSideEntrySource = normalizedSourceOptions && (shouldPreferSourceSideEntry || normalizedSourceOptions.sourceFile !== void 0) && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
4252
+ const sourceSideCssSource = sourceSideEntrySource?.file && normalizedSourceOptions.cssEntries?.some((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(sourceSideEntrySource.file)) ? await resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file) : void 0;
4253
+ if (sourceSideCssSource) return sourceSideCssSource;
4254
4254
  const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
4255
4255
  const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions) : void 0;
4256
4256
  const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
@@ -4274,7 +4274,6 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
4274
4274
  css: prependConfigDirective(source.css, generatorOptions.config)
4275
4275
  } : source;
4276
4276
  }
4277
- if (sourceSideEntrySource && normalizedSourceOptions) return resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file);
4278
4277
  const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, omitUndefined({
4279
4278
  ...resolvedSourceOptions ?? {},
4280
4279
  sourceFile: resolvedEntrySource.file ?? resolvedSourceOptions?.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions)
@@ -4374,7 +4373,7 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
4374
4373
  }
4375
4374
  //#endregion
4376
4375
  //#region src/bundlers/shared/generator-css/user-css.ts
4377
- const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
4376
+ const TAILWIND_V4_GENERATOR_AT_RULES = /* @__PURE__ */ new Set([
4378
4377
  "config",
4379
4378
  "custom-variant",
4380
4379
  "plugin",
@@ -5129,96 +5128,6 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
5129
5128
  }
5130
5129
  }
5131
5130
  //#endregion
5132
- //#region src/bundlers/shared/generator-css/local-imports.ts
5133
- const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
5134
- function createCssSourceOrderAppend(base, extra) {
5135
- if (!base) return extra;
5136
- if (!extra) return base;
5137
- if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
5138
- return `${base}\n${extra}`;
5139
- }
5140
- function isLocalImportRequest(request) {
5141
- return request.length > 0 && !request.startsWith("#") && !request.startsWith("tailwindcss") && !request.startsWith("weapp-tailwindcss") && !request.startsWith("data:") && !REMOTE_IMPORT_RE.test(request);
5142
- }
5143
- function isPureLocalCssImportWrapper(css) {
5144
- let hasImport = false;
5145
- try {
5146
- const root = _weapp_tailwindcss_postcss.postcss.parse(css);
5147
- for (const node of root.nodes) {
5148
- if (node.type === "comment") continue;
5149
- if (node.type !== "atrule" || node.name !== "import") return false;
5150
- const request = parseImportRequest(node.params);
5151
- if (!request || !isLocalImportRequest(request)) return false;
5152
- hasImport = true;
5153
- }
5154
- } catch {
5155
- return false;
5156
- }
5157
- return hasImport;
5158
- }
5159
- function cleanLocalCssImportWrapperTailwindDirectives(css) {
5160
- let hasLocalImport = false;
5161
- let hasTailwindDirective = false;
5162
- try {
5163
- const root = _weapp_tailwindcss_postcss.postcss.parse(css);
5164
- for (const node of root.nodes) {
5165
- if (node.type === "comment") continue;
5166
- if (node.type === "atrule" && node.name === "import") {
5167
- const request = parseImportRequest(node.params);
5168
- if (!request || !isLocalImportRequest(request)) return;
5169
- hasLocalImport = true;
5170
- continue;
5171
- }
5172
- if (node.type === "atrule" && node.name === "source") {
5173
- hasTailwindDirective = true;
5174
- continue;
5175
- }
5176
- return;
5177
- }
5178
- } catch {
5179
- return;
5180
- }
5181
- return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(removeTailwindSourceDirectives(css)) : void 0;
5182
- }
5183
- function prefixLocalCssImportsWithWebpackIgnore(css) {
5184
- try {
5185
- const root = _weapp_tailwindcss_postcss.postcss.parse(css);
5186
- root.walkAtRules("import", (atRule) => {
5187
- const request = parseImportRequest(atRule.params);
5188
- if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
5189
- });
5190
- return root.toString();
5191
- } catch {
5192
- return css;
5193
- }
5194
- }
5195
- function splitLocalCssImports(source) {
5196
- try {
5197
- const root = _weapp_tailwindcss_postcss.postcss.parse(source);
5198
- const importRoot = _weapp_tailwindcss_postcss.postcss.root();
5199
- let changed = false;
5200
- for (const node of [...root.nodes]) {
5201
- if (node.type !== "atrule" || node.name !== "import") continue;
5202
- const request = parseImportRequest(node.params);
5203
- if (!request || !isLocalImportRequest(request)) continue;
5204
- importRoot.append(node.clone());
5205
- node.remove();
5206
- changed = true;
5207
- }
5208
- const imports = importRoot.nodes.filter((node) => node.type === "atrule" && node.name === "import").map((node) => `@import ${node.params};`).join("\n");
5209
- return changed ? {
5210
- imports,
5211
- source: root.toString()
5212
- } : void 0;
5213
- } catch {
5214
- return;
5215
- }
5216
- }
5217
- function restoreLocalCssImports(css, imports) {
5218
- if (!imports?.trim()) return css;
5219
- return createCssSourceOrderAppend(imports, css);
5220
- }
5221
- //#endregion
5222
5131
  //#region src/bundlers/shared/generator-css/user-layer-order.ts
5223
5132
  const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
5224
5133
  const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
@@ -5325,6 +5234,23 @@ function intersectCandidateSets(left, right) {
5325
5234
  for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
5326
5235
  return matched;
5327
5236
  }
5237
+ function parseCssSourceRoot(rawSource) {
5238
+ try {
5239
+ return _weapp_tailwindcss_postcss.postcss.parse(rawSource);
5240
+ } catch {
5241
+ return;
5242
+ }
5243
+ }
5244
+ function cleanLocalCssImportWrapperFromParsedRoot(rawSource, root) {
5245
+ if (!root) return (0, _weapp_tailwindcss_postcss.cleanLocalCssImportWrapperTailwindDirectives)(rawSource);
5246
+ return (0, _weapp_tailwindcss_postcss.cleanLocalCssImportWrapperTailwindDirectivesRoot)(root) ? root.toString() : void 0;
5247
+ }
5248
+ function isPureLocalCssImportWrapperFromParsedRoot(rawSource, root) {
5249
+ return root ? (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapperRoot)(root) : (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(rawSource);
5250
+ }
5251
+ function splitLocalCssImportsFromParsedRoot(rawSource, root) {
5252
+ return root ? (0, _weapp_tailwindcss_postcss.splitLocalCssImportsRoot)(root) : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawSource);
5253
+ }
5328
5254
  function collectCssRuleIdentityMarkers(source) {
5329
5255
  const markers = /* @__PURE__ */ new Set();
5330
5256
  try {
@@ -5373,20 +5299,8 @@ async function generateCssByGenerator(options) {
5373
5299
  const majorVersion = runtimeState.tailwindRuntime.majorVersion;
5374
5300
  if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
5375
5301
  const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
5376
- const localImportParts = splitLocalCssImports(effectiveRawSource);
5377
- const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
5378
- const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
5379
- return finalizeWebGeneratorCss(restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
5380
- };
5381
- const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
5382
- const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
5383
- const userSource = splitLocalCssImports(rawUserSource)?.source ?? rawUserSource;
5384
- const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
5385
- const generatedUserCssOrderSource = hasTailwindGeneratedCss(userSource) ? splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
5386
- const generatedUserCssRawSource = generatedUserCssOrderSource ? createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
5387
- const userCssOrderSource = GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
5388
- const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(generatedUserCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
5389
- const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
5302
+ const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
5303
+ const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
5390
5304
  if (cleanedLocalImportWrapper !== void 0) return {
5391
5305
  css: shouldUseMiniProgramCssBranch(generatorBranch) ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
5392
5306
  classSet: /* @__PURE__ */ new Set(),
@@ -5398,7 +5312,20 @@ async function generateCssByGenerator(options) {
5398
5312
  majorVersion
5399
5313
  }
5400
5314
  };
5401
- if (isPureLocalCssImportWrapper(effectiveRawSource)) return;
5315
+ if (isPureLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot)) return;
5316
+ const localImportParts = splitLocalCssImportsFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
5317
+ const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
5318
+ const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
5319
+ return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
5320
+ };
5321
+ const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
5322
+ const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
5323
+ const userSource = (rawUserSource === generatorRawSource ? void 0 : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawUserSource))?.source ?? rawUserSource;
5324
+ const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
5325
+ const generatedUserCssOrderSource = hasTailwindGeneratedCss(userSource) ? splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
5326
+ const generatedUserCssRawSource = generatedUserCssOrderSource ? createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
5327
+ const userCssOrderSource = GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
5328
+ const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(generatedUserCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
5402
5329
  const hasGeneratedCss = hasTailwindGeneratedCss(generatorRawSource);
5403
5330
  const hasSourceDirectives = hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
5404
5331
  const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(generatorRawSource);
@@ -5466,7 +5393,7 @@ async function generateCssByGenerator(options) {
5466
5393
  debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
5467
5394
  if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
5468
5395
  const incrementalCss = stripTailwindBanner(generated.incrementalCss);
5469
- const finalCss = finalizeWebGeneratorCss(restoreLocalCssImports(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
5396
+ const finalCss = finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
5470
5397
  injectPreflight: false,
5471
5398
  styleOptions: generatorStyleOptions
5472
5399
  })) : options.previousCss, localImports), generated.target, generatorOptions.webCompat);
@@ -6455,7 +6382,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
6455
6382
  }
6456
6383
  if (item === singleCanonicalIgnoreName) continue;
6457
6384
  if (!canonicalIgnoreNames) {
6458
- canonicalIgnoreNames = new Set([singleCanonicalIgnoreName, item]);
6385
+ canonicalIgnoreNames = /* @__PURE__ */ new Set([singleCanonicalIgnoreName, item]);
6459
6386
  continue;
6460
6387
  }
6461
6388
  canonicalIgnoreNames.add(item);
@@ -6726,7 +6653,7 @@ function jsHandler(rawSource, options) {
6726
6653
  defaultEvalHandler = jsHandler;
6727
6654
  //#endregion
6728
6655
  //#region src/tailwindcss/candidates.ts
6729
- const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
6656
+ const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = /* @__PURE__ */ new Set([
6730
6657
  "js",
6731
6658
  "jsx",
6732
6659
  "mjs",
@@ -7018,7 +6945,7 @@ function createSourceCandidateStore(options = {}) {
7018
6945
  }
7019
6946
  function recompute(id) {
7020
6947
  const normalizedId = cleanUrl(id);
7021
- replaceFinal(normalizedId, new Set([
6948
+ replaceFinal(normalizedId, /* @__PURE__ */ new Set([
7022
6949
  ...scanCandidatesById.get(normalizedId) ?? [],
7023
6950
  ...transformCandidatesById.get(normalizedId) ?? [],
7024
6951
  ...cssCandidatesById.get(normalizedId) ?? []
@@ -7049,7 +6976,7 @@ function createSourceCandidateStore(options = {}) {
7049
6976
  return mergeSourcesByPriority().entries();
7050
6977
  }
7051
6978
  function values() {
7052
- const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
6979
+ const values = /* @__PURE__ */ new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
7053
6980
  for (const candidate of inlineExcludedCandidates) values.delete(candidate);
7054
6981
  return values;
7055
6982
  }
@@ -7153,7 +7080,7 @@ function createSourceCandidateStore(options = {}) {
7153
7080
  for (const [id, source] of snapshot.scanSourceById ?? snapshot.sourceById ?? []) scanSourceById.set(id, source);
7154
7081
  for (const [id, source] of snapshot.transformSourceById ?? []) transformSourceById.set(id, source);
7155
7082
  for (const [id, source] of snapshot.cssSourceById ?? []) cssSourceById.set(id, source);
7156
- const ids = new Set([
7083
+ const ids = /* @__PURE__ */ new Set([
7157
7084
  ...scanCandidatesById.keys(),
7158
7085
  ...transformCandidatesById.keys(),
7159
7086
  ...cssCandidatesById.keys()