@fluentic/style 0.1.0-beta.13 → 0.1.0-beta.14

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 (201) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +3 -2
  3. package/atomic/token.ts +10 -1
  4. package/builder/extract/token.ts +10 -0
  5. package/compiler/transform/evaluator/evaluator.ts +83 -9
  6. package/compiler/transform/evaluator/tracer.ts +4 -0
  7. package/compiler/transform/extract/plugin.ts +30 -4
  8. package/compiler/transform/extract/utils/imports.ts +5 -1
  9. package/compiler/transform/extract/utils/replacement.ts +15 -3
  10. package/compiler/transform/extract/utils/state.ts +2 -0
  11. package/compiler/transform/extract/utils/token.ts +107 -0
  12. package/compiler/utils/constants.ts +1 -0
  13. package/dialect/namedTokens.ts +13 -8
  14. package/dist/{combine-yuoQ_qpx.js → combine-CC9bY-hu.js} +2 -2
  15. package/dist/{combine-yuoQ_qpx.js.map → combine-CC9bY-hu.js.map} +1 -1
  16. package/dist/compiler/index.mjs +1 -1
  17. package/dist/{compiler-BEHxZYjz.mjs → compiler-Ct5xGIeu.mjs} +164 -24
  18. package/dist/compiler-Ct5xGIeu.mjs.map +1 -0
  19. package/dist/config/index.js +2 -2
  20. package/dist/{config-DggQEE-4.js → config-BiiMS4rU.js} +3 -3
  21. package/dist/{config-DggQEE-4.js.map → config-BiiMS4rU.js.map} +1 -1
  22. package/dist/{config-B5nEd-TV.js → config-CCgsVvyR.js} +2 -2
  23. package/dist/{config-B5nEd-TV.js.map → config-CCgsVvyR.js.map} +1 -1
  24. package/dist/{config-BWGBkVrM.js → config-DZKR6gH1.js} +4 -4
  25. package/dist/{config-BWGBkVrM.js.map → config-DZKR6gH1.js.map} +1 -1
  26. package/dist/{config-Bqe8Y-4_.js → config-TyjNpRrV.js} +2 -2
  27. package/dist/{config-Bqe8Y-4_.js.map → config-TyjNpRrV.js.map} +1 -1
  28. package/dist/{createTransformElement-B2jSnugo.js → createTransformElement-BGznW-Mu.js} +2 -2
  29. package/dist/{createTransformElement-B2jSnugo.js.map → createTransformElement-BGznW-Mu.js.map} +1 -1
  30. package/dist/{css-CGMAis1n.js → css-BhoclXaw.js} +5 -5
  31. package/dist/{css-CGMAis1n.js.map → css-BhoclXaw.js.map} +1 -1
  32. package/dist/{css-p_5ZNny_.js → css-IecKRNxs.js} +11 -11
  33. package/dist/{css-p_5ZNny_.js.map → css-IecKRNxs.js.map} +1 -1
  34. package/dist/{css-BQRIvzwZ.js → css-WaHZ6gxv.js} +6 -2
  35. package/dist/css-WaHZ6gxv.js.map +1 -0
  36. package/dist/css.js +1 -1
  37. package/dist/{css_extra-DuVzUIYx.js → css_extra-DDeJc2Cu.js} +2 -2
  38. package/dist/{css_extra-DuVzUIYx.js.map → css_extra-DDeJc2Cu.js.map} +1 -1
  39. package/dist/{data-QXDBLlWs.js → data-BgZmL55Y.js} +7 -8
  40. package/dist/{data-QXDBLlWs.js.map → data-BgZmL55Y.js.map} +1 -1
  41. package/dist/{debug-CkgcZDaX.js → debug-D-1hhd0G.js} +27 -3
  42. package/dist/debug-D-1hhd0G.js.map +1 -0
  43. package/dist/dev/rsc.js +6 -6
  44. package/dist/{dev-DocaGP3_.js → dev-CBRbVaeq.js} +6 -7
  45. package/dist/{dev-DocaGP3_.js.map → dev-CBRbVaeq.js.map} +1 -1
  46. package/dist/dev.js +1 -1
  47. package/dist/dialect/extracted/index.js +1 -1
  48. package/dist/dialect/index.js +1 -1
  49. package/dist/{elementMarker-DZjd1NuA.js → elementMarker-CJcfpKL1.js} +5 -6
  50. package/dist/{elementMarker-DZjd1NuA.js.map → elementMarker-CJcfpKL1.js.map} +1 -1
  51. package/dist/entry/dev/adapter/preact.js +1 -1
  52. package/dist/entry/dev/adapter/react.js +1 -1
  53. package/dist/entry/dev/adapter/solid.js +1 -1
  54. package/dist/entry/dev/css.js +2 -2
  55. package/dist/entry/dev/jsx-dev-runtime.js +2 -2
  56. package/dist/entry/dev/jsx-runtime.js +2 -2
  57. package/dist/entry/dev.js +11 -11
  58. package/dist/entry/prod/css.js +2 -2
  59. package/dist/entry/prod/extract.js +10 -1
  60. package/dist/entry/prod/extract.js.map +1 -1
  61. package/dist/entry/prod.js +2 -2
  62. package/dist/entry/rsc-dev/adapter/preact.js +1 -1
  63. package/dist/entry/rsc-dev/adapter/react.js +1 -1
  64. package/dist/entry/rsc-dev/adapter/solid.js +1 -1
  65. package/dist/entry/rsc-dev/css.js +2 -2
  66. package/dist/entry/rsc-dev/dev.js +5 -5
  67. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  68. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  69. package/dist/entry/rsc-dev.js +5 -5
  70. package/dist/entry/rsc-prod/css.js +2 -2
  71. package/dist/entry/rsc-prod.js +12 -3
  72. package/dist/entry/rsc-prod.js.map +1 -1
  73. package/dist/{env-DJyXPJ9q.js → env-C8TRVSyb.js} +5 -1
  74. package/dist/env-C8TRVSyb.js.map +1 -0
  75. package/dist/getClassName-9CsXbNls.js.map +1 -1
  76. package/dist/{getClassName-BB_L7U_v.js → getClassName-BNe3Ycyy.js} +4 -5
  77. package/dist/{getClassName-BB_L7U_v.js.map → getClassName-BNe3Ycyy.js.map} +1 -1
  78. package/dist/{getClassName-BIqt1S41.js → getClassName-CeoxISNW.js} +4 -4
  79. package/dist/{getClassName-BIqt1S41.js.map → getClassName-CeoxISNW.js.map} +1 -1
  80. package/dist/getClassName-DtkplEIt.js.map +1 -1
  81. package/dist/{global-CBQGormL.js → global-CWYOol4o.js} +2 -2
  82. package/dist/{global-CBQGormL.js.map → global-CWYOol4o.js.map} +1 -1
  83. package/dist/global-UOHFwqHN.js +33 -0
  84. package/dist/global-UOHFwqHN.js.map +1 -0
  85. package/dist/{debug-0iaVEC7z.js → hash-DlXmmPPm.js} +167 -5
  86. package/dist/hash-DlXmmPPm.js.map +1 -0
  87. package/dist/index.js +9 -9
  88. package/dist/jsx/jsx-dev-runtime.js +1 -1
  89. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  90. package/dist/jsx/jsx-runtime.js +1 -1
  91. package/dist/jsx/jsx-runtime.server.js +1 -1
  92. package/dist/{jsx-BCufpzdb.js → jsx-8TwYuvgM.js} +4 -4
  93. package/dist/{jsx-BCufpzdb.js.map → jsx-8TwYuvgM.js.map} +1 -1
  94. package/dist/{jsx_runtime-Bu_A8mr4.js → jsx_runtime-CPojW0KD.js} +2 -2
  95. package/dist/{jsx_runtime-Bu_A8mr4.js.map → jsx_runtime-CPojW0KD.js.map} +1 -1
  96. package/dist/{loader-vMHuD1zT.mjs → loader-BVebGteg.mjs} +3 -3
  97. package/dist/{loader-vMHuD1zT.mjs.map → loader-BVebGteg.mjs.map} +1 -1
  98. package/dist/{misc-9EGKYkZo.mjs → misc-Bs2DgdG7.mjs} +2 -2
  99. package/dist/{misc-9EGKYkZo.mjs.map → misc-Bs2DgdG7.mjs.map} +1 -1
  100. package/dist/{namedTokens-DnpyC5XT.js → namedTokens-CwniouKk.js} +13 -9
  101. package/dist/namedTokens-CwniouKk.js.map +1 -0
  102. package/dist/plugin/farm/index.mjs +3 -3
  103. package/dist/plugin/nextjs/index.mjs +4 -4
  104. package/dist/plugin/nextjs/loader.mjs +4 -4
  105. package/dist/plugin/parcel/index.cjs +1 -1
  106. package/dist/plugin/parcel/index.mjs +2 -2
  107. package/dist/plugin/parcel/optimizer.cjs +1 -1
  108. package/dist/plugin/parcel/optimizer.mjs +2 -2
  109. package/dist/plugin/parcel/resolver.cjs +1 -1
  110. package/dist/plugin/parcel/resolver.mjs +2 -2
  111. package/dist/plugin/parcel/runtime.cjs +1 -1
  112. package/dist/plugin/parcel/runtime.mjs +1 -1
  113. package/dist/plugin/parcel/transformer.cjs +1 -1
  114. package/dist/plugin/parcel/transformer.mjs +2 -2
  115. package/dist/plugin/rspack/index.mjs +2 -2
  116. package/dist/plugin/vite/index.mjs +3 -3
  117. package/dist/plugin/webpack/index.mjs +2 -2
  118. package/dist/plugin/webpack/loader.mjs +2 -2
  119. package/dist/presets/tailwind/index.js +3 -3
  120. package/dist/{registry-DVB7n6V-.mjs → registry-D1n78rd7.mjs} +2 -2
  121. package/dist/{registry-DVB7n6V-.mjs.map → registry-D1n78rd7.mjs.map} +1 -1
  122. package/dist/{resolveClassNameRuntime-DvH6j_4N.js → resolveClassNameRuntime-BJcykzdl.js} +2 -2
  123. package/dist/{resolveClassNameRuntime-DvH6j_4N.js.map → resolveClassNameRuntime-BJcykzdl.js.map} +1 -1
  124. package/dist/{rules-znG9bsKI.js → rules-Dz-szpPu.js} +7 -8
  125. package/dist/{rules-znG9bsKI.js.map → rules-Dz-szpPu.js.map} +1 -1
  126. package/dist/server.js +13 -13
  127. package/dist/{shared-DaEDCb8I.cjs → shared-C9XQd8p_.cjs} +164 -24
  128. package/dist/shared-C9XQd8p_.cjs.map +1 -0
  129. package/dist/{shared-O-5Fcsxa.mjs → shared-D4-AKGn6.mjs} +4 -4
  130. package/dist/{shared-O-5Fcsxa.mjs.map → shared-D4-AKGn6.mjs.map} +1 -1
  131. package/dist/sheet-LU89fcH_.js +7 -0
  132. package/dist/{sheet-SlZRjOmw.js.map → sheet-LU89fcH_.js.map} +1 -1
  133. package/dist/{sidecar-DiYLwXbk.mjs → sidecar-CZTYX2vA.mjs} +3 -3
  134. package/dist/{sidecar-DiYLwXbk.mjs.map → sidecar-CZTYX2vA.mjs.map} +1 -1
  135. package/dist/{style-CtXEZqgx.js → style-CmXHCPF4.js} +10 -11
  136. package/dist/{style-CtXEZqgx.js.map → style-CmXHCPF4.js.map} +1 -1
  137. package/dist/{styleStore-CBan0gHQ.js → styleStore-B0x4Ahpx.js} +5 -5
  138. package/dist/{styleStore-CBan0gHQ.js.map → styleStore-B0x4Ahpx.js.map} +1 -1
  139. package/dist/{styleStore-BImBZdt6.js → styleStore-BrpgLNgc.js} +2 -2
  140. package/dist/{styleStore-BImBZdt6.js.map → styleStore-BrpgLNgc.js.map} +1 -1
  141. package/dist/{token-DyLO6Hnf.js → token-DMrBbat8.js} +5 -33
  142. package/dist/token-DMrBbat8.js.map +1 -0
  143. package/dist/{trace-C1_6fM21.js → trace-C7EzEj2Q.js} +3 -3
  144. package/dist/{trace-C1_6fM21.js.map → trace-C7EzEj2Q.js.map} +1 -1
  145. package/dist/{trace-Bsh-Kkg_.js → trace-DzCntvK4.js} +2 -2
  146. package/dist/{trace-Bsh-Kkg_.js.map → trace-DzCntvK4.js.map} +1 -1
  147. package/dist/{transform-8TIMiF5A.js → transform-CSZMklMb.js} +2 -2
  148. package/dist/{transform-8TIMiF5A.js.map → transform-CSZMklMb.js.map} +1 -1
  149. package/dist/types/builder/data/merge/utils.d.ts +6 -1
  150. package/dist/types/builder/data/state.d.ts +16 -2
  151. package/dist/types/builder/extract/token.d.ts +6 -1
  152. package/dist/types/builder/style_fns.d.ts +1 -1
  153. package/dist/types/builder/utils.d.ts +1 -1
  154. package/dist/types/compiler/transform/evaluator/evaluator.d.ts +18 -1
  155. package/dist/types/compiler/transform/extract/utils/replacement.d.ts +2 -0
  156. package/dist/types/compiler/transform/extract/utils/state.d.ts +1 -0
  157. package/dist/types/compiler/transform/extract/utils/token.d.ts +3 -0
  158. package/dist/types/compiler/transform/utils/selector.d.ts +1 -1
  159. package/dist/types/compiler/utils/constants.d.ts +1 -0
  160. package/dist/types/compiler/utils/import_source.d.ts +8 -2
  161. package/dist/types/plugin/bundler/farm/plugin.d.ts +8 -2
  162. package/dist/types/presets/tailwind/selectors.d.ts +24 -24
  163. package/dist/types/presets/tailwind/theme.d.ts +361 -361
  164. package/dist/types/runtime/core/cache/itemWithResolver.d.ts +1 -1
  165. package/dist/types/runtime/core/cache/stateItem.d.ts +8 -2
  166. package/dist/types/runtime/types.d.ts +4 -1
  167. package/dist/types/selector/presets/default.d.ts +28 -28
  168. package/dist/types/selector/presets/minimal.d.ts +10 -10
  169. package/dist/types/selector/selector.d.ts +15 -2
  170. package/dist/types/style/style.d.ts +93 -93
  171. package/dist/{utils-DoKJnvxk.js → utils-B7QcJ-Yw.js} +3 -3
  172. package/dist/{utils-DoKJnvxk.js.map → utils-B7QcJ-Yw.js.map} +1 -1
  173. package/dist/{utils-Bjh9pO87.mjs → utils-BYpkJ-uE.mjs} +3 -3
  174. package/dist/{utils-Bjh9pO87.mjs.map → utils-BYpkJ-uE.mjs.map} +1 -1
  175. package/dist/{utils-BBN9msTv.mjs → utils-CoMwEfhG.mjs} +4 -4
  176. package/dist/{utils-BBN9msTv.mjs.map → utils-CoMwEfhG.mjs.map} +1 -1
  177. package/dist/{utils-10MTZOuB.js → utils-D4KMqCu2.js} +7 -2
  178. package/dist/utils-D4KMqCu2.js.map +1 -0
  179. package/dist/utils.js +3 -3
  180. package/dist/{value-Dg6ALjjj.js → value-yd2SZ1XQ.js} +37 -3
  181. package/dist/value-yd2SZ1XQ.js.map +1 -0
  182. package/dist/{webpack-C1j49Psk.mjs → webpack-B6z1UHh9.mjs} +5 -5
  183. package/dist/{webpack-C1j49Psk.mjs.map → webpack-B6z1UHh9.mjs.map} +1 -1
  184. package/package.json +5 -4
  185. package/runtime/extract/getClassName.ts +1 -1
  186. package/style/token.ts +2 -0
  187. package/dist/compiler-BEHxZYjz.mjs.map +0 -1
  188. package/dist/css-BQRIvzwZ.js.map +0 -1
  189. package/dist/css-D7eTqvMH.js +0 -57
  190. package/dist/css-D7eTqvMH.js.map +0 -1
  191. package/dist/debug-0iaVEC7z.js.map +0 -1
  192. package/dist/debug-CkgcZDaX.js.map +0 -1
  193. package/dist/env-DJyXPJ9q.js.map +0 -1
  194. package/dist/hash-Cr-LCWDt.js +0 -166
  195. package/dist/hash-Cr-LCWDt.js.map +0 -1
  196. package/dist/namedTokens-DnpyC5XT.js.map +0 -1
  197. package/dist/shared-DaEDCb8I.cjs.map +0 -1
  198. package/dist/sheet-SlZRjOmw.js +0 -7
  199. package/dist/token-DyLO6Hnf.js.map +0 -1
  200. package/dist/utils-10MTZOuB.js.map +0 -1
  201. package/dist/value-Dg6ALjjj.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @fluentic/style
