babel-plugin-vasille 3.1.1 → 3.1.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.
- package/lib/call.js +48 -11
- package/lib/css-transformer.js +43 -7
- package/lib/expression.js +71 -22
- package/lib/index.js +6 -3
- package/lib/internal.js +42 -5
- package/lib/jsx-detect.js +42 -4
- package/lib/jsx.js +66 -29
- package/lib/lib.js +75 -30
- package/lib/mesh.js +113 -65
- package/lib/transformer.js +44 -9
- package/lib-node/call.js +2 -2
- package/lib-node/mesh.js +2 -5
- package/lib-node/transformer.js +0 -1
- package/package.json +3 -3
package/lib/jsx.js
CHANGED
|
@@ -1,15 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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) {
|
|
7
44
|
if (t.isJSXElement(path.node)) {
|
|
8
45
|
return [transformJsxElement(path, internal)];
|
|
9
46
|
}
|
|
10
47
|
return transformJsxArray(path.get("children"), internal);
|
|
11
48
|
}
|
|
12
|
-
|
|
49
|
+
function transformJsxArray(paths, internal) {
|
|
13
50
|
const result = [];
|
|
14
51
|
for (const path of paths) {
|
|
15
52
|
if (t.isJSXElement(path.node) || t.isJSXFragment(path.node)) {
|
|
@@ -21,7 +58,7 @@ export function transformJsxArray(paths, internal) {
|
|
|
21
58
|
.replace(/\n\s+$/m, "")
|
|
22
59
|
.replace(/^\s*\n\s+/m, "")
|
|
23
60
|
.replace(/\s*\n\s*/gm, "\n");
|
|
24
|
-
const call = t.callExpression(t.memberExpression(ctx, t.identifier("text")), [t.stringLiteral(fixed)]);
|
|
61
|
+
const call = t.callExpression(t.memberExpression(internal_js_1.ctx, t.identifier("text")), [t.stringLiteral(fixed)]);
|
|
25
62
|
call.loc = path.node.loc;
|
|
26
63
|
if (call.loc) {
|
|
27
64
|
for (const char of path.node.value) {
|
|
@@ -43,7 +80,7 @@ export function transformJsxArray(paths, internal) {
|
|
|
43
80
|
}
|
|
44
81
|
else if (t.isJSXExpressionContainer(path.node)) {
|
|
45
82
|
const value = transformJsxExpressionContainer(path, internal, false, false);
|
|
46
|
-
const call = t.callExpression(t.memberExpression(ctx, t.identifier("text")), [value]);
|
|
83
|
+
const call = t.callExpression(t.memberExpression(internal_js_1.ctx, t.identifier("text")), [value]);
|
|
47
84
|
call.loc = value.loc;
|
|
48
85
|
result.push(t.expressionStatement(call));
|
|
49
86
|
}
|
|
@@ -58,24 +95,24 @@ function transformJsxExpressionContainer(path, internal, acceptSlots, isInternal
|
|
|
58
95
|
const loc = expression.loc;
|
|
59
96
|
if (acceptSlots &&
|
|
60
97
|
(t.isFunctionExpression(expression) || t.isArrowFunctionExpression(expression)) &&
|
|
61
|
-
bodyHasJsx(expression.body)) {
|
|
62
|
-
compose(path.get("expression"), internal, isInternalSlot);
|
|
98
|
+
(0, jsx_detect_js_1.bodyHasJsx)(expression.body)) {
|
|
99
|
+
(0, mesh_js_1.compose)(path.get("expression"), internal, isInternalSlot);
|
|
63
100
|
if (!isInternalSlot) {
|
|
64
101
|
if (expression.params.length < 1) {
|
|
65
102
|
expression.params.push(t.identifier(`_${internal.prefix}`));
|
|
66
103
|
}
|
|
67
|
-
expression.params.push(ctx);
|
|
104
|
+
expression.params.push(internal_js_1.ctx);
|
|
68
105
|
}
|
|
69
106
|
else {
|
|
70
|
-
expression.params.unshift(ctx);
|
|
107
|
+
expression.params.unshift(internal_js_1.ctx);
|
|
71
108
|
}
|
|
72
109
|
expression.loc = loc;
|
|
73
110
|
return expression;
|
|
74
111
|
}
|
|
75
112
|
else if (isInternalSlot && (t.isFunctionExpression(expression) || t.isArrowFunctionExpression(expression))) {
|
|
76
|
-
expression.params.unshift(ctx);
|
|
113
|
+
expression.params.unshift(internal_js_1.ctx);
|
|
77
114
|
}
|
|
78
|
-
let call = exprCall(path.get("expression"), expression, internal);
|
|
115
|
+
let call = (0, lib_js_1.exprCall)(path.get("expression"), expression, internal);
|
|
79
116
|
if (!call && t.isIdentifier(expression) && internal.stack.get(expression.name) === 3 /* VariableState.ReactiveObject */) {
|
|
80
117
|
call = t.callExpression(t.memberExpression(internal.id, t.identifier("rop")), [expression]);
|
|
81
118
|
}
|
|
@@ -119,7 +156,7 @@ function transformJsxElement(path, internal) {
|
|
|
119
156
|
if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {
|
|
120
157
|
const path = attrPath.get("value");
|
|
121
158
|
if (t.isExpression(path.node.expression)) {
|
|
122
|
-
meshExpression(path.get("expression"), internal);
|
|
159
|
+
(0, mesh_js_1.meshExpression)(path.get("expression"), internal);
|
|
123
160
|
}
|
|
124
161
|
events.push(idToProp(name, path.node.expression, 2));
|
|
125
162
|
}
|
|
@@ -139,7 +176,7 @@ function transformJsxElement(path, internal) {
|
|
|
139
176
|
if (t.isExpression(item)) {
|
|
140
177
|
// class={[cond && "string"]}
|
|
141
178
|
if (t.isLogicalExpression(item) && item.operator === "&&" && t.isStringLiteral(item.right)) {
|
|
142
|
-
const call = exprCall(elementPath.get("left"), item.left, internal);
|
|
179
|
+
const call = (0, lib_js_1.exprCall)(elementPath.get("left"), item.left, internal);
|
|
143
180
|
classObject.push(idToProp(item.right, call ?? item.left));
|
|
144
181
|
}
|
|
145
182
|
// class={[{..}]}
|
|
@@ -148,9 +185,9 @@ function transformJsxElement(path, internal) {
|
|
|
148
185
|
// class={[{a: b}]}
|
|
149
186
|
if (t.isObjectProperty(propPath.node)) {
|
|
150
187
|
const prop = propPath;
|
|
151
|
-
const value = exprCall(prop.get("value"), prop.node.value, internal) ?? prop.node.value;
|
|
188
|
+
const value = (0, lib_js_1.exprCall)(prop.get("value"), prop.node.value, internal) ?? prop.node.value;
|
|
152
189
|
if (t.isExpression(prop.node.key) && !t.isIdentifier(prop.node.key)) {
|
|
153
|
-
meshExpression(prop.get("key"), internal);
|
|
190
|
+
(0, mesh_js_1.meshExpression)(prop.get("key"), internal);
|
|
154
191
|
}
|
|
155
192
|
classObject.push(t.objectProperty(prop.node.key, value));
|
|
156
193
|
}
|
|
@@ -170,7 +207,7 @@ function transformJsxElement(path, internal) {
|
|
|
170
207
|
}
|
|
171
208
|
// class={[..]}
|
|
172
209
|
else {
|
|
173
|
-
const call = exprCall(elementPath, item, internal);
|
|
210
|
+
const call = (0, lib_js_1.exprCall)(elementPath, item, internal);
|
|
174
211
|
classElements.push(call ?? item);
|
|
175
212
|
}
|
|
176
213
|
}
|
|
@@ -188,7 +225,7 @@ function transformJsxElement(path, internal) {
|
|
|
188
225
|
else if (t.isJSXExpressionContainer(attr.value) && t.isTemplateLiteral(attr.value.expression)) {
|
|
189
226
|
const jsxAttrPath = attrPath;
|
|
190
227
|
const jsxContainerPath = jsxAttrPath.get("value");
|
|
191
|
-
const value = exprCall(jsxContainerPath.get("expression"), attr.value.expression, internal);
|
|
228
|
+
const value = (0, lib_js_1.exprCall)(jsxContainerPath.get("expression"), attr.value.expression, internal);
|
|
192
229
|
attrs.push(t.objectProperty(t.identifier("class"), value ?? attr.value.expression));
|
|
193
230
|
if (value) {
|
|
194
231
|
console.warn(attrPath.buildCodeFrameError("Vasille: This will slow down your application"));
|
|
@@ -212,9 +249,9 @@ function transformJsxElement(path, internal) {
|
|
|
212
249
|
// style={{a: b}}
|
|
213
250
|
if (t.isObjectProperty(propPath.node)) {
|
|
214
251
|
const prop = propPath;
|
|
215
|
-
const value = exprCall(prop.get("value"), prop.node.value, internal) ?? prop.node.value;
|
|
252
|
+
const value = (0, lib_js_1.exprCall)(prop.get("value"), prop.node.value, internal) ?? prop.node.value;
|
|
216
253
|
if (t.isExpression(prop.node.key) && !t.isIdentifier(prop.node.key)) {
|
|
217
|
-
meshExpression(prop.get("key"), internal);
|
|
254
|
+
(0, mesh_js_1.meshExpression)(prop.get("key"), internal);
|
|
218
255
|
}
|
|
219
256
|
// style={{a: "b"}} -> static in compile time
|
|
220
257
|
if (t.isIdentifier(prop.node.key) && t.isStringLiteral(prop.node.value)) {
|
|
@@ -265,7 +302,7 @@ function transformJsxElement(path, internal) {
|
|
|
265
302
|
const jsxAttrPath = attrPath;
|
|
266
303
|
const jsxContainerPath = jsxAttrPath.get("value");
|
|
267
304
|
const literalPath = jsxContainerPath.get("expression");
|
|
268
|
-
const value = exprCall(literalPath, attr.value.expression, internal);
|
|
305
|
+
const value = (0, lib_js_1.exprCall)(literalPath, attr.value.expression, internal);
|
|
269
306
|
attrs.push(t.objectProperty(t.identifier("style"), value ?? attr.value.expression));
|
|
270
307
|
if (value) {
|
|
271
308
|
console.warn(attrPath.buildCodeFrameError("Vasille: This will slow down your application"));
|
|
@@ -285,7 +322,7 @@ function transformJsxElement(path, internal) {
|
|
|
285
322
|
if (name.namespace.name === "bind") {
|
|
286
323
|
if (t.isJSXExpressionContainer(attr.value) || !attr.value) {
|
|
287
324
|
const value = t.isExpression(attr.value?.expression)
|
|
288
|
-
? exprCall(attrPath.get("value").get("expression"), attr.value.expression, internal)
|
|
325
|
+
? (0, lib_js_1.exprCall)(attrPath.get("value").get("expression"), attr.value.expression, internal)
|
|
289
326
|
: undefined;
|
|
290
327
|
bind.push(idToProp(name.name, value ?? (t.isExpression(attr.value?.expression) ? attr.value.expression : t.booleanLiteral(true))));
|
|
291
328
|
}
|
|
@@ -312,7 +349,7 @@ function transformJsxElement(path, internal) {
|
|
|
312
349
|
attrs.push(t.objectProperty(t.identifier("style"), t.stringLiteral(styleStatic.map(([id, value]) => `${id.name}:${value.value}`).join(";"))));
|
|
313
350
|
}
|
|
314
351
|
const statements = transformJsxArray(path.get("children"), internal);
|
|
315
|
-
const call = t.callExpression(t.memberExpression(ctx, t.identifier("tag")), [
|
|
352
|
+
const call = t.callExpression(t.memberExpression(internal_js_1.ctx, t.identifier("tag")), [
|
|
316
353
|
t.stringLiteral(name.name),
|
|
317
354
|
t.objectExpression([
|
|
318
355
|
...(attrs.length > 0 ? [t.objectProperty(t.identifier("attr"), t.objectExpression(attrs))] : []),
|
|
@@ -328,7 +365,7 @@ function transformJsxElement(path, internal) {
|
|
|
328
365
|
: []),
|
|
329
366
|
...(styleObject.length > 0 ? [t.objectProperty(t.identifier("style"), t.objectExpression(styleObject))] : []),
|
|
330
367
|
]),
|
|
331
|
-
...(statements.length > 0 ? [t.arrowFunctionExpression([ctx], t.blockStatement(statements))] : []),
|
|
368
|
+
...(statements.length > 0 ? [t.arrowFunctionExpression([internal_js_1.ctx], t.blockStatement(statements))] : []),
|
|
332
369
|
]);
|
|
333
370
|
call.loc = path.node.loc;
|
|
334
371
|
return t.expressionStatement(call);
|
|
@@ -386,14 +423,14 @@ function transformJsxElement(path, internal) {
|
|
|
386
423
|
else {
|
|
387
424
|
const statements = transformJsxArray(path.get("children"), internal);
|
|
388
425
|
if (statements.length > 0) {
|
|
389
|
-
const params = [ctx];
|
|
426
|
+
const params = [internal_js_1.ctx];
|
|
390
427
|
if (!isInternal) {
|
|
391
428
|
params.unshift(t.identifier(`_${internal.prefix}`));
|
|
392
429
|
}
|
|
393
430
|
run = t.arrowFunctionExpression(params, t.blockStatement(statements));
|
|
394
431
|
}
|
|
395
432
|
}
|
|
396
|
-
const call = t.callExpression(t.identifier(name.name), [ctx, t.objectExpression(props), ...(run ? [run] : [])]);
|
|
433
|
+
const call = t.callExpression(t.identifier(name.name), [internal_js_1.ctx, t.objectExpression(props), ...(run ? [run] : [])]);
|
|
397
434
|
call.loc = path.node.loc;
|
|
398
435
|
return t.expressionStatement(call);
|
|
399
436
|
}
|
package/lib/lib.js
CHANGED
|
@@ -1,8 +1,53 @@
|
|
|
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.named = named;
|
|
37
|
+
exports.parseCalculateCall = parseCalculateCall;
|
|
38
|
+
exports.exprCall = exprCall;
|
|
39
|
+
exports.forwardOnlyExpr = forwardOnlyExpr;
|
|
40
|
+
exports.own = own;
|
|
41
|
+
exports.ref = ref;
|
|
42
|
+
exports.reactiveObject = reactiveObject;
|
|
43
|
+
exports.arrayModel = arrayModel;
|
|
44
|
+
exports.setModel = setModel;
|
|
45
|
+
exports.mapModel = mapModel;
|
|
46
|
+
const t = __importStar(require("@babel/types"));
|
|
47
|
+
const expression_js_1 = require("./expression.js");
|
|
48
|
+
const internal_js_1 = require("./internal.js");
|
|
49
|
+
const call_js_1 = require("./call.js");
|
|
50
|
+
function named(call, name, internal, argPos) {
|
|
6
51
|
if (internal.devMode && !internal.stateOnly && name) {
|
|
7
52
|
while (argPos && call.arguments.length < argPos) {
|
|
8
53
|
call.arguments.push(t.buildUndefinedNode());
|
|
@@ -11,8 +56,8 @@ export function named(call, name, internal, argPos) {
|
|
|
11
56
|
}
|
|
12
57
|
return call;
|
|
13
58
|
}
|
|
14
|
-
|
|
15
|
-
if (t.isCallExpression(path.node) && calls(path.node, ["calculate", "watch"], internal)) {
|
|
59
|
+
function parseCalculateCall(path, internal) {
|
|
60
|
+
if (t.isCallExpression(path.node) && (0, call_js_1.calls)(path.node, ["calculate", "watch"], internal)) {
|
|
16
61
|
const call = path.node.arguments[0];
|
|
17
62
|
if (path.node.arguments.length !== 1) {
|
|
18
63
|
throw path.buildCodeFrameError("Vasille: Incorrect number of arguments");
|
|
@@ -21,8 +66,8 @@ export function parseCalculateCall(path, internal) {
|
|
|
21
66
|
if (call.params.length > 0) {
|
|
22
67
|
throw path.buildCodeFrameError("Vasille: Argument of calculate cannot have parameters");
|
|
23
68
|
}
|
|
24
|
-
const exprData = checkNode(path.get("arguments")[0], internal);
|
|
25
|
-
call.params = [...exprData.found.keys()].map(name => encodeName(name));
|
|
69
|
+
const exprData = (0, expression_js_1.checkNode)(path.get("arguments")[0], internal);
|
|
70
|
+
call.params = [...exprData.found.keys()].map(name => (0, expression_js_1.encodeName)(name));
|
|
26
71
|
return [call, t.arrayExpression([...exprData.found.values()])];
|
|
27
72
|
}
|
|
28
73
|
else {
|
|
@@ -31,15 +76,15 @@ export function parseCalculateCall(path, internal) {
|
|
|
31
76
|
}
|
|
32
77
|
return null;
|
|
33
78
|
}
|
|
34
|
-
|
|
79
|
+
function exprCall(path, expr, internal, name) {
|
|
35
80
|
const calculateCall = parseCalculateCall(path, internal);
|
|
36
81
|
if (calculateCall) {
|
|
37
82
|
return named(t.callExpression(internal.stateOnly
|
|
38
83
|
? t.memberExpression(internal.id, t.identifier("ex"))
|
|
39
|
-
: t.memberExpression(ctx, t.identifier("expr")), calculateCall), name, internal);
|
|
84
|
+
: t.memberExpression(internal_js_1.ctx, t.identifier("expr")), calculateCall), name, internal);
|
|
40
85
|
}
|
|
41
86
|
if (t.isCallExpression(expr) &&
|
|
42
|
-
calls(expr, ["forward"], internal) &&
|
|
87
|
+
(0, call_js_1.calls)(expr, ["forward"], internal) &&
|
|
43
88
|
expr.arguments.length === 1 &&
|
|
44
89
|
t.isExpression(expr.arguments[0])) {
|
|
45
90
|
const data = exprCall(path.get("arguments")[0], expr.arguments[0], internal);
|
|
@@ -47,35 +92,35 @@ export function exprCall(path, expr, internal, name) {
|
|
|
47
92
|
return t.callExpression(t.memberExpression(internal.id, t.identifier("fo")), [data]);
|
|
48
93
|
}
|
|
49
94
|
}
|
|
50
|
-
const exprData = checkNode(path, internal);
|
|
95
|
+
const exprData = (0, expression_js_1.checkNode)(path, internal);
|
|
51
96
|
if (exprData.self) {
|
|
52
97
|
return exprData.self;
|
|
53
98
|
}
|
|
54
|
-
const names = [...exprData.found.keys()].map(name => encodeName(name));
|
|
99
|
+
const names = [...exprData.found.keys()].map(name => (0, expression_js_1.encodeName)(name));
|
|
55
100
|
const dependencies = t.arrayExpression([...exprData.found.values()]);
|
|
56
101
|
if (names.length > 0 && expr) {
|
|
57
102
|
return named(t.callExpression(internal.stateOnly
|
|
58
103
|
? t.memberExpression(internal.id, t.identifier("ex"))
|
|
59
|
-
: t.memberExpression(ctx, t.identifier("expr")), [t.arrowFunctionExpression(names, expr), dependencies]), name, internal);
|
|
104
|
+
: t.memberExpression(internal_js_1.ctx, t.identifier("expr")), [t.arrowFunctionExpression(names, expr), dependencies]), name, internal);
|
|
60
105
|
}
|
|
61
106
|
return null;
|
|
62
107
|
}
|
|
63
|
-
|
|
108
|
+
function forwardOnlyExpr(path, expr, internal) {
|
|
64
109
|
const calculateCall = parseCalculateCall(path, internal);
|
|
65
110
|
if (calculateCall) {
|
|
66
111
|
return t.callExpression(t.memberExpression(internal.id, t.identifier("ex")), calculateCall);
|
|
67
112
|
}
|
|
68
|
-
const exprData = checkNode(path, internal);
|
|
113
|
+
const exprData = (0, expression_js_1.checkNode)(path, internal);
|
|
69
114
|
return exprData.self
|
|
70
115
|
? t.callExpression(t.memberExpression(internal.id, t.identifier("fo")), [exprData.self])
|
|
71
116
|
: exprData.found.size > 0 && expr
|
|
72
117
|
? t.callExpression(t.memberExpression(internal.id, t.identifier("ex")), [
|
|
73
|
-
t.arrowFunctionExpression([...exprData.found.keys()].map(name => encodeName(name)), expr),
|
|
118
|
+
t.arrowFunctionExpression([...exprData.found.keys()].map(name => (0, expression_js_1.encodeName)(name)), expr),
|
|
74
119
|
t.arrayExpression([...exprData.found.values()]),
|
|
75
120
|
])
|
|
76
121
|
: null;
|
|
77
122
|
}
|
|
78
|
-
|
|
123
|
+
function own(expr, internal, name) {
|
|
79
124
|
if (internal.stateOnly &&
|
|
80
125
|
t.isCallExpression(expr) &&
|
|
81
126
|
t.isMemberExpression(expr.callee) &&
|
|
@@ -87,22 +132,22 @@ export function own(expr, internal, name) {
|
|
|
87
132
|
}
|
|
88
133
|
return named(t.callExpression(internal.stateOnly
|
|
89
134
|
? t.memberExpression(internal.id, t.identifier("fo"))
|
|
90
|
-
: t.memberExpression(ctx, t.identifier("own")), [expr]), name, internal);
|
|
135
|
+
: t.memberExpression(internal_js_1.ctx, t.identifier("own")), [expr]), name, internal);
|
|
91
136
|
}
|
|
92
|
-
|
|
137
|
+
function ref(expr, internal, name) {
|
|
93
138
|
return named(t.callExpression(internal.stateOnly
|
|
94
139
|
? t.memberExpression(internal.id, t.identifier("r"))
|
|
95
|
-
: t.memberExpression(ctx, t.identifier("ref")), expr ? [expr] : []), name, internal, 1);
|
|
140
|
+
: t.memberExpression(internal_js_1.ctx, t.identifier("ref")), expr ? [expr] : []), name, internal, 1);
|
|
96
141
|
}
|
|
97
|
-
|
|
98
|
-
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "sro" : "ro")), internal.stateOnly ? [init] : [ctx, init]), name, internal);
|
|
142
|
+
function reactiveObject(init, internal, name) {
|
|
143
|
+
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "sro" : "ro")), internal.stateOnly ? [init] : [internal_js_1.ctx, init]), name, internal);
|
|
99
144
|
}
|
|
100
|
-
|
|
101
|
-
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "sam" : "am")), internal.stateOnly ? (init ? [init] : []) : [ctx, ...(init ? [init] : [])]), name, internal, 2);
|
|
145
|
+
function arrayModel(init, internal, name) {
|
|
146
|
+
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "sam" : "am")), internal.stateOnly ? (init ? [init] : []) : [internal_js_1.ctx, ...(init ? [init] : [])]), name, internal, 2);
|
|
102
147
|
}
|
|
103
|
-
|
|
104
|
-
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "ssm" : "sm")), internal.stateOnly ? args : [ctx, ...args]), name, internal);
|
|
148
|
+
function setModel(args, internal, name) {
|
|
149
|
+
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "ssm" : "sm")), internal.stateOnly ? args : [internal_js_1.ctx, ...args]), name, internal);
|
|
105
150
|
}
|
|
106
|
-
|
|
107
|
-
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "smm" : "mm")), internal.stateOnly ? args : [ctx, ...args]), name, internal);
|
|
151
|
+
function mapModel(args, internal, name) {
|
|
152
|
+
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "smm" : "mm")), internal.stateOnly ? args : [internal_js_1.ctx, ...args]), name, internal);
|
|
108
153
|
}
|