weapp-tailwindcss 5.0.0-next.30 → 5.0.0-next.32

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 (47) hide show
  1. package/dist/auto-DEHRmEAx.mjs +200 -0
  2. package/dist/auto-dPpsm6FB.js +238 -0
  3. package/dist/{bundle-state-Bi-cQua6.mjs → bundle-state-BIsgsoNW.mjs} +2 -2
  4. package/dist/{bundle-state-Ct_8GcSR.js → bundle-state-C4ib5xPG.js} +3 -3
  5. package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
  6. package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
  7. package/dist/core.js +1 -1
  8. package/dist/core.mjs +1 -1
  9. package/dist/css-macro/auto.d.ts +2 -1
  10. package/dist/css-macro.js +1 -1
  11. package/dist/css-macro.mjs +1 -1
  12. package/dist/{generator-CrU-Ghc1.js → generator-BEXaaUzP.js} +1 -1
  13. package/dist/{generator-Qw-tZ0Z2.mjs → generator-CpsHA4Wd.mjs} +1 -1
  14. package/dist/generator.js +2 -2
  15. package/dist/generator.mjs +2 -2
  16. package/dist/gulp.js +7 -7
  17. package/dist/gulp.mjs +6 -6
  18. package/dist/{incremental-runtime-class-set-BxvZONkv.js → incremental-runtime-class-set-CLP1Qv8F.js} +266 -11
  19. package/dist/{incremental-runtime-class-set-BdZHkoTs.mjs → incremental-runtime-class-set-D2fsgk5t.mjs} +260 -11
  20. package/dist/index.js +4 -4
  21. package/dist/index.mjs +4 -4
  22. package/dist/{postcss-C6zOQqlL.mjs → postcss-BvkdIZr8.mjs} +3 -3
  23. package/dist/{postcss-DAWf9D3C.js → postcss-DN7IQzYb.js} +4 -4
  24. package/dist/postcss.js +1 -1
  25. package/dist/postcss.mjs +1 -1
  26. package/dist/{precheck-D7gJSmJz.js → precheck-CQeqnfo5.js} +4 -4
  27. package/dist/{precheck-D7K12zeX.mjs → precheck-nITnYBDn.mjs} +3 -3
  28. package/dist/presets.js +4 -4
  29. package/dist/presets.mjs +3 -3
  30. package/dist/{source-candidates-DNM8iwXW.js → source-candidates-7Q-kTOSb.js} +1 -1
  31. package/dist/{source-candidates-CX2ozpKM.mjs → source-candidates-_x8bq0Mz.mjs} +1 -1
  32. package/dist/{tailwindcss-B-e2RiXr.js → tailwindcss-Cl7hUlYV.js} +3 -3
  33. package/dist/{tailwindcss-C7dJHZ0G.mjs → tailwindcss-udhXxMX9.mjs} +2 -2
  34. package/dist/{v3-engine-DcvCCHfs.mjs → v3-engine-C_KeUQG3.mjs} +6 -6
  35. package/dist/{v3-engine-CHItlVq5.js → v3-engine-DwY4Fixu.js} +7 -7
  36. package/dist/{vite-rmL1rsA_.mjs → vite-BAHjBu8j.mjs} +17 -10
  37. package/dist/{vite-C65DdWEj.js → vite-CYkkJZ3Q.js} +18 -11
  38. package/dist/vite.js +1 -1
  39. package/dist/vite.mjs +1 -1
  40. package/dist/weapp-tw-css-import-rewrite-loader.js +328 -12
  41. package/dist/{webpack-CqGvjvSQ.js → webpack-CPwDaKy3.js} +8 -8
  42. package/dist/{webpack-BU2Er4qg.mjs → webpack-xxmiRxcy.mjs} +7 -7
  43. package/dist/webpack.js +1 -1
  44. package/dist/webpack.mjs +1 -1
  45. package/package.json +4 -4
  46. package/dist/auto-TH1jG2UW.js +0 -115
  47. package/dist/auto-XyKTOP7B.mjs +0 -78
@@ -1,14 +1,14 @@
1
1
  const require_chunk = require("./chunk-C5U5_Hdc.js");
2
- const require_v3_engine = require("./v3-engine-CHItlVq5.js");
3
- const require_generator = require("./generator-CrU-Ghc1.js");
4
- const require_precheck = require("./precheck-D7gJSmJz.js");
2
+ const require_v3_engine = require("./v3-engine-DwY4Fixu.js");
3
+ const require_generator = require("./generator-BEXaaUzP.js");
4
+ const require_precheck = require("./precheck-CQeqnfo5.js");
5
5
  let node_fs = require("node:fs");
