babel-plugin-vasille 5.1.0 → 5.1.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,6 @@
29
29
  - [1.0 - 1.2](#10---12)
30
30
  - [Questions](#questions)
31
31
 
32
-
33
32
  <hr>
34
33
 
35
34
  ## Installation
@@ -47,37 +46,41 @@ $ npm create steel-frame
47
46
  ```
48
47
 
49
48
  ### Full documentation:
50
- * [Learn `SteelFrameKit` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v5/doc/V4-API.md)
51
- * [Router Documentation](https://github.com/vasille-js/vasille-js/blob/v5/doc/Router-API.md)
52
- * [Compostion functions](https://github.com/vasille-js/vasille-js/blob/v5/doc/Compositions.md)
53
- * [Dependency injection](https://github.com/vasille-js/vasille-js/blob/v5/doc/Context.md)
49
+
50
+ - [Learn `SteelFrameKit` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v5/doc/V4-API.md)
51
+ - [Router Documentation](https://github.com/vasille-js/vasille-js/blob/v5/doc/Router-API.md)
52
+ - [Compostion functions](https://github.com/vasille-js/vasille-js/blob/v5/doc/Compositions.md)
53
+ - [Dependency injection](https://github.com/vasille-js/vasille-js/blob/v5/doc/Context.md)
54
54
 
55
55
  ### Examples
56
- * [TypeScript Example](https://github.com/vasille-js/example-typescript)
57
- * [JavaScript Example](https://github.com/vasille-js/example-javascript)
56
+
57
+ - [TypeScript Example](https://github.com/vasille-js/example-typescript)
58
+ - [JavaScript Example](https://github.com/vasille-js/example-javascript)
58
59
 
59
60
  <hr>
60
61
 
61
62
  ## How SAFE is SteelFrameKit
62
63
 
63
64
  The safe of your application is ensured by
64
- * `100%` coverage of code by unit tests.
65
+
66
+ - `100%` coverage of code by unit tests.
65
67
  Each function, each branch is working as designed.
66
- * OOP, DRY, KISS and SOLID principles are applied.
67
- * `strong typing` makes your javascript/typescript code safe as C++ code.
68
- All entities of `SteelFrameKit` core library are strongly typed, including:
69
- * data fields & properties.
70
- * computed properties (function parameters and result).
71
- * methods.
72
- * events (defined handlers & event emit).
73
- * DOM events & DOM operation (attributing, styling, etc.).
74
- * slots of components.
75
- * references to children.
76
- * No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
68
+ - OOP, DRY, KISS and SOLID principles are applied.
69
+ - `strong typing` makes your code safe.
70
+ All entities of `SteelFrameKit` core library are strongly typed, including:
71
+ - data fields & properties.
72
+ - computed properties (function parameters and result).
73
+ - methods.
74
+ - events (defined handlers & event emit).
75
+ - DOM events & DOM operation (attributing, styling, etc.).
76
+ - slots of components.
77
+ - references to children.
78
+ - No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
77
79
 
78
80
  ## How INTUITIVE is SteelFrameKit
79
81
 
80
82
  There is the "Hello World":
83
+
81
84
  ```typescript jsx
82
85
  import { compose, mount } from "steel-frame";
83
86
 
@@ -91,35 +94,37 @@ mount(document.body, App, {});
91
94
  ## How POWERFUL is SteelFrameKit
92
95
 
93
96
  All of these are supported:
94
- * Components.
95
- * Reactive values (observables).
96
- * Inline computed values.
97
- * Multiline computed values.
98
- * HTML tags.
99
- * Component custom slots.
100
- * 2-way data binding in components.
101
- * Logic block (if, else).
102
- * Loops (array, map, set).
103
- * Dependency injection.
97
+
98
+ - Components.
99
+ - Reactive values (observables).
100
+ - Inline computed values.
101
+ - Multiline computed values.
102
+ - HTML tags.
103
+ - Component custom slots.
104
+ - 2-way data binding in components.
105
+ - Logic block (if, else).
106
+ - Loops (array, map, set).
107
+ - Dependency injection.
104
108
 
105
109
  <hr>
106
110
 
107
111
  ## Road map
108
112
 
109
- * [x] `100%` Test Coverage for core Library v3.
110
- * [x] Develop the `JSX` library.
111
- * [x] `100%` Test Coverage for the JSX library.
112
- * [x] Develop the `Babel Plugin`.
113
- * [x] `100%` Test Coverage fot babel plugin.
114
- * [x] Add CSS support (define styles in components).
115
- * [x] Add router.
116
- * [x] Add SSG (static site generation).
117
- * [ ] Develop tools extension for debugging (WIP).
118
- * [ ] Add SSR (server side rendering).
113
+ - [x] `100%` Test Coverage for core Library v3.
114
+ - [x] Develop the `JSX` library.
115
+ - [x] `100%` Test Coverage for the JSX library.
116
+ - [x] Develop the `Babel Plugin`.
117
+ - [x] `100%` Test Coverage fot babel plugin.
118
+ - [x] Add CSS support (define styles in components).
119
+ - [x] Add router.
120
+ - [x] Add SSG (static site generation).
121
+ - [ ] Develop tools extension for debugging (WIP).
122
+ - [ ] Add SSR (server side rendering).
119
123
 
120
124
  ## Change log
121
125
 
122
126
  We respect semantic versioning:
127
+
123
128
  - A major version is increased when we make incompatible API changes.
124
129
  - A minor version is increased when we add functionality.
125
130
  - Patch version is increased when we fix bugs.
@@ -165,4 +170,4 @@ _Web components as custom tags are supported in any version._
165
170
 
166
171
  If you have questions, feel free to contact the maintainer of the project:
167
172
 
168
- * [Author's Email](mailto:vas.lixcode@gmail.com)
173
+ - [Author's Email](mailto:vas.lixcode@gmail.com)
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/index.js CHANGED
@@ -14,6 +14,8 @@ function default_1() {
14
14
  headTag: !!params.opts.headTag,
15
15
  bodyTag: !!params.opts.bodyTag,
16
16
  shadow: !!params.opts.shadow,
17
+ throwAtFirstError: !!params.opts.throwAtFirstError,
18
+ reporter: typeof params.opts.reporter === "function" ? params.opts.reporter : undefined,
17
19
  });
18
20
  },
19
21
  },
package/lib/jsx.js CHANGED
@@ -284,7 +284,7 @@ function transformJsxElement(path, conditions, internal) {
284
284
  }
285
285
  }
