babel-plugin-vasille 3.2.1 → 4.0.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.
- package/README.md +5 -14
- package/lib/call.js +30 -30
- package/lib/css-transformer.js +42 -44
- package/lib/expression.js +116 -135
- package/lib/index.js +4 -1
- package/lib/internal.js +4 -19
- package/lib/jsx-detect.js +3 -54
- package/lib/jsx.js +244 -128
- package/lib/lib.js +103 -73
- package/lib/mesh.js +542 -494
- package/lib/order-check.js +48 -0
- package/lib/transformer.js +119 -79
- package/package.json +6 -7
- package/lib/bridge.js +0 -173
- package/lib-node/bridge.js +0 -173
- package/lib-node/call.js +0 -115
- package/lib-node/css-transformer.js +0 -248
- package/lib-node/expression.js +0 -600
- package/lib-node/index.js +0 -14
- package/lib-node/internal.js +0 -77
- package/lib-node/jsx-detect.js +0 -100
- package/lib-node/jsx.js +0 -453
- package/lib-node/lib.js +0 -159
- package/lib-node/mesh.js +0 -1051
- package/lib-node/router.js +0 -41
- package/lib-node/transformer.js +0 -150
- package/lib-node/utils.js +0 -50
package/lib-node/lib.js
DELETED
|
@@ -1,159 +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.named = named;
|
|
37
|
-
exports.processCalculateCall = processCalculateCall;
|
|
38
|
-
exports.parseCalculateCall = parseCalculateCall;
|
|
39
|
-
exports.exprCall = exprCall;
|
|
40
|
-
exports.forwardOnlyExpr = forwardOnlyExpr;
|
|
41
|
-
exports.own = own;
|
|
42
|
-
exports.ref = ref;
|
|
43
|
-
exports.reactiveObject = reactiveObject;
|
|
44
|
-
exports.arrayModel = arrayModel;
|
|
45
|
-
exports.setModel = setModel;
|
|
46
|
-
exports.mapModel = mapModel;
|
|
47
|
-
const t = __importStar(require("@babel/types"));
|
|
48
|
-
const expression_js_1 = require("./expression.js");
|
|
49
|
-
const internal_js_1 = require("./internal.js");
|
|
50
|
-
const call_js_1 = require("./call.js");
|
|
51
|
-
function named(call, name, internal, argPos) {
|
|
52
|
-
if (internal.devMode && !internal.stateOnly && name) {
|
|
53
|
-
while (argPos && call.arguments.length < argPos) {
|
|
54
|
-
call.arguments.push(t.buildUndefinedNode());
|
|
55
|
-
}
|
|
56
|
-
call.arguments.push(...(typeof name === "string" ? [t.stringLiteral(name)] : name.map(item => t.stringLiteral(item))));
|
|
57
|
-
}
|
|
58
|
-
return call;
|
|
59
|
-
}
|
|
60
|
-
function processCalculateCall(path, internal) {
|
|
61
|
-
const call = path.node.arguments[0];
|
|
62
|
-
if (path.node.arguments.length !== 1) {
|
|
63
|
-
throw path.buildCodeFrameError("Vasille: Incorrect number of arguments");
|
|
64
|
-
}
|
|
65
|
-
if (t.isFunctionExpression(call) || t.isArrowFunctionExpression(call)) {
|
|
66
|
-
if (call.params.length > 0) {
|
|
67
|
-
throw path.buildCodeFrameError("Vasille: Argument of calculate cannot have parameters");
|
|
68
|
-
}
|
|
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));
|
|
71
|
-
return [call, t.arrayExpression([...exprData.found.values()])];
|
|
72
|
-
}
|
|
73
|
-
throw path.buildCodeFrameError("Vasille: Argument of calculate must be a function");
|
|
74
|
-
}
|
|
75
|
-
function parseCalculateCall(path, internal) {
|
|
76
|
-
if (t.isCallExpression(path.node) && (0, call_js_1.calls)(path, ["calculate", "watch"], internal)) {
|
|
77
|
-
return processCalculateCall(path, internal);
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
function exprCall(path, expr, internal, name) {
|
|
82
|
-
const calculateCall = parseCalculateCall(path, internal);
|
|
83
|
-
if (calculateCall) {
|
|
84
|
-
return named(t.callExpression(internal.stateOnly
|
|
85
|
-
? t.memberExpression(internal.id, t.identifier("ex"))
|
|
86
|
-
: t.memberExpression(internal_js_1.ctx, t.identifier("expr")), calculateCall), name, internal);
|
|
87
|
-
}
|
|
88
|
-
if (t.isCallExpression(expr) &&
|
|
89
|
-
(0, call_js_1.calls)(path, ["forward"], internal) &&
|
|
90
|
-
expr.arguments.length === 1 &&
|
|
91
|
-
t.isExpression(expr.arguments[0])) {
|
|
92
|
-
const data = exprCall(path.get("arguments")[0], expr.arguments[0], internal);
|
|
93
|
-
/* istanbul ignore else */
|
|
94
|
-
if (data && !t.isCallExpression(data)) {
|
|
95
|
-
return t.callExpression(t.memberExpression(internal.id, t.identifier("fo")), [data]);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const exprData = (0, expression_js_1.checkNode)(path, internal);
|
|
99
|
-
if (exprData.self) {
|
|
100
|
-
return exprData.self;
|
|
101
|
-
}
|
|
102
|
-
const names = [...exprData.found.keys()].map(expression_js_1.encodeName);
|
|
103
|
-
const dependencies = t.arrayExpression([...exprData.found.values()]);
|
|
104
|
-
if (expr !== path.node && names.length === 1 && t.isIdentifier(path.node) && path.node.name === names[0].name) {
|
|
105
|
-
return [...exprData.found.values()][0];
|
|
106
|
-
}
|
|
107
|
-
if (names.length > 0 && path.node) {
|
|
108
|
-
return named(t.callExpression(internal.stateOnly
|
|
109
|
-
? t.memberExpression(internal.id, t.identifier("ex"))
|
|
110
|
-
: t.memberExpression(internal_js_1.ctx, t.identifier("expr")), [t.arrowFunctionExpression(names, path.node), dependencies]), name, internal);
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
function forwardOnlyExpr(path, expr, internal) {
|
|
115
|
-
const calculateCall = parseCalculateCall(path, internal);
|
|
116
|
-
if (calculateCall) {
|
|
117
|
-
return t.callExpression(t.memberExpression(internal.id, t.identifier("ex")), calculateCall);
|
|
118
|
-
}
|
|
119
|
-
const exprData = (0, expression_js_1.checkNode)(path, internal);
|
|
120
|
-
return exprData.self
|
|
121
|
-
? t.callExpression(t.memberExpression(internal.id, t.identifier("fo")), [exprData.self])
|
|
122
|
-
: exprData.found.size > 0 && expr
|
|
123
|
-
? t.callExpression(t.memberExpression(internal.id, t.identifier("ex")), [
|
|
124
|
-
t.arrowFunctionExpression([...exprData.found.keys()].map(name => (0, expression_js_1.encodeName)(name)), expr),
|
|
125
|
-
t.arrayExpression([...exprData.found.values()]),
|
|
126
|
-
])
|
|
127
|
-
: null;
|
|
128
|
-
}
|
|
129
|
-
function own(expr, internal, name) {
|
|
130
|
-
if (internal.stateOnly &&
|
|
131
|
-
t.isCallExpression(expr) &&
|
|
132
|
-
t.isMemberExpression(expr.callee) &&
|
|
133
|
-
t.isIdentifier(expr.callee.property) &&
|
|
134
|
-
expr.callee.property.name === "fo" &&
|
|
135
|
-
t.isIdentifier(expr.callee.object) &&
|
|
136
|
-
expr.callee.object === internal.id) {
|
|
137
|
-
return expr;
|
|
138
|
-
}
|
|
139
|
-
return named(t.callExpression(internal.stateOnly
|
|
140
|
-
? t.memberExpression(internal.id, t.identifier("fo"))
|
|
141
|
-
: t.memberExpression(internal_js_1.ctx, t.identifier("own")), [expr]), name, internal);
|
|
142
|
-
}
|
|
143
|
-
function ref(expr, internal, name) {
|
|
144
|
-
return named(t.callExpression(internal.stateOnly
|
|
145
|
-
? t.memberExpression(internal.id, t.identifier("r"))
|
|
146
|
-
: t.memberExpression(internal_js_1.ctx, t.identifier("ref")), expr ? [expr] : []), name, internal, 1);
|
|
147
|
-
}
|
|
148
|
-
function reactiveObject(init, internal, name) {
|
|
149
|
-
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "sro" : "ro")), internal.stateOnly ? [init] : [internal_js_1.ctx, init]), name, internal);
|
|
150
|
-
}
|
|
151
|
-
function arrayModel(init, internal, name) {
|
|
152
|
-
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);
|
|
153
|
-
}
|
|
154
|
-
function setModel(args, internal, name) {
|
|
155
|
-
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "ssm" : "sm")), internal.stateOnly ? args : [internal_js_1.ctx, ...args]), name, internal);
|
|
156
|
-
}
|
|
157
|
-
function mapModel(args, internal, name) {
|
|
158
|
-
return named(t.callExpression(t.memberExpression(internal.id, t.identifier(internal.stateOnly ? "smm" : "mm")), internal.stateOnly ? args : [internal_js_1.ctx, ...args]), name, internal);
|
|
159
|
-
}
|