@tenphi/tasty 0.0.0-snapshot.e244fdb → 0.0.0-snapshot.e360574

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 (107) hide show
  1. package/README.md +404 -385
  2. package/dist/babel-types-BqWM62mn.d.ts +18 -0
  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-CGSGH4Sb.js +60 -0
  6. package/dist/chunks/build-config-CGSGH4Sb.js.map +1 -0
  7. package/dist/chunks/{collector-B0LTHw6Z.js → collector-CbphuMNW.js} +8 -6
  8. package/dist/chunks/collector-CbphuMNW.js.map +1 -0
  9. package/dist/chunks/{config-engine-C3pF9EK9.js → config-engine-_hRNSRwz.js} +17 -12
  10. package/dist/chunks/{config-engine-C3pF9EK9.js.map → config-engine-_hRNSRwz.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-D_it4XZH.js → css-definitions-DKApeTsI.js} +55 -30
  14. package/dist/chunks/css-definitions-DKApeTsI.js.map +1 -0
  15. package/dist/chunks/{css-resources-BN8apgxt.js → css-resources-P7IBUUZs.js} +2 -2
  16. package/dist/chunks/{css-resources-BN8apgxt.js.map → css-resources-P7IBUUZs.js.map} +1 -1
  17. package/dist/chunks/{debug-C9LeNVoJ.js → debug-Der12dU3.js} +22 -21
  18. package/dist/chunks/{debug-C9LeNVoJ.js.map → debug-Der12dU3.js.map} +1 -1
  19. package/dist/chunks/{dsl-C5yuAn41.js → dsl-Ddc5EUBK.js} +51 -41
  20. package/dist/chunks/dsl-Ddc5EUBK.js.map +1 -0
  21. package/dist/chunks/{react-runtime-O-OUrKLH.js → react-runtime-Kw_SrIv_.js} +214 -82
  22. package/dist/chunks/react-runtime-Kw_SrIv_.js.map +1 -0
  23. package/dist/chunks/{runtime-engine-DvnE2g-E.js → runtime-engine-D04uhJXm.js} +96 -102
  24. package/dist/chunks/runtime-engine-D04uhJXm.js.map +1 -0
  25. package/dist/chunks/{runtime-state-BTDqSYBk.js → runtime-state-BUq5X_CG.js} +17 -3
  26. package/dist/chunks/runtime-state-BUq5X_CG.js.map +1 -0
  27. package/dist/chunks/{shared-utils-DWA4LjIa.js → shared-utils-y-HjvPN4.js} +16 -12
  28. package/dist/chunks/{shared-utils-DWA4LjIa.js.map → shared-utils-y-HjvPN4.js.map} +1 -1
  29. package/dist/chunks/{style-engine-C1ECBZxR.js → style-engine-C2Z26n3a.js} +509 -199
  30. package/dist/chunks/style-engine-C2Z26n3a.js.map +1 -0
  31. package/dist/chunks/{zero-engine-B6EnYcXY.js → zero-engine-DaRIJYuG.js} +65 -28
  32. package/dist/chunks/zero-engine-DaRIJYuG.js.map +1 -0
  33. package/dist/{collector-hl5KNH7k.d.ts → collector-mcfTc7CF.d.ts} +2 -3
  34. package/dist/{config-DWL1ZYue.d.ts → config-mZhgbrmh.d.ts} +36 -26
  35. package/dist/core/index.d.ts +4 -4
  36. package/dist/core/index.js +8 -8
  37. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  38. package/dist/{index-D9N9GV24.d.ts → index-BFfu4ucC.d.ts} +176 -177
  39. package/dist/index.d.ts +4 -4
  40. package/dist/index.js +9 -9
  41. package/dist/{merge-styles-C_oMoJVd.d.ts → merge-styles-CaNZmN4Y.d.ts} +2 -3
  42. package/dist/ssr/astro-client.d.ts +1 -1
  43. package/dist/ssr/astro-middleware-extract-static.d.ts +1 -2
  44. package/dist/ssr/astro-middleware-extract.d.ts +1 -2
  45. package/dist/ssr/astro-middleware-static.d.ts +1 -2
  46. package/dist/ssr/astro-middleware.d.ts +1 -2
  47. package/dist/ssr/astro.d.ts +8 -16
  48. package/dist/ssr/astro.js +7 -6
  49. package/dist/ssr/astro.js.map +1 -1
  50. package/dist/ssr/client.d.ts +2 -0
  51. package/dist/ssr/client.js +2 -0
  52. package/dist/ssr/index.d.ts +5 -25
  53. package/dist/ssr/index.js +4 -4
  54. package/dist/ssr/index.js.map +1 -1
  55. package/dist/ssr/next-config.d.ts +3 -5
  56. package/dist/ssr/next-config.js +20 -21
  57. package/dist/ssr/next-config.js.map +1 -1
  58. package/dist/ssr/next.d.ts +3 -9
  59. package/dist/ssr/next.js +5 -4
  60. package/dist/ssr/next.js.map +1 -1
  61. package/dist/static/index.d.ts +8 -9
  62. package/dist/static/index.js +4 -4
  63. package/dist/static/index.js.map +1 -1
  64. package/dist/static/inject.d.ts +1 -2
  65. package/dist/{types-jKZNpias.d.ts → types-YL3eMjVH.d.ts} +17 -67
  66. package/dist/zero/babel.d.ts +67 -2
  67. package/dist/zero/babel.js +66 -58
  68. package/dist/zero/babel.js.map +1 -1
  69. package/dist/zero/index.d.ts +44 -8
  70. package/dist/zero/index.js +24 -2
  71. package/dist/zero/index.js.map +1 -0
  72. package/dist/zero/next.d.ts +4 -5
  73. package/dist/zero/next.js +3 -7
  74. package/dist/zero/next.js.map +1 -1
  75. package/docs/README.md +4 -1
  76. package/docs/adoption.md +25 -17
  77. package/docs/ai-agents.md +59 -35
  78. package/docs/comparison.md +9 -8
  79. package/docs/configuration.md +191 -60
  80. package/docs/debug.md +3 -2
  81. package/docs/design-system.md +117 -15
  82. package/docs/dsl.md +167 -82
  83. package/docs/getting-started.md +81 -22
  84. package/docs/injector.md +39 -40
  85. package/docs/methodology.md +47 -22
  86. package/docs/migration-v3.md +2 -2
  87. package/docs/pipeline.md +50 -26
  88. package/docs/plugins.md +21 -41
  89. package/docs/react-api.md +30 -8
  90. package/docs/runtime-benchmarks.md +53 -45
  91. package/docs/ssr.md +84 -64
  92. package/docs/styles.md +69 -21
  93. package/docs/tasty-static.md +133 -56
  94. package/package.json +55 -40
  95. package/dist/babel-Zs1Q03qt.d.ts +0 -83
  96. package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
  97. package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
  98. package/dist/chunks/build-config-CUQVwdWF.js +0 -42
  99. package/dist/chunks/build-config-CUQVwdWF.js.map +0 -1
  100. package/dist/chunks/collector-B0LTHw6Z.js.map +0 -1
  101. package/dist/chunks/css-definitions-D_it4XZH.js.map +0 -1
  102. package/dist/chunks/dsl-C5yuAn41.js.map +0 -1
  103. package/dist/chunks/react-runtime-O-OUrKLH.js.map +0 -1
  104. package/dist/chunks/runtime-engine-DvnE2g-E.js.map +0 -1
  105. package/dist/chunks/runtime-state-BTDqSYBk.js.map +0 -1
  106. package/dist/chunks/style-engine-C1ECBZxR.js.map +0 -1
  107. package/dist/chunks/zero-engine-B6EnYcXY.js.map +0 -1
