babel-plugin-vasille 3.2.1 → 4.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.
@@ -1,100 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.exprHasJsx = exprHasJsx;
37
- exports.statementHasJsx = statementHasJsx;
38
- exports.bodyHasJsx = bodyHasJsx;
39
- const t = __importStar(require("@babel/types"));
40
- function exprHasJsx(node) {
41
- if (t.isBinaryExpression(node)) {
42
- return (t.isExpression(node.left) && exprHasJsx(node.left)) || exprHasJsx(node.right);
43
- }
44
- if (t.isConditionalExpression(node)) {
45
- return exprHasJsx(node.consequent) || exprHasJsx(node.alternate);
46
- }
47
- if (t.isLogicalExpression(node)) {
48
- return exprHasJsx(node.left) || exprHasJsx(node.right);
49
- }
50
- return t.isJSXElement(node) || t.isJSXFragment(node);
51
- }
52
- function statementHasJsx(statement) {
53
- if (t.isExpressionStatement(statement)) {
54
- return exprHasJsx(statement.expression);
55
- }
56
- if (t.isBlockStatement(statement)) {
57
- return bodyHasJsx(statement);
58
- }
59
- if (t.isDoWhileStatement(statement)) {
60
- return statementHasJsx(statement.body);
61
- }
62
- if (t.isForInStatement(statement)) {
63
- return statementHasJsx(statement.body);
64
- }
65
- if (t.isSwitchStatement(statement)) {
66
- return statement.cases.some(_case => {
67
- return _case.consequent.some(statementHasJsx);
68
- });
69
- }
70
- if (t.isWhileStatement(statement)) {
71
- return statementHasJsx(statement.body);
72
- }
73
- if (t.isForOfStatement(statement)) {
74
- return statementHasJsx(statement.body);
75
- }
76
- if (t.isLabeledStatement(statement)) {
77
- return statementHasJsx(statement.body);
78
- }
79
- if (t.isReturnStatement(statement)) {
80
- return !!statement.argument && exprHasJsx(statement.argument);
81
- }
82
- if (t.isTryStatement(statement)) {
83
- return (statementHasJsx(statement.block) ||
84
- (!!statement.handler && statementHasJsx(statement.handler.body)) ||
85
- (!!statement.finalizer && statementHasJsx(statement.finalizer)));
86
- }
87
- if (t.isIfStatement(statement)) {
88
- return statementHasJsx(statement.consequent) || (!!statement.alternate && statementHasJsx(statement.alternate));
89
- }
90
- if (t.isForStatement(statement)) {
91
- return statementHasJsx(statement.body);
92
- }
93
- return false;
94
- }
95
- function bodyHasJsx(node) {
96
- if (t.isExpression(node)) {
97
- return exprHasJsx(node);
98
- }
99
- return node.body.some(statementHasJsx);
100
- }
package/lib-node/jsx.js DELETED
@@ -1,453 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.transformJsx = transformJsx;
37
- exports.transformJsxArray = transformJsxArray;
38
- const t = __importStar(require("@babel/types"));
39
- const internal_js_1 = require("./internal.js");
40
- const lib_js_1 = require("./lib.js");
41
- const mesh_js_1 = require("./mesh.js");
42
- const jsx_detect_js_1 = require("./jsx-detect.js");
43
- function transformJsx(path, internal) {
44
- if (t.isJSXElement(path.node)) {
45
- return [transformJsxElement(path, internal)];
46
- }
47
- return transformJsxArray(path.get("children"), internal);
48
- }
49
- function transformJsxArray(paths, internal) {
50
- const result = [];
51
- for (const path of paths) {
52
- if (t.isJSXElement(path.node) || t.isJSXFragment(path.node)) {
53
- result.push(...transformJsx(path, internal));
54
- }
55
- else if (t.isJSXText(path.node)) {
56
- if (!/^\s+$/.test(path.node.value)) {
57
- const fixed = path.node.value
58
- .replace(/\n\s+$/m, "")
59
- .replace(/^\s*\n\s+/m, "")
60
- .replace(/\s*\n\s*/gm, "\n");
61
- const call = t.callExpression(t.memberExpression(internal_js_1.ctx, t.identifier("text")), [t.stringLiteral(fixed)]);
62
- call.loc = path.node.loc;
63
- /* istanbul ignore else */
64
- if (call.loc) {
65
- for (const char of path.node.value) {
66
- if (!/\s/.test(char)) {
67
- break;
68
- }
69
- if (char === "\n") {
70
- call.loc.start.column = 0;
71
- call.loc.start.line++;
72
- }
73
- else {
74
- call.loc.start.column++;
75
- }
76
- call.loc.start.index++;
77
- }
78
- }
79
- result.push(t.expressionStatement(call));
80
- }
81
- }
82
- else if (t.isJSXExpressionContainer(path.node)) {
83
- const value = transformJsxExpressionContainer(path, internal, false, false);
84
- const call = t.callExpression(t.memberExpression(internal_js_1.ctx, t.identifier("text")), [value]);
85
- call.loc = value.loc;
86
- result.push(t.expressionStatement(call));
87
- }
88
- else {
89
- throw path.buildCodeFrameError("Vasille: Spread child is not supported");
90
- }
91
- }
92
- return result;
93
- }
94
- function transformJsxExpressionContainer(path, internal, acceptSlots, isInternalSlot) {
95
- const expression = path.node.expression;
96
- const loc = expression.loc;
97
- if (acceptSlots &&
98
- (t.isFunctionExpression(expression) || t.isArrowFunctionExpression(expression)) &&
99
- (0, jsx_detect_js_1.bodyHasJsx)(expression.body)) {
100
- (0, mesh_js_1.compose)(path.get("expression"), internal, isInternalSlot, "slot");
101
- if (!isInternalSlot) {
102
- if (expression.params.length < 1) {
103
- expression.params.push(t.identifier(`_${internal.prefix}`));
104
- }
105
- expression.params.push(internal_js_1.ctx);
106
- }
107
- else {
108
- expression.params.unshift(internal_js_1.ctx);
109
- }
110
- expression.loc = loc;
111
- return expression;
112
- }
113
- else if (isInternalSlot && (t.isFunctionExpression(expression) || t.isArrowFunctionExpression(expression))) {
114
- expression.params.unshift(internal_js_1.ctx);
115
- }
116
- const exprPath = path.get("expression");
117
- let call = (0, lib_js_1.exprCall)(exprPath, expression, internal);
118
- if (!call && t.isIdentifier(expression) && internal.stack.get(expression.name) === 3 /* VariableState.ReactiveObject */) {
119
- call = t.callExpression(t.memberExpression(internal.id, t.identifier("rop")), [expression]);
120
- }
121
- const result = call !== null && call !== void 0 ? call : exprPath.node;
122
- result.loc = loc;
123
- return result;
124
- }
125
- function idToProp(id, value, from) {
126
- let str = t.isIdentifier(id) || t.isJSXIdentifier(id) ? id.name : id.value;
127
- let expr;
128
- if (from) {
129
- str = str.substring(from);
130
- }
131
- if (/^[\w_]+$/.test(str)) {
132
- expr = t.identifier(str);
133
- }
134
- else {
135
- expr = t.stringLiteral(str);
136
- }
137
- expr.loc = id.loc;
138
- return t.objectProperty(expr, value);
139
- }
140
- function transformJsxElement(path, internal) {
141
- var _a, _b, _c, _d, _e, _f, _g;
142
- const name = path.node.openingElement.name;
143
- if (t.isJSXIdentifier(name) && name.name[0].toLowerCase() === name.name[0]) {
144
- const opening = path.get("openingElement");
145
- const attrs = [];
146
- const events = [];
147
- const bind = [];
148
- const classElements = [];
149
- const classObject = [];
150
- const classStatic = [];
151
- const styleObject = [];
152
- const styleStatic = [];
153
- for (const attrPath of opening.get("attributes")) {
154
- const attr = attrPath.node;
155
- if (t.isJSXAttribute(attr)) {
156
- const name = attr.name;
157
- /* istanbul ignore else */
158
- if (t.isJSXIdentifier(name)) {
159
- if (name.name.startsWith("on")) {
160
- if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {
161
- const path = attrPath.get("value");
162
- /* istanbul ignore else */
163
- if (t.isExpression(path.node.expression)) {
164
- (0, mesh_js_1.meshExpression)(path.get("expression"), internal);
165
- }
166
- events.push(idToProp(name, path.node.expression, 2));
167
- }
168
- else {
169
- throw attrPath
170
- .get("value")
171
- .buildCodeFrameError("Vasille: Expected event handler.");
172
- }
173
- }
174
- else if (name.name === "class") {
175
- // class={[..]}
176
- /* istanbul ignore else */
177
- if (t.isJSXExpressionContainer(attr.value) && t.isArrayExpression(attr.value.expression)) {
178
- const valuePath = attrPath.get("value");
179
- const arrayExprPath = valuePath.get("expression");
180
- for (const elementPath of arrayExprPath.get("elements")) {
181
- const item = elementPath.node;
182
- if (t.isExpression(item)) {
183
- // class={[cond && "string"]}
184
- if (t.isLogicalExpression(item) && item.operator === "&&" && t.isStringLiteral(item.right)) {
185
- const call = (0, lib_js_1.exprCall)(elementPath.get("left"), item.left, internal);
186
- classObject.push(idToProp(item.right, call !== null && call !== void 0 ? call : item.left));
187
- }
188
- // class={[{..}]}
189
- else if (t.isObjectExpression(item)) {
190
- for (const propPath of elementPath.get("properties")) {
191
- // class={[{a: b}]}
192
- if (t.isObjectProperty(propPath.node)) {
193
- const prop = propPath;
194
- const value = (_a = (0, lib_js_1.exprCall)(prop.get("value"), prop.node.value, internal)) !== null && _a !== void 0 ? _a : prop.node.value;
195
- if (t.isExpression(prop.node.key) && !t.isIdentifier(prop.node.key)) {
196
- (0, mesh_js_1.meshExpression)(prop.get("key"), internal);
197
- }
198
- classObject.push(t.objectProperty(prop.node.key, value));
199
- }
200
- // class={[{...a}]}
201
- else if (t.isSpreadElement(propPath.node)) {
202
- classObject.push(propPath.node);
203
- }
204
- // class={[{a(){}}]}
205
- else {
206
- throw propPath.buildCodeFrameError("Vasille: Methods are not allowed here");
207
- }
208
- }
209
- }
210
- // class={[".."]}
211
- else if (t.isStringLiteral(elementPath.node)) {
212
- classStatic.push(elementPath.node);
213
- }
214
- // class={[..]}
215
- else {
216
- const call = (0, lib_js_1.exprCall)(elementPath, item, internal);
217
- classElements.push(call !== null && call !== void 0 ? call : item);
218
- }
219
- }
220
- // class={[...array]}
221
- else {
222
- classElements.push(elementPath.node);
223
- }
224
- }
225
- }
226
- // class={"a b"}
227
- else if (t.isJSXExpressionContainer(attr.value) && t.isStringLiteral(attr.value.expression)) {
228
- attrs.push(t.objectProperty(t.identifier("class"), attr.value.expression));
229
- }
230
- // class={`a ${b}`}
231
- else if (t.isJSXExpressionContainer(attr.value) && t.isTemplateLiteral(attr.value.expression)) {
232
- const jsxAttrPath = attrPath;
233
- const jsxContainerPath = jsxAttrPath.get("value");
234
- const value = (0, lib_js_1.exprCall)(jsxContainerPath.get("expression"), attr.value.expression, internal);
235
- attrs.push(t.objectProperty(t.identifier("class"), value !== null && value !== void 0 ? value : attr.value.expression));
236
- if (value) {
237
- console.warn(attrPath.buildCodeFrameError("Vasille: This will slow down your application"));
238
- }
239
- }
240
- // class={name}
241
- else if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {
242
- const expr = (_b = (0, lib_js_1.exprCall)(attrPath.get("value"), attr.value.expression, internal)) !== null && _b !== void 0 ? _b : attr.value.expression;
243
- attrs.push(t.objectProperty(t.identifier("class"), expr));
244
- }
245
- // class="a b"
246
- else if (t.isStringLiteral(attr.value)) {
247
- classStatic.push(attr.value);
248
- }
249
- }
250
- else if (name.name === "style") {
251
- // style={{..}}
252
- /* istanbul ignore else */
253
- if (t.isJSXExpressionContainer(attr.value) && t.isObjectExpression(attr.value.expression)) {
254
- const valuePath = attrPath.get("value");
255
- const objectPath = valuePath.get("expression");
256
- for (const propPath of objectPath.get("properties")) {
257
- // style={{a: b}}
258
- if (t.isObjectProperty(propPath.node)) {
259
- const prop = propPath;
260
- const value = (_c = (0, lib_js_1.exprCall)(prop.get("value"), prop.node.value, internal)) !== null && _c !== void 0 ? _c : prop.node.value;
261
- if (t.isExpression(prop.node.key) && !t.isIdentifier(prop.node.key)) {
262
- (0, mesh_js_1.meshExpression)(prop.get("key"), internal);
263
- }
264
- // style={{a: "b"}} -> static in compile time
265
- if (t.isIdentifier(prop.node.key) && t.isStringLiteral(prop.node.value)) {
266
- styleStatic.push([prop.node.key, prop.node.value]);
267
- }
268
- // style={{a: 23}} -> static in compile time
269
- else if (t.isIdentifier(prop.node.key) && t.isNumericLiteral(prop.node.value)) {
270
- styleStatic.push([prop.node.key, t.stringLiteral(`${prop.node.value.value}px`)]);
271
- }
272
- // style={{a: [1, 2, 3]}} -> static in compile time
273
- else if (t.isIdentifier(prop.node.key) &&
274
- t.isArrayExpression(prop.node.value) &&
275
- prop.node.value.elements.every(item => t.isNumericLiteral(item))) {
276
- styleStatic.push([
277
- prop.node.key,
278
- t.stringLiteral(prop.node.value.elements
279
- .map(item => {
280
- return `${item.value}px`;
281
- })
282
- .join(" ")),
283
- ]);
284
- }
285
- // need processing in run time
286
- else {
287
- styleObject.push(t.objectProperty(prop.node.key, value));
288
- }
289
- }
290
- // style={{...a}}
291
- else if (t.isSpreadElement(propPath.node)) {
292
- styleObject.push(propPath.node);
293
- }
294
- // style={{a(){}}}
295
- else {
296
- throw propPath.buildCodeFrameError("Vasille: Methods are not allowed here");
297
- }
298
- }
299
- }
300
- // style=".."
301
- else if (t.isStringLiteral(attr.value)) {
302
- attrs.push(t.objectProperty(t.identifier("style"), attr.value));
303
- }
304
- // style={".."}
305
- else if (t.isJSXExpressionContainer(attr.value) && t.isStringLiteral(attr.value.expression)) {
306
- attrs.push(t.objectProperty(t.identifier("style"), attr.value.expression));
307
- }
308
- // style={`a: ${b}px`}
309
- else if (t.isJSXExpressionContainer(attr.value) && t.isTemplateLiteral(attr.value.expression)) {
310
- const jsxAttrPath = attrPath;
311
- const jsxContainerPath = jsxAttrPath.get("value");
312
- const literalPath = jsxContainerPath.get("expression");
313
- const value = (0, lib_js_1.exprCall)(literalPath, attr.value.expression, internal);
314
- attrs.push(t.objectProperty(t.identifier("style"), value !== null && value !== void 0 ? value : attr.value.expression));
315
- if (value) {
316
- console.warn(attrPath.buildCodeFrameError("Vasille: This will slow down your application"));
317
- }
318
- }
319
- else if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {
320
- const expr = (_d = (0, lib_js_1.exprCall)(attrPath.get("value"), attr.value.expression, internal)) !== null && _d !== void 0 ? _d : attr.value.expression;
321
- attrs.push(t.objectProperty(t.identifier("style"), expr));
322
- }
323
- }
324
- else {
325
- /* istanbul ignore else */
326
- if (!attr.value || t.isJSXExpressionContainer(attr.value)) {
327
- attrs.push(idToProp(name, t.isExpression((_e = attr.value) === null || _e === void 0 ? void 0 : _e.expression) ? attr.value.expression : t.booleanLiteral(true)));
328
- }
329
- else if (t.isStringLiteral(attr.value)) {
330
- attrs.push(idToProp(name, attr.value));
331
- }
332
- }
333
- }
334
- if (t.isJSXNamespacedName(name)) {
335
- if (name.namespace.name === "bind") {
336
- /* istanbul ignore else */
337
- if (t.isJSXExpressionContainer(attr.value) || !attr.value) {
338
- const value = t.isExpression((_f = attr.value) === null || _f === void 0 ? void 0 : _f.expression)
339
- ? (0, lib_js_1.exprCall)(attrPath.get("value").get("expression"), attr.value.expression, internal)
340
- : undefined;
341
- bind.push(idToProp(name.name, value !== null && value !== void 0 ? value : (t.isExpression((_g = attr.value) === null || _g === void 0 ? void 0 : _g.expression) ? attr.value.expression : t.booleanLiteral(true))));
342
- }
343
- else if (t.isStringLiteral(attr.value)) {
344
- bind.push(idToProp(name.name, attr.value));
345
- }
346
- }
347
- else {
348
- throw attrPath.buildCodeFrameError("Vasille: only bind namespace is supported");
349
- }
350
- }
351
- }
352
- else {
353
- throw attrPath.buildCodeFrameError("Vasille: Spread attribute is not allowed on HTML tags.");
354
- }
355
- }
356
- if (classStatic.length > 0) {
357
- const first = classStatic[0];
358
- const value = classStatic.length === 1 ? classStatic[0] : t.stringLiteral(classStatic.map(item => item.value).join(" "));
359
- value.loc = first.loc;
360
- attrs.push(t.objectProperty(t.identifier("class"), value));
361
- }
362
- if (styleStatic.length > 0) {
363
- attrs.push(t.objectProperty(t.identifier("style"), t.stringLiteral(styleStatic.map(([id, value]) => `${id.name}:${value.value}`).join(";"))));
364
- }
365
- const statements = transformJsxArray(path.get("children"), internal);
366
- const call = t.callExpression(t.memberExpression(internal_js_1.ctx, t.identifier("tag")), [
367
- t.stringLiteral(name.name),
368
- t.objectExpression([
369
- ...(attrs.length > 0 ? [t.objectProperty(t.identifier("attr"), t.objectExpression(attrs))] : []),
370
- ...(events.length > 0 ? [t.objectProperty(t.identifier("events"), t.objectExpression(events))] : []),
371
- ...(bind.length > 0 ? [t.objectProperty(t.identifier("bind"), t.objectExpression(bind))] : []),
372
- ...(classElements.length > 0 || classObject.length
373
- ? [
374
- t.objectProperty(t.identifier("class"), t.arrayExpression([
375
- ...classElements,
376
- ...(classObject.length > 0 ? [t.objectExpression(classObject)] : []),
377
- ])),
378
- ]
379
- : []),
380
- ...(styleObject.length > 0 ? [t.objectProperty(t.identifier("style"), t.objectExpression(styleObject))] : []),
381
- ]),
382
- ...(statements.length > 0 ? [t.arrowFunctionExpression([internal_js_1.ctx], t.blockStatement(statements))] : []),
383
- ]);
384
- call.loc = path.node.loc;
385
- return t.expressionStatement(call);
386
- }
387
- if (t.isJSXIdentifier(name)) {
388
- const element = path.node;
389
- const opening = path.get("openingElement");
390
- const props = [];
391
- let run;
392
- const mapped = internal.mapping.get(name.name);
393
- if (mapped === "Debug" && internal.stack.get(name.name) === undefined && !internal.devMode) {
394
- return t.emptyStatement();
395
- }
396
- for (const attrPath of opening.get("attributes")) {
397
- const attr = attrPath.node;
398
- // <A prop=../>
399
- if (t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name)) {
400
- // <A prop=".."/>
401
- /* istanbul ignore else */
402
- if (t.isStringLiteral(attr.value)) {
403
- props.push(idToProp(attr.name, attr.value));
404
- }
405
- // <A prop={..}/>
406
- else if (t.isJSXExpressionContainer(attr.value)) {
407
- const isSystem = internal.mapping.has(name.name);
408
- const value = transformJsxExpressionContainer(attrPath.get("value"), internal, !isSystem || attr.name.name === "slot", isSystem && attr.name.name === "slot");
409
- props.push(idToProp(attr.name, value));
410
- }
411
- else if (!attr.value) {
412
- props.push(idToProp(attr.name, t.booleanLiteral(true)));
413
- }
414
- }
415
- // <A {...arg}/>
416
- else if (t.isJSXSpreadAttribute(attr)) {
417
- props.push(t.spreadElement(attr.argument));
418
- }
419
- // <A space:name=../>
420
- else {
421
- throw attrPath.buildCodeFrameError("Vasille: Namespaced attributes names are not supported");
422
- }
423
- }
424
- const filteredChildren = element.children.filter(item => {
425
- if (!t.isJSXText(item)) {
426
- return true;
427
- }
428
- return !!item.value.trim();
429
- });
430
- const isInternal = internal.mapping.has(name.name);
431
- if (filteredChildren.length === 1 &&
432
- t.isJSXExpressionContainer(filteredChildren[0]) &&
433
- (t.isFunctionExpression(filteredChildren[0].expression) ||
434
- t.isArrowFunctionExpression(filteredChildren[0].expression))) {
435
- transformJsxExpressionContainer(path.get("children")[element.children.indexOf(filteredChildren[0])], internal, true, isInternal);
436
- run = filteredChildren[0].expression;
437
- }
438
- else {
439
- const statements = transformJsxArray(path.get("children"), internal);
440
- if (statements.length > 0) {
441
- const params = [internal_js_1.ctx];
442
- if (!isInternal) {
443
- params.unshift(t.identifier(`_${internal.prefix}`));
444
- }
445
- run = t.arrowFunctionExpression(params, t.blockStatement(statements));
446
- }
447
- }
448
- const call = t.callExpression(t.identifier(name.name), [t.objectExpression(props), internal_js_1.ctx, ...(run ? [run] : [])]);
449
- call.loc = path.node.loc;
450
- return t.expressionStatement(call);
451
- }
452
- throw path.buildCodeFrameError("Vasille: Unsupported tag detected, html lowercase tag names and components are accepted");
453
- }