rollup-plugin-react-scoped-css 0.6.0 → 0.7.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.
@@ -1,72 +0,0 @@
1
- import { JsxParser } from "./jsx-parser.model";
2
-
3
- export class ClassicJsxParser implements JsxParser {
4
- isNodeReactFragment(node: any) {
5
- return (
6
- node?.arguments?.[0]?.object?.name === "React" &&
7
- node?.arguments?.[0]?.property?.name === "Fragment"
8
- );
9
- }
10
- isNodeReactElement(node: any) {
11
- return (
12
- node?.type === "CallExpression" &&
13
- node?.callee?.object?.name === "React" &&
14
- node?.callee?.property?.name === "createElement"
15
- );
16
- }
17
-
18
- public extendNodeWithAttributes(node: any, attr: string) {
19
- const arg = node?.arguments?.[1];
20
- return {
21
- ...node,
22
- arguments: node?.arguments.map((v: any, i: number) => {
23
- if (i === 1) {
24
- if (v.type === "ObjectExpression") {
25
- return {
26
- ...v,
27
- properties: [...arg.properties, this.createAttributeNode(attr)],
28
- };
29
- } else if (
30
- v.type === "CallExpression" &&
31
- v.callee.name === "_objectSpread"
32
- ) {
33
- const args = [...v.arguments];
34
- args[0].properties = [
35
- ...args[0].properties,
36
- this.createAttributeNode(attr),
37
- ];
38
- return {
39
- ...v,
40
- arguments: args,
41
- };
42
- } else {
43
- return {
44
- type: "ObjectExpression",
45
- properties: [this.createAttributeNode(attr)],
46
- };
47
- }
48
- }
49
- return v;
50
- }),
51
- };
52
- }
53
-
54
- private createAttributeNode(attr: string) {
55
- return {
56
- type: "Property",
57
- method: false,
58
- shorthand: false,
59
- computed: false,
60
- key: {
61
- type: "Identifier",
62
- name: `"${attr}"`,
63
- },
64
- value: {
65
- type: "Literal",
66
- value: true,
67
- raw: "true",
68
- },
69
- kind: "init",
70
- };
71
- }
72
- }
@@ -1,10 +0,0 @@
1
- export interface JsxParser {
2
- isNodeReactElement: (node: any) => boolean;
3
- isNodeReactFragment: (node: any) => boolean;
4
- extendNodeWithAttributes: (node: any, attr: string) => any;
5
- }
6
-
7
- export enum ParserImplementations {
8
- new = "new",
9
- classic = "classic",
10
- }
@@ -1,74 +0,0 @@
1
- import { JsxParser } from "./jsx-parser.model";
2
-
3
- export class NewJsxParser implements JsxParser {
4
- isNodeReactFragment(node: any) {
5
- return (
6
- node.arguments?.[0]?.type === "Identifier" &&
7
- ["_Fragment", "Fragment"].includes(node.arguments?.[0]?.name)
8
- );
9
- }
10
-
11
- isNodeReactElement(node: any) {
12
- return (
13
- node?.type === "CallExpression" &&
14
- ["_jsxDEV", "_jsx", "_jsxs", "jsxDev", "jsx", "jsxs"].includes(
15
- node?.callee?.name
16
- )
17
- );
18
- }
19
-
20
- public extendNodeWithAttributes(node: any, attr: string) {
21
- const arg = node?.arguments?.[1];
22
- return {
23
- ...node,
24
- arguments: node?.arguments.map((v: any, i: number) => {
25
- if (i === 1) {
26
- if (v.type === "ObjectExpression") {
27
- return {
28
- ...v,
29
- properties: [...arg.properties, this.createAttributeNode(attr)],
30
- };
31
- } else if (
32
- v.type === "CallExpression" &&
33
- v.callee.name === "_objectSpread"
34
- ) {
35
- const args = [...v.arguments];
36
- args[0].properties = [
37
- ...args[0].properties,
38
- this.createAttributeNode(attr),
39
- ];
40
- return {
41
- ...v,
42
- arguments: args,
43
- };
44
- } else {
45
- return {
46
- type: "ObjectExpression",
47
- properties: [this.createAttributeNode(attr)],
48
- };
49
- }
50
- }
51
- return v;
52
- }),
53
- };
54
- }
55
-
56
- private createAttributeNode(attr: string) {
57
- return {
58
- type: "Property",
59
- method: false,
60
- shorthand: false,
61
- computed: false,
62
- key: {
63
- type: "Identifier",
64
- name: `"${attr}"`,
65
- },
66
- value: {
67
- type: "Literal",
68
- value: true,
69
- raw: "true",
70
- },
71
- kind: "init",
72
- };
73
- }
74
- }