@tenphi/tasty 3.10.0 → 3.11.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 (88) hide show
  1. package/README.md +403 -380
  2. package/dist/{babel-types-C_7kRP38.d.ts → babel-types-BKDTT4--.d.ts} +2 -2
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/{build-config-l2Ys-AJr.js → build-config-5d8WlQbq.js} +5 -5
  6. package/dist/chunks/{build-config-l2Ys-AJr.js.map → build-config-5d8WlQbq.js.map} +1 -1
  7. package/dist/chunks/{collector-CaNtsRtn.js → collector-CjCak4iE.js} +4 -4
  8. package/dist/chunks/{collector-CaNtsRtn.js.map → collector-CjCak4iE.js.map} +1 -1
  9. package/dist/chunks/{config-engine-CpExZO_T.js → config-engine-uOFYZidB.js} +4 -4
  10. package/dist/chunks/{config-engine-CpExZO_T.js.map → config-engine-uOFYZidB.js.map} +1 -1
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/{css-definitions-DAIJxzFY.js → css-definitions-ubrHP97m.js} +88 -77
  14. package/dist/chunks/css-definitions-ubrHP97m.js.map +1 -0
  15. package/dist/chunks/{debug-CKy49GEr.js → debug-CJ31U_WE.js} +6 -6
  16. package/dist/chunks/{debug-CKy49GEr.js.map → debug-CJ31U_WE.js.map} +1 -1
  17. package/dist/chunks/{dsl-DRhFWQzo.js → dsl-DYSJc1-T.js} +11 -6
  18. package/dist/chunks/dsl-DYSJc1-T.js.map +1 -0
  19. package/dist/chunks/{react-runtime-oi6i3ELR.js → react-runtime-CyyCI02N.js} +168 -61
  20. package/dist/chunks/react-runtime-CyyCI02N.js.map +1 -0
  21. package/dist/chunks/{runtime-engine-DoULyhPt.js → runtime-engine-BQmOu5-W.js} +53 -36
  22. package/dist/chunks/runtime-engine-BQmOu5-W.js.map +1 -0
  23. package/dist/chunks/{runtime-state-CZ2J5QiZ.js → runtime-state-DEsyUMU-.js} +14 -3
  24. package/dist/chunks/runtime-state-DEsyUMU-.js.map +1 -0
  25. package/dist/chunks/{style-engine-CeKsjtIr.js → style-engine-BX2LshDZ.js} +116 -56
  26. package/dist/chunks/style-engine-BX2LshDZ.js.map +1 -0
  27. package/dist/chunks/{zero-engine-fxKu8Jbn.js → zero-engine-Dw0P4yGM.js} +22 -7
  28. package/dist/chunks/zero-engine-Dw0P4yGM.js.map +1 -0
  29. package/dist/{collector-w4mBj5gd.d.ts → collector-CTU-nl0g.d.ts} +2 -2
  30. package/dist/{config-CrZOfNJ5.d.ts → config-CcxqSZI2.d.ts} +28 -9
  31. package/dist/core/index.d.ts +4 -4
  32. package/dist/core/index.js +7 -7
  33. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  34. package/dist/{index-CYJtAI9a.d.ts → index--GdqCPlp.d.ts} +58 -16
  35. package/dist/index.d.ts +4 -4
  36. package/dist/index.js +8 -8
  37. package/dist/{merge-styles-VXwJ0Frr.d.ts → merge-styles-DSkVc6CD.d.ts} +2 -2
  38. package/dist/ssr/astro.js +4 -4
  39. package/dist/ssr/client.d.ts +2 -0
  40. package/dist/ssr/client.js +2 -0
  41. package/dist/ssr/index.d.ts +3 -22
  42. package/dist/ssr/index.js +4 -4
  43. package/dist/ssr/index.js.map +1 -1
  44. package/dist/ssr/next-config.d.ts +1 -1
  45. package/dist/ssr/next-config.js +6 -17
  46. package/dist/ssr/next-config.js.map +1 -1
  47. package/dist/ssr/next.d.ts +1 -1
  48. package/dist/ssr/next.js +3 -3
  49. package/dist/static/index.d.ts +2 -2
  50. package/dist/{types-JEY8PVYP.d.ts → types-DJEM_BOJ.d.ts} +6 -6
  51. package/dist/zero/babel.d.ts +1 -1
  52. package/dist/zero/babel.js +30 -19
  53. package/dist/zero/babel.js.map +1 -1
  54. package/dist/zero/index.d.ts +24 -6
  55. package/dist/zero/index.js +4 -4
  56. package/dist/zero/index.js.map +1 -1
  57. package/dist/zero/next.d.ts +1 -1
  58. package/dist/zero/next.js +3 -7
  59. package/dist/zero/next.js.map +1 -1
  60. package/docs/README.md +4 -1
  61. package/docs/adoption.md +25 -17
  62. package/docs/ai-agents.md +39 -34
  63. package/docs/comparison.md +9 -8
  64. package/docs/configuration.md +174 -58
  65. package/docs/debug.md +3 -2
  66. package/docs/design-system.md +117 -15
  67. package/docs/dsl.md +145 -81
  68. package/docs/getting-started.md +81 -24
  69. package/docs/injector.md +41 -40
  70. package/docs/methodology.md +46 -21
  71. package/docs/migration-v3.md +3 -3
  72. package/docs/pipeline.md +19 -16
  73. package/docs/plugins.md +21 -41
  74. package/docs/react-api.md +61 -9
  75. package/docs/runtime-benchmarks.md +4 -4
  76. package/docs/ssr.md +92 -66
  77. package/docs/styles.md +33 -17
  78. package/docs/tasty-static.md +129 -58
  79. package/package.json +23 -9
  80. package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
  81. package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
  82. package/dist/chunks/css-definitions-DAIJxzFY.js.map +0 -1
  83. package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
  84. package/dist/chunks/react-runtime-oi6i3ELR.js.map +0 -1
  85. package/dist/chunks/runtime-engine-DoULyhPt.js.map +0 -1
  86. package/dist/chunks/runtime-state-CZ2J5QiZ.js.map +0 -1
  87. package/dist/chunks/style-engine-CeKsjtIr.js.map +0 -1
  88. package/dist/chunks/zero-engine-fxKu8Jbn.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { f as parseStyle, j as normalizeDslName, m as resetGlobalPredefinedTokens, p as resetGlobalParseFunctions, u as normalizeColorTokenValue, w as Lru } from "./dsl-DRhFWQzo.js";