2
2
 
3
+ ## 0.1.0-beta.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Compile token factories at their definitions and preserve token references in extracted styles. Token groups become nested objects of extracted token leaves; value scales use a small precompiled lookup helper. Standalone getToken calls now receive CSS-variable metadata, including values imported through re-exports.
8
+
9
+ Named tokens now use global, hash-free CSS variable names derived from their explicit namespace and property path, independent of tokenNameFormat and hashLength. Rebuild all consumers together and update external CSS references to the new names. Path segments escape punctuation to avoid collisions.
10
+
11
+ - Use native TypeScript 7.0.2 for workspace checks and declaration emission, with TypeScript 6.0.2 API compatibility for tooling. Validate packed declarations with both TypeScript 5.9 and 7.
12
+
3
13
  ## 0.1.0-beta.13
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -455,8 +455,9 @@ production builds. Current benchmark snapshots:
455
455
  The main production checks are runtime cost and bundle size. In the production
456
456
  path most apps use, Fluentic extracts CSS at build time and ships the extracted
457
457
  production runtime for `css` prop composition, dynamic values, class-name
458
- merging, and token resolution. That runtime entry currently reports `4.92 KB`
459
- min+gzip.
458
+ merging, and token resolution. The measured runtime surface reports `4.98 KiB`
459
+ (5,097 bytes) min+gzip in the refreshed beta.14 report; generated helpers and the optional JSX/dialect surfaces are
460
+ reported separately.
460
461
  Browser and SSR benchmarks track whether style resolution stays fast in
