@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.
- package/LICENSE.md +21 -0
- package/package.json +6 -5
- package/src/constants.d.mts +2 -0
- package/src/{constants.mts → constants.mjs} +1 -0
- package/src/constants.mjs.map +1 -0
- package/src/evaluation/astEvaluator.d.mts +20 -0
- package/src/evaluation/astEvaluator.mjs +90 -0
- package/src/evaluation/astEvaluator.mjs.map +1 -0
- package/src/evaluation/batchEvaluator.d.mts +13 -0
- package/src/evaluation/batchEvaluator.mjs +54 -0
- package/src/evaluation/batchEvaluator.mjs.map +1 -0
- package/src/evaluation/evalCache.d.mts +9 -0
- package/src/evaluation/evalCache.mjs +65 -0
- package/src/evaluation/evalCache.mjs.map +1 -0
- package/src/evaluation/fluentTokensPlugin.d.mts +2 -0
- package/src/evaluation/fluentTokensPlugin.mjs +70 -0
- package/src/evaluation/fluentTokensPlugin.mjs.map +1 -0
- package/src/evaluation/module.d.mts +44 -0
- package/src/evaluation/module.mjs +207 -0
- package/src/evaluation/module.mjs.map +1 -0
- package/src/evaluation/process.d.mts +24 -0
- package/src/evaluation/{process.mts → process.mjs} +7 -12
- package/src/evaluation/process.mjs.map +1 -0
- package/src/evaluation/types.d.mts +34 -0
- package/src/evaluation/types.mjs +2 -0
- package/src/evaluation/types.mjs.map +1 -0
- package/src/evaluation/vmEvaluator.d.mts +3 -0
- package/src/evaluation/vmEvaluator.mjs +33 -0
- package/src/evaluation/vmEvaluator.mjs.map +1 -0
- package/src/{index.mts → index.d.mts} +0 -4
- package/src/index.mjs +9 -0
- package/src/index.mjs.map +1 -0
- package/src/transformSync.d.mts +41 -0
- package/src/transformSync.mjs +253 -0
- package/src/transformSync.mjs.map +1 -0
- package/src/types.d.mts +12 -0
- package/src/types.mjs +2 -0
- package/src/types.mjs.map +1 -0
- package/src/utils/convertESMtoCJS.d.mts +6 -0
- package/src/utils/convertESMtoCJS.mjs +203 -0
- package/src/utils/convertESMtoCJS.mjs.map +1 -0
- package/src/utils/dedupeCSSRules.d.mts +6 -0
- package/src/utils/dedupeCSSRules.mjs +19 -0
- package/src/utils/dedupeCSSRules.mjs.map +1 -0
- package/CHANGELOG.json +0 -404
- package/CHANGELOG.md +0 -130
- package/__fixtures__/assets/blank.jpg +0 -0
- package/__fixtures__/assets/code.ts +0 -12
- package/__fixtures__/assets/empty.jpg +0 -0
- package/__fixtures__/assets/output.meta.json +0 -12
- package/__fixtures__/assets/output.ts +0 -12
- package/__fixtures__/assets-multiple-declarations/blank.jpg +0 -0
- package/__fixtures__/assets-multiple-declarations/code.ts +0 -8
- package/__fixtures__/assets-multiple-declarations/empty.jpg +0 -0
- package/__fixtures__/assets-multiple-declarations/output.meta.json +0 -9
- package/__fixtures__/assets-multiple-declarations/output.ts +0 -6
- package/__fixtures__/assets-reset-styles/blank.jpg +0 -0
- package/__fixtures__/assets-reset-styles/code.ts +0 -11
- package/__fixtures__/assets-reset-styles/empty.jpg +0 -0
- package/__fixtures__/assets-reset-styles/output.meta.json +0 -11
- package/__fixtures__/assets-reset-styles/output.ts +0 -7
- package/__fixtures__/assets-urls/code.ts +0 -13
- package/__fixtures__/assets-urls/output.meta.json +0 -14
- package/__fixtures__/assets-urls/output.ts +0 -10
- package/__fixtures__/at-rules/code.ts +0 -14
- package/__fixtures__/at-rules/output.meta.json +0 -15
- package/__fixtures__/at-rules/output.ts +0 -10
- package/__fixtures__/config-classname-hash-salt/code.ts +0 -5
- package/__fixtures__/config-classname-hash-salt/output.meta.json +0 -7
- package/__fixtures__/config-classname-hash-salt/output.ts +0 -3
- package/__fixtures__/config-evaluation-rules/code.ts +0 -8
- package/__fixtures__/config-evaluation-rules/consts.ts +0 -1
- package/__fixtures__/config-evaluation-rules/output.meta.json +0 -7
- package/__fixtures__/config-evaluation-rules/output.ts +0 -4
- package/__fixtures__/config-evaluation-rules/sampleEvaluator.cjs +0 -12
- package/__fixtures__/error-argument-count/fixture.js +0 -4
- package/__fixtures__/error-cjs/fixture.js +0 -4
- package/__fixtures__/error-on-undefined/fixture.ts +0 -7
- package/__fixtures__/error-on-undefined/tokens.ts +0 -1
- package/__fixtures__/export-default/code.ts +0 -6
- package/__fixtures__/export-default/output.meta.json +0 -14
- package/__fixtures__/export-default/output.ts +0 -6
- package/__fixtures__/function-mixin/code.ts +0 -6
- package/__fixtures__/function-mixin/mixins.ts +0 -7
- package/__fixtures__/function-mixin/output.meta.json +0 -7
- package/__fixtures__/function-mixin/output.ts +0 -4
- package/__fixtures__/function-mixin/tokens.ts +0 -3
- package/__fixtures__/import-alias/code.ts +0 -5
- package/__fixtures__/import-alias/output.meta.json +0 -7
- package/__fixtures__/import-alias/output.ts +0 -3
- package/__fixtures__/import-custom-module/code.ts +0 -6
- package/__fixtures__/import-custom-module/output.meta.json +0 -7
- package/__fixtures__/import-custom-module/output.ts +0 -4
- package/__fixtures__/keyframes/code.ts +0 -22
- package/__fixtures__/keyframes/output.meta.json +0 -17
- package/__fixtures__/keyframes/output.ts +0 -6
- package/__fixtures__/multiple-declarations/code.ts +0 -8
- package/__fixtures__/multiple-declarations/output.meta.json +0 -7
- package/__fixtures__/multiple-declarations/output.ts +0 -4
- package/__fixtures__/non-existing-module-call/code.ts +0 -10
- package/__fixtures__/non-existing-module-call/module.ts +0 -13
- package/__fixtures__/non-existing-module-call/output.meta.json +0 -7
- package/__fixtures__/non-existing-module-call/output.ts +0 -6
- package/__fixtures__/object/code.ts +0 -6
- package/__fixtures__/object/output.meta.json +0 -14
- package/__fixtures__/object/output.ts +0 -6
- package/__fixtures__/object-computed-keys/code.ts +0 -8
- package/__fixtures__/object-computed-keys/output.meta.json +0 -14
- package/__fixtures__/object-computed-keys/output.ts +0 -8
- package/__fixtures__/object-imported-keys/code.ts +0 -9
- package/__fixtures__/object-imported-keys/consts.ts +0 -2
- package/__fixtures__/object-imported-keys/output.meta.json +0 -7
- package/__fixtures__/object-imported-keys/output.ts +0 -4
- package/__fixtures__/object-mixins/code.ts +0 -11
- package/__fixtures__/object-mixins/mixins.ts +0 -17
- package/__fixtures__/object-mixins/output.meta.json +0 -16
- package/__fixtures__/object-mixins/output.ts +0 -10
- package/__fixtures__/object-mixins/tokens.ts +0 -3
- package/__fixtures__/object-nesting/code.ts +0 -13
- package/__fixtures__/object-nesting/consts.ts +0 -1
- package/__fixtures__/object-nesting/output.meta.json +0 -9
- package/__fixtures__/object-nesting/output.ts +0 -6
- package/__fixtures__/object-reset/code.ts +0 -8
- package/__fixtures__/object-reset/output.meta.json +0 -7
- package/__fixtures__/object-reset/output.ts +0 -5
- package/__fixtures__/object-sequence-expr/code.ts +0 -16
- package/__fixtures__/object-sequence-expr/output.meta.json +0 -7
- package/__fixtures__/object-sequence-expr/output.ts +0 -7
- package/__fixtures__/object-shorthands/code.ts +0 -8
- package/__fixtures__/object-shorthands/output.meta.json +0 -20
- package/__fixtures__/object-shorthands/output.ts +0 -5
- package/__fixtures__/object-variables/code.ts +0 -9
- package/__fixtures__/object-variables/output.meta.json +0 -15
- package/__fixtures__/object-variables/output.ts +0 -9
- package/__fixtures__/object-variables/vars.ts +0 -5
- package/__fixtures__/reset-styles/code.ts +0 -6
- package/__fixtures__/reset-styles/output.meta.json +0 -7
- package/__fixtures__/reset-styles/output.ts +0 -3
- package/__fixtures__/reset-styles-at-rules/code.ts +0 -7
- package/__fixtures__/reset-styles-at-rules/output.meta.json +0 -8
- package/__fixtures__/reset-styles-at-rules/output.ts +0 -3
- package/__fixtures__/rules-with-metadata/code.ts +0 -9
- package/__fixtures__/rules-with-metadata/output.meta.json +0 -14
- package/__fixtures__/rules-with-metadata/output.ts +0 -3
- package/__fixtures__/shared-mixins/code.ts +0 -7
- package/__fixtures__/shared-mixins/mixins.ts +0 -6
- package/__fixtures__/shared-mixins/output.meta.json +0 -7
- package/__fixtures__/shared-mixins/output.ts +0 -8
- package/__fixtures__/static-styles/code.ts +0 -7
- package/__fixtures__/static-styles/output.meta.json +0 -7
- package/__fixtures__/static-styles/output.ts +0 -3
- package/__fixtures__/static-styles-array/code.ts +0 -10
- package/__fixtures__/static-styles-array/output.meta.json +0 -7
- package/__fixtures__/static-styles-array/output.ts +0 -3
- package/__fixtures__/static-styles-string/code.ts +0 -3
- package/__fixtures__/static-styles-string/output.meta.json +0 -7
- package/__fixtures__/static-styles-string/output.ts +0 -3
- package/__fixtures__/tokens/code.ts +0 -11
- package/__fixtures__/tokens/output.meta.json +0 -12
- package/__fixtures__/tokens/output.ts +0 -7
- package/__fixtures__/tokens/tokens.ts +0 -4
- package/__fixtures__/unsupported-css-properties/fixture.ts +0 -16
- package/__fixtures__/unsupported-css-properties/output.meta.json +0 -5
- package/__fixtures__/unsupported-css-properties/output.ts +0 -3
- package/eslint.config.mjs +0 -31
- package/project.json +0 -51
- package/src/evaluation/astEvaluator.mts +0 -109
- package/src/evaluation/astEvaluator.test.mts +0 -126
- package/src/evaluation/batchEvaluator.mts +0 -79
- package/src/evaluation/evalCache.mts +0 -84
- package/src/evaluation/fluentTokensPlugin.mts +0 -82
- package/src/evaluation/fluentTokensPlugin.test.mts +0 -130
- package/src/evaluation/module.mts +0 -271
- package/src/evaluation/module.test.mts +0 -133
- package/src/evaluation/types.mts +0 -49
- package/src/evaluation/vmEvaluator.mts +0 -45
- package/src/evaluation/vmEvaluator.test.mts +0 -30
- package/src/transformSync.mts +0 -425
- package/src/transformSync.test.mts +0 -429
- package/src/types.mts +0 -13
- package/src/utils/convertESMtoCJS.mts +0 -226
- package/src/utils/convertESMtoCJS.test.mts +0 -159
- package/src/utils/dedupeCSSRules.mts +0 -25
- package/src/utils/dedupeCSSRules.test.mts +0 -39
- package/tsconfig.json +0 -19
- package/tsconfig.lib.json +0 -30
- package/tsconfig.spec.json +0 -24
- package/vitest.config.mts +0 -18
|
@@ -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,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,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,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
|
-
});
|
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
|
-
}
|