6
6
  let postcss = require("postcss");
7
7
  postcss = require_chunk.__toESM(postcss);
8
- let node_path = require("node:path");
9
- node_path = require_chunk.__toESM(node_path);
10
8
  let node_process = require("node:process");
11
9
  node_process = require_chunk.__toESM(node_process);
10
+ let node_path = require("node:path");
11
+ node_path = require_chunk.__toESM(node_path);
12
12
  let tailwindcss_patch = require("tailwindcss-patch");
13
13
  let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
14
14
  //#region src/bundlers/shared/generator-css/markers.ts
@@ -108,6 +108,11 @@ const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?
108
108
  const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
109
109
  const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
110
110
  const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant)\b[\s\S]*\{/;
111
+ const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
112
+ ["tailwindcss/base", "base"],
113
+ ["tailwindcss/components", "components"],
114
+ ["tailwindcss/utilities", "utilities"]
115
+ ]);
111
116
  function parseImportRequest(params) {
112
117
  return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
113
118
  }
@@ -287,6 +292,24 @@ function hasPreprocessorOnlySyntax(rawSource) {
287
292
  function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
288
293
  return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
289
294
  }
295
+ function normalizeTailwindV3CssEntrySource(rawSource) {
296
+ try {
297
+ const root = postcss.default.parse(rawSource);
298
+ let changed = false;
299
+ root.walkAtRules("import", (node) => {
300
+ const layer = TAILWIND_V3_SUBPATH_IMPORT_LAYERS.get(parseImportRequest(node.params) ?? "");
301
+ if (!layer) return;
302
+ node.replaceWith(postcss.default.atRule({
303
+ name: "tailwind",
304
+ params: layer
305
+ }));
306
+ changed = true;
307
+ });
308
+ return changed ? root.toString() : rawSource;
309
+ } catch {
310
+ return rawSource;
311
+ }
312
+ }
290
313
  function normalizeTailwindSourceDirectives(rawSource, options = {}) {
291
314
  if (!options.importFallback) return rawSource;
292
315
  try {
@@ -1022,14 +1045,14 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
1022
1045
  css: rawSource
1023
1046
  } : void 0;
1024
1047
  const sourceSideEntrySource = canResolveSourceSideCssEntry(file, cssHandlerOptions) ? resolveSourceSideCssEntrySource(file, mergedSourceOptions, { removeConfig: true }) : void 0;
1025
- const resolvedEntrySource = shouldResolveSourceSideCssEntry(rawSource) ? applyEntrySource ?? cssEntrySource ?? sourceSideEntrySource : shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) ? sourceSideEntrySource ?? cssEntrySource : cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource;
1048
+ const resolvedEntrySource = shouldResolveSourceSideCssEntry(rawSource) ? cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource : shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) ? sourceSideEntrySource ?? cssEntrySource : cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource;
1026
1049
  if (!resolvedEntrySource) return generatorOptions?.config ? require_v3_engine.resolveTailwindV3Source(mergedSourceOptions) : require_v3_engine.resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher);
1027
1050
  if (cssEntrySource && !sourceSideEntrySource && !applyEntrySource && !hasTailwindRootDirectives(rawSource, { importFallback: true })) return generatorOptions?.config ? require_v3_engine.resolveTailwindV3Source(mergedSourceOptions) : require_v3_engine.resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher);
1028
1051
  const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, require_v3_engine.omitUndefined(mergedSourceOptions));
1029
1052
  return require_v3_engine.resolveTailwindV3Source({
1030
1053
  ...mergedSourceOptions,
1031
1054
  base: resolvedEntrySource.base,
1032
- css: resolvedEntrySource.css,
1055
+ css: normalizeTailwindV3CssEntrySource(resolvedEntrySource.css),
1033
1056
  ...config ? { config } : {}
1034
1057
  });
1035
1058
  }
@@ -1376,6 +1399,125 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
1376
1399
  }
1377
1400
  }
1378
1401
  //#endregion