461
462
  app-shaped renders. See the
462
463
  [Bundle Size](https://fluenticstack.com/style/docs/benchmark/bundle-size/),
package/atomic/token.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { CSS_CONFIG } from '../config/config/css';
2
2
  import type { TokenNameFormat, TokenNameInfo } from '../config/types';
3
- import { getStyleTokenId, getStyleTokenName, type StyleTokenData, type StyleTokenOverride } from '../style/token';
3
+ import {
4
+ getStyleTokenId,
5
+ getStyleTokenName,
6
+ getStyleTokenVarName,
7
+ type StyleTokenData,
8
+ type StyleTokenOverride,
9
+ } from '../style/token';
4
10
  import { getCssVar, getCssVarRawFallback } from './utils/cssVar';
5
11
  import { createNameFormatter } from './utils/format';
6
12
  import { getIdentifierSafeHash } from './utils/hash';
@@ -13,6 +19,9 @@ export function getTokenVarName(
13
19
  token: StyleTokenData | StyleTokenOverride,
14
20
  format: TokenNameFormat | null,
15
21
  ) {
22
+ const explicitName = getStyleTokenVarName(token);
23
+ if (explicitName) return explicitName;
24
+
16
25
  const id = getStyleTokenId(token);
17
26
  const debugName = getStyleTokenName(token);
18
27
 
@@ -55,3 +55,13 @@ function isExtractedTokenRef(value: unknown): value is StyleTokenData {
55
55
  typeof (value as StyleTokenData)[TOKEN_ID] === 'string' &&
56
56
  (value as { [TOKEN_OVERRIDE]?: true; })[TOKEN_OVERRIDE] !== true;
57
57
  }
58
+
59
+ /** A compiled value scale: parsing and CSS variable naming happen in the compiler. */
60
+ export function createExtractedValues(entries: readonly (readonly [string | number, StyleToken<unknown>])[]) {
61
+ const tokens = new Map(entries);
62
+ return function(key: string | number, value?: unknown) {
63
+ const token = tokens.get(key);
64
+ if (!token) throw new Error(`[Style.values] VALUE_NOT_FOUND: ${String(key)}`);
65
+ return arguments.length >= 2 ? token(value) : token;
66
+ };
67
+ }
@@ -27,11 +27,13 @@ import {
27
27
  getStyleTokenId,
28
28
  getStyleTokenName,
29
29
  isStyleTokenData,
30
+ isStyleTokenOverrideData,
30
31
  type StyleTokenData,
31
32
  type StyleTokenOverride,
32
33
  TOKEN_ID,
33
34
  TOKEN_NAME,
34
35
  TOKEN_OVERRIDE,
36
+ TOKEN_VAR_NAME,
35
37
  } from '../../../style/token';
36
38
  import type { StyleTransform } from '../../../style/transform';
37
39
  import { exposeStyle } from '../../../style/utils';
@@ -70,12 +72,16 @@ import {
70
72
  IMPORT_PATHS,
71
73
  STYLE_UTILS_IMPORT_PATH,
72
74
  } from '../../utils/constants';
73
- import type { BabelTypes } from '../utils/babel';
75
+ import { BabelCore, type BabelTypes } from '../utils/babel';
74
76
  import type { EvalFail, EvalModuleBindings, EvalOk, EvalResult, ImportMap, ResolveImportFn } from './types';
75
77
 
76
78
  const STYLE_IMPORT_PATHS = new Set(IMPORT_PATHS);
77
79
 
78
80
  export const COMPILED_RUNTIME_VALUE = Symbol();
81
+ export const COMPILED_TOKEN_REFERENCE = Symbol();
82
+ export type CompiledTokenReference = {
83
+ [COMPILED_TOKEN_REFERENCE]?: { expression: BabelTypes.Expression; filePath: string; };
84
+ };
79
85
  export const COMPILED_STYLE_OBJECT_LOCATIONS = Symbol();
80
86
  const COMPILED_TOKEN_FACTORY = Symbol();
81
87
 
@@ -123,6 +129,7 @@ export type EvalScope = {
123
129
  styleTransform?: StyleTransform | null;
124
130
  sourcemapTrace?: 'style' | 'value';
125
131
  runtimeMode?: CompilerRuntimeMode | null;
132
+ tokenNameFormat?: TokenNameFormat | null;
126
133
  };
127
134
 
128
135
  export function evaluateNode(
@@ -148,10 +155,10 @@ export function evaluateNode(
148
155
  return evaluateTemplate(node, scope);
149
156
 
150
157
  case 'Identifier':
151
- return evaluateIdentifier(node, scope);
158
+ return referenceResult(evaluateIdentifier(node, scope), node, scope);
152
159
 
153
160
  case 'MemberExpression':
154
- return evaluateMember(node as BabelTypes.MemberExpression, scope);
161
+ return referenceResult(evaluateMember(node as BabelTypes.MemberExpression, scope), node, scope);
155
162
 
156
163
  case 'ObjectExpression':
157
164
  return evaluateObject(node as BabelTypes.ObjectExpression, scope);
@@ -160,7 +167,7 @@ export function evaluateNode(
160
167
  return evaluateArray(node as BabelTypes.ArrayExpression, scope);
161
168
 
162
169
  case 'CallExpression':
163
- return evaluateCall(node as BabelTypes.CallExpression, scope);
170
+ return referenceCallResult(evaluateCall(node as BabelTypes.CallExpression, scope), node, scope);
164
171
 
165
172
  case 'BinaryExpression':
166
173
  return evaluateBinary(node as BabelTypes.BinaryExpression, scope);
@@ -679,7 +686,12 @@ function evaluateCall(node: BabelTypes.CallExpression, scope: EvalScope): EvalRe
679
686
  if (!value.ok) return value;
680
687
 
681
688
  if (isStyleTokenData(value.value)) {
682
- return evalOk(getTokenVar(value.value, CSS_CONFIG.tokenNameFormat || null));
689
+ return evalOk(
690
+ getTokenVar(
691
+ value.value,
692
+ scope.tokenNameFormat === undefined ? CSS_CONFIG.tokenNameFormat || null : scope.tokenNameFormat,
693
+ ),
694
+ );
683
695
  }
684
696
 
685
697
  return evalOk(value.value);
@@ -740,7 +752,7 @@ function evaluateCall(node: BabelTypes.CallExpression, scope: EvalScope): EvalRe
740
752
  return evalOk(createCompiledTokenOverride(target, provide.value, node));
741
753
  }
742
754
 
743
- return evalOk(withRuntimeValue(node, target));
755
+ return referenceResult(evalOk(withRuntimeValue(node, target)), node, scope);
744
756
  }
745
757
  }
746
758
 
@@ -773,7 +785,7 @@ function evaluateCall(node: BabelTypes.CallExpression, scope: EvalScope): EvalRe
773
785
  const meta = scope.styleMetas?.get(node.callee.object.name);
774
786
  const transformedFrames = transformKeyframes(
775
787
  frames.value as KeyframesObject,
776
- meta?.transform ?? scope.styleTransform ?? null,
788
+ (meta?.mode === 'StyleObject' ? meta.transform : null) ?? scope.styleTransform ?? null,
777
789
  );
778
790
  const format = CSS_EXTRA_CONFIG.namedRuleFormat.keyframes ?? null;
779
791
 
@@ -941,6 +953,7 @@ function createCompiledTokenOverride(
941
953
  [TOKEN_ID]: getStyleTokenId(token),
942
954
  [TOKEN_OVERRIDE]: true,
943
955
  [TOKEN_NAME]: getStyleTokenName(token),
956
+ [TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
944
957
  value: value.value,
945
958
  ref: value,
946
959
  });
@@ -950,6 +963,7 @@ function createCompiledTokenOverride(
950
963
  [TOKEN_ID]: getStyleTokenId(token),
951
964
  [TOKEN_OVERRIDE]: true,
952
965
  [TOKEN_NAME]: getStyleTokenName(token),
966
+ [TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
953
967
  value,
954
968
  ref: null,
955
969
  });
@@ -1108,6 +1122,7 @@ function createCompiledValues(
1108
1122
  stableId: string | undefined,
1109
1123
  isNumber: boolean,
1110
1124
  ): CompiledTokenFactory {
1125
+ if (!values.length) throw new Error('[Style.values] NO_VALUES');
1111
1126
  const tokens = new Map<unknown, StyleTokenData>();
1112
1127
  const groupName = getStyleTokenNameFromId(stableId);
1113
1128
 
@@ -1138,12 +1153,12 @@ function parseCompiledValue(value: unknown, isNumber: boolean) {
1138
1153
  if (!isNumber) return value;
1139
1154
 
1140
1155
  const number = Number(value);
1141
- if (!Number.isFinite(number)) return value;
1156
+ if (!Number.isFinite(number)) throw new Error(`[Style.values] INVALID_NUMBER_VALUE: ${String(value)}`);
1142
1157
 
1143
1158
  return number;
1144
1159
  }
1145
1160
 
1146
- function isCompiledTokenFactory(value: unknown): value is CompiledTokenFactory {
1161
+ export function isCompiledTokenFactory(value: unknown): value is CompiledTokenFactory {
1147
1162
  return !!value && typeof value === 'object' && (value as CompiledTokenFactory)[COMPILED_TOKEN_FACTORY] === true;
1148
1163
  }
1149
1164
 
@@ -1224,9 +1239,18 @@ function withRuntimeValue<T extends StyleTokenData | StyleTokenOverride>(
1224
1239
  runtimeValue: BabelTypes.Expression,
1225
1240
  token: T,
1226
1241
  ): T {
1242
+ if (typeof token === 'function') {
1243
+ return new Proxy(token, {
1244
+ get(target, key) {
1245
+ if (key === COMPILED_RUNTIME_VALUE) return runtimeValue;
1246
+ return Reflect.get(target, key);
1247
+ },
1248
+ });
1249
+ }
1227
1250
  return Object.assign({}, token, {
1228
1251
  [TOKEN_ID]: token[TOKEN_ID],
1229
1252
  [TOKEN_NAME]: token[TOKEN_NAME] ?? null,
1253
+ [TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
1230
1254
  [COMPILED_RUNTIME_VALUE]: runtimeValue,
1231
1255
  });
1232
1256
  }
@@ -1277,3 +1301,53 @@ function evaluateUnary(node: BabelTypes.UnaryExpression, scope: EvalScope): Eval
1277
1301
  return evalFail(`Unsupported unary operator: ${node.operator}`);
1278
1302
  }
1279
1303
  }
1304
+
1305
+ function referenceResult(result: EvalResult, expression: BabelTypes.Expression, scope: EvalScope): EvalResult {
1306
+ if (!result.ok) return result;
1307
+ return evalOk(referenceValue(result.value, expression, scope));
1308
+ }
1309
+
1310
+ function referenceValue(value: unknown, expression: BabelTypes.Expression, scope: EvalScope, nested = false): unknown {
1311
+ if (isStyleTokenData(value) || isStyleTokenOverrideData(value)) {
1312
+ if (nested && (value as CompiledTokenReference)[COMPILED_TOKEN_REFERENCE]?.filePath === scope.filePath) {
1313
+ return value;
1314
+ }
1315
+ const reference = { expression, filePath: scope.filePath };
1316
+ if (typeof value === 'function') {
1317
+ return new Proxy(value, {
1318
+ get(target, key) {
1319
+ if (key === COMPILED_TOKEN_REFERENCE) return reference;
1320
+ return Reflect.get(target, key);
1321
+ },
1322
+ });
1323
+ }
1324
+ return Object.assign(
1325
+ withRuntimeValue((value as CompiledRuntimeValue)[COMPILED_RUNTIME_VALUE] ?? expression, value),
1326
+ {
1327
+ [COMPILED_TOKEN_REFERENCE]: reference,
1328
+ },
1329
+ );
1330
+ }
1331
+ if (!value || typeof value !== 'object' || isCompiledTokenFactory(value)) return value;
1332
+ // Only recurse through ordinary data records; compiled styles and other tagged data stay intact.
1333
+ if (Object.getOwnPropertySymbols(value).some((key) => key !== COMPILED_STYLE_OBJECT_LOCATIONS)) return value;
1334
+ const result = Object.defineProperties(Array.isArray(value) ? [] : {}, Object.getOwnPropertyDescriptors(value));
1335
+ for (const key of Object.keys(value)) {
1336
+ (result as Record<string, unknown>)[key] = referenceValue(
1337
+ (value as Record<string, unknown>)[key],
1338
+ BabelCore.types.memberExpression(expression, BabelCore.types.stringLiteral(key), true),
1339
+ scope,
1340
+ true,
1341
+ );
1342
+ }
1343
+ return result;
1344
+ }
1345
+
1346
+ function referenceCallResult(result: EvalResult, node: BabelTypes.CallExpression, scope: EvalScope): EvalResult {
1347
+ // Factory calls are rewritten separately. Ordinary token/value calls retain their expression.
1348
+ const imp = node.callee.type === 'Identifier' ? scope.imports.get(node.callee.name) : undefined;
1349
+ if (imp && STYLE_IMPORT_PATHS.has(imp.source)) return result;
1350
+ return result.ok && (isStyleTokenData(result.value) || isStyleTokenOverrideData(result.value))
1351
+ ? referenceResult(result, node, scope)
1352
+ : result;
1353
+ }
@@ -245,10 +245,13 @@ function parseAndExtractModule(
245
245
 
246
246
  if (stmt.source) {
247
247
  imports.set(exported, { source: stmt.source.value, name: local });
248
+ rawBindings.set(exported, t.identifier(exported));
248
249
  } else if (rawBindings.has(local)) {
249
250
  rawBindings.set(exported, rawBindings.get(local)!);
250
251
  } else if (bindings.has(local)) {
251
252
  bindings.set(exported, bindings.get(local)!);
253
+ } else if (imports.has(local)) {
254
+ rawBindings.set(exported, t.identifier(local));
252
255
  }
253
256
  }
254
257
 
@@ -270,6 +273,7 @@ function parseAndExtractModule(
270
273
  }
271
274
 
272
275
  const scope: EvalScope = {
276
+ tokenNameFormat: options.css?.tokenNameFormat ?? null,
273
277
  bindings,
274
278
  imports,
275
279
  styleNames,
@@ -15,7 +15,12 @@ import {
15
15
  } from '../../utils/constants';
16
16
  import { createImportSourceMatcher } from '../../utils/import_source';
17
17
  import { normalizePath } from '../../utils/path';
18
- import { evaluateEnumDeclaration, evaluateNode } from '../evaluator/evaluator';
18
+ import {
19
+ COMPILED_TOKEN_REFERENCE,
20
+ type CompiledTokenReference,
21
+ evaluateEnumDeclaration,
22
+ evaluateNode,
23
+ } from '../evaluator/evaluator';
19
24
  import { getImportedName } from '../syntax';
20
25
  import { annotateAtRuleDeclaration } from '../syntax/static_ids';
21
26
  import { BabelCore } from '../utils/babel';
@@ -28,7 +33,7 @@ import { buildReplacement } from './utils/replacement';
28
33
  import { recordCompiledBinding } from './utils/slot';
29
34
  import { type ExtractPluginState, getEvalScope, type HoistedDeclaration } from './utils/state';
30
35
  import { compileThemeCall } from './utils/theme';
31
- import { annotateTokenDeclaration } from './utils/token';
36
+ import { annotateTokenDeclaration, compileTokenFactory } from './utils/token';
32
37
 
33
38
  export type PluginState = BabelCore.PluginPass & ExtractPluginState;
34
39
 
@@ -59,6 +64,7 @@ export function createExtractPlugin(args: PluginArgs) {
59
64
 
60
65
  return {
61
66
  pre(this) {
67
+ this.tokenFactoryReplacements = new Map();
62
68
  this.styleNames = new Set();
63
69
  this.sheetNames = new Set();
64
70
  this.styleMetas = new Map();
@@ -161,6 +167,14 @@ export function createExtractPlugin(args: PluginArgs) {
161
167
  },
162
168
 
163
169
  CallExpression(path, state) {
170
+ if (mode === 'extract') {
171
+ try {
172
+ const tokenFactory = compileTokenFactory(path.node, state, t);
173
+ if (tokenFactory) state.tokenFactoryReplacements.set(path.node, tokenFactory);
174
+ } catch (error) {
175
+ throw path.buildCodeFrameError(error instanceof Error ? error.message : String(error));
176
+ }
177
+ }
164
178
  if (
165
179
  path.parent.type === 'MemberExpression' &&
166
180
  !(path.parent.computed)
@@ -270,6 +284,15 @@ export function createExtractPlugin(args: PluginArgs) {
270
284
  exit(path, state) {
271
285
  if (mode === 'collect') return;
272
286
 
287
+ path.traverse({
288
+ CallExpression(factoryPath) {
289
+ const replacement = state.tokenFactoryReplacements.get(factoryPath.node);
290
+ if (!replacement) return;
291
+ factoryPath.replaceWith(replacement);
292
+ factoryPath.skip();
293
+ state.needsExtractImport = true;
294
+ },
295
+ });
273
296
  pruneUnusedStyleInputDeclarations(path, state);
274
297
  pruneUnusedStyleImports(path, state);
275
298
 
@@ -466,8 +489,11 @@ function createRuntimeTokenCollector(
466
489
 
467
490
  return {
468
491
  overrides,
469
- addOverride(item: { valueNode: BabelTypes.Expression; }) {
470
- overrides.push(args.t.cloneNode(item.valueNode));
492
+ addOverride(item: { valueNode: BabelTypes.Expression; value: unknown; }) {
493
+ const reference = (item.value as CompiledTokenReference)[COMPILED_TOKEN_REFERENCE];
494
+ overrides.push(
495
+ args.t.cloneNode(reference?.filePath === args.state.filePath ? reference.expression : item.valueNode, true),
496
+ );
471
497
  },
472
498
  add(item: object, valueNode: BabelTypes.Expression) {
473
499
  if (canHoistRuntimeValue(args.path, valueNode)) {
@@ -3,6 +3,9 @@ import {
3
3
  FN_COMBINE_SCOPE,
4
4
  FN_COMBINE_STYLE,
5
5
  FN_CREATE_THEME,
6
+ FN_CREATE_TOKEN,
7
+ FN_CREATE_TOKENS,
8
+ FN_CREATE_VALUES,
6
9
  FN_GET_CLASS_NAME,
7
10
  FN_GET_TOKEN,
8
11
  IMPORT_PATHS,
@@ -128,5 +131,6 @@ function isCompilerHandledImport(
128
131
  source: string,
129
132
  name: string,
130
133
  ) {
131
- return IMPORT_PATHS.includes(source) && name === FN_CREATE_THEME;
134
+ return IMPORT_PATHS.includes(source) &&
135
+ [FN_CREATE_THEME, FN_CREATE_TOKEN, FN_CREATE_TOKENS, FN_CREATE_VALUES].includes(name);
132
136
  }
@@ -27,6 +27,7 @@ import {
27
27
  FN_CREATE_EXTRACTED_STYLE_MERGE,
28
28
  FN_CREATE_EXTRACTED_TOKEN,
29
29
  } from '../../../utils/constants';
30
+ import { COMPILED_TOKEN_REFERENCE, type CompiledTokenReference } from '../../evaluator/evaluator';
30
31
  import type { BabelTypes } from '../../utils/babel';
31
32
  import type {
32
33
  CompiledChainData,
@@ -352,7 +353,11 @@ function buildVariableValueExpression(
352
353
  options: BuildReplacementOptions,
353
354
  ): BabelTypes.Expression {
354
355
  if (isStyleTokenData(value)) {
355
- state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
356
+ const reference = (value as CompiledTokenReference)[COMPILED_TOKEN_REFERENCE];
357
+ if (reference?.filePath === state.filePath) {
358
+ const runtimeToken = options.getRuntimeToken?.(item, reference.expression);
359
+ if (runtimeToken) return runtimeToken;
360
+ }
356
361
  return buildExtractedTokenExpression(t, value, state);
357
362
  }
358
363
 
@@ -363,11 +368,16 @@ function buildVariableValueExpression(
363
368
  return valueNode ? t.cloneNode(valueNode) : literalExpression(t, value);
364
369
  }
365
370
 
366
- function buildExtractedTokenExpression(
371
+ export function buildExtractedTokenExpression(
367
372
  t: typeof BabelTypes,
368
373
  token: StyleTokenData,
369
374
  state: ExtractPluginState,
375
+ preserveReference = true,
370
376
  ): BabelTypes.Expression {
377
+ const reference = (token as CompiledTokenReference)[COMPILED_TOKEN_REFERENCE];
378
+ if (preserveReference && reference?.filePath === state.filePath) {
379
+ return t.cloneNode(reference.expression, true);
380
+ }
371
381
  state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
372
382
  const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
373
383
 
@@ -388,6 +398,8 @@ function buildExtractedTokenOverrideExpression(
388
398
  token: StyleTokenOverride,
389
399
  state: ExtractPluginState,
390
400
  ): BabelTypes.Expression {
401
+ const reference = (token as CompiledTokenReference)[COMPILED_TOKEN_REFERENCE];
402
+ if (reference?.filePath === state.filePath) return t.cloneNode(reference.expression, true);
391
403
  state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
392
404
  const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
393
405
  const extractedToken = t.callExpression(
@@ -420,5 +432,5 @@ function literalExpression(
420
432
  if (typeof value === 'boolean') return t.booleanLiteral(value);
421
433
  if (value === null || value === undefined) return t.nullLiteral();
422
434
 
423
- return t.stringLiteral(String(value));
435
+ return t.valueToNode(value) as BabelTypes.Expression;
424
436
  }
@@ -13,6 +13,7 @@ export type HoistedDeclaration = {
13
13
  };
14
14
 
15
15
  export type ExtractPluginState = {
16
+ tokenFactoryReplacements: Map<BabelTypes.CallExpression, BabelTypes.Expression>;
16
17
  fileId: string;
17
18
  filePath: string;
18
19
  styleFilePath: string;
@@ -47,5 +48,6 @@ export function getEvalScope(state: ExtractPluginState): EvalScope {
47
48
  styleMetas: state.styleMetas,
48
49
  bindingNodes: state.bindingNodes,
49
50
  runtimeMode: state.runtimeMode,
51
+ tokenNameFormat: state.options.css?.tokenNameFormat ?? null,
50
52
  };
51
53
  }
@@ -1 +1,108 @@
1
+ import { isStyleTokenData } from '../../../../style/token';
2
+ import {
3
+ FN_CREATE_EXTRACTED_VALUES,
4
+ FN_CREATE_TOKEN,
5
+ FN_CREATE_TOKENS,
6
+ FN_CREATE_VALUES,
7
+ IMPORT_PATHS,
8
+ } from '../../../utils/constants';
9
+ import {
10
+ COMPILED_RUNTIME_VALUE,
11
+ type CompiledRuntimeValue,
12
+ evaluateNode,
13
+ isCompiledTokenFactory,
14
+ } from '../../evaluator/evaluator';
15
+ import { getObjectPropertyKey } from '../../syntax/utils';
16
+ import type { BabelTypes } from '../../utils/babel';
17
+ import { buildExtractedTokenExpression } from './replacement';
18
+ import { type ExtractPluginState, getEvalScope } from './state';
19
+
1
20
  export { annotateTokenDeclaration } from '../../syntax/static_ids';
21
+
22
+ export function compileTokenFactory(
23
+ node: BabelTypes.CallExpression,
24
+ state: ExtractPluginState,
25
+ t: typeof BabelTypes,
26
+ ): BabelTypes.Expression | null {
27
+ if (node.callee.type !== 'Identifier') return null;
28
+ const imp = state.imports.get(node.callee.name);
29
+ if (!imp || !IMPORT_PATHS.includes(imp.source)) return null;
30
+ if (![FN_CREATE_TOKEN, FN_CREATE_TOKENS, FN_CREATE_VALUES].includes(imp.name)) return null;
31
+
32
+ const inputValue = evaluateNode(node.arguments[0] as BabelTypes.Node, getEvalScope(state));
33
+ if (inputValue.ok && hasUnresolvedValue(inputValue.value)) {
34
+ throw new Error(`Cannot extract ${imp.name}: factory inputs must be statically resolvable`);
35
+ }
36
+ const result = evaluateNode(node, getEvalScope(state));
37
+ if (!result.ok) throw new Error(`Cannot extract ${imp.name}: ${result.reason}`);
38
+
39
+ if (isCompiledTokenFactory(result.value)) {
40
+ state.usedHelpers.add(FN_CREATE_EXTRACTED_VALUES);
41
+ const expression = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_VALUES), [
42
+ t.arrayExpression([...result.value.tokens].map(([key, token]) =>
43
+ t.arrayExpression([
44
+ t.valueToNode(key) as BabelTypes.Expression,
45
+ buildExtractedTokenExpression(t, token, state, false),
46
+ ])
47
+ )),
48
+ ]);
49
+ t.addComment(expression, 'leading', '#__PURE__');
50
+ return expression;
51
+ }
52
+
53
+ const input = node.arguments[0] as BabelTypes.Expression;
54
+ if (imp.name === FN_CREATE_TOKEN) return buildGroup(result.value, input);
55
+ const raw = evaluateNode(input, getEvalScope(state));
56
+ const array = raw.ok && Array.isArray(raw.value) ? raw.value : null;
57
+ if (array) {
58
+ return t.objectExpression(
59
+ Object.entries(result.value as object).map(([key, token]) => {
60
+ let index = array.length - 1;
61
+ while (index >= 0 && String(array[index]) !== key) index--;
62
+ return t.objectProperty(
63
+ t.stringLiteral(key),
64
+ buildGroup(token, member(input, String(index))),
65
+ key === '__proto__',
66
+ );
67
+ }),
68
+ );
69
+ }
70
+ return buildGroup(result.value, input);
71
+
72
+ function buildGroup(value: unknown, source: BabelTypes.Expression): BabelTypes.Expression {
73
+ if (isStyleTokenData(value)) {
74
+ const expression = buildExtractedTokenExpression(t, value, state, false) as BabelTypes.CallExpression;
75
+ if (!value.ref) expression.arguments[1] = t.cloneNode(source, true);
76
+ t.addComment(expression, 'leading', '#__PURE__');
77
+ return expression;
78
+ }
79
+ if (!value || typeof value !== 'object') throw new Error(`Invalid ${imp!.name} token group`);
80
+ return t.objectExpression(
81
+ Object.entries(value).map(([key, child]) =>
82
+ t.objectProperty(t.stringLiteral(key), buildGroup(child, member(source, key)), key === '__proto__')
83
+ ),
84
+ );
85
+ }
86
+ function member(source: BabelTypes.Expression, key: string): BabelTypes.Expression {
87
+ if (source.type === 'ObjectExpression') {
88
+ for (let index = source.properties.length - 1; index >= 0; index--) {
89
+ const property = source.properties[index]!;
90
+ if (property.type !== 'ObjectProperty' || property.computed) break;
91
+ if (getObjectPropertyKey(property) === key) return property.value as BabelTypes.Expression;
92
+ }
93
+ }
94
+ if (
95
+ source.type === 'ArrayExpression' && !source.elements.some((item) => item?.type === 'SpreadElement') &&
96
+ source.elements[Number(key)] && t.isExpression(source.elements[Number(key)])
97
+ ) {
98
+ return source.elements[Number(key)] as BabelTypes.Expression;
99
+ }
100
+ return t.memberExpression(t.cloneNode(source, true), t.stringLiteral(key), true);
101
+ }
102
+ }
103
+
104
+ function hasUnresolvedValue(value: unknown): boolean {
105
+ if (!value || typeof value !== 'object' || isStyleTokenData(value)) return false;
106
+ if ((value as CompiledRuntimeValue)[COMPILED_RUNTIME_VALUE]) return true;
107
+ return Object.values(value).some(hasUnresolvedValue);
108
+ }
@@ -67,6 +67,7 @@ export const FN_CREATE_EXTRACTED_SHEET = 'createExtractedSheet';
67
67
  export const FN_CREATE_EXTRACTED_SLOT = 'createExtractedSlot';
68
68
  export const FN_CREATE_EXTRACTED_SCOPE = 'createExtractedScope';
69
69
  export const FN_CREATE_EXTRACTED_TOKEN = 'createExtractedToken';
70
+ export const FN_CREATE_EXTRACTED_VALUES = 'createExtractedValues';
70
71
  export const FN_CREATE_EXTRACTED_THEME = 'createExtractedTheme';
71
72
  export const FN_GET_EXTRACTED_STYLE_ITEMS = 'getExtractedStyleItems';
72
73
  export const FN_CREATE_EXTRACTED_STYLE_MERGE = 'createExtractedStyleMerge';
@@ -1,6 +1,3 @@
1
- import { getTokenVarName } from '../atomic/token';
2
- import { sanitizeCssIdentName } from '../atomic/utils/cssIdent';
3
- import { CSS_CONFIG } from '../config/config/css';
4
1
  import {
5
2
  createStyleToken,
6
3
  type StyleToken,
@@ -29,8 +26,9 @@ type NamedTokenRoot = {
29
26
  const ROOT = Symbol('fluentic.namedTokens.root');
30
27
 
31
28
  export function createNamedToken<T>(id: string, value?: T): NamedToken<T> {
32
- const token = createStyleToken(value, createNamedTokenId(id)) as NamedToken<T>;
33
- token[TOKEN_VAR_NAME] = getTokenVarName(token, CSS_CONFIG.tokenNameFormat ?? null);
29
+ const tokenId = createNamedTokenId(id);
30
+ const token = createStyleToken(value, tokenId) as NamedToken<T>;
31
+ token[TOKEN_VAR_NAME] = '--token-' + tokenId;
34
32
  return token;
35
33
  }
36
34
 
@@ -63,7 +61,12 @@ export function getNamedToken<T = unknown>(
63
61
  }
64
62
 
65
63
  export function createNamedTokenId(id: string) {
66
- return sanitizeCssIdentName(id.replace(/\./g, '-'), 'named-token');
64
+ return id.split('.').map(encodeNamedTokenSegment).join('-');
65
+ }
66
+
67
+ // Escape separators and the escape marker itself so distinct paths cannot collide.
68
+ function encodeNamedTokenSegment(segment: string) {
69
+ return segment.replace(/[^a-zA-Z0-9]/gu, (char) => '_x' + char.codePointAt(0)!.toString(16) + '_');
67
70
  }
68
71
 
69
72
  function createNamedTokenProxy(
@@ -103,12 +106,14 @@ function getNamedTokenAtPath(
103
106
  root: NamedTokenRoot,
104
107
  path: string[],
105
108
  ) {
106
- const key = path.join('.');
109
+ const key = JSON.stringify(path);
107
110
  const cached = root.cache.get(key);
108
111
  if (cached) return cached;
109
112
 
110
113
  const value = getValueAtPath(root.values, path);
111
- const token = createNamedToken(root.namespace + '.' + key, value);
114
+ const id = root.namespace.split('.').concat(path).map(encodeNamedTokenSegment).join('-');
115
+ const token = createStyleToken(value, id);
116
+ token[TOKEN_VAR_NAME] = '--token-' + id;
112
117
  root.cache.set(key, token);
113
118
  return token;
114
119
  }
@@ -1,5 +1,5 @@
1
1
  import { B as BUILDER_STATE, L as BUILDER_SELECTOR, P as BUILDER_CALLSITE, U as RUNTIME_CONFIG, d as getExtractedTokenBoundData, f as isExtractedTokenBoundData, l as createCacheTreeNode, q as symbol, u as getCacheTreeChild, z as BUILDER_SLOT_ID } from "./className-yhJCGT0F.js";
2
- import { $ as createStyleToken, A as normalizeManualSelectors$1, B as mergeStyleData, Ct as traceMarker, D as createIdCounter, Dt as isStyleImportantValue, Et as importantValue, F as resolveCallsite, I as transformStyle, J as classNameValue, L as mergeSelectorOverrideData, M as FnPrefixSelector, Mt as setBuildConfig, N as FnPrefixSlot, Nt as CSS_CONFIG, O as getId, Ot as DEV_CONFIG, P as FnPrefixStyle, R as mergeSlotData, S as createKeyframes, St as traceError, Tt as weightValue, U as normalizeSelectorArg, Y as isClassNameValue, Z as mergeScopeData, _ as getCombinedStyleStyles, _t as createSelectorOverrideData, a as createThemeClassName, at as getScopeTargetSlotId, bt as createStyleData, c as createCombinedStyleTokenWrapper, ct as isSheetData, d as addTokenValues, dt as getDebugCallsiteId, f as createMutableTokenValues, ft as getTraceCallsiteId, g as getCombinedStyleScopes, gt as createSelectorData, h as mergeTokenValues, ht as createScopeTargetData, it as getScopeTargetScope, j as FnPrefixScope, jt as setBuildDebugClassName, k as assertManualSelectorSyntax, kt as hashString, l as getStyleTokenValues, m as mergeTokenOverrides, mt as createScopeData, ot as isScopeData, p as finishTokenValues, pt as isDebugData, rt as getChildStyleTokenName, s as createCombinedStyleFacade, st as isScopeTargetData, u as addTokenOverride, ut as isStyleData, v as isCombinedStyle, vt as createSlotData, wt as isStyleWeightValue, xt as createThemeData, yt as createSlotOverrideData, z as mergeSlotOverrideData } from "./css-BQRIvzwZ.js";
2
+ import { $ as createStyleToken, A as normalizeManualSelectors$1, B as mergeStyleData, Ct as traceMarker, D as createIdCounter, Dt as isStyleImportantValue, Et as importantValue, F as resolveCallsite, I as transformStyle, J as classNameValue, L as mergeSelectorOverrideData, M as FnPrefixSelector, Mt as setBuildConfig, N as FnPrefixSlot, Nt as CSS_CONFIG, O as getId, Ot as DEV_CONFIG, P as FnPrefixStyle, R as mergeSlotData, S as createKeyframes, St as traceError, Tt as weightValue, U as normalizeSelectorArg, Y as isClassNameValue, Z as mergeScopeData, _ as getCombinedStyleStyles, _t as createSelectorOverrideData, a as createThemeClassName, at as getScopeTargetSlotId, bt as createStyleData, c as createCombinedStyleTokenWrapper, ct as isSheetData, d as addTokenValues, dt as getDebugCallsiteId, f as createMutableTokenValues, ft as getTraceCallsiteId, g as getCombinedStyleScopes, gt as createSelectorData, h as mergeTokenValues, ht as createScopeTargetData, it as getScopeTargetScope, j as FnPrefixScope, jt as setBuildDebugClassName, k as assertManualSelectorSyntax, kt as hashString, l as getStyleTokenValues, m as mergeTokenOverrides, mt as createScopeData, ot as isScopeData, p as finishTokenValues, pt as isDebugData, rt as getChildStyleTokenName, s as createCombinedStyleFacade, st as isScopeTargetData, u as addTokenOverride, ut as isStyleData, v as isCombinedStyle, vt as createSlotData, wt as isStyleWeightValue, xt as createThemeData, yt as createSlotOverrideData, z as mergeSlotOverrideData } from "./css-WaHZ6gxv.js";
3
3
  import { SelectorType, parse } from "css-what";
4
4
  //#region entry/shared/config_debug.ts
5
5
  const buildConfig = JSON.parse(FLUENTIC_STYLE_BUILD_CONFIG);
@@ -1251,4 +1251,4 @@ function collectTokenOverrides(data, result, resolver) {
1251
1251
  //#endregion
1252
1252
  export { createValues as a, resetStyleThemeIdCounter as c, createStyleFn as d, getStyleFnMeta as f, type as g, transformKeyframes as h, createToken as i, createClassNameFn as l, createStyleKeyframes as m, bindScope as n, createTokens as o, style as p, combineScope as r, createTheme as s, createCombinedStyleGetter as t, assignStyleFnMeta as u };
1253
1253
 
1254
- //# sourceMappingURL=combine-yuoQ_qpx.js.map
1254
+ //# sourceMappingURL=combine-CC9bY-hu.js.map