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/mesh.js CHANGED
@@ -1,22 +1,73 @@
1
- import * as t from "@babel/types";
2
- import { calls, composeOnly, styleOnly } from "./call.js";
3
- import { idIsIValue, memberIsIValue, nodeIsReactiveObject } from "./expression.js";
4
- import { ctx } from "./internal.js";
5
- import { transformJsx } from "./jsx.js";
6
- import { arrayModel, exprCall, forwardOnlyExpr, mapModel, named, own, parseCalculateCall, reactiveObject, ref, setModel, } from "./lib.js";
7
- export function meshOrIgnoreAllExpressions(nodePaths, internal) {
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.meshOrIgnoreAllExpressions = meshOrIgnoreAllExpressions;
37
+ exports.meshAllExpressions = meshAllExpressions;
38
+ exports.meshComposeCall = meshComposeCall;
39
+ exports.meshAllUnknown = meshAllUnknown;
40
+ exports.meshLValue = meshLValue;
41
+ exports.meshOrIgnoreExpression = meshOrIgnoreExpression;
42
+ exports.meshExpression = meshExpression;
43
+ exports.meshStatements = meshStatements;
44
+ exports.ignoreParams = ignoreParams;
45
+ exports.reactiveArrayPattern = reactiveArrayPattern;
46
+ exports.meshStatement = meshStatement;
47
+ exports.meshFunction = meshFunction;
48
+ exports.composeExpression = composeExpression;
49
+ exports.composeStatements = composeStatements;
50
+ exports.composeStatement = composeStatement;
51
+ exports.compose = compose;
52
+ const t = __importStar(require("@babel/types"));
53
+ const call_js_1 = require("./call.js");
54
+ const expression_js_1 = require("./expression.js");
55
+ const internal_js_1 = require("./internal.js");
56
+ const jsx_js_1 = require("./jsx.js");
57
+ const lib_js_1 = require("./lib.js");
58
+ function meshOrIgnoreAllExpressions(nodePaths, internal) {
8
59
  for (const path of nodePaths) {
9
60
  if (t.isExpression(path.node)) {
10
61
  meshExpression(path, internal);
11
62
  }
12
63
  }
13
64
  }
14
- export function meshAllExpressions(nodePaths, internal) {
65
+ function meshAllExpressions(nodePaths, internal) {
15
66
  for (const path of nodePaths) {
16
67
  meshExpression(path, internal);
17
68
  }
18
69
  }
19
- export function meshComposeCall(call, name, nodePath, internal) {
70
+ function meshComposeCall(call, name, nodePath, internal) {
20
71
  const arg = call.arguments[0];
21
72
  if (call.arguments.length !== 1 || !(t.isFunctionExpression(arg) || t.isArrowFunctionExpression(arg))) {
22
73
  throw nodePath.buildCodeFrameError("Vasille: Invalid arguments");
@@ -24,16 +75,13 @@ export function meshComposeCall(call, name, nodePath, internal) {
24
75
  const fnPath = nodePath.get("arguments")[0];
25
76
  compose(fnPath, internal, false);
26
77
  if (!internal.stateOnly) {
27
- arg.params.unshift(ctx);
78
+ arg.params.unshift(internal_js_1.ctx);
28
79
  }
29
80
  if (internal.devMode) {
30
81
  call.arguments.push(t.stringLiteral(`${internal.prefix}:${name ? name.name : "#anonymouse"}`));
31
82
  }
32
- if (t.isIdentifier(call.callee) && call.callee.name === "state") {
33
- nodePath.replaceWith(call.arguments[0]);
34
- }
35
83
  }
36
- export function meshAllUnknown(paths, internal) {
84
+ function meshAllUnknown(paths, internal) {
37
85
  for (const path of paths) {
38
86
  if (t.isSpreadElement(path.node)) {
39
87
  meshExpression(path.get("argument"), internal);
@@ -43,23 +91,23 @@ export function meshAllUnknown(paths, internal) {
43
91
  }
44
92
  }
45
93
  }
46
- export function meshLValue(path, internal) {
94
+ function meshLValue(path, internal) {
47
95
  const node = path.node;
48
96
  if (t.isExpression(node)) {
49
97
  meshExpression(path, internal);
50
98
  }
51
99
  }
52
- export function meshOrIgnoreExpression(path, internal) {
100
+ function meshOrIgnoreExpression(path, internal) {
53
101
  if (t.isExpression(path.node)) {
54
102
  meshExpression(path, internal);
55
103
  }
56
104
  }
57
- export function meshExpression(nodePath, internal, isRoot) {
105
+ function meshExpression(nodePath, internal, isRoot) {
58
106
  const expr = nodePath.node;
59
107
  if (!expr) {
60
108
  return;
61
109
  }
62
- if (calls(expr, ["compose", "extend", "state"], internal)) {
110
+ if ((0, call_js_1.calls)(expr, ["compose", "store"], internal)) {
63
111
  meshComposeCall(expr, null, nodePath, internal);
64
112
  return;
65
113
  }
@@ -76,7 +124,7 @@ export function meshExpression(nodePath, internal, isRoot) {
76
124
  }
77
125
  case "Identifier": {
78
126
  const state = internal.stack.get(expr.name);
79
- if (idIsIValue(nodePath, internal)) {
127
+ if ((0, expression_js_1.idIsIValue)(nodePath, internal)) {
80
128
  nodePath.replaceWith(t.memberExpression(expr, t.identifier(state === 4 /* VariableState.ReactivePointer */ ? "$$" : "$")));
81
129
  }
82
130
  break;
@@ -89,8 +137,8 @@ export function meshExpression(nodePath, internal, isRoot) {
89
137
  case "CallExpression":
90
138
  case "OptionalCallExpression": {
91
139
  const path = nodePath;
92
- const callsFn = calls(path.node, composeOnly, internal);
93
- const callsStyleHint = calls(path.node, styleOnly, internal);
140
+ const callsFn = (0, call_js_1.calls)(path.node, call_js_1.composeOnly, internal);
141
+ const callsStyleHint = (0, call_js_1.calls)(path.node, call_js_1.styleOnly, internal);
94
142
  if (callsFn) {
95
143
  throw path.buildCodeFrameError(`Vasille: Usage of hint "${callsFn}" is restricted here`);
96
144
  }
@@ -99,7 +147,7 @@ export function meshExpression(nodePath, internal, isRoot) {
99
147
  }
100
148
  meshOrIgnoreExpression(path.get("callee"), internal);
101
149
  meshAllUnknown(path.get("arguments"), internal);
102
- if (calls(path.node, ["calculate"], internal)) {
150
+ if ((0, call_js_1.calls)(path.node, ["calculate"], internal)) {
103
151
  if (path.node.arguments.length === 1 &&
104
152
  (t.isFunctionExpression(path.node.arguments[0]) || t.isArrowFunctionExpression(path.node.arguments[0]))) {
105
153
  path.replaceWith(t.callExpression(path.node.arguments[0], []));
@@ -116,7 +164,7 @@ export function meshExpression(nodePath, internal, isRoot) {
116
164
  let replaced = false;
117
165
  meshLValue(path.get("left"), internal);
118
166
  if (t.isIdentifier(left) && internal.stack.get(left.name) === 4 /* VariableState.ReactivePointer */) {
119
- const replaceWith = forwardOnlyExpr(path.get("right"), path.node.right, internal);
167
+ const replaceWith = (0, lib_js_1.forwardOnlyExpr)(path.get("right"), path.node.right, internal);
120
168
  if (replaceWith) {
121
169
  path.get("right").replaceWith(replaceWith);
122
170
  replaced = true;
@@ -136,7 +184,7 @@ export function meshExpression(nodePath, internal, isRoot) {
136
184
  if (t.isExpression(property) && !t.isIdentifier(property)) {
137
185
  meshOrIgnoreExpression(path.get("property"), internal);
138
186
  }
139
- if (memberIsIValue(node, internal)) {
187
+ if ((0, expression_js_1.memberIsIValue)(node, internal)) {
140
188
  path.replaceWith(t.memberExpression(node, t.identifier("$")));
141
189
  }
142
190
  break;
@@ -224,7 +272,7 @@ export function meshExpression(nodePath, internal, isRoot) {
224
272
  !path.node.computed &&
225
273
  t.isIdentifier(path.node.key) &&
226
274
  t.isExpression(valuePath.node)) {
227
- const call = exprCall(valuePath, valuePath.node, internal);
275
+ const call = (0, lib_js_1.exprCall)(valuePath, valuePath.node, internal);
228
276
  if (call) {
229
277
  if (path.node.key.name.startsWith("$")) {
230
278
  valuePath.replaceWith(call);
@@ -276,12 +324,12 @@ export function meshExpression(nodePath, internal, isRoot) {
276
324
  }
277
325
  }
278
326
  }
279
- export function meshStatements(paths, internal) {
327
+ function meshStatements(paths, internal) {
280
328
  for (const path of paths) {
281
329
  meshStatement(path, internal);
282
330
  }
283
331
  }
284
- export function ignoreParams(val, internal) {
332
+ function ignoreParams(val, internal) {
285
333
  if (t.isAssignmentPattern(val)) {
286
334
  val = val.left;
287
335
  }
@@ -317,7 +365,7 @@ function ignoreObjectPattern(pattern, internal) {
317
365
  }
318
366
  }
319
367
  }
320
- export function reactiveArrayPattern(path, internal) {
368
+ function reactiveArrayPattern(path, internal) {
321
369
  if (t.isArrayPattern(path.node)) {
322
370
  path.node.elements.forEach((element, index) => {
323
371
  if (t.isIdentifier(element)) {
@@ -360,7 +408,7 @@ function meshClassBody(path, internal) {
360
408
  }
361
409
  }
362
410
  }
363
- export function meshStatement(path, internal) {
411
+ function meshStatement(path, internal) {
364
412
  const statement = path.node;
365
413
  switch (statement && statement.type) {
366
414
  case "BlockStatement":
@@ -448,7 +496,7 @@ export function meshStatement(path, internal) {
448
496
  const _path = path;
449
497
  for (const declaration of _path.get("declarations")) {
450
498
  const expr = declaration.node.init;
451
- if (expr && t.isIdentifier(declaration.node.id) && calls(expr, ["compose", "extend", "state"], internal)) {
499
+ if (expr && t.isIdentifier(declaration.node.id) && (0, call_js_1.calls)(expr, ["compose", "store"], internal)) {
452
500
  meshComposeCall(expr, declaration.node.id, declaration.get("init"), internal);
453
501
  }
454
502
  else {
@@ -487,7 +535,7 @@ export function meshStatement(path, internal) {
487
535
  }
488
536
  }
489
537
  }
490
- export function meshFunction(path, internal) {
538
+ function meshFunction(path, internal) {
491
539
  if (t.isFunctionDeclaration(path.node) && path.node.id) {
492
540
  internal.stack.set(path.node.id.name, 1 /* VariableState.Ignored */);
493
541
  }
@@ -508,7 +556,7 @@ export function meshFunction(path, internal) {
508
556
  }
509
557
  internal.stack.pop();
510
558
  }
511
- export function composeExpression(path, internal, isRoot) {
559
+ function composeExpression(path, internal, isRoot) {
512
560
  const expr = path.node;
513
561
  switch (expr && expr.type) {
514
562
  case "AssignmentExpression": {
@@ -518,11 +566,11 @@ export function composeExpression(path, internal, isRoot) {
518
566
  case "CallExpression":
519
567
  case "OptionalCallExpression": {
520
568
  const call = expr;
521
- if (calls(call, ["watch"], internal)) {
522
- const args = parseCalculateCall(path, internal);
569
+ if ((0, call_js_1.calls)(call, ["watch"], internal)) {
570
+ const args = (0, lib_js_1.parseCalculateCall)(path, internal);
523
571
  if (args) {
524
572
  if (args[1].elements.length > 0) {
525
- path.replaceWith(t.callExpression(t.memberExpression(ctx, t.identifier("watch")), args));
573
+ path.replaceWith(t.callExpression(t.memberExpression(internal_js_1.ctx, t.identifier("watch")), args));
526
574
  }
527
575
  else {
528
576
  path.replaceWith(t.callExpression(args[0], []));
@@ -548,18 +596,18 @@ export function composeExpression(path, internal, isRoot) {
548
596
  if (internal.stateOnly) {
549
597
  throw path.buildCodeFrameError("Vasille: JSX is not allowed in states");
550
598
  }
551
- path.replaceWithMultiple(transformJsx(path, internal));
599
+ path.replaceWithMultiple((0, jsx_js_1.transformJsx)(path, internal));
552
600
  break;
553
601
  default:
554
602
  meshExpression(path, internal, isRoot);
555
603
  }
556
604
  }
557
- export function composeStatements(paths, internal, isRoot) {
605
+ function composeStatements(paths, internal, isRoot) {
558
606
  for (const path of paths) {
559
607
  composeStatement(path, internal, isRoot);
560
608
  }
561
609
  }
562
- export function composeStatement(path, internal, isRoot) {
610
+ function composeStatement(path, internal, isRoot) {
563
611
  const statement = path.node;
564
612
  if (!statement) {
565
613
  return;
@@ -659,35 +707,35 @@ export function composeStatement(path, internal, isRoot) {
659
707
  return [idName(pattern.elements[0]), idName(pattern.elements[1])];
660
708
  }
661
709
  ignoreParams(declaration.node.id, internal);
662
- if (calls(declaration.node.init, ["awaited"], internal)) {
710
+ if ((0, call_js_1.calls)(declaration.node.init, ["awaited"], internal)) {
663
711
  reactiveArrayPattern(declaration.get("id"), internal);
664
712
  meshAllUnknown(declaration.get("init").get("arguments"), internal);
665
- named(declaration.node.init, idDoubleName(), internal);
713
+ (0, lib_js_1.named)(declaration.node.init, idDoubleName(), internal);
666
714
  meshInit = false;
667
715
  }
668
716
  else if (t.isIdentifier(id)) {
669
717
  internal.stack.set(id.name, declares);
670
718
  const init = declaration.node.init;
671
- if (calls(init, ["value"], internal)) {
719
+ if ((0, call_js_1.calls)(init, ["value"], internal)) {
672
720
  internal.stack.set(id.name, 1 /* VariableState.Ignored */);
673
721
  declaration.get("init").replaceWith(init.arguments[0]);
674
722
  _path.node.kind = kind;
675
723
  }
676
- else if (calls(init, ["bind"], internal)) {
724
+ else if ((0, call_js_1.calls)(init, ["bind"], internal)) {
677
725
  const argument = init.arguments[0];
678
726
  const argumentPath = declaration.get("init").get("arguments")[0];
679
727
  let replaceWith = declares === 2 /* VariableState.Reactive */
680
- ? forwardOnlyExpr(argumentPath, argument, internal)
681
- : exprCall(argumentPath, argument, internal, idName());
728
+ ? (0, lib_js_1.forwardOnlyExpr)(argumentPath, argument, internal)
729
+ : (0, lib_js_1.exprCall)(argumentPath, argument, internal, idName());
682
730
  if (!replaceWith) {
683
731
  replaceWith =
684
732
  declares === 2 /* VariableState.Reactive */
685
733
  ? t.callExpression(t.memberExpression(internal.id, t.identifier("r")), [argument])
686
- : ref(argument, internal, idName());
734
+ : (0, lib_js_1.ref)(argument, internal, idName());
687
735
  }
688
736
  if (declares === 2 /* VariableState.Reactive */) {
689
737
  internal.stack.set(id.name, 4 /* VariableState.ReactivePointer */);
690
- replaceWith = own(replaceWith, internal, idName());
738
+ replaceWith = (0, lib_js_1.own)(replaceWith, internal, idName());
691
739
  }
692
740
  else {
693
741
  internal.stack.set(id.name, 2 /* VariableState.Reactive */);
@@ -695,58 +743,58 @@ export function composeStatement(path, internal, isRoot) {
695
743
  declaration.get("init").replaceWith(replaceWith);
696
744
  meshInit = !replaceWith;
697
745
  }
698
- else if (calls(init, ["ref"], internal)) {
746
+ else if ((0, call_js_1.calls)(init, ["ref"], internal)) {
699
747
  const argument = init.arguments[0];
700
748
  internal.stack.set(id.name, 2 /* VariableState.Reactive */);
701
- declaration.get("init").replaceWith(ref(t.isExpression(argument) ? argument : null, internal, idName()));
749
+ declaration.get("init").replaceWith((0, lib_js_1.ref)(t.isExpression(argument) ? argument : null, internal, idName()));
702
750
  }
703
- else if (calls(init, ["reactiveObject"], internal)) {
751
+ else if ((0, call_js_1.calls)(init, ["reactiveObject"], internal)) {
704
752
  const value = init.arguments[0];
705
753
  if (kind !== "const") {
706
754
  throw declaration.buildCodeFrameError(`Vasille: Reactive objects must be must be declared as constants`);
707
755
  }
708
756
  if (t.isObjectExpression(value)) {
709
- declaration.get("init").replaceWith(reactiveObject(value, internal, idName()));
757
+ declaration.get("init").replaceWith((0, lib_js_1.reactiveObject)(value, internal, idName()));
710
758
  internal.stack.set(id.name, 3 /* VariableState.ReactiveObject */);
711
759
  }
712
760
  else {
713
761
  throw declaration.buildCodeFrameError(`Vasille: reactiveObject requires object expression as argument`);
714
762
  }
715
763
  }
716
- else if (calls(init, ["arrayModel"], internal)) {
764
+ else if ((0, call_js_1.calls)(init, ["arrayModel"], internal)) {
717
765
  const value = init.arguments[0];
718
766
  if (kind !== "const") {
719
767
  throw declaration.buildCodeFrameError(`Vasille: Array models must be must be declared as constants`);
720
768
  }
721
769
  if (t.isArrayExpression(value)) {
722
- declaration.get("init").replaceWith(arrayModel(value, internal, idName()));
770
+ declaration.get("init").replaceWith((0, lib_js_1.arrayModel)(value, internal, idName()));
723
771
  }
724
772
  else {
725
- declaration.get("init").replaceWith(arrayModel(null, internal, idName()));
773
+ declaration.get("init").replaceWith((0, lib_js_1.arrayModel)(null, internal, idName()));
726
774
  }
727
775
  }
728
- else if (calls(init, ["mapModel", "setModel"], internal)) {
776
+ else if ((0, call_js_1.calls)(init, ["mapModel", "setModel"], internal)) {
729
777
  const args = init.arguments;
730
- const name = calls(init, ["mapModel", "setModel"], internal);
778
+ const name = (0, call_js_1.calls)(init, ["mapModel", "setModel"], internal);
731
779
  if (kind !== "const") {
732
780
  throw declaration.buildCodeFrameError(`Vasille: ${name === "mapModel" ? "Map" : "Set"} models must be declared as constants`);
733
781
  }
734
782
  declaration
735
783
  .get("init")
736
- .replaceWith(name === "mapModel" ? mapModel(args, internal, idName()) : setModel(args, internal, idName()));
784
+ .replaceWith(name === "mapModel" ? (0, lib_js_1.mapModel)(args, internal, idName()) : (0, lib_js_1.setModel)(args, internal, idName()));
737
785
  }
738
786
  else if (t.isObjectExpression(init)) {
739
787
  if (kind !== "const") {
740
788
  throw declaration.buildCodeFrameError(`Vasille: Objects must be must be declared as constants`);
741
789
  }
742
- declaration.get("init").replaceWith(reactiveObject(init, internal, idName()));
790
+ declaration.get("init").replaceWith((0, lib_js_1.reactiveObject)(init, internal, idName()));
743
791
  internal.stack.set(id.name, 3 /* VariableState.ReactiveObject */);
744
792
  }
745
793
  else if (t.isArrayExpression(init)) {
746
794
  if (kind !== "const") {
747
795
  throw declaration.buildCodeFrameError(`Vasille: Arrays must be must be declared as constants`);
748
796
  }
749
- declaration.get("init").replaceWith(arrayModel(init, internal, idName()));
797
+ declaration.get("init").replaceWith((0, lib_js_1.arrayModel)(init, internal, idName()));
750
798
  }
751
799
  else if (t.isNewExpression(init) && t.isIdentifier(init.callee)) {
752
800
  if (init.callee.name === "Map" || init.callee.name === "Set") {
@@ -756,26 +804,26 @@ export function composeStatement(path, internal, isRoot) {
756
804
  declaration
757
805
  .get("init")
758
806
  .replaceWith(init.callee.name === "Map"
759
- ? mapModel(init.arguments, internal, idName())
760
- : setModel(init.arguments, internal, idName()));
807
+ ? (0, lib_js_1.mapModel)(init.arguments, internal, idName())
808
+ : (0, lib_js_1.setModel)(init.arguments, internal, idName()));
761
809
  }
762
810
  }
763
811
  else if (declares === 2 /* VariableState.Reactive */) {
764
- const replaceWith = forwardOnlyExpr(declaration.get("init"), declaration.node.init, internal);
812
+ const replaceWith = (0, lib_js_1.forwardOnlyExpr)(declaration.get("init"), declaration.node.init, internal);
765
813
  meshInit = !replaceWith;
766
814
  internal.stack.set(id.name, replaceWith ? 4 /* VariableState.ReactivePointer */ : 2 /* VariableState.Reactive */);
767
815
  declaration
768
816
  .get("init")
769
- .replaceWith(replaceWith ? own(replaceWith, internal, idName()) : ref(declaration.node.init, internal, idName()));
817
+ .replaceWith(replaceWith ? (0, lib_js_1.own)(replaceWith, internal, idName()) : (0, lib_js_1.ref)(declaration.node.init, internal, idName()));
770
818
  }
771
819
  else {
772
- const replaceWith = exprCall(declaration.get("init"), declaration.node.init, internal, idName());
820
+ const replaceWith = (0, lib_js_1.exprCall)(declaration.get("init"), declaration.node.init, internal, idName());
773
821
  if (replaceWith) {
774
822
  declaration.get("init").replaceWith(replaceWith);
775
823
  }
776
824
  internal.stack.set(id.name, replaceWith
777
825
  ? 2 /* VariableState.Reactive */
778
- : nodeIsReactiveObject(declaration.get("init"), internal)
826
+ : (0, expression_js_1.nodeIsReactiveObject)(declaration.get("init"), internal)
779
827
  ? 3 /* VariableState.ReactiveObject */
780
828
  : 1 /* VariableState.Ignored */);
781
829
  meshInit = !replaceWith;
@@ -807,7 +855,7 @@ export function composeStatement(path, internal, isRoot) {
807
855
  meshStatement(path, internal);
808
856
  }
809
857
  }
810
- export function compose(path, internal, isInternalSlot) {
858
+ function compose(path, internal, isInternalSlot) {
811
859
  internal.stack.push();
812
860
  const node = path.node;
813
861
  const params = node.params;
@@ -1,7 +1,43 @@
1
- import * as t from "@babel/types";
2
- import { StackedStates } from "./internal.js";
3
- import { meshStatement } from "./mesh.js";
4
- import { findStyleInNode } from "./css-transformer.js";
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,12 @@ const ignoreMembers = new Set([
21
57
  "laptop",
22
58
  "prefersDark",
23
59
  "prefersLight",
24
- "state",
25
60
  ]);
26
61
  function extractText(node) {
27
62
  // no case found for string literal
28
63
  return node.name;
29
64
  }
30
- export function trProgram(path, devMode) {
65
+ function trProgram(path, devMode) {
31
66
  let id;
32
67
  let stylesConnected = false;
33
68
  const internal = {
@@ -38,7 +73,7 @@ export function trProgram(path, devMode) {
38
73
  set id(expr) {
39
74
  id = expr;
40
75
  },
41
- stack: new StackedStates(),
76
+ stack: new internal_js_1.StackedStates(),
42
77
  mapping: new Map(),
43
78
  global: "",
44
79
  prefix: "Vasille_",
@@ -89,8 +124,8 @@ export function trProgram(path, devMode) {
89
124
  if (!id) {
90
125
  return;
91
126
  }
92
- else if (!stylesConnected || !findStyleInNode(statementPath, internal)) {
93
- meshStatement(statementPath, internal);
127
+ else if (!stylesConnected || !(0, css_transformer_js_1.findStyleInNode)(statementPath, internal)) {
128
+ (0, mesh_js_1.meshStatement)(statementPath, internal);
94
129
  }
95
130
  }
96
131
  }
package/lib-node/call.js CHANGED
@@ -71,10 +71,10 @@ function calls(node, names, internal) {
71
71
  if (requiresContextSet.has(callee.name) && t.isCallExpression(node)) {
72
72
  node.arguments.unshift(internal_js_1.ctx);
73
73
  }
74
- if (mapped === "state") {
74
+ if (mapped === "store") {
75
75
  internal.stateOnly = true;
76
76
  }
77
- if (mapped === "compose" || mapped === "extend") {
77
+ if (mapped === "compose") {
78
78
  internal.stateOnly = false;
79
79
  }
80
80
  return mapped;
package/lib-node/mesh.js CHANGED
@@ -80,9 +80,6 @@ function meshComposeCall(call, name, nodePath, internal) {
80
80
  if (internal.devMode) {
81
81
  call.arguments.push(t.stringLiteral(`${internal.prefix}:${name ? name.name : "#anonymouse"}`));
82
82
  }
83
- if (t.isIdentifier(call.callee) && call.callee.name === "state") {
84
- nodePath.replaceWith(call.arguments[0]);
85
- }
86
83
  }
87
84
  function meshAllUnknown(paths, internal) {
88
85
  for (const path of paths) {
@@ -110,7 +107,7 @@ function meshExpression(nodePath, internal, isRoot) {
110
107
  if (!expr) {
111
108
  return;
112
109
  }
113
- if ((0, call_js_1.calls)(expr, ["compose", "extend", "state"], internal)) {
110
+ if ((0, call_js_1.calls)(expr, ["compose", "store"], internal)) {
114
111
  meshComposeCall(expr, null, nodePath, internal);
115
112
  return;
116
113
  }
@@ -499,7 +496,7 @@ function meshStatement(path, internal) {
499
496
  const _path = path;
500
497
  for (const declaration of _path.get("declarations")) {
501
498
  const expr = declaration.node.init;
502
- if (expr && t.isIdentifier(declaration.node.id) && (0, call_js_1.calls)(expr, ["compose", "extend", "state"], internal)) {
499
+ if (expr && t.isIdentifier(declaration.node.id) && (0, call_js_1.calls)(expr, ["compose", "store"], internal)) {
503
500
  meshComposeCall(expr, declaration.node.id, declaration.get("init"), internal);
504
501
  }
505
502
  else {
@@ -57,7 +57,6 @@ const ignoreMembers = new Set([
57
57
  "laptop",
58
58
  "prefersDark",
59
59
  "prefersLight",
60
- "state",
61
60
  ]);
62
61
  function extractText(node) {
63
62
  // no case found for string literal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-vasille",
3
- "version": "3.1.1",
3
+ "version": "3.1.5",
4
4
  "description": "Convert Vasille Meta Language code to pure JavaScript",
5
5
  "main": "lib-node/index.js",
6
6
  "type": "commonjs",
@@ -50,7 +50,7 @@
50
50
  "typescript": "^5.8.3",
51
51
  "vasille": "^3.1.0",
52
52
  "vasille-css": "^3.1.0",
53
- "vasille-dx": "^3.1.0",
54
- "vasille-web": "^3.1.0"
53
+ "vasille-dx": "^3.1.3",
54
+ "vasille-web": "^3.1.5"
55
55
  }
56
56
  }