babel-plugin-vasille 0.99.5 → 3.1.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.
@@ -15,29 +15,37 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
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
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.trProgram = trProgram;
27
37
  const t = __importStar(require("@babel/types"));
28
- const internal_1 = require("./internal");
29
- const mesh_1 = require("./mesh");
30
- const css_transformer_1 = require("./css-transformer");
31
- const imports = new Map([
32
- ["vasille-dx", "VasilleDX"],
33
- ["vasille-web", "VasilleWeb"],
34
- ]);
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");
41
+ const imports = new Map([["vasille-web", "VasilleWeb"]]);
35
42
  const ignoreMembers = new Set([
36
43
  "value",
37
44
  "ref",
38
45
  "bind",
39
46
  "calculate",
40
47
  "watch",
48
+ "forward",
41
49
  "arrayModel",
42
50
  "mapModel",
43
51
  "reactiveObject",
@@ -49,9 +57,11 @@ const ignoreMembers = new Set([
49
57
  "laptop",
50
58
  "prefersDark",
51
59
  "prefersLight",
60
+ "state",
52
61
  ]);
53
62
  function extractText(node) {
54
- return t.isIdentifier(node) ? node.name : node.value;
63
+ // no case found for string literal
64
+ return node.name;
55
65
  }
56
66
  function trProgram(path, devMode) {
57
67
  let id;
@@ -64,13 +74,13 @@ function trProgram(path, devMode) {
64
74
  set id(expr) {
65
75
  id = expr;
66
76
  },
67
- stack: new internal_1.StackedStates(),
77
+ stack: new internal_js_1.StackedStates(),
68
78
  mapping: new Map(),
69
79
  global: "",
70
- cssGlobal: "",
71
80
  prefix: "Vasille_",
72
81
  importStatement: null,
73
82
  internalUsed: false,
83
+ stateOnly: false,
74
84
  devMode: devMode,
75
85
  };
76
86
  for (const statementPath of path.get("body")) {
@@ -78,25 +88,24 @@ function trProgram(path, devMode) {
78
88
  if (t.isImportDeclaration(statement)) {
79
89
  const name = imports.get(statement.source.value);
80
90
  if (name) {
81
- internal.prefix = `${name}_`;
91
+ internal.prefix = name;
82
92
  for (const specifier of statement.specifiers) {
83
93
  if (t.isImportNamespaceSpecifier(specifier)) {
84
94
  internal.global = specifier.local.name;
85
95
  if (statement.source.value === "vasille-web") {
86
- internal.cssGlobal = internal.global;
87
96
  stylesConnected = true;
88
97
  }
89
- id = t.memberExpression(t.identifier(internal.global), t.identifier("$"));
98
+ internal.id = t.memberExpression(t.identifier(internal.global), t.identifier("$"));
90
99
  }
91
100
  else if (t.isImportSpecifier(specifier)) {
92
101
  const imported = extractText(specifier.imported);
93
102
  const local = specifier.local.name;
94
103
  internal.mapping.set(local, imported);
95
- if (imported === "webStyleSheet") {
104
+ if (imported === "styleSheet") {
96
105
  stylesConnected = true;
97
106
  }
98
107
  if (!id) {
99
- id = t.identifier(name);
108
+ internal.id = t.identifier(name);
100
109
  }
101
110
  internal.importStatement = statementPath;
102
111
  }
@@ -106,41 +115,18 @@ function trProgram(path, devMode) {
106
115
  return true;
107
116
  }
108
117
  else {
109
- return !ignoreMembers.has(extractText(spec.imported));
118
+ return !(ignoreMembers.has(extractText(spec.imported)) ||
119
+ (!internal.devMode && extractText(spec.imported) === "Debug"));
110
120
  }
111
121
  });
112
122
  }
113
- else if (statement.source.value === "vasille-css") {
114
- for (const specifier of statement.specifiers) {
115
- if (t.isImportSpecifier(specifier)) {
116
- internal.mapping.set(specifier.local.name, extractText(specifier.imported));
117
- }
118
- else if (t.isImportNamespaceSpecifier(specifier)) {
119
- internal.cssGlobal = specifier.local.name;
120
- }
121
- }
122
- statement.specifiers = statement.specifiers.filter(spec => {
123
- if (!t.isImportSpecifier(spec)) {
124
- return true;
125
- }
126
- else {
127
- return !ignoreMembers.has(extractText(spec.imported));
128
- }
129
- });
130
- stylesConnected = true;
131
- }
132
123
  }
133
124
  else {
134
125
  if (!id) {
135
- if (stylesConnected) {
136
- (0, css_transformer_1.findStyleInNode)(statementPath, internal);
137
- }
138
- else {
139
- return;
140
- }
126
+ return;
141
127
  }
142
- else if (!stylesConnected || !(0, css_transformer_1.findStyleInNode)(statementPath, internal)) {
143
- (0, mesh_1.meshStatement)(statementPath, internal);
128
+ else if (!stylesConnected || !(0, css_transformer_js_1.findStyleInNode)(statementPath, internal)) {
129
+ (0, mesh_js_1.meshStatement)(statementPath, internal);
144
130
  }
145
131
  }
146
132
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "babel-plugin-vasille",
3
- "version": "0.99.5",
3
+ "version": "3.1.0",
4
4
  "description": "Convert Vasille Meta Language code to pure JavaScript",
5
5
  "main": "lib-node/index.js",
6
- "type": "commonjs",
6
+ "type": "module",
7
7
  "exports": {
8
8
  "import": "./lib-node/index.js",
9
9
  "browser": "./lib/index.js",
@@ -15,8 +15,9 @@
15
15
  "prettier": "prettier src test/**/*.ts* --write",
16
16
  "build": "tsc --build tsconfig-build.json",
17
17
  "build-node": "tsc --build tsconfig-build-node.json",
18
- "test": "jest",
19
- "test-coverage": "jest --coverage"
18
+ "tsc-tests": "tsc --build test/tsconfig.json",
19
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
20
+ "test-coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
20
21
  },
21
22
  "keywords": [
22
23
  "front-end",
@@ -32,21 +33,24 @@
32
33
  },
33
34
  "homepage": "https://github.com/vasille-js/vasille-js#readme",
34
35
  "devDependencies": {
35
- "@babel/parser": "^7.26.1",
36
- "@babel/plugin-syntax-jsx": "^7.25.9",
37
- "@babel/plugin-transform-typescript": "^7.25.9",
38
- "@babel/types": "^7.26.0",
36
+ "@babel/parser": "^7.28.0",
37
+ "@babel/plugin-syntax-jsx": "^7.27.1",
38
+ "@babel/plugin-transform-typescript": "^7.28.0",
39
+ "@babel/types": "^7.28.2",
39
40
  "@types/babel__core": "^7.20.5",
40
- "@types/jest": "^29.5.14",
41
+ "@types/jest": "^30.0.0",
41
42
  "@types/jsdom": "^21.1.7",
42
- "@types/node": "^22.8.1",
43
- "jest": "^29.7.0",
44
- "jsdom": "^25.0.1",
43
+ "@types/node": "^24.1.0",
44
+ "cross-env": "^10.0.0",
45
+ "jest": "^30.0.5",
46
+ "jsdom": "^26.1.0",
45
47
  "path": "^0.12.7",
46
- "prettier": "^3.3.3",
47
- "ts-jest": "^29.2.5",
48
- "typescript": "^5.6.3",
49
- "vasille-css": "^3.0.3",
50
- "vasille-dx": "^3.0.3"
48
+ "prettier": "^3.6.2",
49
+ "ts-jest": "^29.4.0",
50
+ "typescript": "^5.8.3",
51
+ "vasille": "^3.1.0",
52
+ "vasille-css": "^3.1.0",
53
+ "vasille-dx": "^3.1.0",
54
+ "vasille-web": "^3.1.0"
51
55
  }
52
56
  }