@fluentic/style 0.1.0-beta.5 → 0.1.0-beta.6

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 (183) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +105 -31
  3. package/atomic/className.ts +19 -2
  4. package/atomic/utils/hash.ts +1 -65
  5. package/compiler/compiler/compiler.ts +85 -8
  6. package/compiler/cssProp.ts +0 -14
  7. package/compiler/transform/cssProp/plugin.ts +33 -1
  8. package/compiler/transform/evaluator/evaluator.ts +1 -0
  9. package/compiler/transform/extract/chain/chain.ts +120 -11
  10. package/compiler/utils/import_source.ts +17 -7
  11. package/dist/{combine-Ca6LfFxv.js → combine-D0AXSTn-.js} +2 -2
  12. package/dist/{combine-Ca6LfFxv.js.map → combine-D0AXSTn-.js.map} +1 -1
  13. package/dist/compiler/index.mjs +1 -1
  14. package/dist/{compiler-OgDBuqfs.mjs → compiler-CCvRlaq0.mjs} +141 -89
  15. package/dist/compiler-CCvRlaq0.mjs.map +1 -0
  16. package/dist/{config-Barf8f4B.js → config-B-w6rOe0.js} +2 -2
  17. package/dist/{config-Barf8f4B.js.map → config-B-w6rOe0.js.map} +1 -1
  18. package/dist/{config-CsB4MuFI.js → config-B1WtpYar.js} +2 -2
  19. package/dist/{config-CsB4MuFI.js.map → config-B1WtpYar.js.map} +1 -1
  20. package/dist/{config-t76UljYv.js → config-CCMwA9Gm.js} +2 -2
  21. package/dist/{config-t76UljYv.js.map → config-CCMwA9Gm.js.map} +1 -1
  22. package/dist/{createTransformElement-DDqld3RF.js → createTransformElement-PCilcudP.js} +2 -2
  23. package/dist/{createTransformElement-DDqld3RF.js.map → createTransformElement-PCilcudP.js.map} +1 -1
  24. package/dist/{css-a9O5so0b.js → css-DirG7Jwu.js} +41 -7
  25. package/dist/css-DirG7Jwu.js.map +1 -0
  26. package/dist/{css-YfHN_8Nk.js → css-nmclCl2P.js} +8 -8
  27. package/dist/{css-YfHN_8Nk.js.map → css-nmclCl2P.js.map} +1 -1
  28. package/dist/{css-CZwrac6F.js → css-shX7_73D.js} +12 -41
  29. package/dist/css-shX7_73D.js.map +1 -0
  30. package/dist/css.js +1 -1
  31. package/dist/{data-CzHJg147.js → data-DUvixly5.js} +14 -6
  32. package/dist/data-DUvixly5.js.map +1 -0
  33. package/dist/{debug-DkrxyknP.js → debug-DJRCBKhM.js} +2 -2
  34. package/dist/{debug-DkrxyknP.js.map → debug-DJRCBKhM.js.map} +1 -1
  35. package/dist/dev/rsc.js +5 -5
  36. package/dist/{dev-z4laBwlS.js → dev-Cwha8aAp.js} +4 -4
  37. package/dist/{dev-z4laBwlS.js.map → dev-Cwha8aAp.js.map} +1 -1
  38. package/dist/dev.js +1 -1
  39. package/dist/dialect/extracted/index.js +1 -1
  40. package/dist/dialect/index.js +1 -1
  41. package/dist/{elementMarker-CqhU_l_m.js → elementMarker-Cb46vtLU.js} +3 -3
  42. package/dist/{elementMarker-CqhU_l_m.js.map → elementMarker-Cb46vtLU.js.map} +1 -1
  43. package/dist/entry/dev/adapter/preact.js +2 -2
  44. package/dist/entry/dev/adapter/react.js +2 -2
  45. package/dist/entry/dev/adapter/solid.js +2 -2
  46. package/dist/entry/dev/css.js +2 -2
  47. package/dist/entry/dev/jsx-dev-runtime.js +2 -2
  48. package/dist/entry/dev/jsx-runtime.js +2 -2
  49. package/dist/entry/dev.js +8 -8
  50. package/dist/entry/prod/adapter/preact.js +1 -1
  51. package/dist/entry/prod/adapter/react.js +1 -1
  52. package/dist/entry/prod/adapter/solid.js +1 -1
  53. package/dist/entry/prod/css.js +2 -2
  54. package/dist/entry/prod.js +2 -2
  55. package/dist/entry/rsc-dev/adapter/preact.js +5 -4
  56. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -1
  57. package/dist/entry/rsc-dev/adapter/react.js +5 -4
  58. package/dist/entry/rsc-dev/adapter/react.js.map +1 -1
  59. package/dist/entry/rsc-dev/adapter/solid.js +5 -4
  60. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -1
  61. package/dist/entry/rsc-dev/css.js +2 -2
  62. package/dist/entry/rsc-dev/dev.js +5 -6
  63. package/dist/entry/rsc-dev/dev.js.map +1 -1
  64. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  65. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  66. package/dist/entry/rsc-dev.js +5 -5
  67. package/dist/entry/rsc-prod/css.js +2 -2
  68. package/dist/entry/rsc-prod.js +2 -2
  69. package/dist/{env-Db2cRt-h.js → env-0Gu2Jh47.js} +2 -39
  70. package/dist/env-0Gu2Jh47.js.map +1 -0
  71. package/dist/{utils-CLnpwhJd.js → getClassName-CHZKhmde.js} +5 -43
  72. package/dist/getClassName-CHZKhmde.js.map +1 -0
  73. package/dist/{getClassName-DaZF5nfJ.js → getClassName-CHd0iCXp.js} +3 -3
  74. package/dist/{getClassName-DaZF5nfJ.js.map → getClassName-CHd0iCXp.js.map} +1 -1
  75. package/dist/global-Dg37z0lV.js +14 -0
  76. package/dist/global-Dg37z0lV.js.map +1 -0
  77. package/dist/{hash-BOlQThNz.js → hash-Cr-LCWDt.js} +2 -40
  78. package/dist/hash-Cr-LCWDt.js.map +1 -0
  79. package/dist/index.js +6 -6
  80. package/dist/jsx/jsx-dev-runtime.js +1 -1
  81. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  82. package/dist/jsx/jsx-runtime.js +1 -1
  83. package/dist/jsx/jsx-runtime.server.js +1 -1
  84. package/dist/{jsx-C2pnWLcb.js → jsx-BMFC8_tA.js} +4 -4
  85. package/dist/{jsx-C2pnWLcb.js.map → jsx-BMFC8_tA.js.map} +1 -1
  86. package/dist/{jsx_runtime-XJSHujgI.js → jsx_runtime-Ch1pZ6-n.js} +2 -2
  87. package/dist/{jsx_runtime-XJSHujgI.js.map → jsx_runtime-Ch1pZ6-n.js.map} +1 -1
  88. package/dist/{loader-DHvgp0fK.mjs → loader-hNaefW-U.mjs} +13 -14
  89. package/dist/loader-hNaefW-U.mjs.map +1 -0
  90. package/dist/{misc-BuSLnvx0.mjs → misc-1OS0aeY1.mjs} +2 -2
  91. package/dist/{misc-BuSLnvx0.mjs.map → misc-1OS0aeY1.mjs.map} +1 -1
  92. package/dist/{namedTokens-D3tt-joz.js → namedTokens-mgRfd9hs.js} +3 -3
  93. package/dist/{namedTokens-D3tt-joz.js.map → namedTokens-mgRfd9hs.js.map} +1 -1
  94. package/dist/plugin/farm/index.mjs +3 -3
  95. package/dist/plugin/nextjs/index.mjs +120 -16
  96. package/dist/plugin/nextjs/index.mjs.map +1 -1
  97. package/dist/plugin/nextjs/loader.mjs +4 -4
  98. package/dist/plugin/parcel/index.cjs +1 -1
  99. package/dist/plugin/parcel/index.mjs +2 -2
  100. package/dist/plugin/parcel/optimizer.cjs +1 -1
  101. package/dist/plugin/parcel/optimizer.mjs +2 -2
  102. package/dist/plugin/parcel/resolver.cjs +1 -1
  103. package/dist/plugin/parcel/resolver.mjs +2 -2
  104. package/dist/plugin/parcel/runtime.cjs +1 -1
  105. package/dist/plugin/parcel/runtime.mjs +1 -1
  106. package/dist/plugin/parcel/transformer.cjs +1 -1
  107. package/dist/plugin/parcel/transformer.mjs +2 -2
  108. package/dist/plugin/rspack/index.mjs +2 -2
  109. package/dist/plugin/vite/index.mjs +3 -3
  110. package/dist/plugin/webpack/index.mjs +2 -2
  111. package/dist/plugin/webpack/loader.mjs +2 -2
  112. package/dist/presets/tailwind/index.js +25 -3
  113. package/dist/presets/tailwind/index.js.map +1 -1
  114. package/dist/{registry-r3BKWqpI.mjs → registry-OA0niXJL.mjs} +2 -2
  115. package/dist/{registry-r3BKWqpI.mjs.map → registry-OA0niXJL.mjs.map} +1 -1
  116. package/dist/{resolveClassNameRuntime-D5a37GNr.js → resolveClassNameRuntime-BKXT1bmR.js} +2 -2
  117. package/dist/{resolveClassNameRuntime-D5a37GNr.js.map → resolveClassNameRuntime-BKXT1bmR.js.map} +1 -1
  118. package/dist/{rules-B0_rKPfB.js → rules-DgcCENkw.js} +5 -5
  119. package/dist/{rules-B0_rKPfB.js.map → rules-DgcCENkw.js.map} +1 -1
  120. package/dist/server.js +10 -10
  121. package/dist/{shared-8_Msr7Q5.cjs → shared-Bc9RwNNj.cjs} +140 -88
  122. package/dist/shared-Bc9RwNNj.cjs.map +1 -0
  123. package/dist/{shared-BGO_05rW.mjs → shared-COiLPdZ1.mjs} +4 -4
  124. package/dist/{shared-BGO_05rW.mjs.map → shared-COiLPdZ1.mjs.map} +1 -1
  125. package/dist/sheet-B87QCFWF.js +7 -0
  126. package/dist/{sheet-BpLZIIuO.js.map → sheet-B87QCFWF.js.map} +1 -1
  127. package/dist/{sidecar-Bu2x35JE.mjs → sidecar-ViZUL9B8.mjs} +3 -3
  128. package/dist/{sidecar-Bu2x35JE.mjs.map → sidecar-ViZUL9B8.mjs.map} +1 -1
  129. package/dist/{styleStore-BDy5TH6N.js → styleStore-BlC8Ax9f.js} +3 -3
  130. package/dist/{styleStore-BDy5TH6N.js.map → styleStore-BlC8Ax9f.js.map} +1 -1
  131. package/dist/{styleStore-DX3z_UVK.js → styleStore-DHzH25A7.js} +2 -2
  132. package/dist/{styleStore-DX3z_UVK.js.map → styleStore-DHzH25A7.js.map} +1 -1
  133. package/dist/{token-BsW_S8fN.js → token-CAQWMtan.js} +2 -2
  134. package/dist/{token-BsW_S8fN.js.map → token-CAQWMtan.js.map} +1 -1
  135. package/dist/{trace-BdKEpgME.js → trace-D3yBmJad.js} +2 -2
  136. package/dist/{trace-BdKEpgME.js.map → trace-D3yBmJad.js.map} +1 -1
  137. package/dist/{trace-DcuMxR45.js → trace-DdXWjgAD.js} +3 -3
  138. package/dist/{trace-DcuMxR45.js.map → trace-DdXWjgAD.js.map} +1 -1
  139. package/dist/{types-BEUgXuu2.js → types-BhdAXX7z.js} +7 -7
  140. package/dist/{types-BEUgXuu2.js.map → types-BhdAXX7z.js.map} +1 -1
  141. package/dist/utils-B6HVRX10.js +42 -0
  142. package/dist/utils-B6HVRX10.js.map +1 -0
  143. package/dist/{utils-BPDxr-oc.mjs → utils-C7UalRKf.mjs} +41 -7
  144. package/dist/utils-C7UalRKf.mjs.map +1 -0
  145. package/dist/{utils-sBVZEq4u.js → utils-Cd4wqN56.js} +2 -39
  146. package/dist/utils-Cd4wqN56.js.map +1 -0
  147. package/dist/{utils-DZjLTV4D.mjs → utils-DjxH0zc7.mjs} +3 -3
  148. package/dist/{utils-DZjLTV4D.mjs.map → utils-DjxH0zc7.mjs.map} +1 -1
  149. package/dist/utils-DxCpyV2E.js +62 -0
  150. package/dist/utils-DxCpyV2E.js.map +1 -0
  151. package/dist/utils.js +2 -2
  152. package/dist/{webpack-DTKgR-HY.mjs → webpack-6et2ZVI6.mjs} +5 -5
  153. package/dist/{webpack-DTKgR-HY.mjs.map → webpack-6et2ZVI6.mjs.map} +1 -1
  154. package/entry/rsc_dev/adapter/preact.ts +9 -1
  155. package/entry/rsc_dev/adapter/react.ts +9 -1
  156. package/entry/rsc_dev/adapter/solid.ts +9 -1
  157. package/package.json +21 -11
  158. package/plugin/bundler/webpack/shared/loader.ts +9 -7
  159. package/plugin/nextjs/plugin.ts +205 -15
  160. package/plugin/nextjs/types.ts +1 -2
  161. package/plugin/nextjs/utils.ts +50 -0
  162. package/presets/tailwind/classname/transform.ts +32 -1
  163. package/runtime/adapter/utils.ts +40 -14
  164. package/dist/compiler-OgDBuqfs.mjs.map +0 -1
  165. package/dist/css-CZwrac6F.js.map +0 -1
  166. package/dist/css-a9O5so0b.js.map +0 -1
  167. package/dist/css_extra-CXXZAylc.js +0 -8
  168. package/dist/css_extra-CXXZAylc.js.map +0 -1
  169. package/dist/data-CzHJg147.js.map +0 -1
  170. package/dist/env-Db2cRt-h.js.map +0 -1
  171. package/dist/getClassName-DKtQl5ZX.js +0 -32
  172. package/dist/getClassName-DKtQl5ZX.js.map +0 -1
  173. package/dist/global-zYTvWskP.js +0 -10
  174. package/dist/global-zYTvWskP.js.map +0 -1
  175. package/dist/hash-BOlQThNz.js.map +0 -1
  176. package/dist/loader-DHvgp0fK.mjs.map +0 -1
  177. package/dist/shared-8_Msr7Q5.cjs.map +0 -1
  178. package/dist/sheet-BpLZIIuO.js +0 -7
  179. package/dist/utils-BPDxr-oc.mjs.map +0 -1
  180. package/dist/utils-CLnpwhJd.js.map +0 -1
  181. package/dist/utils-okFWrQsg.js +0 -41
  182. package/dist/utils-okFWrQsg.js.map +0 -1
  183. package/dist/utils-sBVZEq4u.js.map +0 -1