2
- import { i as warn, n as isSelector, o as isDevEnv, r as resetStyleWarnings } from "./shared-utils-y-HjvPN4.js";
3
- import { A as rscClassRegexGlobal, B as extractLocalFunctions, D as makeClassName, F as getEffectiveDefinition, G as parseFunctionName, H as formatFunctionPrelude, J as resetFunctionPolyfills, L as normalizePropertyDefinition, M as validateNamePrefix, N as hashString, P as extractLocalProperties, R as parsePropertyToken, S as formatFontFaceRule, U as formatFunctionRule, V as formatFunctionDeclarations, _ as formatCounterStyleRule, b as fontFaceContentHash, c as extractLocalKeyframes, d as mergeKeyframes, f as replaceAnimationNames, g as formatCounterStyleDeclarations, h as extractLocalCounterStyle, i as formatKeyframesCSS, j as tastyClassRegex, k as makeKeyframeName, l as filterUsedKeyframes, m as resolveSelectorKeyframes, o as formatPropertyCSS, p as resolveKeyframesNames, q as registerLocalFunctionPolyfills, r as formatRules, s as extractAnimationNamesFromStyles, u as hasLocalKeyframes, w as PropertyTypeResolver, x as formatFontFaceDeclarations, y as extractLocalFontFace } from "./css-definitions-DAIJxzFY.js";
4
- import { C as camelToKebab, J as markStylesGeneratedState, K as hasStylesGenerated, M as createStyle, T as STYLE_HANDLER_MAP, V as resetStyleChunks, X as resetStylesGeneratedState, Y as resetGlobalPolyfillsState, a as registerBaseStyleProps, b as renderStyles, k as resetHandlers, n as generateChunkCacheKey, o as resetBaseStyleProps, q as isFunctionsPolyfillEnabled, r as categorizeStyleKeys, t as renderStylesForChunk, w as splitSelectorsSafely, y as clearPipelineCache } from "./style-engine-CeKsjtIr.js";
5
- import { n as applyStyleConfig, r as normalizeConfig, t as resolveRecipesWith } from "./config-engine-CpExZO_T.js";
6
- import { _ as mergeGlobalProperties, a as getGlobalConfigTokens, b as setRuntimeConfigState, c as getGlobalFunctions, f as mergeGlobalConfigTokens, g as mergeGlobalKeyframes, h as mergeGlobalFunctions, i as getEffectiveProperties, l as getGlobalKeyframes, m as mergeGlobalFontFaces, o as getGlobalCounterStyles, p as mergeGlobalCounterStyles, s as getGlobalFontFaces, t as getRegisteredSSRCollector, u as getGlobalStyles, v as mergeGlobalStyles, y as resetConfigResources } from "./runtime-state-CZ2J5QiZ.js";
1
+ import { f as parseStyle, j as normalizeDslName, m as resetGlobalPredefinedTokens, p as resetGlobalParseFunctions, u as normalizeColorTokenValue, w as Lru } from "./dsl-DYSJc1-T.js";
2
+ import { a as warnOnceDev, i as warn, n as isSelector, o as isDevEnv, r as resetStyleWarnings } from "./shared-utils-y-HjvPN4.js";
3
+ import { A as rscClassRegexGlobal, B as parsePropertyToken, D as makeClassName, F as extractLocalProperties, H as formatFunctionDeclarations, I as getEffectiveDefinition, J as registerLocalFunctionPolyfills, K as parseFunctionName, M as validateNamePrefix, N as hashString, S as formatFontFaceRule, U as formatFunctionPrelude, V as extractLocalFunctions, W as formatFunctionRule, Y as resetFunctionPolyfills, _ as formatCounterStyleRule, b as fontFaceContentHash, c as extractLocalKeyframes, d as mergeKeyframes, f as replaceAnimationNames, g as formatCounterStyleDeclarations, h as extractLocalCounterStyle, i as formatKeyframesCSS, j as tastyClassRegex, k as makeKeyframeName, l as filterUsedKeyframes, m as resolveSelectorKeyframes, o as formatPropertyCSS, p as resolveKeyframesNames, r as formatRules, s as extractAnimationNamesFromStyles, u as hasLocalKeyframes, w as PropertyTypeResolver, x as formatFontFaceDeclarations, y as extractLocalFontFace, z as normalizePropertyDefinition } from "./css-definitions-ubrHP97m.js";
4
+ import { C as camelToKebab, J as markStylesGeneratedState, K as hasStylesGenerated, M as createStyle, T as STYLE_HANDLER_MAP, V as resetStyleChunks, X as resetStylesGeneratedState, Y as resetGlobalPolyfillsState, a as registerBaseStyleProps, b as renderStyles, k as resetHandlers, n as generateChunkCacheKey, o as resetBaseStyleProps, q as isFunctionsPolyfillEnabled, r as categorizeStyleKeys, t as renderStylesForChunk, w as splitSelectorsSafely, y as clearPipelineCache } from "./style-engine-BX2LshDZ.js";
5
+ import { n as applyStyleConfig, r as normalizeConfig, t as resolveRecipesWith } from "./config-engine-uOFYZidB.js";
6
+ import { _ as mergeGlobalKeyframes, a as getEffectivePropertiesByName, b as resetConfigResources, c as getGlobalFontFaces, d as getGlobalStyles, g as mergeGlobalFunctions, h as mergeGlobalFontFaces, i as getEffectiveProperties, l as getGlobalFunctions, m as mergeGlobalCounterStyles, o as getGlobalConfigTokens, p as mergeGlobalConfigTokens, s as getGlobalCounterStyles, t as getRegisteredSSRCollector, u as getGlobalKeyframes, v as mergeGlobalProperties, x as setRuntimeConfigState, y as mergeGlobalStyles } from "./runtime-state-DEsyUMU-.js";
7
7
  import React from "react";
