@griffel/postcss-syntax 1.3.10 → 1.3.11
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/.babelrc +3 -0
- package/CHANGELOG.json +618 -0
- package/CHANGELOG.md +263 -0
- package/eslint.config.mjs +18 -0
- package/package.json +5 -7
- package/project.json +51 -0
- package/src/constants.ts +5 -0
- package/src/createSyntax.ts +19 -0
- package/src/{index.d.ts → index.ts} +6 -6
- package/src/location-preset.ts +206 -0
- package/src/parse.test.ts +501 -0
- package/src/parse.ts +155 -0
- package/src/stringify.ts +12 -0
- package/src/transform-sync.test.ts +300 -0
- package/src/transform-sync.ts +36 -0
- package/tsconfig.json +16 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.spec.json +20 -0
- package/vitest.config.mts +18 -0
- package/LICENSE.md +0 -21
- package/src/constants.d.ts +0 -5
- package/src/constants.js +0 -9
- package/src/constants.js.map +0 -1
- package/src/createSyntax.d.ts +0 -8
- package/src/createSyntax.js +0 -18
- package/src/createSyntax.js.map +0 -1
- package/src/index.js +0 -17
- package/src/index.js.map +0 -1
- package/src/location-preset.d.ts +0 -28
- package/src/location-preset.js +0 -149
- package/src/location-preset.js.map +0 -1
- package/src/parse.d.ts +0 -17
- package/src/parse.js +0 -112
- package/src/parse.js.map +0 -1
- package/src/stringify.d.ts +0 -2
- package/src/stringify.js +0 -14
- package/src/stringify.js.map +0 -1
- package/src/transform-sync.d.ts +0 -13
- package/src/transform-sync.js +0 -30
- package/src/transform-sync.js.map +0 -1
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import transformSync, { type TransformOptions } from './transform-sync';
|
|
4
|
+
|
|
5
|
+
describe('transformSync', () => {
|
|
6
|
+
it('should parse TS and return metadata that contains css location', () => {
|
|
7
|
+
const sourceCode = `
|
|
8
|
+
import type { GriffelStyle } from '@griffel/react'
|
|
9
|
+
import { makeStyles } from '@griffel/react';
|
|
10
|
+
|
|
11
|
+
const mixin = (): GriffelStyle => ({
|
|
12
|
+
marginTop: '4px',
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const useStyles = makeStyles({
|
|
16
|
+
root: {
|
|
17
|
+
color: 'red',
|
|
18
|
+
backgroundColor: 'green',
|
|
19
|
+
...mixin()
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
`;
|
|
23
|
+
const options: TransformOptions = {
|
|
24
|
+
filename: 'test.styles.ts',
|
|
25
|
+
pluginOptions: {
|
|
26
|
+
babelOptions: {
|
|
27
|
+
presets: ['@babel/preset-typescript'],
|
|
28
|
+
},
|
|
29
|
+
generateMetadata: true,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const result = transformSync(sourceCode, options);
|
|
34
|
+
|
|
35
|
+
expect(result.metadata.cssEntries).toMatchInlineSnapshot(`
|
|
36
|
+
{
|
|
37
|
+
"useStyles": {
|
|
38
|
+
"root": [
|
|
39
|
+
".fe3e8s9{color:red;}",
|
|
40
|
+
".fcnqdeg{background-color:green;}",
|
|
41
|
+
".fvjh0tl{margin-top:4px;}",
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
`);
|
|
46
|
+
expect(result.metadata.locations).toMatchInlineSnapshot(`
|
|
47
|
+
{
|
|
48
|
+
"useStyles": {
|
|
49
|
+
"root": {
|
|
50
|
+
"end": Position {
|
|
51
|
+
"column": 7,
|
|
52
|
+
"index": 317,
|
|
53
|
+
"line": 14,
|
|
54
|
+
},
|
|
55
|
+
"filename": undefined,
|
|
56
|
+
"identifierName": undefined,
|
|
57
|
+
"start": Position {
|
|
58
|
+
"column": 6,
|
|
59
|
+
"index": 227,
|
|
60
|
+
"line": 10,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
`);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should parse TS and return comment directives prefixed with griffel-', () => {
|
|
69
|
+
const sourceCode = `
|
|
70
|
+
import type { GriffelStyle } from '@griffel/react'
|
|
71
|
+
import { makeStyles, makeResetStyles } from '@griffel/react';
|
|
72
|
+
|
|
73
|
+
export const useStyles = makeStyles({
|
|
74
|
+
// griffel-csslint-disable foo
|
|
75
|
+
// griffel-csslint-disable bar
|
|
76
|
+
root: {
|
|
77
|
+
color: 'red',
|
|
78
|
+
backgroundColor: 'green',
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
// griffel-csslint-disable foo
|
|
82
|
+
foo: {
|
|
83
|
+
color: 'blue'
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
// griffel-csslint-disable foo
|
|
88
|
+
export const useResetStyles = makeResetStyles({
|
|
89
|
+
color: 'red',
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// griffel-csslint-disable foo
|
|
93
|
+
// griffel-csslint-disable bar
|
|
94
|
+
const useResetStylesExportedLater = makeResetStyles({
|
|
95
|
+
color: 'red',
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
export { useResetStylesExportedLater };
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
const options: TransformOptions = {
|
|
102
|
+
filename: 'test.styles.ts',
|
|
103
|
+
pluginOptions: {
|
|
104
|
+
babelOptions: {
|
|
105
|
+
presets: ['@babel/preset-typescript'],
|
|
106
|
+
},
|
|
107
|
+
generateMetadata: true,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const result = transformSync(sourceCode, options);
|
|
112
|
+
|
|
113
|
+
expect(result.metadata.commentDirectives).toMatchInlineSnapshot(`
|
|
114
|
+
{
|
|
115
|
+
"useStyles": {
|
|
116
|
+
"foo": [
|
|
117
|
+
[
|
|
118
|
+
"griffel-csslint-disable",
|
|
119
|
+
"foo",
|
|
120
|
+
],
|
|
121
|
+
],
|
|
122
|
+
"root": [
|
|
123
|
+
[
|
|
124
|
+
"griffel-csslint-disable",
|
|
125
|
+
"foo",
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
"griffel-csslint-disable",
|
|
129
|
+
"bar",
|
|
130
|
+
],
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
`);
|
|
135
|
+
|
|
136
|
+
expect(result.metadata.resetCommentDirectives).toMatchInlineSnapshot(`
|
|
137
|
+
{
|
|
138
|
+
"useResetStyles": [
|
|
139
|
+
[
|
|
140
|
+
"griffel-csslint-disable",
|
|
141
|
+
"foo",
|
|
142
|
+
],
|
|
143
|
+
],
|
|
144
|
+
"useResetStylesExportedLater": [
|
|
145
|
+
[
|
|
146
|
+
"griffel-csslint-disable",
|
|
147
|
+
"foo",
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
"griffel-csslint-disable",
|
|
151
|
+
"bar",
|
|
152
|
+
],
|
|
153
|
+
],
|
|
154
|
+
}
|
|
155
|
+
`);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should return location of makeStyles call expression', () => {
|
|
159
|
+
const sourceCode = `
|
|
160
|
+
import type { GriffelStyle } from "@griffel/react";
|
|
161
|
+
import { makeStyles } from "@griffel/react";
|
|
162
|
+
|
|
163
|
+
const mixin = (): GriffelStyle => ({
|
|
164
|
+
marginTop: "4px",
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const styles = {
|
|
168
|
+
root: {
|
|
169
|
+
color: "red",
|
|
170
|
+
backgroundColor: "green",
|
|
171
|
+
...mixin(),
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const useStyles1 = makeStyles(styles);
|
|
176
|
+
export const useStyles2 = makeStyles(styles);
|
|
177
|
+
`;
|
|
178
|
+
const options: TransformOptions = {
|
|
179
|
+
filename: 'test.styles.ts',
|
|
180
|
+
pluginOptions: {
|
|
181
|
+
babelOptions: {
|
|
182
|
+
presets: ['@babel/preset-typescript'],
|
|
183
|
+
},
|
|
184
|
+
generateMetadata: true,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const result = transformSync(sourceCode, options);
|
|
189
|
+
|
|
190
|
+
expect(result.metadata.cssEntries).toMatchInlineSnapshot(`
|
|
191
|
+
{
|
|
192
|
+
"useStyles1": {
|
|
193
|
+
"root": [
|
|
194
|
+
".fe3e8s9{color:red;}",
|
|
195
|
+
".fcnqdeg{background-color:green;}",
|
|
196
|
+
".fvjh0tl{margin-top:4px;}",
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
"useStyles2": {
|
|
200
|
+
"root": [
|
|
201
|
+
".fe3e8s9{color:red;}",
|
|
202
|
+
".fcnqdeg{background-color:green;}",
|
|
203
|
+
".fvjh0tl{margin-top:4px;}",
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
`);
|
|
208
|
+
expect(result.metadata.callExpressionLocations).toEqual({
|
|
209
|
+
useStyles1: {
|
|
210
|
+
end: {
|
|
211
|
+
column: 50,
|
|
212
|
+
index: 383,
|
|
213
|
+
line: 17,
|
|
214
|
+
},
|
|
215
|
+
start: {
|
|
216
|
+
column: 32,
|
|
217
|
+
index: 365,
|
|
218
|
+
line: 17,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
useStyles2: {
|
|
222
|
+
end: {
|
|
223
|
+
column: 50,
|
|
224
|
+
index: 435,
|
|
225
|
+
line: 18,
|
|
226
|
+
},
|
|
227
|
+
start: {
|
|
228
|
+
column: 32,
|
|
229
|
+
index: 417,
|
|
230
|
+
line: 18,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('should return location of makeResetStyles call expression', () => {
|
|
237
|
+
const sourceCode = `
|
|
238
|
+
import type { GriffelStyle } from "@griffel/react";
|
|
239
|
+
import { makeResetStyles } from "@griffel/react";
|
|
240
|
+
const mixin = (): GriffelStyle => ({
|
|
241
|
+
marginTop: "4px",
|
|
242
|
+
});
|
|
243
|
+
const styles = {
|
|
244
|
+
color: "red",
|
|
245
|
+
backgroundColor: "green",
|
|
246
|
+
...mixin(),
|
|
247
|
+
};
|
|
248
|
+
export const useResetStyles1 = makeResetStyles(styles);
|
|
249
|
+
export const useResetStyles2 = makeResetStyles(styles);
|
|
250
|
+
`;
|
|
251
|
+
const options: TransformOptions = {
|
|
252
|
+
filename: 'test.styles.ts',
|
|
253
|
+
pluginOptions: {
|
|
254
|
+
babelOptions: {
|
|
255
|
+
presets: ['@babel/preset-typescript'],
|
|
256
|
+
},
|
|
257
|
+
generateMetadata: true,
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const result = transformSync(sourceCode, options);
|
|
262
|
+
|
|
263
|
+
expect(result.metadata.cssResetEntries).toMatchInlineSnapshot(`
|
|
264
|
+
{
|
|
265
|
+
"useResetStyles1": [
|
|
266
|
+
".rv6h41g{color:red;background-color:green;margin-top:4px;}",
|
|
267
|
+
],
|
|
268
|
+
"useResetStyles2": [
|
|
269
|
+
".rv6h41g{color:red;background-color:green;margin-top:4px;}",
|
|
270
|
+
],
|
|
271
|
+
}
|
|
272
|
+
`);
|
|
273
|
+
expect(result.metadata.callExpressionLocations).toEqual({
|
|
274
|
+
useResetStyles1: {
|
|
275
|
+
end: {
|
|
276
|
+
column: 60,
|
|
277
|
+
index: 362,
|
|
278
|
+
line: 12,
|
|
279
|
+
},
|
|
280
|
+
start: {
|
|
281
|
+
column: 37,
|
|
282
|
+
index: 339,
|
|
283
|
+
line: 12,
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
useResetStyles2: {
|
|
287
|
+
end: {
|
|
288
|
+
column: 60,
|
|
289
|
+
index: 424,
|
|
290
|
+
line: 13,
|
|
291
|
+
},
|
|
292
|
+
start: {
|
|
293
|
+
column: 37,
|
|
294
|
+
index: 401,
|
|
295
|
+
line: 13,
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Babel from '@babel/core';
|
|
2
|
+
import type { BabelPluginMetadata, BabelPluginOptions } from '@griffel/babel-preset';
|
|
3
|
+
import griffelPreset from '@griffel/babel-preset';
|
|
4
|
+
import type { LocationPluginMetadata } from './location-preset';
|
|
5
|
+
import locationPreset from './location-preset';
|
|
6
|
+
|
|
7
|
+
export type TransformOptions = {
|
|
8
|
+
filename: string;
|
|
9
|
+
pluginOptions: BabelPluginOptions;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Transforms passed source code with Babel, uses user's config for parsing, but ignores it for transforms.
|
|
14
|
+
*/
|
|
15
|
+
export default function transformSync(sourceCode: string, options: TransformOptions) {
|
|
16
|
+
const { plugins, presets } = options.pluginOptions.babelOptions ?? { plugins: [], presets: [] };
|
|
17
|
+
const babelFileResult = Babel.transformSync(sourceCode, {
|
|
18
|
+
// Ignore all user's configs and apply only our plugin
|
|
19
|
+
babelrc: false,
|
|
20
|
+
configFile: false,
|
|
21
|
+
plugins,
|
|
22
|
+
presets: [...(presets ?? []), [griffelPreset, options.pluginOptions], [locationPreset, options.pluginOptions]],
|
|
23
|
+
|
|
24
|
+
filename: options.filename,
|
|
25
|
+
sourceFileName: options.filename,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (babelFileResult === null) {
|
|
29
|
+
throw new Error(`Failed to transform "${options.filename}" due unknown Babel error...`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
metadata: babelFileResult.metadata as unknown as BabelPluginMetadata & LocationPluginMetadata,
|
|
34
|
+
code: babelFileResult.code,
|
|
35
|
+
};
|
|
36
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"outDir": "../../dist/out-tsc",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"types": ["node", "environment"]
|
|
8
|
+
},
|
|
9
|
+
"exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"],
|
|
10
|
+
"include": ["**/*.ts"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"typeRoots": ["../../node_modules", "../../node_modules/@types", "../../typings"],
|
|
6
|
+
"types": ["vitest/importMeta", "vite/client", "node", "vitest", "environment"]
|
|
7
|
+
},
|
|
8
|
+
"include": [
|
|
9
|
+
"vitest.config.mts",
|
|
10
|
+
"**/*.test.ts",
|
|
11
|
+
"**/*.spec.ts",
|
|
12
|
+
"**/*.test.tsx",
|
|
13
|
+
"**/*.spec.tsx",
|
|
14
|
+
"**/*.test.js",
|
|
15
|
+
"**/*.spec.js",
|
|
16
|
+
"**/*.test.jsx",
|
|
17
|
+
"**/*.spec.jsx",
|
|
18
|
+
"**/*.d.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
root: __dirname,
|
|
6
|
+
cacheDir: '../../node_modules/.vite/packages/postcss-syntax',
|
|
7
|
+
plugins: [nxViteTsPaths()],
|
|
8
|
+
test: {
|
|
9
|
+
watch: false,
|
|
10
|
+
environment: 'node',
|
|
11
|
+
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
12
|
+
reporters: ['default'],
|
|
13
|
+
coverage: {
|
|
14
|
+
reportsDirectory: '../../coverage/packages/postcss-syntax',
|
|
15
|
+
provider: 'v8',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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/src/constants.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const GRIFFEL_SLOT_RAW = "griffel-slot";
|
|
2
|
-
export declare const GRIFFEL_SRC_RAW = "griffel-src";
|
|
3
|
-
export declare const GRIFFEL_DECLARATOR_RAW = "griffel-declarator";
|
|
4
|
-
export declare const GRIFFEL_SLOT_LOCATION_RAW = "griffel-slot-location";
|
|
5
|
-
export declare const GRIFFEL_DECLARATOR_LOCATION_RAW = "griffel-declarator-location";
|
package/src/constants.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GRIFFEL_DECLARATOR_LOCATION_RAW = exports.GRIFFEL_SLOT_LOCATION_RAW = exports.GRIFFEL_DECLARATOR_RAW = exports.GRIFFEL_SRC_RAW = exports.GRIFFEL_SLOT_RAW = void 0;
|
|
4
|
-
exports.GRIFFEL_SLOT_RAW = 'griffel-slot';
|
|
5
|
-
exports.GRIFFEL_SRC_RAW = 'griffel-src';
|
|
6
|
-
exports.GRIFFEL_DECLARATOR_RAW = 'griffel-declarator';
|
|
7
|
-
exports.GRIFFEL_SLOT_LOCATION_RAW = 'griffel-slot-location';
|
|
8
|
-
exports.GRIFFEL_DECLARATOR_LOCATION_RAW = 'griffel-declarator-location';
|
|
9
|
-
//# sourceMappingURL=constants.js.map
|
package/src/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../packages/postcss-syntax/src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,cAAc,CAAC;AAClC,QAAA,eAAe,GAAG,aAAa,CAAC;AAChC,QAAA,sBAAsB,GAAG,oBAAoB,CAAC;AAC9C,QAAA,yBAAyB,GAAG,uBAAuB,CAAC;AACpD,QAAA,+BAA+B,GAAG,6BAA6B,CAAC"}
|
package/src/createSyntax.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BabelPluginOptions } from '@griffel/babel-preset';
|
|
2
|
-
import type * as postcss from 'postcss';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a custom syntax with configured options for @griffel/babel-preset
|
|
5
|
-
* @param options - Options to configure @griffel/babel-preset
|
|
6
|
-
* @returns a postcss custom syntax
|
|
7
|
-
*/
|
|
8
|
-
export declare function createSyntax(options: BabelPluginOptions): postcss.Syntax;
|
package/src/createSyntax.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSyntax = createSyntax;
|
|
4
|
-
const parse_1 = require("./parse");
|
|
5
|
-
const stringify_1 = require("./stringify");
|
|
6
|
-
/**
|
|
7
|
-
* Creates a custom syntax with configured options for @griffel/babel-preset
|
|
8
|
-
* @param options - Options to configure @griffel/babel-preset
|
|
9
|
-
* @returns a postcss custom syntax
|
|
10
|
-
*/
|
|
11
|
-
function createSyntax(options) {
|
|
12
|
-
const extendedParse = (css, opts) => (0, parse_1.parse)(css, { ...opts, ...options });
|
|
13
|
-
return {
|
|
14
|
-
stringify: stringify_1.stringify,
|
|
15
|
-
parse: extendedParse,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=createSyntax.js.map
|
package/src/createSyntax.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSyntax.js","sourceRoot":"","sources":["../../../../packages/postcss-syntax/src/createSyntax.ts"],"names":[],"mappings":";;AAWA,oCAOC;AAfD,mCAAgC;AAChC,2CAAwC;AAExC;;;;GAIG;AACH,SAAgB,YAAY,CAAC,OAA2B;IACtD,MAAM,aAAa,GAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAA,aAAK,EAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAEzF,OAAO;QACL,SAAS,EAAT,qBAAS;QACT,KAAK,EAAE,aAAa;KACrB,CAAC;AACJ,CAAC"}
|
package/src/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GRIFFEL_SLOT_LOCATION_RAW = exports.GRIFFEL_DECLARATOR_LOCATION_RAW = exports.createSyntax = exports.stringify = exports.parse = void 0;
|
|
4
|
-
const parse_1 = require("./parse");
|
|
5
|
-
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });
|
|
6
|
-
const stringify_1 = require("./stringify");
|
|
7
|
-
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return stringify_1.stringify; } });
|
|
8
|
-
var createSyntax_1 = require("./createSyntax");
|
|
9
|
-
Object.defineProperty(exports, "createSyntax", { enumerable: true, get: function () { return createSyntax_1.createSyntax; } });
|
|
10
|
-
exports.default = {
|
|
11
|
-
parse: parse_1.parse,
|
|
12
|
-
stringify: stringify_1.stringify,
|
|
13
|
-
};
|
|
14
|
-
var constants_1 = require("./constants");
|
|
15
|
-
Object.defineProperty(exports, "GRIFFEL_DECLARATOR_LOCATION_RAW", { enumerable: true, get: function () { return constants_1.GRIFFEL_DECLARATOR_LOCATION_RAW; } });
|
|
16
|
-
Object.defineProperty(exports, "GRIFFEL_SLOT_LOCATION_RAW", { enumerable: true, get: function () { return constants_1.GRIFFEL_SLOT_LOCATION_RAW; } });
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/postcss-syntax/src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAGvB,sFAHA,aAAK,OAGA;AAFd,2CAAwC;AAExB,0FAFP,qBAAS,OAEO;AACzB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAErB,kBAAe;IACb,KAAK,EAAL,aAAK;IACL,SAAS,EAAT,qBAAS;CACV,CAAC;AAEF,yCAAyF;AAAhF,4HAAA,+BAA+B,OAAA;AAAE,sHAAA,yBAAyB,OAAA"}
|
package/src/location-preset.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { PluginObj, PluginPass, types as t, ConfigAPI } from '@babel/core';
|
|
2
|
-
import type { BabelPluginOptions } from '@griffel/babel-preset';
|
|
3
|
-
export type CommentDirective = [ /** directive *//** directive */ string, /** value */ string];
|
|
4
|
-
export type CommentDirectivesBySlot = Record</** slot */ string, CommentDirective[]>;
|
|
5
|
-
export type CommentDirectivesByHookDeclarator = Record</** hook declarator */ string, CommentDirectivesBySlot>;
|
|
6
|
-
export type LocationsBySlot = Record</** slot */ string, t.SourceLocation>;
|
|
7
|
-
export type LocationsByHookDeclarator = Record</** hook declarator */ string, LocationsBySlot>;
|
|
8
|
-
export type ResetCommentDirectivesByHookDeclarator = Record</** hook declarator */ string, CommentDirective[]>;
|
|
9
|
-
export type ResetLocationsByHookDeclarator = Record</** hook declarator */ string, t.SourceLocation>;
|
|
10
|
-
export interface LocationPluginState extends PluginPass {
|
|
11
|
-
callExpressionLocations?: Record</** hook declarator */ string, t.SourceLocation>;
|
|
12
|
-
locations?: LocationsByHookDeclarator;
|
|
13
|
-
commentDirectives?: CommentDirectivesByHookDeclarator;
|
|
14
|
-
resetCommentDirectives?: ResetCommentDirectivesByHookDeclarator;
|
|
15
|
-
resetLocations?: ResetLocationsByHookDeclarator;
|
|
16
|
-
}
|
|
17
|
-
export interface LocationPluginMetadata {
|
|
18
|
-
callExpressionLocations: Record</** hook declarator */ string, t.SourceLocation>;
|
|
19
|
-
locations: LocationsByHookDeclarator;
|
|
20
|
-
commentDirectives: CommentDirectivesByHookDeclarator;
|
|
21
|
-
resetCommentDirectives: ResetCommentDirectivesByHookDeclarator;
|
|
22
|
-
resetLocations: ResetLocationsByHookDeclarator;
|
|
23
|
-
}
|
|
24
|
-
export type LocationPluginOptions = Pick<BabelPluginOptions, 'modules'>;
|
|
25
|
-
declare const _default: (babel: ConfigAPI, options: LocationPluginOptions) => {
|
|
26
|
-
plugins: (LocationPluginOptions | ((api: object, options: LocationPluginOptions | null | undefined, dirname: string) => PluginObj<LocationPluginState>))[][];
|
|
27
|
-
};
|
|
28
|
-
export default _default;
|