1402
+ //#region src/bundlers/shared/generator-css/user-layer-order.ts
1403
+ const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
1404
+ const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
1405
+ const UTILITY_LAYER_INSERTION_RES = [
1406
+ /(^|\n)\.(?:fixed|absolute|relative|sticky|static)\s*\{/,
1407
+ /(^|\n)\.(?:block|inline-block|inline|flex|inline-flex|grid|hidden)\s*\{/,
1408
+ /(^|\n)\.(?:m|mx|my|mt|mr|mb|ml|p|px|py|pt|pr|pb|pl)-/,
1409
+ /(^|\n)\.(?:w|h|min-w|min-h|max-w|max-h)-/,
1410
+ /(^|\n)\.(?:bg|text|border|rounded|shadow|opacity|transition|transform|translate|scale|rotate|gap|items|justify|content)-/
1411
+ ];
1412
+ function appendCss(base, extra) {
1413
+ if (!base) return extra;
1414
+ if (!extra) return base;
1415
+ if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
1416
+ return `${base}\n${extra}`;
1417
+ }
1418
+ function removeFirstCssOccurrence(css, chunk) {
1419
+ const trimmed = chunk.trim();
1420
+ if (!trimmed) return css;
1421
+ const index = css.indexOf(trimmed);
1422
+ if (index === -1) return css;
1423
+ return appendCss(css.slice(0, index).trimEnd(), css.slice(index + trimmed.length).trimStart());
1424
+ }
1425
+ function collectSelectorsFromCss(css) {
1426
+ const selectors = /* @__PURE__ */ new Set();
1427
+ try {
1428
+ postcss.default.parse(css).walkRules((rule) => {
1429
+ for (const selector of rule.selectors ?? [rule.selector]) {
1430
+ const normalized = selector.trim();
1431
+ if (normalized) selectors.add(normalized);
1432
+ }
1433
+ });
1434
+ } catch {}
1435
+ return selectors;
1436
+ }
1437
+ function matchesLayerSelector(selector, layerSelector) {
1438
+ if (selector === layerSelector) return true;
1439
+ if (!selector.startsWith(layerSelector)) return false;
1440
+ const next = selector[layerSelector.length];
1441
+ return next === ":" || next === "[";
1442
+ }
1443
+ function removeCssRulesForSelectors(css, layerCss) {
1444
+ const selectors = [...collectSelectorsFromCss(layerCss)];
1445
+ if (selectors.length === 0) return css;
1446
+ try {
1447
+ const root = postcss.default.parse(css);
1448
+ root.walkRules((rule) => {
1449
+ if ((rule.selectors ?? [rule.selector]).some((selector) => selectors.some((layerSelector) => matchesLayerSelector(selector.trim(), layerSelector)))) rule.remove();
1450
+ });
1451
+ return root.toString();
1452
+ } catch {
1453
+ return removeFirstCssOccurrence(css, layerCss);
1454
+ }
1455
+ }
1456
+ function wrapUserLayerComponentsCss(css) {
1457
+ return css.trim().length > 0 ? `${USER_LAYER_COMPONENTS_START}\n${css}\n${USER_LAYER_COMPONENTS_END}` : css;
1458
+ }
1459
+ function extractMarkedUserLayerComponentsCss(css) {
1460
+ const layers = [];
1461
+ let rest = "";
1462
+ let cursor = 0;
1463
+ while (cursor < css.length) {
1464
+ const startIndex = css.indexOf(USER_LAYER_COMPONENTS_START, cursor);
1465
+ if (startIndex === -1) {
1466
+ rest += css.slice(cursor);
1467
+ break;
1468
+ }
1469
+ rest += css.slice(cursor, startIndex);
1470
+ const contentStart = startIndex + 47;
1471
+ const endIndex = css.indexOf(USER_LAYER_COMPONENTS_END, contentStart);
1472
+ if (endIndex === -1) {
1473
+ rest += css.slice(startIndex);
1474
+ break;
1475
+ }
1476
+ const layerCss = css.slice(contentStart, endIndex).trim();
1477
+ if (layerCss) layers.push(layerCss);
1478
+ cursor = endIndex + 45;
1479
+ }
1480
+ return {
1481
+ layers,
1482
+ rest
1483
+ };
1484
+ }
1485
+ function findUtilityLayerInsertionIndex(css) {
1486
+ let index = -1;
1487
+ for (const pattern of UTILITY_LAYER_INSERTION_RES) {
1488
+ const match = pattern.exec(css);
1489
+ if (!match) continue;
1490
+ const nextIndex = match.index + (match[1]?.length ?? 0);
1491
+ index = index === -1 ? nextIndex : Math.min(index, nextIndex);
1492
+ }
1493
+ return index;
1494
+ }
1495
+ function reorderMarkedUserLayerComponentsCss(css) {
1496
+ if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
1497
+ const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
1498
+ if (layers.length === 0) return rest;
1499
+ const layerCss = layers.join("\n");
1500
+ const insertionIndex = findUtilityLayerInsertionIndex(rest);
1501
+ if (insertionIndex === -1) return appendCss(rest, layerCss);
1502
+ return appendCss(appendCss(rest.slice(0, insertionIndex), layerCss), rest.slice(insertionIndex));
1503
+ }
1504
+ function mergeMarkedUserLayerComponentsCss(baseCss, markedCss) {
1505
+ if (!markedCss.includes(USER_LAYER_COMPONENTS_START)) return {
1506
+ css: baseCss,
1507
+ merged: false
1508
+ };
1509
+ const { layers } = extractMarkedUserLayerComponentsCss(markedCss);
1510
+ if (layers.length === 0) return {
1511
+ css: baseCss,
1512
+ merged: false
1513
+ };
1514
+ const layerCss = layers.join("\n");
1515
+ return {
1516
+ css: reorderMarkedUserLayerComponentsCss(appendCss(removeCssRulesForSelectors(baseCss, layerCss), wrapUserLayerComponentsCss(layerCss))),
1517
+ merged: true
1518
+ };
1519
+ }
1520
+ //#endregion
1379
1521
  //#region src/bundlers/shared/generator-css.ts
1380
1522
  const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
1381
1523
  const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
@@ -1449,6 +1591,9 @@ function createCssSourceOrderAppend(base, extra) {
1449
1591
  if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
1450
1592
  return `${base}\n${extra}`;
1451
1593
  }
1594
+ function shouldFinalizeMarkedUserLayerComponentsCss(file) {
1595
+ return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
1596
+ }
1452
1597
  function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
1453
1598
  const placeholderParts = splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
1454
1599
  if (placeholderParts) return placeholderParts;
@@ -1456,6 +1601,84 @@ function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
1456
1601
  if (exactParts) return exactParts;
1457
1602
  return splitTailwindGeneratedCssByBanner(rawSource);
1458
1603
  }
1604
+ function splitUserCssLayerBlocks(source) {
1605
+ if (!source.includes("@layer")) return {
1606
+ layer: "",
1607
+ rest: source
1608
+ };
1609
+ try {
1610
+ const root = postcss.default.parse(source);
1611
+ const layerRoot = postcss.default.root();
1612
+ const restRoot = postcss.default.root();
1613
+ for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
1614
+ return {
1615
+ layer: layerRoot.toString(),
1616
+ rest: restRoot.toString()
1617
+ };
1618
+ } catch {
1619
+ return {
1620
+ layer: source,
1621
+ rest: ""
1622
+ };
1623
+ }
1624
+ }
1625
+ function hasUserCssLayerBlocks(source) {
1626
+ if (!source.includes("@layer")) return false;
1627
+ try {
1628
+ let hasLayerBlock = false;
1629
+ postcss.default.parse(source).walkAtRules("layer", (node) => {
1630
+ if (node.nodes?.length) hasLayerBlock = true;
1631
+ });
1632
+ return hasLayerBlock;
1633
+ } catch {
1634
+ return true;
1635
+ }
1636
+ }
1637
+ function collectUserLayerSelectors(source) {
1638
+ const selectors = /* @__PURE__ */ new Set();
1639
+ try {
1640
+ postcss.default.parse(source).walkRules((rule) => {
1641
+ for (const selector of rule.selectors ?? [rule.selector]) {
1642
+ const normalized = selector.trim();
1643
+ if (normalized) selectors.add(normalized);
1644
+ }
1645
+ });
1646
+ } catch {}
1647
+ return selectors;
1648
+ }
1649
+ function matchesUserLayerSelector(selector, userLayerSelector) {
1650
+ if (selector === userLayerSelector) return true;
1651
+ if (!selector.startsWith(userLayerSelector)) return false;
1652
+ const next = selector[userLayerSelector.length];
1653
+ return next === ":" || next === "[";
1654
+ }
1655
+ function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
1656
+ const selectors = collectUserLayerSelectors(userLayerSource);
1657
+ if (selectors.size === 0) return {
1658
+ layer: "",
1659
+ rest: css
1660
+ };
1661
+ try {
1662
+ const root = postcss.default.parse(css);
1663
+ const layerRoot = postcss.default.root();
1664
+ const selectorList = [...selectors];
1665
+ root.walkRules((rule) => {
1666
+ if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
1667
+ layerRoot.append(rule.clone());
1668
+ rule.remove();
1669
+ }
1670
+ });
1671
+ return {
1672
+ layer: layerRoot.toString(),
1673
+ rest: root.toString()
1674
+ };
1675
+ } catch {
1676
+ return {
1677
+ layer: "",
1678
+ rest: css
1679
+ };
1680
+ }
1681
+ }
1459
1682
  async function transformGeneratorUserCss(source, options) {
1460
1683
  if (source.trim().length === 0) return "";
1461
1684
  const cleanedSource = removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source)), { importFallback: options.importFallback });