@@ -0,0 +1,18 @@
1
+ import { t as TastyConfig } from "./config-mZhgbrmh.js";
2
+ //#region src/zero/babel-types.d.ts
3
+ /**
4
+ * Build-time configuration for zero-runtime mode.
5
+ * Subset of TastyConfig excluding runtime-only DOM options
6
+ * (`nonce`, `maxRulesPerSheet`, `forceTextInjection`, `gc`)
7
+ * and overriding `devMode` default to `false`.
8
+ */
9
+ type TastyZeroConfig = Omit<TastyConfig, 'nonce' | 'maxRulesPerSheet' | 'forceTextInjection' | 'gc' | 'devMode'> & {
10
+ /**
11
+ * Enable development mode features: source comments in generated CSS.
12
+ * @default false
13
+ */
14
+ devMode?: boolean;
15
+ };
16
+ //#endregion
17
+ export { TastyZeroConfig as t };
18
+ //# sourceMappingURL=babel-types-BqWM62mn.d.ts.map
@@ -0,0 +1,37 @@
1
+ import * as asyncHooks from "node:async_hooks";
2
+ //#region src/ssr/async-storage.ts
3
+ const ALS_KEY = "__tasty_ssr_als__";
4
+ function getStorageClass() {
5
+ try {
6
+ const Storage = asyncHooks.AsyncLocalStorage;
7
+ return typeof Storage === "function" ? Storage : null;
8
+ } catch {
9
+ return null;
10
+ }
11
+ }
12
+ function isAsyncStorageAvailable() {
13
+ return getStorageClass() !== null;
14
+ }
15
+ function getSharedStorage() {
16
+ const g = globalThis;
17
+ if (!g[ALS_KEY]) {
18
+ const StorageClass = getStorageClass();
19
+ if (!StorageClass) return null;
20
+ g[ALS_KEY] = new StorageClass();
21
+ }
22
+ return g[ALS_KEY];
23
+ }
24
+ function runWithCollector(collector, fn) {
25
+ const storage = getSharedStorage();
26
+ if (!storage) throw new Error("[Tasty] runWithCollector() needs AsyncLocalStorage from node:async_hooks, which this environment does not provide. Call it on the server.");
27
+ return storage.run(collector, fn);
28
+ }
29
+ function getSSRCollector() {
30
+ const storage = getSharedStorage();
31
+ if (typeof storage?.getStore !== "function") return null;
32
+ return storage.getStore() ?? null;
33
+ }
34
+ //#endregion
35
+ export { isAsyncStorageAvailable as n, runWithCollector as r, getSSRCollector as t };
36
+
37
+ //# sourceMappingURL=async-storage-f9j9JRtq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-storage-f9j9JRtq.js","names":[],"sources":["../../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks', which a browser bundle stubs\n * out. Nothing reads the import until a collector is looked up, and a stub\n * reads as \"no storage\", so `@tenphi/tasty/ssr` can still be imported there\n * (for `hydrateTastyClasses()`) without breaking rendering.\n */\n\nimport * as asyncHooks from 'node:async_hooks';\nimport type { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\ntype Storage = AsyncLocalStorage<ServerStyleCollector>;\n\n/** The `AsyncLocalStorage` class, or null where the module is stubbed out. */\nfunction getStorageClass(): typeof AsyncLocalStorage | null {\n try {\n const Storage = asyncHooks.AsyncLocalStorage;\n return typeof Storage === 'function' ? Storage : null;\n } catch {\n // Some development stubs throw on any property access.\n return null;\n }\n}\n\n/**\n * Whether this environment has `AsyncLocalStorage` — a server runtime rather\n * than a browser bundle.\n */\nexport function isAsyncStorageAvailable(): boolean {\n return getStorageClass() !== null;\n}\n\nfunction getSharedStorage(): Storage | null {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n const StorageClass = getStorageClass();\n if (!StorageClass) return null;\n g[ALS_KEY] = new StorageClass<ServerStyleCollector>();\n }\n return g[ALS_KEY] as Storage;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n const storage = getSharedStorage();\n if (!storage) {\n throw new Error(\n '[Tasty] runWithCollector() needs AsyncLocalStorage from node:async_hooks, which this environment does not provide. Call it on the server.',\n );\n }\n return storage.run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;AAuBA,MAAM,UAAU;AAKhB,SAAS,kBAAmD;CAC1D,IAAI;EACF,MAAM,UAAU,WAAW;EAC3B,OAAO,OAAO,YAAY,aAAa,UAAU;CACnD,QAAQ;EAEN,OAAO;CACT;AACF;AAMA,SAAgB,0BAAmC;CACjD,OAAO,gBAAgB,MAAM;AAC/B;AAEA,SAAS,mBAAmC;CAC1C,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,UAAU;EACf,MAAM,eAAe,gBAAgB;EACrC,IAAI,CAAC,cAAc,OAAO;EAC1B,EAAE,WAAW,IAAI,aAAmC;CACtD;CACA,OAAO,EAAE;AACX;AAOA,SAAgB,iBACd,WACA,IACG;CACH,MAAM,UAAU,iBAAiB;CACjC,IAAI,CAAC,SACH,MAAM,IAAI,MACR,2IACF;CAEF,OAAO,QAAQ,IAAI,WAAW,EAAE;AAClC;AAMA,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,iBAAiB;CACjC,IAAI,OAAO,SAAS,aAAa,YAAY,OAAO;CACpD,OAAO,QAAQ,SAAS,KAAK;AAC/B"}
@@ -0,0 +1,60 @@
1
+ import { c as getGlobalParser, m as resetGlobalPredefinedTokens, p as resetGlobalParseFunctions, r as CUSTOM_UNITS } from "./dsl-Ddc5EUBK.js";
2
+ import { o as isDevEnv, r as resetStyleWarnings } from "./shared-utils-y-HjvPN4.js";
3
+ import { M as validateNamePrefix, Y as resetFunctionPolyfills } from "./css-definitions-DKApeTsI.js";
4
+ import { H as clearGlobalPredefinedStates, V as resetStyleChunks, X as resetStylesGeneratedState, Y as resetGlobalPolyfillsState, k as resetHandlers, q as isFunctionsPolyfillEnabled, x as clearParseCache, y as clearPipelineCache } from "./style-engine-C2Z26n3a.js";
5
+ import { n as applyStyleConfig, r as normalizeConfig } from "./config-engine-_hRNSRwz.js";
6
+ //#region src/zero/config.ts
7
+ const emittedWarnings = /* @__PURE__ */ new Set();
8
+ const devMode = isDevEnv();
9
+ let activeConfig = null;
10
+ let appliedConfig = null;
11
+ function getActiveZeroConfig() {
12
+ return activeConfig;
13
+ }
14
+ function setActiveZeroConfig(config) {
15
+ activeConfig = config;
16
+ }
17
+ function warnOnce(key, message) {
18
+ if (devMode && !emittedWarnings.has(key)) {
19
+ emittedWarnings.add(key);
20
+ console.warn(message);
21
+ }
22
+ }
23
+ function configureZero(config) {
24
+ if (config.namePrefix !== void 0) validateNamePrefix(config.namePrefix);
25
+ const normalized = normalizeConfig(config);
26
+ appliedConfig = {
27
+ source: config,
28
+ normalized,
29
+ functions: applyStyleConfig(config, normalized, warnOnce)
30
+ };
31
+ return appliedConfig;
32
+ }
33
+ function reapplyZeroConfig(config) {
34
+ if (appliedConfig === config) return config;
35
+ resetZeroConfig();
36
+ return configureZero(config.source);
37
+ }
38
+ function resetZeroConfig() {
39
+ resetStylesGeneratedState();
40
+ resetGlobalPolyfillsState();
41
+ resetGlobalPredefinedTokens();
42
+ resetGlobalParseFunctions();
43
+ clearGlobalPredefinedStates();
44
+ clearParseCache();
45
+ getGlobalParser().setUnits(CUSTOM_UNITS);
46
+ resetFunctionPolyfills();
47
+ resetHandlers();
48
+ resetStyleChunks();
49
+ clearPipelineCache();
50
+ emittedWarnings.clear();
51
+ resetStyleWarnings();
52
+ appliedConfig = null;
53
+ }
54
+ function functionsForExtraction(config) {
55
+ return isFunctionsPolyfillEnabled() ? void 0 : config.functions;
56
+ }
57
+ //#endregion
58
+ export { resetZeroConfig as a, reapplyZeroConfig as i, functionsForExtraction as n, setActiveZeroConfig as o, getActiveZeroConfig as r, configureZero as t };
59
+
60
+ //# sourceMappingURL=build-config-CGSGH4Sb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-config-CGSGH4Sb.js","names":[],"sources":["../../src/zero/config.ts"],"sourcesContent":["/** Build-time configuration without the browser injector/runtime registries. */\n\nimport { resetStyleChunks } from '../chunks/style-chunk-map';\nimport {\n applyStyleConfig,\n normalizeConfig,\n type NormalizedConfig,\n} from '../config-normalize';\nimport {\n isFunctionsPolyfillEnabled,\n resetGlobalPolyfillsState,\n resetStylesGeneratedState,\n} from '../config-state';\nimport { resetFunctionPolyfills } from '../functions';\nimport { clearPipelineCache } from '../pipeline';\nimport { clearParseCache } from '../pipeline/parseStateKey';\nimport { clearGlobalPredefinedStates } from '../states';\nimport { resetHandlers } from '../styles/predefined';\nimport { isDevEnv } from '../utils/is-dev-env';\nimport { validateNamePrefix } from '../utils/name-prefix';\nimport {\n CUSTOM_UNITS,\n getGlobalParser,\n resetGlobalParseFunctions,\n resetGlobalPredefinedTokens,\n} from '../utils/styles';\nimport { resetStyleWarnings } from '../utils/warnings';\n\nimport type { FunctionDefinition } from '../injector/types';\nimport type { TastyZeroConfig } from './babel-types';\n\nexport interface ResolvedZeroConfig {\n source: TastyZeroConfig;\n normalized: NormalizedConfig;\n functions: Record<string, FunctionDefinition>;\n}\n\nconst emittedWarnings = new Set<string>();\nconst devMode = isDevEnv();\n\n/**\n * Configuration set through the public `/zero` `configure()`, which the\n * programmatic extractors read for recipes and global keyframes. The Babel\n * plugin passes its configuration explicitly and leaves this unset.\n */\nlet activeConfig: ResolvedZeroConfig | null = null;\n\n/**\n * The configuration the engine state currently reflects. The state is\n * process-wide, so the Babel plugin, `withTastyNext()` and `/zero`\n * `configure()` can replace one another's; each re-applies its own when this\n * is not it.\n */\nlet appliedConfig: ResolvedZeroConfig | null = null;\n\nexport function getActiveZeroConfig(): ResolvedZeroConfig | null {\n return activeConfig;\n}\n\nexport function setActiveZeroConfig(config: ResolvedZeroConfig | null): void {\n activeConfig = config;\n}\n\nfunction warnOnce(key: string, message: string): void {\n if (devMode && !emittedWarnings.has(key)) {\n emittedWarnings.add(key);\n console.warn(message);\n }\n}\n\n/** Resolve and apply the style-engine subset used during static extraction. */\nexport function configureZero(config: TastyZeroConfig): ResolvedZeroConfig {\n if (config.namePrefix !== undefined) validateNamePrefix(config.namePrefix);\n\n const normalized = normalizeConfig(config);\n const functions = applyStyleConfig(config, normalized, warnOnce);\n\n appliedConfig = { source: config, normalized, functions };\n return appliedConfig;\n}\n\n/**\n * Apply `config` again if another configuration replaced it since, and return\n * the configuration now applied (a fresh one when it was re-applied).\n */\nexport function reapplyZeroConfig(\n config: ResolvedZeroConfig,\n): ResolvedZeroConfig {\n if (appliedConfig === config) return config;\n\n resetZeroConfig();\n return configureZero(config.source);\n}\n\n/** Reset only state that the build-time configuration path can mutate. */\nexport function resetZeroConfig(): void {\n resetStylesGeneratedState();\n resetGlobalPolyfillsState();\n resetGlobalPredefinedTokens();\n resetGlobalParseFunctions();\n // State aliases and units are merged into, never replaced, so a new\n // configuration would otherwise keep the previous one's. Parsed state keys\n // are cached on the assumption that aliases do not change.\n clearGlobalPredefinedStates();\n clearParseCache();\n getGlobalParser().setUnits(CUSTOM_UNITS);\n resetFunctionPolyfills();\n resetHandlers();\n resetStyleChunks();\n clearPipelineCache();\n emittedWarnings.clear();\n resetStyleWarnings();\n appliedConfig = null;\n}\n\nexport function functionsForExtraction(\n config: ResolvedZeroConfig,\n): Record<string, FunctionDefinition> | undefined {\n return isFunctionsPolyfillEnabled() ? undefined : config.functions;\n}\n"],"mappings":";;;;;;AAqCA,MAAM,kCAAkB,IAAI,IAAY;AACxC,MAAM,UAAU,SAAS;AAOzB,IAAI,eAA0C;AAQ9C,IAAI,gBAA2C;AAE/C,SAAgB,sBAAiD;CAC/D,OAAO;AACT;AAEA,SAAgB,oBAAoB,QAAyC;CAC3E,eAAe;AACjB;AAEA,SAAS,SAAS,KAAa,SAAuB;CACpD,IAAI,WAAW,CAAC,gBAAgB,IAAI,GAAG,GAAG;EACxC,gBAAgB,IAAI,GAAG;EACvB,QAAQ,KAAK,OAAO;CACtB;AACF;AAGA,SAAgB,cAAc,QAA6C;CACzE,IAAI,OAAO,eAAe,KAAA,GAAW,mBAAmB,OAAO,UAAU;CAEzE,MAAM,aAAa,gBAAgB,MAAM;CAGzC,gBAAgB;EAAE,QAAQ;EAAQ;EAAY,WAF5B,iBAAiB,QAAQ,YAAY,QAED;CAAE;CACxD,OAAO;AACT;AAMA,SAAgB,kBACd,QACoB;CACpB,IAAI,kBAAkB,QAAQ,OAAO;CAErC,gBAAgB;CAChB,OAAO,cAAc,OAAO,MAAM;AACpC;AAGA,SAAgB,kBAAwB;CACtC,0BAA0B;CAC1B,0BAA0B;CAC1B,4BAA4B;CAC5B,0BAA0B;CAI1B,4BAA4B;CAC5B,gBAAgB;CAChB,gBAAgB,CAAC,CAAC,SAAS,YAAY;CACvC,uBAAuB;CACvB,cAAc;CACd,iBAAiB;CACjB,mBAAmB;CACnB,gBAAgB,MAAM;CACtB,mBAAmB;CACnB,gBAAgB;AAClB;AAEA,SAAgB,uBACd,QACgD;CAChD,OAAO,2BAA2B,IAAI,KAAA,IAAY,OAAO;AAC3D"}
@@ -1,6 +1,6 @@
1
- import { A as validateNamePrefix, D as makeKeyframeName, E as makeCounterStyleName, T as makeClassName, U as parseFunctionName, V as formatFunctionRule, a as formatPropertyCSS, b as formatFontFaceRule, h as formatCounterStyleRule, j as hashString, n as formatGlobalRules, r as formatRules, t as createServerStyleArtifact, v as fontFaceContentHash } from "./css-definitions-D_it4XZH.js";
2
- import { b as renderStyles } from "./style-engine-C1ECBZxR.js";
3
- import { a as getGlobalConfigTokens, c as getGlobalFunctions, i as getEffectiveProperties, l as getGlobalStyles, o as getGlobalCounterStyles, s as getGlobalFontFaces, u as getRuntimeConfigState } from "./runtime-state-BTDqSYBk.js";
1
+ import { D as makeClassName, K as parseFunctionName, M as validateNamePrefix, N as hashString, O as makeCounterStyleName, S as formatFontFaceRule, W as formatFunctionRule, _ as formatCounterStyleRule, b as fontFaceContentHash, i as formatKeyframesCSS, k as makeKeyframeName, m as resolveSelectorKeyframes, n as formatGlobalRules, o as formatPropertyCSS, r as formatRules, t as createServerStyleArtifact } from "./css-definitions-DKApeTsI.js";
2
+ import { b as renderStyles } from "./style-engine-C2Z26n3a.js";
3
+ import { a as getGlobalConfigTokens, c as getGlobalFunctions, d as getRuntimeConfigState, i as getEffectiveProperties, l as getGlobalKeyframes, o as getGlobalCounterStyles, s as getGlobalFontFaces, u as getGlobalStyles } from "./runtime-state-BUq5X_CG.js";
4
4
  //#region src/ssr/collector.ts
