babel-plugin-vasille 3.1.1 → 3.2.1
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/README.md +5 -4
- package/lib/bridge.js +173 -0
- package/lib/call.js +73 -25
- package/lib/css-transformer.js +43 -7
- package/lib/expression.js +120 -44
- package/lib/index.js +6 -3
- package/lib/internal.js +42 -5
- package/lib/jsx-detect.js +42 -4
- package/lib/jsx.js +83 -32
- package/lib/lib.js +94 -43
- package/lib/mesh.js +277 -97
- package/lib/router.js +41 -0
- package/lib/transformer.js +50 -9
- package/lib/utils.js +50 -0
- package/lib-node/bridge.js +173 -0
- package/lib-node/call.js +30 -19
- package/lib-node/css-transformer.js +4 -4
- package/lib-node/expression.js +50 -23
- package/lib-node/jsx.js +25 -11
- package/lib-node/lib.js +26 -20
- package/lib-node/mesh.js +182 -53
- package/lib-node/router.js +41 -0
- package/lib-node/transformer.js +6 -1
- package/lib-node/utils.js +50 -0
- package/package.json +10 -11
package/lib/expression.js
CHANGED
|
@@ -1,74 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.encodeName = encodeName;
|
|
37
|
+
exports.idIsIValue = idIsIValue;
|
|
38
|
+
exports.idIsLocal = idIsLocal;
|
|
39
|
+
exports.memberIsIValue = memberIsIValue;
|
|
40
|
+
exports.nodeIsReactiveObject = nodeIsReactiveObject;
|
|
41
|
+
exports.checkNode = checkNode;
|
|
42
|
+
exports.checkOrIgnoreAllExpressions = checkOrIgnoreAllExpressions;
|
|
43
|
+
exports.checkAllExpressions = checkAllExpressions;
|
|
44
|
+
exports.checkAllUnknown = checkAllUnknown;
|
|
45
|
+
exports.checkOrIgnoreExpression = checkOrIgnoreExpression;
|
|
46
|
+
exports.checkExpression = checkExpression;
|
|
47
|
+
exports.checkStatements = checkStatements;
|
|
48
|
+
exports.checkStatement = checkStatement;
|
|
49
|
+
exports.checkFunction = checkFunction;
|
|
50
|
+
const t = __importStar(require("@babel/types"));
|
|
51
|
+
const bridge_1 = require("./bridge");
|
|
52
|
+
const call_js_1 = require("./call.js");
|
|
53
|
+
const internal_js_1 = require("./internal.js");
|
|
54
|
+
const router_1 = require("./router");
|
|
55
|
+
const utils_1 = require("./utils");
|
|
56
|
+
function encodeName(name) {
|
|
57
|
+
return insertName(name);
|
|
58
|
+
}
|
|
59
|
+
function insertName(name, search) {
|
|
60
|
+
const id = t.identifier(`Vasille_${name}`);
|
|
61
|
+
search?.inserted.add(id);
|
|
62
|
+
return id;
|
|
6
63
|
}
|
|
7
64
|
function addIdentifier(path, search) {
|
|
8
65
|
if (!search.found.has(path.node.name)) {
|
|
9
66
|
search.found.set(path.node.name, path.node);
|
|
10
67
|
}
|
|
11
|
-
path.replaceWith(
|
|
12
|
-
}
|
|
13
|
-
function stringify(node) {
|
|
14
|
-
let name = "";
|
|
15
|
-
if (t.isStringLiteral(node)) {
|
|
16
|
-
name = node.value;
|
|
17
|
-
}
|
|
18
|
-
if (t.isPrivateName(node)) {
|
|
19
|
-
name = node.id.name;
|
|
20
|
-
}
|
|
21
|
-
if (t.isIdentifier(node)) {
|
|
22
|
-
name = node.name;
|
|
23
|
-
}
|
|
24
|
-
return name;
|
|
68
|
+
path.replaceWith(insertName(path.node.name, search));
|
|
25
69
|
}
|
|
26
70
|
function extractMemberName(path, search) {
|
|
27
71
|
const names = [];
|
|
28
72
|
let it = path.node;
|
|
29
73
|
while (t.isMemberExpression(it)) {
|
|
30
|
-
const name = stringify(it.property);
|
|
74
|
+
const name = (0, utils_1.stringify)(it.property);
|
|
31
75
|
if (name === "$" && it !== path.node) {
|
|
32
76
|
throw path.buildCodeFrameError("Vasille: The reactive/observable value is nested");
|
|
33
77
|
}
|
|
34
78
|
it = it.object;
|
|
35
79
|
names.push(name);
|
|
36
80
|
}
|
|
37
|
-
names.push(stringify(it));
|
|
81
|
+
names.push((0, utils_1.stringify)(it));
|
|
38
82
|
if (t.isIdentifier(it) &&
|
|
39
|
-
search.stack.get(it.name, VariableScope.Local) === 1 /* VariableState.Ignored */) {
|
|
83
|
+
search.stack.get(it.name, internal_js_1.VariableScope.Local) === 1 /* VariableState.Ignored */) {
|
|
40
84
|
throw path.buildCodeFrameError("Vasille: This node cannot be processed, the root of expression is a local variable");
|
|
41
85
|
}
|
|
42
86
|
return names.reverse().join("_");
|
|
43
87
|
}
|
|
44
88
|
function addMemberExpr(path, search) {
|
|
45
89
|
const name = extractMemberName(path, search);
|
|
90
|
+
/* istanbul ignore else */
|
|
46
91
|
if (!search.found.has(name)) {
|
|
47
92
|
search.found.set(name, path.node);
|
|
48
93
|
}
|
|
49
|
-
path.replaceWith(
|
|
94
|
+
path.replaceWith(insertName(name, search));
|
|
50
95
|
}
|
|
51
96
|
function addExternalIValue(path, search) {
|
|
52
97
|
const name = extractMemberName(path, search);
|
|
53
98
|
if (!search.found.has(name)) {
|
|
54
99
|
search.found.set(name, path.node.object);
|
|
55
100
|
}
|
|
56
|
-
path.replaceWith(
|
|
101
|
+
path.replaceWith(insertName(name, search));
|
|
57
102
|
}
|
|
58
103
|
function meshIdentifier(path, internal) {
|
|
59
104
|
if (idIsIValue(path, internal)) {
|
|
60
105
|
path.replaceWith(t.memberExpression(path.node, t.identifier("$")));
|
|
61
106
|
}
|
|
62
107
|
}
|
|
63
|
-
|
|
108
|
+
function idIsIValue(path, internal, scope) {
|
|
64
109
|
const node = path.node;
|
|
65
110
|
return (REACTIVE_STATES.includes(internal.stack.get(node.name, scope)) &&
|
|
66
111
|
(!t.isMemberExpression(path.parent) || path.parent.object === node));
|
|
67
112
|
}
|
|
68
|
-
|
|
69
|
-
return internal.stack.get(path.node.name, VariableScope.Local) !== undefined;
|
|
113
|
+
function idIsLocal(path, internal) {
|
|
114
|
+
return internal.stack.get(path.node.name, internal_js_1.VariableScope.Local) !== undefined;
|
|
70
115
|
}
|
|
71
|
-
|
|
116
|
+
function memberIsIValue(node, internal, scope) {
|
|
72
117
|
return ((t.isIdentifier(node.object) &&
|
|
73
118
|
(internal.stack.get(node.object.name, scope) === 3 /* VariableState.ReactiveObject */ ||
|
|
74
119
|
(t.isIdentifier(node.property) &&
|
|
@@ -83,7 +128,7 @@ export function memberIsIValue(node, internal, scope) {
|
|
|
83
128
|
((t.isIdentifier(node.object.property) && node.object.property.name.startsWith("$$")) ||
|
|
84
129
|
(t.isStringLiteral(node.object.property) && node.object.property.value.startsWith("$$")))));
|
|
85
130
|
}
|
|
86
|
-
|
|
131
|
+
function nodeIsReactiveObject(path, internal) {
|
|
87
132
|
const node = path.node;
|
|
88
133
|
if (t.isIdentifier(node)) {
|
|
89
134
|
return internal.stack.get(node.name) === 3 /* VariableState.ReactiveObject */;
|
|
@@ -100,6 +145,7 @@ function meshMember(path, internal) {
|
|
|
100
145
|
}
|
|
101
146
|
function meshLValue(path, internal) {
|
|
102
147
|
const node = path.node;
|
|
148
|
+
/* istanbul ignore else */
|
|
103
149
|
if (t.isIdentifier(node)) {
|
|
104
150
|
meshIdentifier(path, internal);
|
|
105
151
|
}
|
|
@@ -108,6 +154,7 @@ function meshLValue(path, internal) {
|
|
|
108
154
|
}
|
|
109
155
|
else if (t.isArrayPattern(node)) {
|
|
110
156
|
for (const item of path.get("elements")) {
|
|
157
|
+
/* istanbul ignore else */
|
|
111
158
|
if (t.isOptionalMemberExpression(item.node) || t.isLVal(item.node)) {
|
|
112
159
|
meshLValue(item, internal);
|
|
113
160
|
}
|
|
@@ -117,11 +164,12 @@ function meshLValue(path, internal) {
|
|
|
117
164
|
meshLValue(path.get("argument"), internal);
|
|
118
165
|
}
|
|
119
166
|
}
|
|
120
|
-
|
|
167
|
+
function checkNode(path, internal) {
|
|
121
168
|
const search = {
|
|
122
169
|
external: internal,
|
|
123
170
|
found: new Map(),
|
|
124
171
|
self: null,
|
|
172
|
+
inserted: new Set(),
|
|
125
173
|
stack: internal.stack,
|
|
126
174
|
};
|
|
127
175
|
if (t.isIdentifier(path.node)) {
|
|
@@ -142,6 +190,7 @@ export function checkNode(path, internal) {
|
|
|
142
190
|
}
|
|
143
191
|
internal.stack.fixLocalIndex();
|
|
144
192
|
internal.stack.push();
|
|
193
|
+
/* istanbul ignore else */
|
|
145
194
|
if (t.isExpression(path.node)) {
|
|
146
195
|
checkExpression(path, search);
|
|
147
196
|
}
|
|
@@ -149,20 +198,22 @@ export function checkNode(path, internal) {
|
|
|
149
198
|
internal.stack.resetLocalIndex();
|
|
150
199
|
return search;
|
|
151
200
|
}
|
|
152
|
-
|
|
201
|
+
function checkOrIgnoreAllExpressions(nodePaths, search) {
|
|
153
202
|
for (const path of nodePaths) {
|
|
203
|
+
/* istanbul ignore else */
|
|
154
204
|
if (t.isExpression(path.node)) {
|
|
155
205
|
checkExpression(path, search);
|
|
156
206
|
}
|
|
157
207
|
}
|
|
158
208
|
}
|
|
159
|
-
|
|
209
|
+
function checkAllExpressions(nodePaths, search) {
|
|
160
210
|
for (const path of nodePaths) {
|
|
161
211
|
checkExpression(path, search);
|
|
162
212
|
}
|
|
163
213
|
}
|
|
164
|
-
|
|
214
|
+
function checkAllUnknown(paths, internal) {
|
|
165
215
|
for (const path of paths) {
|
|
216
|
+
/* istanbul ignore else */
|
|
166
217
|
if (t.isSpreadElement(path.node)) {
|
|
167
218
|
checkExpression(path.get("argument"), internal);
|
|
168
219
|
}
|
|
@@ -171,13 +222,14 @@ export function checkAllUnknown(paths, internal) {
|
|
|
171
222
|
}
|
|
172
223
|
}
|
|
173
224
|
}
|
|
174
|
-
|
|
225
|
+
function checkOrIgnoreExpression(path, search) {
|
|
226
|
+
/* istanbul ignore else */
|
|
175
227
|
if (t.isExpression(path.node)) {
|
|
176
228
|
checkExpression(path, search);
|
|
177
229
|
}
|
|
178
230
|
}
|
|
179
231
|
const REACTIVE_STATES = [2 /* VariableState.Reactive */, 4 /* VariableState.ReactivePointer */];
|
|
180
|
-
|
|
232
|
+
function checkExpression(nodePath, search) {
|
|
181
233
|
const expr = nodePath.node;
|
|
182
234
|
switch (expr && expr.type) {
|
|
183
235
|
case "TemplateLiteral": {
|
|
@@ -192,8 +244,9 @@ export function checkExpression(nodePath, search) {
|
|
|
192
244
|
break;
|
|
193
245
|
}
|
|
194
246
|
case "Identifier": {
|
|
247
|
+
/* istanbul ignore else */
|
|
195
248
|
if (expr && t.isIdentifier(expr)) {
|
|
196
|
-
if (idIsIValue(nodePath, search.external, VariableScope.Global) &&
|
|
249
|
+
if (idIsIValue(nodePath, search.external, internal_js_1.VariableScope.Global) &&
|
|
197
250
|
!idIsLocal(nodePath, search.external)) {
|
|
198
251
|
addIdentifier(nodePath, search);
|
|
199
252
|
}
|
|
@@ -207,11 +260,27 @@ export function checkExpression(nodePath, search) {
|
|
|
207
260
|
}
|
|
208
261
|
case "CallExpression": {
|
|
209
262
|
const path = nodePath;
|
|
210
|
-
|
|
211
|
-
|
|
263
|
+
const bridge = (0, bridge_1.processBridgeCall)(path, search.external, search);
|
|
264
|
+
if (bridge) {
|
|
265
|
+
if (bridge === "value") {
|
|
266
|
+
addMemberExpr(nodePath, search);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else if ((0, call_js_1.calls)(path, ["router"], search.external)) {
|
|
270
|
+
if (!search.external.stateOnly) {
|
|
271
|
+
(0, router_1.routerReplace)(path);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
throw path.buildCodeFrameError("Vasille: The router is not available in stores");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
if ((0, call_js_1.calls)(path, call_js_1.composeOnly, search.external)) {
|
|
279
|
+
throw path.buildCodeFrameError("Vasille: Usage of hints is restricted here");
|
|
280
|
+
}
|
|
281
|
+
checkOrIgnoreExpression(path.get("callee"), search);
|
|
282
|
+
checkAllUnknown(path.get("arguments"), search);
|
|
212
283
|
}
|
|
213
|
-
checkOrIgnoreExpression(path.get("callee"), search);
|
|
214
|
-
checkAllUnknown(path.get("arguments"), search);
|
|
215
284
|
break;
|
|
216
285
|
}
|
|
217
286
|
case "OptionalCallExpression": {
|
|
@@ -230,7 +299,7 @@ export function checkExpression(nodePath, search) {
|
|
|
230
299
|
case "OptionalMemberExpression": {
|
|
231
300
|
const path = nodePath;
|
|
232
301
|
const node = path.node;
|
|
233
|
-
if (memberIsIValue(node, search.external, VariableScope.Global)) {
|
|
302
|
+
if (memberIsIValue(node, search.external, internal_js_1.VariableScope.Global)) {
|
|
234
303
|
addMemberExpr(path, search);
|
|
235
304
|
}
|
|
236
305
|
else if (t.isIdentifier(node.property) && node.property.name === "$") {
|
|
@@ -280,6 +349,7 @@ export function checkExpression(nodePath, search) {
|
|
|
280
349
|
case "UpdateExpression": {
|
|
281
350
|
const path = nodePath;
|
|
282
351
|
const arg = path.node.argument;
|
|
352
|
+
/* istanbul ignore else */
|
|
283
353
|
if (t.isLVal(arg)) {
|
|
284
354
|
meshLValue(path.get("argument"), search.external);
|
|
285
355
|
}
|
|
@@ -352,17 +422,19 @@ export function checkExpression(nodePath, search) {
|
|
|
352
422
|
}
|
|
353
423
|
}
|
|
354
424
|
}
|
|
355
|
-
|
|
425
|
+
function checkStatements(paths, search) {
|
|
356
426
|
for (const path of paths) {
|
|
357
427
|
checkStatement(path, search);
|
|
358
428
|
}
|
|
359
429
|
}
|
|
360
430
|
function ignoreLocals(val, search) {
|
|
431
|
+
/* istanbul ignore else */
|
|
361
432
|
if (t.isIdentifier(val)) {
|
|
362
433
|
search.stack.set(val.name, 1 /* VariableState.Ignored */);
|
|
363
434
|
}
|
|
364
435
|
else if (t.isObjectPattern(val)) {
|
|
365
436
|
for (const prop of val.properties) {
|
|
437
|
+
/* istanbul ignore else */
|
|
366
438
|
if (t.isObjectProperty(prop) && t.isIdentifier(prop.value)) {
|
|
367
439
|
search.stack.set(prop.value.name, 1 /* VariableState.Ignored */);
|
|
368
440
|
}
|
|
@@ -376,6 +448,7 @@ function ignoreLocals(val, search) {
|
|
|
376
448
|
}
|
|
377
449
|
else if (t.isArrayPattern(val)) {
|
|
378
450
|
for (const element of val.elements) {
|
|
451
|
+
/* istanbul ignore else */
|
|
379
452
|
if (element && !t.isVoidPattern(element)) {
|
|
380
453
|
ignoreLocals(element, search);
|
|
381
454
|
}
|
|
@@ -383,13 +456,14 @@ function ignoreLocals(val, search) {
|
|
|
383
456
|
}
|
|
384
457
|
else if (t.isVariableDeclaration(val)) {
|
|
385
458
|
for (const declarator of val.declarations) {
|
|
459
|
+
/* istanbul ignore else */
|
|
386
460
|
if (!t.isVoidPattern(declarator.id)) {
|
|
387
461
|
ignoreLocals(declarator.id, search);
|
|
388
462
|
}
|
|
389
463
|
}
|
|
390
464
|
}
|
|
391
465
|
}
|
|
392
|
-
|
|
466
|
+
function checkStatement(path, search) {
|
|
393
467
|
const statement = path.node;
|
|
394
468
|
if (!statement) {
|
|
395
469
|
return;
|
|
@@ -429,6 +503,7 @@ export function checkStatement(path, search) {
|
|
|
429
503
|
case "ForStatement": {
|
|
430
504
|
const _path = path;
|
|
431
505
|
const node = _path.node;
|
|
506
|
+
/* istanbul ignore else */
|
|
432
507
|
if (node.init) {
|
|
433
508
|
if (t.isExpression(node.init)) {
|
|
434
509
|
checkExpression(_path.get("init"), search);
|
|
@@ -486,6 +561,7 @@ export function checkStatement(path, search) {
|
|
|
486
561
|
case "TryStatement":
|
|
487
562
|
const handlerPath = path.get("handler");
|
|
488
563
|
checkStatement(path.get("block"), search);
|
|
564
|
+
/* istanbul ignore else */
|
|
489
565
|
if (handlerPath.node) {
|
|
490
566
|
checkStatement(handlerPath.get("body"), search);
|
|
491
567
|
}
|
|
@@ -509,7 +585,7 @@ export function checkStatement(path, search) {
|
|
|
509
585
|
}
|
|
510
586
|
}
|
|
511
587
|
}
|
|
512
|
-
|
|
588
|
+
function checkFunction(path, search) {
|
|
513
589
|
const node = path.node;
|
|
514
590
|
for (const param of node.params) {
|
|
515
591
|
ignoreLocals(param, search);
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const transformer_js_1 = require("./transformer.js");
|
|
5
|
+
function default_1() {
|
|
3
6
|
return {
|
|
4
7
|
name: "Vasille",
|
|
5
8
|
visitor: {
|
|
6
9
|
Program(path, params) {
|
|
7
|
-
trProgram(path, params.opts.devMode !== false);
|
|
10
|
+
(0, transformer_js_1.trProgram)(path, params.opts.devMode !== false);
|
|
8
11
|
},
|
|
9
12
|
},
|
|
10
13
|
};
|
package/lib/internal.js
CHANGED
|
@@ -1,11 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.ctx = exports.StackedStates = exports.VariableScope = void 0;
|
|
37
|
+
const t = __importStar(require("@babel/types"));
|
|
38
|
+
var VariableScope;
|
|
3
39
|
(function (VariableScope) {
|
|
4
40
|
VariableScope[VariableScope["Any"] = 0] = "Any";
|
|
5
41
|
VariableScope[VariableScope["Local"] = 1] = "Local";
|
|
6
42
|
VariableScope[VariableScope["Global"] = 2] = "Global";
|
|
7
|
-
})(VariableScope || (VariableScope = {}));
|
|
8
|
-
|
|
43
|
+
})(VariableScope || (exports.VariableScope = VariableScope = {}));
|
|
44
|
+
class StackedStates {
|
|
9
45
|
constructor() {
|
|
10
46
|
this.maps = [];
|
|
11
47
|
this.localIndex = -1;
|
|
@@ -37,4 +73,5 @@ export class StackedStates {
|
|
|
37
73
|
this.maps[this.maps.length - 1].set(name, state);
|
|
38
74
|
}
|
|
39
75
|
}
|
|
40
|
-
|
|
76
|
+
exports.StackedStates = StackedStates;
|
|
77
|
+
exports.ctx = t.identifier("Vasille");
|
package/lib/jsx-detect.js
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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) {
|
|
3
41
|
if (t.isBinaryExpression(node)) {
|
|
4
42
|
return (t.isExpression(node.left) && exprHasJsx(node.left)) || exprHasJsx(node.right);
|
|
5
43
|
}
|
|
@@ -11,7 +49,7 @@ export function exprHasJsx(node) {
|
|
|
11
49
|
}
|
|
12
50
|
return t.isJSXElement(node) || t.isJSXFragment(node);
|
|
13
51
|
}
|
|
14
|
-
|
|
52
|
+
function statementHasJsx(statement) {
|
|
15
53
|
if (t.isExpressionStatement(statement)) {
|
|
16
54
|
return exprHasJsx(statement.expression);
|
|
17
55
|
}
|
|
@@ -54,7 +92,7 @@ export function statementHasJsx(statement) {
|
|
|
54
92
|
}
|
|
55
93
|
return false;
|
|
56
94
|
}
|
|
57
|
-
|
|
95
|
+
function bodyHasJsx(node) {
|
|
58
96
|
if (t.isExpression(node)) {
|
|
59
97
|
return exprHasJsx(node);
|
|
60
98
|
}
|