@@ -504,11 +504,14 @@ function createCssPropPlugin(args) {
504
504
  }
505
505
  },
506
506
  JSXOpeningElement(path, state) {
507
+ const keyHoistedAttributes = hoistKeyAttributes(path.node.attributes);
508
+ if (keyHoistedAttributes) path.node.attributes = keyHoistedAttributes;
507
509
  if (!getCssPropOptions(state.options) || !state.mergeId) return;
508
510
  if (!isIntrinsicElement(path.node.name)) return;
509
511
  if (!hasCssAttribute(path.node.attributes)) return;
510
- const parts = path.node.attributes.map((attr) => buildPart(t, attr));
511
- path.node.attributes = [t.jsxSpreadAttribute(t.callExpression(state.mergeId, [t.arrayExpression(parts)]))];
512
+ const keyAttributes = path.node.attributes.filter(isKeyAttribute);
513
+ const parts = path.node.attributes.filter((attr) => !isKeyAttribute(attr)).map((attr) => buildPart(t, attr));
514
+ path.node.attributes = [...keyAttributes, t.jsxSpreadAttribute(t.callExpression(state.mergeId, [t.arrayExpression(parts)]))];
512
515
  state.changed = true;
513
516
  }
514
517
  }
@@ -526,6 +529,17 @@ function hasCssAttribute(attrs) {
526
529
  return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "css";
527
530
  });
