vasille 1.2.9 → 2.0.3
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/LICENSE.md +21 -0
- package/README.md +195 -129
- package/cdn/es2015.js +3231 -0
- package/cdn/es5.js +3675 -0
- package/flow-typed/vasille.js +839 -0
- package/lib/binding/attribute.js +32 -0
- package/lib/binding/binding.js +39 -0
- package/lib/binding/class.js +51 -0
- package/lib/binding/style.js +29 -0
- package/lib/core/core.js +186 -0
- package/lib/core/destroyable.js +45 -0
- package/lib/core/errors.js +16 -0
- package/lib/core/executor.js +154 -0
- package/lib/core/ivalue.js +56 -0
- package/lib/core/signal.js +50 -0
- package/lib/core/slot.js +47 -0
- package/lib/index.js +27 -22
- package/lib/models/array-model.js +208 -0
- package/lib/models/listener.js +130 -0
- package/lib/models/map-model.js +66 -0
- package/lib/models/model.js +1 -0
- package/lib/models/object-model.js +78 -0
- package/lib/models/set-model.js +62 -0
- package/lib/node/app.js +39 -0
- package/lib/node/interceptor.js +83 -0
- package/lib/node/node.js +1204 -0
- package/lib/node/watch.js +27 -0
- package/lib/value/expression.js +83 -0
- package/lib/value/mirror.js +58 -0
- package/lib/value/pointer.js +26 -0
- package/lib/value/reference.js +55 -0
- package/lib/views/array-view.js +21 -0
- package/lib/views/base-view.js +49 -0
- package/lib/views/map-view.js +19 -0
- package/lib/views/object-view.js +19 -0
- package/lib/views/repeat-node.js +106 -0
- package/lib/views/repeater.js +63 -0
- package/lib/views/set-view.js +22 -0
- package/package.json +26 -18
- package/types/binding/attribute.d.ts +23 -0
- package/types/binding/binding.d.ts +30 -0
- package/types/binding/class.d.ts +23 -0
- package/types/binding/style.d.ts +23 -0
- package/types/core/core.d.ts +144 -0
- package/types/core/destroyable.d.ts +15 -0
- package/types/core/errors.d.ts +4 -0
- package/types/core/executor.d.ts +87 -0
- package/types/core/ivalue.d.ts +45 -0
- package/types/core/signal.d.ts +35 -0
- package/types/core/slot.d.ts +45 -0
- package/types/index.d.ts +27 -21
- package/types/models/array-model.d.ts +103 -0
- package/types/models/listener.d.ts +74 -0
- package/types/models/map-model.d.ts +35 -0
- package/types/models/model.d.ts +19 -0
- package/types/models/object-model.d.ts +36 -0
- package/types/models/set-model.d.ts +34 -0
- package/types/node/app.d.ts +42 -0
- package/types/node/interceptor.d.ts +50 -0
- package/types/node/node.d.ts +741 -0
- package/types/node/watch.d.ts +23 -0
- package/types/value/expression.d.ts +60 -0
- package/types/value/mirror.d.ts +35 -0
- package/types/value/pointer.d.ts +19 -0
- package/types/value/reference.d.ts +30 -0
- package/types/views/array-view.d.ts +13 -0
- package/types/views/base-view.d.ts +43 -0
- package/types/views/map-view.d.ts +11 -0
- package/types/views/object-view.d.ts +11 -0
- package/types/views/repeat-node.d.ts +35 -0
- package/types/views/repeater.d.ts +38 -0
- package/types/views/set-view.d.ts +11 -0
- package/CHANGELOG.md +0 -23
- package/img/favicon.svg +0 -441
- package/img/getLocus.svg +0 -18
- package/img/logo.png +0 -0
- package/img/logo.svg +0 -550
- package/img/scores-o-log.png +0 -0
- package/img/scores-o.png +0 -0
- package/img/scores-wo-log.png +0 -0
- package/img/scores-wo.png +0 -0
- package/img/x1-x32.png +0 -0
- package/lib/attribute.js +0 -71
- package/lib/attribute.js.map +0 -1
- package/lib/bind.js +0 -286
- package/lib/bind.js.map +0 -1
- package/lib/class.js +0 -97
- package/lib/class.js.map +0 -1
- package/lib/executor.js +0 -167
- package/lib/executor.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interfaces/core.js +0 -247
- package/lib/interfaces/core.js.map +0 -1
- package/lib/interfaces/destroyable.js +0 -39
- package/lib/interfaces/destroyable.js.map +0 -1
- package/lib/interfaces/errors.js +0 -49
- package/lib/interfaces/errors.js.map +0 -1
- package/lib/interfaces/ibind.js +0 -31
- package/lib/interfaces/ibind.js.map +0 -1
- package/lib/interfaces/idefinition.js +0 -64
- package/lib/interfaces/idefinition.js.map +0 -1
- package/lib/interfaces/ivalue.js +0 -60
- package/lib/interfaces/ivalue.js.map +0 -1
- package/lib/models.js +0 -579
- package/lib/models.js.map +0 -1
- package/lib/node.js +0 -2155
- package/lib/node.js.map +0 -1
- package/lib/property.js +0 -38
- package/lib/property.js.map +0 -1
- package/lib/style.js +0 -66
- package/lib/style.js.map +0 -1
- package/lib/value.js +0 -203
- package/lib/value.js.map +0 -1
- package/lib/views.js +0 -688
- package/lib/views.js.map +0 -1
- package/types/attribute.d.ts +0 -18
- package/types/bind.d.ts +0 -72
- package/types/class.d.ts +0 -19
- package/types/data.d.ts +0 -11
- package/types/event.d.ts +0 -10
- package/types/executor.d.ts +0 -57
- package/types/interfaces/core.d.ts +0 -129
- package/types/interfaces/destroyable.d.ts +0 -11
- package/types/interfaces/errors.d.ts +0 -24
- package/types/interfaces/ibind.d.ts +0 -19
- package/types/interfaces/idefinition.d.ts +0 -29
- package/types/interfaces/ivalue.d.ts +0 -40
- package/types/models.d.ts +0 -179
- package/types/node.d.ts +0 -906
- package/types/property.d.ts +0 -9
- package/types/style.d.ts +0 -28
- package/types/value.d.ts +0 -43
- package/types/views.d.ts +0 -135
package/types/bind.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bind some values to one expression
|
|
3
|
-
* @implements IBind
|
|
4
|
-
*/
|
|
5
|
-
export class Expression extends IBind implements IBind {
|
|
6
|
-
/**
|
|
7
|
-
* Creates a function bounded to N value
|
|
8
|
-
* @param func {Function} The function to bound
|
|
9
|
-
* @param values {Array<IValue<*>>} Values to bound to
|
|
10
|
-
* @param link {Boolean} If true links immediately
|
|
11
|
-
*/
|
|
12
|
-
constructor(func: Function, values: Array<IValue<any>>, link?: boolean);
|
|
13
|
-
/**
|
|
14
|
-
* The array of value which will trigger recalculation
|
|
15
|
-
* @type {Array<IValue<*>>}
|
|
16
|
-
*/
|
|
17
|
-
values: Array<IValue<any>>;
|
|
18
|
-
/**
|
|
19
|
-
* Cache the values of expression variables
|
|
20
|
-
* @type {Array<*>}
|
|
21
|
-
* @version 1.1
|
|
22
|
-
*/
|
|
23
|
-
valuesCache: Array<any>;
|
|
24
|
-
/**
|
|
25
|
-
* The function which will be executed on recalculation
|
|
26
|
-
* @type {Function}
|
|
27
|
-
*/
|
|
28
|
-
func: Function;
|
|
29
|
-
/**
|
|
30
|
-
* Expression will link different handler for each value of list
|
|
31
|
-
* @type {Array<Function>}
|
|
32
|
-
* @version 1.1
|
|
33
|
-
*/
|
|
34
|
-
linkedFunc: Array<Function>;
|
|
35
|
-
/**
|
|
36
|
-
* The current linking state
|
|
37
|
-
* @type {boolean}
|
|
38
|
-
*/
|
|
39
|
-
linked: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* The buffer to keep the last calculated value
|
|
42
|
-
* @type {Reference<*>}
|
|
43
|
-
*/
|
|
44
|
-
sync: any;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Describe a common binding logic
|
|
48
|
-
* @implements IValue
|
|
49
|
-
*/
|
|
50
|
-
export class Binding extends IValue implements IValue {
|
|
51
|
-
/**
|
|
52
|
-
* Constructs a common binding logic
|
|
53
|
-
* @param rt {INode} Root component
|
|
54
|
-
* @param ts {INode} This component
|
|
55
|
-
* @param name {String} Name of property/attribute
|
|
56
|
-
* @param func {?Function} A function to run on value change
|
|
57
|
-
* @param values {Array<IValue>} values array to bind
|
|
58
|
-
*/
|
|
59
|
-
constructor(rt: any, ts: any, name: string, func: Function | null, ...values: Array<IValue>);
|
|
60
|
-
binding: IValue;
|
|
61
|
-
func: any;
|
|
62
|
-
owner: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Is a virtual function to get the specific bind function
|
|
65
|
-
* @param name {String} The name of attribute/property
|
|
66
|
-
* @returns {Function} A function to update attribute/property value
|
|
67
|
-
* @throws Always trows and must be overloaded in child class
|
|
68
|
-
*/
|
|
69
|
-
bound(name: string): Function;
|
|
70
|
-
}
|
|
71
|
-
import { IBind } from "./interfaces/ibind.js";
|
|
72
|
-
import { IValue } from "./interfaces/ivalue.js";
|
package/types/class.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a class target 1 to 1 bind
|
|
3
|
-
* @param rt {INode} is the root component
|
|
4
|
-
* @param ts {INode} is the this component
|
|
5
|
-
* @param name {String} is attribute name
|
|
6
|
-
* @param value {?any} is attribute value
|
|
7
|
-
* @param func {?Callable} is attribute value calculation function
|
|
8
|
-
* @returns {AttributeBinding} 1 to 1 bind of attribute
|
|
9
|
-
*/
|
|
10
|
-
export function classify(rt: any, ts: any, name: string, value?: any | null, func?: Callable | null): any;
|
|
11
|
-
/**
|
|
12
|
-
* Represents a HTML class binding description
|
|
13
|
-
* @extends Binding
|
|
14
|
-
*/
|
|
15
|
-
export class ClassBinding extends Binding {
|
|
16
|
-
current: any;
|
|
17
|
-
}
|
|
18
|
-
import { Callable } from "./interfaces/idefinition.js";
|
|
19
|
-
import { Binding } from "./bind.js";
|
package/types/data.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constructs a data field value
|
|
3
|
-
* @param rt {BaseNode} Root component
|
|
4
|
-
* @param ts {BaseNode} This component
|
|
5
|
-
* @param value {?*} The default value of field
|
|
6
|
-
* @param func {?Callable} The function to calc filed value
|
|
7
|
-
* @return {Value} A new generated value
|
|
8
|
-
*/
|
|
9
|
-
export function datify(rt: BaseNode, ts: BaseNode, value?: any | null, func?: Callable | null): any;
|
|
10
|
-
import { BaseNode } from "./node";
|
|
11
|
-
import { Callable } from "./interfaces/idefinition";
|
package/types/event.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Covert a event function to a Vasille.js value
|
|
3
|
-
* @param rt {BaseNode} is the root component
|
|
4
|
-
* @param ts {BaseNode} is the this component
|
|
5
|
-
* @param name {String} is the event name
|
|
6
|
-
* @param handler {Function} is the handler function
|
|
7
|
-
* @returns {Value} a Vasille.js value
|
|
8
|
-
*/
|
|
9
|
-
export function eventify(rt: BaseNode, ts: BaseNode, name: string, handler: Function): any;
|
|
10
|
-
import { BaseNode } from "./node";
|
package/types/executor.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents an executor unit interface
|
|
3
|
-
*/
|
|
4
|
-
export class Executor {
|
|
5
|
-
/**
|
|
6
|
-
* Adds a CSS class
|
|
7
|
-
* @param el {HTMLElement} HTML element
|
|
8
|
-
* @param cl {string}
|
|
9
|
-
*/
|
|
10
|
-
addClass(el: HTMLElement, cl: string): void;
|
|
11
|
-
/**
|
|
12
|
-
* Removes a CSS class
|
|
13
|
-
* @param el {HTMLElement} HTML element
|
|
14
|
-
* @param cl {string}
|
|
15
|
-
*/
|
|
16
|
-
removeClass(el: HTMLElement, cl: string): void;
|
|
17
|
-
/**
|
|
18
|
-
* Sets a tag attribute
|
|
19
|
-
* @param el {HTMLElement} HTML element
|
|
20
|
-
* @param name {string}
|
|
21
|
-
* @param value {string}
|
|
22
|
-
*/
|
|
23
|
-
setAttribute(el: HTMLElement, name: string, value: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* Removes a tag attribute
|
|
26
|
-
* @param el {HTMLElement} HTML element
|
|
27
|
-
* @param name {string}
|
|
28
|
-
*/
|
|
29
|
-
removeAttribute(el: HTMLElement, name: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Sets a style attribute
|
|
32
|
-
* @param el {HTMLElement} HTML element
|
|
33
|
-
* @param prop {string}
|
|
34
|
-
* @param value {string}
|
|
35
|
-
*/
|
|
36
|
-
setStyle(el: HTMLElement, prop: string, value: string): void;
|
|
37
|
-
/**
|
|
38
|
-
* Inserts a child
|
|
39
|
-
* @param el {HTMLElement} HTML element
|
|
40
|
-
* @param child {HTMLElement | Text | Comment} Child to insert
|
|
41
|
-
* @param before {HTMLElement | Text | Comment} Child used as position locator
|
|
42
|
-
*/
|
|
43
|
-
insertBefore(el: HTMLElement, child: HTMLElement | Text | Comment, before: HTMLElement | Text | Comment): void;
|
|
44
|
-
/**
|
|
45
|
-
* Appends a child
|
|
46
|
-
* @param el {HTMLElement} HTML element
|
|
47
|
-
* @param child {HTMLElement | Text | Comment} Child to append
|
|
48
|
-
*/
|
|
49
|
-
appendChild(el: HTMLElement, child: HTMLElement | Text | Comment): void;
|
|
50
|
-
/**
|
|
51
|
-
* Calls a call-back function
|
|
52
|
-
* @param cb {Function} call-back function
|
|
53
|
-
*/
|
|
54
|
-
callCallback(cb: Function): void;
|
|
55
|
-
}
|
|
56
|
-
export class InstantExecutor extends Executor {
|
|
57
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Destroy all destroyable object fields
|
|
3
|
-
* @param obj {Object<any, any>} Object to be iterated
|
|
4
|
-
*/
|
|
5
|
-
export function $destroyObject(obj: any): void;
|
|
6
|
-
/**
|
|
7
|
-
* Represents a Vasille.js node
|
|
8
|
-
* @implements Destroyable
|
|
9
|
-
*/
|
|
10
|
-
export class VasilleNodePrivate extends Destroyable implements Destroyable {
|
|
11
|
-
/**
|
|
12
|
-
* The encapsulated element
|
|
13
|
-
* @type {HTMLElement | Text | Comment}
|
|
14
|
-
* @see VasilleNode#coreEl
|
|
15
|
-
* @see VasilleNode#el
|
|
16
|
-
* @see VasilleNode#text
|
|
17
|
-
* @see VasilleNode#comment
|
|
18
|
-
*/
|
|
19
|
-
$el: HTMLElement | Text | Comment;
|
|
20
|
-
/**
|
|
21
|
-
* The collection of attributes
|
|
22
|
-
* @type {Object<String, IValue>}
|
|
23
|
-
* @see VasilleNode#attr
|
|
24
|
-
*/
|
|
25
|
-
$attrs: any;
|
|
26
|
-
/**
|
|
27
|
-
* The collection of style attributes
|
|
28
|
-
* @type {Object<String, IValue>}
|
|
29
|
-
* @see VasilleNode#style
|
|
30
|
-
*/
|
|
31
|
-
$style: any;
|
|
32
|
-
/**
|
|
33
|
-
* The root node
|
|
34
|
-
* @type {INode}
|
|
35
|
-
*/
|
|
36
|
-
root: any;
|
|
37
|
-
/**
|
|
38
|
-
* The this node
|
|
39
|
-
* @type {INode}
|
|
40
|
-
*/
|
|
41
|
-
ts: any;
|
|
42
|
-
/**
|
|
43
|
-
* The app node
|
|
44
|
-
* @type {VasilleNode}
|
|
45
|
-
*/
|
|
46
|
-
app: VasilleNode;
|
|
47
|
-
/**
|
|
48
|
-
* A link to a parent node
|
|
49
|
-
* @type {VasilleNode}
|
|
50
|
-
*/
|
|
51
|
-
parent: VasilleNode;
|
|
52
|
-
/**
|
|
53
|
-
* The next node
|
|
54
|
-
* @type {?VasilleNode}
|
|
55
|
-
*/
|
|
56
|
-
next: VasilleNode | null;
|
|
57
|
-
/**
|
|
58
|
-
* The previous node
|
|
59
|
-
* @type {?VasilleNode}
|
|
60
|
-
*/
|
|
61
|
-
prev: VasilleNode | null;
|
|
62
|
-
/**
|
|
63
|
-
* Gets the encapsulated element anyway
|
|
64
|
-
* @type {HTMLElement | Text | Comment}
|
|
65
|
-
* @see VasilleNode#$el
|
|
66
|
-
*/
|
|
67
|
-
get coreEl(): HTMLElement | Text | Comment;
|
|
68
|
-
/**
|
|
69
|
-
* Gets the encapsulated element if it is a html element, otherwise undefined
|
|
70
|
-
* @type {HTMLElement}
|
|
71
|
-
* @see VasilleNode#$el
|
|
72
|
-
*/
|
|
73
|
-
get el(): HTMLElement;
|
|
74
|
-
/**
|
|
75
|
-
* Gets the encapsulated element if it is a html text node, otherwise undefined
|
|
76
|
-
* @type {Text}
|
|
77
|
-
* @see VasilleNode#$el
|
|
78
|
-
*/
|
|
79
|
-
get text(): Text;
|
|
80
|
-
/**
|
|
81
|
-
* Gets the encapsulated element if it is a html comment, otherwise undefined
|
|
82
|
-
* @type {Comment}
|
|
83
|
-
* @see VasilleNode#$el
|
|
84
|
-
*/
|
|
85
|
-
get comment(): Comment;
|
|
86
|
-
/**
|
|
87
|
-
* Encapsulate element
|
|
88
|
-
* @param el {HTMLElement | Text | Comment} element to encapsulate
|
|
89
|
-
* @private
|
|
90
|
-
*/
|
|
91
|
-
private encapsulate;
|
|
92
|
-
/**
|
|
93
|
-
* Pre-initializes the base of a node
|
|
94
|
-
* @param app {App} the app node
|
|
95
|
-
* @param rt {INode} The root node
|
|
96
|
-
* @param ts {INode} The this node
|
|
97
|
-
* @param before {?VasilleNode} VasilleNode to paste this after
|
|
98
|
-
*/
|
|
99
|
-
preinit(app: any, rt: any, ts: any, before: VasilleNode | null): void;
|
|
100
|
-
/**
|
|
101
|
-
* Gets the component life attribute value
|
|
102
|
-
* @param field {string} attribute name
|
|
103
|
-
* @return {IValue}
|
|
104
|
-
*/
|
|
105
|
-
attr(field: string): IValue;
|
|
106
|
-
/**
|
|
107
|
-
* Gets the component life style attribute
|
|
108
|
-
* @param field {Object<String, IValue>}
|
|
109
|
-
* @return {IValue<string>}
|
|
110
|
-
* @see VasilleNode#$style
|
|
111
|
-
*/
|
|
112
|
-
style(field: any): any;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* This class is symbolic
|
|
116
|
-
*/
|
|
117
|
-
export class VasilleNode extends Destroyable {
|
|
118
|
-
/**
|
|
119
|
-
* Constructs a Vasille Node
|
|
120
|
-
* @param $ {VasilleNodePrivate}
|
|
121
|
-
*/
|
|
122
|
-
constructor($: VasilleNodePrivate);
|
|
123
|
-
/**
|
|
124
|
-
* @type {VasilleNodePrivate}
|
|
125
|
-
*/
|
|
126
|
-
$: VasilleNodePrivate;
|
|
127
|
-
}
|
|
128
|
-
import { Destroyable } from "./destroyable.js";
|
|
129
|
-
import { IValue } from "./ivalue.js";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @return {string}
|
|
3
|
-
*/
|
|
4
|
-
export function notOverwritten(): string;
|
|
5
|
-
/**
|
|
6
|
-
* @return {string}
|
|
7
|
-
*/
|
|
8
|
-
export function internalError(msg: any): string;
|
|
9
|
-
/**
|
|
10
|
-
* @return {string}
|
|
11
|
-
*/
|
|
12
|
-
export function userError(msg: any, err: any): string;
|
|
13
|
-
/**
|
|
14
|
-
* @return {string}
|
|
15
|
-
*/
|
|
16
|
-
export function typeError(msg: any): string;
|
|
17
|
-
/**
|
|
18
|
-
* @return {string}
|
|
19
|
-
*/
|
|
20
|
-
export function notFound(msg: any): string;
|
|
21
|
-
/**
|
|
22
|
-
* @return {string}
|
|
23
|
-
*/
|
|
24
|
-
export function wrongBinding(msg: any): string;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mark an object which can be bound
|
|
3
|
-
* @interface
|
|
4
|
-
*/
|
|
5
|
-
export class IBind extends IValue {
|
|
6
|
-
/**
|
|
7
|
-
* Ensure the binding to be bound
|
|
8
|
-
* @return a pointer to this
|
|
9
|
-
* @throws must be overwritten
|
|
10
|
-
*/
|
|
11
|
-
link(): void;
|
|
12
|
-
/**
|
|
13
|
-
* Ensure the binding to be unbound
|
|
14
|
-
* @return a pointer to this
|
|
15
|
-
* @throws must be overwritten
|
|
16
|
-
*/
|
|
17
|
-
unlink(): void;
|
|
18
|
-
}
|
|
19
|
-
import { IValue } from "./ivalue.js";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check the type of value
|
|
3
|
-
* @param v {*} value
|
|
4
|
-
* @param t {Function} type constructor
|
|
5
|
-
* @return {boolean}
|
|
6
|
-
*/
|
|
7
|
-
export function checkType(v: any, t: Function): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Check if a type is a subtype
|
|
10
|
-
* @param parent {Function} potential superclass
|
|
11
|
-
* @param child {Function} potential subclass
|
|
12
|
-
* @return {boolean}
|
|
13
|
-
*/
|
|
14
|
-
export function isSubclassOf(parent: Function, child: Function): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Represent a function encapsulated to a class
|
|
17
|
-
*/
|
|
18
|
-
export class Callable {
|
|
19
|
-
/**
|
|
20
|
-
* Encapsulates a function
|
|
21
|
-
* @param func {Function} function to encapsulate
|
|
22
|
-
*/
|
|
23
|
-
constructor(func: Function);
|
|
24
|
-
/**
|
|
25
|
-
* Function which will resolve value
|
|
26
|
-
* @type {Function}
|
|
27
|
-
*/
|
|
28
|
-
func: Function;
|
|
29
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A interface which describes a value
|
|
3
|
-
* @interface
|
|
4
|
-
* @extends Destroyable
|
|
5
|
-
*/
|
|
6
|
-
export class IValue extends Destroyable {
|
|
7
|
-
/**
|
|
8
|
-
* Used for strong type checking
|
|
9
|
-
* @type {?Function}
|
|
10
|
-
*/
|
|
11
|
-
type: Function | null;
|
|
12
|
-
/**
|
|
13
|
-
* Sets the encapsulated value
|
|
14
|
-
* @param value {*} Reference to encapsulate
|
|
15
|
-
* @return {IValue} A pointer to this
|
|
16
|
-
* @throws Must be overwritten
|
|
17
|
-
*/
|
|
18
|
-
set $(arg: any);
|
|
19
|
-
/**
|
|
20
|
-
* Gets the encapsulated value
|
|
21
|
-
* @return {*} Must return a value
|
|
22
|
-
* @throws Must be overwritten
|
|
23
|
-
*/
|
|
24
|
-
get $(): any;
|
|
25
|
-
/**
|
|
26
|
-
* Add a new handler to value change
|
|
27
|
-
* @param handler {Function} The handler to add
|
|
28
|
-
* @return {IValue} a pointer to this
|
|
29
|
-
* @throws Must be overwritten
|
|
30
|
-
*/
|
|
31
|
-
on(handler: Function): IValue;
|
|
32
|
-
/**
|
|
33
|
-
* Removes a handler of value change
|
|
34
|
-
* @param handler {Function} the handler to remove
|
|
35
|
-
* @return {IValue} a pointer to this
|
|
36
|
-
* @throws Must be overwritten
|
|
37
|
-
*/
|
|
38
|
-
off(handler: Function): IValue;
|
|
39
|
-
}
|
|
40
|
-
import { Destroyable } from "./destroyable.js";
|
package/types/models.d.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transforms a JS value to a Vasille.js value
|
|
3
|
-
* @param v {*} input value
|
|
4
|
-
* @return {IValue} transformed value
|
|
5
|
-
*/
|
|
6
|
-
export function vassilify(v: any): IValue;
|
|
7
|
-
/**
|
|
8
|
-
* Model based on Array class
|
|
9
|
-
* @extends Array<IValue>
|
|
10
|
-
*/
|
|
11
|
-
export class ArrayModel extends Array<IValue> {
|
|
12
|
-
/**
|
|
13
|
-
* Constructs an array model from an array
|
|
14
|
-
* @param data {Array<IValue>} input data
|
|
15
|
-
*/
|
|
16
|
-
constructor(data?: Array<IValue>);
|
|
17
|
-
/**
|
|
18
|
-
* Listener of array model
|
|
19
|
-
* @type {Listener}
|
|
20
|
-
*/
|
|
21
|
-
listener: Listener;
|
|
22
|
-
/**
|
|
23
|
-
* Gets the last value of array and null when it is empty
|
|
24
|
-
* @return {?IValue}
|
|
25
|
-
*/
|
|
26
|
-
get last(): IValue;
|
|
27
|
-
/**
|
|
28
|
-
* Inserts a value to the end of array
|
|
29
|
-
* @param v {*} value to insert
|
|
30
|
-
* @return {this} a pointer to this
|
|
31
|
-
*/
|
|
32
|
-
append(v: any): this;
|
|
33
|
-
/**
|
|
34
|
-
* Clears array
|
|
35
|
-
* @return {this} a pointer to this
|
|
36
|
-
*/
|
|
37
|
-
clear(): this;
|
|
38
|
-
/**
|
|
39
|
-
* Inserts a value to position <i>index</i>
|
|
40
|
-
* @param index {number} index to insert value
|
|
41
|
-
* @param v {*} value to insert
|
|
42
|
-
* @return {this} a pointer to this
|
|
43
|
-
*/
|
|
44
|
-
insert(index: number, v: any): this;
|
|
45
|
-
/**
|
|
46
|
-
* Inserts a value to the beginning of array
|
|
47
|
-
* @param v {*} value to insert
|
|
48
|
-
* @return {this} a pointer to this
|
|
49
|
-
*/
|
|
50
|
-
prepend(v: any): this;
|
|
51
|
-
/**
|
|
52
|
-
* Removes a value from an index
|
|
53
|
-
* @param index {number} index of value to remove
|
|
54
|
-
* @return {this} a pointer to this
|
|
55
|
-
*/
|
|
56
|
-
removeAt(index: number): this;
|
|
57
|
-
/**
|
|
58
|
-
* Removes the first value of array
|
|
59
|
-
* @return {this} a pointer to this
|
|
60
|
-
*/
|
|
61
|
-
removeFirst(): this;
|
|
62
|
-
/**
|
|
63
|
-
* Removes the ast value of array
|
|
64
|
-
* @return {this} a pointer to this
|
|
65
|
-
*/
|
|
66
|
-
removeLast(): this;
|
|
67
|
-
/**
|
|
68
|
-
* Remove the first occurrence of value
|
|
69
|
-
* @param v {IValue} value to remove
|
|
70
|
-
* @return {this}
|
|
71
|
-
*/
|
|
72
|
-
removeOne(v: IValue): this;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* A Object based model
|
|
76
|
-
* @extends Object<String, IValue>
|
|
77
|
-
*/
|
|
78
|
-
export class ObjectModel {
|
|
79
|
-
/**
|
|
80
|
-
* the listener of object
|
|
81
|
-
* @type {Listener}
|
|
82
|
-
*/
|
|
83
|
-
listener: Listener;
|
|
84
|
-
/**
|
|
85
|
-
* Gets a value of a field
|
|
86
|
-
* @param key {string}
|
|
87
|
-
* @return {IValue<*>}
|
|
88
|
-
*/
|
|
89
|
-
get(key: string): any;
|
|
90
|
-
/**
|
|
91
|
-
* Sets a object property value <b>(use for new properties only)</b>
|
|
92
|
-
* @param key {string} property name
|
|
93
|
-
* @param v {*} property value
|
|
94
|
-
* @return {ObjectModel} a pointer to this
|
|
95
|
-
*/
|
|
96
|
-
set(key: string, v: any): ObjectModel;
|
|
97
|
-
/**
|
|
98
|
-
* Deletes a object property
|
|
99
|
-
* @param key {string} property name
|
|
100
|
-
*/
|
|
101
|
-
delete(key: string): void;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* A Map based memory
|
|
105
|
-
* @extends Map<*, IValue>
|
|
106
|
-
*/
|
|
107
|
-
export class MapModel extends Map<any, IValue> {
|
|
108
|
-
/**
|
|
109
|
-
* Constructs a map model based on a map
|
|
110
|
-
* @param map {Map<*, IValue>} input data
|
|
111
|
-
*/
|
|
112
|
-
constructor(map?: Map<any, IValue>);
|
|
113
|
-
/**
|
|
114
|
-
* listener of map
|
|
115
|
-
* @type {Listener}
|
|
116
|
-
*/
|
|
117
|
-
listener: Listener;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* A Set based model
|
|
121
|
-
* @extends Set<IValue>
|
|
122
|
-
*/
|
|
123
|
-
export class SetModel extends Set<IValue> {
|
|
124
|
-
/**
|
|
125
|
-
* Constructs a set model based on a set
|
|
126
|
-
* @param set {Set<IValue>} input data
|
|
127
|
-
*/
|
|
128
|
-
constructor(set?: Set<IValue>);
|
|
129
|
-
listener: any;
|
|
130
|
-
}
|
|
131
|
-
import { IValue } from "./interfaces/ivalue.js";
|
|
132
|
-
/**
|
|
133
|
-
* Represent a listener for a model
|
|
134
|
-
*/
|
|
135
|
-
declare class Listener {
|
|
136
|
-
/**
|
|
137
|
-
* Functions to run on adding new items
|
|
138
|
-
* @type {Set<Function>}
|
|
139
|
-
*/
|
|
140
|
-
onAdded: Set<Function>;
|
|
141
|
-
/**
|
|
142
|
-
* Functions to run on item removing
|
|
143
|
-
* @type {Set<Function>}
|
|
144
|
-
*/
|
|
145
|
-
onRemoved: Set<Function>;
|
|
146
|
-
/**
|
|
147
|
-
* Emits added event to listeners
|
|
148
|
-
* @param index {number | string | *} index of value
|
|
149
|
-
* @param value {IValue} value of added item
|
|
150
|
-
*/
|
|
151
|
-
emitAdded(index: number | string | any, value: IValue): void;
|
|
152
|
-
/**
|
|
153
|
-
* Emits removed event to listeners
|
|
154
|
-
* @param index {number | string | *} index of removed value
|
|
155
|
-
* @param value {IValue} value of removed item
|
|
156
|
-
*/
|
|
157
|
-
emitRemoved(index: number | string | any, value: IValue): void;
|
|
158
|
-
/**
|
|
159
|
-
* Adds an handler to added event
|
|
160
|
-
* @param handler {Function} function to run on event emitting
|
|
161
|
-
*/
|
|
162
|
-
onAdd(handler: Function): void;
|
|
163
|
-
/**
|
|
164
|
-
* Adds an handler to removed event
|
|
165
|
-
* @param handler {Function} function to run on event emitting
|
|
166
|
-
*/
|
|
167
|
-
onRemove(handler: Function): void;
|
|
168
|
-
/**
|
|
169
|
-
* Removes an handler from added event
|
|
170
|
-
* @param handler {Function} handler to remove
|
|
171
|
-
*/
|
|
172
|
-
offAdd(handler: Function): void;
|
|
173
|
-
/**
|
|
174
|
-
* Removes an handler form removed event
|
|
175
|
-
* @param handler {Function} handler to remove
|
|
176
|
-
*/
|
|
177
|
-
offRemove(handler: Function): void;
|
|
178
|
-
}
|
|
179
|
-
export {};
|