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/lib-node/mesh.js CHANGED
@@ -41,11 +41,11 @@ exports.composeStatements = composeStatements;
41
41
  exports.composeStatement = composeStatement;
42
42
  exports.compose = compose;
43
43
  const t = __importStar(require("@babel/types"));
44
- const call_js_1 = require("./call.js");
45
- const internal_js_1 = require("./internal.js");
46
- const jsx_detect_js_1 = require("./jsx-detect.js");
47
- const lib_js_1 = require("./lib.js");
48
- const jsx_js_1 = require("./jsx.js");
44
+ const call_1 = require("./call");
45
+ const internal_1 = require("./internal");
46
+ const jsx_detect_1 = require("./jsx-detect");
47
+ const lib_1 = require("./lib");
48
+ const jsx_1 = require("./jsx");
49
49
  function meshOrIgnoreAllExpressions(nodePaths, internal) {
50
50
  for (const path of nodePaths) {
51
51
  if (t.isExpression(path.node)) {
@@ -65,7 +65,7 @@ function meshComposeCall(call, name, nodePath, internal) {
65
65
  }
66
66
  const fnPath = nodePath.get("arguments")[0];
67
67
  compose(fnPath, internal, false);
68
- arg.params.unshift(internal_js_1.ctx);
68
+ arg.params.unshift(internal_1.ctx);
69
69
  if (t.isArrowFunctionExpression(arg) && internal.devMode) {
70
70
  fnPath.replaceWith(t.functionExpression(t.identifier(internal.prefix + (name ? name.name : "Default")), arg.params, t.isBlockStatement(arg.body) ? arg.body : t.blockStatement([t.returnStatement(arg.body)]), false, arg.async));
71
71
  }
@@ -104,7 +104,7 @@ function meshExpression(nodePath, internal) {
104
104
  if (!expr) {
105
105
  return;
106
106
  }
107
- if ((0, call_js_1.calls)(expr, ["compose", "extend"], internal)) {
107
+ if ((0, call_1.calls)(expr, ["compose", "extend"], internal)) {
108
108
  meshComposeCall(expr, null, nodePath, internal);
109
109
  return;
110
110
  }
@@ -141,13 +141,13 @@ function meshExpression(nodePath, internal) {
141
141
  }
142
142
  case "CallExpression": {
143
143
  const path = nodePath;
144
- const callsFn = (0, call_js_1.calls)(path.node, call_js_1.composeOnly, internal);
144
+ const callsFn = (0, call_1.calls)(path.node, call_1.composeOnly, internal);
145
145
  if (callsFn) {
146
146
  throw path.buildCodeFrameError(`Vasille: Usage of function "${callsFn}" is restricted here`);
147
147
  }
148
148
  meshOrIgnoreExpression(path.get("callee"), internal);
149
149
  meshAllUnknown(path.get("arguments"), internal);
150
- if ((0, call_js_1.calls)(path.node, ["calculate"], internal)) {
150
+ if ((0, call_1.calls)(path.node, ["calculate"], internal)) {
151
151
  if (path.node.arguments.length !== 1 && !t.isExpression(path.node.arguments[0])) {
152
152
  throw path.buildCodeFrameError("Vasille: Incorrect calculate argument");
153
153
  }
@@ -166,7 +166,7 @@ function meshExpression(nodePath, internal) {
166
166
  const left = path.node.left;
167
167
  meshLValue(path.get("left"), internal);
168
168
  if (t.isIdentifier(left) && internal.stack.get(left.name) === 4 /* VariableState.ReactivePointer */) {
169
- const replaceWith = (0, lib_js_1.forwardOnlyExpr)(path.get("right"), path.node.right, internal);
169
+ const replaceWith = (0, lib_1.forwardOnlyExpr)(path.get("right"), path.node.right, internal);
170
170
  if (replaceWith) {
171
171
  path.get("right").replaceWith(replaceWith);
172
172
  }
@@ -513,7 +513,7 @@ function meshStatement(path, internal) {
513
513
  for (const declaration of _path.get("declarations")) {
514
514
  const expr = declaration.node.init;
515
515
  let ignore = true;
516
- if (expr && t.isIdentifier(declaration.node.id) && (0, call_js_1.calls)(expr, ["compose", "extend"], internal)) {
516
+ if (expr && t.isIdentifier(declaration.node.id) && (0, call_1.calls)(expr, ["compose", "extend"], internal)) {
517
517
  meshComposeCall(expr, declaration.node.id, declaration.get("init"), internal);
518
518
  }
519
519
  else {
@@ -607,7 +607,7 @@ function composeExpression(path, internal) {
607
607
  switch (expr.type) {
608
608
  case "AssignmentExpression": {
609
609
  const assign = expr;
610
- if ((0, call_js_1.calls)(assign.right, ["awaited"], internal)) {
610
+ if ((0, call_1.calls)(assign.right, ["awaited"], internal)) {
611
611
  reactiveArrayPattern(assign.left, internal);
612
612
  }
613
613
  else {
@@ -619,27 +619,27 @@ function composeExpression(path, internal) {
619
619
  case "OptionalCallExpression": {
620
620
  const call = expr;
621
621
  let replaced = false;
622
- if ((0, call_js_1.calls)(call, ["watch"], internal)) {
623
- const args = (0, lib_js_1.parseCalculateCall)(path, internal);
622
+ if ((0, call_1.calls)(call, ["watch"], internal)) {
623
+ const args = (0, lib_1.parseCalculateCall)(path, internal);
624
624
  if (args) {
625
- path.replaceWith(t.callExpression(t.memberExpression(internal_js_1.ctx, t.identifier("watch")), args));
625
+ path.replaceWith(t.callExpression(t.memberExpression(internal_1.ctx, t.identifier("watch")), args));
626
626
  replaced = true;
627
627
  }
628
628
  }
629
- else if ((0, call_js_1.calls)(call, ["arrayModel"], internal)) {
629
+ else if ((0, call_1.calls)(call, ["arrayModel"], internal)) {
630
630
  const value = call.arguments[0];
631
631
  if (t.isArrayExpression(value)) {
632
- path.replaceWith((0, lib_js_1.arrayModel)(value, internal));
632
+ path.replaceWith((0, lib_1.arrayModel)(value, internal));
633
633
  replaced = true;
634
634
  }
635
635
  else {
636
636
  path.buildCodeFrameError(`Vasille: arrayModel requires array expression as argument`);
637
637
  }
638
638
  }
639
- else if ((0, call_js_1.calls)(call, ["mapModel", "setModel"], internal)) {
639
+ else if ((0, call_1.calls)(call, ["mapModel", "setModel"], internal)) {
640
640
  const args = call.arguments;
641
- const name = (0, call_js_1.calls)(call, ["mapModel", "setModel"], internal);
642
- path.replaceWith(name === "mapModel" ? (0, lib_js_1.mapModel)(args, internal) : (0, lib_js_1.setModel)(args, internal));
641
+ const name = (0, call_1.calls)(call, ["mapModel", "setModel"], internal);
642
+ path.replaceWith(name === "mapModel" ? (0, lib_1.mapModel)(args, internal) : (0, lib_1.setModel)(args, internal));
643
643
  replaced = true;
644
644
  }
645
645
  if (!replaced) {
@@ -649,7 +649,7 @@ function composeExpression(path, internal) {
649
649
  }
650
650
  case "JSXElement":
651
651
  case "JSXFragment":
652
- path.replaceWithMultiple((0, jsx_js_1.transformJsx)(path, internal));
652
+ path.replaceWithMultiple((0, jsx_1.transformJsx)(path, internal));
653
653
  break;
654
654
  default:
655
655
  meshExpression(path, internal);
@@ -669,7 +669,7 @@ function composeStatement(path, internal) {
669
669
  case "FunctionDeclaration": {
670
670
  const _path = path;
671
671
  const fn = _path.node;
672
- if ((0, jsx_detect_js_1.bodyHasJsx)(fn.body)) {
672
+ if ((0, jsx_detect_1.bodyHasJsx)(fn.body)) {
673
673
  compose(_path, internal, false);
674
674
  }
675
675
  else {
@@ -771,7 +771,7 @@ function composeStatement(path, internal) {
771
771
  const id = declaration.node.id;
772
772
  let meshInit = true;
773
773
  ignoreParams(declaration.node.id, internal);
774
- if ((0, call_js_1.calls)(declaration.node.init, ["awaited"], internal)) {
774
+ if ((0, call_1.calls)(declaration.node.init, ["awaited"], internal)) {
775
775
  reactiveArrayPattern(declaration.node.id, internal);
776
776
  meshAllUnknown(declaration.get("init").get("arguments"), internal);
777
777
  meshInit = false;
@@ -779,20 +779,20 @@ function composeStatement(path, internal) {
779
779
  else if (t.isIdentifier(id)) {
780
780
  internal.stack.set(id.name, declares);
781
781
  const init = declaration.node.init;
782
- if ((0, call_js_1.calls)(init, ["value"], internal)) {
782
+ if ((0, call_1.calls)(init, ["value"], internal)) {
783
783
  internal.stack.set(id.name, 1 /* VariableState.Ignored */);
784
784
  declaration.get("init").replaceWith(init.arguments[0]);
785
785
  _path.node.kind = kind;
786
786
  }
787
- else if ((0, call_js_1.calls)(init, ["bind"], internal)) {
787
+ else if ((0, call_1.calls)(init, ["bind"], internal)) {
788
788
  const argument = init.arguments[0];
789
789
  const replaceWith = declares === 2 /* VariableState.Reactive */
790
- ? (0, lib_js_1.forwardOnlyExpr)(declaration.get("init"), argument, internal)
791
- : (0, lib_js_1.exprCall)(declaration.get("init"), argument, internal);
792
- let insertNode = replaceWith !== null && replaceWith !== void 0 ? replaceWith : (0, lib_js_1.ref)(t.isExpression(argument) ? argument : null);
790
+ ? (0, lib_1.forwardOnlyExpr)(declaration.get("init"), argument, internal)
791
+ : (0, lib_1.exprCall)(declaration.get("init"), argument, internal);
792
+ let insertNode = replaceWith !== null && replaceWith !== void 0 ? replaceWith : (0, lib_1.ref)(t.isExpression(argument) ? argument : null);
793
793
  if (declares === 2 /* VariableState.Reactive */) {
794
794
  internal.stack.set(id.name, 4 /* VariableState.ReactivePointer */);
795
- insertNode = (0, lib_js_1.own)(insertNode);
795
+ insertNode = (0, lib_1.own)(insertNode);
796
796
  }
797
797
  else {
798
798
  internal.stack.set(id.name, 2 /* VariableState.Reactive */);
@@ -800,58 +800,58 @@ function composeStatement(path, internal) {
800
800
  declaration.get("init").replaceWith(insertNode);
801
801
  meshInit = !replaceWith;
802
802
  }
803
- else if ((0, call_js_1.calls)(init, ["ref"], internal)) {
803
+ else if ((0, call_1.calls)(init, ["ref"], internal)) {
804
804
  const argument = init.arguments[0];
805
805
  internal.stack.set(id.name, 2 /* VariableState.Reactive */);
806
- declaration.get("init").replaceWith((0, lib_js_1.ref)(t.isExpression(argument) ? argument : null));
806
+ declaration.get("init").replaceWith((0, lib_1.ref)(t.isExpression(argument) ? argument : null));
807
807
  }
808
- else if ((0, call_js_1.calls)(init, ["reactiveObject"], internal)) {
808
+ else if ((0, call_1.calls)(init, ["reactiveObject"], internal)) {
809
809
  const value = init.arguments[0];
810
810
  if (kind !== "const") {
811
811
  declaration.buildCodeFrameError(`Vasille: Reactive objects must be must be declared as constants`);
812
812
  }
813
813
  if (t.isObjectExpression(value)) {
814
- declaration.get("init").replaceWith((0, lib_js_1.reactiveObject)(value, internal));
814
+ declaration.get("init").replaceWith((0, lib_1.reactiveObject)(value, internal));
815
815
  internal.stack.set(id.name, 3 /* VariableState.ReactiveObject */);
816
816
  }
817
817
  else {
818
818
  declaration.buildCodeFrameError(`Vasille: reactiveObject requires object expression as argument`);
819
819
  }
820
820
  }
821
- else if ((0, call_js_1.calls)(init, ["arrayModel"], internal)) {
821
+ else if ((0, call_1.calls)(init, ["arrayModel"], internal)) {
822
822
  const value = init.arguments[0];
823
823
  if (kind !== "const") {
824
824
  declaration.buildCodeFrameError(`Vasille: Array models must be must be declared as constants`);
825
825
  }
826
826
  if (t.isArrayExpression(value)) {
827
- declaration.get("init").replaceWith((0, lib_js_1.arrayModel)(value, internal));
827
+ declaration.get("init").replaceWith((0, lib_1.arrayModel)(value, internal));
828
828
  }
829
829
  else {
830
830
  declaration.buildCodeFrameError(`Vasille: arrayModel requires array expression as argument`);
831
831
  }
832
832
  }
833
- else if ((0, call_js_1.calls)(init, ["mapModel", "setModel"], internal)) {
833
+ else if ((0, call_1.calls)(init, ["mapModel", "setModel"], internal)) {
834
834
  const args = init.arguments;
835
- const name = (0, call_js_1.calls)(init, ["mapModel", "setModel"], internal);
835
+ const name = (0, call_1.calls)(init, ["mapModel", "setModel"], internal);
836
836
  if (kind !== "const") {
837
837
  declaration.buildCodeFrameError(`Vasille: ${name === "mapModel" ? "Map" : "Set"} models must be declared as constants`);
838
838
  }
839
839
  declaration
840
840
  .get("init")
841
- .replaceWith(name === "mapModel" ? (0, lib_js_1.mapModel)(args, internal) : (0, lib_js_1.setModel)(args, internal));
841
+ .replaceWith(name === "mapModel" ? (0, lib_1.mapModel)(args, internal) : (0, lib_1.setModel)(args, internal));
842
842
  }
843
843
  else if (t.isObjectExpression(init)) {
844
844
  if (kind !== "const") {
845
845
  declaration.buildCodeFrameError(`Vasille: Objects must be must be declared as constants`);
846
846
  }
847
- declaration.get("init").replaceWith((0, lib_js_1.reactiveObject)(init, internal));
847
+ declaration.get("init").replaceWith((0, lib_1.reactiveObject)(init, internal));
848
848
  internal.stack.set(id.name, 3 /* VariableState.ReactiveObject */);
849
849
  }
850
850
  else if (t.isArrayExpression(init)) {
851
851
  if (kind !== "const") {
852
852
  declaration.buildCodeFrameError(`Vasille: Arrays must be must be declared as constants`);
853
853
  }
854
- declaration.get("init").replaceWith((0, lib_js_1.arrayModel)(init, internal));
854
+ declaration.get("init").replaceWith((0, lib_1.arrayModel)(init, internal));
855
855
  }
856
856
  else if (t.isNewExpression(init) && t.isIdentifier(init.callee)) {
857
857
  if (init.callee.name === "Map" || init.callee.name === "Set") {
@@ -860,17 +860,17 @@ function composeStatement(path, internal) {
860
860
  }
861
861
  declaration
862
862
  .get("init")
863
- .replaceWith(init.callee.name === "Map" ? (0, lib_js_1.mapModel)(init.arguments, internal) : (0, lib_js_1.setModel)(init.arguments, internal));
863
+ .replaceWith(init.callee.name === "Map" ? (0, lib_1.mapModel)(init.arguments, internal) : (0, lib_1.setModel)(init.arguments, internal));
864
864
  }
865
865
  }
866
866
  else if (declares === 2 /* VariableState.Reactive */) {
867
- const replaceWith = (0, lib_js_1.forwardOnlyExpr)(declaration.get("init"), declaration.node.init, internal);
867
+ const replaceWith = (0, lib_1.forwardOnlyExpr)(declaration.get("init"), declaration.node.init, internal);
868
868
  meshInit = !replaceWith;
869
869
  internal.stack.set(id.name, replaceWith ? 4 /* VariableState.ReactivePointer */ : 2 /* VariableState.Reactive */);
870
- declaration.get("init").replaceWith(replaceWith ? (0, lib_js_1.own)(replaceWith) : (0, lib_js_1.ref)(declaration.node.init));
870
+ declaration.get("init").replaceWith(replaceWith ? (0, lib_1.own)(replaceWith) : (0, lib_1.ref)(declaration.node.init));
871
871
  }
872
872
  else {
873
- const replaceWith = (0, lib_js_1.exprCall)(declaration.get("init"), declaration.node.init, internal);
873
+ const replaceWith = (0, lib_1.exprCall)(declaration.get("init"), declaration.node.init, internal);
874
874
  if (replaceWith) {
875
875
  declaration.get("init").replaceWith(replaceWith);
876
876
  }
@@ -25,9 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.trProgram = trProgram;
27
27
  const t = __importStar(require("@babel/types"));
28
- const internal_js_1 = require("./internal.js");
29
- const mesh_js_1 = require("./mesh.js");
30
- const imports = new Map([["vasille-dx", "VasilleDX"], ["vasille-web", "VasilleWeb"]]);
28
+ const internal_1 = require("./internal");
29
+ const mesh_1 = require("./mesh");
30
+ const imports = new Map([
31
+ ["vasille-dx", "VasilleDX"],
32
+ ["vasille-web", "VasilleWeb"],
33
+ ]);
31
34
  const ignoreMembers = new Set([
32
35
  "value",
33
36
  "ref",
@@ -52,7 +55,7 @@ function trProgram(path, devMode) {
52
55
  set id(expr) {
53
56
  id = expr;
54
57
  },
55
- stack: new internal_js_1.StackedStates(),
58
+ stack: new internal_1.StackedStates(),
56
59
  mapping: new Map(),
57
60
  global: "",
58
61
  prefix: "Vasille_",
@@ -95,7 +98,7 @@ function trProgram(path, devMode) {
95
98
  if (!id) {
96
99
  return;
97
100
  }
98
- (0, mesh_js_1.meshStatement)(statementPath, internal);
101
+ (0, mesh_1.meshStatement)(statementPath, internal);
99
102
  }
100
103
  }
101
104
  if (internal.internalUsed && !internal.global && internal.importStatement) {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "babel-plugin-vasille",
3
- "version": "0.99.0",
3
+ "version": "0.99.2",
4
4
  "description": "",
5
- "main": "lib/index.js",
6
- "type": "module",
5
+ "main": "lib-node/index.js",
6
+ "type": "commonjs",
7
7
  "exports": {
8
- "import": "./lib/index.js",
8
+ "import": "./lib-node/index.js",
9
9
  "browser": "./lib/index.js",
10
10
  "node": "./lib-node/index.js",
11
11
  "require": "./lib-node/index.js"
@@ -25,8 +25,12 @@
25
25
  ],
26
26
  "author": "lixcode",
27
27
  "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/vasille-js/vasille-js/issues"
30
+ },
31
+ "homepage": "https://github.com/vasille-js/vasille-js#readme",
28
32
  "dependencies": {
29
- "vasille-dx": "^3.0.1"
33
+ "vasille-dx": "^3.0.3"
30
34
  },
31
35
  "devDependencies": {
32
36
  "@babel/parser": "^7.26.1",