babel-plugin-vasille 5.1.0 → 5.1.1
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 +45 -40
- package/lib/lib.js +4 -0
- package/lib/mesh.js +12 -0
- package/lib/transformer.js +9 -5
- package/package.json +1 -1
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
57
|
-
|
|
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
|
-
|
|
65
|
+
|
|
66
|
+
- `100%` coverage of code by unit tests.
|
|
65
67
|
Each function, each branch is working as designed.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
All entities of `SteelFrameKit` core library are strongly typed, including:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
173
|
+
- [Author's Email](mailto:vas.lixcode@gmail.com)
|
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");
|
|
@@ -202,3 +203,6 @@ function toKebabCase(name) {
|
|
|
202
203
|
}
|
|
203
204
|
return fixed;
|
|
204
205
|
}
|
|
206
|
+
function nameIsRestricted(name) {
|
|
207
|
+
return name.endsWith("Model") || name.startsWith("prompt");
|
|
208
|
+
}
|
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();
|
package/lib/transformer.js
CHANGED
|
@@ -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",
|
|
@@ -291,12 +292,12 @@ function transformProgram(path, filename, opts) {
|
|
|
291
292
|
return t.callExpression(t.memberExpression(left, t.identifier("update")), [right, getExecutionPosition(assign)]);
|
|
292
293
|
},
|
|
293
294
|
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
295
|
if (opts.devLayer) {
|
|
296
|
+
const params = fn.params.map((item) => {
|
|
297
|
+
return t.isFunctionParameter(item) ? item : item.parameter;
|
|
298
|
+
});
|
|
299
|
+
const body = fn.body;
|
|
300
|
+
const args = t.identifier("VasilleArgs");
|
|
300
301
|
fn.body = t.blockStatement([
|
|
301
302
|
t.returnStatement(call("runFn", [
|
|
302
303
|
t.arrowFunctionExpression(params, body, fn.async),
|
|
@@ -316,6 +317,9 @@ function transformProgram(path, filename, opts) {
|
|
|
316
317
|
}
|
|
317
318
|
return fn;
|
|
318
319
|
},
|
|
320
|
+
setupPosition(target, area) {
|
|
321
|
+
return call("setupPosition", [target, nodeToStaticPosition(area)]);
|
|
322
|
+
},
|
|
319
323
|
shareStateById(value, name) {
|
|
320
324
|
return shareStateById(value, name);
|
|
321
325
|
},
|