8
8
  //#region src/prop-handlers.ts
9
9
  const GTKEY = "__tasty_prop_handlers__";
@@ -938,6 +938,9 @@ function registerHydratedClass(registry, className) {
938
938
  });
939
939
  registry.pinCounts.set(className, 0);
940
940
  }
941
+ function isPreAllocated(ruleInfo) {
942
+ return ruleInfo.ruleIndex === -1 && ruleInfo.sheetIndex === -1;
943
+ }
941
944
  var StyleInjector = class {
942
945
  sheetManager;
943
946
  config;
@@ -946,6 +949,7 @@ var StyleInjector = class {
946
949
  namePrefix;
947
950
  classRegex;
948
951
  rscClassRegex;
952
+ evictions = 0;
949
953
  get _sheetManager() {
950
954
  return this.sheetManager;
951
955
  }
@@ -1040,6 +1044,18 @@ var StyleInjector = class {
1040
1044
  isNewAllocation: true
1041
1045
  };
1042
1046
  }
1047
+ reuseInjected(registry, className, pin) {
1048
+ registry.unusedSince.delete(className);
1049
+ if (pin) {
1050
+ const pins = registry.pinCounts.get(className) || 0;
1051
+ registry.pinCounts.set(className, pins + 1);
1052
+ }
1053
+ if (registry.metrics) registry.metrics.hits++;
1054
+ return {
1055
+ className,
1056
+ dispose: pin ? () => this.unpin(className, registry) : noop
1057
+ };
1058
+ }
1043
1059
  inject(rules, options) {
1044
1060
  const root = options?.root || document;
1045
1061
  const registry = this.sheetManager.getRegistry(root);
@@ -1052,28 +1068,7 @@ var StyleInjector = class {
1052
1068
  let className;
1053
1069
  if (cacheKey && registry.cacheKeyToClassName.has(cacheKey)) {
1054
1070
  className = registry.cacheKeyToClassName.get(cacheKey);
1055
- const existingRuleInfo = registry.rules.get(className);
1056
- if (existingRuleInfo.ruleIndex === -3) {
1057
- registry.unusedSince.delete(className);
1058
- if (pin) registry.pinCounts.set(className, (registry.pinCounts.get(className) || 0) + 1);
1059
- if (registry.metrics) registry.metrics.hits++;
1060
- return {
1061
- className,
1062
- dispose: pin ? () => this.unpin(className, registry) : noop
1063
- };
1064
- }
1065
- if (!(existingRuleInfo.ruleIndex === -1 && existingRuleInfo.sheetIndex === -1)) {
1066
- registry.unusedSince.delete(className);
1067
- if (pin) {
1068
- const pins = registry.pinCounts.get(className) || 0;
1069
- registry.pinCounts.set(className, pins + 1);
1070
- }
1071
- if (registry.metrics) registry.metrics.hits++;
1072
- return {
1073
- className,
1074
- dispose: pin ? () => this.unpin(className, registry) : noop
1075
- };
1076
- }
1071
+ if (!isPreAllocated(registry.rules.get(className))) return this.reuseInjected(registry, className, pin);
1077
1072
  } else if (cacheKey) {
1078
1073
  className = this.generateClassName(cacheKey);
1079
1074
  if (this.tryHydratedHit(registry, cacheKey, className)) {
@@ -1087,6 +1082,8 @@ var StyleInjector = class {
1087
1082
  } else {
1088
1083
  const parts = rules.map((r) => `${r.selector}\0${r.declarations}`);
1089
1084
  className = makeClassName(this.namePrefix, hashString(parts.join("\n")));
1085
+ const existing = registry.rules.get(className);
1086
+ if (existing && !isPreAllocated(existing)) return this.reuseInjected(registry, className, pin);
1090
1087
  }
1091
1088
  const rulesToInsert = rules.map((rule) => {
1092
1089
  let newSelector = rule.selector;
@@ -1573,12 +1570,15 @@ var StyleInjector = class {
1573
1570
  else if (unused.length > capacity) doomed = unused.slice(capacity);
1574
1571
  else return 0;
1575
1572
  if (doomed.length === 0) return 0;
1576
- return this.sheetManager.deleteClasses(registry, doomed);
1573
+ const deleted = this.sheetManager.deleteClasses(registry, doomed);
1574
+ if (deleted > 0) this.evictions++;
1575
+ return deleted;
1577
1576
  }
1578
1577
  destroy(root) {
1579
1578
  flushStyles();
1580
1579
  const targetRoot = root || document;
1581
1580
  this.sheetManager.cleanup(targetRoot);
1581
+ this.evictions++;
1582
1582
  if (this.cancelPendingGC && !this.sheetManager.hasActiveRoots()) {
1583
1583
  this.cancelPendingGC();
1584
1584
  this.cancelPendingGC = null;
@@ -1936,6 +1936,16 @@ const createRSCCache = () => ({
1936
1936
  generatedNames: /* @__PURE__ */ new Map()
1937
1937
  });
1938
1938
  const getRSCCache = typeof React.cache === "function" ? React.cache(createRSCCache) : createRSCCache;
1939
+ let requestScopeMissing = false;
1940
+ function checkRequestScope() {
1941
+ if (requestScopeMissing) return;
1942
+ const rscCache = getRSCCache();
1943
+ if (rscCache.scopeChecked) return;
1944
+ rscCache.scopeChecked = true;
1945
+ if (getRSCCache() === rscCache) return;
1946
+ requestScopeMissing = true;
1947
+ warnOnceDev("rsc-request-scope", "Server rendering without a style collector, outside React Server Components. Each tasty() element inlines all of its CSS, and configured globals (tokens, @property defaults such as --gap, globalStyles, @font-face) and the CSS of useGlobalStyles(), useRawCSS(), useKeyframes() and the other style functions are not emitted. Use tastyIntegration() in Astro, TastyRegistry in Next.js, or runWithCollector() from @tenphi/tasty/ssr elsewhere.");
1948
+ }
1939
1949
  function rscAllocateClassName(rscCache, cacheKey) {
1940
1950
  const existing = rscCache.cacheKeyToClassName.get(cacheKey);
1941
1951
  if (existing) return {
@@ -1969,16 +1979,22 @@ function pushRSCCSS(rscCache, key, css, replace) {
1969
1979
  rscCache.pendingCSS.push(css);
1970
1980
  return true;
1971
1981
  }
1982
+ function queueRSCCSS(rscCache, css) {
1983
+ rscCache.pendingCSS.push(css);
1984
+ }
1972
1985
  function getStyleTarget() {
1973
1986
  const collector = getRegisteredSSRCollector();
1974
1987
  if (collector) return {
1975
1988
  mode: "ssr",
1976
1989
  collector
1977
1990
  };
1978
- if (typeof document === "undefined") return {
1979
- mode: "rsc",
1980
- cache: getRSCCache()
1981
- };
1991
+ if (typeof document === "undefined") {
1992
+ checkRequestScope();
1993
+ return {
1994
+ mode: "rsc",
1995
+ cache: getRSCCache()
1996
+ };
1997
+ }
1982
1998
  return { mode: "client" };
1983
1999
  }
1984
2000
  //#endregion
@@ -1992,10 +2008,11 @@ function scanAndEmitAutoProperties(rules, styles, emit) {
1992
2008
  if (parsed.isValid) registered.add(parsed.cssName);
1993
2009
  }
1994
2010
  }
2011
+ const declared = getEffectivePropertiesByName();
1995
2012
  const resolver = new PropertyTypeResolver();
1996
2013
  for (const rule of rules) {
1997
2014
  if (!rule.declarations) continue;
1998
- resolver.scanDeclarations(rule.declarations, (name) => registered.has(name), (name, syntax, initialValue) => {
2015
+ resolver.scanDeclarations(rule.declarations, (name) => registered.has(name) || declared.has(name), (name, syntax, initialValue) => {
1999
2016
  registered.add(name);
2000
2017
  const css = formatPropertyCSS(name, {
2001
2018
  syntax,
@@ -2410,6 +2427,6 @@ function depsEqual(a, b) {
2410
2427
  return true;
2411
2428
  }
2412
2429
  //#endregion
2413
- export { ownKeyframes as A, hasGlobalKeyframes as B, holdKeyframes as C, injector as D, injectRawCSS as E, configure as F, StyleInjector as G, isConfigLocked as H, getConfig as I, flushStyles as J, SheetManager as K, getGlobalInjector as L, touch as M, ChunkSheetRegistry as N, isPropertyDefined as O, chunkSheetRegistry as P, propHandlerRegistry as Q, getGlobalRecipes as R, getRawCSSText as S, injectGlobal as T, isTestEnvironment as U, hasGlobalRecipes as V, resetConfig as W, openBatchWindow as X, hasPendingStyleWrites as Y, resetStyleBatch as Z, fontFace as _, filterBaseProps as a, getCSSText as b, hasKeys as c, getStyleTarget as d, pushRSCCSS as f, destroy as g, createInjector as h, modAttrs as i, property as j, keyframes as k, collectAutoInferredProperties as l, counterStyle as m, createClientState as n, computeStyles as o, cleanup as p, closeBatchWindow as q, processTokens as r, resolveRecipes as s, depsEqual as t, collectAutoInferredPropertiesRSC as u, func as v, inject as w, getCSSTextForNode as x, gc as y, getNamePrefix as z };
2430
+ export { openBatchWindow as $, injector as A, getGlobalInjector as B, getCSSText as C, inject as D, holdKeyframes as E, touch as F, isConfigLocked as G, getNamePrefix as H, ChunkSheetRegistry as I, StyleInjector as J, isTestEnvironment as K, chunkSheetRegistry as L, keyframes as M, ownKeyframes as N, injectGlobal as O, property as P, hasPendingStyleWrites as Q, configure as R, gc as S, getRawCSSText as T, hasGlobalKeyframes as U, getGlobalRecipes as V, hasGlobalRecipes as W, closeBatchWindow as X, SheetManager as Y, flushStyles as Z, counterStyle as _, filterBaseProps as a, fontFace as b, hasKeys as c, checkRequestScope as d, resetStyleBatch as et, getRSCCache as f, cleanup as g, queueRSCCSS as h, modAttrs as i, isPropertyDefined as j, injectRawCSS as k, collectAutoInferredProperties as l, pushRSCCSS as m, createClientState as n, computeStyles as o, getStyleTarget as p, resetConfig as q, processTokens as r, resolveRecipes as s, depsEqual as t, propHandlerRegistry as tt, collectAutoInferredPropertiesRSC as u, createInjector as v, getCSSTextForNode as w, func as x, destroy as y, getConfig as z };
2414
2431
 
2415
- //# sourceMappingURL=runtime-engine-DoULyhPt.js.map
2432
+ //# sourceMappingURL=runtime-engine-BQmOu5-W.js.map