528
531
  }
532
+ function hoistKeyAttributes(attrs) {
533
+ const keyAttributes = attrs.filter(isKeyAttribute);
534
+ if (!keyAttributes.length) return null;
535
+ const firstKeyIndex = attrs.findIndex(isKeyAttribute);
536
+ const firstSpreadIndex = attrs.findIndex((attr) => attr.type === "JSXSpreadAttribute");
537
+ if (firstSpreadIndex < 0 || firstKeyIndex < firstSpreadIndex) return null;
538
+ return [...keyAttributes, ...attrs.filter((attr) => !isKeyAttribute(attr))];
539
+ }
540
+ function isKeyAttribute(attr) {
541
+ return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "key";
542
+ }
529
543
  function buildPart(t, attr) {
530
544
  if (attr.type === "JSXSpreadAttribute") return attr.argument;
531
545
  return t.objectExpression([t.objectProperty(getObjectKey(t, attr.name), getAttributeValue(t, attr))]);
@@ -1403,46 +1417,9 @@ function formatScopeClassName$1(format, info) {
1403
1417
  }
1404
1418
  //#endregion
1405
1419
  //#region atomic/utils/hash.ts
1406
- const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
1407
- byValue: /* @__PURE__ */ new Map(),
1408
- byHash: /* @__PURE__ */ new Map(),
1409
- usedByLength: []
1410
- }));
1411
1420
  function getIdentifierSafeHash(value, startLength = 7) {
1412
- return getPooledHash(value, startLength);
1413
- }
1414
- function getPooledHash(value, startLength) {
1415
1421
  const normalizedStartLength = normalizeHashLength(startLength);
1416
- const valueKey = normalizedStartLength + "\0" + value;
1417
- const existing = POOLED_HASH_STATE.byValue.get(valueKey);
1418
- if (existing) return existing;
1419
- let length = normalizedStartLength;
1420
- while (true) {
1421
- if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
1422
- length++;
1423
- continue;
1424
- }
1425
- for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
1426
- const hash = getPooledHashCandidate(value, length, index);
1427
- const owner = POOLED_HASH_STATE.byHash.get(hash);
1428
- if (owner !== void 0 && owner !== valueKey) continue;
1429
- POOLED_HASH_STATE.byValue.set(valueKey, hash);
1430
- POOLED_HASH_STATE.byHash.set(hash, valueKey);
1431
- POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
1432
- return hash;
1433
- }
1434
- length++;
1435
- }
1436
- }
1437
- function getPooledHashCandidate(value, length, index) {
1438
- return getIdentifierSafeHashValue(hashString(index === 0 ? value : value + "::" + index)).slice(0, length);
1439
- }
1440
- function getPooledHashUsedCount(length) {
1441
- return POOLED_HASH_STATE.usedByLength[length] ?? 0;
1442
- }
1443
- function getIdentifierSafeHashPoolSize(length) {
1444
- if (length <= 0) return 0;
1445
- return 26 * 36 ** (length - 1);
1422
+ return getIdentifierSafeHashValue(hashString(value)).slice(0, normalizedStartLength);
1446
1423
  }
