vasille 3.2.1 → 4.0.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 +5 -14
- package/eslint.config.js +25 -0
- package/lib/core/core.js +8 -94
- package/lib/core/destroyable.js +1 -10
- package/lib/core/ivalue.js +3 -5
- package/lib/functional/safety.js +1 -1
- package/lib/index.js +18 -20
- package/lib/models/array-model.js +15 -48
- package/lib/models/listener.js +12 -14
- package/lib/models/map-model.js +9 -6
- package/lib/models/set-model.js +8 -7
- package/lib/node/app.js +7 -5
- package/lib/node/node.js +80 -95
- package/lib/node/watch.js +24 -8
- package/lib/runner/web/binding/binding.js +4 -6
- package/lib/runner/web/binding/class.js +19 -6
- package/lib/runner/web/binding/property.js +20 -0
- package/lib/runner/web/runner.js +31 -22
- package/lib/value/expression.js +29 -21
- package/lib/value/pointer.js +45 -54
- package/lib/value/reference.js +21 -17
- package/lib/views/array-view.js +4 -4
- package/lib/views/base-view.js +19 -8
- package/lib/views/map-view.js +2 -2
- package/lib/views/repeat-node.js +12 -11
- package/lib/views/set-view.js +3 -3
- package/package.json +18 -9
- package/types/core/core.d.ts +3 -47
- package/types/core/destroyable.d.ts +2 -12
- package/types/core/ivalue.d.ts +3 -5
- package/types/index.d.ts +21 -22
- package/types/models/array-model.d.ts +11 -11
- package/types/models/listener.d.ts +8 -8
- package/types/models/map-model.d.ts +8 -6
- package/types/models/model.d.ts +2 -7
- package/types/models/set-model.d.ts +7 -7
- package/types/node/app.d.ts +6 -6
- package/types/node/node.d.ts +21 -49
- package/types/node/runner.d.ts +3 -0
- package/types/node/watch.d.ts +5 -1
- package/types/runner/web/binding/binding.d.ts +1 -2
- package/types/runner/web/binding/class.d.ts +2 -0
- package/types/runner/web/binding/property.d.ts +17 -0
- package/types/runner/web/runner.d.ts +1 -1
- package/types/value/expression.d.ts +7 -12
- package/types/value/pointer.d.ts +32 -22
- package/types/value/reference.d.ts +2 -4
- package/types/views/array-view.d.ts +2 -2
- package/types/views/base-view.d.ts +2 -3
- package/types/views/repeat-node.d.ts +4 -3
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/types/tsconfig-types.tsbuildinfo +0 -1
package/lib/value/pointer.js
CHANGED
|
@@ -1,70 +1,61 @@
|
|
|
1
|
-
import { IValue } from "../core/ivalue.js";
|
|
2
1
|
import { Reference } from "./reference.js";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @class
|
|
6
|
-
* @extends
|
|
3
|
+
* Forward only link type
|
|
4
|
+
* @class Forward
|
|
5
|
+
* @extends Reference
|
|
7
6
|
*/
|
|
8
|
-
export class
|
|
7
|
+
export class Forward extends Reference {
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
9
|
+
* forwarded value
|
|
10
|
+
* @type IValue
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
target;
|
|
13
|
+
/**
|
|
14
|
+
* Handler to receive updates from forwarded value
|
|
15
|
+
*/
|
|
16
|
+
handler;
|
|
17
|
+
/**
|
|
18
|
+
* Constructs a value forwarder
|
|
19
|
+
* @param value {IValue} is source of forwarded data
|
|
20
|
+
* @param ctx lifetime context
|
|
21
|
+
*/
|
|
22
|
+
constructor(value, ctx) {
|
|
23
|
+
super(value.V);
|
|
15
24
|
this.handler = (v) => {
|
|
16
|
-
this.
|
|
25
|
+
this.V = v;
|
|
17
26
|
};
|
|
18
27
|
this.target = value;
|
|
19
|
-
this.reference = new Reference(value.$);
|
|
20
28
|
value.on(this.handler);
|
|
21
|
-
|
|
22
|
-
get $() {
|
|
23
|
-
return this.reference.$;
|
|
24
|
-
}
|
|
25
|
-
set $(v) {
|
|
26
|
-
this.target?.off(this.handler);
|
|
27
|
-
this.target = null;
|
|
28
|
-
this.reference.$ = v;
|
|
29
|
-
}
|
|
30
|
-
get $$() {
|
|
31
|
-
return this.reference.$;
|
|
32
|
-
}
|
|
33
|
-
set $$(v) {
|
|
34
|
-
/* istanbul ignore else */
|
|
35
|
-
if (this.target !== v) {
|
|
36
|
-
this.disconnectTarget();
|
|
37
|
-
}
|
|
38
|
-
if (v instanceof IValue) {
|
|
39
|
-
this.target = v;
|
|
40
|
-
this.target.on(this.handler);
|
|
41
|
-
this.reference.$ = v.$;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.$ = v;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
on(handler) {
|
|
48
|
-
this.reference.on(handler);
|
|
49
|
-
}
|
|
50
|
-
off(handler) {
|
|
51
|
-
this.reference.off(handler);
|
|
29
|
+
ctx?.bind(this);
|
|
52
30
|
}
|
|
53
31
|
destroy() {
|
|
54
|
-
this.target
|
|
55
|
-
this.reference.destroy();
|
|
56
|
-
super.destroy();
|
|
57
|
-
}
|
|
58
|
-
disconnectTarget() {
|
|
59
|
-
this.target?.off(this.handler);
|
|
32
|
+
this.target.off(this.handler);
|
|
60
33
|
}
|
|
61
34
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Backward only link type
|
|
37
|
+
* @class Backward
|
|
38
|
+
* @extends Reference
|
|
39
|
+
*/
|
|
40
|
+
export class Backward extends Reference {
|
|
41
|
+
/**
|
|
42
|
+
* target, which receive the updates
|
|
43
|
+
* @type IValue
|
|
44
|
+
*/
|
|
45
|
+
target;
|
|
46
|
+
/**
|
|
47
|
+
* Constructs a value backward stream
|
|
48
|
+
* @param value {IValue} target, which receive the updates
|
|
49
|
+
*/
|
|
50
|
+
constructor(value) {
|
|
51
|
+
super(value.V);
|
|
52
|
+
this.target = value;
|
|
53
|
+
}
|
|
54
|
+
get V() {
|
|
55
|
+
return super.V;
|
|
66
56
|
}
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
set V(value) {
|
|
58
|
+
super.V = value;
|
|
59
|
+
this.target.V = value;
|
|
69
60
|
}
|
|
70
61
|
}
|
package/lib/value/reference.js
CHANGED
|
@@ -6,6 +6,17 @@ import { reportError } from "../functional/safety.js";
|
|
|
6
6
|
* @extends IValue
|
|
7
7
|
*/
|
|
8
8
|
export class Reference extends IValue {
|
|
9
|
+
/**
|
|
10
|
+
* The encapsulated value
|
|
11
|
+
* @type {*}
|
|
12
|
+
*/
|
|
13
|
+
state;
|
|
14
|
+
/**
|
|
15
|
+
* Array of handlers
|
|
16
|
+
* @type {Set}
|
|
17
|
+
* @readonly
|
|
18
|
+
*/
|
|
19
|
+
onChange;
|
|
9
20
|
/**
|
|
10
21
|
* @param value {any} the initial value
|
|
11
22
|
*/
|
|
@@ -14,13 +25,20 @@ export class Reference extends IValue {
|
|
|
14
25
|
this.state = value;
|
|
15
26
|
this.onChange = new Set();
|
|
16
27
|
}
|
|
17
|
-
get
|
|
28
|
+
get V() {
|
|
18
29
|
return this.state;
|
|
19
30
|
}
|
|
20
|
-
set
|
|
31
|
+
set V(value) {
|
|
21
32
|
if (this.state !== value) {
|
|
22
33
|
this.state = value;
|
|
23
|
-
this.
|
|
34
|
+
this.onChange.forEach(handler => {
|
|
35
|
+
try {
|
|
36
|
+
handler(value);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
reportError(e);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
24
42
|
}
|
|
25
43
|
}
|
|
26
44
|
on(handler) {
|
|
@@ -29,18 +47,4 @@ export class Reference extends IValue {
|
|
|
29
47
|
off(handler) {
|
|
30
48
|
this.onChange.delete(handler);
|
|
31
49
|
}
|
|
32
|
-
destroy() {
|
|
33
|
-
super.destroy();
|
|
34
|
-
this.onChange.clear();
|
|
35
|
-
}
|
|
36
|
-
updateDeps(value) {
|
|
37
|
-
this.onChange.forEach(handler => {
|
|
38
|
-
try {
|
|
39
|
-
handler(value);
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
reportError(e);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
50
|
}
|
package/lib/views/array-view.js
CHANGED
|
@@ -5,13 +5,13 @@ import { BaseView } from "./base-view.js";
|
|
|
5
5
|
* @extends BaseView
|
|
6
6
|
*/
|
|
7
7
|
export class ArrayView extends BaseView {
|
|
8
|
-
createChild(
|
|
9
|
-
super.createChild(
|
|
8
|
+
createChild(id, item, before) {
|
|
9
|
+
super.createChild(item, item, before || this.nodes.get(id));
|
|
10
10
|
}
|
|
11
11
|
compose() {
|
|
12
12
|
super.compose();
|
|
13
|
-
this.
|
|
14
|
-
this.createChild(
|
|
13
|
+
this.model.forEach(item => {
|
|
14
|
+
this.createChild(item, item);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
}
|
package/lib/views/base-view.js
CHANGED
|
@@ -3,25 +3,36 @@ import { RepeatNode } from "./repeat-node.js";
|
|
|
3
3
|
* Base class of default views
|
|
4
4
|
* @class BaseView
|
|
5
5
|
* @extends RepeatNode
|
|
6
|
-
* @implements IModel
|
|
7
6
|
*/
|
|
8
7
|
export class BaseView extends RepeatNode {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
model;
|
|
9
|
+
/**
|
|
10
|
+
* Handler to catch values addition
|
|
11
|
+
* @type {Function}
|
|
12
|
+
*/
|
|
13
|
+
addHandler;
|
|
14
|
+
/**
|
|
15
|
+
* Handler to catch values removes
|
|
16
|
+
* @type {Function}
|
|
17
|
+
*/
|
|
18
|
+
removeHandler;
|
|
19
|
+
constructor(input, runner) {
|
|
20
|
+
super(input, runner);
|
|
21
|
+
this.model = input.model;
|
|
11
22
|
}
|
|
12
23
|
compose() {
|
|
13
24
|
this.addHandler = (id, item) => {
|
|
14
|
-
this.createChild(
|
|
25
|
+
this.createChild(id, item);
|
|
15
26
|
};
|
|
16
27
|
this.removeHandler = (id, item) => {
|
|
17
28
|
this.destroyChild(id, item);
|
|
18
29
|
};
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
30
|
+
this.model.listener.onAdd(this.addHandler);
|
|
31
|
+
this.model.listener.onRemove(this.removeHandler);
|
|
21
32
|
}
|
|
22
33
|
destroy() {
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
34
|
+
this.model.listener.offAdd(this.addHandler);
|
|
35
|
+
this.model.listener.offRemove(this.removeHandler);
|
|
25
36
|
super.destroy();
|
|
26
37
|
}
|
|
27
38
|
}
|
package/lib/views/map-view.js
CHANGED
|
@@ -7,8 +7,8 @@ import { BaseView } from "./base-view.js";
|
|
|
7
7
|
export class MapView extends BaseView {
|
|
8
8
|
compose() {
|
|
9
9
|
super.compose();
|
|
10
|
-
this.
|
|
11
|
-
this.createChild(
|
|
10
|
+
this.model.forEach((value, key) => {
|
|
11
|
+
this.createChild(key, value);
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
}
|
package/lib/views/repeat-node.js
CHANGED
|
@@ -5,17 +5,18 @@ import { Fragment } from "../node/node.js";
|
|
|
5
5
|
* @extends Fragment
|
|
6
6
|
*/
|
|
7
7
|
export class RepeatNode extends Fragment {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Children node hash
|
|
10
|
+
* @type {Map}
|
|
11
|
+
*/
|
|
12
|
+
nodes = new Map();
|
|
13
|
+
slot;
|
|
14
|
+
constructor(input, runner) {
|
|
15
|
+
super(runner);
|
|
16
|
+
this.slot = input.slot;
|
|
15
17
|
}
|
|
16
|
-
createChild(
|
|
17
|
-
const
|
|
18
|
-
const node = new Fragment({}, this.runner, `${_id}`);
|
|
18
|
+
createChild(id, item, before) {
|
|
19
|
+
const node = new Fragment(this.runner);
|
|
19
20
|
node.parent = this;
|
|
20
21
|
this.destroyChild(id, item);
|
|
21
22
|
if (before) {
|
|
@@ -30,7 +31,7 @@ export class RepeatNode extends Fragment {
|
|
|
30
31
|
this.children.add(node);
|
|
31
32
|
}
|
|
32
33
|
this.lastChild = node;
|
|
33
|
-
|
|
34
|
+
this.slot?.(node, item, id);
|
|
34
35
|
this.nodes.set(id, node);
|
|
35
36
|
}
|
|
36
37
|
destroyChild(id, item) {
|
package/lib/views/set-view.js
CHANGED
|
@@ -6,12 +6,12 @@ import { BaseView } from "./base-view.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export class SetView extends BaseView {
|
|
8
8
|
constructor(input, runner) {
|
|
9
|
-
super(input, runner
|
|
9
|
+
super(input, runner);
|
|
10
10
|
}
|
|
11
11
|
compose() {
|
|
12
12
|
super.compose();
|
|
13
|
-
this.
|
|
14
|
-
this.createChild(
|
|
13
|
+
this.model.forEach(item => {
|
|
14
|
+
this.createChild(item, item);
|
|
15
15
|
});
|
|
16
16
|
return {};
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vasille",
|
|
3
|
-
"description": "The
|
|
3
|
+
"description": "The framework designed to build bulletproof frontends (core library).",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "4.0.0",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./types/index.d.ts",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"prepack": "cp -f ../README.md ./README.md",
|
|
23
23
|
"prettier": "npx prettier src test --write",
|
|
24
|
+
"prebuild": "rm -rf types lib",
|
|
24
25
|
"build": "tsc --build tsconfig.json",
|
|
25
|
-
"test": "jest",
|
|
26
|
-
"test-coverage": "jest --coverage"
|
|
27
|
-
"update-types": "tsc --build tsconfig-types.json"
|
|
26
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
|
27
|
+
"test-coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
@@ -41,6 +41,13 @@
|
|
|
41
41
|
],
|
|
42
42
|
"author": "lixcode",
|
|
43
43
|
"license": "MIT",
|
|
44
|
+
"browserslist": [
|
|
45
|
+
"safari 6",
|
|
46
|
+
"ie 10",
|
|
47
|
+
"chrome 23",
|
|
48
|
+
"firefox 21",
|
|
49
|
+
"opera 15"
|
|
50
|
+
],
|
|
44
51
|
"bugs": {
|
|
45
52
|
"url": "https://github.com/vasille-js/vasille-js/issues"
|
|
46
53
|
},
|
|
@@ -53,14 +60,16 @@
|
|
|
53
60
|
"@types/events": "^3.0.3",
|
|
54
61
|
"@types/jest": "^30.0.0",
|
|
55
62
|
"@types/jsdom": "^21.1.7",
|
|
56
|
-
"@
|
|
57
|
-
"
|
|
58
|
-
"eslint": "^9.
|
|
63
|
+
"@types/node": "^24.2.1",
|
|
64
|
+
"cross-env": "^10.0.0",
|
|
65
|
+
"eslint": "^9.33.0",
|
|
66
|
+
"eslint-plugin-compat": "^6.0.2",
|
|
59
67
|
"jest": "^30.0.5",
|
|
60
68
|
"jsdom": "^26.1.0",
|
|
61
69
|
"prettier": "^3.6.2",
|
|
62
70
|
"ts-jest": "^29.4.0",
|
|
63
71
|
"tslint-config-prettier": "^1.18.0",
|
|
64
|
-
"typescript": "^5.8.3"
|
|
72
|
+
"typescript": "^5.8.3",
|
|
73
|
+
"typescript-eslint": "^8.39.0"
|
|
65
74
|
}
|
|
66
75
|
}
|
package/types/core/core.d.ts
CHANGED
|
@@ -1,60 +1,16 @@
|
|
|
1
1
|
import { Destroyable } from "./destroyable.js";
|
|
2
|
-
import { IValue } from "./ivalue.js";
|
|
3
|
-
import { KindOfIValue } from "../value/expression.js";
|
|
4
|
-
import { Pointer } from "../value/pointer.js";
|
|
5
2
|
/**
|
|
6
3
|
* A reactive object
|
|
7
4
|
* @class Reactive
|
|
8
5
|
* @extends Destroyable
|
|
9
6
|
*/
|
|
10
|
-
export declare class Reactive
|
|
7
|
+
export declare class Reactive implements Destroyable {
|
|
11
8
|
/**
|
|
12
9
|
* A list of user-defined bindings
|
|
13
|
-
* @type {Set}
|
|
14
10
|
*/
|
|
15
|
-
private
|
|
11
|
+
private linked;
|
|
16
12
|
private onDestroy?;
|
|
17
|
-
|
|
18
|
-
readonly state: Record<string, [string, unknown]>;
|
|
19
|
-
constructor(input: T);
|
|
20
|
-
/**
|
|
21
|
-
* Create a reference
|
|
22
|
-
* @param value {*} value to reference
|
|
23
|
-
* @param name {string} used for debugging internal state
|
|
24
|
-
*/
|
|
25
|
-
ref<T>(value: T, name?: string): IValue<T>;
|
|
26
|
-
/**
|
|
27
|
-
* Create a forward-only pointer
|
|
28
|
-
* @param value {IValue} value to point
|
|
29
|
-
* @param name {string} used for debugging internal state
|
|
30
|
-
*/
|
|
31
|
-
forward<T>(value: IValue<T>, name?: string): IValue<T>;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a pointer
|
|
34
|
-
* @param value {*} default value to point
|
|
35
|
-
* @param name {string} used for debugging internal state
|
|
36
|
-
*/
|
|
37
|
-
own<T>(value: IValue<T>, name?: string): Pointer<T>;
|
|
38
|
-
/**
|
|
39
|
-
* Register a model/dependency
|
|
40
|
-
*/
|
|
41
|
-
register<T extends Destroyable>(data: T, name?: string): T;
|
|
42
|
-
release(data: Destroyable): void;
|
|
43
|
-
/**
|
|
44
|
-
* Creates a watcher
|
|
45
|
-
* @param func {function} function to run on any argument change
|
|
46
|
-
* @param values
|
|
47
|
-
*/
|
|
48
|
-
watch<Args extends unknown[]>(func: (...args: Args) => void, values: KindOfIValue<Args>): void;
|
|
49
|
-
/**
|
|
50
|
-
* Creates a computed value
|
|
51
|
-
* @param func {function} function to run on any argument change
|
|
52
|
-
* @param values
|
|
53
|
-
* @param name {string} used for debugging internal state
|
|
54
|
-
* @return {IValue} the created ivalue
|
|
55
|
-
*/
|
|
56
|
-
expr<T, Args extends unknown[]>(func: (...args: Args) => T, values: KindOfIValue<Args>, name?: string): IValue<T>;
|
|
13
|
+
bind<T extends Destroyable>(value: T): void;
|
|
57
14
|
runOnDestroy(func: () => void): void;
|
|
58
|
-
addState(method: string, name: string, state: unknown): void;
|
|
59
15
|
destroy(): void;
|
|
60
16
|
}
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mark an object which can be destroyed
|
|
3
|
-
* @interface
|
|
3
|
+
* @interface Destroyable
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
6
|
-
/**
|
|
7
|
-
* Garbage collector method
|
|
8
|
-
*/
|
|
9
|
-
destroy(): void;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Mark an object which can be destroyed
|
|
13
|
-
* @class Destroyable
|
|
14
|
-
*/
|
|
15
|
-
export declare class Destroyable implements IDestroyable {
|
|
5
|
+
export interface Destroyable {
|
|
16
6
|
/**
|
|
17
7
|
* Garbage collector method
|
|
18
8
|
*/
|
package/types/core/ivalue.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { Destroyable } from "./destroyable.js";
|
|
2
1
|
/**
|
|
3
2
|
* Interface which describes a value
|
|
4
3
|
* @class IValue
|
|
5
|
-
* @extends Destroyable
|
|
6
4
|
*/
|
|
7
|
-
export declare abstract class IValue<T>
|
|
5
|
+
export declare abstract class IValue<T> {
|
|
8
6
|
/**
|
|
9
7
|
* Get the encapsulated value
|
|
10
8
|
* @return {*} the encapsulated value
|
|
11
9
|
*/
|
|
12
|
-
abstract get
|
|
10
|
+
abstract get V(): T;
|
|
13
11
|
/**
|
|
14
12
|
* Sets the encapsulated value
|
|
15
13
|
* @param value {*} value to encapsulate
|
|
16
14
|
*/
|
|
17
|
-
abstract set
|
|
15
|
+
abstract set V(value: T);
|
|
18
16
|
/**
|
|
19
17
|
* Add a new handler to value change
|
|
20
18
|
* @param handler {function(value : *)} the handler to add
|
package/types/index.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export { Destroyable, IValue, Reference, Pointer, ArrayModel, proxyArrayModel, MapModel, SetModel, BaseView, Listener, ArrayView, MapView, SetView, Fragment, Tag, App, Portal, Expression, Reactive, TextNode, DebugNode, Watch, Runner, KindOfIValue, ListenableModel, userError, setErrorHandler, reportError, };
|
|
1
|
+
export type { Destroyable } from "./core/destroyable.js";
|
|
2
|
+
export { Reactive } from "./core/core.js";
|
|
3
|
+
export { IValue } from "./core/ivalue.js";
|
|
4
|
+
export { reportError, setErrorHandler } from "./functional/safety.js";
|
|
5
|
+
export { ArrayModel } from "./models/array-model.js";
|
|
6
|
+
export { Listener } from "./models/listener.js";
|
|
7
|
+
export { MapModel } from "./models/map-model.js";
|
|
8
|
+
export { SetModel } from "./models/set-model.js";
|
|
9
|
+
export { App, Portal } from "./node/app.js";
|
|
10
|
+
export { Fragment, Tag, TextNode, DebugNode, SwitchedNode } from "./node/node.js";
|
|
11
|
+
export { Expression, type KindOfIValue } from "./value/expression.js";
|
|
12
|
+
export { Forward, Backward } from "./value/pointer.js";
|
|
13
|
+
export { Reference } from "./value/reference.js";
|
|
14
|
+
export { ArrayView } from "./views/array-view.js";
|
|
15
|
+
export { BaseView } from "./views/base-view.js";
|
|
16
|
+
export { MapView } from "./views/map-view.js";
|
|
17
|
+
export { SetView } from "./views/set-view.js";
|
|
18
|
+
export { userError } from "./core/errors.js";
|
|
19
|
+
export { type ListenableModel } from "./models/model.js";
|
|
20
|
+
export { Watch } from "./node/watch.js";
|
|
21
|
+
export { type Runner } from "./node/runner.js";
|
|
@@ -1,42 +1,43 @@
|
|
|
1
|
+
import { Reactive } from "../core/core.js";
|
|
1
2
|
import { Listener } from "./listener.js";
|
|
2
3
|
import { ListenableModel } from "./model.js";
|
|
3
4
|
/**
|
|
4
5
|
* Model based on Array class
|
|
5
6
|
* @extends Array
|
|
6
|
-
* @implements
|
|
7
|
+
* @implements ListenableModel
|
|
7
8
|
*/
|
|
8
9
|
export declare class ArrayModel<T> extends Array<T> implements ListenableModel<T, T> {
|
|
9
10
|
listener: Listener<T, T>;
|
|
10
|
-
passive: boolean;
|
|
11
11
|
/**
|
|
12
12
|
* @param data {Array} input data
|
|
13
|
+
* @param ctx lifetime context of model
|
|
13
14
|
*/
|
|
14
|
-
constructor(data?: Array<T> | number);
|
|
15
|
+
constructor(data?: Array<T> | number, ctx?: Reactive);
|
|
15
16
|
/**
|
|
16
|
-
* Calls Array.fill and notify about changes
|
|
17
|
+
* Calls `Array.fill` and notify about changes
|
|
17
18
|
* @param value {*} value to fill with
|
|
18
19
|
* @param start {?number} begin index
|
|
19
20
|
* @param end {?number} end index
|
|
20
21
|
*/
|
|
21
22
|
fill(value: T, start?: number, end?: number): this;
|
|
22
23
|
/**
|
|
23
|
-
* Calls Array.pop and notify about changes
|
|
24
|
+
* Calls `Array.pop` and notify about changes
|
|
24
25
|
* @return {*} removed value
|
|
25
26
|
*/
|
|
26
27
|
pop(): T | undefined;
|
|
27
28
|
/**
|
|
28
|
-
* Calls Array.push and notify about changes
|
|
29
|
+
* Calls `Array.push` and notify about changes
|
|
29
30
|
* @param items {...*} values to push
|
|
30
|
-
* @return {number} new length of array
|
|
31
|
+
* @return {number} new length of the array
|
|
31
32
|
*/
|
|
32
33
|
push(...items: Array<T>): number;
|
|
33
34
|
/**
|
|
34
|
-
* Calls Array.shift and notify about changed
|
|
35
|
+
* Calls `Array.shift` and notify about changed
|
|
35
36
|
* @return {*} the shifted value
|
|
36
37
|
*/
|
|
37
38
|
shift(): T | undefined;
|
|
38
39
|
/**
|
|
39
|
-
* Calls Array.splice and notify about changed
|
|
40
|
+
* Calls `Array.splice` and notify about changed
|
|
40
41
|
* @param start {number} start index
|
|
41
42
|
* @param deleteCount {?number} delete count
|
|
42
43
|
* @param items {...*}
|
|
@@ -46,10 +47,9 @@ export declare class ArrayModel<T> extends Array<T> implements ListenableModel<T
|
|
|
46
47
|
/**
|
|
47
48
|
* Calls Array.unshift and notify about changed
|
|
48
49
|
* @param items {...*} values to insert
|
|
49
|
-
* @return {number} the length after
|
|
50
|
+
* @return {number} the length after prepending
|
|
50
51
|
*/
|
|
51
52
|
unshift(...items: Array<T>): number;
|
|
52
53
|
replace(at: number, with_: T): this;
|
|
53
54
|
destroy(): void;
|
|
54
55
|
}
|
|
55
|
-
export declare function proxyArrayModel<T>(arr: ArrayModel<T>): ArrayModel<T>;
|
|
@@ -18,31 +18,31 @@ export declare class Listener<ValueT, IndexT = string | number> {
|
|
|
18
18
|
* @param index {*} index of value
|
|
19
19
|
* @param value {*} value of added item
|
|
20
20
|
*/
|
|
21
|
-
emitAdded(index
|
|
21
|
+
emitAdded(index?: IndexT, value?: ValueT): void;
|
|
22
22
|
/**
|
|
23
23
|
* Emits removed event to listeners
|
|
24
24
|
* @param index {*} index of removed value
|
|
25
25
|
* @param value {*} value of removed item
|
|
26
26
|
*/
|
|
27
|
-
emitRemoved(index
|
|
27
|
+
emitRemoved(index?: IndexT, value?: ValueT): void;
|
|
28
28
|
/**
|
|
29
29
|
* Adds a handler to added event
|
|
30
30
|
* @param handler {function} function to run on event emitting
|
|
31
31
|
*/
|
|
32
|
-
onAdd(handler: (index
|
|
32
|
+
onAdd(handler: (index?: IndexT, value?: ValueT) => void): void;
|
|
33
33
|
/**
|
|
34
34
|
* Adds a handler to removed event
|
|
35
35
|
* @param handler {function} function to run on event emitting
|
|
36
36
|
*/
|
|
37
|
-
onRemove(handler: (index
|
|
37
|
+
onRemove(handler: (index?: IndexT, value?: ValueT) => void): void;
|
|
38
38
|
/**
|
|
39
|
-
* Removes
|
|
39
|
+
* Removes a handler from added event
|
|
40
40
|
* @param handler {function} handler to remove
|
|
41
41
|
*/
|
|
42
|
-
offAdd(handler: (index
|
|
42
|
+
offAdd(handler: (index?: IndexT, value?: ValueT) => void): void;
|
|
43
43
|
/**
|
|
44
|
-
* Removes
|
|
44
|
+
* Removes a handler form removed event
|
|
45
45
|
* @param handler {function} handler to remove
|
|
46
46
|
*/
|
|
47
|
-
offRemove(handler: (index
|
|
47
|
+
offRemove(handler: (index?: IndexT, value?: ValueT) => void): void;
|
|
48
48
|
}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
+
import { Reactive } from "../core/core.js";
|
|
1
2
|
import { Listener } from "./listener.js";
|
|
2
3
|
import { ListenableModel } from "./model.js";
|
|
3
4
|
/**
|
|
4
|
-
* A Map based memory
|
|
5
|
+
* A `Map` based memory
|
|
5
6
|
* @class MapModel
|
|
6
7
|
* @extends Map
|
|
7
|
-
* @implements
|
|
8
|
+
* @implements ListenableModel
|
|
8
9
|
*/
|
|
9
10
|
export declare class MapModel<K, T> extends Map<K, T> implements ListenableModel<K, T> {
|
|
10
11
|
listener: Listener<T, K>;
|
|
11
12
|
/**
|
|
12
13
|
* Constructs a map model
|
|
13
14
|
* @param map {[*, *][]} input data
|
|
15
|
+
* @param ctx lifetime context
|
|
14
16
|
*/
|
|
15
|
-
constructor(map?: [K, T][]);
|
|
17
|
+
constructor(map?: [K, T][], ctx?: Reactive);
|
|
16
18
|
/**
|
|
17
|
-
* Calls Map.clear and notify about changes
|
|
19
|
+
* Calls `Map.clear` and notify about changes
|
|
18
20
|
*/
|
|
19
21
|
clear(): void;
|
|
20
22
|
/**
|
|
21
|
-
* Calls Map.delete and notify abut changes
|
|
23
|
+
* Calls `Map.delete` and notify abut changes
|
|
22
24
|
* @param key {*} key
|
|
23
25
|
* @return {boolean} true if removed something, otherwise false
|
|
24
26
|
*/
|
|
25
27
|
delete(key: K): boolean;
|
|
26
28
|
/**
|
|
27
|
-
* Calls Map.set and notify abut changes
|
|
29
|
+
* Calls `Map.set` and notify abut changes
|
|
28
30
|
* @param key {*} key
|
|
29
31
|
* @param value {*} value
|
|
30
32
|
* @return {MapModel} a pointer to this
|