babel-plugin-vasille 0.99.3 → 0.99.5

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.
@@ -72,14 +72,17 @@ function processValue(name, path, pseudo, theme, media, mediaDefault, allowFallb
72
72
  }
73
73
  else if (allowFallback) {
74
74
  return [
75
- ...path.get("elements").map(path => {
75
+ ...path
76
+ .get("elements")
77
+ .map(path => {
76
78
  if (t.isExpression(path.node)) {
77
79
  return processValue(name, path, pseudo, theme, media, mediaDefault, false, internal);
78
80
  }
79
81
  else {
80
82
  throw path.buildCodeFrameError("Vasille: Exprected expression");
81
83
  }
82
- }).flat(1),
84
+ })
85
+ .flat(1),
83
86
  ];
84
87
  }
85
88
  else {
@@ -104,9 +107,12 @@ function processProp(path, pseudo, media, internal) {
104
107
  throw path.get("key").buildCodeFrameError("Vasille: Media queries allowed inly in the root of style");
105
108
  }
106
109
  if (t.isObjectExpression(path.node.value)) {
107
- return path.get("value").get("properties").map(item => {
110
+ return path.get("value")
111
+ .get("properties")
112
+ .map(item => {
108
113
  return tryProcessProp(item, "", name, internal);
109
- }).flat(1);
114
+ })
115
+ .flat(1);
110
116
  }
111
117
  else {
112
118
  throw path.get("value").buildCodeFrameError("Vasille: Exprected object expression");
@@ -117,9 +123,12 @@ function processProp(path, pseudo, media, internal) {
117
123
  throw path.get("key").buildCodeFrameError("Recursive pseudo classes are restriced");
118
124
  }
119
125
  if (t.isObjectExpression(path.node.value)) {
120
- return path.get("value").get("properties").map(item => {
126
+ return path.get("value")
127
+ .get("properties")
128
+ .map(item => {
121
129
  return tryProcessProp(item, name, media, internal);
122
- }).flat(1);
130
+ })
131
+ .flat(1);
123
132
  }
124
133
  else {
125
134
  throw path.get("value").buildCodeFrameError("Vasille: Exprected object expression");
@@ -188,10 +197,10 @@ export function findStyleInNode(path, internal) {
188
197
  for (const theme in sorted[defaultMediaRule][mediaRule]) {
189
198
  for (const pseudo in sorted[defaultMediaRule][mediaRule][theme]) {
190
199
  const rulePack = sorted[defaultMediaRule][mediaRule][theme][pseudo].join(";");
191
- const pseudoPack = pseudo ? `{}${pseudo}{${rulePack}}` : `{}{${rulePack}}`;
200
+ const pseudoPack = pseudo ? `.{}${pseudo}{${rulePack}}` : `.{}{${rulePack}}`;
192
201
  const themePack = theme ? `${theme} ${pseudoPack}` : pseudoPack;
193
202
  const mediaRulePack = t.stringLiteral(mediaRule ? `${mediaRule}{${themePack}}` : themePack);
194
- expressions.push(defaultMediaRule !== '0'
203
+ expressions.push(defaultMediaRule !== "0"
195
204
  ? t.arrayExpression([t.numericLiteral(parseInt(defaultMediaRule)), mediaRulePack])
196
205
  : mediaRulePack);
197
206
  }
@@ -109,9 +109,11 @@ export function trProgram(path, devMode) {
109
109
  if (stylesConnected) {
110
110
  findStyleInNode(statementPath, internal);
111
111
  }
112
- return;
112
+ else {
113
+ return;
114
+ }
113
115
  }
114
- if (!stylesConnected || !findStyleInNode(statementPath, internal)) {
116
+ else if (!stylesConnected || !findStyleInNode(statementPath, internal)) {
115
117
  meshStatement(statementPath, internal);
116
118
  }
117
119
  }
@@ -124,7 +126,6 @@ export function trProgram(path, devMode) {
124
126
  if (t.isImportSpecifier(item) && t.isIdentifier(item.local)) {
125
127
  return statementPath.scope.bindings[item.local.name].referenced;
126
128
  }
127
- return true;
128
129
  }),
129
130
  t.importSpecifier(internal.id, t.identifier("$")),
130
131
  ], statement.source));
@@ -98,14 +98,17 @@ function processValue(name, path, pseudo, theme, media, mediaDefault, allowFallb
98
98
  }
99
99
  else if (allowFallback) {
100
100
  return [
101
- ...path.get("elements").map(path => {
101
+ ...path
102
+ .get("elements")
103
+ .map(path => {
102
104
  if (t.isExpression(path.node)) {
103
105
  return processValue(name, path, pseudo, theme, media, mediaDefault, false, internal);
104
106
  }
105
107
  else {
106
108
  throw path.buildCodeFrameError("Vasille: Exprected expression");
107
109
  }
108
- }).flat(1),
110
+ })
111
+ .flat(1),
109
112
  ];
110
113
  }
111
114
  else {
@@ -130,9 +133,12 @@ function processProp(path, pseudo, media, internal) {
130
133
  throw path.get("key").buildCodeFrameError("Vasille: Media queries allowed inly in the root of style");
131
134
  }
132
135
  if (t.isObjectExpression(path.node.value)) {
133
- return path.get("value").get("properties").map(item => {
136
+ return path.get("value")
137
+ .get("properties")
138
+ .map(item => {
134
139
  return tryProcessProp(item, "", name, internal);
135
- }).flat(1);
140
+ })
141
+ .flat(1);
136
142
  }
137
143
  else {
138
144
  throw path.get("value").buildCodeFrameError("Vasille: Exprected object expression");
@@ -143,9 +149,12 @@ function processProp(path, pseudo, media, internal) {
143
149
  throw path.get("key").buildCodeFrameError("Recursive pseudo classes are restriced");
144
150
  }
145
151
  if (t.isObjectExpression(path.node.value)) {
146
- return path.get("value").get("properties").map(item => {
152
+ return path.get("value")
153
+ .get("properties")
154
+ .map(item => {
147
155
  return tryProcessProp(item, name, media, internal);
148
- }).flat(1);
156
+ })
157
+ .flat(1);
149
158
  }
150
159
  else {
151
160
  throw path.get("value").buildCodeFrameError("Vasille: Exprected object expression");
@@ -214,10 +223,10 @@ function findStyleInNode(path, internal) {
214
223
  for (const theme in sorted[defaultMediaRule][mediaRule]) {
215
224
  for (const pseudo in sorted[defaultMediaRule][mediaRule][theme]) {
216
225
  const rulePack = sorted[defaultMediaRule][mediaRule][theme][pseudo].join(";");
217
- const pseudoPack = pseudo ? `{}${pseudo}{${rulePack}}` : `{}{${rulePack}}`;
226
+ const pseudoPack = pseudo ? `.{}${pseudo}{${rulePack}}` : `.{}{${rulePack}}`;
218
227
  const themePack = theme ? `${theme} ${pseudoPack}` : pseudoPack;
219
228
  const mediaRulePack = t.stringLiteral(mediaRule ? `${mediaRule}{${themePack}}` : themePack);
220
- expressions.push(defaultMediaRule !== '0'
229
+ expressions.push(defaultMediaRule !== "0"
221
230
  ? t.arrayExpression([t.numericLiteral(parseInt(defaultMediaRule)), mediaRulePack])
222
231
  : mediaRulePack);
223
232
  }
@@ -135,9 +135,11 @@ function trProgram(path, devMode) {
135
135
  if (stylesConnected) {
136
136
  (0, css_transformer_1.findStyleInNode)(statementPath, internal);
137
137
  }
138
- return;
138
+ else {
139
+ return;
140
+ }
139
141
  }
140
- if (!stylesConnected || !(0, css_transformer_1.findStyleInNode)(statementPath, internal)) {
142
+ else if (!stylesConnected || !(0, css_transformer_1.findStyleInNode)(statementPath, internal)) {
141
143
  (0, mesh_1.meshStatement)(statementPath, internal);
142
144
  }
143
145
  }
@@ -150,7 +152,6 @@ function trProgram(path, devMode) {
150
152
  if (t.isImportSpecifier(item) && t.isIdentifier(item.local)) {
151
153
  return statementPath.scope.bindings[item.local.name].referenced;
152
154
  }
153
- return true;
154
155
  }),
155
156
  t.importSpecifier(internal.id, t.identifier("$")),
156
157
  ], statement.source));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-vasille",
3
- "version": "0.99.3",
3
+ "version": "0.99.5",
4
4
  "description": "Convert Vasille Meta Language code to pure JavaScript",
5
5
  "main": "lib-node/index.js",
6
6
  "type": "commonjs",