1447
1424
  function getIdentifierSafeHashValue(hash) {
1448
1425
  const first = hash.charCodeAt(0);
@@ -1492,8 +1469,16 @@ function getAtomicClassName(property, priority, important, value, selector, pare
1492
1469
  });
1493
1470
  }
1494
1471
  function getRuntimeClassNameHashLength(debugClassName) {
1495
- if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
1496
- return CSS_CONFIG.hashLength ?? 7;
1472
+ return getClassNameHashLength({
1473
+ debugClassName,
1474
+ isDev: DEV_CONFIG.isDev,
1475
+ devHashLength: DEV_CONFIG.hashLength,
1476
+ cssHashLength: CSS_CONFIG.hashLength
1477
+ });
1478
+ }
1479
+ function getClassNameHashLength(options) {
1480
+ if (options.debugClassName && options.isDev) return options.devHashLength ?? options.cssHashLength ?? 3;
1481
+ return options.cssHashLength ?? 7;
1497
1482
  }
1498
1483
  function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
1499
1484
  let hash = property;
@@ -3749,9 +3734,11 @@ function createImportSourceMatcher(importSources) {
3749
3734
  meta: DefaultStyleFnMeta
3750
3735
  });
3751
3736
  importSources?.forEach((entry) => {
3737
+ const meta = entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null);
3738
+ if (!meta) return;
3752
3739
  addImportSourceEntry(state, {
3753
3740
  ...entry,
3754
- meta: getStyleFnMeta(entry.styleFn)
3741
+ meta
3755
3742
  });
3756
3743
  });
