@csszyx/unplugin 0.14.5 → 0.15.1

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 (52) hide show
  1. package/README.md +4 -3
  2. package/dist/index.cjs +8 -7
  3. package/dist/index.d.cts +70 -3
  4. package/dist/index.d.mts +70 -3
  5. package/dist/index.mjs +4 -4
  6. package/dist/next-config.d.cts +1 -2
  7. package/dist/next-config.d.mts +1 -2
  8. package/dist/next-prebuild.cjs +9 -5
  9. package/dist/next-prebuild.d.cts +4 -2
  10. package/dist/next-prebuild.d.mts +4 -2
  11. package/dist/next-prebuild.mjs +8 -4
  12. package/dist/next-turbo-loader.cjs +20 -14
  13. package/dist/next-turbo-loader.d.cts +1 -1
  14. package/dist/next-turbo-loader.d.mts +1 -1
  15. package/dist/next-turbo-loader.mjs +19 -13
  16. package/dist/next-watcher.cjs +2 -2
  17. package/dist/next-watcher.d.cts +2 -2
  18. package/dist/next-watcher.d.mts +2 -2
  19. package/dist/next-watcher.mjs +2 -2
  20. package/dist/postcss.cjs +124 -0
  21. package/dist/postcss.d.cts +42 -0
  22. package/dist/postcss.d.mts +42 -0
  23. package/dist/postcss.mjs +107 -0
  24. package/dist/shared/{unplugin.RGzhYt-D.cjs → unplugin.8KYddE6x.cjs} +394 -226
  25. package/dist/shared/{unplugin.CPEWNSA0.d.cts → unplugin.BGog1Bib.d.cts} +9 -6
  26. package/dist/shared/{unplugin.CPEWNSA0.d.mts → unplugin.BGog1Bib.d.mts} +9 -6
  27. package/dist/shared/{unplugin.BU0O4IkX.mjs → unplugin.BLptVbUe.mjs} +22 -61
  28. package/dist/shared/{unplugin.BXYakiXt.d.cts → unplugin.BT7PqYuK.d.cts} +53 -55
  29. package/dist/shared/{unplugin.BXYakiXt.d.mts → unplugin.BT7PqYuK.d.mts} +53 -55
  30. package/dist/shared/{unplugin.Cji6O5jv.cjs → unplugin.BWnmKv07.cjs} +32 -69
  31. package/dist/shared/{unplugin.NlPvn5P4.mjs → unplugin.Bk9o8_RZ.mjs} +2 -6
  32. package/dist/shared/{unplugin.VtXstzEh.cjs → unplugin.BzF0V2kw.cjs} +6 -11
  33. package/dist/shared/{unplugin.CdZxp0x-.d.mts → unplugin.COlI0dJs.d.mts} +1 -1
  34. package/dist/shared/{unplugin.BnRf0Tvd.mjs → unplugin.D68hyqgb.mjs} +347 -178
  35. package/dist/shared/{unplugin.DN95k991.mjs → unplugin.DAzgbtuZ.mjs} +2 -2
  36. package/dist/shared/unplugin.DDSWQJYX.cjs +289 -0
  37. package/dist/shared/unplugin.DH_ij6cf.mjs +258 -0
  38. package/dist/shared/{unplugin.BZPdvVcj.mjs → unplugin.DK0b4fr7.mjs} +105 -127
  39. package/dist/shared/{unplugin.D8BxOOkA.cjs → unplugin.J6ue_lRJ.cjs} +121 -142
  40. package/dist/shared/{unplugin.DVbPNK3W.cjs → unplugin.gksolKh2.cjs} +6 -6
  41. package/dist/shared/{unplugin.xeED_qwh.d.cts → unplugin.rWOMecQs.d.cts} +1 -1
  42. package/dist/vite.cjs +4 -4
  43. package/dist/vite.d.cts +2 -2
  44. package/dist/vite.d.mts +1 -1
  45. package/dist/vite.mjs +4 -4
  46. package/dist/webpack.cjs +4 -4
  47. package/dist/webpack.d.cts +2 -1
  48. package/dist/webpack.d.mts +1 -1
  49. package/dist/webpack.mjs +4 -4
  50. package/package.json +19 -9
  51. package/dist/shared/unplugin.B3XoSRB8.mjs +0 -40
  52. package/dist/shared/unplugin.BkRah5Ot.cjs +0 -48
@@ -13,10 +13,10 @@ const svelteAdapter = require('@csszyx/svelte-adapter');
13
13
  const types = require('@csszyx/types');
14
14
  const vueAdapter = require('@csszyx/vue-adapter');
15
15
  const unplugin$1 = require('unplugin');
16
- const transformCache = require('./unplugin.VtXstzEh.cjs');
16
+ const safelistSource = require('./unplugin.DDSWQJYX.cjs');
17
+ const transformCache = require('./unplugin.BzF0V2kw.cjs');
17
18
  const cssMangler = require('../css-mangler.cjs');
18
- const themeGroupsFile = require('./unplugin.D8BxOOkA.cjs');
19
- const htmlEscape = require('./unplugin.BkRah5Ot.cjs');
19
+ const themeGroupsFile = require('./unplugin.J6ue_lRJ.cjs');
20
20
  const node_zlib = require('node:zlib');
21
21
  const postcss = require('postcss');
22
22
  const valueParser = require('postcss-value-parser');
@@ -37,7 +37,9 @@ function _interopNamespaceCompat(e) {
37
37
  }
38
38
 
39
39
  const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs);
40
+ const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
40
41
  const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
42
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
41
43
  const postcss__default = /*#__PURE__*/_interopDefaultCompat(postcss);
42
44
  const valueParser__default = /*#__PURE__*/_interopDefaultCompat(valueParser);
43
45
 
@@ -168,7 +170,7 @@ function scanGlobalVarCss(css, options = {}) {
168
170
  filePath,
169
171
  definitions,
170
172
  references,
171
- registered: htmlEscape.sortStrings(registered),
173
+ registered: safelistSource.sortStrings(registered),
172
174
  thirdParty: isThirdPartyCssPath(filePath)
173
175
  };
174
176
  }
@@ -187,7 +189,7 @@ function extractVarReferences(value) {
187
189
  for (const match of value.matchAll(VAR_REFERENCE_RE)) {
188
190
  references.add(match[1]);
189
191
  }
190
- return htmlEscape.sortStrings(references);
192
+ return safelistSource.sortStrings(references);
191
193
  }
192
194
  function isThirdPartyCssPath(filePath) {
193
195
  return filePath.split(/[\\/]/).includes("node_modules");
@@ -228,7 +230,7 @@ function planGlobalVarAliases(input) {
228
230
  entries.push({
229
231
  original,
230
232
  alias,
231
- scopes: htmlEscape.sortStrings(
233
+ scopes: safelistSource.sortStrings(
232
234
  new Set((definitions.get(original) ?? []).map((definition) => definition.scopeId))
233
235
  )
234
236
  });
@@ -263,7 +265,7 @@ function collectCandidates(input, definitions) {
263
265
  }
264
266
  }
265
267
  }
266
- return htmlEscape.sortStrings(candidates);
268
+ return safelistSource.sortStrings(candidates);
267
269
  }
