vasille-jsx 3.1.0 → 3.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/lib/internal.js +2 -2
- package/lib/library.js +6 -0
- package/lib/objects.js +1 -1
- package/package.json +2 -2
- package/types/internal.d.ts +2 -2
- package/types/library.d.ts +1 -0
- package/types/objects.d.ts +1 -1
package/lib/internal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyArrayModel, Expression, Pointer, Reference } from "vasille";
|
|
2
|
-
import { reactiveObject, reactiveObjectProxy,
|
|
2
|
+
import { reactiveObject, reactiveObjectProxy, storeReactiveObject } from "./objects.js";
|
|
3
3
|
import { ContextArray, ContextMap, ContextSet } from "./models.js";
|
|
4
4
|
export const internal = {
|
|
5
5
|
/** create an expression (without context), use it for OwningPointer */
|
|
@@ -33,7 +33,7 @@ export const internal = {
|
|
|
33
33
|
return node.register(proxyArrayModel(new ContextArray(data)), name);
|
|
34
34
|
},
|
|
35
35
|
/** translate `{...} to $.sro({...})` */
|
|
36
|
-
sro:
|
|
36
|
+
sro: storeReactiveObject,
|
|
37
37
|
/** translate `new Set(#)` to `$.ssm(#)` */
|
|
38
38
|
ssm(data) {
|
|
39
39
|
return new ContextSet(data);
|
package/lib/library.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IValue } from "vasille";
|
|
2
|
+
import { storeReactiveObject } from "./objects.js";
|
|
2
3
|
export function awaited(node, target, errName, dataName) {
|
|
3
4
|
const value = node.ref(undefined, dataName);
|
|
4
5
|
const err = node.ref(undefined, errName);
|
|
@@ -34,6 +35,11 @@ export function awaited(node, target, errName, dataName) {
|
|
|
34
35
|
run();
|
|
35
36
|
return [err, value, run];
|
|
36
37
|
}
|
|
38
|
+
export function store(fn) {
|
|
39
|
+
return (input) => {
|
|
40
|
+
return input ? fn(storeReactiveObject(input)) : fn();
|
|
41
|
+
};
|
|
42
|
+
}
|
|
37
43
|
export function ensureIValue(node, value) {
|
|
38
44
|
return value instanceof IValue ? value : node.ref(value);
|
|
39
45
|
}
|
package/lib/objects.js
CHANGED
|
@@ -79,7 +79,7 @@ export function reactiveObjectProxy(o) {
|
|
|
79
79
|
},
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
export function
|
|
82
|
+
export function storeReactiveObject(o) {
|
|
83
83
|
for (const key of Object.keys(o)) {
|
|
84
84
|
if (!(o[key] instanceof IValue)) {
|
|
85
85
|
o[key] = new Reference(proxy(o[key]));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vasille-jsx",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"description": "The first Developer eXperience
|
|
3
|
+
"version": "3.1.2",
|
|
4
|
+
"description": "The first Developer eXperience Orientated front-end framework (JSX components)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
"types": "./types/index.d.ts",
|
package/types/internal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IValue, Reactive, KindOfIValue, Expression } from "vasille";
|
|
2
|
-
import { reactiveObject,
|
|
2
|
+
import { reactiveObject, storeReactiveObject } from "./objects.js";
|
|
3
3
|
import { ContextMap, ContextSet } from "./models.js";
|
|
4
4
|
export declare const internal: {
|
|
5
5
|
/** create an expression (without context), use it for OwningPointer */
|
|
@@ -21,7 +21,7 @@ export declare const internal: {
|
|
|
21
21
|
/** translate `[...]` to `$.am(this, [...])` */
|
|
22
22
|
am(node: Reactive, data?: unknown[], name?: string): import("vasille").ArrayModel<unknown>;
|
|
23
23
|
/** translate `{...} to $.sro({...})` */
|
|
24
|
-
sro: typeof
|
|
24
|
+
sro: typeof storeReactiveObject;
|
|
25
25
|
/** translate `new Set(#)` to `$.ssm(#)` */
|
|
26
26
|
ssm(data?: unknown[]): ContextSet<unknown>;
|
|
27
27
|
/** translate `new Map(#)` to `$.smm(#)` */
|
package/types/library.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IValue, Reactive } from "vasille";
|
|
2
2
|
export declare function awaited<T>(node: Reactive, target: Promise<T> | (() => Promise<T>), errName?: string, dataName?: string): [IValue<unknown>, IValue<unknown>, () => void];
|
|
3
|
+
export declare function store(fn: (input?: object) => object): (input?: object) => object;
|
|
3
4
|
export declare function ensureIValue<T>(node: Reactive, value: T | IValue<T>): IValue<T>;
|
package/types/objects.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export declare function reactiveObjectProxy<T extends {
|
|
|
12
12
|
}>(o: T): {
|
|
13
13
|
[K in keyof T]: T[K] extends IValue<infer R> ? R : never;
|
|
14
14
|
};
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function storeReactiveObject<T extends object>(o: T): {
|
|
16
16
|
[K in keyof T]: T[K] extends IValue<unknown> ? T[K] : IValue<T[K]>;
|
|
17
17
|
};
|