vasille-jsx 4.1.0 → 4.3.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.
- package/README.md +8 -3
- package/lib/components.js +16 -10
- package/lib/compose.js +1 -1
- package/lib/internal.js +1 -1
- package/package.json +2 -2
- package/types/internal.d.ts +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ $ npm create vasille
|
|
|
35
35
|
### Full documentation:
|
|
36
36
|
* [Learn `Vasille` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v4/doc/V4-API.md)
|
|
37
37
|
* [Vasille Router Documentation](https://github.com/vasille-js/vasille-js/blob/v4/doc/Router-API.md)
|
|
38
|
+
* [Vasille Compostion function](https://github.com/vasille-js/vasille-js/blob/v4/doc/Compositions.md)
|
|
38
39
|
|
|
39
40
|
### Examples
|
|
40
41
|
* [TypeScript Example](https://github.com/vasille-js/example-typescript)
|
|
@@ -103,14 +104,18 @@ All of these are supported:
|
|
|
103
104
|
|
|
104
105
|
## Change log
|
|
105
106
|
|
|
106
|
-
### 4.
|
|
107
|
+
### 4.2.0
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
Add support for inlined conditions in JSX, binary `&&` and ternary `?:` operator.
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
### 4.1.0
|
|
111
112
|
|
|
112
113
|
Added SSG (static site generation) as build option `vasille-web build static`.
|
|
113
114
|
|
|
115
|
+
### 4.0.0
|
|
116
|
+
|
|
117
|
+
Initial version of the framework with file based routing and building scripts (`vasille-web dev` and `vasille-web build spa`).
|
|
118
|
+
|
|
114
119
|
## Questions
|
|
115
120
|
|
|
116
121
|
If you have questions, feel free to contact the maintainer of the project:
|
package/lib/components.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { ArrayModel, ArrayView, Fragment, MapModel, MapView, SetModel, SetView, SwitchedNode, userError, Watch as CoreWatch, } from "vasille";
|
|
1
|
+
import { ArrayModel, ArrayView, Fragment, MapModel, MapView, reportError, safe, SetModel, SetView, SwitchedNode, userError, Watch as CoreWatch, } from "vasille";
|
|
2
2
|
export function Slot({ model, slot, ...options }, ctx, defaultSlot) {
|
|
3
|
-
|
|
4
|
-
model
|
|
3
|
+
try {
|
|
4
|
+
if (model) {
|
|
5
|
+
model(options, ctx);
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
(slot ?? defaultSlot)?.({}, ctx);
|
|
9
|
+
}
|
|
5
10
|
}
|
|
6
|
-
|
|
7
|
-
(
|
|
11
|
+
catch (e) {
|
|
12
|
+
reportError(e);
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
15
|
export function Switch(options, ctx) {
|
|
@@ -35,20 +40,21 @@ export function For({ of: model, slot: _slot }, ctx, defaultSlot) {
|
|
|
35
40
|
}
|
|
36
41
|
// fallback if is used external Array/Map/Set
|
|
37
42
|
else {
|
|
43
|
+
const safeSlot = safe(slot);
|
|
38
44
|
console.warn("Vasille <For of/> fallback detected. Please provide reactive data.");
|
|
39
45
|
if (model instanceof Array) {
|
|
40
46
|
model.forEach((value) => {
|
|
41
|
-
|
|
47
|
+
safeSlot(ctx, value, value);
|
|
42
48
|
});
|
|
43
49
|
}
|
|
44
50
|
else if (model instanceof Map) {
|
|
45
51
|
model.forEach((value, key) => {
|
|
46
|
-
|
|
52
|
+
safeSlot(ctx, value, key);
|
|
47
53
|
});
|
|
48
54
|
}
|
|
49
55
|
else if (model instanceof Set) {
|
|
50
56
|
model.forEach(value => {
|
|
51
|
-
|
|
57
|
+
safeSlot(ctx, value, value);
|
|
52
58
|
});
|
|
53
59
|
}
|
|
54
60
|
else {
|
|
@@ -60,7 +66,7 @@ export function Watch({ $model, slot: _slot }, ctx, defaultSlot) {
|
|
|
60
66
|
const slot = _slot ?? defaultSlot;
|
|
61
67
|
/* istanbul ignore else */
|
|
62
68
|
if (slot) {
|
|
63
|
-
ctx.create(new CoreWatch({ model: $model, slot }, ctx.runner));
|
|
69
|
+
ctx.create(new CoreWatch({ model: $model, slot: safe(slot) }, ctx.runner));
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
export function Debug({ $model }, ctx) {
|
|
@@ -74,7 +80,7 @@ export function Delay({ time, slot: _slot }, ctx, defaultSlot) {
|
|
|
74
80
|
/* istanbul ignore else */
|
|
75
81
|
if (slot) {
|
|
76
82
|
timer = setTimeout(() => {
|
|
77
|
-
slot(node);
|
|
83
|
+
safe(slot)(node);
|
|
78
84
|
timer = undefined;
|
|
79
85
|
}, time);
|
|
80
86
|
}
|
package/lib/compose.js
CHANGED
package/lib/internal.js
CHANGED
|
@@ -49,7 +49,7 @@ export function ensure(data) {
|
|
|
49
49
|
* 1. `{[a]: a1 = 3} = {x: 2}` to `{[a]: a1 = match("a1", 3)} = {x: 2}`
|
|
50
50
|
*/
|
|
51
51
|
export function match(name, data) {
|
|
52
|
-
const iValueRequired = name.startsWith("$");
|
|
52
|
+
const iValueRequired = typeof name === "string" && name.startsWith("$");
|
|
53
53
|
const isIValue = data instanceof IValue;
|
|
54
54
|
if (iValueRequired && !isIValue) {
|
|
55
55
|
return new Reference(data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vasille-jsx",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "The same framework which is designed to build bulletproof frontends (JSX components)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"opera 15"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"vasille": "^4.
|
|
47
|
+
"vasille": "^4.3.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/jest": "^30.0.0",
|
package/types/internal.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare function ensure(data: unknown): IValue<any>;
|
|
|
32
32
|
* 1. `{[a]: a1} = {x: 2}` to `{[a]: a1 = match("a1")} = {x: 2}`
|
|
33
33
|
* 1. `{[a]: a1 = 3} = {x: 2}` to `{[a]: a1 = match("a1", 3)} = {x: 2}`
|
|
34
34
|
*/
|
|
35
|
-
export declare function match(name: string, data?: unknown): any;
|
|
35
|
+
export declare function match(name: string | number | symbol, data?: unknown): any;
|
|
36
36
|
/**
|
|
37
37
|
* Set a value of a field (alternative to proxies)
|
|
38
38
|
* 1. `obj.$key = 23` to `set(obj, "$key", 23)`
|