@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
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griffel/transform",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"description": "A package that performs build time transforms for Griffel",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"./package.json": "./package.json"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@griffel/core": "^1.21.
|
|
22
|
-
"@griffel/transform-shaker": "^1.0.
|
|
21
|
+
"@griffel/core": "^1.21.2",
|
|
22
|
+
"@griffel/transform-shaker": "^1.0.7",
|
|
23
23
|
"debug": "^4.3.0",
|
|
24
24
|
"magic-string": "^0.30.19",
|
|
25
25
|
"oxc-parser": "^0.132.0",
|
|
26
26
|
"oxc-walker": "^1.0.0"
|
|
27
|
-
}
|
|
28
|
-
|
|
27
|
+
},
|
|
28
|
+
"module": "./src/index.mts.js"
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../../packages/transform/src/constants.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Node, Program } from 'oxc-parser';
|
|
2
|
+
import type { EvaluationResult, AstEvaluatorPlugin } from './types.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Sentinel value returned by plugins and evaluateNode to signal "can't handle this node".
|
|
5
|
+
* Using a symbol avoids the cost of Error construction and stack trace capture.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEOPT: unique symbol;
|
|
8
|
+
export type Deopt = typeof DEOPT;
|
|
9
|
+
/**
|
|
10
|
+
* Simple static evaluator for object expressions with nested objects.
|
|
11
|
+
* Based on Babel's evaluation approach but simplified for our specific use case.
|
|
12
|
+
*
|
|
13
|
+
* Handles:
|
|
14
|
+
* - Objects with nested objects: { root: { color: 'red', padding: 0 } }
|
|
15
|
+
* - String literals, numeric literals, boolean literals, null
|
|
16
|
+
* - Simple property access
|
|
17
|
+
*
|
|
18
|
+
* Plugins can extend evaluation to handle additional node types.
|
|
19
|
+
*/
|
|
20
|
+
export declare function astEvaluator(node: Node, programAst: Program, plugins?: AstEvaluatorPlugin[]): EvaluationResult;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentinel value returned by plugins and evaluateNode to signal "can't handle this node".
|
|
3
|
+
* Using a symbol avoids the cost of Error construction and stack trace capture.
|
|
4
|
+
*/
|
|
5
|
+
export const DEOPT = Symbol('deopt');
|
|
6
|
+
/**
|
|
7
|
+
* Simple static evaluator for object expressions with nested objects.
|
|
8
|
+
* Based on Babel's evaluation approach but simplified for our specific use case.
|
|
9
|
+
*
|
|
10
|
+
* Handles:
|
|
11
|
+
* - Objects with nested objects: { root: { color: 'red', padding: 0 } }
|
|
12
|
+
* - String literals, numeric literals, boolean literals, null
|
|
13
|
+
* - Simple property access
|
|
14
|
+
*
|
|
15
|
+
* Plugins can extend evaluation to handle additional node types.
|
|
16
|
+
*/
|
|
17
|
+
export function astEvaluator(node, programAst, plugins = []) {
|
|
18
|
+
const context = {
|
|
19
|
+
programAst,
|
|
20
|
+
evaluateNode,
|
|
21
|
+
};
|
|
22
|
+
function evaluateNode(node) {
|
|
23
|
+
// Base cases
|
|
24
|
+
switch (node.type) {
|
|
25
|
+
case 'Literal':
|
|
26
|
+
return node.value;
|
|
27
|
+
case 'ObjectExpression':
|
|
28
|
+
return evaluateObjectExpression(node);
|
|
29
|
+
case 'TemplateLiteral':
|
|
30
|
+
if (node.expressions.length === 0) {
|
|
31
|
+
return node.quasis[0].value.cooked;
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
// Try plugins in order
|
|
36
|
+
// ---
|
|
37
|
+
for (const plugin of plugins) {
|
|
38
|
+
const result = plugin.evaluateNode(node, context);
|
|
39
|
+
if (result !== DEOPT) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return DEOPT;
|
|
44
|
+
}
|
|
45
|
+
function evaluateObjectExpression(node) {
|
|
46
|
+
const obj = {};
|
|
47
|
+
for (const prop of node.properties) {
|
|
48
|
+
if (prop.type !== 'Property' || prop.kind !== 'init') {
|
|
49
|
+
return DEOPT;
|
|
50
|
+
}
|
|
51
|
+
let key;
|
|
52
|
+
if (prop.computed) {
|
|
53
|
+
return DEOPT;
|
|
54
|
+
}
|
|
55
|
+
else if (prop.key.type === 'Identifier') {
|
|
56
|
+
key = prop.key.name;
|
|
57
|
+
}
|
|
58
|
+
else if (prop.key.type === 'Literal') {
|
|
59
|
+
const keyLiteral = prop.key;
|
|
60
|
+
if (typeof keyLiteral.value === 'string' || typeof keyLiteral.value === 'number') {
|
|
61
|
+
key = String(keyLiteral.value);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return DEOPT;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return DEOPT;
|
|
69
|
+
}
|
|
70
|
+
const value = evaluateNode(prop.value);
|
|
71
|
+
if (value === DEOPT) {
|
|
72
|
+
return DEOPT;
|
|
73
|
+
}
|
|
74
|
+
obj[key] = value;
|
|
75
|
+
}
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
const result = evaluateNode(node);
|
|
79
|
+
if (result === DEOPT) {
|
|
80
|
+
return {
|
|
81
|
+
confident: false,
|
|
82
|
+
value: undefined,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
confident: true,
|
|
87
|
+
value: result,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=astEvaluator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astEvaluator.mjs","sourceRoot":"","sources":["../../../../../packages/transform/src/evaluation/astEvaluator.mts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAkB,MAAM,CAAC,OAAO,CAAC,CAAC;AAGpD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,UAAmB,EAAE,UAAgC,EAAE;IAC9F,MAAM,OAAO,GAAwB;QACnC,UAAU;QACV,YAAY;KACb,CAAC;IAEF,SAAS,YAAY,CAAC,IAAU;QAC9B,aAAa;QACb,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,KAAK,CA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UAAU,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;oBACjF,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBACjC,CAAC;qBAAM,CAAC;oBACN,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEvC,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;gBACpB,OAAO,KAAK,CAAC;YACf,CAAC;YAED,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnB,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QACrB,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,SAAS;SACjB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,MAAM;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Program } from 'oxc-parser';
|
|
2
|
+
import type { StyleCall } from '../types.mjs';
|
|
3
|
+
import type { TransformResolver } from './module.mjs';
|
|
4
|
+
import type { AstEvaluatorPlugin, EvalRule } from './types.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* Batch evaluates all style calls in a file for better performance.
|
|
7
|
+
* Uses static evaluation first, then falls back to VM evaluation for complex expressions.
|
|
8
|
+
* Optimizes VM evaluation by sharing module loading and parsing overhead.
|
|
9
|
+
*/
|
|
10
|
+
export declare function batchEvaluator(sourceCode: string, filename: string, styleCalls: StyleCall[], evaluationRules: EvalRule[], resolveFilename: TransformResolver, programAst: Program, astEvaluationPlugins?: AstEvaluatorPlugin[]): {
|
|
11
|
+
usedVMForEvaluation: boolean;
|
|
12
|
+
evaluationResults: unknown[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { astEvaluator } from './astEvaluator.mjs';
|
|
2
|
+
import { vmEvaluator } from './vmEvaluator.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Batch evaluates all style calls in a file for better performance.
|
|
5
|
+
* Uses static evaluation first, then falls back to VM evaluation for complex expressions.
|
|
6
|
+
* Optimizes VM evaluation by sharing module loading and parsing overhead.
|
|
7
|
+
*/
|
|
8
|
+
export function batchEvaluator(sourceCode, filename, styleCalls, evaluationRules, resolveFilename, programAst, astEvaluationPlugins = []) {
|
|
9
|
+
const evaluationResults = new Array(styleCalls.length);
|
|
10
|
+
// Track which indices need VM evaluation and build the expression code string
|
|
11
|
+
const vmIndices = [];
|
|
12
|
+
let expressionCode = '';
|
|
13
|
+
// First pass: try static evaluation for all calls
|
|
14
|
+
for (let i = 0; i < styleCalls.length; i++) {
|
|
15
|
+
const styleCall = styleCalls[i];
|
|
16
|
+
const staticResult = astEvaluator(styleCall.argumentNode, programAst, astEvaluationPlugins);
|
|
17
|
+
if (staticResult.confident) {
|
|
18
|
+
evaluationResults[i] = staticResult.value;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
// Mark for VM evaluation
|
|
22
|
+
if (expressionCode.length > 0) {
|
|
23
|
+
expressionCode += ',';
|
|
24
|
+
}
|
|
25
|
+
expressionCode += styleCall.argumentCode;
|
|
26
|
+
vmIndices.push(i);
|
|
27
|
+
}
|
|
28
|
+
if (vmIndices.length === 0) {
|
|
29
|
+
return {
|
|
30
|
+
usedVMForEvaluation: false,
|
|
31
|
+
evaluationResults,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// Second pass: batch VM evaluation for complex expressions
|
|
35
|
+
const vmResult = vmEvaluator(sourceCode, filename, expressionCode, evaluationRules, resolveFilename);
|
|
36
|
+
if (!vmResult.confident) {
|
|
37
|
+
if (vmResult.error) {
|
|
38
|
+
throw vmResult.error;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new Error('Evaluation of a code fragment failed, this is a bug, please report it');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Map VM results back to correct indices
|
|
45
|
+
const vmValues = vmResult.value;
|
|
46
|
+
for (let i = 0; i < vmIndices.length; i++) {
|
|
47
|
+
evaluationResults[vmIndices[i]] = vmValues[i];
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
usedVMForEvaluation: true,
|
|
51
|
+
evaluationResults,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=batchEvaluator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batchEvaluator.mjs","sourceRoot":"","sources":["../../../../../packages/transform/src/evaluation/batchEvaluator.mts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAkB,EAClB,QAAgB,EAChB,UAAuB,EACvB,eAA2B,EAC3B,eAAkC,EAClC,UAAmB,EACnB,uBAA6C,EAAE;IAK/C,MAAM,iBAAiB,GAAc,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAElE,8EAA8E;IAC9E,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,IAAI,cAAc,GAAG,EAAE,CAAC;IAExB,kDAAkD;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,YAAY,GAAG,YAAY,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC;QAE5F,IAAI,YAAY,CAAC,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aria/babel-preset v3.0.0-beta.19, adapted to use `debug` package.
|
|
4
|
+
*/
|
|
5
|
+
export declare const clear: () => void;
|
|
6
|
+
export declare const clearForFile: (filename: string) => void;
|
|
7
|
+
export declare const has: ([filename, ...exports]: string[], text: string) => boolean;
|
|
8
|
+
export declare const get: ([filename, ...exports]: string[], text: string) => unknown;
|
|
9
|
+
export declare const set: ([filename, ...exports]: string[], text: string, value: unknown) => void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluation cache for module results.
|
|
3
|
+
* Copied from @linaria/babel-preset v3.0.0-beta.19, adapted to use `debug` package.
|
|
4
|
+
*/
|
|
5
|
+
import { createHash } from 'node:crypto';
|
|
6
|
+
import createDebug from 'debug';
|
|
7
|
+
const debug = createDebug('griffel:eval-cache');
|
|
8
|
+
const fileHashes = new Map();
|
|
9
|
+
const evalCache = new Map();
|
|
10
|
+
const fileKeys = new Map();
|
|
11
|
+
const hash = (text) => createHash('sha1').update(text).digest('base64');
|
|
12
|
+
let lastText = '';
|
|
13
|
+
let lastHash = hash(lastText);
|
|
14
|
+
const memoizedHash = (text) => {
|
|
15
|
+
if (lastText !== text) {
|
|
16
|
+
lastHash = hash(text);
|
|
17
|
+
lastText = text;
|
|
18
|
+
}
|
|
19
|
+
return lastHash;
|
|
20
|
+
};
|
|
21
|
+
const toKey = (filename, exports) => exports.length > 0 ? `${filename}:${exports.join(',')}` : filename;
|
|
22
|
+
export const clear = () => {
|
|
23
|
+
fileHashes.clear();
|
|
24
|
+
evalCache.clear();
|
|
25
|
+
fileKeys.clear();
|
|
26
|
+
};
|
|
27
|
+
export const clearForFile = (filename) => {
|
|
28
|
+
const keys = fileKeys.get(filename) ?? [];
|
|
29
|
+
if (keys.length === 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
debug('clear-for-file', filename);
|
|
33
|
+
keys.forEach(key => {
|
|
34
|
+
fileHashes.delete(key);
|
|
35
|
+
evalCache.delete(key);
|
|
36
|
+
});
|
|
37
|
+
fileKeys.set(filename, []);
|
|
38
|
+
};
|
|
39
|
+
export const has = ([filename, ...exports], text) => {
|
|
40
|
+
const key = toKey(filename, exports);
|
|
41
|
+
const textHash = memoizedHash(text);
|
|
42
|
+
debug('has', `${key} ${textHash}`);
|
|
43
|
+
return fileHashes.get(key) === textHash;
|
|
44
|
+
};
|
|
45
|
+
export const get = ([filename, ...exports], text) => {
|
|
46
|
+
const key = toKey(filename, exports);
|
|
47
|
+
const textHash = memoizedHash(text);
|
|
48
|
+
debug('get', `${key} ${textHash}`);
|
|
49
|
+
if (fileHashes.get(key) !== textHash) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return evalCache.get(key);
|
|
53
|
+
};
|
|
54
|
+
export const set = ([filename, ...exports], text, value) => {
|
|
55
|
+
const key = toKey(filename, exports);
|
|
56
|
+
const textHash = memoizedHash(text);
|
|
57
|
+
debug('set', `${key} ${textHash}`);
|
|
58
|
+
fileHashes.set(key, textHash);
|
|
59
|
+
evalCache.set(key, value);
|
|
60
|
+
if (!fileKeys.has(filename)) {
|
|
61
|
+
fileKeys.set(filename, []);
|
|
62
|
+
}
|
|
63
|
+
fileKeys.get(filename).push(key);
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=evalCache.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evalCache.mjs","sourceRoot":"","sources":["../../../../../packages/transform/src/evaluation/evalCache.mts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,MAAM,KAAK,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAEhD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC7C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;AAC7C,MAAM,QAAQ,GAAG,IAAI,GAAG,EA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GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACpC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,QAAQ,EAAE,CAAC,CAAC;IACnC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9B,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAE1B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { DEOPT } from './astEvaluator.mjs';
|
|
2
|
+
// zIndex tokens are not part of the theme and include default fallback values.
|
|
3
|
+
// See: https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/zIndexes.ts
|
|
4
|
+
const Z_INDEX_DEFAULTS = {
|
|
5
|
+
zIndexBackground: 0,
|
|
6
|
+
zIndexContent: 1,
|
|
7
|
+
zIndexOverlay: 1000,
|
|
8
|
+
zIndexPopup: 2000,
|
|
9
|
+
zIndexMessages: 3000,
|
|
10
|
+
zIndexFloating: 4000,
|
|
11
|
+
zIndexPriority: 5000,
|
|
12
|
+
zIndexDebug: 6000,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Evaluates template literals that contain Fluent UI design tokens.
|
|
16
|
+
* Transforms `${tokens.propertyName}` expressions into CSS custom properties: `var(--propertyName)`
|
|
17
|
+
*/
|
|
18
|
+
function evaluateTemplateLiteralWithTokens(node) {
|
|
19
|
+
let result = '';
|
|
20
|
+
for (let i = 0; i < node.quasis.length; i++) {
|
|
21
|
+
result += node.quasis[i].value.cooked;
|
|
22
|
+
if (i < node.expressions.length) {
|
|
23
|
+
const expression = node.expressions[i];
|
|
24
|
+
if (expression.type === 'MemberExpression' &&
|
|
25
|
+
expression.object.type === 'Identifier' &&
|
|
26
|
+
expression.object.name === 'tokens' &&
|
|
27
|
+
expression.property.type === 'Identifier' &&
|
|
28
|
+
!expression.computed) {
|
|
29
|
+
const name = expression.property.name;
|
|
30
|
+
const fallback = Z_INDEX_DEFAULTS[name];
|
|
31
|
+
result += fallback !== undefined ? `var(--${name}, ${fallback})` : `var(--${name})`;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return DEOPT;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Evaluates member expressions that reference Fluent UI design tokens.
|
|
42
|
+
* Transforms `tokens.propertyName` expressions into CSS custom properties: `var(--propertyName)`
|
|
43
|
+
*/
|
|
44
|
+
function evaluateTokensMemberExpression(node) {
|
|
45
|
+
if (node.object.type === 'Identifier' &&
|
|
46
|
+
node.object.name === 'tokens' &&
|
|
47
|
+
node.property.type === 'Identifier' &&
|
|
48
|
+
!node.computed) {
|
|
49
|
+
const name = node.property.name;
|
|
50
|
+
const fallback = Z_INDEX_DEFAULTS[name];
|
|
51
|
+
return fallback !== undefined ? `var(--${name}, ${fallback})` : `var(--${name})`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return DEOPT;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export const fluentTokensPlugin = {
|
|
58
|
+
name: 'fluentTokensPlugin',
|
|
59
|
+
evaluateNode(node) {
|
|
60
|
+
switch (node.type) {
|
|
61
|
+
case 'TemplateLiteral':
|
|
62
|
+
return evaluateTemplateLiteralWithTokens(node);
|
|
63
|
+
case 'MemberExpression':
|
|
64
|
+
return evaluateTokensMemberExpression(node);
|
|
65
|
+
default:
|
|
66
|
+
return DEOPT;
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=fluentTokensPlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluentTokensPlugin.mjs","sourceRoot":"","sources":["../../../../../packages/transform/src/evaluation/fluentTokensPlugin.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAc,MAAM,oBAAoB,CAAC;AAGvD,+EAA+E;AAC/E,gGAAgG;AAChG,MAAM,gBAAgB,GAA2B;IAC/C,gBAAgB,EAAE,CAAC;IACnB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,IAAI;CAClB,CAAC;AAEF;;;GAGG;AACH,SAAS,iCAAiC,CAAC,IAAqB;IAC9D,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;QAEtC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAEvC,IACE,UAAU,CAAC,IAAI,KAAK,kBAAkB;gBACtC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;gBACvC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;gBACnC,UAAU,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;gBACzC,CAAC,UAAU,CAAC,QAAQ,EACpB,CAAC;gBACD,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACtC,MAAM,QAAQ,GAAG,gBAAgB,C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context.
|
|
3
|
+
* Copied from @linaria/babel-preset v3.0.0-beta.19, adapted to use `debug` package
|
|
4
|
+
* and local imports instead of @linaria/* packages.
|
|
5
|
+
*
|
|
6
|
+
* This serves 2 purposes:
|
|
7
|
+
* - Avoid leakage from evaluated code to module cache in current context, e.g. `babel-register`
|
|
8
|
+
* - Allow us to invalidate the module cache without affecting other stuff, necessary for rebuilds
|
|
9
|
+
*
|
|
10
|
+
* We also use it to transpile the code with Babel by default.
|
|
11
|
+
* We also store source maps for it to provide correct error stacktraces.
|
|
12
|
+
*/
|
|
13
|
+
import type { EvalRule } from './types.mjs';
|
|
14
|
+
export type TransformResolver = (id: string, options: {
|
|
15
|
+
filename: string;
|
|
16
|
+
paths: readonly string[];
|
|
17
|
+
}) => {
|
|
18
|
+
path: string;
|
|
19
|
+
builtin: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare class Module {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly filename: string;
|
|
24
|
+
readonly paths: readonly string[];
|
|
25
|
+
rules: EvalRule[];
|
|
26
|
+
imports: Map<string, string[]> | null;
|
|
27
|
+
dependencies: string[] | null;
|
|
28
|
+
transform: ((code: string, filename: string) => string) | null;
|
|
29
|
+
static readonly extensions: Set<string>;
|
|
30
|
+
exports: unknown;
|
|
31
|
+
private readonly resolveFilename;
|
|
32
|
+
private debug;
|
|
33
|
+
private debuggerDepth;
|
|
34
|
+
constructor(filename: string, rules: EvalRule[], resolveFilename: TransformResolver, debuggerDepth?: number);
|
|
35
|
+
require: ((id: string) => unknown) & {
|
|
36
|
+
ensure: () => void;
|
|
37
|
+
cache: Record<string, Module>;
|
|
38
|
+
resolve: (id: string) => string;
|
|
39
|
+
};
|
|
40
|
+
evaluate(text: string, only?: string[] | null, useEvalCache?: boolean): void;
|
|
41
|
+
static invalidate: () => void;
|
|
42
|
+
static invalidateEvalCache: () => void;
|
|
43
|
+
static _nodeModulePaths: (filename: string) => string[];
|
|
44
|
+
}
|