@griffel/postcss-syntax 1.0.8 → 1.1.0
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/package.json +1 -1
- package/src/constants.d.ts +2 -0
- package/src/constants.js +3 -1
- package/src/constants.js.map +1 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +4 -1
- package/src/index.js.map +1 -1
- package/src/location-preset.js +0 -3
- package/src/location-preset.js.map +1 -1
- package/src/parse.d.ts +5 -1
- package/src/parse.js +31 -80
- package/src/parse.js.map +1 -1
package/package.json
CHANGED
package/src/constants.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const GRIFFEL_SLOT_RAW = "griffel-slot";
|
|
2
2
|
export declare const GRIFFEL_SRC_RAW = "griffel-src";
|
|
3
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
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GRIFFEL_DECLARATOR_RAW = exports.GRIFFEL_SRC_RAW = exports.GRIFFEL_SLOT_RAW = void 0;
|
|
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
4
|
exports.GRIFFEL_SLOT_RAW = 'griffel-slot';
|
|
5
5
|
exports.GRIFFEL_SRC_RAW = 'griffel-src';
|
|
6
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';
|
|
7
9
|
//# sourceMappingURL=constants.js.map
|
package/src/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export { createSyntax } from './createSyntax';
|
|
|
5
5
|
declare const _default: {
|
|
6
6
|
parse: (css: string | {
|
|
7
7
|
toString(): string;
|
|
8
|
-
}, opts?: import("./parse").ParserOptions | undefined) => import("postcss/lib/
|
|
8
|
+
}, opts?: import("./parse").ParserOptions | undefined) => import("postcss/lib/root").default;
|
|
9
9
|
stringify: import("postcss").Stringifier;
|
|
10
10
|
};
|
|
11
11
|
export default _default;
|
|
12
|
+
export { GRIFFEL_DECLARATOR_LOCATION_RAW, GRIFFEL_SLOT_LOCATION_RAW } from './constants';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSyntax = exports.stringify = exports.parse = void 0;
|
|
3
|
+
exports.GRIFFEL_SLOT_LOCATION_RAW = exports.GRIFFEL_DECLARATOR_LOCATION_RAW = exports.createSyntax = exports.stringify = exports.parse = void 0;
|
|
4
4
|
const parse_1 = require("./parse");
|
|
5
5
|
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });
|
|
6
6
|
const stringify_1 = require("./stringify");
|
|
@@ -11,4 +11,7 @@ exports.default = {
|
|
|
11
11
|
parse: parse_1.parse,
|
|
12
12
|
stringify: stringify_1.stringify,
|
|
13
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; } });
|
|
14
17
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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.js
CHANGED
|
@@ -72,9 +72,6 @@ const plugin = (0, helper_plugin_utils_1.declare)((api, options) => {
|
|
|
72
72
|
state.locations[declaratorId][key.node.name] = {
|
|
73
73
|
...property.node.loc,
|
|
74
74
|
};
|
|
75
|
-
state.locations[declaratorId][key.node.name] = {
|
|
76
|
-
...property.node.loc,
|
|
77
|
-
};
|
|
78
75
|
});
|
|
79
76
|
}
|
|
80
77
|
if (resetFunctionKinds.includes(callee.node.name)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location-preset.js","sourceRoot":"","sources":["../../../../packages/postcss-syntax/src/location-preset.ts"],"names":[],"mappings":";;AACA,oEAAqD;AAgBrD;;GAEG;AACH,MAAM,MAAM,GAAG,IAAA,6BAAO,EAAwD,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;IAC7F,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAErB,MAAM,EACJ,OAAO,GAAG;QACR,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE;QAChG,EAAE,YAAY,EAAE,4BAA4B,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE;KAC7G,GACF,GAAG,OAAO,CAAC;IAEZ,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;;QAC9C,OAAO,MAAA,WAAW,CAAC,UAAU,mCAAI,YAAY,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;;QACnD,OAAO,MAAA,WAAW,CAAC,eAAe,mCAAI,iBAAiB,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,+BAA+B;QAErC,GAAG;YACD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,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,OAAO;qBACR;oBAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE;wBACzB,OAAO;qBACR;oBAED,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;iBAC3D;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kBAAe,CAAC,KAAgB,EAAE,OAA8B,EAAE,EAAE;IAClE,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC7B,CAAC;AACJ,CAAC,CAAC"}
|
package/src/parse.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import type { BabelPluginOptions } from '@griffel/babel-preset';
|
|
|
3
3
|
export type PostCSSParserOptions = Pick<postcss.ProcessOptions<postcss.Document | postcss.Root>, 'from' | 'map'>;
|
|
4
4
|
export interface ParserOptions extends PostCSSParserOptions, BabelPluginOptions {
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Generates CSS rules from a JavaScript file. Each slot in `makeStyles` and each `makeResetStyles` will be one line in the output.
|
|
8
|
+
* It returns a PostCSS AST that parses the generated CSS rules. For each node in AST, attaches information about its related slot location from the original js file.
|
|
9
|
+
*/
|
|
6
10
|
export declare const parse: (css: string | {
|
|
7
11
|
toString(): string;
|
|
8
|
-
}, opts?: ParserOptions) => postcss.
|
|
12
|
+
}, opts?: ParserOptions) => postcss.Root;
|
package/src/parse.js
CHANGED
|
@@ -4,6 +4,10 @@ exports.parse = void 0;
|
|
|
4
4
|
const postcss = require("postcss");
|
|
5
5
|
const transform_sync_1 = require("./transform-sync");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
|
+
/**
|
|
8
|
+
* Generates CSS rules from a JavaScript file. Each slot in `makeStyles` and each `makeResetStyles` will be one line in the output.
|
|
9
|
+
* It returns a PostCSS AST that parses the generated CSS rules. For each node in AST, attaches information about its related slot location from the original js file.
|
|
10
|
+
*/
|
|
7
11
|
const parse = (css, opts) => {
|
|
8
12
|
const { from: filename = 'postcss-syntax.styles.ts' } = opts !== null && opts !== void 0 ? opts : {};
|
|
9
13
|
const griffelPluginOptions = extractGrifellBabelPluginOptions(opts);
|
|
@@ -16,88 +20,35 @@ const parse = (css, opts) => {
|
|
|
16
20
|
},
|
|
17
21
|
});
|
|
18
22
|
const { cssEntries, cssResetEntries, resetLocations, locations } = metadata;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const location = locations[declarator][slot];
|
|
26
|
-
const nodes = rules.map(rule => {
|
|
27
|
-
const root = postcss.parse(rule);
|
|
28
|
-
root.walk(node => {
|
|
29
|
-
node.raws[constants_1.GRIFFEL_SLOT_RAW] = slot;
|
|
30
|
-
node.raws[constants_1.GRIFFEL_DECLARATOR_RAW] = declarator;
|
|
31
|
-
if (!node.source) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
// There's currently no way to to map generated CSS to original JS code
|
|
35
|
-
// Mapping each node to the original slot is probably the best we can do for now
|
|
36
|
-
node.source.end = {
|
|
37
|
-
offset: 0,
|
|
38
|
-
column: location.end.column,
|
|
39
|
-
line: location.end.line,
|
|
40
|
-
};
|
|
41
|
-
node.source.start = {
|
|
42
|
-
offset: 0,
|
|
43
|
-
column: location.start.column,
|
|
44
|
-
line: location.start.line,
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
return root.nodes[0];
|
|
48
|
-
});
|
|
49
|
-
return [...arr, ...nodes];
|
|
50
|
-
}, []);
|
|
51
|
-
})
|
|
52
|
-
.flat();
|
|
53
|
-
const cssResetRuleNodes = Object.entries(cssResetEntries).map(([declarator, [resetRule]]) => {
|
|
54
|
-
if (!resetLocations[declarator]) {
|
|
55
|
-
throw new Error(`No code location for ${declarator} - please report a bug`);
|
|
56
|
-
}
|
|
57
|
-
const location = resetLocations[declarator];
|
|
58
|
-
const root = postcss.parse(resetRule);
|
|
59
|
-
root.walk(node => {
|
|
60
|
-
node.raws[constants_1.GRIFFEL_DECLARATOR_RAW] = declarator;
|
|
61
|
-
if (!node.source) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
// There's currently no way to to map generated CSS to original JS code through Griffel AOT
|
|
65
|
-
// Mapping each node to the original slot is probably the best we can do for now
|
|
66
|
-
node.source.end = {
|
|
67
|
-
offset: 0,
|
|
68
|
-
column: location.end.column,
|
|
69
|
-
line: location.end.line,
|
|
70
|
-
};
|
|
71
|
-
node.source.start = {
|
|
72
|
-
offset: 0,
|
|
73
|
-
column: location.start.column,
|
|
74
|
-
line: location.start.line,
|
|
75
|
-
};
|
|
23
|
+
const cssRuleSlotNames = [];
|
|
24
|
+
const cssRules = [];
|
|
25
|
+
Object.entries(cssEntries).map(([declarator, slots]) => {
|
|
26
|
+
Object.entries(slots).map(([slot, rules]) => {
|
|
27
|
+
cssRuleSlotNames.push(`${declarator} ${slot}`);
|
|
28
|
+
cssRules.push(rules.join(''));
|
|
76
29
|
});
|
|
77
|
-
return root.nodes[0];
|
|
78
30
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return doc;
|
|
31
|
+
Object.entries(cssResetEntries).map(([declarator, resetRules]) => {
|
|
32
|
+
cssRuleSlotNames.push(`${declarator}`);
|
|
33
|
+
cssRules.push(resetRules.join(''));
|
|
34
|
+
});
|
|
35
|
+
const root = postcss.parse(cssRules.join('\n'));
|
|
36
|
+
root.walk(node => {
|
|
37
|
+
if (!node.source || node.source.start === undefined) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const [declarator, slot] = cssRuleSlotNames[node.source.start.line - 1].split(' ');
|
|
41
|
+
node.raws[constants_1.GRIFFEL_DECLARATOR_RAW] = declarator;
|
|
42
|
+
if (slot) {
|
|
43
|
+
node.raws[constants_1.GRIFFEL_SLOT_RAW] = slot;
|
|
44
|
+
node.raws[constants_1.GRIFFEL_SLOT_LOCATION_RAW] = locations[declarator][slot];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
node.raws[constants_1.GRIFFEL_DECLARATOR_LOCATION_RAW] = resetLocations[declarator];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
root.raws[constants_1.GRIFFEL_SRC_RAW] = css;
|
|
51
|
+
return root;
|
|
101
52
|
};
|
|
102
53
|
exports.parse = parse;
|
|
103
54
|
const extractGrifellBabelPluginOptions = (opts = {}) => {
|
package/src/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../packages/postcss-syntax/src/parse.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,qDAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../packages/postcss-syntax/src/parse.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,qDAA6C;AAC7C,2CAMqB;AAOrB;;;GAGG;AACI,MAAM,KAAK,GAAG,CAAC,GAAoC,EAAE,IAAoB,EAAE,EAAE;IAClF,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,0BAA0B,EAAE,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC;IACnE,MAAM,oBAAoB,GAAG,gCAAgC,CAAC,IAAI,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC5B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,wBAAa,EAAC,IAAI,EAAE;QACvC,QAAQ;QACR,aAAa,EAAE;YACb,GAA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