286
286
  else {
287
- (0, lib_js_1.err)(lib_js_1.Errors.TokenNotSupported, valuePath, "Expected event handler", internal);
287
+ (0, lib_js_1.err)(lib_js_1.Errors.TokenNotSupported, attrPath, "Expected event handler", internal);
288
288
  }
289
289
  }
290
290
  else if (name.name === "class") {
@@ -349,7 +349,7 @@ function transformJsxElement(path, conditions, internal) {
349
349
  // class={`a ${b}`}
350
350
  else if (expressionPath && expressionPath.isExpression()) {
351
351
  if ((0, lib_js_1.exprCall)(expressionPath, expressionPath.node, internal, { strong: true }, expressionPath.node)) {
352
- console.warn(attrPath.buildCodeFrameError("Vasille: This will slow down your application"));
352
+ internal.reportError("This will slow down your application", attrPath.node);
353
353
  }
354
354
  attrs.push(t.objectProperty(t.identifier("class"), expressionPath.node));
355
355
  }
@@ -427,7 +427,7 @@ function transformJsxElement(path, conditions, internal) {
427
427
  /* istanbul ignore else */
428
428
  if (expressionPath && expressionPath.isExpression()) {
429
429
  if ((0, lib_js_1.exprCall)(expressionPath, expressionPath.node, internal, { strong: true }, expressionPath.node)) {
430
- console.warn(attrPath.buildCodeFrameError("Vasille: This will slow down your application"));
430
+ internal.reportError("This will slow down your application", attrPath.node);
431
431
  }
432
432
  attrs.push(t.objectProperty(t.identifier("style"), expressionPath.node));
433
433
  }
@@ -601,6 +601,7 @@ function transformJsxElement(path, conditions, internal) {
601
601
  (0, lib_js_1.err)(lib_js_1.Errors.RulesOfVasille, path, "Malformed JSX If tag is missing", internal);
602
602
  }
603
603
  if (mapped === "If" || mapped === "ElseIf") {
604
+ /* istanbul ignore else */
604
605
  if (t.isExpression(condition) && (t.isFunctionExpression(slot) || t.isArrowFunctionExpression(slot))) {
605
606
  if (!conditions.cases) {
606
607
  conditions.cases = [{ condition, slot }];
package/lib/lib.js CHANGED
@@ -47,6 +47,7 @@ exports.processModelCall = processModelCall;
47
47
  exports.checkReactiveName = checkReactiveName;
48
48
  exports.checkNonReactiveName = checkNonReactiveName;
49
49
  exports.toKebabCase = toKebabCase;
50
+ exports.nameIsRestricted = nameIsRestricted;
50
51
  const t = __importStar(require("@babel/types"));
51
52
  const expression_js_1 = require("./expression.js");
52
53
  const internal_js_1 = require("./internal.js");
@@ -67,10 +68,7 @@ function err(e, node, content, internal, ret) {
67
68
  Error.stackTraceLimit = 0;
68
69
  const error = node.buildCodeFrameError(`Vasille[${e}]{${Errors[e]}}: ${content}`, Error);
69
70
  Error.stackTraceLimit = limit;
70
- if (!internal.firstError) {
71
- internal.firstError = error;
72
- }
73
- console.log(error);
71
+ internal.reportError(`${Errors[e]}: ${content}`, node.node, error);
74
72
  return ret;
75
73
  }
76
74
  function processCalculateCall(path, internal, area, name) {
@@ -202,3 +200,6 @@ function toKebabCase(name) {
202
200
  }
203
201
  return fixed;
204
202
  }
203
+ function nameIsRestricted(name) {
204
+ return name.endsWith("Model") || name.startsWith("prompt");
205
+ }
package/lib/mesh.js CHANGED
@@ -242,6 +242,12 @@ function meshExpression(nodePath, internal) {
242
242
  (0, lib_js_1.err)(lib_js_1.Errors.IncompatibleContext, path, "Prompts can be constructed only from components", internal);
243
243
  }
244
244
  path.node.arguments.unshift(internal_js_1.ctx);
245
+ if (internal.devLayer) {
246
+ while (path.node.arguments.length < 3) {
247
+ path.node.arguments.push(t.buildUndefinedNode());
248
+ }
249
+ path.node.arguments.push((0, transformer_1.nodeToStaticPosition)(path.node));
250
+ }
245
251
  }
246
252
  // dependency injection
247
253
  else if (internal.isComposing &&
@@ -445,6 +451,9 @@ function ignoreParams(path, internal, allowReactiveId) {
445
451
  if (!allowReactiveId || !allowReactiveId.includes("id")) {
446
452
  (0, lib_js_1.checkNonReactiveName)(path, internal);
447
453
  }
454
+ if ((0, lib_js_1.nameIsRestricted)(path.node.name)) {
455
+ (0, lib_js_1.err)(lib_js_1.Errors.RulesOfVasille, path, "This name is restricted (start with `prompt` or ends with `Model`)", internal);
456
+ }
448
457
  }
449
458
  // param is object destruction
450
459
  else if (path.isObjectPattern()) {
@@ -953,6 +962,9 @@ function meshFunction(path, internal) {
953
962
  if (idPath.isIdentifier()) {
954
963
  internal.stack.set(path.node.id.name, {});
955
964
  (0, lib_js_1.checkNonReactiveName)(idPath, internal);
965
+ if (internal.devLayer) {
966
+ path.insertAfter(internal.setupPosition(idPath.node, path.node));
967
+ }
956
968
  }
957
969
  }
958
970
  internal.stack.push();
@@ -1118,9 +1130,6 @@ function composeStatement(path, internal) {
1118
1130
  const argument = init.arguments[0];
1119
1131
  const isReactive = (0, lib_js_1.exprCall)(initPath, initPath.node, internal, { name: idName(), strong: true }, declaration.node);
1120
1132
  meshInit = !isReactive;
1121
- if (!isReactive) {
1122
- declaration.get("init").replaceWith((0, lib_js_1.ref)(argument, internal, declaration.node, idName()));
1123
- }
1124
1133
  (0, lib_js_1.checkReactiveName)(idPath, internal);
1125
1134
  }
1126
1135
  // let y = ref(2)
@@ -194,6 +194,7 @@ function transformProgram(path, filename, opts) {
194
194
  executionPosition: "VasilleExePos",
195
195
  runFn: "VasilleRun",
196
196
  wrapFn: "VasilleWrap",
197
+ setupPosition: "VasilleSetupPosition",
197
198
  shareStateById: "VasilleState",
198
199
  positionedText: "VasillePosText",
199
200
  earlyInspector: "VasilleInspector",
@@ -206,6 +207,7 @@ function transformProgram(path, filename, opts) {
206
207
  }
207
208
  return t.callExpression(t.identifier(ids[key]), args);
208
209
  }
210
+ const reports = [];
209
211
  const internal = {
210
212
  stack: new internal_js_1.StackedStates(),
211
213
  mapping: new Map(),
@@ -291,12 +293,12 @@ function transformProgram(path, filename, opts) {
291
293
  return t.callExpression(t.memberExpression(left, t.identifier("update")), [right, getExecutionPosition(assign)]);
292
294
  },
293
295
  wrapFunctionBody(fn) {
294
- const params = fn.params.map((item) => {
295
- return t.isFunctionParameter(item) ? item : item.parameter;
296
- });
297
- const body = fn.body;
298
- const args = t.identifier("VasilleArgs");
299
296
  if (opts.devLayer) {
297
+ const params = fn.params.map((item) => {
298
+ return t.isFunctionParameter(item) ? item : item.parameter;
299
+ });
300
+ const body = fn.body;
301
+ const args = t.identifier("VasilleArgs");
300
302
  fn.body = t.blockStatement([
301
303
  t.returnStatement(call("runFn", [
302
304
  t.arrowFunctionExpression(params, body, fn.async),
@@ -316,6 +318,9 @@ function transformProgram(path, filename, opts) {
316
318
  }
317
319
  return fn;
318
320
  },
321
+ setupPosition(target, area) {
322
+ return call("setupPosition", [target, nodeToStaticPosition(area)]);
323
+ },
319
324
  shareStateById(value, name) {
320
325
  return shareStateById(value, name);
321
326
  },
@@ -326,6 +331,27 @@ function transformProgram(path, filename, opts) {
326
331
  used.add("earlyInspector");
327
332
  return t.identifier(ids["earlyInspector"]);
328
333
  },
334
+ reportError(message, node, e) {
335
+ const pos = node.loc;
336
+ /* istanbul ignore else */
337
+ if (pos) {
338
+ reports.push({
339
+ message: message,
340
+ from: [pos.start.line, pos.start.column],
341
+ to: [pos.end.line, pos.end.column],
342
+ class: e ? "error" : "warning",
343
+ });
344
+ }
345
+ if (e) {
346
+ if (opts.throwAtFirstError) {
347
+ throw e;
348
+ }
349
+ console.error(e);
350
+ }
351
+ else {
352
+ console.warn(message);
353
+ }
354
+ },
329
355
  };
330
356
  function getCtx() {
331
357
  if (internal.isComposing)
@@ -365,8 +391,13 @@ function transformProgram(path, filename, opts) {
365
391
  }
366
392
  }
367
393
  updateImports(path, internal, ids, used);
368
- if (internal.firstError)
369
- throw internal.firstError;
394
+ opts.reporter?.({
395
+ filePath: filename,
396
+ reports: reports,
397
+ });
398
+ if (reports.some(item => item.class === "error")) {
399
+ throw new Error("Compilation failed");
400
+ }
370
401
  if (opts.devLayer) {
371
402
  path.node.body.unshift(t.variableDeclaration("const", [t.variableDeclarator(filePathId, t.stringLiteral(internal.steelFilePath))]));
372
403
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-vasille",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
4
4
  "description": "Convert Vasille Meta Language code to pure JavaScript",
5
5
  "main": "lib/index.js",
6
6
  "type": "commonjs",
@@ -8,11 +8,13 @@
8
8
  "import": "./lib/index.js",
9
9
  "browser": "./lib/index.js",
10
10
  "node": "./lib/index.js",
11
- "require": "./lib/index.js"
11
+ "require": "./lib/index.js",
12
+ "types": "./types/index.d.ts"
12
13
  },
13
14
  "scripts": {
14
15
  "prepack": "cp -f ../README.md ./README.md",
15
16
  "prettier": "prettier src test/**/*.ts* test/*.ts --write",
17
+ "prebuild": "rm -rf lib types",
16
18
  "build": "tsc --build tsconfig-build.json",
17
19
  "tsc-tests": "tsc --build test/tsconfig.json",
18
20
  "test": "jest",
@@ -26,7 +28,7 @@
26
28
  "babel"
27
29
  ],
28
30
  "author": "lixcode",
29
- "license": "MIT",
31
+ "license": "LGPL-2.1-only",
30
32
  "bugs": {
31
33
  "url": "https://github.com/vasille-js/vasille-js/issues"
32
34
  },
@@ -0,0 +1,14 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { Internal } from "./internal.js";
3
+ export type FnNames = "compose" | "view" | "component" | "store" | "model" | "screen" | "page" | "modal" | "prompt" | "awaited" | "calculate" | "forward" | "watch" | "ref" | "bind" | "raw" | "arrayModel" | "setModel" | "mapModel" | "beforeMount" | "afterMount" | "beforeDestroy" | "router" | "theme" | "dark" | "mobile" | "tablet" | "laptop" | "prefersDark" | "prefersLight" | "styleSheet" | "share" | "receive" | "impute";
4
+ export declare const composeFunctions: ["compose", "store", "model", "view", "component", "page", "modal", "prompt", "screen"];
5
+ export declare const refFunctions: ["ref"];
6
+ export declare const asyncFunctions: ["awaited"];
7
+ export declare const bindFunctions: ["watch", "calculate", "bind"];
8
+ export declare const modelFunctions: ["arrayModel", "mapModel", "setModel"];
9
+ export declare const composeOnly: ["router", "beforeMount", "afterMount", "beforeDestroy"];
10
+ export declare const styleOnly: ["theme", "dark", "mobile", "tablet", "laptop", "prefersDark", "prefersLight", "styleSheet"];
11
+ export declare const dependencyInjections: ["share", "receive", "impute"];
12
+ export declare const hintFunctions: FnNames[];
13
+ export declare function calls(path: NodePath<types.CallExpression>, names: FnNames[], internal: Internal): boolean;
14
+ export declare function calls(path: NodePath<types.Expression | null | undefined>, names: FnNames[], internal: Internal): path is NodePath<types.CallExpression>;
@@ -0,0 +1,11 @@
1
+ export interface CompilationErrorReport {
2
+ from: [number, number];
3
+ to: [number, number];
4
+ message: string;
5
+ class: "error" | "warning";
6
+ }
7
+ export interface CompilationErrorReports {
8
+ filePath: string;
9
+ reports: CompilationErrorReport[];
10
+ }
11
+ export type CompilationErrorReporter = (reports: CompilationErrorReports) => void;
@@ -0,0 +1,3 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { Internal } from "./internal.js";
3
+ export declare function findStyleInNode(path: NodePath<types.Node | null | undefined>, internal: Internal): boolean;
@@ -0,0 +1,27 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { Internal, StackedStates } from "./internal.js";
3
+ export interface Dependency {
4
+ node: types.Expression;
5
+ paramName: types.Identifier;
6
+ }
7
+ export interface Search {
8
+ found: Map<string, Dependency>;
9
+ external: Internal;
10
+ self: types.Expression | null;
11
+ inserted: Set<types.Expression>;
12
+ stack: StackedStates;
13
+ }
14
+ export declare function nodeIsMeshed(path: NodePath<types.Node | null | undefined>): boolean;
15
+ export declare function idIsIValue(path: NodePath<types.Identifier>): boolean;
16
+ export declare function memberIsIValue(node: types.MemberExpression | types.OptionalMemberExpression): boolean;
17
+ export declare function memberIsIValueInExpr(path: NodePath<types.MemberExpression | types.OptionalMemberExpression>, search: Search): boolean;
18
+ export declare function exprIsSure(path: NodePath<types.Expression | null | undefined>, internal: Internal): boolean | 1;
19
+ export declare function checkNode(path: NodePath<types.Node | null | undefined>, internal: Internal, area: types.Node, name?: string): Search;
20
+ export declare function checkOrIgnoreAllExpressions<T extends types.Node>(nodePaths: NodePath<types.Expression | null | T>[], search: Search): void;
21
+ export declare function checkAllExpressions(nodePaths: NodePath<types.Expression | null>[], search: Search): void;
22
+ export declare function checkAllUnknown(paths: NodePath<types.SpreadElement | types.ArgumentPlaceholder | types.Expression | null>[], internal: Search): void;
23
+ export declare function checkOrIgnoreExpression<T extends types.Node>(path: NodePath<types.Expression | null | undefined | T>, search: Search): void;
24
+ export declare function checkExpression(nodePath: NodePath<types.Expression | null | undefined>, search: Search): void;
25
+ export declare function checkStatements(paths: NodePath<types.Statement>[], search: Search): void;
26
+ export declare function checkStatement(path: NodePath<types.Statement | null | undefined>, search: Search): void;
27
+ export declare function checkFunction(path: NodePath<types.ArrowFunctionExpression | types.FunctionExpression | types.FunctionDeclaration | types.ObjectMethod>, search: Search): void;
@@ -0,0 +1,19 @@
1
+ import * as Babel from "@babel/core";
2
+ export default function (): Babel.PluginObj<{
3
+ file: {
4
+ opts: {
5
+ filename: string;
6
+ };
7
+ };
8
+ opts: {
9
+ devLayer: unknown;
10
+ strictFolders: unknown;
11
+ replaceWeb: unknown;
12
+ headTag: unknown;
13
+ bodyTag: unknown;
14
+ shadow: unknown;
15
+ throwAtFirstError: unknown;
16
+ reporter: unknown;
17
+ };
18
+ }>;
19
+ export type { CompilationErrorReporter, CompilationErrorReport, CompilationErrorReports } from "./communication";
@@ -0,0 +1,55 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { TSTypeElement } from "@babel/types";
3
+ export type VariableState = Record<string, 1>;
4
+ export declare class StackedStates {
5
+ private maps;
6
+ private checkingIndex;
7
+ constructor();
8
+ push(startChecking?: boolean): void;
9
+ pop(): void;
10
+ get(name: string, checkingContextOnly?: boolean): VariableState | undefined;
11
+ set(name: string, state: VariableState): void;
12
+ }
13
+ export interface Internal {
14
+ mapping: Map<string, string>;
15
+ interfaces: Map<string, TSTypeElement[]>;
16
+ componentsImports: Map<string, string>;
17
+ stack: StackedStates;
18
+ global: string;
19
+ prefix: string;
20
+ importStatement: NodePath<types.ImportDeclaration> | null;
21
+ stateOnly: boolean;
22
+ isComposing?: boolean;
23
+ isFunctionParsing?: boolean;
24
+ filename: string;
25
+ steelFilePath: string;
26
+ devLayer: boolean;
27
+ strictFolders: boolean;
28
+ stylesConnected: boolean;
29
+ replaceWeb: string;
30
+ headTag?: boolean;
31
+ bodyTag?: boolean;
32
+ shadow?: boolean;
33
+ reportError(message: string, node: types.Node, e?: Error): void;
34
+ ref(arg: types.Expression | null, area: types.Node, name: string | undefined): types.Expression;
35
+ expr(func: types.Expression, values: types.Expression[], codes: string[], area: types.Node, name: string | undefined): types.Expression;
36
+ setModel(arg: types.Expression | types.SpreadElement | types.ArgumentPlaceholder | null, usage: types.Node, name: string | undefined): types.Expression;
37
+ mapModel(arg: types.Expression | types.SpreadElement | types.ArgumentPlaceholder | null, usage: types.Node, name: string | undefined): types.Expression;
38
+ arrayModel(arg: types.Expression | types.SpreadElement | types.ArgumentPlaceholder | null, usage: types.Node, name: string | undefined): types.Expression;
39
+ ensure(arg: types.MemberExpression | types.OptionalMemberExpression, area: types.Node): types.Expression;
40
+ match(name: types.Expression, arg: types.Expression, area: types.Node): types.CallExpression;
41
+ set(obj: types.Expression, field: types.Expression, value: types.Expression, area: types.Node): types.CallExpression;
42
+ Switch(arg: types.ObjectExpression): types.CallExpression;
43
+ safe(arg: types.FunctionExpression | types.ArrowFunctionExpression): types.CallExpression;
44
+ updateIValue(assign: types.AssignmentExpression, left: types.Expression, right: types.Expression): types.Expression;
45
+ wrapFunctionBody(fn: types.FunctionDeclaration | types.ObjectMethod | types.ClassMethod | types.ClassPrivateMethod): void;
46
+ setupPosition(target: types.Expression, area: types.Node): types.Expression;
47
+ wrapFunction(fn: types.FunctionExpression | types.ArrowFunctionExpression): types.Node;
48
+ shareStateById(value: types.Expression, name: string): types.Expression;
49
+ positionedText(text: types.Expression, area: types.Node): types.Expression;
50
+ earlyInspector(): types.Expression;
51
+ }
52
+ export declare const ctx: types.Identifier;
53
+ export declare const runner: types.MemberExpression;
54
+ export declare const inspector: types.MemberExpression;
55
+ export declare const V: types.Identifier;
@@ -0,0 +1,3 @@
1
+ import { types } from "@babel/core";
2
+ export declare function exprHasJsx(node: types.Expression): boolean;
3
+ export declare function bodyHasJsx(node: types.BlockStatement | types.Expression): boolean;
package/types/jsx.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { Internal } from "./internal.js";
3
+ export interface ConditionCollection {
4
+ cases: {
5
+ condition: types.Expression;
6
+ slot: types.FunctionExpression | types.ArrowFunctionExpression;
7
+ }[] | null;
8
+ }
9
+ export declare function transformJsx(path: NodePath<types.JSXElement | types.JSXFragment>, conditions: ConditionCollection, internal: Internal): types.Statement[];
10
+ export declare function transformJsxArray(paths: NodePath<types.JSXText | types.JSXExpressionContainer | types.JSXSpreadChild | types.JSXElement | types.JSXFragment>[], internal: Internal): types.Statement[];
11
+ export declare function processConditions(conditions: ConditionCollection, internal: Internal, _default?: types.FunctionExpression | types.ArrowFunctionExpression): types.Statement[];
package/types/lib.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { Identifier } from "@babel/types";
3
+ import { Dependency } from "./expression.js";
4
+ import { Internal } from "./internal.js";
5
+ export declare enum Errors {
6
+ IncorrectArguments = 1,
7
+ IncompatibleContext = 2,
8
+ TokenNotSupported = 3,
9
+ Dilemma = 4,
10
+ ParserError = 5,
11
+ RulesOfVasille = 6
12
+ }
13
+ export declare function err(e: Errors, node: NodePath<unknown>, content: string, internal: Internal, ret?: undefined): void;
14
+ export declare function err<T>(e: Errors, node: NodePath<unknown>, content: string, internal: Internal, ret: T): T;
15
+ export declare function processCalculateCall(path: NodePath<types.CallExpression>, internal: Internal, area: types.Node, name: string | undefined): boolean;
16
+ export declare function parseCalculateCall(path: NodePath<types.Expression | null | undefined>, internal: Internal, area: types.Node, name: string | undefined): boolean;
17
+ export declare function bindCall(path: NodePath<types.Expression | null | undefined>, expr: types.Expression | null | undefined, data: Map<string, Dependency>, internal: Internal, name?: string): boolean;
18
+ export declare function exprCall(path: NodePath<types.Expression | null | undefined>, expr: types.Expression | null | undefined, internal: Internal, opts: {
19
+ name?: string;
20
+ strong?: boolean;
21
+ }, area: types.Node): boolean;
22
+ export declare function ref(expr: types.Node | null | undefined, internal: Internal, area: types.Node, name?: string): types.Expression;
23
+ export declare function arrayModel(args: types.CallExpression["arguments"], usage: types.Node, internal: Internal, name?: string): types.Expression;
24
+ export declare function setModel(args: types.CallExpression["arguments"], usage: types.Node, internal: Internal, name?: string): types.Expression;
25
+ export declare function mapModel(args: types.CallExpression["arguments"], usage: types.Node, internal: Internal, name?: string): types.Expression;
26
+ export declare function processModelCall(path: NodePath<types.CallExpression | types.NewExpression>, usage: types.Node, type: "Map" | "Set" | "Array", isConst: boolean, internal: Internal, name?: string): void;
27
+ export declare function checkReactiveName(idPath: NodePath<unknown>, internal: Internal): void;
28
+ export declare function checkNonReactiveName(idPath: NodePath<Identifier>, internal: Internal): void;
29
+ export declare function toKebabCase(name: string): string;
30
+ export declare function nameIsRestricted(name: string): boolean;
@@ -0,0 +1,19 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { Internal, VariableState } from "./internal.js";
3
+ export declare function meshOrIgnoreAllExpressions<T extends types.Node>(nodePaths: NodePath<types.Expression | null | T>[], internal: Internal): void;
4
+ export declare function meshAllExpressions(nodePaths: NodePath<types.Expression | null>[], internal: Internal): void;
5
+ export declare function meshComposeCall(name: string | null | undefined, path: NodePath<types.Node | null | undefined>, internal: Internal, isExported?: boolean): void;
6
+ export declare function meshAllUnknown(paths: NodePath<types.SpreadElement | types.ArgumentPlaceholder | types.Expression | null>[], internal: Internal): void;
7
+ export declare function meshLValue(path: NodePath<types.LVal | types.Expression | types.VoidPattern | null | undefined>, internal: Internal): void;
8
+ export declare function meshOrIgnoreExpression<T extends types.Node>(path: NodePath<types.Expression | types.VoidPattern | null | undefined | T>, internal: Internal): void;
9
+ export declare function meshExpression(nodePath: NodePath<types.Expression | null | undefined>, internal: Internal): void;
10
+ export declare function meshStatements(paths: NodePath<types.Statement>[], internal: Internal): void;
11
+ export declare function ignoreParams(path: NodePath<types.LVal | types.VoidPattern | null | undefined>, internal: Internal, allowReactiveId: false | ("id" | "array")[]): void;
12
+ export declare function reactiveArrayPattern(path: NodePath<types.LVal | types.OptionalMemberExpression | types.VoidPattern>, internal: Internal): void;
13
+ export declare function processObjectExpression(path: NodePath<types.ObjectExpression>, internal: Internal): VariableState;
14
+ export declare function meshStatement(path: NodePath<types.Statement | null | undefined>, internal: Internal): void;
15
+ export declare function meshFunction(path: NodePath<types.ArrowFunctionExpression | types.FunctionExpression | types.FunctionDeclaration | types.ObjectMethod | types.ClassMethod | types.ClassPrivateMethod>, internal: Internal): void;
16
+ export declare function composeExpression(path: NodePath<types.Expression | null | undefined>, internal: Internal): void;
17
+ export declare function composeStatements(paths: NodePath<types.Statement | null | undefined>[], internal: Internal): void;
18
+ export declare function composeStatement(path: NodePath<types.Statement | null | undefined>, internal: Internal): void;
19
+ export declare function compose(path: NodePath<types.ArrowFunctionExpression | types.FunctionExpression>, internal: Internal, isInternalSlot: boolean, isSlot: boolean): void;
@@ -0,0 +1,3 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { Internal } from "./internal";
3
+ export declare function checkOrder(paths: NodePath<types.Statement | null | undefined>[], internal: Internal): void;
@@ -0,0 +1,15 @@
1
+ import { types } from "@babel/core";
2
+ import { TSTypeElement } from "@babel/types";
3
+ import { Internal } from "./internal";
4
+ declare const any = 0;
5
+ declare const string = 1;
6
+ declare const number = 2;
7
+ declare const boolean = 3;
8
+ type PropType = typeof string | typeof number | typeof boolean | typeof any;
9
+ export declare function registerInterface(name: string, members: TSTypeElement[], internal: Internal): void;
10
+ export declare function processUnion(type: types.TSUnionType): PropType;
11
+ export declare function processType(type: types.TSType): PropType;
12
+ export declare function processSignatures(members: TSTypeElement[]): types.ObjectExpression;
13
+ export declare function processTypeLiteral(literal: types.TSTypeLiteral): types.ObjectExpression;
14
+ export declare function processReference(id: types.TSTypeReference, internal: Internal): types.ObjectExpression | undefined;
15
+ export {};
@@ -0,0 +1,2 @@
1
+ import { NodePath } from "@babel/core";
2
+ export declare function routerReplace(path: NodePath<unknown>): void;
@@ -0,0 +1,16 @@
1
+ import { NodePath, types } from "@babel/core";
2
+ import { Internal } from "./internal.js";
3
+ import { CompilationErrorReporter } from "./communication";
4
+ export interface TransformerOptions {
5
+ devLayer: boolean;
6
+ strictFolders: boolean;
7
+ replaceWeb: string | undefined;
8
+ headTag: boolean;
9
+ bodyTag: boolean;
10
+ shadow: boolean;
11
+ reporter: CompilationErrorReporter | undefined;
12
+ throwAtFirstError: boolean;
13
+ }
14
+ export declare function nodeToStaticPosition(node: types.Node): types.ArrayExpression;
15
+ export declare function transformProgram(path: NodePath<types.Program>, filename: string, opts: TransformerOptions): void;
16
+ export declare function inspectorOf(internal: Internal): types.Expression;
@@ -0,0 +1,2 @@
1
+ import { types } from "@babel/core";
2
+ export declare function stringify(node: types.Expression | types.PrivateName): string;