3757
3744
  return (source) => {
@@ -5973,7 +5960,7 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, st
5973
5960
  if (!meta) return null;
5974
5961
  if (meta.mode === "ClassName") {
5975
5962
  if (chain.kind !== "style") return null;
5976
- return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
5963
+ return compileClassNameChain(chain, meta.selectors, fileId, nodeLoc, scope, css, meta.transform, styleNames, opts);
5977
5964
  }
5978
5965
  const selectors = meta.selectors;
5979
5966
  const transform = meta.transform;
@@ -6064,14 +6051,19 @@ function compileSelectorStyleArg(styleArgNode, fileId, scope, cssConfig, transfo
6064
6051
  function getCssConfig(opts, runtimeMode) {
6065
6052
  const css = opts.css;
6066
6053
  const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
6054
+ const debugClassName = css?.debugClassName ?? isDevRuntimeMode;
6067
6055
  return {
6068
6056
  classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
6069
6057
  sheetClassNameFormat: css?.sheetClassNameFormat ?? DEFAULT_CONFIG.sheetClassNameFormat ?? null,
6070
6058
  transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
6071
- hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
6059
+ hashLength: getClassNameHashLength({
6060
+ debugClassName,
6061
+ isDev: isDevRuntimeMode,
6062
+ cssHashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength
6063
+ }),
6072
6064
  tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
6073
6065
  localClassName: isDevRuntimeMode,
6074
- debugClassName: css?.debugClassName ?? isDevRuntimeMode,
6066
+ debugClassName,
6075
6067
  scopeTargetPrefix: css?.scopeTargetPrefix ?? ""
6076
6068
  };
6077
6069
  }
@@ -6089,10 +6081,10 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
6089
6081
  rules
6090
6082
  };
6091
6083
  }
