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/router.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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.routerReplace = routerReplace;
|
|
37
|
+
const t = __importStar(require("@babel/types"));
|
|
38
|
+
const internal_1 = require("./internal");
|
|
39
|
+
function routerReplace(path) {
|
|
40
|
+
path.replaceWith(t.memberExpression(t.memberExpression(internal_1.ctx, t.identifier("runner")), t.identifier("router")));
|
|
41
|
+
}
|
package/lib/transformer.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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.trProgram = trProgram;
|
|
37
|
+
const t = __importStar(require("@babel/types"));
|
|
38
|
+
const internal_js_1 = require("./internal.js");
|
|
39
|
+
const mesh_js_1 = require("./mesh.js");
|
|
40
|
+
const css_transformer_js_1 = require("./css-transformer.js");
|
|
5
41
|
const imports = new Map([["vasille-web", "VasilleWeb"]]);
|
|
6
42
|
const ignoreMembers = new Set([
|
|
7
43
|
"value",
|
|
@@ -21,13 +57,15 @@ const ignoreMembers = new Set([
|
|
|
21
57
|
"laptop",
|
|
22
58
|
"prefersDark",
|
|
23
59
|
"prefersLight",
|
|
24
|
-
"
|
|
60
|
+
"bridge",
|
|
61
|
+
"router",
|
|
62
|
+
"runOnDestroy",
|
|
25
63
|
]);
|
|
26
64
|
function extractText(node) {
|
|
27
65
|
// no case found for string literal
|
|
28
66
|
return node.name;
|
|
29
67
|
}
|
|
30
|
-
|
|
68
|
+
function trProgram(path, devMode) {
|
|
31
69
|
let id;
|
|
32
70
|
let stylesConnected = false;
|
|
33
71
|
const internal = {
|
|
@@ -38,7 +76,7 @@ export function trProgram(path, devMode) {
|
|
|
38
76
|
set id(expr) {
|
|
39
77
|
id = expr;
|
|
40
78
|
},
|
|
41
|
-
stack: new StackedStates(),
|
|
79
|
+
stack: new internal_js_1.StackedStates(),
|
|
42
80
|
mapping: new Map(),
|
|
43
81
|
global: "",
|
|
44
82
|
prefix: "Vasille_",
|
|
@@ -54,8 +92,10 @@ export function trProgram(path, devMode) {
|
|
|
54
92
|
if (name) {
|
|
55
93
|
internal.prefix = name;
|
|
56
94
|
for (const specifier of statement.specifiers) {
|
|
95
|
+
/* istanbul ignore else */
|
|
57
96
|
if (t.isImportNamespaceSpecifier(specifier)) {
|
|
58
97
|
internal.global = specifier.local.name;
|
|
98
|
+
/* istanbul ignore else */
|
|
59
99
|
if (statement.source.value === "vasille-web") {
|
|
60
100
|
stylesConnected = true;
|
|
61
101
|
}
|
|
@@ -89,8 +129,8 @@ export function trProgram(path, devMode) {
|
|
|
89
129
|
if (!id) {
|
|
90
130
|
return;
|
|
91
131
|
}
|
|
92
|
-
else if (!stylesConnected || !findStyleInNode(statementPath, internal)) {
|
|
93
|
-
meshStatement(statementPath, internal);
|
|
132
|
+
else if (!stylesConnected || !(0, css_transformer_js_1.findStyleInNode)(statementPath, internal)) {
|
|
133
|
+
(0, mesh_js_1.meshStatement)(statementPath, internal);
|
|
94
134
|
}
|
|
95
135
|
}
|
|
96
136
|
}
|
|
@@ -99,6 +139,7 @@ export function trProgram(path, devMode) {
|
|
|
99
139
|
const statement = statementPath.node;
|
|
100
140
|
statementPath.replaceWith(t.importDeclaration([
|
|
101
141
|
...statement.specifiers.filter(item => {
|
|
142
|
+
/* istanbul ignore else */
|
|
102
143
|
if (t.isImportSpecifier(item) && t.isIdentifier(item.local)) {
|
|
103
144
|
return statementPath.scope.bindings[item.local.name].referenced;
|
|
104
145
|
}
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
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.stringify = stringify;
|
|
37
|
+
const t = __importStar(require("@babel/types"));
|
|
38
|
+
function stringify(node) {
|
|
39
|
+
let name = "";
|
|
40
|
+
if (t.isStringLiteral(node)) {
|
|
41
|
+
name = node.value;
|
|
42
|
+
}
|
|
43
|
+
if (t.isPrivateName(node)) {
|
|
44
|
+
name = node.id.name;
|
|
45
|
+
}
|
|
46
|
+
if (t.isIdentifier(node)) {
|
|
47
|
+
name = node.name;
|
|
48
|
+
}
|
|
49
|
+
return name;
|
|
50
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
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.processBridgeCall = processBridgeCall;
|
|
37
|
+
const t = __importStar(require("@babel/types"));
|
|
38
|
+
const expression_1 = require("./expression");
|
|
39
|
+
const lib_1 = require("./lib");
|
|
40
|
+
const mesh_1 = require("./mesh");
|
|
41
|
+
const utils_1 = require("./utils");
|
|
42
|
+
const bridgeConstName = "bridge";
|
|
43
|
+
function processBridgeCall(path, internal, search) {
|
|
44
|
+
const node = path.node;
|
|
45
|
+
if (t.isCallExpression(node) && t.isMemberExpression(node.callee)) {
|
|
46
|
+
const callee = node.callee;
|
|
47
|
+
let propName = null;
|
|
48
|
+
if (t.isIdentifier(callee.object)) {
|
|
49
|
+
const mapped = internal.mapping.get(callee.object.name);
|
|
50
|
+
if (mapped && mapped === bridgeConstName && internal.stack.get(callee.object.name) === undefined) {
|
|
51
|
+
propName = (0, utils_1.stringify)(callee.property);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (t.isMemberExpression(callee.object) && t.isIdentifier(callee.object.object)) {
|
|
55
|
+
const rootName = callee.object.object.name;
|
|
56
|
+
if (rootName === internal.global &&
|
|
57
|
+
internal.stack.get(rootName) === undefined &&
|
|
58
|
+
(0, utils_1.stringify)(callee.object.property) === bridgeConstName) {
|
|
59
|
+
propName = (0, utils_1.stringify)(callee.property);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (propName) {
|
|
63
|
+
const getArg = (mesh = true) => {
|
|
64
|
+
if (node.arguments.length !== 1 || !t.isExpression(node.arguments[0])) {
|
|
65
|
+
throw path.buildCodeFrameError("Vasille: Expected 1 argument");
|
|
66
|
+
}
|
|
67
|
+
if (mesh) {
|
|
68
|
+
(0, mesh_1.meshExpression)(path.get("arguments")[0], internal);
|
|
69
|
+
}
|
|
70
|
+
return node.arguments[0];
|
|
71
|
+
};
|
|
72
|
+
const callWithArg = (name) => {
|
|
73
|
+
path.replaceWith(t.callExpression(t.memberExpression(internal.id, t.identifier(name)), [getArg()]));
|
|
74
|
+
};
|
|
75
|
+
const callWithOptionalArg = (name) => {
|
|
76
|
+
if (node.arguments.length === 0) {
|
|
77
|
+
path.replaceWith(t.callExpression(t.memberExpression(internal.id, t.identifier(name)), []));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
callWithArg(name);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
switch (propName) {
|
|
84
|
+
case "ref": {
|
|
85
|
+
callWithArg("r");
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "bind": {
|
|
89
|
+
const arg = getArg(false);
|
|
90
|
+
const result = (0, expression_1.checkNode)(path.get("arguments")[0], internal);
|
|
91
|
+
if (result.self) {
|
|
92
|
+
path.replaceWith(result.self);
|
|
93
|
+
}
|
|
94
|
+
else if (result.found.size > 0) {
|
|
95
|
+
const found = result.found;
|
|
96
|
+
path.replaceWith(t.callExpression(t.memberExpression(internal.id, t.identifier("ex")), [
|
|
97
|
+
t.arrowFunctionExpression([...found.keys()].map(expression_1.encodeName), arg),
|
|
98
|
+
t.arrayExpression([...found.values()]),
|
|
99
|
+
]));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
callWithArg("r");
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "calculate":
|
|
107
|
+
case "watch": {
|
|
108
|
+
const args = (0, lib_1.processCalculateCall)(path, internal);
|
|
109
|
+
path.replaceWith(t.callExpression(t.memberExpression(internal.id, t.identifier("ex")), args));
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case "arrayModel": {
|
|
113
|
+
callWithOptionalArg("sam");
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case "setModel": {
|
|
117
|
+
callWithOptionalArg("ssm");
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case "mapModel": {
|
|
121
|
+
callWithOptionalArg("smm");
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case "reactiveObject": {
|
|
125
|
+
callWithArg("sro");
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "value": {
|
|
129
|
+
if (!search) {
|
|
130
|
+
path.replaceWith(t.memberExpression(getArg(), t.identifier("$")));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
path.replaceWith(getArg());
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "setValue": {
|
|
138
|
+
if (node.arguments.length !== 2 || !t.isExpression(node.arguments[0]) || !t.isExpression(node.arguments[1])) {
|
|
139
|
+
throw path.buildCodeFrameError("Vasille: Expected 2 arguments");
|
|
140
|
+
}
|
|
141
|
+
(0, mesh_1.meshExpression)(path.get("arguments")[0], internal);
|
|
142
|
+
if (search) {
|
|
143
|
+
(0, expression_1.checkExpression)(path.get("arguments")[1], search);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
(0, mesh_1.meshExpression)(path.get("arguments")[1], internal);
|
|
147
|
+
}
|
|
148
|
+
path.replaceWith(t.assignmentExpression("=", t.memberExpression(node.arguments[0], t.identifier("$")), node.arguments[1]));
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case "stored": {
|
|
152
|
+
const arg = getArg(false);
|
|
153
|
+
if ((t.isIdentifier(arg) && (0, expression_1.idIsIValue)(path.get("arguments")[0], internal)) ||
|
|
154
|
+
(t.isMemberExpression(arg) && (0, expression_1.memberIsIValue)(arg, internal))) {
|
|
155
|
+
path.replaceWith(t.memberExpression(arg, t.identifier("$")));
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
callWithArg("rv");
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "destroy": {
|
|
163
|
+
path.replaceWith(t.callExpression(t.memberExpression(getArg(true), t.identifier("destroy")), []));
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
default:
|
|
167
|
+
throw path.buildCodeFrameError(`Vasille: Unknown bridge method "${propName}"`);
|
|
168
|
+
}
|
|
169
|
+
return propName;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
173
|
+
}
|
package/lib-node/call.js
CHANGED
|
@@ -40,6 +40,7 @@ const internal_js_1 = require("./internal.js");
|
|
|
40
40
|
exports.composeOnly = [
|
|
41
41
|
"forward",
|
|
42
42
|
"watch",
|
|
43
|
+
"calculate",
|
|
43
44
|
"ref",
|
|
44
45
|
"bind",
|
|
45
46
|
"value",
|
|
@@ -48,6 +49,8 @@ exports.composeOnly = [
|
|
|
48
49
|
"mapModel",
|
|
49
50
|
"setModel",
|
|
50
51
|
"reactiveObject",
|
|
52
|
+
"router",
|
|
53
|
+
"runOnDestroy",
|
|
51
54
|
];
|
|
52
55
|
exports.styleOnly = [
|
|
53
56
|
"theme",
|
|
@@ -61,29 +64,37 @@ exports.styleOnly = [
|
|
|
61
64
|
];
|
|
62
65
|
exports.requiresContext = ["awaited"];
|
|
63
66
|
const requiresContextSet = new Set(exports.requiresContext);
|
|
64
|
-
function
|
|
67
|
+
function checkCall(path, name, internal) {
|
|
68
|
+
const node = path.node;
|
|
69
|
+
if (requiresContextSet.has(name) && t.isCallExpression(node)) {
|
|
70
|
+
if (internal.stateOnly) {
|
|
71
|
+
throw path.buildCodeFrameError(`Vasille: ${name} function can be used only in components`);
|
|
72
|
+
}
|
|
73
|
+
node.arguments.unshift(internal_js_1.ctx);
|
|
74
|
+
}
|
|
75
|
+
if (name === "store") {
|
|
76
|
+
internal.stateOnly = true;
|
|
77
|
+
}
|
|
78
|
+
if (["compose", "view", "mvcView", "mvvmView", "hybridView", "screen"].includes(name)) {
|
|
79
|
+
internal.stateOnly = false;
|
|
80
|
+
}
|
|
81
|
+
return name;
|
|
82
|
+
}
|
|
83
|
+
function calls(path, names, internal) {
|
|
84
|
+
const node = path.node;
|
|
65
85
|
const set = new Set(names);
|
|
66
86
|
const callee = t.isCallExpression(node) ? node.callee : null;
|
|
67
87
|
if (callee) {
|
|
68
88
|
if (t.isIdentifier(callee)) {
|
|
69
89
|
const mapped = internal.mapping.get(callee.name);
|
|
70
90
|
if (mapped && set.has(mapped) && internal.stack.get(callee.name) === undefined) {
|
|
71
|
-
|
|
72
|
-
node.arguments.unshift(internal_js_1.ctx);
|
|
73
|
-
}
|
|
74
|
-
if (mapped === "state") {
|
|
75
|
-
internal.stateOnly = true;
|
|
76
|
-
}
|
|
77
|
-
if (mapped === "compose" || mapped === "extend") {
|
|
78
|
-
internal.stateOnly = false;
|
|
79
|
-
}
|
|
80
|
-
return mapped;
|
|
91
|
+
return checkCall(path, mapped, internal);
|
|
81
92
|
}
|
|
82
93
|
return false;
|
|
83
94
|
}
|
|
84
|
-
const global = internal.stack.get(internal.global) === undefined;
|
|
85
95
|
let propName = null;
|
|
86
96
|
if (t.isMemberExpression(callee)) {
|
|
97
|
+
/* istanbul ignore else */
|
|
87
98
|
if (t.isIdentifier(callee.property)) {
|
|
88
99
|
propName = callee.property.name;
|
|
89
100
|
}
|
|
@@ -91,13 +102,13 @@ function calls(node, names, internal) {
|
|
|
91
102
|
propName = callee.property.value;
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
if (propName &&
|
|
106
|
+
set.has(propName) &&
|
|
107
|
+
t.isMemberExpression(callee) &&
|
|
108
|
+
t.isIdentifier(callee.object) &&
|
|
109
|
+
callee.object.name === internal.global &&
|
|
110
|
+
internal.stack.get(internal.global) === undefined) {
|
|
111
|
+
return checkCall(path, propName, internal);
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
return false;
|
|
@@ -47,7 +47,7 @@ function tryProcessProp(path, pseudo, media, internal) {
|
|
|
47
47
|
}
|
|
48
48
|
const mediaDefaults = ["mobile", "tablet", "laptop", "prefersDark", "prefersLight"];
|
|
49
49
|
function processValue(name, path, pseudo, theme, media, mediaDefault, allowFallback, internal) {
|
|
50
|
-
if ((0, call_js_1.calls)(path
|
|
50
|
+
if ((0, call_js_1.calls)(path, ["theme"], internal)) {
|
|
51
51
|
const call = path.node;
|
|
52
52
|
if (theme) {
|
|
53
53
|
throw path.buildCodeFrameError("Vasille: The theme seems the be defined twice");
|
|
@@ -61,14 +61,14 @@ function processValue(name, path, pseudo, theme, media, mediaDefault, allowFallb
|
|
|
61
61
|
.buildCodeFrameError("Vasille: Expected string literal");
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
if ((0, call_js_1.calls)(path
|
|
64
|
+
if ((0, call_js_1.calls)(path, ["dark"], internal)) {
|
|
65
65
|
if (theme) {
|
|
66
66
|
throw path.buildCodeFrameError("Vasille: The theme seem the be defined twice");
|
|
67
67
|
}
|
|
68
68
|
return processValue(name, path.get("arguments")[0], pseudo, `.dark`, media, mediaDefault, false, internal);
|
|
69
69
|
}
|
|
70
70
|
let callee;
|
|
71
|
-
if ((callee = (0, call_js_1.calls)(path
|
|
71
|
+
if ((callee = (0, call_js_1.calls)(path, mediaDefaults, internal))) {
|
|
72
72
|
const index = mediaDefaults.indexOf(callee) + 1;
|
|
73
73
|
if (mediaDefault.includes(index)) {
|
|
74
74
|
return processValue(name, path.get("arguments")[0], pseudo, theme, media, mediaDefault, false, internal);
|
|
@@ -178,7 +178,7 @@ function findStyleInNode(path, internal) {
|
|
|
178
178
|
}
|
|
179
179
|
if (t.isVariableDeclaration(path.node) &&
|
|
180
180
|
path.node.declarations.length === 1 &&
|
|
181
|
-
(0, call_js_1.calls)(path.
|
|
181
|
+
(0, call_js_1.calls)(path.get("declarations")[0].get("init"), ["styleSheet"], internal)) {
|
|
182
182
|
const call = path.node.declarations[0].init;
|
|
183
183
|
const callPath = path
|
|
184
184
|
.get("declarations")[0]
|