5
5
  var ServerStyleCollector = class {
6
6
  chunks = /* @__PURE__ */ new Map();
@@ -68,8 +68,10 @@ var ServerStyleCollector = class {
68
68
  const globalStyles = getGlobalStyles();
69
69
  if (globalStyles) {
70
70
  for (const [selector, styles] of Object.entries(globalStyles)) if (Object.keys(styles).length > 0) {
71
- const rules = renderStyles(styles, selector);
72
- if (rules.length > 0) {
71
+ const rendered = renderStyles(styles, selector);
72
+ if (rendered.length > 0) {
73
+ const { rules, keyframes } = resolveSelectorKeyframes(styles, rendered, getGlobalKeyframes());
74
+ for (const [name, steps] of keyframes ?? []) this.collectKeyframes(name, formatKeyframesCSS(name, steps));
73
75
  const css = formatGlobalRules(rules);
74
76
  if (css) this.collectGlobalStyles(`__global:styles:${selector}`, css);
75
77
  }
@@ -205,4 +207,4 @@ function createServerStyleCollector(namePrefix) {
205
207
  //#endregion
206
208
  export { createServerStyleCollector as n, ServerStyleCollector as t };
207
209
 
208
- //# sourceMappingURL=collector-B0LTHw6Z.js.map
210
+ //# sourceMappingURL=collector-CbphuMNW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector-CbphuMNW.js","names":[],"sources":["../../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalConfigTokens,\n getGlobalCounterStyles,\n getGlobalFontFaces,\n getGlobalFunctions,\n getGlobalKeyframes,\n getGlobalStyles,\n getRuntimeConfigState,\n} from '../config-resources';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { formatFunctionRule, parseFunctionName } from '../functions';\nimport { resolveSelectorKeyframes } from '../keyframes';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport {\n DEFAULT_NAME_PREFIX,\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { createServerStyleArtifact } from './artifacts';\nimport type { ServerStyleArtifact, ServerStyleArtifactKind } from './artifacts';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatKeyframesCSS } from './format-keyframes';\nimport { formatRules } from './format-rules';\n\nexport type { ServerStyleArtifact, ServerStyleArtifactKind } from './artifacts';\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private functionRules = new Map<string, string>();\n private flushedFunctionKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix =\n namePrefix ?? getRuntimeConfigState()?.namePrefix ?? DEFAULT_NAME_PREFIX;\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFaces();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyles();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css, { weak: true });\n }\n }\n\n const globalFn = getGlobalFunctions();\n if (globalFn) {\n for (const [name, definition] of Object.entries(globalFn)) {\n const css = formatFunctionRule(name, definition);\n this.collectFunction(parseFunctionName(name), css, { weak: true });\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rendered = renderStyles(styles, selector) as StyleResult[];\n if (rendered.length > 0) {\n const { rules, keyframes } = resolveSelectorKeyframes(\n styles,\n rendered,\n getGlobalKeyframes(),\n );\n for (const [name, steps] of keyframes ?? []) {\n this.collectKeyframes(name, formatKeyframesCSS(name, steps));\n }\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = this.generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name and overrides an\n * existing rule by default. Pass `weak: true` for global `configure()`\n * definitions, which never clobber an existing rule.\n */\n collectCounterStyle(\n name: string,\n css: string,\n options?: { weak?: boolean },\n ): void {\n const existing = this.counterStyleRules.get(name);\n if (existing === undefined) {\n this.counterStyleRules.set(name, css);\n return;\n }\n if (options?.weak || existing === css) return;\n this.counterStyleRules.set(name, css);\n // If a rule with this name was already flushed (streaming), allow the\n // overriding rule to be flushed again so it wins by source order.\n this.flushedCounterStyleKeys.delete(name);\n }\n\n /**\n * Record a @function rule. Deduplicated by CSS function name and overrides an\n * existing rule by default. Pass `weak: true` for global `configure()`\n * definitions, which never clobber an existing rule.\n */\n collectFunction(\n name: string,\n css: string,\n options?: { weak?: boolean },\n ): void {\n const existing = this.functionRules.get(name);\n if (existing === undefined) {\n this.functionRules.set(name, css);\n return;\n }\n if (options?.weak || existing === css) return;\n this.functionRules.set(name, css);\n // If a rule with this name was already flushed (streaming), allow the\n // overriding rule to be flushed again so it wins by source order.\n this.flushedFunctionKeys.delete(name);\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n *\n * Pass `replace` for slot-keyed entries (an explicit `id`), where the last\n * write must win to match the client's update-tracking behavior.\n */\n collectGlobalStyles(key: string, css: string, replace?: boolean): void {\n if (replace || !this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n *\n * Pass `replace` for slot-keyed entries (an explicit `id`), where the last\n * write must win to match the client's update-tracking behavior.\n */\n collectRawCSS(key: string, css: string, replace?: boolean): void {\n if (replace || !this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Return the collected CSS as structured, ordered artifacts.\n *\n * Artifact boundaries are part of the collector output so build tools never\n * need to split or parse CSS text. IDs include the logical collection key\n * and content, making them stable across equivalent page renders while a CSS\n * change always produces a different ID.\n */\n getArtifacts(): ServerStyleArtifact[] {\n const artifacts: ServerStyleArtifact[] = [];\n\n const append = (\n kind: ServerStyleArtifactKind,\n entries: Iterable<[string, string]>,\n ) => {\n for (const [key, css] of entries) {\n artifacts.push(\n createServerStyleArtifact(kind, key, css, artifacts.length),\n );\n }\n };\n\n append('property', this.propertyRules);\n append('font-face', this.fontFaceRules);\n append('counter-style', this.counterStyleRules);\n append('function', this.functionRules);\n append('raw', this.rawCSS);\n append('global', this.globalStyles);\n append('chunk', this.chunks);\n append('keyframes', this.keyframeRules);\n\n return artifacts;\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n return this.getArtifacts()\n .map(({ css }) => css)\n .join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.functionRules) {\n if (!this.flushedFunctionKeys.has(key)) {\n parts.push(css);\n this.flushedFunctionKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n\n/**\n * Factory for creating a {@link ServerStyleCollector} instance.\n *\n * Canonical functional entry point; the `ServerStyleCollector` class remains\n * exported for advanced/internal use.\n *\n * @param namePrefix - Optional override for the configured class-name prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n *\n * @example\n * ```ts\n * import { createServerStyleCollector } from '@tenphi/tasty/ssr';\n *\n * const collector = createServerStyleCollector();\n * ```\n */\nexport function createServerStyleCollector(\n namePrefix?: string,\n): ServerStyleCollector {\n return new ServerStyleCollector(namePrefix);\n}\n"],"mappings":";;;;AA8CA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,IAAoB;CACzC,sCAA8B,IAAI,IAAoB;CACtD,8BAAsB,IAAI,IAAY;CACtC,gCAAwB,IAAI,IAAoB;CAChD,sCAA8B,IAAI,IAAY;CAC9C,gCAAwB,IAAI,IAAoB;CAChD,sCAA8B,IAAI,IAAY;CAC9C,+BAAuB,IAAI,IAAoB;CAC/C,oCAA4B,IAAI,IAAY;CAC5C,yBAAiB,IAAI,IAAoB;CACzC,iCAAyB,IAAI,IAAY;CACzC,gCAAwB,IAAI,IAAoB;CAChD,sCAA8B,IAAI,IAAY;CAC9C,oCAA4B,IAAI,IAAoB;CACpD,0CAAkC,IAAI,IAAY;CAClD,gCAAwB,IAAI,IAAoB;CAChD,sCAA8B,IAAI,IAAY;CAC9C,mBAA2B;CAC3B,sBAA8B;CAC9B,qBAA6B;CAC7B;CASA,YAAY,YAAqB;EAC/B,IAAI,eAAe,KAAA,GACjB,mBAAmB,UAAU;EAE/B,KAAK,aACH,cAAc,sBAAsB,CAAC,EAAE,cAAA;CAC3C;CAEA,kBAA0B,UAA0B;EAClD,OAAO,cAAc,KAAK,YAAY,WAAW,QAAQ,CAAC;CAC5D;CAWA,mBAAyB;EACvB,IAAI,KAAK,oBAAoB;EAC7B,KAAK,qBAAqB;EAE1B,KAAK,MAAM,CAAC,OAAO,eAAe,OAAO,QACvC,uBAAuB,CACzB,GAAG;GACD,MAAM,MAAM,kBAAkB,OAAO,UAAU;GAC/C,IA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,QAAQ,KAAK,eAC7B,IAAI,CAAC,KAAK,oBAAoB,IAAI,IAAI,GAAG;GACvC,MAAM,KAAK,GAAG;GACd,KAAK,oBAAoB,IAAI,IAAI;EACnC;EAGF,OAAO,MAAM,KAAK,IAAI;CACxB;CAEA,oCAA4B,IAAI,IAAY;CAM5C,wBAAkC;EAChC,MAAM,QAAkB,CAAC;EACzB,KAAK,MAAM,aAAa,KAAK,oBAAoB,OAAO,GACtD,IAAI,CAAC,KAAK,kBAAkB,IAAI,SAAS,GAAG;GAC1C,KAAK,kBAAkB,IAAI,SAAS;GACpC,MAAM,KAAK,SAAS;EACtB;EAEF,OAAO;CACT;AACF;AAkBA,SAAgB,2BACd,YACsB;CACtB,OAAO,IAAI,qBAAqB,UAAU;AAC5C"}
@@ -1,9 +1,9 @@
1
- import { c as getGlobalParser, g as setGlobalPredefinedTokens, r as CUSTOM_UNITS, s as getGlobalParseFunctions, u as normalizeColorTokenValue } from "./dsl-C5yuAn41.js";
2
- import { n as isSelector, o as isDevEnv, t as mergeStyles } from "./shared-utils-DWA4LjIa.js";
3
- import { W as registerFunctionPolyfill, q as splitFunctions } from "./css-definitions-D_it4XZH.js";
4
- import { E as registerHandler, T as normalizeHandlerDefinition, U as isFunctionsPolyfillEnabled, V as setGlobalPredefinedStates, q as setGlobalPolyfillsState } from "./style-engine-C1ECBZxR.js";
1
+ import { c as getGlobalParser, g as setGlobalPredefinedTokens, r as CUSTOM_UNITS, s as getGlobalParseFunctions, u as normalizeColorTokenValue } from "./dsl-Ddc5EUBK.js";
2
+ import { n as isSelector, o as isDevEnv, t as mergeStyles } from "./shared-utils-y-HjvPN4.js";
3
+ import { X as splitFunctions, q as registerFunctionPolyfill } from "./css-definitions-DKApeTsI.js";
4
+ import { D as normalizeHandlerDefinition, G as setGlobalPredefinedStates, O as registerHandler, Z as setGlobalPolyfillsState, q as isFunctionsPolyfillEnabled } from "./style-engine-C2Z26n3a.js";
5
5
  //#region src/utils/typography.ts
6
- const RESERVED_PRESET_NAMES = new Set([
6
+ const RESERVED_PRESET_NAMES = /* @__PURE__ */ new Set([
7
7
  "strong",
8
8
  "bold",
9
9
  "italic",
@@ -55,10 +55,13 @@ function applyStyleConfig(config, normalized, warnOnce) {
55
55
  Object.assign(currentFuncs, parseFuncs);
56
56
  }
57
57
  if (isFunctionsPolyfillEnabled()) for (const [name, definition] of Object.entries(functionDefs)) registerFunctionPolyfill(name, definition);
58
- for (const [name, definition] of Object.entries(normalized.handlers)) registerHandler(normalizeHandlerDefinition(name, definition), {
59
- key: name,
60
- source: normalized.handlerSources.get(name)
61
- });
58
+ for (const [name, definition] of Object.entries(normalized.handlers)) {
59
+ const handler = normalizeHandlerDefinition(name, definition);
60
+ registerHandler(handler, {
61
+ key: name,
62
+ source: normalized.handlerSources.get(name)
63
+ });
64
+ }
62
65
  if (Object.keys(normalized.replaceTokens).length > 0) {
63
66
  const processedTokens = {};
64
67
  for (const [key, value] of Object.entries(normalized.replaceTokens)) if (key.startsWith("#")) {
@@ -220,8 +223,10 @@ function resolveRecipesForLevel(styles, recipes) {
220
223
  else flatStyles[key] = allRest[key];
221
224
  if (!base && !post) return allRest;
222
225
  let result;
223
- if (base) result = mergeStyles(collectRecipeStyles(base, recipes), flatStyles);
224
- else result = { ...flatStyles };
226
+ if (base) {
227
+ const baseStyles = collectRecipeStyles(base, recipes);
228
+ result = mergeStyles(baseStyles, flatStyles);
229
+ } else result = { ...flatStyles };
225
230
  if (post) {
226
231
  const postStyles = collectRecipeStyles(post, recipes);
227
232
  result = mergeStyles(result, postStyles);
@@ -264,4 +269,4 @@ function resolveRecipesWith(styles, recipes) {
264
269
  //#endregion
265
270
  export { generateTypographyTokens as i, applyStyleConfig as n, normalizeConfig as r, resolveRecipesWith as t };
266
271
 
267
- //# sourceMappingURL=config-engine-C3pF9EK9.js.map
272
+ //# sourceMappingURL=config-engine-_hRNSRwz.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-engine-C3pF9EK9.js","names":[],"sources":["../../src/utils/typography.ts","../../src/config-normalize.ts","../../src/utils/resolve-recipes-core.ts"],"sourcesContent":["import type { ConfigTokens } from '../styles/types';\n\nconst RESERVED_PRESET_NAMES = new Set([\n 'strong',\n 'bold',\n 'italic',\n 'icon',\n 'tight',\n]);\n\n/**\n * A typography token value: plain value or a state map for responsive/theme-aware presets.\n *\n * @example\n * // Plain value\n * fontWeight: '400'\n * // State map\n * fontWeight: { '': '400', '@dark': '300' }\n */\nexport type TypographyTokenValue =\n | string\n | number\n | Record<string, string | number | undefined | null | '@inherit'>;\n\n/**\n * Typography preset configuration.\n * Each preset defines font properties that get expanded into CSS custom properties.\n * All fields accept plain values or state maps for responsive/theme-aware tokens.\n *\n * Use with `generateTypographyTokens()` to create typography tokens for your design system.\n */\nexport interface TypographyPreset {\n fontSize: TypographyTokenValue;\n lineHeight: TypographyTokenValue;\n letterSpacing?: TypographyTokenValue;\n fontWeight: TypographyTokenValue;\n boldFontWeight?: TypographyTokenValue;\n iconSize?: TypographyTokenValue;\n textTransform?: TypographyTokenValue;\n fontFamily?: TypographyTokenValue;\n fontStyle?: TypographyTokenValue;\n}\n\n/**\n * Generate typography tokens with $ prefix for CSS custom properties.\n *\n * Each preset generates the following CSS custom properties:\n * - `${name}-font-size`\n * - `${name}-line-height`\n * - `${name}-letter-spacing`\n * - `${name}-font-weight`\n * - `${name}-bold-font-weight` (if defined)\n * - `${name}-icon-size` (if defined)\n * - `${name}-text-transform` (if defined)\n * - `${name}-font-family` (if defined)\n * - `${name}-font-style` (if defined)\n *\n * @param presets - Typography presets object\n * @returns ConfigTokens object with $ prefixed keys\n *\n * @example\n * const customTokens = generateTypographyTokens({\n * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },\n * body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },\n * });\n */\nexport function generateTypographyTokens(\n presets: Record<string, TypographyPreset>,\n): ConfigTokens {\n const tokens: ConfigTokens = {} as ConfigTokens;\n\n for (const [name, preset] of Object.entries(presets)) {\n if (RESERVED_PRESET_NAMES.has(name)) {\n throw new Error(\n `Invalid typography preset name \"${name}\". This name is reserved as a preset modifier.`,\n );\n }\n\n tokens[`$${name}-font-size`] = preset.fontSize;\n tokens[`$${name}-line-height`] = preset.lineHeight;\n tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? 'normal';\n tokens[`$${name}-font-weight`] = preset.fontWeight;\n\n if (preset.boldFontWeight !== undefined) {\n tokens[`$${name}-bold-font-weight`] = preset.boldFontWeight;\n }\n\n if (preset.iconSize !== undefined) {\n tokens[`$${name}-icon-size`] = preset.iconSize;\n }\n\n if (preset.textTransform !== undefined) {\n tokens[`$${name}-text-transform`] = preset.textTransform;\n }\n\n if (preset.fontFamily !== undefined) {\n tokens[`$${name}-font-family`] = preset.fontFamily;\n }\n\n if (preset.fontStyle !== undefined) {\n tokens[`$${name}-font-style`] = preset.fontStyle;\n }\n }\n\n return tokens;\n}\n","/**\n * Configuration processing shared by runtime and build-time paths.\n *\n * Plugins are folded first and direct configuration wins. Keeping this step\n * independent from the DOM injector lets zero-runtime tooling reuse the exact\n * same precedence and style-engine setup without loading browser infrastructure.\n */\n\nimport { registerFunctionPolyfill, splitFunctions } from './functions';\nimport {\n isFunctionsPolyfillEnabled,\n setGlobalPolyfillsState,\n} from './config-state';\nimport { setGlobalPredefinedStates } from './states';\nimport {\n normalizeHandlerDefinition,\n registerHandler,\n} from './styles/predefined';\nimport {\n CUSTOM_UNITS,\n getGlobalParseFunctions,\n getGlobalParser,\n normalizeColorTokenValue,\n setGlobalPredefinedTokens,\n} from './utils/styles';\nimport { generateTypographyTokens } from './utils/typography';\n\nimport type { TastyConfig } from './config';\nimport type { FunctionsConfig } from './functions';\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport type { UnitHandler } from './parser/types';\nimport type { PropHandlerDefinition } from './prop-handlers';\nimport type { ConfigTokens, RecipeStyles, Styles } from './styles/types';\nimport type { StyleHandlerDefinition } from './utils/styles';\nimport type { TypographyPreset } from './utils/typography';\n\nexport interface NormalizedConfig {\n states: Record<string, string>;\n units: Record<string, string | UnitHandler>;\n functions: FunctionsConfig;\n handlers: Record<string, StyleHandlerDefinition>;\n handlerSources: Map<string, string>;\n propHandlers: Record<string, PropHandlerDefinition>;\n propHandlerSources: Map<string, string>;\n baseStyleProps: string[];\n properties: Record<string, PropertyDefinition>;\n keyframes: Record<string, KeyframesSteps>;\n fontFaces: Record<string, FontFaceInput>;\n counterStyles: Record<string, CounterStyleDescriptors>;\n replaceTokens: Record<string, string | number | boolean>;\n tokens: ConfigTokens;\n recipes: Record<string, RecipeStyles>;\n globalStyles: Record<string, Styles>;\n}\n\ntype WarnOnce = (key: string, message: string) => void;\n\n/** Apply parser and style-engine configuration shared by every renderer. */\nexport function applyStyleConfig(\n config: Partial<TastyConfig>,\n normalized: NormalizedConfig,\n warnOnce: WarnOnce,\n): Record<string, FunctionDefinition> {\n const tokenKeys = new Set(Object.keys(normalized.tokens));\n for (const key of Object.keys(normalized.replaceTokens)) {\n if (tokenKeys.has(key)) {\n warnOnce(\n `token-conflict-${key}`,\n `[Tasty] Token \"${key}\" is defined in both \\`tokens\\` and \\`replaceTokens\\`. ` +\n `\\`replaceTokens\\` performs parse-time substitution, so the \\`tokens\\` ` +\n `CSS custom property will be injected but never used by Tasty styles. ` +\n `Remove it from one of the two.`,\n );\n }\n }\n\n if (config.colorSpace) {\n warnOnce(\n 'colorSpace-deprecated',\n '[Tasty] configure({ colorSpace }) no longer has any effect and will be ' +\n 'removed in the next major. Colors are emitted as authored, and opacity ' +\n \"is applied with relative color syntax, which reads a color's channels \" +\n 'in the browser. To address channels yourself, write ' +\n '`oklch(from var(--name-color) l c h)` against the token.',\n );\n }\n\n if (Object.keys(normalized.states).length > 0) {\n setGlobalPredefinedStates(normalized.states);\n }\n\n const parser = getGlobalParser();\n if (config.parserCacheSize !== undefined) {\n parser.updateOptions({ cacheSize: config.parserCacheSize });\n }\n if (Object.keys(normalized.units).length > 0) {\n const currentUnits = parser.getUnits() ?? CUSTOM_UNITS;\n parser.setUnits({ ...currentUnits, ...normalized.units });\n }\n\n if (config.polyfills) setGlobalPolyfillsState(config.polyfills);\n\n const { parseFuncs, functionDefs } = splitFunctions(\n normalized.functions,\n (key, kind) => {\n warnOnce(\n `functions-mismatch-${key}`,\n kind === 'expected-definition'\n ? `[Tasty] functions[\"${key}\"]: a \"$$\"-prefixed key denotes a CSS @function ` +\n `and expects a definition object, but received a function. Entry ignored.`\n : `[Tasty] functions[\"${key}\"]: a bare key denotes a parse function and ` +\n `expects a function value, but received an object. ` +\n `Did you mean \"$$${key}\"? Entry ignored.`,\n );\n },\n );\n\n if (Object.keys(parseFuncs).length > 0) {\n const currentFuncs = getGlobalParseFunctions();\n parser.setFunctions({ ...currentFuncs, ...parseFuncs });\n Object.assign(currentFuncs, parseFuncs);\n }\n\n if (isFunctionsPolyfillEnabled()) {\n for (const [name, definition] of Object.entries(functionDefs)) {\n registerFunctionPolyfill(name, definition);\n }\n }\n\n for (const [name, definition] of Object.entries(normalized.handlers)) {\n const handler = normalizeHandlerDefinition(name, definition);\n registerHandler(handler, {\n key: name,\n source: normalized.handlerSources.get(name),\n });\n }\n\n if (Object.keys(normalized.replaceTokens).length > 0) {\n const processedTokens: Record<string, string> = {};\n for (const [key, value] of Object.entries(normalized.replaceTokens)) {\n if (key.startsWith('#')) {\n const normalizedValue = normalizeColorTokenValue(value);\n if (normalizedValue === null) continue;\n processedTokens[key] = String(normalizedValue);\n } else if (value !== false) {\n processedTokens[key] = String(value);\n }\n }\n setGlobalPredefinedTokens(processedTokens);\n }\n\n return functionDefs;\n}\n\n/** Merge an optional configuration record into an accumulated record. */\nfunction mergeRecord<T extends object>(target: T, source?: Partial<T>): T {\n return source ? { ...target, ...source } : target;\n}\n\n/** Merge a named extension record and retain where each winning entry came from. */\nfunction mergeSourcedRecord<T>(\n target: Record<string, T>,\n source: Record<string, T> | undefined,\n sources: Map<string, string>,\n pluginName?: string,\n): Record<string, T> {\n if (!source) return target;\n\n const label =\n pluginName === undefined ? 'configure()' : `plugin \"${pluginName}\"`;\n for (const key of Object.keys(source)) sources.set(key, label);\n\n return { ...target, ...source };\n}\n\nexport function normalizeConfig(\n config: Partial<TastyConfig>,\n): NormalizedConfig {\n let states: Record<string, string> = {};\n let units: Record<string, string | UnitHandler> = {};\n let functions: FunctionsConfig = {};\n let handlers: Record<string, StyleHandlerDefinition> = {};\n const handlerSources = new Map<string, string>();\n let propHandlers: Record<string, PropHandlerDefinition> = {};\n const propHandlerSources = new Map<string, string>();\n const baseStyleProps: string[] = [];\n let properties: Record<string, PropertyDefinition> = {};\n let keyframes: Record<string, KeyframesSteps> = {};\n let fontFaces: Record<string, FontFaceInput> = {};\n let counterStyles: Record<string, CounterStyleDescriptors> = {};\n let replaceTokens: Record<string, string | number | boolean> = {};\n let tokens: ConfigTokens = {} as ConfigTokens;\n let recipes: Record<string, RecipeStyles> = {};\n let presets: Record<string, TypographyPreset> = {};\n const globalStyles: Record<string, Styles> = {};\n\n for (const plugin of config.plugins ?? []) {\n states = mergeRecord(states, plugin.states);\n units = mergeRecord(units, plugin.units);\n functions = mergeRecord(functions, plugin.functions);\n handlers = mergeSourcedRecord(\n handlers,\n plugin.handlers,\n handlerSources,\n plugin.name,\n );\n propHandlers = mergeSourcedRecord(\n propHandlers,\n plugin.propHandlers,\n propHandlerSources,\n plugin.name,\n );\n if (plugin.baseStyleProps) baseStyleProps.push(...plugin.baseStyleProps);\n properties = mergeRecord(properties, plugin.properties);\n keyframes = mergeRecord(keyframes, plugin.keyframes);\n fontFaces = mergeRecord(fontFaces, plugin.fontFaces);\n counterStyles = mergeRecord(counterStyles, plugin.counterStyles);\n replaceTokens = mergeRecord(replaceTokens, plugin.replaceTokens);\n tokens = mergeRecord(tokens, plugin.tokens);\n recipes = mergeRecord(recipes, plugin.recipes);\n presets = mergeRecord(presets, plugin.presets);\n mergeGlobalStyles(globalStyles, plugin.globalStyles);\n }\n\n states = mergeRecord(states, config.states);\n units = mergeRecord(units, config.units);\n functions = mergeRecord(functions, config.functions);\n handlers = mergeSourcedRecord(handlers, config.handlers, handlerSources);\n propHandlers = mergeSourcedRecord(\n propHandlers,\n config.propHandlers,\n propHandlerSources,\n );\n if (config.baseStyleProps) baseStyleProps.push(...config.baseStyleProps);\n properties = mergeRecord(properties, config.properties);\n keyframes = mergeRecord(keyframes, config.keyframes);\n fontFaces = mergeRecord(fontFaces, config.fontFaces);\n counterStyles = mergeRecord(counterStyles, config.counterStyles);\n replaceTokens = mergeRecord(replaceTokens, config.replaceTokens);\n presets = mergeRecord(presets, config.presets);\n\n if (Object.keys(presets).length > 0) {\n tokens = { ...generateTypographyTokens(presets), ...tokens };\n }\n\n tokens = mergeRecord(tokens, config.tokens);\n recipes = mergeRecord(recipes, config.recipes);\n mergeGlobalStyles(globalStyles, config.globalStyles);\n\n return {\n states,\n units,\n functions,\n handlers,\n handlerSources,\n propHandlers,\n propHandlerSources,\n baseStyleProps,\n properties,\n keyframes,\n fontFaces,\n counterStyles,\n replaceTokens,\n tokens,\n recipes,\n globalStyles,\n };\n}\n\nfunction mergeGlobalStyles(\n target: Record<string, Styles>,\n source?: Record<string, Styles>,\n): void {\n if (!source) return;\n\n for (const [selector, styles] of Object.entries(source)) {\n target[selector] = target[selector]\n ? { ...target[selector], ...styles }\n : styles;\n }\n}\n","/**\n * Recipe resolution utility.\n *\n * Resolves `recipe` style properties by looking up predefined recipe styles\n * from global configuration and merging them with the component's own styles.\n *\n * Resolution order per level (top-level and each sub-element independently):\n * base_recipe_1 base_recipe_2 → component styles → post_recipe_1 post_recipe_2\n *\n * The `/` separator splits base recipes (before component styles)\n * from post recipes (after component styles). All merges use mergeStyles\n * semantics: primitives and state maps with '' key fully replace;\n * state maps without '' key extend the existing value.\n *\n * Returns the same object reference if no recipes are present (zero overhead).\n */\n\nimport type { RecipeStyles, Styles } from '../styles/types';\n\nimport { isDevEnv } from './is-dev-env';\nimport { isSelector } from './is-selector';\nimport { mergeStyles } from './merge-styles';\n\nconst devMode = isDevEnv();\n\ninterface ParsedRecipeGroups {\n base: string[] | null;\n post: string[] | null;\n}\n\n/**\n * Parse a recipe string into base and post recipe name groups.\n *\n * Syntax: `'base1 base2 / post1 post2'`\n * - Names are space-separated within each group\n * - `/` separates base (before component) from post (after component) groups\n * - `/` is optional; if absent, all names are base\n * - `none` as the sole base value means \"no base recipes\"\n *\n * Returns `{ base: null, post: null }` if the string is empty or invalid.\n */\nfunction parseRecipeNames(value: unknown): ParsedRecipeGroups {\n const empty: ParsedRecipeGroups = { base: null, post: null };\n\n if (typeof value !== 'string') return empty;\n const trimmed = value.trim();\n if (trimmed === '') return empty;\n\n const slashIndex = trimmed.indexOf('/');\n\n if (slashIndex === -1) {\n if (trimmed === 'none') return empty;\n const names = splitNames(trimmed);\n return { base: names, post: null };\n }\n\n const basePart = trimmed.slice(0, slashIndex);\n const postPart = trimmed.slice(slashIndex + 1);\n\n return {\n base: basePart.trim() === 'none' ? null : splitNames(basePart),\n post: splitNames(postPart),\n };\n}\n\nfunction splitNames(s: string): string[] | null {\n const names = s.split(/\\s+/).filter(Boolean);\n return names.length > 0 ? names : null;\n}\n\n/**\n * Collect merged styles for a list of recipe names.\n * Each recipe is flat-spread on top of the previous.\n */\nfunction collectRecipeStyles(\n names: string[],\n recipes: Record<string, RecipeStyles>,\n): Record<string, unknown> {\n let merged: Record<string, unknown> = {};\n\n for (const name of names) {\n const recipeStyles = recipes[name];\n\n if (!recipeStyles) {\n if (devMode) {\n console.warn(\n `[Tasty] Recipe \"${name}\" not found. ` +\n `Make sure it is defined in configure({ recipes: { ... } }).`,\n );\n }\n continue;\n }\n\n merged = { ...merged, ...(recipeStyles as Record<string, unknown>) };\n }\n\n return merged;\n}\n\n/**\n * Resolve recipe references in a flat styles object (no sub-elements).\n * Returns null if no `recipe` key is present.\n *\n * Resolution: base recipes → component styles → post recipes (all via mergeStyles)\n */\nfunction resolveRecipesForLevel(\n styles: Record<string, unknown>,\n recipes: Record<string, RecipeStyles>,\n): Record<string, unknown> | null {\n if (!('recipe' in styles)) return null;\n\n const { base, post } = parseRecipeNames(styles.recipe);\n\n // Separate selector keys (sub-elements) from flat style properties.\n // mergeStyles handles selectors with its own semantics (e.g. false = delete),\n // but at this level we only want recipe merging on flat properties.\n\n const { recipe: _recipe, ...allRest } = styles;\n const flatStyles: Record<string, unknown> = {};\n const selectorStyles: Record<string, unknown> = {};\n\n for (const key of Object.keys(allRest)) {\n if (isSelector(key)) {\n selectorStyles[key] = allRest[key];\n } else {\n flatStyles[key] = allRest[key];\n }\n }\n\n if (!base && !post) {\n return allRest;\n }\n\n // 1. Merge base recipes, then component styles on top (via mergeStyles)\n let result: Record<string, unknown>;\n\n if (base) {\n const baseStyles = collectRecipeStyles(base, recipes);\n result = mergeStyles(baseStyles as Styles, flatStyles as Styles) as Record<\n string,\n unknown\n >;\n } else {\n result = { ...flatStyles };\n }\n\n // 2. Apply post recipes via mergeStyles (state map extend semantics)\n if (post) {\n const postStyles = collectRecipeStyles(post, recipes);\n result = mergeStyles(result as Styles, postStyles as Styles) as Record<\n string,\n unknown\n >;\n }\n\n // Re-attach selector keys unchanged\n for (const key of Object.keys(selectorStyles)) {\n result[key] = selectorStyles[key];\n }\n\n return result;\n}\n\n/**\n * Resolve all `recipe` style properties in a styles object.\n *\n * Handles both top-level and sub-element recipe references.\n * Returns the same object reference if no recipes are present anywhere\n * (zero overhead for the common case).\n *\n * @param styles - The styles object potentially containing `recipe` keys\n * @returns Resolved styles with recipe values merged in, or the original object if unchanged\n */\nexport function resolveRecipesWith(\n styles: Styles,\n recipes: Record<string, RecipeStyles> | null,\n): Styles {\n // Fast path: no recipes configured\n if (!recipes) return styles;\n\n let changed = false;\n\n // Resolve top-level recipe\n const topResolved = resolveRecipesForLevel(\n styles as Record<string, unknown>,\n recipes,\n );\n\n let result: Record<string, unknown>;\n\n if (topResolved) {\n changed = true;\n result = topResolved;\n } else {\n // Keep reference; a shallow copy is deferred until a sub-element actually changes\n result = styles as Record<string, unknown>;\n }\n\n // Resolve sub-element recipes\n const keys = Object.keys(result);\n\n for (const key of keys) {\n if (!isSelector(key)) continue;\n\n const subStyles = result[key];\n\n if (\n !subStyles ||\n typeof subStyles !== 'object' ||\n Array.isArray(subStyles)\n ) {\n continue;\n }\n\n const subRecord = subStyles as Record<string, unknown>;\n\n if (!('recipe' in subRecord)) continue;\n\n const subResolved = resolveRecipesForLevel(subRecord, recipes);\n\n if (subResolved) {\n if (!changed) {\n // First change in sub-elements -- need to shallow-copy the top level\n changed = true;\n result = { ...(styles as Record<string, unknown>) };\n }\n // Define an own data property so even an untrusted key cannot invoke an\n // inherited setter such as Object.prototype.__proto__.\n Object.defineProperty(result, key, {\n configurable: true,\n enumerable: true,\n value: subResolved,\n writable: true,\n });\n }\n }\n\n return changed ? (result as Styles) : styles;\n}\n"],"mappings":";;;;;AAEA,MAAM,wBAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;AACF,CAAC;AA0DD,SAAgB,yBACd,SACc;CACd,MAAM,SAAuB,CAAC;CAE9B,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,OAAO,GAAG;EACpD,IAAI,sBAAsB,IAAI,IAAI,GAChC,MAAM,IAAI,MACR,mCAAmC,KAAK,+CAC1C;EAGF,OAAO,IAAI,KAAK,eAAe,OAAO;EACtC,OAAO,IAAI,KAAK,iBAAiB,OAAO;EACxC,OAAO,IAAI,KAAK,oBAAoB,OAAO,iBAAiB;EAC5D,OAAO,IAAI,KAAK,iBAAiB,OAAO;EAExC,IAAI,OAAO,mBAAmB,KAAA,GAC5B,OAAO,IAAI,KAAK,sBAAsB,OAAO;EAG/C,IAAI,OAAO,aAAa,KAAA,GACtB,OAAO,IAAI,KAAK,eAAe,OAAO;EAGxC,IAAI,OAAO,kBAAkB,KAAA,GAC3B,OAAO,IAAI,KAAK,oBAAoB,OAAO;EAG7C,IAAI,OAAO,eAAe,KAAA,GACxB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EtB,MAAM,YAAY,OAAO;EAEzB,IACE,CAAC,aACD,OAAO,cAAc,YACrB,MAAM,QAAQ,SAAS,GAEvB;EAGF,MAAM,YAAY;EAElB,IAAI,EAAE,YAAY,YAAY;EAE9B,MAAM,cAAc,uBAAuB,WAAW,OAAO;EAE7D,IAAI,aAAa;GACf,IAAI,CAAC,SAAS;IAEZ,UAAU;IACV,SAAS,EAAE,GAAI,OAAmC;GACpD;GAGA,OAAO,eAAe,QAAQ,KAAK;IACjC,cAAc;IACd,YAAY;IACZ,OAAO;IACP,UAAU;GACZ,CAAC;EACH;CACF;CAEA,OAAO,UAAW,SAAoB;AACxC"}
1
+ {"version":3,"file":"config-engine-_hRNSRwz.js","names":[],"sources":["../../src/utils/typography.ts","../../src/config-normalize.ts","../../src/utils/resolve-recipes-core.ts"],"sourcesContent":["import type { ConfigTokens } from '../styles/types';\n\nconst RESERVED_PRESET_NAMES = new Set([\n 'strong',\n 'bold',\n 'italic',\n 'icon',\n 'tight',\n]);\n\n/**\n * A typography token value: plain value or a state map for responsive/theme-aware presets.\n *\n * @example\n * // Plain value\n * fontWeight: '400'\n * // State map\n * fontWeight: { '': '400', '@dark': '300' }\n */\nexport type TypographyTokenValue =\n | string\n | number\n | Record<string, string | number | undefined | null | '@inherit'>;\n\n/**\n * Typography preset configuration.\n * Each preset defines font properties that get expanded into CSS custom properties.\n * All fields accept plain values or state maps for responsive/theme-aware tokens.\n *\n * Use with `generateTypographyTokens()` to create typography tokens for your design system.\n */\nexport interface TypographyPreset {\n fontSize: TypographyTokenValue;\n lineHeight: TypographyTokenValue;\n letterSpacing?: TypographyTokenValue;\n fontWeight: TypographyTokenValue;\n boldFontWeight?: TypographyTokenValue;\n iconSize?: TypographyTokenValue;\n textTransform?: TypographyTokenValue;\n fontFamily?: TypographyTokenValue;\n fontStyle?: TypographyTokenValue;\n}\n\n/**\n * Generate typography tokens with $ prefix for CSS custom properties.\n *\n * Each preset generates the following CSS custom properties:\n * - `${name}-font-size`\n * - `${name}-line-height`\n * - `${name}-letter-spacing`\n * - `${name}-font-weight`\n * - `${name}-bold-font-weight` (if defined)\n * - `${name}-icon-size` (if defined)\n * - `${name}-text-transform` (if defined)\n * - `${name}-font-family` (if defined)\n * - `${name}-font-style` (if defined)\n *\n * @param presets - Typography presets object\n * @returns ConfigTokens object with $ prefixed keys\n *\n * @example\n * const customTokens = generateTypographyTokens({\n * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },\n * body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },\n * });\n */\nexport function generateTypographyTokens(\n presets: Record<string, TypographyPreset>,\n): ConfigTokens {\n const tokens: ConfigTokens = {} as ConfigTokens;\n\n for (const [name, preset] of Object.entries(presets)) {\n if (RESERVED_PRESET_NAMES.has(name)) {\n throw new Error(\n `Invalid typography preset name \"${name}\". This name is reserved as a preset modifier.`,\n );\n }\n\n tokens[`$${name}-font-size`] = preset.fontSize;\n tokens[`$${name}-line-height`] = preset.lineHeight;\n tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? 'normal';\n tokens[`$${name}-font-weight`] = preset.fontWeight;\n\n if (preset.boldFontWeight !== undefined) {\n tokens[`$${name}-bold-font-weight`] = preset.boldFontWeight;\n }\n\n if (preset.iconSize !== undefined) {\n tokens[`$${name}-icon-size`] = preset.iconSize;\n }\n\n if (preset.textTransform !== undefined) {\n tokens[`$${name}-text-transform`] = preset.textTransform;\n }\n\n if (preset.fontFamily !== undefined) {\n tokens[`$${name}-font-family`] = preset.fontFamily;\n }\n\n if (preset.fontStyle !== undefined) {\n tokens[`$${name}-font-style`] = preset.fontStyle;\n }\n }\n\n return tokens;\n}\n","/**\n * Configuration processing shared by runtime and build-time paths.\n *\n * Plugins are folded first and direct configuration wins. Keeping this step\n * independent from the DOM injector lets zero-runtime tooling reuse the exact\n * same precedence and style-engine setup without loading browser infrastructure.\n */\n\nimport { registerFunctionPolyfill, splitFunctions } from './functions';\nimport {\n isFunctionsPolyfillEnabled,\n setGlobalPolyfillsState,\n} from './config-state';\nimport { setGlobalPredefinedStates } from './states';\nimport {\n normalizeHandlerDefinition,\n registerHandler,\n} from './styles/predefined';\nimport {\n CUSTOM_UNITS,\n getGlobalParseFunctions,\n getGlobalParser,\n normalizeColorTokenValue,\n setGlobalPredefinedTokens,\n} from './utils/styles';\nimport { generateTypographyTokens } from './utils/typography';\n\nimport type { TastyConfig } from './config';\nimport type { FunctionsConfig } from './functions';\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport type { UnitHandler } from './parser/types';\nimport type { PropHandlerDefinition } from './prop-handlers';\nimport type { ConfigTokens, RecipeStyles, Styles } from './styles/types';\nimport type { StyleHandlerDefinition } from './utils/styles';\nimport type { TypographyPreset } from './utils/typography';\n\nexport interface NormalizedConfig {\n states: Record<string, string>;\n units: Record<string, string | UnitHandler>;\n functions: FunctionsConfig;\n handlers: Record<string, StyleHandlerDefinition>;\n handlerSources: Map<string, string>;\n propHandlers: Record<string, PropHandlerDefinition>;\n propHandlerSources: Map<string, string>;\n baseStyleProps: string[];\n properties: Record<string, PropertyDefinition>;\n keyframes: Record<string, KeyframesSteps>;\n fontFaces: Record<string, FontFaceInput>;\n counterStyles: Record<string, CounterStyleDescriptors>;\n replaceTokens: Record<string, string | number | boolean>;\n tokens: ConfigTokens;\n recipes: Record<string, RecipeStyles>;\n globalStyles: Record<string, Styles>;\n}\n\ntype WarnOnce = (key: string, message: string) => void;\n\n/** Apply parser and style-engine configuration shared by every renderer. */\nexport function applyStyleConfig(\n config: Partial<TastyConfig>,\n normalized: NormalizedConfig,\n warnOnce: WarnOnce,\n): Record<string, FunctionDefinition> {\n const tokenKeys = new Set(Object.keys(normalized.tokens));\n for (const key of Object.keys(normalized.replaceTokens)) {\n if (tokenKeys.has(key)) {\n warnOnce(\n `token-conflict-${key}`,\n `[Tasty] Token \"${key}\" is defined in both \\`tokens\\` and \\`replaceTokens\\`. ` +\n `\\`replaceTokens\\` performs parse-time substitution, so the \\`tokens\\` ` +\n `CSS custom property will be injected but never used by Tasty styles. ` +\n `Remove it from one of the two.`,\n );\n }\n }\n\n if (config.colorSpace) {\n warnOnce(\n 'colorSpace-deprecated',\n '[Tasty] configure({ colorSpace }) no longer has any effect and will be ' +\n 'removed in the next major. Colors are emitted as authored, and opacity ' +\n \"is applied with relative color syntax, which reads a color's channels \" +\n 'in the browser. To address channels yourself, write ' +\n '`oklch(from var(--name-color) l c h)` against the token.',\n );\n }\n\n if (Object.keys(normalized.states).length > 0) {\n setGlobalPredefinedStates(normalized.states);\n }\n\n const parser = getGlobalParser();\n if (config.parserCacheSize !== undefined) {\n parser.updateOptions({ cacheSize: config.parserCacheSize });\n }\n if (Object.keys(normalized.units).length > 0) {\n const currentUnits = parser.getUnits() ?? CUSTOM_UNITS;\n parser.setUnits({ ...currentUnits, ...normalized.units });\n }\n\n if (config.polyfills) setGlobalPolyfillsState(config.polyfills);\n\n const { parseFuncs, functionDefs } = splitFunctions(\n normalized.functions,\n (key, kind) => {\n warnOnce(\n `functions-mismatch-${key}`,\n kind === 'expected-definition'\n ? `[Tasty] functions[\"${key}\"]: a \"$$\"-prefixed key denotes a CSS @function ` +\n `and expects a definition object, but received a function. Entry ignored.`\n : `[Tasty] functions[\"${key}\"]: a bare key denotes a parse function and ` +\n `expects a function value, but received an object. ` +\n `Did you mean \"$$${key}\"? Entry ignored.`,\n );\n },\n );\n\n if (Object.keys(parseFuncs).length > 0) {\n const currentFuncs = getGlobalParseFunctions();\n parser.setFunctions({ ...currentFuncs, ...parseFuncs });\n Object.assign(currentFuncs, parseFuncs);\n }\n\n if (isFunctionsPolyfillEnabled()) {\n for (const [name, definition] of Object.entries(functionDefs)) {\n registerFunctionPolyfill(name, definition);\n }\n }\n\n for (const [name, definition] of Object.entries(normalized.handlers)) {\n const handler = normalizeHandlerDefinition(name, definition);\n registerHandler(handler, {\n key: name,\n source: normalized.handlerSources.get(name),\n });\n }\n\n if (Object.keys(normalized.replaceTokens).length > 0) {\n const processedTokens: Record<string, string> = {};\n for (const [key, value] of Object.entries(normalized.replaceTokens)) {\n if (key.startsWith('#')) {\n const normalizedValue = normalizeColorTokenValue(value);\n if (normalizedValue === null) continue;\n processedTokens[key] = String(normalizedValue);\n } else if (value !== false) {\n processedTokens[key] = String(value);\n }\n }\n setGlobalPredefinedTokens(processedTokens);\n }\n\n return functionDefs;\n}\n\n/** Merge an optional configuration record into an accumulated record. */\nfunction mergeRecord<T extends object>(target: T, source?: Partial<T>): T {\n return source ? { ...target, ...source } : target;\n}\n\n/** Merge a named extension record and retain where each winning entry came from. */\nfunction mergeSourcedRecord<T>(\n target: Record<string, T>,\n source: Record<string, T> | undefined,\n sources: Map<string, string>,\n pluginName?: string,\n): Record<string, T> {\n if (!source) return target;\n\n const label =\n pluginName === undefined ? 'configure()' : `plugin \"${pluginName}\"`;\n for (const key of Object.keys(source)) sources.set(key, label);\n\n return { ...target, ...source };\n}\n\nexport function normalizeConfig(\n config: Partial<TastyConfig>,\n): NormalizedConfig {\n let states: Record<string, string> = {};\n let units: Record<string, string | UnitHandler> = {};\n let functions: FunctionsConfig = {};\n let handlers: Record<string, StyleHandlerDefinition> = {};\n const handlerSources = new Map<string, string>();\n let propHandlers: Record<string, PropHandlerDefinition> = {};\n const propHandlerSources = new Map<string, string>();\n const baseStyleProps: string[] = [];\n let properties: Record<string, PropertyDefinition> = {};\n let keyframes: Record<string, KeyframesSteps> = {};\n let fontFaces: Record<string, FontFaceInput> = {};\n let counterStyles: Record<string, CounterStyleDescriptors> = {};\n let replaceTokens: Record<string, string | number | boolean> = {};\n let tokens: ConfigTokens = {} as ConfigTokens;\n let recipes: Record<string, RecipeStyles> = {};\n let presets: Record<string, TypographyPreset> = {};\n const globalStyles: Record<string, Styles> = {};\n\n for (const plugin of config.plugins ?? []) {\n states = mergeRecord(states, plugin.states);\n units = mergeRecord(units, plugin.units);\n functions = mergeRecord(functions, plugin.functions);\n handlers = mergeSourcedRecord(\n handlers,\n plugin.handlers,\n handlerSources,\n plugin.name,\n );\n propHandlers = mergeSourcedRecord(\n propHandlers,\n plugin.propHandlers,\n propHandlerSources,\n plugin.name,\n );\n if (plugin.baseStyleProps) baseStyleProps.push(...plugin.baseStyleProps);\n properties = mergeRecord(properties, plugin.properties);\n keyframes = mergeRecord(keyframes, plugin.keyframes);\n fontFaces = mergeRecord(fontFaces, plugin.fontFaces);\n counterStyles = mergeRecord(counterStyles, plugin.counterStyles);\n replaceTokens = mergeRecord(replaceTokens, plugin.replaceTokens);\n tokens = mergeRecord(tokens, plugin.tokens);\n recipes = mergeRecord(recipes, plugin.recipes);\n presets = mergeRecord(presets, plugin.presets);\n mergeGlobalStyles(globalStyles, plugin.globalStyles);\n }\n\n states = mergeRecord(states, config.states);\n units = mergeRecord(units, config.units);\n functions = mergeRecord(functions, config.functions);\n handlers = mergeSourcedRecord(handlers, config.handlers, handlerSources);\n propHandlers = mergeSourcedRecord(\n propHandlers,\n config.propHandlers,\n propHandlerSources,\n );\n if (config.baseStyleProps) baseStyleProps.push(...config.baseStyleProps);\n properties = mergeRecord(properties, config.properties);\n keyframes = mergeRecord(keyframes, config.keyframes);\n fontFaces = mergeRecord(fontFaces, config.fontFaces);\n counterStyles = mergeRecord(counterStyles, config.counterStyles);\n replaceTokens = mergeRecord(replaceTokens, config.replaceTokens);\n presets = mergeRecord(presets, config.presets);\n\n if (Object.keys(presets).length > 0) {\n tokens = { ...generateTypographyTokens(presets), ...tokens };\n }\n\n tokens = mergeRecord(tokens, config.tokens);\n recipes = mergeRecord(recipes, config.recipes);\n mergeGlobalStyles(globalStyles, config.globalStyles);\n\n return {\n states,\n units,\n functions,\n handlers,\n handlerSources,\n propHandlers,\n propHandlerSources,\n baseStyleProps,\n properties,\n keyframes,\n fontFaces,\n counterStyles,\n replaceTokens,\n tokens,\n recipes,\n globalStyles,\n };\n}\n\nfunction mergeGlobalStyles(\n target: Record<string, Styles>,\n source?: Record<string, Styles>,\n): void {\n if (!source) return;\n\n for (const [selector, styles] of Object.entries(source)) {\n target[selector] = target[selector]\n ? { ...target[selector], ...styles }\n : styles;\n }\n}\n","/**\n * Recipe resolution utility.\n *\n * Resolves `recipe` style properties by looking up predefined recipe styles\n * from global configuration and merging them with the component's own styles.\n *\n * Resolution order per level (top-level and each sub-element independently):\n * base_recipe_1 base_recipe_2 → component styles → post_recipe_1 post_recipe_2\n *\n * The `/` separator splits base recipes (before component styles)\n * from post recipes (after component styles). All merges use mergeStyles\n * semantics: primitives and state maps with '' key fully replace;\n * state maps without '' key extend the existing value.\n *\n * Returns the same object reference if no recipes are present (zero overhead).\n */\n\nimport type { RecipeStyles, Styles } from '../styles/types';\n\nimport { isDevEnv } from './is-dev-env';\nimport { isSelector } from './is-selector';\nimport { mergeStyles } from './merge-styles';\n\nconst devMode = isDevEnv();\n\ninterface ParsedRecipeGroups {\n base: string[] | null;\n post: string[] | null;\n}\n\n/**\n * Parse a recipe string into base and post recipe name groups.\n *\n * Syntax: `'base1 base2 / post1 post2'`\n * - Names are space-separated within each group\n * - `/` separates base (before component) from post (after component) groups\n * - `/` is optional; if absent, all names are base\n * - `none` as the sole base value means \"no base recipes\"\n *\n * Returns `{ base: null, post: null }` if the string is empty or invalid.\n */\nfunction parseRecipeNames(value: unknown): ParsedRecipeGroups {\n const empty: ParsedRecipeGroups = { base: null, post: null };\n\n if (typeof value !== 'string') return empty;\n const trimmed = value.trim();\n if (trimmed === '') return empty;\n\n const slashIndex = trimmed.indexOf('/');\n\n if (slashIndex === -1) {\n if (trimmed === 'none') return empty;\n const names = splitNames(trimmed);\n return { base: names, post: null };\n }\n\n const basePart = trimmed.slice(0, slashIndex);\n const postPart = trimmed.slice(slashIndex + 1);\n\n return {\n base: basePart.trim() === 'none' ? null : splitNames(basePart),\n post: splitNames(postPart),\n };\n}\n\nfunction splitNames(s: string): string[] | null {\n const names = s.split(/\\s+/).filter(Boolean);\n return names.length > 0 ? names : null;\n}\n\n/**\n * Collect merged styles for a list of recipe names.\n * Each recipe is flat-spread on top of the previous.\n */\nfunction collectRecipeStyles(\n names: string[],\n recipes: Record<string, RecipeStyles>,\n): Record<string, unknown> {\n let merged: Record<string, unknown> = {};\n\n for (const name of names) {\n const recipeStyles = recipes[name];\n\n if (!recipeStyles) {\n if (devMode) {\n console.warn(\n `[Tasty] Recipe \"${name}\" not found. ` +\n `Make sure it is defined in configure({ recipes: { ... } }).`,\n );\n }\n continue;\n }\n\n merged = { ...merged, ...(recipeStyles as Record<string, unknown>) };\n }\n\n return merged;\n}\n\n/**\n * Resolve recipe references in a flat styles object (no sub-elements).\n * Returns null if no `recipe` key is present.\n *\n * Resolution: base recipes → component styles → post recipes (all via mergeStyles)\n */\nfunction resolveRecipesForLevel(\n styles: Record<string, unknown>,\n recipes: Record<string, RecipeStyles>,\n): Record<string, unknown> | null {\n if (!('recipe' in styles)) return null;\n\n const { base, post } = parseRecipeNames(styles.recipe);\n\n // Separate selector keys (sub-elements) from flat style properties.\n // mergeStyles handles selectors with its own semantics (e.g. false = delete),\n // but at this level we only want recipe merging on flat properties.\n\n const { recipe: _recipe, ...allRest } = styles;\n const flatStyles: Record<string, unknown> = {};\n const selectorStyles: Record<string, unknown> = {};\n\n for (const key of Object.keys(allRest)) {\n if (isSelector(key)) {\n selectorStyles[key] = allRest[key];\n } else {\n flatStyles[key] = allRest[key];\n }\n }\n\n if (!base && !post) {\n return allRest;\n }\n\n // 1. Merge base recipes, then component styles on top (via mergeStyles)\n let result: Record<string, unknown>;\n\n if (base) {\n const baseStyles = collectRecipeStyles(base, recipes);\n result = mergeStyles(baseStyles as Styles, flatStyles as Styles) as Record<\n string,\n unknown\n >;\n } else {\n result = { ...flatStyles };\n }\n\n // 2. Apply post recipes via mergeStyles (state map extend semantics)\n if (post) {\n const postStyles = collectRecipeStyles(post, recipes);\n result = mergeStyles(result as Styles, postStyles as Styles) as Record<\n string,\n unknown\n >;\n }\n\n // Re-attach selector keys unchanged\n for (const key of Object.keys(selectorStyles)) {\n result[key] = selectorStyles[key];\n }\n\n return result;\n}\n\n/**\n * Resolve all `recipe` style properties in a styles object.\n *\n * Handles both top-level and sub-element recipe references.\n * Returns the same object reference if no recipes are present anywhere\n * (zero overhead for the common case).\n *\n * @param styles - The styles object potentially containing `recipe` keys\n * @returns Resolved styles with recipe values merged in, or the original object if unchanged\n */\nexport function resolveRecipesWith(\n styles: Styles,\n recipes: Record<string, RecipeStyles> | null,\n): Styles {\n // Fast path: no recipes configured\n if (!recipes) return styles;\n\n let changed = false;\n\n // Resolve top-level recipe\n const topResolved = resolveRecipesForLevel(\n styles as Record<string, unknown>,\n recipes,\n );\n\n let result: Record<string, unknown>;\n\n if (topResolved) {\n changed = true;\n result = topResolved;\n } else {\n // Keep reference; a shallow copy is deferred until a sub-element actually changes\n result = styles as Record<string, unknown>;\n }\n\n // Resolve sub-element recipes\n const keys = Object.keys(result);\n\n for (const key of keys) {\n if (!isSelector(key)) continue;\n\n const subStyles = result[key];\n\n if (\n !subStyles ||\n typeof subStyles !== 'object' ||\n Array.isArray(subStyles)\n ) {\n continue;\n }\n\n const subRecord = subStyles as Record<string, unknown>;\n\n if (!('recipe' in subRecord)) continue;\n\n const subResolved = resolveRecipesForLevel(subRecord, recipes);\n\n if (subResolved) {\n if (!changed) {\n // First change in sub-elements -- need to shallow-copy the top level\n changed = true;\n result = { ...(styles as Record<string, unknown>) };\n }\n // Define an own data property so even an untrusted key cannot invoke an\n // inherited setter such as Object.prototype.__proto__.\n Object.defineProperty(result, key, {\n configurable: true,\n enumerable: true,\n value: subResolved,\n writable: true,\n });\n }\n }\n\n return changed ? (result as Styles) : styles;\n}\n"],"mappings":";;;;;AAEA,MAAM,wCAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;AACF,CAAC;AA0DD,SAAgB,yBACd,SACc;CACd,MAAM,SAAuB,CAAC;CAE9B,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,OAAO,GAAG;EACpD,IAAI,sBAAsB,IAAI,IAAI,GA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,UAAoB;CAIjE,OACE,SAAS,EAAE,GAAG,WAAW;CAI3B,IAAI,MAAM;EACR,MAAM,aAAa,oBAAoB,MAAM,OAAO;EACpD,SAAS,YAAY,QAAkB,UAAoB;CAI7D;CAGA,KAAK,MAAM,OAAO,OAAO,KAAK,cAAc,GAC1C,OAAO,OAAO,eAAe;CAG/B,OAAO;AACT;AAYA,SAAgB,mBACd,QACA,SACQ;CAER,IAAI,CAAC,SAAS,OAAO;CAErB,IAAI,UAAU;CAGd,MAAM,cAAc,uBAClB,QACA,OACF;CAEA,IAAI;CAEJ,IAAI,aAAa;EACf,UAAU;EACV,SAAS;CACX,OAEE,SAAS;CAIX,MAAM,OAAO,OAAO,KAAK,MAAM;CAE/B,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,CAAC,WAAW,GAAG,GAAG;EAEtB,MAAM,YAAY,OAAO;EAEzB,IACE,CAAC,aACD,OAAO,cAAc,YACrB,MAAM,QAAQ,SAAS,GAEvB;EAGF,MAAM,YAAY;EAElB,IAAI,EAAE,YAAY,YAAY;EAE9B,MAAM,cAAc,uBAAuB,WAAW,OAAO;EAE7D,IAAI,aAAa;GACf,IAAI,CAAC,SAAS;IAEZ,UAAU;IACV,SAAS,EAAE,GAAI,OAAmC;GACpD;GAGA,OAAO,eAAe,QAAQ,KAAK;IACjC,cAAc;IACd,YAAY;IACZ,OAAO;IACP,UAAU;GACZ,CAAC;EACH;CACF;CAEA,OAAO,UAAW,SAAoB;AACxC"}
@@ -0,0 +1,25 @@
1
+ import { createRequire } from "node:module";
2
+ import * as path from "node:path";
3
+ //#region src/zero/config-file.ts
4
+ const packageRequire = createRequire(import.meta.url);
5
+ let createJiti;
6
+ function loadJiti() {
7
+ if (createJiti) return createJiti;
8
+ let jitiPath;
9
+ try {
10
+ jitiPath = packageRequire.resolve("jiti");
11
+ } catch (error) {
12
+ if (error instanceof Error && "code" in error && error.code === "MODULE_NOT_FOUND") throw new Error("[Tasty] `configFile` requires the optional `jiti` package. Install `jiti` or pass the imported config through `config` instead.", { cause: error });
13
+ throw error;
14
+ }
15
+ createJiti = packageRequire(jitiPath).createJiti;
16
+ return createJiti;
17
+ }
18
+ function loadConfigFile(file, baseDir = path.dirname(file)) {
19
+ const loaded = loadJiti()(baseDir, { moduleCache: false })(file);
20
+ return loaded && typeof loaded === "object" && "default" in loaded ? loaded.default : loaded;
21
+ }
22
+ //#endregion
23
+ export { loadConfigFile as t };
24
+
25
+ //# sourceMappingURL=config-file-DlZXJMj8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-file-DlZXJMj8.js","names":[],"sources":["../../src/zero/config-file.ts"],"sourcesContent":["/**\n * Loads a Tasty config file (`tasty.config.ts` and friends) through `jiti`.\n *\n * `jiti` is an optional peer dependency, needed only for `configFile`. It is\n * resolved on first use rather than imported, so the Babel plugin and the\n * Next.js wrappers load without it when the config is passed in directly.\n */\n\nimport { createRequire } from 'node:module';\nimport * as path from 'node:path';\n\nimport type { createJiti as createJitiType } from 'jiti';\n\nconst packageRequire = createRequire(import.meta.url);\n\nlet createJiti: typeof createJitiType | undefined;\n\nfunction loadJiti(): typeof createJitiType {\n if (createJiti) return createJiti;\n\n let jitiPath: string;\n try {\n jitiPath = packageRequire.resolve('jiti');\n } catch (error) {\n if (\n error instanceof Error &&\n 'code' in error &&\n error.code === 'MODULE_NOT_FOUND'\n ) {\n throw new Error(\n '[Tasty] `configFile` requires the optional `jiti` package. Install `jiti` or pass the imported config through `config` instead.',\n { cause: error },\n );\n }\n throw error;\n }\n\n createJiti = (\n packageRequire(jitiPath) as { createJiti: typeof createJitiType }\n ).createJiti;\n return createJiti;\n}\n\n/**\n * Load `file` fresh (no module cache) and return its default export, or the\n * module itself when it has none. Relative imports inside the file resolve\n * from `baseDir`, which defaults to the file's own directory.\n */\nexport function loadConfigFile<T>(\n file: string,\n baseDir: string = path.dirname(file),\n): T {\n const jiti = loadJiti()(baseDir, { moduleCache: false });\n const loaded = jiti(file) as T | { default: T };\n\n // jiti returns the ESM namespace, so unwrap `default` when present.\n return loaded && typeof loaded === 'object' && 'default' in loaded\n ? (loaded.default as T)\n : (loaded as T);\n}\n"],"mappings":";;;AAaA,MAAM,iBAAiB,cAAc,YAAY,GAAG;AAEpD,IAAI;AAEJ,SAAS,WAAkC;CACzC,IAAI,YAAY,OAAO;CAEvB,IAAI;CACJ,IAAI;EACF,WAAW,eAAe,QAAQ,MAAM;CAC1C,SAAS,OAAO;EACd,IACE,iBAAiB,SACjB,UAAU,SACV,MAAM,SAAS,oBAEf,MAAM,IAAI,MACR,mIACA,EAAE,OAAO,MAAM,CACjB;EAEF,MAAM;CACR;CAEA,aACE,eAAe,QAAQ,CAAC,CACxB;CACF,OAAO;AACT;AAOA,SAAgB,eACd,MACA,UAAkB,KAAK,QAAQ,IAAI,GAChC;CAEH,MAAM,SADO,SAAS,CAAC,CAAC,SAAS,EAAE,aAAa,MAAM,CACpC,CAAC,CAAC,IAAI;CAGxB,OAAO,UAAU,OAAO,WAAW,YAAY,aAAa,SACvD,OAAO,UACP;AACP"}
@@ -1,8 +1,8 @@
1
- import { F as RE_RAW_UNIT, P as RE_NUMBER, a as customFunction, f as parseStyle } from "./dsl-C5yuAn41.js";
2
- import { C as STYLE_HANDLER_MAP, k as createStyle } from "./style-engine-C1ECBZxR.js";
1
+ import { F as RE_RAW_UNIT, P as RE_NUMBER, a as customFunction, f as parseStyle } from "./dsl-Ddc5EUBK.js";
2
+ import { M as createStyle, T as STYLE_HANDLER_MAP, j as scanAnimationNames } from "./style-engine-C2Z26n3a.js";
3
3
  //#region src/functions/index.ts
4
4
  const FUNCTION_KEY = "@function";
5
- const RESERVED_KEYS = new Set([
5
+ const RESERVED_KEYS = /* @__PURE__ */ new Set([
6
6
  "args",
7
7
  "returns",
8
8
  "result"
@@ -180,6 +180,7 @@ function resetFunctionPolyfills() {
180
180
  }
181
181
  //#endregion
182
182
  //#region src/properties/defaults.ts
183
+ const DEFAULT_TRANSITION = "80ms";
183
184
  const DEFAULT_PROPERTIES = {
184
185
  "#tasty-second-fill": {
185
186
  inherits: false,
@@ -197,13 +198,13 @@ const DEFAULT_PROPERTIES = {
197
198
  inherits: true,
198
199
  initialValue: "rgb(0 0 0)"
199
200
  },
200
- "#clear": {
201
+ "#border": {
201
202
  inherits: true,
202
- initialValue: "transparent"
203
+ initialValue: "currentcolor"
203
204
  },
204
- "#border": {
205
+ "#outline": {
205
206
  inherits: true,
206
- initialValue: "rgb(0 0 0)"
207
+ initialValue: "currentcolor"
207
208
  },
208
209
  $gap: {
209
210
  syntax: "<length>",
@@ -228,7 +229,7 @@ const DEFAULT_PROPERTIES = {
228
229
  $transition: {
229
230
  syntax: "<time>",
230
231
  inherits: true,
231
- initialValue: "80ms"
232
+ initialValue: DEFAULT_TRANSITION
232
233
  },
233
234
  "$sharp-radius": {
234
235
  syntax: "<length>",
@@ -402,7 +403,8 @@ function inferSyntaxFromValue(value) {
402
403
  }
403
404
  const unitMatch = trimmed.match(RE_RAW_UNIT);
404
405
  if (unitMatch) {
405
- const mapping = UNIT_TO_SYNTAX[unitMatch[2]];
406
+ const unit = unitMatch[2];
407
+ const mapping = UNIT_TO_SYNTAX[unit];
406
408
  if (mapping) return mapping;
407
409
  }
408
410
  return null;
@@ -595,7 +597,6 @@ function formatCounterStyleRule(name, descriptors) {
595
597
  //#endregion
596
598
  //#region src/keyframes/index.ts
597
599
  const KEYFRAMES_KEY = "@keyframes";
598
- const NON_NAME_KEYWORDS = new Set("none initial inherit unset revert auto normal running paused reverse alternate alternate-reverse forwards backwards both ease linear ease-in ease-out ease-in-out step-start step-end".split(" "));
599
600
  function hasLocalKeyframes(styles) {
600
601
  return KEYFRAMES_KEY in styles;
601
602
  }
@@ -613,21 +614,8 @@ function mergeKeyframes(local, global) {
613
614
  ...local
614
615
  };
615
616
  }
616
- function extractAnimationNameFromValue(value) {
617
- for (const part of value.trim().split(/\s+/)) {
618
- const lower = part.toLowerCase();
619
- if (NON_NAME_KEYWORDS.has(lower)) continue;
620
- if (part === "infinite" || /^(?:-?[\d.]+m?s|\d+|(?:cubic-bezier|steps)\()/i.test(part)) continue;
621
- const match = /^([a-zA-Z_-][a-zA-Z0-9_-]*)/.exec(part);
622
- if (match) return match[1];
623
- }
624
- return null;
625
- }
626
617
  function collectAnimationNamesFromValue(value, names) {
627
- for (const animation of value.split(",")) {
628
- const name = extractAnimationNameFromValue(animation);
629
- if (name) names.add(name);
630
- }
618
+ for (const item of scanAnimationNames(value)) if (item) names.add(item.name);
631
619
  }
632
620
  function extractAnimationNamesFromStyleValue(value, names) {
633
621
  if (typeof value === "string") collectAnimationNamesFromValue(value, names);
@@ -711,6 +699,37 @@ function filterUsedKeyframes(keyframes, usedNames) {
711
699
  }
712
700
  return hasAny ? used : null;
713
701
  }
702
+ function resolveSelectorKeyframes(styles, rules, globalKeyframes) {
703
+ const usedNames = extractAnimationNamesFromStyles(styles);
704
+ if (usedNames.size === 0) return {
705
+ rules,
706
+ keyframes: null
707
+ };
708
+ const used = filterUsedKeyframes(mergeKeyframes(hasLocalKeyframes(styles) ? extractLocalKeyframes(styles) : null, globalKeyframes), usedNames);
709
+ if (!used) return {
710
+ rules,
711
+ keyframes: null
712
+ };
713
+ const names = resolveKeyframesNames(used);
714
+ const referenced = /* @__PURE__ */ new Set();
715
+ const renamed = rules.map((rule) => {
716
+ const declarations = replaceAnimationNames(rule.declarations, names, referenced);
717
+ return declarations === rule.declarations ? rule : {
718
+ ...rule,
719
+ declarations
720
+ };
721
+ });
722
+ if (referenced.size === 0) return {
723
+ rules,
724
+ keyframes: null
725
+ };
726
+ const keyframes = /* @__PURE__ */ new Map();
727
+ for (const [authored, steps] of Object.entries(used)) if (referenced.has(authored)) keyframes.set(names.get(authored), steps);
728
+ return {
729
+ rules: renamed,
730
+ keyframes
731
+ };
732
+ }
714
733
  //#endregion
715
734
  //#region src/ssr/format-property.ts
716
735
  function formatPropertyCSS(token, definition) {
@@ -737,11 +756,13 @@ function buildPropertyRule(cssName, definition) {
737
756
  }
738
757
  //#endregion
739
758
  //#region src/ssr/format-keyframes.ts
740
- function stepsToCSS(steps) {
759
+ function formatKeyframesSteps(steps) {
741
760
  const rules = [];
761
+ const allDeclarations = [];
742
762
  for (const [key, value] of Object.entries(steps)) {
743
763
  if (typeof value === "string") {
744
764
  rules.push(`${key} { ${value.trim()} }`);
765
+ allDeclarations.push(value.trim());
745
766
  continue;
746
767
  }
747
768
  const styleMap = value || {};
@@ -786,11 +807,15 @@ function stepsToCSS(steps) {
786
807
  });
787
808
  const declarations = declarationPairs.map((d) => `${d.prop}: ${d.value}`).join("; ");
788
809
  rules.push(`${key} { ${declarations.trim()} }`);
810
+ if (declarations) allDeclarations.push(declarations);
789
811
  }
790
- return rules.join(" ");
812
+ return {
813
+ css: rules.join(" "),
814
+ declarations: allDeclarations.join("; ")
815
+ };
791
816
  }
792
817
  function formatKeyframesCSS(name, steps) {
793
- return `@keyframes ${name} { ${stepsToCSS(steps)} }`;
818
+ return `@keyframes ${name} { ${formatKeyframesSteps(steps).css} }`;
794
819
  }
795
820
  //#endregion
796
821
  //#region src/ssr/format-rules.ts
@@ -851,7 +876,7 @@ function formatGlobalRules(rules) {
851
876
  if (rules.length === 0) return "";
852
877
  const cssRules = [];
853
878
  for (const rule of rules) {
854
- const baseRule = `${rule.rootPrefix ? `${rule.rootPrefix} ${rule.selector}` : rule.selector} { ${rule.declarations} }`;
879
+ const baseRule = `${rule.rootPrefix ? `${rule.rootPrefix} ${rule.selector}` : rule.selector} { ${rule.startingStyle ? `@starting-style { ${rule.declarations} }` : rule.declarations} }`;
855
880
  let fullRule = baseRule;
856
881
  if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
857
882
  cssRules.push(fullRule);
@@ -870,6 +895,6 @@ function createServerStyleArtifact(kind, key, css, order) {
870
895
  };
871
896
  }
872
897
  //#endregion
873
- export { validateNamePrefix as A, formatFunctionPrelude as B, DEFAULT_NAME_PREFIX as C, makeKeyframeName as D, makeCounterStyleName as E, normalizePropertyDefinition as F, registerLocalFunctionPolyfills as G, hasLocalFunctions as H, parsePropertyToken as I, resetFunctionPolyfills as K, DEFAULT_PROPERTIES as L, extractLocalProperties as M, getEffectiveDefinition as N, rscClassRegexGlobal as O, hasLocalProperties as P, extractLocalFunctions as R, PropertyTypeResolver as S, makeClassName as T, parseFunctionName as U, formatFunctionRule as V, registerFunctionPolyfill as W, extractLocalFontFace as _, formatPropertyCSS as a, formatFontFaceRule as b, filterUsedKeyframes as c, replaceAnimationNames as d, resolveKeyframesNames as f, hasLocalCounterStyle as g, formatCounterStyleRule as h, formatKeyframesCSS as i, hashString as j, tastyClassRegex as k, hasLocalKeyframes as l, formatCounterStyleDeclarations as m, formatGlobalRules as n, extractAnimationNamesFromStyles as o, extractLocalCounterStyle as p, splitFunctions as q, formatRules as r, extractLocalKeyframes as s, createServerStyleArtifact as t, mergeKeyframes as u, fontFaceContentHash as v, DEFAULT_ZERO_NAME_PREFIX as w, hasLocalFontFace as x, formatFontFaceDeclarations as y, formatFunctionDeclarations as z };
898
+ export { rscClassRegexGlobal as A, DEFAULT_TRANSITION as B, hasLocalFontFace as C, makeClassName as D, DEFAULT_ZERO_NAME_PREFIX as E, getEffectiveDefinition as F, hasLocalFunctions as G, formatFunctionDeclarations as H, hasLocalProperties as I, registerLocalFunctionPolyfills as J, parseFunctionName as K, normalizePropertyDefinition as L, validateNamePrefix as M, hashString as N, makeCounterStyleName as O, extractLocalProperties as P, parsePropertyToken as R, formatFontFaceRule as S, DEFAULT_NAME_PREFIX as T, formatFunctionPrelude as U, extractLocalFunctions as V, formatFunctionRule as W, splitFunctions as X, resetFunctionPolyfills as Y, formatCounterStyleRule as _, formatKeyframesSteps as a, fontFaceContentHash as b, extractLocalKeyframes as c, mergeKeyframes as d, replaceAnimationNames as f, formatCounterStyleDeclarations as g, extractLocalCounterStyle as h, formatKeyframesCSS as i, tastyClassRegex as j, makeKeyframeName as k, filterUsedKeyframes as l, resolveSelectorKeyframes as m, formatGlobalRules as n, formatPropertyCSS as o, resolveKeyframesNames as p, registerFunctionPolyfill as q, formatRules as r, extractAnimationNamesFromStyles as s, createServerStyleArtifact as t, hasLocalKeyframes as u, hasLocalCounterStyle as v, PropertyTypeResolver as w, formatFontFaceDeclarations as x, extractLocalFontFace as y, DEFAULT_PROPERTIES as z };
874
899
 
875
- //# sourceMappingURL=css-definitions-D_it4XZH.js.map
900
+ //# sourceMappingURL=css-definitions-DKApeTsI.js.map