6092
- function compileClassNameChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options) {
6084
+ function compileClassNameChain(chain, selectors, fileId, nodeLoc, scope, cssConfig, transform, styleNames, options) {
6093
6085
  const items = [];
6094
6086
  const rules = [];
6095
- if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, cssConfig, transform, 1, null, items, rules)) return null;
6087
+ if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, createClassNameFallbackLocation(nodeLoc, scope, fileId), cssConfig, transform, 1, null, items, rules)) return null;
6096
6088
  let i = 0;
6097
6089
  while (i < chain.methods.length) {
6098
6090
  const method = chain.methods[i];
@@ -6114,7 +6106,7 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
6114
6106
  const localChain = getLocalStyleChainArg(method.args[0], scope, styleNames);
6115
6107
  const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
6116
6108
  if (localChain?.kind === "style" && localMeta?.mode === "ClassName") {
6117
- const result = compileClassNameChain(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, styleNames, options);
6109
+ const result = compileClassNameChain(localChain, localMeta.selectors, fileId, method.nameNode.loc?.start, scope, cssConfig, localMeta.transform, styleNames, options);
6118
6110
  if (!result) return false;
6119
6111
  items.push(...result.items);
6120
6112
  rules.push(...result.rules);
@@ -6139,7 +6131,7 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
6139
6131
  }
6140
6132
  const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
6141
6133
  const classNameOffset = hasArg ? argOffset + 1 : argOffset;
6142
- return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, cssConfig, transform, 1, null, items, rules);
6134
+ return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
6143
6135
  }
6144
6136
  if (selectorStr.includes("$$") || selectorStr.includes("$")) {
6145
6137
  const splitToken = selectorStr.includes("$$") ? "$$" : "$";
@@ -6149,14 +6141,15 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
6149
6141
  if (!selectorArg.ok) return false;
6150
6142
  const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
6151
6143
  const itemSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
6152
- return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
6144
+ return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
6153
6145
  }
6154
6146
  const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
6155
- return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
6147
+ return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
6156
6148
  }
6157
- function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, cssConfig, transform, type, slotId, items, rules) {
6149
+ function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, fallbackLocation, cssConfig, transform, type, slotId, items, rules) {
6158
6150
  if (startIndex >= args.length) return true;
6159
6151
  const styleObj = {};
6152
+ const locations = {};
6160
6153
  let i = startIndex;
6161
6154
  while (i < args.length) {
6162
6155
  const arg = evaluateNode(args[i], scope);
@@ -6164,28 +6157,59 @@ function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, s
6164
6157
  throwIfRequiredStaticStyleValue(arg);
6165
6158
  return false;
6166
6159
  }
6167
- if (!appendClassNameArgStyle(arg.value, transform, styleObj)) return false;
6160
+ if (!appendClassNameArgStyle(args[i], arg.value, transform, styleObj, locations, fallbackLocation, scope, fileId)) return false;
6168
6161
  i++;
6169
6162
  }
6163
+ if (Object.keys(locations).length) Object.defineProperty(styleObj, COMPILED_STYLE_OBJECT_LOCATIONS, {
6164
+ configurable: true,
6165
+ enumerable: false,
6166
+ value: locations
6167
+ });
6170
6168
  return addStyleItems(styleObj, selector, null, atRules, fileId, type, slotId, items, rules, cssConfig);
6171
6169
  }