268
270
  function validateCandidates(candidates, definitions, reserved, aliasPrefix) {
269
271
  const diagnostics = [];
@@ -541,8 +543,8 @@ function createRSCModuleRecord(code, id) {
541
543
  }
542
544
  function deleteRSCModuleRecord(records, id) {
543
545
  const normalized = normalizeModuleId(id);
544
- const clean = transformCache.normalizePathSeparators(id.split("?")[0] ?? id);
545
- const resolved = transformCache.normalizePathSeparators(path__namespace.resolve(clean));
546
+ const clean = safelistSource.normalizePathSeparators(id.split("?")[0] ?? id);
547
+ const resolved = safelistSource.normalizePathSeparators(path__namespace.resolve(clean));
546
548
  pruneRSCModulePathCaches(/* @__PURE__ */ new Set([normalized, resolved, clean]));
547
549
  let deleted = records.delete(normalized);
548
550
  if (resolved !== normalized) {
@@ -588,7 +590,7 @@ const APP_ROUTER_ENTRIES = /* @__PURE__ */ new Set([
588
590
  "route"
589
591
  ]);
590
592
  function isNextAppRouterEntry(id) {
591
- const clean = transformCache.normalizePathSeparators(id.split("?")[0] ?? id);
593
+ const clean = safelistSource.normalizePathSeparators(id.split("?")[0] ?? id);
592
594
  if (!clean.includes("/app/") && !clean.startsWith("app/")) return false;
593
595
  const basename = clean.split("/").pop() ?? "";
594
596
  const dotIdx = basename.indexOf(".");
@@ -943,9 +945,9 @@ function normalizeModuleId(id) {
943
945
  }
944
946
  let normalized;
945
947
  try {
946
- normalized = transformCache.normalizePathSeparators(fs__namespace.realpathSync.native(clean));
948
+ normalized = safelistSource.normalizePathSeparators(fs__namespace.realpathSync.native(clean));
947
949
  } catch {
948
- normalized = transformCache.normalizePathSeparators(path__namespace.resolve(clean));
950
+ normalized = safelistSource.normalizePathSeparators(path__namespace.resolve(clean));
949
951
  }
950
952
  normalizedModuleIdCache.set(clean, normalized);
951
953
  return normalized;
@@ -991,7 +993,7 @@ function resolveLocalModule(importer, source) {
991
993
  }
992
994
  function pruneRSCModulePathCaches(moduleIds) {
993
995
  for (const [key, value] of normalizedModuleIdCache) {
994
- const normalizedKey = transformCache.normalizePathSeparators(key);
996
+ const normalizedKey = safelistSource.normalizePathSeparators(key);
995
997
  if (moduleIds.has(value) || moduleIds.has(normalizedKey)) {
996
998
  normalizedModuleIdCache.delete(key);
997
999
  }
@@ -1619,10 +1621,10 @@ An unread option is silent, so whatever you configured it for is not happening.`
1619
1621
  const GLOB_MAGIC_RE = /[*?[\]{}]/;
1620
1622
  const DEFAULT_IGNORED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", ".turbo", "dist", "build"]);
1621
1623
  function normalizeFileId(id) {
1622
- return transformCache.normalizePathSeparators(id.split(/[?#]/, 1)[0]);
1624
+ return safelistSource.normalizePathSeparators(id.split(/[?#]/, 1)[0]);
1623
1625
  }
1624
1626
  function normalizeRoot(rootDir) {
1625
- return transformCache.normalizePathSeparators(path__namespace.resolve(rootDir));
1627
+ return safelistSource.normalizePathSeparators(path__namespace.resolve(rootDir));
1626
1628
  }
1627
1629
  function hasGlobMagic(pattern) {
1628
1630
  return GLOB_MAGIC_RE.test(pattern);
@@ -1631,7 +1633,7 @@ function escapeRegExp(ch) {
1631
1633
  return /[|\\{}()[\]^$+?.]/.test(ch) ? `\\${ch}` : ch;
1632
1634
  }
1633
1635
  function globToRegExp(pattern) {
1634
- const normalized = transformCache.normalizePathSeparators(pattern);
1636
+ const normalized = safelistSource.normalizePathSeparators(pattern);
1635
1637
  let out = "^";
1636
1638
  for (let i = 0; i < normalized.length; i++) {
1637
1639
  const ch = normalized[i];
@@ -1654,7 +1656,7 @@ function globToRegExp(pattern) {
1654
1656
  function relativeToRoot(file, rootDir) {
1655
1657
  const root = normalizeRoot(rootDir);
1656
1658
  const normalizedFile = normalizeFileId(file);
1657
- return transformCache.normalizePathSeparators(path__namespace.posix.relative(root, normalizedFile));
1659
+ return safelistSource.normalizePathSeparators(path__namespace.posix.relative(root, normalizedFile));
1658
1660
  }
1659
1661
  function matchesPattern(id, pattern, rootDir) {
1660
1662
  const file = normalizeFileId(id);
@@ -1663,7 +1665,7 @@ function matchesPattern(id, pattern, rootDir) {
1663
1665
  pattern.lastIndex = 0;
1664
1666
  return pattern.test(file) || pattern.test(relative);
1665
1667
  }
1666
- const normalizedPattern = transformCache.normalizePathSeparators(pattern);
1668
+ const normalizedPattern = safelistSource.normalizePathSeparators(pattern);
1667
1669
  if (hasGlobMagic(normalizedPattern)) {
1668
1670
  const re = globToRegExp(normalizedPattern);
1669
1671
  return re.test(file) || re.test(relative);
@@ -1727,18 +1729,36 @@ function expandFilePatterns(rootDir, patterns) {
1727
1729
  }
1728
1730
  }
1729
1731
  }
1730
- return htmlEscape.sortStrings(files);
1732
+ return safelistSource.sortStrings(files);
1733
+ }
1734
+
1735
+ const BACKSLASH = String.fromCodePoint(92);
1736
+ function unicodeEscape(hexadecimal) {
1737
+ return `${BACKSLASH}u${hexadecimal}`;
1738
+ }
1739
+ function replaceEveryLiteral(value, search, replacement) {
1740
+ return value.replaceAll(search, () => replacement);
1741
+ }
1742
+ function escapeSingleQuotedString(value) {
1743
+ let escaped = replaceEveryLiteral(value, BACKSLASH, BACKSLASH.repeat(2));
1744
+ escaped = replaceEveryLiteral(escaped, "'", `${BACKSLASH}'`);
1745
+ escaped = replaceEveryLiteral(escaped, "\r", `${BACKSLASH}r`);
1746
+ return replaceEveryLiteral(escaped, "\n", `${BACKSLASH}n`);
1747
+ }
1748
+ function escapeDoubleQuotedString(value) {
1749
+ const escaped = replaceEveryLiteral(value, BACKSLASH, BACKSLASH.repeat(2));
1750
+ return replaceEveryLiteral(escaped, '"', `${BACKSLASH}"`);
1731
1751
  }
1732
1752
 
1733
1753
  const LINE_SEPARATOR$1 = String.fromCodePoint(8232);
1734
1754
  const PARAGRAPH_SEPARATOR$1 = String.fromCodePoint(8233);
1735
1755
  function safeJsonForScriptTag(value, prettyPrint = false) {
1736
1756
  const json = prettyPrint ? JSON.stringify(value, null, 2) : JSON.stringify(value);
1737
- let escaped = htmlEscape.replaceEveryLiteral(json, "<", htmlEscape.unicodeEscape("003C"));
1738
- escaped = htmlEscape.replaceEveryLiteral(escaped, ">", htmlEscape.unicodeEscape("003E"));
1739
- escaped = htmlEscape.replaceEveryLiteral(escaped, "&", htmlEscape.unicodeEscape("0026"));
1740
- escaped = htmlEscape.replaceEveryLiteral(escaped, LINE_SEPARATOR$1, htmlEscape.unicodeEscape("2028"));
1741
- return htmlEscape.replaceEveryLiteral(escaped, PARAGRAPH_SEPARATOR$1, htmlEscape.unicodeEscape("2029"));
1757
+ let escaped = replaceEveryLiteral(json, "<", unicodeEscape("003C"));
1758
+ escaped = replaceEveryLiteral(escaped, ">", unicodeEscape("003E"));
1759
+ escaped = replaceEveryLiteral(escaped, "&", unicodeEscape("0026"));
1760
+ escaped = replaceEveryLiteral(escaped, LINE_SEPARATOR$1, unicodeEscape("2028"));
1761
+ return replaceEveryLiteral(escaped, PARAGRAPH_SEPARATOR$1, unicodeEscape("2029"));
1742
1762
  }
1743
1763
  function injectHtmlOpeningAttr(html, attr) {
1744
1764
  const lower = html.toLowerCase();
@@ -1764,31 +1784,22 @@ function injectChecksum(html, checksum, minify = false) {
1764
1784
  const attrName = minify ? "data-sz-cs" : "data-sz-checksum";
1765
1785
  return injectHtmlOpeningAttr(html, ` ${attrName}="${checksum}"`);
1766
1786
  }
1767
- function injectMangleMapScript(html, mangleMap, options = {}) {
1768
- const {
1769
- prettyPrint = false,
1770
- varMangleMap = {},
1771
- globalVarAliasPrefix = types.CSSZYX_GLOBAL_ALIAS_PREFIX,
1772
- installRuntimeObject = true
1773
- } = options;
1774
- const checksumMap = createHydrationMangleMap(mangleMap, varMangleMap);
1775
- const jsonContent = safeJsonForScriptTag(checksumMap, prettyPrint);
1776
- const varMapContent = safeJsonForScriptTag(varMangleMap);
1777
- const reuseChecksumPayload = Object.keys(varMangleMap).length === 0;
1778
- const classMapExpr = reuseChecksumPayload ? '(function(){var e=document.getElementById("__CSSZYX_MANGLE_MAP__");return e?JSON.parse(e.textContent):{}})()' : safeJsonForScriptTag(mangleMap);
1779
- const scriptTag = `<script id="__CSSZYX_MANGLE_MAP__" type="application/json">${jsonContent}<\/script>`;
1780
- const prefixContent = safeJsonForScriptTag(globalVarAliasPrefix);
1781
- const debugScript = `<script>(function(){var m=${classMapExpr};var vm=${varMapContent};var gp=${prefixContent};var r={};var vr={};for(var k in m)r[m[k]]=k;for(var vk in vm){var vv=vm[vk];var vs=Array.isArray(vv)?vv:[vv];for(var vi=0;vi<vs.length;vi++)(vr[vs[vi]]||(vr[vs[vi]]=[])).push(vk)}var cs=document.documentElement.getAttribute("data-sz-checksum")||"";window.__csszyx={mangleMap:m,varMangleMap:vm,checksum:cs,decode:function(c){return r[c]},encode:function(c){return m[c]},decodeVar:function(v){return vr[v]||[]},encodeVar:function(v){return vm[v]},decodeGlobalVar:function(v){var a=vr[v]||[];return v.indexOf(gp)===0?a[0]:void 0},decodeAll:function(el){return(el.className||"").split(" ").map(function(c){return r[c]||c})}}})()<\/script>`;
1782
- const combined = installRuntimeObject ? `${scriptTag}
1783
- ${debugScript}` : scriptTag;
1787
+ function withScriptTag(html, scriptTag) {
1784
1788
  if (html.includes("</head>")) {
1785
- return html.replace("</head>", `${combined}
1789
+ return html.replace("</head>", `${scriptTag}
1786
1790
  </head>`);
1787
- } else if (html.includes("</html>")) {
1788
- return html.replace("</html>", `${combined}
1791
+ }
1792
+ if (html.includes("</html>")) {
1793
+ return html.replace("</html>", `${scriptTag}
1789
1794
  </html>`);
1790
1795
  }
1791
- return html + combined;
1796
+ return html + scriptTag;
1797
+ }
1798
+ function injectMangleMapScript(html, mangleMap, options = {}) {
1799
+ const { prettyPrint = false, varMangleMap = {} } = options;
1800
+ const checksumMap = createHydrationMangleMap(mangleMap, varMangleMap);
1801
+ const scriptTag = `<script id="__CSSZYX_MANGLE_MAP__" type="application/json">${safeJsonForScriptTag(checksumMap, prettyPrint)}<\/script>`;
1802
+ return withScriptTag(html, scriptTag);
1792
1803
  }
1793
1804
  function injectMangleMapAttribute(html, mangleMap, minify = false, varMangleMap = {}) {
1794
1805
  const attrName = minify ? "data-sz-m" : "data-sz-map";
@@ -1835,7 +1846,7 @@ function buildRecoveryManifest(tokens, options) {
1835
1846
  const stripped = options.production === true;
1836
1847
  const strippedDevOnlyPaths = [];
1837
1848
  const sorted = {};
1838
- const sortedKeys = htmlEscape.sortStrings(tokens.keys());
1849
+ const sortedKeys = safelistSource.sortStrings(tokens.keys());
1839
1850
  for (const key of sortedKeys) {
1840
1851
  const data = tokens.get(key);
1841
1852
  if (!data) {
@@ -1862,27 +1873,97 @@ function injectRecoveryManifest(html, manifest) {
1862
1873
  }
1863
1874
  const json = JSON.stringify(manifest);
1864
1875
  const scriptTag = `<script id="__SZ_RECOVERY_MANIFEST__" type="application/json">${json}<\/script>`;
1865
- if (html.includes("</head>")) {
1866
- return html.replace("</head>", `${scriptTag}
1867
- </head>`);
1868
- } else if (html.includes("</html>")) {
1869
- return html.replace("</html>", `${scriptTag}
1870
- </html>`);
1871
- }
1872
- return html + scriptTag;
1876
+ return withScriptTag(html, scriptTag);
1873
1877
  }
1874
1878
 
1875
1879
  const LINE_SEPARATOR = String.fromCodePoint(8232);
1876
1880
  const PARAGRAPH_SEPARATOR = String.fromCodePoint(8233);
1877
1881
  function escapeJsonForInlineScript(json) {
1878
- let escaped = htmlEscape.replaceEveryLiteral(json, "`", htmlEscape.unicodeEscape("0060"));
1879
- escaped = htmlEscape.replaceEveryLiteral(escaped, "$", htmlEscape.unicodeEscape("0024"));
1880
- escaped = htmlEscape.replaceEveryLiteral(escaped, "<", htmlEscape.unicodeEscape("003c"));
1881
- escaped = htmlEscape.replaceEveryLiteral(escaped, LINE_SEPARATOR, htmlEscape.unicodeEscape("2028"));
1882
- return htmlEscape.replaceEveryLiteral(escaped, PARAGRAPH_SEPARATOR, htmlEscape.unicodeEscape("2029"));
1882
+ let escaped = replaceEveryLiteral(json, "`", unicodeEscape("0060"));
1883
+ escaped = replaceEveryLiteral(escaped, "$", unicodeEscape("0024"));
1884
+ escaped = replaceEveryLiteral(escaped, "<", unicodeEscape("003c"));
1885
+ escaped = replaceEveryLiteral(escaped, LINE_SEPARATOR, unicodeEscape("2028"));
1886
+ return replaceEveryLiteral(escaped, PARAGRAPH_SEPARATOR, unicodeEscape("2029"));
1887
+ }
1888
+ function escapeJsonForStringLiteral(json) {
1889
+ let escaped = replaceEveryLiteral(json, "\\", unicodeEscape("005c"));
1890
+ for (const [character, code] of [
1891
+ ['"', "0022"],
1892
+ ["'", "0027"],
1893
+ ["`", "0060"],
1894
+ ["$", "0024"],
1895
+ ["<", "003c"],
1896
+ [">", "003e"],
1897
+ [LINE_SEPARATOR, "2028"],
1898
+ [PARAGRAPH_SEPARATOR, "2029"]
1899
+ ]) {
1900
+ escaped = replaceEveryLiteral(escaped, character, unicodeEscape(code));
1901
+ }
1902
+ return escaped;
1883
1903
  }
1884
1904
  function escapeForDoubleQuotedString(value) {
1885
- return htmlEscape.escapeDoubleQuotedString(value);
1905
+ return escapeDoubleQuotedString(value);
1906
+ }
1907
+
1908
+ function createLazyAggregate(build, initial) {
1909
+ const entries = /* @__PURE__ */ new Map();
1910
+ let current = initial;
1911
+ let dirty = false;
1912
+ return {
1913
+ entries,
1914
+ set(key, entry) {
1915
+ entries.set(key, entry);
1916
+ dirty = true;
1917
+ },
1918
+ delete(key) {
1919
+ if (entries.delete(key)) dirty = true;
1920
+ },
1921
+ get() {
1922
+ if (dirty) {
1923
+ current = build(entries);
1924
+ dirty = false;
1925
+ }
1926
+ return current;
1927
+ }
1928
+ };
1929
+ }
1930
+
1931
+ function needsRuntimeMangleRegistration(manglingEnabled, mangleMap) {
1932
+ if (!manglingEnabled) return false;
1933
+ return Object.keys(mangleMap).length > 0;
1934
+ }
1935
+ function removedMangleMapDeliveryMessage() {
1936
+ return "[csszyx] production.mangleMapDelivery has been removed and is ignored. The runtime mangle map is always registered from inside the JS bundle now, on every lane, so the built HTML never carries an executable inline <script> and a strict script-src 'self' policy needs no exception. Delete the option. (`window.__csszyx` is now opt-in through `production.mangleDebugGlobal`.)";
1937
+ }
1938
+
1939
+ const MANGLE_RUNTIME_FILE = "mangle-runtime.mjs";
1940
+ function ensureMangleRuntimeFile(outputDir, globalVarAliasPrefix, exposeDebugGlobal) {
1941
+ const target = path__default.join(outputDir, MANGLE_RUNTIME_FILE);
1942
+ const staging = `${target}.${process.pid}.tmp`;
1943
+ try {
1944
+ fs__default.mkdirSync(outputDir, { recursive: true });
1945
+ fs__default.writeFileSync(
1946
+ staging,
1947
+ themeGroupsFile.createMangleRuntimeModule(globalVarAliasPrefix, exposeDebugGlobal),
1948
+ "utf8"
1949
+ );
1950
+ fs__default.renameSync(staging, target);
1951
+ return target;
1952
+ } catch {
1953
+ try {
1954
+ fs__default.rmSync(staging, { force: true });
1955
+ } catch {
1956
+ }
1957
+ return null;
1958
+ }
1959
+ }
1960
+ function applyMangleRuntimeEntry(compiler, context, file, onRegistered) {
1961
+ const EntryPlugin = compiler.webpack?.EntryPlugin;
1962
+ if (EntryPlugin === void 0) {
1963
+ return;
1964
+ }
1965
+ new EntryPlugin(context, file, { name: void 0 }).apply(compiler);
1966
+ onRegistered();
1886
1967
  }
1887
1968
 
1888
1969
  function createMangleSizeAccount() {
@@ -1920,7 +2001,7 @@ function recordCodePair(account, before, after) {
1920
2001
  account.codeGzAfter += gzipBytes(after);
1921
2002
  }
1922
2003
  function computeMangleSizeVerdict(account, mapPayload) {
1923
- const channels = htmlEscape.sortStrings(account.channels);
2004
+ const channels = safelistSource.sortStrings(account.channels);
1924
2005
  const mapCost = gzipBytes(mapPayload) * channels.length;
1925
2006
  const cssSaving = account.cssGzBefore - account.cssGzAfter;
1926
2007
  const codeSaving = account.codeGzBefore - account.codeGzAfter;
@@ -1932,7 +2013,7 @@ function mangleSizeMessage(verdict) {
1932
2013
  const cssPart = verdict.cssSaving >= 0 ? `the mangled CSS saves ${verdict.cssSaving} B` : `the mangled CSS COSTS ${-verdict.cssSaving} B (short tokens compress worse than the names they replaced)`;
1933
2014
  const codePart = verdict.codeSaving >= 0 ? `the shortened classes in code save ${verdict.codeSaving} B` : `the shortened classes in code COST ${-verdict.codeSaving} B`;
1934
2015
  const channelPart = verdict.channels.length > 1 ? `${verdict.channels.join(" + ")} (${verdict.channels.length} copies)` : verdict.channels[0];
1935
- return `[csszyx] production.mangle is making this build BIGGER: +${verdict.net} B gzipped. The runtime mangle map costs ${verdict.mapCost} B via ${channelPart}, while ${cssPart} and ${codePart}. Mangling is a name-obfuscation feature; over a compressed response it does not reduce payload, because utility class names compress far better than the map they need. If you enabled it for size, set \`production.mangle: false\`. If you enabled it to hide class names, this is the expected price and you can ignore this. Narrowing \`production.mangleMapDelivery\` removes a map copy when only one channel is needed.`;
2016
+ return `[csszyx] production.mangle is making this build BIGGER: +${verdict.net} B gzipped. The runtime mangle map costs ${verdict.mapCost} B via ${channelPart}, while ${cssPart} and ${codePart}. Mangling is a name-obfuscation feature; over a compressed response it does not reduce payload, because utility class names compress far better than the map they need. If you enabled it for size, set \`production.mangle: false\`. If you enabled it to hide class names, this is the expected price and you can ignore this. Two copies is not a misconfiguration: the bundle carries the map the runtime reads, and the HTML carries the same census for the hydration checksum.`;
1936
2017
  }
1937
2018
 
1938
2019
  function isParserMode(value) {
@@ -1993,10 +2074,10 @@ function isSameFileVersion(before, after) {
1993
2074
  function generateThemeDts(opts) {
1994
2075
  const { theme, sourceFiles } = opts;
1995
2076
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
1996
- const withoutCarriageReturns = htmlEscape.replaceEveryLiteral(sourceFiles.join(", "), "\r", " ");
1997
- const sources = htmlEscape.replaceEveryLiteral(withoutCarriageReturns, "\n", " ");
1998
- const toUnion = (tokens) => tokens.map((t) => `'${htmlEscape.escapeSingleQuotedString(t)}'`).join(" | ");
1999
- const quoteKey = (key) => /^[a-z_$][\w$]*$/i.test(key) ? key : `'${htmlEscape.escapeSingleQuotedString(key)}'`;
2077
+ const withoutCarriageReturns = replaceEveryLiteral(sourceFiles.join(", "), "\r", " ");
2078
+ const sources = replaceEveryLiteral(withoutCarriageReturns, "\n", " ");
2079
+ const toUnion = (tokens) => tokens.map((t) => `'${escapeSingleQuotedString(t)}'`).join(" | ");
2080
+ const quoteKey = (key) => /^[a-z_$][\w$]*$/i.test(key) ? key : `'${escapeSingleQuotedString(key)}'`;
2000
2081
  const entries = [];
2001
2082
  if (theme.colors.length > 0) {
2002
2083
  entries.push(` colors: ${toUnion(theme.colors)};`);
@@ -2099,13 +2180,14 @@ function findOpeningTag(source, tag) {
2099
2180
  }
2100
2181
  }
2101
2182
  const _warnedClassNameAuthors = /* @__PURE__ */ new Set();
2183
+ const _warnedSafelistWriteFailures = /* @__PURE__ */ new Set();
2102
2184
  let _hasWarnedTsConfig = false;
2103
2185
  let _hasWarnedTransformCacheVersion = false;
2104
2186
  let _hasWarnedNativeFallback = false;
2105
2187
  const _loggedActiveParsers = /* @__PURE__ */ new Set();
2106
- const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.RGzhYt-D.cjs', document.baseURI).href)));
2188
+ const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.8KYddE6x.cjs', document.baseURI).href)));
2107
2189
  const PLUGIN_VERSION = findPackageVersionFromFile(
2108
- node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.RGzhYt-D.cjs', document.baseURI).href))),
2190
+ node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.8KYddE6x.cjs', document.baseURI).href))),
2109
2191
  UNKNOWN_PACKAGE_VERSION
2110
2192
  );
2111
2193
  const COMPILER_VERSION = findPackageVersionFromModule("@csszyx/compiler", UNKNOWN_PACKAGE_VERSION);
@@ -2133,41 +2215,6 @@ function resolveNativeCacheIdentity() {
2133
2215
  }
2134
2216
  const BENCH_TRACE_ENABLED = process.env.CSSZYX_BENCH_TRACE === "1";
2135
2217
  const BENCH_TRACE_FILE = process.env.CSSZYX_BENCH_TRACE_FILE;
2136
- function appendTailwindSourceDirective(code, relPath) {
2137
- const directive = `@source "${relPath}";`;
2138
- if (code.includes(directive)) {
2139
- return null;
2140
- }
2141
- const separator = code.length === 0 || code.endsWith("\n") ? "" : "\n";
2142
- return `${code}${separator}${directive}
2143
- `;
2144
- }
2145
- function stripCssBlockComments(code) {
2146
- const SLASH = 47;
2147
- const STAR = 42;
2148
- let out = "";
2149
- let last = 0;
2150
- let i = 0;
2151
- const n = code.length;
2152
- while (i < n) {
2153
- if (code.codePointAt(i) === SLASH && code.codePointAt(i + 1) === STAR) {
2154
- out += code.slice(last, i);
2155
- i += 2;
2156
- while (i < n && !(code.codePointAt(i) === STAR && code.codePointAt(i + 1) === SLASH)) {
2157
- i++;
2158
- }
2159
- i += 2;
2160
- last = i;
2161
- } else {
2162
- i++;
2163
- }
2164
- }
2165
- return out + code.slice(last);
2166
- }
2167
- function cssImportsTailwind(code) {
2168
- const withoutBlockComments = stripCssBlockComments(code);
2169
- return /@import\s+["']tailwindcss(?:\/[^"']*)?["']/.test(withoutBlockComments);
2170
- }
2171
2218
  function hasInjectableTailwindCandidate(classes) {
2172
2219
  for (const c of classes) {
2173
2220
  if (c.length >= 2 && /^[a-z]/.test(c)) {
@@ -2231,7 +2278,7 @@ function tailwindImportScopesContent(css) {
2231
2278
  return false;
2232
2279
  }
2233
2280
  function cssHasContentScope(code) {
2234
- const s = stripCssBlockComments(code);
2281
+ const s = safelistSource.stripCssBlockComments(code);
2235
2282
  return tailwindImportScopesContent(s) || /@source\s+not\b/.test(s);
2236
2283
  }
2237
2284
  function isMonorepoPackage(root) {
@@ -2291,7 +2338,7 @@ function emitMissingCssFallback(quiet, message, id, emit) {
2291
2338
  ${message}`);
2292
2339
  }
2293
2340
  function normalizeForMatch(p) {
2294
- const n = transformCache.normalizePathSeparators(p);
2341
+ const n = safelistSource.normalizePathSeparators(p);
2295
2342
  return n.length > 1 && n.endsWith("/") ? n.slice(0, -1) : n;
2296
2343
  }
2297
2344
  function findJsxExpressionEnd(code, bodyStart) {
@@ -2418,15 +2465,6 @@ function watchModeMangleMessage() {
2418
2465
  function realContentHashDisabledMessage() {
2419
2466
  return "[csszyx] optimization.realContentHash is off while production.mangle is on. csszyx mangles assets after webpack computes their content hashes, and realContentHash is what recomputes those hashes from the final bytes. Without it, two builds that differ only by mangling emit the same filenames with different contents and caches keep serving the old file.";
2420
2467
  }
2421
- function computeSafelistRelPath(rootDir, safelistFilename, cssId) {
2422
- const safelistPath = transformCache.normalizePathSeparators(path__namespace.join(rootDir, safelistFilename));
2423
- const cssDir = transformCache.normalizePathSeparators(path__namespace.dirname(cssId));
2424
- let relPath = path__namespace.posix.relative(cssDir, safelistPath);
2425
- if (!relPath.startsWith(".")) {
2426
- relPath = `./${relPath}`;
2427
- }
2428
- return relPath;
2429
- }
2430
2468
  function cssVariableEntries(result) {
2431
2469
  const entries = [];
2432
2470
  for (const [original, value] of result.cssVariableMap ?? []) {
@@ -2447,7 +2485,6 @@ function recordFileVarMangleEntries(state, filename, entries) {
2447
2485
  } else {
2448
2486
  state.varMangleEntriesByFile.set(normalizedFilename, entries);
2449
2487
  }
2450
- state.varMangleMap = buildVarMangleMap(state.varMangleEntriesByFile);
2451
2488
  }
2452
2489
  function shouldTrackGlobalVarSources(config) {
2453
2490
  return config?.enabled === true;
@@ -2682,7 +2719,6 @@ function recordFileCSSVariableMetrics(state, filename, code) {
2682
2719
  state.cssVarMetricsByFile.delete(normalizedFilename);
2683
2720
  }
2684
2721
  }
2685
- state.cssVarMetrics = buildCSSVariableMetrics(state.cssVarMetricsByFile);
2686
2722
  }
2687
2723
  function collectCSSVariableMetrics(code) {
2688
2724
  const componentUses = /* @__PURE__ */ new Map();
@@ -2843,9 +2879,20 @@ function findPackageVersionFromFile(file, fallback) {
2843
2879
  }
2844
2880
  }
2845
2881
  function normalizeSourceFilename(filename) {
2846
- return transformCache.normalizePathSeparators(filename);
2882
+ return safelistSource.normalizePathSeparators(filename);
2847
2883
  }
2848
2884
  const SCRIPT_ID_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
2885
+ const STYLESHEET_FILE_EXTENSIONS = [
2886
+ ".css",
2887
+ ".pcss",
2888
+ ".postcss",
2889
+ ".scss",
2890
+ ".sass",
2891
+ ".less",
2892
+ ".styl",
2893
+ ".stylus",
2894
+ ".sss"
2895
+ ];
2849
2896
  const SOURCE_MODULE_EXTENSIONS = [...SCRIPT_ID_EXTENSIONS, ".cts", ".mts", ".cjs", ".mjs"];
2850
2897
  function matchesScriptExtension(id, extensions) {
2851
2898
  return extensions.some((ext) => id.endsWith(ext) || id.includes(`${ext}?`));
@@ -3115,20 +3162,18 @@ function createCsszyxPlugins(options = {}) {
3115
3162
  let specifierAliases = [];
3116
3163
  const mangleReserved = new Set(options.production?.mangleExclude ?? []);
3117
3164
  let mangleMapFrozen = false;
3165
+ let prescanSawServerModule = false;
3166
+ let skipRscRecords = false;
3167
+ let lastPrescanCacheMisses = 0;
3118
3168
  let frozenOwnedClasses = /* @__PURE__ */ new Set();
3119
3169
  let frozenAuthoredClasses = /* @__PURE__ */ new Set();
3120
3170
  let cssRewrittenInTransform = false;
3121
3171
  let projectCssFiles = [];
3122
3172
  const transformMangledSources = /* @__PURE__ */ new Set();
3123
3173
  const transformExternalClasses = /* @__PURE__ */ new Set();
3124
- const mangleMapDelivery = options.production?.mangleMapDelivery ?? "both";
3125
- if (!["both", "html", "bundle"].includes(mangleMapDelivery)) {
3126
- throw new Error(
3127
- `[csszyx] production.mangleMapDelivery must be 'both', 'html' or 'bundle'; got ${JSON.stringify(mangleMapDelivery)}.`
3128
- );
3174
+ if (options.production?.mangleMapDelivery !== void 0) {
3175
+ console.warn(removedMangleMapDeliveryMessage());
3129
3176
  }
3130
- const deliverMapInHtml = mangleMapDelivery !== "bundle";
3131
- const deliverMapInBundle = mangleMapDelivery !== "html";
3132
3177
  const sizeAccount = createMangleSizeAccount();
3133
3178
  const astBudgetOverride = options.build?.astBudgetLimit;
3134
3179
  const prescanAstBudget = astBudgetOverride ?? 5e5;
@@ -3139,7 +3184,6 @@ function createCsszyxPlugins(options = {}) {
3139
3184
  const globalVarMangleConfig = options.production?.mangleGlobalVars;
3140
3185
  const globalVarSourceTrackingEnabled = shouldTrackGlobalVarSources(globalVarMangleConfig);
3141
3186
  const globalVarAliasPrefix = globalVarMangleConfig?.aliasPrefix ?? types.CSSZYX_GLOBAL_ALIAS_PREFIX;
3142
- const encodedGlobalVarAliasPrefix = encodeURIComponent(globalVarAliasPrefix);
3143
3187
  const earlyGlobalVarAliasEntries = createEarlyGlobalVarAliasEntries(
3144
3188
  globalVarMangleConfig,
3145
3189
  globalVarAliasPrefix
@@ -3194,12 +3238,21 @@ function createCsszyxPlugins(options = {}) {
3194
3238
  const transformMemoryCache = /* @__PURE__ */ new Map();
3195
3239
  let transformMemoryCacheCodeChars = 0;
3196
3240
  const prescanResultHandoff = /* @__PURE__ */ new Map();
3241
+ const varMangleEntries = createLazyAggregate(
3242
+ buildVarMangleMap,
3243
+ Object.fromEntries(earlyGlobalVarAliasEntries)
3244
+ );
3245
+ const cssVarMetricTotals = createLazyAggregate(
3246
+ buildCSSVariableMetrics,
3247
+ emptyCSSVariableMetrics()
3248
+ );
3197
3249
  const state = {
3198
3250
  classes: /* @__PURE__ */ new Set(),
3199
3251
  parsedTheme: null,
3200
3252
  scanCssTheme: null,
3201
3253
  autoThemeCssFiles: [],
3202
3254
  sawTailwindEntry: false,
3255
+ tailwindEntryFiles: /* @__PURE__ */ new Set(),
3203
3256
  sawAnyCss: false,
3204
3257
  tailwindWarningEmitted: false,
3205
3258
  tailwindEntryScoped: false,
@@ -3213,10 +3266,14 @@ function createCsszyxPlugins(options = {}) {
3213
3266
  ownedClasses: /* @__PURE__ */ new Set(),
3214
3267
  authoredClasses: /* @__PURE__ */ new Set(),
3215
3268
  mangleMap: {},
3216
- varMangleEntriesByFile: /* @__PURE__ */ new Map(),
3217
- varMangleMap: Object.fromEntries(earlyGlobalVarAliasEntries),
3218
- cssVarMetricsByFile: /* @__PURE__ */ new Map(),
3219
- cssVarMetrics: emptyCSSVariableMetrics(),
3269
+ varMangleEntriesByFile: varMangleEntries,
3270
+ get varMangleMap() {
3271
+ return varMangleEntries.get();
3272
+ },
3273
+ cssVarMetricsByFile: cssVarMetricTotals,
3274
+ get cssVarMetrics() {
3275
+ return cssVarMetricTotals.get();
3276
+ },
3220
3277
  checksum: "",
3221
3278
  finalized: false,
3222
3279
  rootDir: process.cwd(),
@@ -3228,7 +3285,7 @@ function createCsszyxPlugins(options = {}) {
3228
3285
  if (earlyGlobalVarAliasEntries.length > 0) {
3229
3286
  state.varMangleEntriesByFile.set(GLOBAL_VAR_ALIAS_MAP_OWNER, earlyGlobalVarAliasEntries);
3230
3287
  }
3231
- const SAFELIST_FILENAME = "csszyx-classes.html";
3288
+ const SAFELIST_FILENAME = safelistSource.SAFELIST_FILE;
3232
3289
  const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
3233
3290
  ".tsx",
3234
3291
  ".jsx",
@@ -3381,6 +3438,7 @@ function createCsszyxPlugins(options = {}) {
3381
3438
  );
3382
3439
  if (cached) return cached;
3383
3440
  }
3441
+ lastPrescanCacheMisses++;
3384
3442
  const execution = runConfiguredParser(source, effectiveFilename, compilerOptions);
3385
3443
  if (cacheEnabled && cacheKey && execution.cacheable) {
3386
3444
  transformCache.writeTransformCache(cacheRoot, cacheInput, execution.result, cacheKey);
@@ -3467,6 +3525,7 @@ function createCsszyxPlugins(options = {}) {
3467
3525
  if (cacheEnabled) evictTransformCacheOnce();
3468
3526
  compiler.ensureRustTransformAvailable();
3469
3527
  const misses = collectRustPrescanMisses(batchable, compilerOptions, cacheRoot, results);
3528
+ lastPrescanCacheMisses += misses.length;
3470
3529
  if (misses.length > 0) {
3471
3530
  try {
3472
3531
  runRustPrescanBatch(misses, compilerOptions, cacheRoot, results);
@@ -3610,12 +3669,7 @@ function createCsszyxPlugins(options = {}) {
3610
3669
  return;
3611
3670
  }
3612
3671
  const safelistPath = path__namespace.join(state.rootDir, SAFELIST_FILENAME);
3613
- const classNames = Array.from(classes);
3614
- const classList = htmlEscape.escapeHtmlAttribute(classNames.join(" "));
3615
- const content = `<!-- Auto-generated by csszyx \u2014 DO NOT EDIT -->
3616
- <!-- Tailwind CSS scans this file for class name detection -->
3617
- <div class="${classList}"><div class="${classList}">x</div><div class="${classList}">x</div></div>
3618
- ` + htmlEscape.renderTailwindScannerCandidates(classNames);
3672
+ const content = safelistSource.renderSafelistFile(Array.from(classes));
3619
3673
  try {
3620
3674
  let existing = "";
3621
3675
  try {
@@ -3626,9 +3680,18 @@ function createCsszyxPlugins(options = {}) {
3626
3680
  }
3627
3681
  }
3628
3682
  if (existing !== content) {
3629
- fs__namespace.writeFileSync(safelistPath, content);
3683
+ safelistSource.atomicWriteFileSync(safelistPath, content);
3684
+ safelistSource.removeLegacySafelists(state.rootDir, console.warn);
3630
3685
  }
3631
- } catch {
3686
+ } catch (error) {
3687
+ if (_warnedSafelistWriteFailures.has(safelistPath)) {
3688
+ return;
3689
+ }
3690
+ _warnedSafelistWriteFailures.add(safelistPath);
3691
+ const reason = error instanceof Error ? error.message : String(error);
3692
+ console.warn(
3693
+ `[csszyx] could not write the generated safelist to ${safelistPath}: ${reason}. Tailwind scans that file for the classes csszyx found, so the CSS it generates will be missing them. Check that the directory exists and is writable.`
3694
+ );
3632
3695
  }
3633
3696
  }
3634
3697
  function recordPackagesSkipIfSz(filePath) {
@@ -3680,15 +3743,15 @@ function createCsszyxPlugins(options = {}) {
3680
3743
  function refreshSzvRegistryEntry(filePath, content) {
3681
3744
  if (!shouldProcessSource(filePath)) return;
3682
3745
  if (content === null) {
3683
- szvCrossModuleRegistry.delete(transformCache.normalizePathSeparators(filePath));
3684
- szvCrossModuleForwards.delete(transformCache.normalizePathSeparators(filePath));
3746
+ szvCrossModuleRegistry.delete(safelistSource.normalizePathSeparators(filePath));
3747
+ szvCrossModuleForwards.delete(safelistSource.normalizePathSeparators(filePath));
3685
3748
  return;
3686
3749
  }
3687
3750
  transformCache.recordSzvRegistryFile(szvCrossModuleRegistry, filePath, content);
3688
3751
  transformCache.recordCrossModuleForwards(szvCrossModuleForwards, filePath, content);
3689
3752
  if (importedStaticSzEnabled) {
3690
3753
  transformCache.recordSzObjectRegistryFile(szvCrossModuleRegistry, filePath, content);
3691
- szObjectProvidersExamined.add(transformCache.normalizePathSeparators(filePath));
3754
+ szObjectProvidersExamined.add(safelistSource.normalizePathSeparators(filePath));
3692
3755
  recordProvidersDemandedBy(filePath, content);
3693
3756
  }
3694
3757
  }
@@ -3711,7 +3774,7 @@ function createCsszyxPlugins(options = {}) {
3711
3774
  for (const specifier of queue) {
3712
3775
  const providerPath = transformCache.resolveProviderPathWith(specifier, transformCache.isReadableProviderFile);
3713
3776
  if (providerPath === void 0) continue;
3714
- const key = transformCache.normalizePathSeparators(providerPath);
3777
+ const key = safelistSource.normalizePathSeparators(providerPath);
3715
3778
  if (!szObjectProvidersExamined.has(key)) {
3716
3779
  szObjectProvidersExamined.add(key);
3717
3780
  readAndRecordSzObjectProvider(providerPath);
@@ -3735,14 +3798,14 @@ function createCsszyxPlugins(options = {}) {
3735
3798
  for (const specifier of queue) {
3736
3799
  const providerPath = transformCache.resolveProviderPath(seenSourcePaths, specifier);
3737
3800
  if (providerPath === void 0) continue;
3738
- szObjectProvidersExamined.add(transformCache.normalizePathSeparators(providerPath));
3801
+ szObjectProvidersExamined.add(safelistSource.normalizePathSeparators(providerPath));
3739
3802
  readAndRecordSzObjectProvider(providerPath);
3740
3803
  enqueueForwardedProviders(providerPath, queue, queued);
3741
3804
  }
3742
3805
  }
3743
3806
  function enqueueForwardedProviders(providerPath, queue, queued) {
3744
3807
  const directory = path__namespace.dirname(providerPath);
3745
- for (const forward of szvCrossModuleForwards.get(transformCache.normalizePathSeparators(providerPath)) ?? []) {
3808
+ for (const forward of szvCrossModuleForwards.get(safelistSource.normalizePathSeparators(providerPath)) ?? []) {
3746
3809
  for (const base of transformCache.specifierBases(forward.specifier, directory, specifierAliases)) {
3747
3810
  if (queued.has(base)) continue;
3748
3811
  queued.add(base);
@@ -3766,6 +3829,7 @@ function createCsszyxPlugins(options = {}) {
3766
3829
  szvCrossModuleRegistry.clear();
3767
3830
  szvCrossModuleForwards.clear();
3768
3831
  szObjectProvidersExamined.clear();
3832
+ prescanSawServerModule = false;
3769
3833
  const prescanStarted = node_perf_hooks.performance.now();
3770
3834
  const discoveredClasses = /* @__PURE__ */ new Set();
3771
3835
  const rawDiscoveredClasses = /* @__PURE__ */ new Set();
@@ -3784,9 +3848,12 @@ function createCsszyxPlugins(options = {}) {
3784
3848
  return;
3785
3849
  }
3786
3850
  recordAuthoredClasses(content);
3851
+ if (!prescanSawServerModule && isRSCServerModule(content, filePath)) {
3852
+ prescanSawServerModule = true;
3853
+ }
3787
3854
  recordSzvRegistryEntries(filePath, content);
3788
3855
  transformCache.recordCrossModuleForwards(szvCrossModuleForwards, filePath, content);
3789
- seenSourcePaths.add(transformCache.normalizePathSeparators(filePath));
3856
+ seenSourcePaths.add(safelistSource.normalizePathSeparators(filePath));
3790
3857
  if (fileMayContainSafelistableSz(content)) {
3791
3858
  prescanSources.push({ filePath, content });
3792
3859
  recordSzObjectDemand(filePath, content);
@@ -3823,6 +3890,7 @@ function createCsszyxPlugins(options = {}) {
3823
3890
  }
3824
3891
  }
3825
3892
  }
3893
+ const walkStarted = node_perf_hooks.performance.now();
3826
3894
  scanDir(state.rootDir);
3827
3895
  const normRoot = normalizeForMatch(state.rootDir);
3828
3896
  for (const sourceDir of compileSourceDirs) {
@@ -3831,7 +3899,20 @@ function createCsszyxPlugins(options = {}) {
3831
3899
  }
3832
3900
  scanDir(sourceDir);
3833
3901
  }
3902
+ traceBenchTiming(
3903
+ `prescan:walk files=${seenSourcePaths.size} sz=${prescanSources.length}`,
3904
+ state.rootDir,
3905
+ node_perf_hooks.performance.now() - walkStarted
3906
+ );
3907
+ const demandStarted = node_perf_hooks.performance.now();
3834
3908
  recordDemandedSzObjectProviders(seenSourcePaths, szObjectDemand);
3909
+ traceBenchTiming(
3910
+ `prescan:demand providers=${szObjectProvidersExamined.size}`,
3911
+ state.rootDir,
3912
+ node_perf_hooks.performance.now() - demandStarted
3913
+ );
3914
+ const batchStarted = node_perf_hooks.performance.now();
3915
+ lastPrescanCacheMisses = 0;
3835
3916
  const prescanContentByPath = new Map(
3836
3917
  prescanSources.map((file) => [file.filePath, file.content])
3837
3918
  );
@@ -3844,12 +3925,23 @@ function createCsszyxPlugins(options = {}) {
3844
3925
  rawDiscoveredClasses
3845
3926
  );
3846
3927
  }
3928
+ traceBenchTiming(
3929
+ `prescan:batch files=${prescanSources.length} misses=${lastPrescanCacheMisses}`,
3930
+ state.rootDir,
3931
+ node_perf_hooks.performance.now() - batchStarted
3932
+ );
3847
3933
  for (const cls of discoveredClasses) {
3848
3934
  addSafelistClass(cls);
3849
3935
  state.ownedClasses.add(cls);
3850
3936
  }
3851
3937
  const safelistClasses = /* @__PURE__ */ new Set([...discoveredClasses, ...rawDiscoveredClasses]);
3938
+ const safelistStarted = node_perf_hooks.performance.now();
3852
3939
  writeSafelistFile(safelistClasses);
3940
+ traceBenchTiming(
3941
+ `prescan:safelist classes=${safelistClasses.size}`,
3942
+ state.rootDir,
3943
+ node_perf_hooks.performance.now() - safelistStarted
3944
+ );
3853
3945
  traceBenchTiming("prescan", state.rootDir, node_perf_hooks.performance.now() - prescanStarted);
3854
3946
  }
3855
3947
  function collectPrescanResult(result, filePath, discoveredClasses, rawDiscoveredClasses) {
@@ -4028,6 +4120,12 @@ function createCsszyxPlugins(options = {}) {
4028
4120
  result = result.split(themeGroupsFile.CHECKSUM_PLACEHOLDER).join(state.checksum);
4029
4121
  }
4030
4122
  const isEvalWrapped = result.includes("eval(") && result.includes("sourceURL=webpack");
4123
+ if (result.includes(themeGroupsFile.CENSUS_PLACEHOLDER)) {
4124
+ const census = safeJsonForScriptTag(
4125
+ createHydrationMangleMap(state.mangleMap, state.varMangleMap)
4126
+ );
4127
+ result = result.split(themeGroupsFile.CENSUS_PLACEHOLDER).join(escapeJsonForStringLiteral(census));
4128
+ }
4031
4129
  if (result.includes(themeGroupsFile.MANGLE_MAP_PLACEHOLDER)) {
4032
4130
  const jsonMap = escapeJsonForInlineScript(JSON.stringify(state.mangleMap));
4033
4131
  const escapedMap = isEvalWrapped ? escapeForDoubleQuotedString(jsonMap) : jsonMap;
@@ -4057,14 +4155,84 @@ function createCsszyxPlugins(options = {}) {
4057
4155
  usesBoolClass: false
4058
4156
  };
4059
4157
  }
4158
+ function recordUntransformedHotFile(file, content) {
4159
+ trackGlobalVarSourceFile(file, content);
4160
+ recordFileVarMangleEntries(state, file, []);
4161
+ recordFileCSSVariableMetrics(state, file, null);
4162
+ }
4163
+ function discoverHotFileClasses(file, watcher) {
4164
+ if (!shouldProcessSource(file)) {
4165
+ return;
4166
+ }
4167
+ let fileContent, result;
4168
+ try {
4169
+ fileContent = fs__namespace.readFileSync(file, "utf-8");
4170
+ } catch {
4171
+ refreshSzvRegistryEntry(file, null);
4172
+ return;
4173
+ }
4174
+ refreshSzvRegistryEntry(file, fileContent);
4175
+ if (!fileContent.includes("sz=") && !fileContent.includes("szs=") && !/\bsz\s*:\s*["'{]/.test(fileContent)) {
4176
+ recordUntransformedHotFile(file, fileContent);
4177
+ return;
4178
+ }
4179
+ try {
4180
+ const hmrTransformStarted = node_perf_hooks.performance.now();
4181
+ result = transformConfiguredSource(fileContent, file);
4182
+ traceBenchTiming("handle-hot-update", file, node_perf_hooks.performance.now() - hmrTransformStarted);
4183
+ } catch {
4184
+ recordUntransformedHotFile(file, fileContent);
4185
+ return;
4186
+ }
4187
+ if (!result.transformed) {
4188
+ recordUntransformedHotFile(file, fileContent);
4189
+ return;
4190
+ }
4191
+ recordHotTransformResult(file, fileContent, result, watcher);
4192
+ }
4193
+ function recordHotTransformResult(file, fileContent, result, watcher) {
4194
+ const sizeBefore = state.classes.size;
4195
+ trackGlobalVarSourceFile(file, fileContent);
4196
+ for (const cls of result.classes) {
4197
+ addSafelistClass(cls);
4198
+ state.ownedClasses.add(cls);
4199
+ }
4200
+ recordFileVarMangleEntries(state, file, cssVariableEntries(result));
4201
+ recordFileCSSVariableMetrics(state, file, result.code);
4202
+ for (const [token, data] of result.recoveryTokens) {
4203
+ state.recoveryTokens.set(token, data);
4204
+ }
4205
+ if (state.classes.size > sizeBefore) {
4206
+ writeSafelistFile(state.classes);
4207
+ const safelistPath = path__namespace.join(state.rootDir, SAFELIST_FILENAME);
4208
+ watcher.emit("change", safelistPath);
4209
+ }
4210
+ }
4211
+ function tailwindEntryModules(moduleGraph) {
4212
+ const modules = [];
4213
+ for (const file of state.tailwindEntryFiles) {
4214
+ const found = moduleGraph.getModulesByFile(file);
4215
+ if (found) modules.push(...found);
4216
+ }
4217
+ return modules;
4218
+ }
4060
4219
  function transformTailwindCssEntry(code, id) {
4061
4220
  state.sawAnyCss = true;
4062
- if (!cssImportsTailwind(code)) return null;
4221
+ const [cssFile] = id.split("?");
4222
+ const legacy = safelistSource.findLegacySourceDirective(code, cssFile);
4223
+ if (legacy !== null) {
4224
+ throw new Error(safelistSource.legacySourceMessage(cssFile, legacy.target));
4225
+ }
4226
+ if (!safelistSource.cssImportsTailwind(code)) return null;
4063
4227
  state.sawTailwindEntry = true;
4228
+ const [entryFile] = id.split("?");
4229
+ if (STYLESHEET_FILE_EXTENSIONS.some((ext) => entryFile.endsWith(ext))) {
4230
+ state.tailwindEntryFiles.add(entryFile);
4231
+ }
4064
4232
  if (cssHasContentScope(code)) state.tailwindEntryScoped = true;
4065
4233
  if (!hasInjectableTailwindCandidate(state.classes)) return null;
4066
- const relPath = computeSafelistRelPath(state.rootDir, SAFELIST_FILENAME, id);
4067
- const transformed = appendTailwindSourceDirective(code, relPath);
4234
+ const relPath = safelistSource.computeSafelistRelPath(state.rootDir, SAFELIST_FILENAME, id);
4235
+ const transformed = safelistSource.appendTailwindSourceDirective(code, relPath);
4068
4236
  return transformed === null ? null : { code: transformed, map: null };
4069
4237
  }
4070
4238
  function reportTransformDiagnostics(result, id, warn) {
@@ -4132,16 +4300,16 @@ function createCsszyxPlugins(options = {}) {
4132
4300
  if (!code.includes("<html") || !/(?:layout|Root|Document|app)\.tsx?$/i.test(id)) {
4133
4301
  return null;
4134
4302
  }
4135
- let transformedCode = code;
4136
4303
  const attrName = options.production?.minify ? "data-sz-cs" : "data-sz-checksum";
4137
- const htmlTag = findOpeningTag(transformedCode, "html");
4138
- if (htmlTag) {
4139
- transformedCode = `${transformedCode.slice(0, htmlTag.close)} ${attrName}="${themeGroupsFile.CHECKSUM_PLACEHOLDER}"${transformedCode.slice(htmlTag.close)}`;
4304
+ const htmlTag = findOpeningTag(code, "html");
4305
+ if (!htmlTag) {
4306
+ return code;
4140
4307
  }
4141
- const debugScript = `<script dangerouslySetInnerHTML={{__html: \`(function(){var m=${themeGroupsFile.MANGLE_MAP_PLACEHOLDER};var vm=${themeGroupsFile.VAR_MANGLE_MAP_PLACEHOLDER};var gp=decodeURIComponent(${escapeJsonForInlineScript(JSON.stringify(encodedGlobalVarAliasPrefix))});var r={};var vr={};for(var k in m)r[m[k]]=k;for(var vk in vm){var vv=vm[vk];var vs=Array.isArray(vv)?vv:[vv];for(var vi=0;vi<vs.length;vi++)(vr[vs[vi]]||(vr[vs[vi]]=[])).push(vk)}window.__csszyx={mangleMap:m,varMangleMap:vm,checksum:"${themeGroupsFile.CHECKSUM_PLACEHOLDER}",decode:function(c){return r[c]},encode:function(c){return m[c]},decodeVar:function(v){return vr[v]||[]},encodeVar:function(v){return vm[v]},decodeGlobalVar:function(v){var a=vr[v]||[];return v.indexOf(gp)===0?a[0]:void 0},decodeAll:function(el){return(el.className||"").split(" ").map(function(c){return r[c]||c})}}})()\`}} />`;
4308
+ let transformedCode = `${code.slice(0, htmlTag.close)} ${attrName}="${themeGroupsFile.CHECKSUM_PLACEHOLDER}"${code.slice(htmlTag.close)}`;
4309
+ const censusTag = `<script id="__CSSZYX_MANGLE_MAP__" type="application/json" dangerouslySetInnerHTML={{__html: \`${themeGroupsFile.CENSUS_PLACEHOLDER}\`}} />`;
4142
4310
  const bodyTag = findOpeningTag(transformedCode, "body");
4143
4311
  if (bodyTag) {
4144
- transformedCode = `${transformedCode.slice(0, bodyTag.close + 1)}${debugScript}${transformedCode.slice(bodyTag.close + 1)}`;
4312
+ transformedCode = `${transformedCode.slice(0, bodyTag.close + 1)}${censusTag}${transformedCode.slice(bodyTag.close + 1)}`;
4145
4313
  }
4146
4314
  return transformedCode;
4147
4315
  }
@@ -4207,12 +4375,22 @@ ${transformedCode}`;
4207
4375
  if (activeFramework !== "vite" && activeFramework !== "rollup") {
4208
4376
  return null;
4209
4377
  }
4210
- if (!manglingEnabled || !deliverMapInBundle || !shouldProcessSource(id) || !MANGLE_RUNTIME_CONSUMER_RE.test(transformedCode) || transformedCode.includes(themeGroupsFile.MANGLE_RUNTIME_VIRTUAL_ID)) {
4378
+ if (!manglingEnabled || !shouldProcessSource(id) || !MANGLE_RUNTIME_CONSUMER_RE.test(transformedCode) || transformedCode.includes(themeGroupsFile.MANGLE_RUNTIME_VIRTUAL_ID)) {
4211
4379
  return null;
4212
4380
  }
4213
4381
  return insertRuntimeImport(transformedCode, `import '${themeGroupsFile.MANGLE_RUNTIME_VIRTUAL_ID}';
4214
4382
  `);
4215
4383
  }
4384
+ function applyWebpackMangleRuntimeEntry(compiler) {
4385
+ const root = compiler.context;
4386
+ const file = ensureMangleRuntimeFile(
4387
+ path__namespace.join(root, ".csszyx"),
4388
+ globalVarAliasPrefix,
4389
+ options.production?.mangleDebugGlobal === true
4390
+ );
4391
+ if (file === null) return;
4392
+ applyMangleRuntimeEntry(compiler, root, file, () => sizeAccount.channels.add("bundle"));
4393
+ }
4216
4394
  function collectPreTransformClasses(output) {
4217
4395
  if (!output.transformed && !output.code.includes("class=") && !output.code.includes("className=")) {
4218
4396
  return null;
@@ -4278,7 +4456,10 @@ ${transformedCode}`;
4278
4456
  }
4279
4457
  if (id === themeGroupsFile.RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID) {
4280
4458
  sizeAccount.channels.add("bundle");
4281
- return themeGroupsFile.createMangleRuntimeModule(globalVarAliasPrefix);
4459
+ return themeGroupsFile.createMangleRuntimeModule(
4460
+ globalVarAliasPrefix,
4461
+ options.production?.mangleDebugGlobal === true
4462
+ );
4282
4463
  }
4283
4464
  if (id === themeGroupsFile.RESOLVED_THEME_GROUPS_VIRTUAL_ID) {
4284
4465
  return themeGroupsFile.createThemeGroupsModule(themeGroupTokens());
@@ -4356,8 +4537,10 @@ ${transformedCode}`;
4356
4537
  }
4357
4538
  if (matchesScriptExtension(id, SCRIPT_ID_EXTENSIONS)) {
4358
4539
  assertNoRSCBoundaryViolation(output.code, id);
4359
- const record = createRSCModuleRecord(output.code, id);
4360
- state.rscModules.set(record.id, record);
4540
+ if (!skipRscRecords) {
4541
+ const record = createRSCModuleRecord(output.code, id);
4542
+ state.rscModules.set(record.id, record);
4543
+ }
4361
4544
  }
4362
4545
  return collectPreTransformClasses(output);
4363
4546
  },
@@ -4434,10 +4617,8 @@ ${transformedCode}`;
4434
4617
  if (compiler.options?.mode === "development") {
4435
4618
  manglingEnabled = false;
4436
4619
  }
4437
- if (manglingEnabled && mangleMapDelivery !== "both") {
4438
- console.warn(
4439
- `[csszyx] production.mangleMapDelivery: '${mangleMapDelivery}' has no effect on the webpack lane \u2014 map delivery only narrows on vite/rollup builds.`
4440
- );
4620
+ if (manglingEnabled) {
4621
+ applyWebpackMangleRuntimeEntry(compiler);
4441
4622
  }
4442
4623
  compiler.hooks.beforeCompile.tap("csszyx:prescan", () => {
4443
4624
  announceActiveParser();
@@ -4496,6 +4677,7 @@ ${transformedCode}`;
4496
4677
  }
4497
4678
  evictTransformCacheOnce();
4498
4679
  prescanAndWriteClasses();
4680
+ skipRscRecords = config.command === "build" && !config.build?.watch && !prescanSawServerModule;
4499
4681
  state.scanCssTheme = runThemeScan(root, options.build?.scanCss) ?? state.scanCssTheme;
4500
4682
  runAutoThemeScan(root);
4501
4683
  if (config.command === "build") {
@@ -4509,11 +4691,36 @@ ${transformedCode}`;
4509
4691
  },
4510
4692
  /**
4511
4693
  * Vite HMR hook: re-runs theme scan when a watched CSS file changes,
4512
- * and incrementally updates csszyx-classes.html when a source file gains new sz classes.
4513
- * @param ctx - HMR context containing the changed file
4694
+ * and incrementally updates the safelist when a source file gains new sz classes.
4695
+ *
4696
+ * `hotUpdate` rather than `handleHotUpdate` because the safelist
4697
+ * can arrive as a CREATE. `writeSafelistFile` returns early on an
4698
+ * empty class set, so a project with no `sz` at prescan has no
4699
+ * safelist file, and the first `sz` edit makes one. Vite routes a
4700
+ * create to `hotUpdate` only — its `handleHotUpdate` branch runs
4701
+ * for `type === 'update'` and nothing else — so the legacy hook
4702
+ * left that one event to `@tailwindcss/vite`, which answers a
4703
+ * scanned file whose only modules are asset nodes with an
4704
+ * unaddressed `full-reload`.
4705
+ *
4706
+ * @param this - Vite's plugin context for the pass being run.
4707
+ * @param this.environment - The environment this pass belongs to,
4708
+ * absent when a host calls the hook without one.
4709
+ * @param this.environment.name - `client` for the pass that owns
4710
+ * the page; `ssr` and any custom environment follow it.
4711
+ * @param this.environment.moduleGraph - That environment's own
4712
+ * graph, the one Vite replaces with this hook's answer.
4713
+ * @param ctx - HMR context: the changed file, why it changed, and
4714
+ * the dev server.
4715
+ * @returns The modules a safelist write affects, so Vite hot-updates
4716
+ * the stylesheet instead of reloading the page; undefined otherwise,
4717
+ * which leaves Vite's own handling in place.
4514
4718
  */
4515
- handleHotUpdate(ctx) {
4516
- prescanResultHandoff.clear();
4719
+ hotUpdate(ctx) {
4720
+ const isClientPass = (this.environment?.name ?? "client") === "client";
4721
+ if (isClientPass) {
4722
+ prescanResultHandoff.clear();
4723
+ }
4517
4724
  const scanCss = options.build?.scanCss;
4518
4725
  const reloadThemeGroupsModule = () => {
4519
4726
  const themeGroupsModule = ctx.server.moduleGraph.getModuleById(
@@ -4523,7 +4730,7 @@ ${transformedCode}`;
4523
4730
  ctx.server.moduleGraph.invalidateModule(themeGroupsModule);
4524
4731
  }
4525
4732
  };
4526
- if (ctx.file.endsWith(".css")) {
4733
+ if (isClientPass && ctx.file.endsWith(".css")) {
4527
4734
  const root = ctx.server.config.root || process.cwd();
4528
4735
  const before = themeGroupsFile.createThemeGroupsModule(themeGroupTokens());
4529
4736
  if (scanCss && matchesAnyPattern(ctx.file, scanCss, root)) {
@@ -4535,59 +4742,13 @@ ${transformedCode}`;
4535
4742
  ctx.server.ws.send({ type: "full-reload" });
4536
4743
  }
4537
4744
  }
4538
- if (!shouldProcessSource(ctx.file)) {
4539
- return;
4540
- }
4541
- let fileContent, result;
4542
- try {
4543
- fileContent = fs__namespace.readFileSync(ctx.file, "utf-8");
4544
- } catch {
4545
- refreshSzvRegistryEntry(ctx.file, null);
4546
- return;
4547
- }
4548
- refreshSzvRegistryEntry(ctx.file, fileContent);
4549
- if (!fileContent.includes("sz=") && !fileContent.includes("szs=") && !/\bsz\s*:\s*["'{]/.test(fileContent)) {
4550
- trackGlobalVarSourceFile(ctx.file, fileContent);
4551
- recordFileVarMangleEntries(state, ctx.file, []);
4552
- recordFileCSSVariableMetrics(state, ctx.file, null);
4553
- return;
4554
- }
4555
- try {
4556
- const hmrTransformStarted = node_perf_hooks.performance.now();
4557
- result = transformConfiguredSource(fileContent, ctx.file);
4558
- traceBenchTiming(
4559
- "handle-hot-update",
4560
- ctx.file,
4561
- node_perf_hooks.performance.now() - hmrTransformStarted
4745
+ if (safelistSource.normalizePathSeparators(ctx.file) === safelistSource.normalizePathSeparators(path__namespace.join(state.rootDir, SAFELIST_FILENAME))) {
4746
+ return tailwindEntryModules(
4747
+ this.environment?.moduleGraph ?? ctx.server.environments.client.moduleGraph
4562
4748
  );
4563
- } catch {
4564
- trackGlobalVarSourceFile(ctx.file, fileContent);
4565
- recordFileVarMangleEntries(state, ctx.file, []);
4566
- recordFileCSSVariableMetrics(state, ctx.file, null);
4567
- return;
4568
- }
4569
- if (!result.transformed) {
4570
- trackGlobalVarSourceFile(ctx.file, fileContent);
4571
- recordFileVarMangleEntries(state, ctx.file, []);
4572
- recordFileCSSVariableMetrics(state, ctx.file, null);
4573
- return;
4574
- }
4575
- const sizeBefore = state.classes.size;
4576
- trackGlobalVarSourceFile(ctx.file, fileContent);
4577
- for (const cls of result.classes) {
4578
- addSafelistClass(cls);
4579
- state.ownedClasses.add(cls);
4580
- }
4581
- recordFileVarMangleEntries(state, ctx.file, cssVariableEntries(result));
4582
- recordFileCSSVariableMetrics(state, ctx.file, result.code);
4583
- for (const [token, data] of result.recoveryTokens) {
4584
- state.recoveryTokens.set(token, data);
4585
- }
4586
- if (state.classes.size > sizeBefore) {
4587
- writeSafelistFile(state.classes);
4588
- const safelistPath = path__namespace.join(state.rootDir, SAFELIST_FILENAME);
4589
- ctx.server.watcher.emit("change", safelistPath);
4590
4749
  }
4750
+ if (isClientPass) discoverHotFileClasses(ctx.file, ctx.server.watcher);
4751
+ return void 0;
4591
4752
  },
4592
4753
  transformIndexHtml: {
4593
4754
  order: "pre",
@@ -4601,13 +4762,11 @@ ${transformedCode}`;
4601
4762
  finalizeMangleMap();
4602
4763
  const injectedMangleMap = manglingEnabled ? state.mangleMap : {};
4603
4764
  let result = transformIndexHtml(html, injectedMangleMap, state.checksum, {
4604
- // Always 'script'; the checksum itself is injected by
4605
- // injectHydrationData regardless of this mode.
4765
+ // Always 'script' the inert JSON census; the
4766
+ // checksum attribute is injected regardless.
4606
4767
  mode: "script",
4607
4768
  minify: process.env.NODE_ENV === "production",
4608
- varMangleMap: state.varMangleMap,
4609
- globalVarAliasPrefix,
4610
- installRuntimeObject: deliverMapInHtml
4769
+ varMangleMap: state.varMangleMap
4611
4770
  });
4612
4771
  if (manglingEnabled) {
4613
4772
  sizeAccount.channels.add("html");
@@ -4628,6 +4787,18 @@ ${transformedCode}`;
4628
4787
  }
4629
4788
  result = injectRecoveryManifest(result, manifest);
4630
4789
  }
4790
+ if (needsRuntimeMangleRegistration(manglingEnabled, injectedMangleMap)) {
4791
+ return {
4792
+ html: result,
4793
+ tags: [
4794
+ {
4795
+ tag: "script",
4796
+ attrs: { type: "module", src: themeGroupsFile.MANGLE_RUNTIME_VIRTUAL_ID },
4797
+ injectTo: "head-prepend"
4798
+ }
4799
+ ]
4800
+ };
4801
+ }
4631
4802
  return result;
4632
4803
  }
4633
4804
  }
@@ -4980,17 +5151,14 @@ const esbuildPlugin = (options = {}) => {
4980
5151
  };
4981
5152
 
4982
5153
  exports.allocateMangleTokens = allocateMangleTokens;
4983
- exports.appendTailwindSourceDirective = appendTailwindSourceDirective;
4984
5154
  exports.assertNoRSCBoundaryViolation = assertNoRSCBoundaryViolation;
4985
5155
  exports.assertNoRSCGraphViolation = assertNoRSCGraphViolation;
4986
5156
  exports.collectMangleHybridHazards = collectMangleHybridHazards;
4987
- exports.computeSafelistRelPath = computeSafelistRelPath;
4988
5157
  exports.createGlobalVarAliasValidationOptions = createGlobalVarAliasValidationOptions;
4989
5158
  exports.createGlobalVarMapAssetSource = createGlobalVarMapAssetSource;
4990
5159
  exports.createGlobalVarScanCacheKey = createGlobalVarScanCacheKey;
4991
5160
  exports.createRSCModuleRecord = createRSCModuleRecord;
4992
5161
  exports.cssHasContentScope = cssHasContentScope;
4993
- exports.cssImportsTailwind = cssImportsTailwind;
4994
5162
  exports.deleteRSCModuleRecord = deleteRSCModuleRecord;
4995
5163
  exports.emitMissingCssFallback = emitMissingCssFallback;
4996
5164
  exports.esbuildPlugin = esbuildPlugin;