@@ -1584,7 +1807,7 @@ async function generateCssByGenerator(options) {
1584
1807
  sources: generatedResults.flatMap((item) => item.sources)
1585
1808
  };
1586
1809
  debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
1587
- if (typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
1810
+ if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(effectiveRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
1588
1811
  const incrementalCss = stripTailwindBanner(generated.incrementalCss);
1589
1812
  return {
1590
1813
  css: incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, { injectPreflight: false })) : options.previousCss,
@@ -1606,9 +1829,14 @@ async function generateCssByGenerator(options) {
1606
1829
  styleHandler,
1607
1830
  importFallback: generatorOptions.importFallback
1608
1831
  };
1832
+ const afterLayerParts = generated.target === "weapp" ? splitUserCssLayerBlocks(orderedExtraCss.after) : {
1833
+ layer: "",
1834
+ rest: orderedExtraCss.after
1835
+ };
1609
1836
  const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
1610
- const afterUserCss = await transformGeneratorUserCss(orderedExtraCss.after, userCssOptions);
1611
- css = createCssSourceOrderAppend(createCssSourceOrderAppend(beforeUserCss, css), afterUserCss);
1837
+ const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
1838
+ const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
1839
+ css = createCssSourceOrderAppend(createCssSourceOrderAppend(createCssSourceOrderAppend(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(afterLayerUserCss) : afterLayerUserCss), css), afterUserCss);
1612
1840
  if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
1613
1841
  hasSourceDirectives,
1614
1842
  hasMatchedCssSourceFile
@@ -1617,6 +1845,7 @@ async function generateCssByGenerator(options) {
1617
1845
  css = createCssSourceOrderAppend(css, userCss);
1618
1846
  }
1619
1847
  if (generated.target === "weapp") {
1848
+ if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
1620
1849
  css = await appendLegacyCompatCss(css, effectiveRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1621
1850
  css = await appendLegacyContainerCompatCss(css, effectiveRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
1622
1851
  }
@@ -1629,7 +1858,27 @@ async function generateCssByGenerator(options) {
1629
1858
  }
1630
1859
  debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
1631
1860
  let css = stripTailwindBanner(generated.css);
1632
- if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, effectiveRawSource);
1861
+ if (generated.target === "weapp") {
1862
+ css = inheritLegacyUnitConvertedDeclarations(css, effectiveRawSource);
1863
+ if (hasUserCssLayerBlocks(effectiveRawSource)) {
1864
+ const layerParts = splitUserCssLayerBlocks(effectiveRawSource);
1865
+ const layerUserCss = await transformGeneratorUserCss(layerParts.layer, {
1866
+ generatorTarget: generated.target,
1867
+ generatorStyleOptions,
1868
+ cssUserHandlerOptions,
1869
+ styleHandler,
1870
+ importFallback: generatorOptions.importFallback
1871
+ });
1872
+ const layerCss = layerUserCss.trim().length > 0 && !hasTailwindApplyDirective(layerUserCss) ? {
1873
+ layer: layerUserCss,
1874
+ rest: css
1875
+ } : extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
1876
+ if (layerCss.layer.trim().length > 0) {
1877
+ css = createCssSourceOrderAppend(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
1878
+ if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
1879
+ }
1880
+ }
1881
+ }
1633
1882
  if (hasMatchedCssSourceFile || generated.target === "web") {
1634
1883
  if (shouldAppendWebBundleCssFallback(generated.target, {
1635
1884
  hasSourceDirectives,
@@ -2018,6 +2267,12 @@ Object.defineProperty(exports, "hasTailwindSourceDirectives", {
2018
2267
  return hasTailwindSourceDirectives;
2019
2268
  }
2020
2269
  });
2270
+ Object.defineProperty(exports, "mergeMarkedUserLayerComponentsCss", {
2271
+ enumerable: true,
2272
+ get: function() {
2273
+ return mergeMarkedUserLayerComponentsCss;
2274
+ }
2275
+ });
2021
2276
  Object.defineProperty(exports, "normalizeTailwindSourceForGenerator", {
2022
2277
  enumerable: true,
2023
2278
  get: function() {