@griffel/transform 3.0.5 → 3.0.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 (188) hide show
  1. package/LICENSE.md +21 -0
  2. package/package.json +6 -5
  3. package/src/constants.d.mts +2 -0
  4. package/src/{constants.mts → constants.mjs} +1 -0
  5. package/src/constants.mjs.map +1 -0
  6. package/src/evaluation/astEvaluator.d.mts +20 -0
  7. package/src/evaluation/astEvaluator.mjs +90 -0
  8. package/src/evaluation/astEvaluator.mjs.map +1 -0
  9. package/src/evaluation/batchEvaluator.d.mts +13 -0
  10. package/src/evaluation/batchEvaluator.mjs +54 -0
  11. package/src/evaluation/batchEvaluator.mjs.map +1 -0
  12. package/src/evaluation/evalCache.d.mts +9 -0
  13. package/src/evaluation/evalCache.mjs +65 -0
  14. package/src/evaluation/evalCache.mjs.map +1 -0
  15. package/src/evaluation/fluentTokensPlugin.d.mts +2 -0
  16. package/src/evaluation/fluentTokensPlugin.mjs +70 -0
  17. package/src/evaluation/fluentTokensPlugin.mjs.map +1 -0
  18. package/src/evaluation/module.d.mts +44 -0
  19. package/src/evaluation/module.mjs +207 -0
  20. package/src/evaluation/module.mjs.map +1 -0
  21. package/src/evaluation/process.d.mts +24 -0
  22. package/src/evaluation/{process.mts → process.mjs} +7 -12
  23. package/src/evaluation/process.mjs.map +1 -0
  24. package/src/evaluation/types.d.mts +34 -0
  25. package/src/evaluation/types.mjs +2 -0
  26. package/src/evaluation/types.mjs.map +1 -0
  27. package/src/evaluation/vmEvaluator.d.mts +3 -0
  28. package/src/evaluation/vmEvaluator.mjs +33 -0
  29. package/src/evaluation/vmEvaluator.mjs.map +1 -0
  30. package/src/{index.mts → index.d.mts} +0 -4
  31. package/src/index.mjs +9 -0
  32. package/src/index.mjs.map +1 -0
  33. package/src/transformSync.d.mts +41 -0
  34. package/src/transformSync.mjs +253 -0
  35. package/src/transformSync.mjs.map +1 -0
  36. package/src/types.d.mts +12 -0
  37. package/src/types.mjs +2 -0
  38. package/src/types.mjs.map +1 -0
  39. package/src/utils/convertESMtoCJS.d.mts +6 -0
  40. package/src/utils/convertESMtoCJS.mjs +203 -0
  41. package/src/utils/convertESMtoCJS.mjs.map +1 -0
  42. package/src/utils/dedupeCSSRules.d.mts +6 -0
  43. package/src/utils/dedupeCSSRules.mjs +19 -0
  44. package/src/utils/dedupeCSSRules.mjs.map +1 -0
  45. package/CHANGELOG.json +0 -404
  46. package/CHANGELOG.md +0 -130
  47. package/__fixtures__/assets/blank.jpg +0 -0
  48. package/__fixtures__/assets/code.ts +0 -12
  49. package/__fixtures__/assets/empty.jpg +0 -0
  50. package/__fixtures__/assets/output.meta.json +0 -12
  51. package/__fixtures__/assets/output.ts +0 -12
  52. package/__fixtures__/assets-multiple-declarations/blank.jpg +0 -0
  53. package/__fixtures__/assets-multiple-declarations/code.ts +0 -8
  54. package/__fixtures__/assets-multiple-declarations/empty.jpg +0 -0
  55. package/__fixtures__/assets-multiple-declarations/output.meta.json +0 -9
  56. package/__fixtures__/assets-multiple-declarations/output.ts +0 -6
  57. package/__fixtures__/assets-reset-styles/blank.jpg +0 -0
  58. package/__fixtures__/assets-reset-styles/code.ts +0 -11
  59. package/__fixtures__/assets-reset-styles/empty.jpg +0 -0
  60. package/__fixtures__/assets-reset-styles/output.meta.json +0 -11
  61. package/__fixtures__/assets-reset-styles/output.ts +0 -7
  62. package/__fixtures__/assets-urls/code.ts +0 -13
  63. package/__fixtures__/assets-urls/output.meta.json +0 -14
  64. package/__fixtures__/assets-urls/output.ts +0 -10
  65. package/__fixtures__/at-rules/code.ts +0 -14
  66. package/__fixtures__/at-rules/output.meta.json +0 -15
  67. package/__fixtures__/at-rules/output.ts +0 -10
  68. package/__fixtures__/config-classname-hash-salt/code.ts +0 -5
  69. package/__fixtures__/config-classname-hash-salt/output.meta.json +0 -7
  70. package/__fixtures__/config-classname-hash-salt/output.ts +0 -3
  71. package/__fixtures__/config-evaluation-rules/code.ts +0 -8
  72. package/__fixtures__/config-evaluation-rules/consts.ts +0 -1
  73. package/__fixtures__/config-evaluation-rules/output.meta.json +0 -7
  74. package/__fixtures__/config-evaluation-rules/output.ts +0 -4
  75. package/__fixtures__/config-evaluation-rules/sampleEvaluator.cjs +0 -12
  76. package/__fixtures__/error-argument-count/fixture.js +0 -4
  77. package/__fixtures__/error-cjs/fixture.js +0 -4
  78. package/__fixtures__/error-on-undefined/fixture.ts +0 -7
  79. package/__fixtures__/error-on-undefined/tokens.ts +0 -1
  80. package/__fixtures__/export-default/code.ts +0 -6
  81. package/__fixtures__/export-default/output.meta.json +0 -14
  82. package/__fixtures__/export-default/output.ts +0 -6
  83. package/__fixtures__/function-mixin/code.ts +0 -6
  84. package/__fixtures__/function-mixin/mixins.ts +0 -7
  85. package/__fixtures__/function-mixin/output.meta.json +0 -7
  86. package/__fixtures__/function-mixin/output.ts +0 -4
  87. package/__fixtures__/function-mixin/tokens.ts +0 -3
  88. package/__fixtures__/import-alias/code.ts +0 -5
  89. package/__fixtures__/import-alias/output.meta.json +0 -7
  90. package/__fixtures__/import-alias/output.ts +0 -3
  91. package/__fixtures__/import-custom-module/code.ts +0 -6
  92. package/__fixtures__/import-custom-module/output.meta.json +0 -7
  93. package/__fixtures__/import-custom-module/output.ts +0 -4
  94. package/__fixtures__/keyframes/code.ts +0 -22
  95. package/__fixtures__/keyframes/output.meta.json +0 -17
  96. package/__fixtures__/keyframes/output.ts +0 -6
  97. package/__fixtures__/multiple-declarations/code.ts +0 -8
  98. package/__fixtures__/multiple-declarations/output.meta.json +0 -7
  99. package/__fixtures__/multiple-declarations/output.ts +0 -4
  100. package/__fixtures__/non-existing-module-call/code.ts +0 -10
  101. package/__fixtures__/non-existing-module-call/module.ts +0 -13
  102. package/__fixtures__/non-existing-module-call/output.meta.json +0 -7
  103. package/__fixtures__/non-existing-module-call/output.ts +0 -6
  104. package/__fixtures__/object/code.ts +0 -6
  105. package/__fixtures__/object/output.meta.json +0 -14
  106. package/__fixtures__/object/output.ts +0 -6
  107. package/__fixtures__/object-computed-keys/code.ts +0 -8
  108. package/__fixtures__/object-computed-keys/output.meta.json +0 -14
  109. package/__fixtures__/object-computed-keys/output.ts +0 -8
  110. package/__fixtures__/object-imported-keys/code.ts +0 -9
  111. package/__fixtures__/object-imported-keys/consts.ts +0 -2
  112. package/__fixtures__/object-imported-keys/output.meta.json +0 -7
  113. package/__fixtures__/object-imported-keys/output.ts +0 -4
  114. package/__fixtures__/object-mixins/code.ts +0 -11
  115. package/__fixtures__/object-mixins/mixins.ts +0 -17
  116. package/__fixtures__/object-mixins/output.meta.json +0 -16
  117. package/__fixtures__/object-mixins/output.ts +0 -10
  118. package/__fixtures__/object-mixins/tokens.ts +0 -3
  119. package/__fixtures__/object-nesting/code.ts +0 -13
  120. package/__fixtures__/object-nesting/consts.ts +0 -1
  121. package/__fixtures__/object-nesting/output.meta.json +0 -9
  122. package/__fixtures__/object-nesting/output.ts +0 -6
  123. package/__fixtures__/object-reset/code.ts +0 -8
  124. package/__fixtures__/object-reset/output.meta.json +0 -7
  125. package/__fixtures__/object-reset/output.ts +0 -5
  126. package/__fixtures__/object-sequence-expr/code.ts +0 -16
  127. package/__fixtures__/object-sequence-expr/output.meta.json +0 -7
  128. package/__fixtures__/object-sequence-expr/output.ts +0 -7
  129. package/__fixtures__/object-shorthands/code.ts +0 -8
  130. package/__fixtures__/object-shorthands/output.meta.json +0 -20
  131. package/__fixtures__/object-shorthands/output.ts +0 -5
  132. package/__fixtures__/object-variables/code.ts +0 -9
  133. package/__fixtures__/object-variables/output.meta.json +0 -15
  134. package/__fixtures__/object-variables/output.ts +0 -9
  135. package/__fixtures__/object-variables/vars.ts +0 -5
  136. package/__fixtures__/reset-styles/code.ts +0 -6
  137. package/__fixtures__/reset-styles/output.meta.json +0 -7
  138. package/__fixtures__/reset-styles/output.ts +0 -3
  139. package/__fixtures__/reset-styles-at-rules/code.ts +0 -7
  140. package/__fixtures__/reset-styles-at-rules/output.meta.json +0 -8
  141. package/__fixtures__/reset-styles-at-rules/output.ts +0 -3
  142. package/__fixtures__/rules-with-metadata/code.ts +0 -9
  143. package/__fixtures__/rules-with-metadata/output.meta.json +0 -14
  144. package/__fixtures__/rules-with-metadata/output.ts +0 -3
  145. package/__fixtures__/shared-mixins/code.ts +0 -7
  146. package/__fixtures__/shared-mixins/mixins.ts +0 -6
  147. package/__fixtures__/shared-mixins/output.meta.json +0 -7
  148. package/__fixtures__/shared-mixins/output.ts +0 -8
  149. package/__fixtures__/static-styles/code.ts +0 -7
  150. package/__fixtures__/static-styles/output.meta.json +0 -7
  151. package/__fixtures__/static-styles/output.ts +0 -3
  152. package/__fixtures__/static-styles-array/code.ts +0 -10
  153. package/__fixtures__/static-styles-array/output.meta.json +0 -7
  154. package/__fixtures__/static-styles-array/output.ts +0 -3
  155. package/__fixtures__/static-styles-string/code.ts +0 -3
  156. package/__fixtures__/static-styles-string/output.meta.json +0 -7
  157. package/__fixtures__/static-styles-string/output.ts +0 -3
  158. package/__fixtures__/tokens/code.ts +0 -11
  159. package/__fixtures__/tokens/output.meta.json +0 -12
  160. package/__fixtures__/tokens/output.ts +0 -7
  161. package/__fixtures__/tokens/tokens.ts +0 -4
  162. package/__fixtures__/unsupported-css-properties/fixture.ts +0 -16
  163. package/__fixtures__/unsupported-css-properties/output.meta.json +0 -5
  164. package/__fixtures__/unsupported-css-properties/output.ts +0 -3
  165. package/eslint.config.mjs +0 -31
  166. package/project.json +0 -51
  167. package/src/evaluation/astEvaluator.mts +0 -109
  168. package/src/evaluation/astEvaluator.test.mts +0 -126
  169. package/src/evaluation/batchEvaluator.mts +0 -79
  170. package/src/evaluation/evalCache.mts +0 -84
  171. package/src/evaluation/fluentTokensPlugin.mts +0 -82
  172. package/src/evaluation/fluentTokensPlugin.test.mts +0 -130
  173. package/src/evaluation/module.mts +0 -271
  174. package/src/evaluation/module.test.mts +0 -133
  175. package/src/evaluation/types.mts +0 -49
  176. package/src/evaluation/vmEvaluator.mts +0 -45
  177. package/src/evaluation/vmEvaluator.test.mts +0 -30
  178. package/src/transformSync.mts +0 -425
  179. package/src/transformSync.test.mts +0 -429
  180. package/src/types.mts +0 -13
  181. package/src/utils/convertESMtoCJS.mts +0 -226
  182. package/src/utils/convertESMtoCJS.test.mts +0 -159
  183. package/src/utils/dedupeCSSRules.mts +0 -25
  184. package/src/utils/dedupeCSSRules.test.mts +0 -39
  185. package/tsconfig.json +0 -19
  186. package/tsconfig.lib.json +0 -30
  187. package/tsconfig.spec.json +0 -24
  188. package/vitest.config.mts +0 -18