6172
- function appendClassNameArgStyle(value, transform, styleObj) {
6170
+ function appendClassNameArgStyle(node, value, transform, styleObj, locations, fallbackLocation, scope, fileId) {
6173
6171
  if (!value) return true;
6174
6172
  if (typeof value === "string") {
6175
- Object.assign(styleObj, decorateClassNameStyle(transform.transform(value), value));
6173
+ const transformed = decorateClassNameStyle(transform.transform(value), value);
6174
+ Object.assign(styleObj, transformed);
6175
+ assignClassNameStyleLocations(transformed, locations, getClassNameArgLocation(node, fallbackLocation, scope, fileId));
6176
6176
  return true;
6177
6177
  }
6178
6178
  if (Array.isArray(value)) {
6179
- for (const item of value) if (!appendClassNameArgStyle(item, transform, styleObj)) return false;
6179
+ const nodes = node.type === "ArrayExpression" ? node.elements : [];
6180
+ for (let i = 0; i < value.length; i++) if (!appendClassNameArgStyle(nodes[i] ?? node, value[i], transform, styleObj, locations, fallbackLocation, scope, fileId)) return false;
6180
6181
  return true;
6181
6182
  }
6182
6183
  if (isWeightedClassName(value)) {
6183
6184
  const transformed = decorateClassNameStyle(transform.transform(value.className), value.className);
6184
6185
  Object.assign(styleObj, applyClassNameWeight(transformed, value.weight));
6186
+ assignClassNameStyleLocations(transformed, locations, getWeightedClassNameArgLocation(node, fallbackLocation, scope, fileId));
6185
6187
  return true;
6186
6188
  }
6187
6189
  return false;
6188
6190
  }
6191
+ function assignClassNameStyleLocations(styleObj, locations, location) {
6192
+ if (!location) return;
6193
+ for (const property of Object.keys(styleObj)) locations[property] = location;
6194
+ }
6195
+ function getClassNameArgLocation(node, fallbackLocation, scope, fileId) {
6196
+ if (node.type === "StringLiteral") return createClassNameFallbackLocation(node.loc?.start, scope, fileId);
6197
+ if (node.type === "TemplateLiteral" && node.expressions.length === 0) return createClassNameFallbackLocation(node.loc?.start, scope, fileId);
6198
+ return fallbackLocation;
6199
+ }
6200
+ function getWeightedClassNameArgLocation(node, fallbackLocation, scope, fileId) {
6201
+ if (node.type === "CallExpression" && node.arguments[0] && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "weight") return getClassNameArgLocation(node.arguments[0], fallbackLocation, scope, fileId);
6202
+ return fallbackLocation;
6203
+ }
6204
+ function createClassNameFallbackLocation(loc, scope, fileId) {
6205
+ if (!loc) return null;
6206
+ return {
6207
+ filePath: scope.styleFilePath ?? fileId,
6208
+ line: loc.line,
6209
+ column: loc.column + 1,
6210
+ variable: false
6211
+ };
6212
+ }
6189
6213
  function decorateClassNameStyle(style, className) {
6190
6214
  const result = {};
6191
6215
  for (const [property, value] of Object.entries(style)) {
@@ -7037,7 +7061,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
7037
7061
  column: propertyLoc.column
7038
7062
  } : null);
7039
7063
  const shouldUseVariable = !!(token || runtimeValue);
7040
- const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
7064
+ const variableName = shouldUseVariable && propertyLoc && propertyLoc.variable !== false ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
7041
7065
  const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
7042
7066
  const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
7043
7067
  const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
@@ -8380,10 +8404,10 @@ function createCompiler(args, options) {
8380
8404
  const tracer = createTracer(internal);
8381
8405
  const collector = createCssCollector();
8382
8406
  const compileDebug = (args) => {
8383
- return rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode);
8407
+ return rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
8384
8408
  };
8385
8409
  const compileDebugRSC = (args) => {
8386
- const debugResult = rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode);
8410
+ const debugResult = rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
8387
8411
  if (!debugResult) return null;
8388
8412
  const rscCollector = createCssCollector();
8389
8413
  transformExtract(internal, args, {
@@ -8412,7 +8436,7 @@ function createCompiler(args, options) {
8412
8436
  return rewriteTransformResult({
8413
8437
  ...result,
8414
8438
  rules: collector.getItems().slice(startIndex)
8415
- }, internal.runtimeMode);
8439
+ }, internal.runtimeMode, args.code);
8416
8440
  };
8417
8441
  const getExtractedCss = () => {
8418
8442
  return extractCss(collector.getItems(), {
@@ -8442,44 +8466,72 @@ function createCompilerInternal(args, options) {
8442
8466
  options
8443
8467
  };
8444
8468
  }
8445
- function rewriteTransformResult(result, runtimeMode) {
8469
+ function rewriteTransformResult(result, runtimeMode, sourceCode) {
8446
8470
  if (!result || !runtimeMode) return result;
8447
8471
  return {
8448
8472
  ...result,
8449
- code: rewriteCompilerRuntimeImports(result.code, runtimeMode)
8473
+ code: rewriteCompilerRuntimeImports(result.code, runtimeMode, sourceCode)
8450
8474
  };
8451
8475
  }
8452
- function rewriteCompilerRuntimeImports(code, runtimeMode) {
8453
- return rewriteImportSources(code, (source) => getCompilerRuntimeImportSource(source, runtimeMode));
8476
+ function rewriteCompilerRuntimeImports(code, runtimeMode, sourceCode) {
8477
+ const importRuntimeMode = getImportRuntimeMode(runtimeMode, sourceCode);
8478
+ return rewriteImportSources(code, (source) => getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode));
8479
+ }
8480
+ function getImportRuntimeMode(runtimeMode, sourceCode) {
8481
+ if (runtimeMode === "rsc-dev" && hasUseClientDirective(sourceCode)) return "dev";
8482
+ return runtimeMode;
8454
8483
  }
8455
- function getCompilerRuntimeImportSource(source, runtimeMode) {
8456
- if (source === "@fluentic/style") return getStyleRuntimeImportPath(runtimeMode);
8457
- const adapterImportPath = getStyleRuntimeAdapterImportPath(source, runtimeMode);
8484
+ function getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode) {
8485
+ if (source === "@fluentic/style") return getStyleRuntimeImportPath(importRuntimeMode);
8486
+ const adapterImportPath = getStyleRuntimeAdapterImportPath(source, importRuntimeMode);
8458
8487
  if (adapterImportPath) return adapterImportPath;
8459
- if (source === "@fluentic/style/css") return getStyleRuntimeCssImportPath(runtimeMode);
8488
+ if (source === "@fluentic/style/css") return getStyleRuntimeCssImportPath(importRuntimeMode);
8460
8489
  if (source === "@fluentic/style/entry/prod/runtime") return getStyleExtractRuntimeImportPath(runtimeMode);
8461
8490
  if (runtimeMode === "rsc-dev" && source === "@fluentic/style/dev/rsc") return getStyleRuntimeDevRscImportPath(runtimeMode);
8462
8491
  return null;
8463
8492
  }
8464
- const CssPropPresets = {
8465
- Solid: {
8466
- classProp: "class",
8467
- styleProp: "style",
8468
- styleMode: "solid",
8469
- adapter: "@fluentic/style/adapter/solid"
8470
- },
8471
- Preact: {
8472
- classProp: "class",
8473
- styleProp: "style",
8474
- styleMode: "react",
8475
- adapter: "@fluentic/style/adapter/preact"
8476
- },
8477
- React: {
8478
- classProp: "className",
8479
- styleProp: "style",
8480
- styleMode: "react",
8481
- adapter: "@fluentic/style/adapter/react"
8493
+ function hasUseClientDirective(code) {
8494
+ let index = 0;
8495
+ while (index < code.length) {
8496
+ index = skipWhitespaceAndComments(code, index);
8497
+ const quote = code[index];
8498
+ if (quote !== "\"" && quote !== "'") return false;
8499
+ const end = code.indexOf(quote, index + 1);
8500
+ if (end < 0) return false;
8501
+ const directive = code.slice(index + 1, end);
8502
+ index = skipWhitespaceAndComments(code, end + 1);
8503
+ if (code[index] === ";") index += 1;
8504
+ else if (code[index] && code[index] !== "\n" && code[index] !== "\r") return false;
8505
+ if (directive === "use client") return true;
8482
8506
  }
8507
+ return false;
8508
+ }
8509
+ function skipWhitespaceAndComments(code, index) {
8510
+ let next = index;
8511
+ while (next < code.length) {
8512
+ const char = code[next];
8513
+ if (char === " " || char === " " || char === "\n" || char === "\r") {
8514
+ next += 1;
8515
+ continue;
8516
+ }
8517
+ if (char === "/" && code[next + 1] === "/") {
8518
+ const lineEnd = code.indexOf("\n", next + 2);
8519
+ next = lineEnd < 0 ? code.length : lineEnd + 1;
8520
+ continue;
8521
+ }
8522
+ if (char === "/" && code[next + 1] === "*") {
8523
+ const commentEnd = code.indexOf("*/", next + 2);
8524
+ next = commentEnd < 0 ? code.length : commentEnd + 2;
8525
+ continue;
8526
+ }
8527
+ break;
8528
+ }
8529
+ return next;
8530
+ }
8531
+ const CssPropPresets = {
8532
+ Solid: { adapter: "@fluentic/style/adapter/solid" },
8533
+ Preact: { adapter: "@fluentic/style/adapter/preact" },
8534
+ React: { adapter: "@fluentic/style/adapter/react" }
8483
8535
  };
8484
8536
  //#endregion
8485
8537
  //#region plugin/utils/constants.ts
@@ -9174,4 +9226,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
9174
9226
  }
9175
9227
  });
9176
9228
 
9177
- //# sourceMappingURL=shared-8_Msr7Q5.cjs.map
9229
+ //# sourceMappingURL=shared-Bc9RwNNj.cjs.map