babel-plugin-vasille 0.99.0 → 0.99.2

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 CHANGED
@@ -29,7 +29,7 @@ npm install vasille-web --save
29
29
  Create an app from a template
30
30
 
31
31
  ```bash
32
- $ npx create vasille
32
+ $ npm create vasille
33
33
  ```
34
34
 
35
35
  Alternative method to create a TypeScript app.
@@ -47,7 +47,7 @@ $ npx degit vasille-js/example-javascript my-project
47
47
 
48
48
  ### Examples
49
49
  * [TypeScript Example](https://github.com/vasille-js/example-typescript)
50
- * [JavaScript Example](https://github.com/vas[README.md](..%2Ftest%2Fmy-app%2FREADME.md)ille-js/example-javascript)
50
+ * [JavaScript Example](https://github.com/vasille-js/example-javascript)
51
51
 
52
52
  <hr>
53
53
 
package/lib/call.js CHANGED
@@ -1,6 +1,33 @@
1
- import * as t from "@babel/types";
2
- import { ctx } from "./internal.js";
3
- export const composeOnly = [
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.requiresContext = exports.composeOnly = void 0;
27
+ exports.calls = calls;
28
+ const t = __importStar(require("@babel/types"));
29
+ const internal_1 = require("./internal");
30
+ exports.composeOnly = [
4
31
  "forward",
5
32
  "watch",
6
33
  "ref",
@@ -11,9 +38,9 @@ export const composeOnly = [
11
38
  "setModel",
12
39
  "reactiveObject",
13
40
  ];
14
- export const requiresContext = ["awaited", "forward"];
15
- const requiresContextSet = new Set(requiresContext);
16
- export function calls(node, names, internal) {
41
+ exports.requiresContext = ["awaited", "forward"];
42
+ const requiresContextSet = new Set(exports.requiresContext);
43
+ function calls(node, names, internal) {
17
44
  const set = new Set(names);
18
45
  const callee = t.isCallExpression(node) ? node.callee : null;
19
46
  if (callee) {
@@ -21,7 +48,7 @@ export function calls(node, names, internal) {
21
48
  const mapped = internal.mapping.get(callee.name);
22
49
  if (mapped && set.has(mapped) && internal.stack.get(callee.name) === undefined) {
23
50
  if (requiresContextSet.has(callee.name) && t.isCallExpression(node)) {
24
- node.arguments.unshift(ctx);
51
+ node.arguments.unshift(internal_1.ctx);
25
52
  }
26
53
  return mapped;
27
54
  }
@@ -41,7 +68,7 @@ export function calls(node, names, internal) {
41
68
  if (t.isMemberExpression(callee) && t.isIdentifier(callee.object) && propName) {
42
69
  if (callee.object.name === internal.global && set.has(propName)) {
43
70
  if (requiresContextSet.has(callee.object.name) && t.isCallExpression(node)) {
44
- node.arguments.unshift(ctx);
71
+ node.arguments.unshift(internal_1.ctx);
45
72
  }
46
73
  return callee.object.name;
47
74
  }
package/lib/expression.js CHANGED
@@ -1,6 +1,41 @@
1
- import * as t from "@babel/types";
2
- import { StackedStates } from "./internal.js";
3
- export function encodeName(name) {
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.encodeName = encodeName;
27
+ exports.checkNode = checkNode;
28
+ exports.checkOrIgnoreAllExpressions = checkOrIgnoreAllExpressions;
29
+ exports.checkAllExpressions = checkAllExpressions;
30
+ exports.checkAllUnknown = checkAllUnknown;
31
+ exports.chekOrIgnoreExpression = chekOrIgnoreExpression;
32
+ exports.checkExpression = checkExpression;
33
+ exports.checkStatements = checkStatements;
34
+ exports.checkStatement = checkStatement;
35
+ exports.checkFunction = checkFunction;
36
+ const t = __importStar(require("@babel/types"));
37
+ const internal_1 = require("./internal");
38
+ function encodeName(name) {
4
39
  return t.identifier(`Vasille_${name}`);
5
40
  }
6
41
  function addIdentifier(path, search) {
@@ -84,12 +119,12 @@ function meshLValue(path, internal) {
84
119
  });
85
120
  }
86
121
  }
87
- export function checkNode(path, internal) {
122
+ function checkNode(path, internal) {
88
123
  const search = {
89
124
  external: internal,
90
125
  found: new Map(),
91
126
  self: null,
92
- stack: new StackedStates(),
127
+ stack: new internal_1.StackedStates(),
93
128
  };
94
129
  if (t.isIdentifier(path.node)) {
95
130
  const state = internal.stack.get(path.node.name);
@@ -114,19 +149,19 @@ export function checkNode(path, internal) {
114
149
  }
115
150
  return search;
116
151
  }
117
- export function checkOrIgnoreAllExpressions(nodePaths, search) {
152
+ function checkOrIgnoreAllExpressions(nodePaths, search) {
118
153
  for (const path of nodePaths) {
119
154
  if (t.isExpression(path.node)) {
120
155
  checkExpression(path, search);
121
156
  }
122
157
  }
123
158
  }
124
- export function checkAllExpressions(nodePaths, search) {
159
+ function checkAllExpressions(nodePaths, search) {
125
160
  for (const path of nodePaths) {
126
161
  checkExpression(path, search);
127
162
  }
128
163
  }
129
- export function checkAllUnknown(paths, internal) {
164
+ function checkAllUnknown(paths, internal) {
130
165
  for (const path of paths) {
131
166
  if (t.isSpreadElement(path.node)) {
132
167
  checkExpression(path.get("argument"), internal);
@@ -136,12 +171,12 @@ export function checkAllUnknown(paths, internal) {
136
171
  }
137
172
  }
138
173
  }
139
- export function chekOrIgnoreExpression(path, search) {
174
+ function chekOrIgnoreExpression(path, search) {
140
175
  if (t.isExpression(path.node)) {
141
176
  checkExpression(path, search);
142
177
  }
143
178
  }
144
- export function checkExpression(nodePath, search) {
179
+ function checkExpression(nodePath, search) {
145
180
  const expr = nodePath.node;
146
181
  if (!expr) {
147
182
  return;
@@ -342,7 +377,7 @@ export function checkExpression(nodePath, search) {
342
377
  }
343
378
  }
344
379
  }
345
- export function checkStatements(paths, search) {
380
+ function checkStatements(paths, search) {
346
381
  for (const path of paths) {
347
382
  checkStatement(path, search);
348
383
  }
@@ -377,7 +412,7 @@ function ignoreLocals(val, search) {
377
412
  }
378
413
  }
379
414
  }
380
- export function checkStatement(path, search) {
415
+ function checkStatement(path, search) {
381
416
  const statement = path.node;
382
417
  if (!statement) {
383
418
  return;
@@ -505,7 +540,7 @@ export function checkStatement(path, search) {
505
540
  }
506
541
  }
507
542
  }
508
- export function checkFunction(path, search) {
543
+ function checkFunction(path, search) {
509
544
  const node = path.node;
510
545
  if (t.isExpression(node.body)) {
511
546
  checkExpression(path.get("body"), search);
package/lib/index.js CHANGED
@@ -1,10 +1,13 @@
1
- import { trProgram } from "./transformer.js";
2
- export default function () {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const transformer_1 = require("./transformer");
5
+ function default_1() {
3
6
  return {
4
7
  name: "Vasille",
5
8
  visitor: {
6
9
  Program(path, params) {
7
- trProgram(path, params.devMode !== false);
10
+ (0, transformer_1.trProgram)(path, params.opts.devMode !== false);
8
11
  },
9
12
  },
10
13
  };
package/lib/internal.js CHANGED
@@ -1,5 +1,31 @@
1
- import * as t from "@babel/types";
2
- export class StackedStates {
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ctx = exports.StackedStates = void 0;
27
+ const t = __importStar(require("@babel/types"));
28
+ class StackedStates {
3
29
  constructor() {
4
30
  this.maps = [];
5
31
  this.push();
@@ -22,4 +48,5 @@ export class StackedStates {
22
48
  this.maps[this.maps.length - 1].set(name, state);
23
49
  }
24
50
  }
25
- export const ctx = t.identifier("Vasille");
51
+ exports.StackedStates = StackedStates;
52
+ exports.ctx = t.identifier("Vasille");
package/lib/jsx-detect.js CHANGED
@@ -1,5 +1,33 @@
1
- import * as t from "@babel/types";
2
- export function exprHasJsx(node) {
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.exprHasJsx = exprHasJsx;
27
+ exports.statementHasJsx = statementHasJsx;
28
+ exports.bodyHasJsx = bodyHasJsx;
29
+ const t = __importStar(require("@babel/types"));
30
+ function exprHasJsx(node) {
3
31
  if (t.isBinaryExpression(node)) {
4
32
  return (t.isExpression(node.left) && exprHasJsx(node.left)) || exprHasJsx(node.right);
5
33
  }
@@ -20,7 +48,7 @@ export function exprHasJsx(node) {
20
48
  }
21
49
  return t.isJSXElement(node) || t.isJSXFragment(node);
22
50
  }
23
- export function statementHasJsx(statement) {
51
+ function statementHasJsx(statement) {
24
52
  if (t.isExpressionStatement(statement)) {
25
53
  return exprHasJsx(statement.expression);
26
54
  }
@@ -52,7 +80,7 @@ export function statementHasJsx(statement) {
52
80
  }
53
81
  return false;
54
82
  }
55
- export function bodyHasJsx(node) {
83
+ function bodyHasJsx(node) {
56
84
  if (t.isExpression(node)) {
57
85
  return exprHasJsx(node);
58
86
  }