@@ -1,7 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": true,
4
- "cssRulesByBucket": {
5
- "h": [".f1cm6cy7:hover .fui-Switch:before{background-color:red;}"]
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- import type { GriffelStyle } from '@griffel/react';
2
- import { __css } from '@griffel/react';
3
-
4
- const switchClassName = 'fui-Switch';
5
- let _a: Record<string, GriffelStyle>;
6
-
7
- export const useStyles = __css({ root: { ozcac4: 'f1cm6cy7' } });
@@ -1,8 +0,0 @@
1
- import { makeStyles } from '@griffel/react';
2
-
3
- export const useStyles = makeStyles({
4
- root: {
5
- borderRight: `5px solid red /* @noflip */`,
6
- borderBottom: `5px solid red`,
7
- },
8
- });
@@ -1,20 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": false,
4
- "cssRulesByBucket": {
5
- "d": [
6
- [
7
- ".fq3r367{border-right:5px solid red ;}",
8
- {
9
- "p": -1
10
- }
11
- ],
12
- [
13
- ".f171p8tk{border-bottom:5px solid red;}",
14
- {
15
- "p": -1
16
- }
17
- ]
18
- ]
19
- }
20
- }
@@ -1,5 +0,0 @@
1
- import { __css } from '@griffel/react';
2
-
3
- export const useStyles = __css({
4
- root: { h3c5rm: 0, vrafjx: 0, Bekrc4i: 0, u1mtju: 'fq3r367', B9xav0g: 0, oivjwe: 0, Bn0qgzm: 0, Bgfg5da: 'f171p8tk' },
5
- });
@@ -1,9 +0,0 @@
1
- import { makeStyles } from '@griffel/react';
2
- import { colorGreen, theme } from './vars';
3
-
4
- const colorRed = 'red';
5
-
6
- export const useStyles = makeStyles({
7
- root: { color: colorRed, paddingLeft: '4px' },
8
- icon: { color: theme.black, backgroundColor: colorGreen, marginLeft: '4px' },
9
- });
@@ -1,15 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": true,
4
- "cssRulesByBucket": {
5
- "d": [
6
- ".fe3e8s9{color:red;}",
7
- ".fycuoez{padding-left:4px;}",
8
- ".f8wuabp{padding-right:4px;}",
9
- ".fusgiwz{color:#000;}",
10
- ".fcnqdeg{background-color:green;}",
11
- ".fjf1xye{margin-left:4px;}",
12
- ".f8zmjen{margin-right:4px;}"
13
- ]
14
- }
15
- }
@@ -1,9 +0,0 @@
1
- import { __css } from '@griffel/react';
2
- import { colorGreen, theme } from './vars';
3
-
4
- const colorRed = 'red';
5
-
6
- export const useStyles = __css({
7
- root: { sj55zd: 'fe3e8s9', uwmqm3: ['fycuoez', 'f8wuabp'] },
8
- icon: { sj55zd: 'fusgiwz', De3pzq: 'fcnqdeg', Frg6f3: ['fjf1xye', 'f8zmjen'] },
9
- });
@@ -1,5 +0,0 @@
1
- export const colorGreen = 'green';
2
-
3
- export const theme = {
4
- black: '#000',
5
- };
@@ -1,6 +0,0 @@
1
- import { makeResetStyles } from '@griffel/react';
2
-
3
- export const useStyles = makeResetStyles({
4
- color: 'red',
5
- paddingLeft: '4px',
6
- });
@@ -1,7 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": false,
4
- "cssRulesByBucket": {
5
- "r": [".rjefjbm{color:red;padding-left:4px;}", ".r7z97ji{color:red;padding-right:4px;}"]
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- import { __resetCSS } from '@griffel/react';
2
-
3
- export const useStyles = __resetCSS('rjefjbm', 'r7z97ji');
@@ -1,7 +0,0 @@
1
- import { makeResetStyles } from '@griffel/react';
2
-
3
- export const useStyles = makeResetStyles({
4
- color: 'red',
5
- '@supports (display: flex)': { color: 'pink' },
6
- '@media (min-width: 100px)': { color: 'blue' },
7
- });
@@ -1,8 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": false,
4
- "cssRulesByBucket": {
5
- "r": [".rjrhw4c{color:red;}"],
6
- "s": ["@supports (display: flex){.rjrhw4c{color:pink;}}", "@media (min-width: 100px){.rjrhw4c{color:blue;}}"]
7
- }
8
- }
@@ -1,3 +0,0 @@
1
- import { __resetCSS } from '@griffel/react';
2
-
3
- export const useStyles = __resetCSS('rjrhw4c', null);
@@ -1,9 +0,0 @@
1
- import { makeStyles } from '@griffel/react';
2
-
3
- export const useStyles = makeStyles({
4
- media: {
5
- '@media screen and (max-width: 100px)': {
6
- color: 'red',
7
- },
8
- },
9
- });
@@ -1,14 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": false,
4
- "cssRulesByBucket": {
5
- "m": [
6
- [
7
- "@media screen and (max-width: 100px){.ful25cn{color:red;}}",
8
- {
9
- "m": "screen and (max-width: 100px)"
10
- }
11
- ]
12
- ]
13
- }
14
- }
@@ -1,3 +0,0 @@
1
- import { __css } from '@griffel/react';
2
-
3
- export const useStyles = __css({ media: { Bn3jx5e: 'ful25cn' } });
@@ -1,7 +0,0 @@
1
- import { makeStyles } from '@griffel/react';
2
- import { sharedStyles } from './mixins';
3
-
4
- export const useStyles = makeStyles({
5
- ...sharedStyles,
6
- icon: { color: 'red' },
7
- });
@@ -1,6 +0,0 @@
1
- import type { GriffelStyle } from '@griffel/core';
2
-
3
- export const sharedStyles: Record<string, GriffelStyle> = {
4
- root: { display: 'flex' },
5
- container: { display: 'grid' },
6
- };
@@ -1,7 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": true,
4
- "cssRulesByBucket": {
5
- "d": [".f22iagw{display:flex;}", ".f13qh94s{display:grid;}", ".fe3e8s9{color:red;}"]
6
- }
7
- }
@@ -1,8 +0,0 @@
1
- import { __css } from '@griffel/react';
2
- import { sharedStyles } from './mixins';
3
-
4
- export const useStyles = __css({
5
- root: { mc9l5x: 'f22iagw' },
6
- container: { mc9l5x: 'f13qh94s' },
7
- icon: { sj55zd: 'fe3e8s9' },
8
- });
@@ -1,7 +0,0 @@
1
- import { makeStaticStyles } from '@griffel/react';
2
-
3
- export const useStaticStyles = makeStaticStyles({
4
- body: {
5
- background: 'red',
6
- },
7
- });
@@ -1,7 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": false,
4
- "cssRulesByBucket": {
5
- "d": ["body{background:red;}"]
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- import { __staticCSS } from '@griffel/react';
2
-
3
- export const useStaticStyles = __staticCSS({ d: ['body{background:red;}'] });
@@ -1,10 +0,0 @@
1
- import { makeStaticStyles } from '@griffel/react';
2
-
3
- export const useStaticStyles = makeStaticStyles([
4
- {
5
- body: {
6
- background: 'red',
7
- },
8
- },
9
- 'html { margin: 0; }',
10
- ]);
@@ -1,7 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": true,
4
- "cssRulesByBucket": {
5
- "d": ["body{background:red;}", "html{margin:0;}"]
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- import { __staticCSS } from '@griffel/react';
2
-
3
- export const useStaticStyles = __staticCSS({ d: ['body{background:red;}', 'html{margin:0;}'] });
@@ -1,3 +0,0 @@
1
- import { makeStaticStyles } from '@griffel/react';
2
-
3
- export const useStaticStyles = makeStaticStyles('body { background: red; }');
@@ -1,7 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": false,
4
- "cssRulesByBucket": {
5
- "d": ["body{background:red;}"]
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- import { __staticCSS } from '@griffel/react';
2
-
3
- export const useStaticStyles = __staticCSS({ d: ['body{background:red;}'] });
@@ -1,11 +0,0 @@
1
- import { makeStyles } from '@griffel/react';
2
- import { customTokens } from './tokens';
3
-
4
- export const useStyles = makeStyles({
5
- root: {
6
- backgroundColor: 'black',
7
- color: customTokens.colorPaletteBlueBorder2,
8
- display: 'flex',
9
- },
10
- rootPrimary: { color: customTokens.colorBrandBackground },
11
- });
@@ -1,12 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": true,
4
- "cssRulesByBucket": {
5
- "d": [
6
- ".f1734hy{background-color:black;}",
7
- ".ff34w31{color:var(--colorPaletteBlueBorder2);}",
8
- ".f22iagw{display:flex;}",
9
- ".f1817uup{color:var(--colorBrandBackground);}"
10
- ]
11
- }
12
- }
@@ -1,7 +0,0 @@
1
- import { __css } from '@griffel/react';
2
- import { customTokens } from './tokens';
3
-
4
- export const useStyles = __css({
5
- root: { De3pzq: 'f1734hy', sj55zd: 'ff34w31', mc9l5x: 'f22iagw' },
6
- rootPrimary: { sj55zd: 'f1817uup' },
7
- });
@@ -1,4 +0,0 @@
1
- export const customTokens = {
2
- colorPaletteBlueBorder2: 'var(--colorPaletteBlueBorder2)',
3
- colorBrandBackground: 'var(--colorBrandBackground)',
4
- };
@@ -1,16 +0,0 @@
1
- import { makeStyles } from '@griffel/react';
2
-
3
- export const useStyles = makeStyles({
4
- // List of shorthand properties is not exhaustive
5
- // resulting output should be empty anyway
6
- root: {
7
- // @ts-expect-error unsupported css properties should be stripped
8
- all: 'initial',
9
- // @ts-expect-error unsupported css properties should be stripped
10
- borderColor: 'value',
11
- // @ts-expect-error unsupported css properties should be stripped
12
- borderStyle: 'value',
13
- // @ts-expect-error unsupported css properties should be stripped
14
- borderWidth: 'value',
15
- },
16
- });
@@ -1,5 +0,0 @@
1
- {
2
- "usedProcessing": true,
3
- "usedVMForEvaluation": false,
4
- "cssRulesByBucket": {}
5
- }
@@ -1,3 +0,0 @@
1
- import { __css } from '@griffel/react';
2
-
3
- export const useStyles = __css({ root: {} });
package/eslint.config.mjs DELETED
@@ -1,31 +0,0 @@
1
- import baseConfig from '../../eslint.config.mjs';
2
-
3
- export default [
4
- {
5
- ignores: ['**/dist', '**/out-tsc', '__fixtures__/*/output.ts'],
6
- },
7
- ...baseConfig,
8
- {
9
- files: ['__fixtures__/*/*.ts'],
10
- rules: {
11
- '@typescript-eslint/no-empty-function': 'off',
12
- '@typescript-eslint/no-var-requires': 'off',
13
- },
14
- },
15
- {
16
- files: ['vite.config.*', 'vitest.config.*'],
17
- rules: {
18
- 'import-x/no-extraneous-dependencies': 'off',
19
- },
20
- },
21
- {
22
- files: ['**/*.ts', '**/*.tsx'],
23
- // Override or add rules here
24
- rules: {},
25
- },
26
- {
27
- files: ['**/*.js', '**/*.jsx'],
28
- // Override or add rules here
29
- rules: {},
30
- },
31
- ];
package/project.json DELETED
@@ -1,51 +0,0 @@
1
- {
2
- "name": "@griffel/transform",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/transform/src",
5
- "projectType": "library",
6
- "tags": [],
7
- "targets": {
8
- "lint": {
9
- "executor": "@nx/eslint:lint",
10
- "outputs": ["{options.outputFile}"]
11
- },
12
- "test": {
13
- "executor": "@nx/vitest:test",
14
- "outputs": ["{options.reportsDirectory}"],
15
- "options": {
16
- "reportsDirectory": "{projectRoot}/../../coverage/packages/transform"
17
- }
18
- },
19
- "build": {
20
- "executor": "@nx/js:tsc",
21
- "outputs": ["{options.outputPath}"],
22
- "options": {
23
- "outputPath": "dist/packages/transform",
24
- "tsConfig": "packages/transform/tsconfig.lib.json",
25
- "skipTypeField": true,
26
- "packageJson": "packages/transform/package.json",
27
- "main": "packages/transform/src/index.mts",
28
- "assets": [
29
- "packages/transform/README.md",
30
- {
31
- "glob": "LICENSE.md",
32
- "input": ".",
33
- "output": "."
34
- }
35
- ]
36
- }
37
- },
38
- "type-check": {
39
- "executor": "nx:run-commands",
40
- "options": {
41
- "cwd": "packages/transform",
42
- "commands": [
43
- {
44
- "command": "tsc -b --pretty"
45
- }
46
- ]
47
- },
48
- "outputs": []
49
- }
50
- }
51
- }
@@ -1,109 +0,0 @@
1
- import type { Node, ObjectExpression, Program, TemplateLiteral } from 'oxc-parser';
2
- import type { EvaluationResult, AstEvaluatorContext, AstEvaluatorPlugin } from './types.mjs';
3
-
4
- /**
5
- * Sentinel value returned by plugins and evaluateNode to signal "can't handle this node".
6
- * Using a symbol avoids the cost of Error construction and stack trace capture.
7
- */
8
- export const DEOPT: unique symbol = Symbol('deopt');
9
- export type Deopt = typeof DEOPT;
10
-
11
- /**
12
- * Simple static evaluator for object expressions with nested objects.
13
- * Based on Babel's evaluation approach but simplified for our specific use case.
14
- *
15
- * Handles:
16
- * - Objects with nested objects: { root: { color: 'red', padding: 0 } }
17
- * - String literals, numeric literals, boolean literals, null
18
- * - Simple property access
19
- *
20
- * Plugins can extend evaluation to handle additional node types.
21
- */
22
- export function astEvaluator(node: Node, programAst: Program, plugins: AstEvaluatorPlugin[] = []): EvaluationResult {
23
- const context: AstEvaluatorContext = {
24
- programAst,
25
- evaluateNode,
26
- };
27
-
28
- function evaluateNode(node: Node): unknown {
29
- // Base cases
30
- switch (node.type) {
31
- case 'Literal':
32
- return node.value;
33
-
34
- case 'ObjectExpression':
35
- return evaluateObjectExpression(node);
36
-
37
- case 'TemplateLiteral':
38
- if ((node as TemplateLiteral).expressions.length === 0) {
39
- return (node as TemplateLiteral).quasis[0].value.cooked;
40
- }
41
- break;
42
- }
43
-
44
- // Try plugins in order
45
- // ---
46
-
47
- for (const plugin of plugins) {
48
- const result = plugin.evaluateNode(node, context);
49
-
50
- if (result !== DEOPT) {
51
- return result;
52
- }
53
- }
54
-
55
- return DEOPT;
56
- }
57
-
58
- function evaluateObjectExpression(node: ObjectExpression): unknown {
59
- const obj: Record<string, unknown> = {};
60
-
61
- for (const prop of node.properties) {
62
- if (prop.type !== 'Property' || prop.kind !== 'init') {
63
- return DEOPT;
64
- }
65
-
66
- let key: string;
67
-
68
- if (prop.computed) {
69
- return DEOPT;
70
- } else if (prop.key.type === 'Identifier') {
71
- key = prop.key.name;
72
- } else if (prop.key.type === 'Literal') {
73
- const keyLiteral = prop.key;
74
-
75
- if (typeof keyLiteral.value === 'string' || typeof keyLiteral.value === 'number') {
76
- key = String(keyLiteral.value);
77
- } else {
78
- return DEOPT;
79
- }
80
- } else {
81
- return DEOPT;
82
- }
83
-
84
- const value = evaluateNode(prop.value);
85
-
86
- if (value === DEOPT) {
87
- return DEOPT;
88
- }
89
-
90
- obj[key] = value;
91
- }
92
-
93
- return obj;
94
- }
95
-
96
- const result = evaluateNode(node);
97
-
98
- if (result === DEOPT) {
99
- return {
100
- confident: false,
101
- value: undefined,
102
- };
103
- }
104
-
105
- return {
106
- confident: true,
107
- value: result,
108
- };
109
- }