vasille 1.2.7 → 2.0.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.
Files changed (131) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +153 -119
  3. package/flow-typed/vasille.js +837 -0
  4. package/lib/binding/attribute.js +32 -0
  5. package/lib/binding/binding.js +39 -0
  6. package/lib/binding/class.js +51 -0
  7. package/lib/binding/style.js +29 -0
  8. package/lib/core/core.js +178 -0
  9. package/lib/core/destroyable.js +45 -0
  10. package/lib/core/errors.js +16 -0
  11. package/lib/core/executor.js +154 -0
  12. package/lib/core/ivalue.js +56 -0
  13. package/lib/core/signal.js +50 -0
  14. package/lib/core/slot.js +47 -0
  15. package/lib/index.js +27 -22
  16. package/lib/models/array-model.js +208 -0
  17. package/lib/models/listener.js +130 -0
  18. package/lib/models/map-model.js +66 -0
  19. package/lib/models/model.js +1 -0
  20. package/lib/models/object-model.js +78 -0
  21. package/lib/models/set-model.js +62 -0
  22. package/lib/node/app.js +38 -0
  23. package/lib/node/interceptor.js +83 -0
  24. package/lib/node/node.js +1202 -0
  25. package/lib/node/watch.js +27 -0
  26. package/lib/value/expression.js +83 -0
  27. package/lib/value/mirror.js +58 -0
  28. package/lib/value/pointer.js +26 -0
  29. package/lib/value/reference.js +55 -0
  30. package/lib/views/array-view.js +23 -0
  31. package/lib/views/base-view.js +49 -0
  32. package/lib/views/map-view.js +20 -0
  33. package/lib/views/object-view.js +20 -0
  34. package/lib/views/repeat-node.js +106 -0
  35. package/lib/views/repeater.js +63 -0
  36. package/lib/views/set-view.js +23 -0
  37. package/package.json +16 -15
  38. package/types/binding/attribute.d.ts +23 -0
  39. package/types/binding/binding.d.ts +30 -0
  40. package/types/binding/class.d.ts +23 -0
  41. package/types/binding/style.d.ts +23 -0
  42. package/types/core/core.d.ts +140 -0
  43. package/types/core/destroyable.d.ts +15 -0
  44. package/types/core/errors.d.ts +4 -0
  45. package/types/core/executor.d.ts +87 -0
  46. package/types/core/ivalue.d.ts +45 -0
  47. package/types/core/signal.d.ts +35 -0
  48. package/types/core/slot.d.ts +45 -0
  49. package/types/index.d.ts +27 -21
  50. package/types/models/array-model.d.ts +103 -0
  51. package/types/models/listener.d.ts +74 -0
  52. package/types/models/map-model.d.ts +35 -0
  53. package/types/models/model.d.ts +19 -0
  54. package/types/models/object-model.d.ts +36 -0
  55. package/types/models/set-model.d.ts +34 -0
  56. package/types/node/app.d.ts +37 -0
  57. package/types/node/interceptor.d.ts +50 -0
  58. package/types/node/node.d.ts +741 -0
  59. package/types/node/watch.d.ts +23 -0
  60. package/types/value/expression.d.ts +60 -0
  61. package/types/value/mirror.d.ts +35 -0
  62. package/types/value/pointer.d.ts +19 -0
  63. package/types/value/reference.d.ts +30 -0
  64. package/types/views/array-view.d.ts +13 -0
  65. package/types/views/base-view.d.ts +43 -0
  66. package/types/views/map-view.d.ts +11 -0
  67. package/types/views/object-view.d.ts +11 -0
  68. package/types/views/repeat-node.d.ts +35 -0
  69. package/types/views/repeater.d.ts +38 -0
  70. package/types/views/set-view.d.ts +11 -0
  71. package/CHANGELOG.md +0 -23
  72. package/img/favicon.svg +0 -441
  73. package/img/getLocus.svg +0 -18
  74. package/img/logo.png +0 -0
  75. package/img/logo.svg +0 -550
  76. package/img/scores-o-log.png +0 -0
  77. package/img/scores-o.png +0 -0
  78. package/img/scores-wo-log.png +0 -0
  79. package/img/scores-wo.png +0 -0
  80. package/img/x1-x32.png +0 -0
  81. package/lib/attribute.js +0 -71
  82. package/lib/attribute.js.map +0 -1
  83. package/lib/bind.js +0 -286
  84. package/lib/bind.js.map +0 -1
  85. package/lib/class.js +0 -97
  86. package/lib/class.js.map +0 -1
  87. package/lib/executor.js +0 -167
  88. package/lib/executor.js.map +0 -1
  89. package/lib/index.js.map +0 -1
  90. package/lib/interfaces/core.js +0 -247
  91. package/lib/interfaces/core.js.map +0 -1
  92. package/lib/interfaces/destroyable.js +0 -39
  93. package/lib/interfaces/destroyable.js.map +0 -1
  94. package/lib/interfaces/errors.js +0 -49
  95. package/lib/interfaces/errors.js.map +0 -1
  96. package/lib/interfaces/ibind.js +0 -31
  97. package/lib/interfaces/ibind.js.map +0 -1
  98. package/lib/interfaces/idefinition.js +0 -64
  99. package/lib/interfaces/idefinition.js.map +0 -1
  100. package/lib/interfaces/ivalue.js +0 -60
  101. package/lib/interfaces/ivalue.js.map +0 -1
  102. package/lib/models.js +0 -579
  103. package/lib/models.js.map +0 -1
  104. package/lib/node.js +0 -2155
  105. package/lib/node.js.map +0 -1
  106. package/lib/property.js +0 -38
  107. package/lib/property.js.map +0 -1
  108. package/lib/style.js +0 -66
  109. package/lib/style.js.map +0 -1
  110. package/lib/value.js +0 -203
  111. package/lib/value.js.map +0 -1
  112. package/lib/views.js +0 -688
  113. package/lib/views.js.map +0 -1
  114. package/types/attribute.d.ts +0 -18
  115. package/types/bind.d.ts +0 -72
  116. package/types/class.d.ts +0 -19
  117. package/types/data.d.ts +0 -11
  118. package/types/event.d.ts +0 -10
  119. package/types/executor.d.ts +0 -57
  120. package/types/interfaces/core.d.ts +0 -129
  121. package/types/interfaces/destroyable.d.ts +0 -11
  122. package/types/interfaces/errors.d.ts +0 -24
  123. package/types/interfaces/ibind.d.ts +0 -19
  124. package/types/interfaces/idefinition.d.ts +0 -29
  125. package/types/interfaces/ivalue.d.ts +0 -40
  126. package/types/models.d.ts +0 -179
  127. package/types/node.d.ts +0 -906
  128. package/types/property.d.ts +0 -9
  129. package/types/style.d.ts +0 -28
  130. package/types/value.d.ts +0 -43
  131. package/types/views.d.ts +0 -135
@@ -0,0 +1,23 @@
1
+ import { Binding } from "./binding";
2
+ import type { INode } from "../node/node";
3
+ import type { IValue } from "../core/ivalue";
4
+ /**
5
+ * Represents a HTML class binding description
6
+ * @class ClassBinding
7
+ * @extends Binding
8
+ */
9
+ export declare class ClassBinding extends Binding<string | boolean> {
10
+ /**
11
+ * Constructs an HTML class binding description
12
+ * @param node {INode} the vasille node
13
+ * @param name {String} the name of class
14
+ * @param value {IValue} the value to bind
15
+ */
16
+ constructor(node: INode, name: string, value: IValue<string | boolean>);
17
+ /**
18
+ * Generates a function which updates the html class value
19
+ * @param name {String} The name of attribute
20
+ * @returns {Function} a function which will update attribute value
21
+ */
22
+ protected bound(name: string): (node: INode, value: string | boolean) => void;
23
+ }
@@ -0,0 +1,23 @@
1
+ import { Binding } from "./binding";
2
+ import type { INode } from "../node/node";
3
+ import type { IValue } from "../core/ivalue";
4
+ /**
5
+ * Describes a style attribute binding
6
+ * @class StyleBinding
7
+ * @extends Binding
8
+ */
9
+ export declare class StyleBinding extends Binding<string> {
10
+ /**
11
+ * Constructs a style binding attribute
12
+ * @param node {INode} the vasille node
13
+ * @param name {string} the name of style property
14
+ * @param value {IValue} the value to bind
15
+ */
16
+ constructor(node: INode, name: string, value: IValue<string>);
17
+ /**
18
+ * Generates a function to update style property value
19
+ * @param name {string}
20
+ * @returns {Function} a function to update style property
21
+ */
22
+ protected bound(name: string): (node: INode, value: string) => void;
23
+ }
@@ -0,0 +1,140 @@
1
+ import { Destroyable } from "./destroyable.js";
2
+ import { IValue } from "./ivalue.js";
3
+ import { Expression } from "../value/expression";
4
+ import { Pointer } from "../value/pointer";
5
+ import { Mirror } from "../value/mirror";
6
+ import { IModel } from "../models/model";
7
+ /**
8
+ * Private stuff of a reactive object
9
+ * @class ReactivePrivate
10
+ * @extends Destroyable
11
+ */
12
+ export declare class ReactivePrivate extends Destroyable {
13
+ /**
14
+ * A list of user-defined values
15
+ * @type {Set}
16
+ */
17
+ watch: Set<IValue<unknown>>;
18
+ /**
19
+ * A list of user-defined bindings
20
+ * @type {Set}
21
+ */
22
+ bindings: Set<Destroyable>;
23
+ /**
24
+ * A list of user defined models
25
+ */
26
+ models: Set<IModel<any, any>>;
27
+ /**
28
+ * Reactivity switch state
29
+ * @type {boolean}
30
+ */
31
+ enabled: boolean;
32
+ /**
33
+ * The frozen state of object
34
+ * @type {boolean}
35
+ */
36
+ frozen: boolean;
37
+ /**
38
+ * An expression which will freeze/unfreeze the object
39
+ * @type {IValue<void>}
40
+ */
41
+ freezeExpr: Expression<void, boolean>;
42
+ constructor();
43
+ $destroy(): void;
44
+ }
45
+ /**
46
+ * A reactive object
47
+ * @class Reactive
48
+ * @extends Destroyable
49
+ */
50
+ export declare class Reactive extends Destroyable {
51
+ /**
52
+ * Private stuff
53
+ * @protected
54
+ */
55
+ protected $: ReactivePrivate;
56
+ constructor($?: ReactivePrivate);
57
+ /**
58
+ * Create a reference
59
+ * @param value {*} value to reference
60
+ */
61
+ $ref<T>(value: T): IValue<T>;
62
+ /**
63
+ * Create a mirror
64
+ * @param value {IValue} value to mirror
65
+ * @param forwardOnly {boolean} forward only sync
66
+ */
67
+ $mirror<T>(value: IValue<T>, forwardOnly?: boolean): Mirror<T>;
68
+ /**
69
+ * Creates a pointer
70
+ * @param value {*} default value to point
71
+ * @param forwardOnly {boolean} forward only sync
72
+ */
73
+ $point<T>(value: T | IValue<T>, forwardOnly?: boolean): Pointer<T>;
74
+ /**
75
+ * Register a model
76
+ * @param model
77
+ */
78
+ $register<T extends IModel<any, any>>(model: T): T;
79
+ /**
80
+ * Creates a watcher
81
+ * @param func {function} function to run on any argument change
82
+ * @param v1 {IValue} argument
83
+ * @param v2 {IValue} argument
84
+ * @param v3 {IValue} argument
85
+ * @param v4 {IValue} argument
86
+ * @param v5 {IValue} argument
87
+ * @param v6 {IValue} argument
88
+ * @param v7 {IValue} argument
89
+ * @param v8 {IValue} argument
90
+ * @param v9 {IValue} argument
91
+ */
92
+ $watch<T1>(func: (a1: T1) => void, v1: IValue<T1>): any;
93
+ $watch<T1, T2>(func: (a1: T1, a2: T2) => void, v1: IValue<T1>, v2: IValue<T2>): any;
94
+ $watch<T1, T2, T3>(func: (a1: T1, a2: T2, a3: T3) => void, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>): any;
95
+ $watch<T1, T2, T3, T4>(func: (a1: T1, a2: T2, a3: T3, a4: T4) => void, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>): any;
96
+ $watch<T1, T2, T3, T4, T5>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5) => void, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>): any;
97
+ $watch<T1, T2, T3, T4, T5, T6>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6) => void, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>): any;
98
+ $watch<T1, T2, T3, T4, T5, T6, T7>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7) => void, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>, v7: IValue<T7>): any;
99
+ $watch<T1, T2, T3, T4, T5, T6, T7, T8>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8) => void, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>, v7: IValue<T7>, v8: IValue<T8>): any;
100
+ $watch<T1, T2, T3, T4, T5, T6, T7, T8, T9>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8, a9: T9) => void, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>, v7: IValue<T7>, v8: IValue<T8>, v9: IValue<T9>): any;
101
+ /**
102
+ * Creates a computed value
103
+ * @param func {function} function to run on any argument change
104
+ * @param v1 {IValue} argument
105
+ * @param v2 {IValue} argument
106
+ * @param v3 {IValue} argument
107
+ * @param v4 {IValue} argument
108
+ * @param v5 {IValue} argument
109
+ * @param v6 {IValue} argument
110
+ * @param v7 {IValue} argument
111
+ * @param v8 {IValue} argument
112
+ * @param v9 {IValue} argument
113
+ * @return {IValue} the created ivalue
114
+ */
115
+ $bind<T, T1>(func: (a1: T1) => T, v1: IValue<T1>): any;
116
+ $bind<T, T1, T2>(func: (a1: T1, a2: T2) => T, v1: IValue<T1>, v2: IValue<T2>): any;
117
+ $bind<T, T1, T2, T3>(func: (a1: T1, a2: T2, a3: T3) => T, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>): any;
118
+ $bind<T, T1, T2, T3, T4>(func: (a1: T1, a2: T2, a3: T3, a4: T4) => T, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>): any;
119
+ $bind<T, T1, T2, T3, T4, T5>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5) => T, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>): any;
120
+ $bind<T, T1, T2, T3, T4, T5, T6>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6) => T, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>): any;
121
+ $bind<T, T1, T2, T3, T4, T5, T6, T7>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7) => T, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>, v7: IValue<T7>): any;
122
+ $bind<T, T1, T2, T3, T4, T5, T6, T7, T8>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8) => T, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>, v7: IValue<T7>, v8: IValue<T8>): any;
123
+ $bind<T, T1, T2, T3, T4, T5, T6, T7, T8, T9>(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8, a9: T9) => T, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>, v7: IValue<T7>, v8: IValue<T8>, v9: IValue<T9>): any;
124
+ /**
125
+ * Enable reactivity of fields
126
+ */
127
+ $enable(): void;
128
+ /**
129
+ * Disable reactivity of fields
130
+ */
131
+ $disable(): void;
132
+ /**
133
+ * Disable/Enable reactivity of object fields with feedback
134
+ * @param cond {IValue} show condition
135
+ * @param onOff {function} on show feedback
136
+ * @param onOn {function} on hide feedback
137
+ */
138
+ $bindAlive(cond: IValue<boolean>, onOff?: () => void, onOn?: () => void): this;
139
+ $destroy(): void;
140
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Mark an object which can be destroyed
3
+ * @class Destroyable
4
+ */
5
+ export declare class Destroyable {
6
+ /**
7
+ * Make object fields non configurable
8
+ * @protected
9
+ */
10
+ protected $seal(): void;
11
+ /**
12
+ * Garbage collector method
13
+ */
14
+ $destroy(): void;
15
+ }
@@ -0,0 +1,4 @@
1
+ export declare function notOverwritten(): string;
2
+ export declare function internalError(msg: string): string;
3
+ export declare function userError(msg: string, err: string): string;
4
+ export declare function wrongBinding(msg: string): string;
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Represents an executor unit interface
3
+ * @class Executor
4
+ */
5
+ export declare class Executor {
6
+ /**
7
+ * Adds a CSS class
8
+ * @param el {Element} element to manipulate
9
+ * @param cl {string} class to be added
10
+ */
11
+ addClass(el: Element, cl: string): void;
12
+ /**
13
+ * Removes a CSS class
14
+ * @param el {Element} element to manipulate
15
+ * @param cl {string} class to be removed
16
+ */
17
+ removeClass(el: Element, cl: string): void;
18
+ /**
19
+ * Sets a tag attribute
20
+ * @param el {Element} element to manipulate
21
+ * @param name {string} name of attribute
22
+ * @param value {string} value of attribute
23
+ */
24
+ setAttribute(el: Element, name: string, value: string): void;
25
+ /**
26
+ * Removes a tag attribute
27
+ * @param el {Element} element to manipulate
28
+ * @param name {string} name of attribute
29
+ */
30
+ removeAttribute(el: Element, name: string): void;
31
+ /**
32
+ * Sets a style attribute
33
+ * @param el {HTMLElement} element to manipulate
34
+ * @param prop {string} property name
35
+ * @param value {string} property value
36
+ */
37
+ setStyle(el: HTMLElement, prop: string, value: string): void;
38
+ /**
39
+ * Inserts a child before target
40
+ * @param target {Element} target element
41
+ * @param child {Node} element to insert before
42
+ */
43
+ insertBefore(target: Node, child: Node): void;
44
+ /**
45
+ * Appends a child to element
46
+ * @param el {Element} element
47
+ * @param child {Node} child to be inserted
48
+ */
49
+ appendChild(el: Element, child: Node): void;
50
+ /**
51
+ * Calls a call-back function
52
+ * @param cb {function} call-back function
53
+ */
54
+ callCallback(cb: () => void): void;
55
+ }
56
+ /**
57
+ * Executor which execute any commands immediately
58
+ * @class InstantExecutor
59
+ * @extends Executor
60
+ */
61
+ export declare class InstantExecutor extends Executor {
62
+ addClass(el: Element, cl: string): void;
63
+ removeClass(el: Element, cl: string): void;
64
+ setAttribute(el: Element, name: string, value: string): void;
65
+ removeAttribute(el: Element, name: string): void;
66
+ setStyle(el: HTMLElement, prop: string, value: string): void;
67
+ insertBefore(target: Node, child: Node): void;
68
+ appendChild(el: Node, child: Node): void;
69
+ callCallback(cb: () => void): void;
70
+ }
71
+ /**
72
+ * Executor which execute any commands over timeout
73
+ * @class TimeoutExecutor
74
+ * @extends InstantExecutor
75
+ */
76
+ export declare class TimeoutExecutor extends InstantExecutor {
77
+ addClass(el: Element, cl: string): void;
78
+ removeClass(el: Element, cl: string): void;
79
+ setAttribute(el: Element, name: string, value: string): void;
80
+ removeAttribute(el: Element, name: string): void;
81
+ setStyle(el: HTMLElement, prop: string, value: string): void;
82
+ insertBefore(target: Node, child: Node): void;
83
+ appendChild(el: Node, child: Node): void;
84
+ callCallback(cb: () => void): void;
85
+ }
86
+ export declare const instantExecutor: InstantExecutor;
87
+ export declare const timeoutExecutor: TimeoutExecutor;
@@ -0,0 +1,45 @@
1
+ import { Destroyable } from "./destroyable.js";
2
+ /**
3
+ * Interface which describes a value
4
+ * @class IValue
5
+ * @extends Destroyable
6
+ */
7
+ export declare class IValue<T> extends Destroyable {
8
+ /**
9
+ * Is enabled state flag
10
+ * @protected
11
+ */
12
+ protected isEnabled: boolean;
13
+ /**
14
+ * @param isEnabled {boolean} initial is enabled state
15
+ */
16
+ constructor(isEnabled: boolean);
17
+ /**
18
+ * Get the encapsulated value
19
+ * @return {*} the encapsulated value
20
+ */
21
+ get $(): T;
22
+ /**
23
+ * Sets the encapsulated value
24
+ * @param value {*} value to encapsulate
25
+ */
26
+ set $(value: T);
27
+ /**
28
+ * Add a new handler to value change
29
+ * @param handler {function(value : *)} the handler to add
30
+ */
31
+ on(handler: (value: T) => void): this;
32
+ /**
33
+ * Removes a handler of value change
34
+ * @param handler {function(value : *)} the handler to remove
35
+ */
36
+ off(handler: (value: T) => void): this;
37
+ /**
38
+ * Enable update handlers triggering
39
+ */
40
+ enable(): this;
41
+ /**
42
+ * disable update handlers triggering
43
+ */
44
+ disable(): this;
45
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Signal is an event generator
3
+ * @class Signal
4
+ */
5
+ export declare class Signal<T1 = void, T2 = void, T3 = void, T4 = void, T5 = void, T6 = void, T7 = void, T8 = void, T9 = void> {
6
+ /**
7
+ * Handler of event
8
+ * @type {Set}
9
+ * @private
10
+ */
11
+ private handlers;
12
+ /**
13
+ * Emit event
14
+ * @param a1 {*} argument
15
+ * @param a2 {*} argument
16
+ * @param a3 {*} argument
17
+ * @param a4 {*} argument
18
+ * @param a5 {*} argument
19
+ * @param a6 {*} argument
20
+ * @param a7 {*} argument
21
+ * @param a8 {*} argument
22
+ * @param a9 {*} argument
23
+ */
24
+ emit(a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8, a9: T9): void;
25
+ /**
26
+ * Subscribe to event
27
+ * @param func {function} handler
28
+ */
29
+ subscribe(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8, a9: T9) => void): void;
30
+ /**
31
+ * Unsubscribe from event
32
+ * @param func {function} handler
33
+ */
34
+ unsubscribe(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8, a9: T9) => void): void;
35
+ }
@@ -0,0 +1,45 @@
1
+ import { Fragment } from "../node/node";
2
+ /**
3
+ * Component slot
4
+ * @class Slot
5
+ */
6
+ export declare class Slot<t1 = void, t2 = void, t3 = void, t4 = void, t5 = void, t6 = void, t7 = void, t8 = void, t9 = void> {
7
+ /**
8
+ * Function to run
9
+ * @type {function(node : Fragment)}
10
+ */
11
+ private runner?;
12
+ /**
13
+ * Sets the runner
14
+ * @param func {function} the function to run
15
+ */
16
+ insert(func: (a0: Fragment, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9) => void): void;
17
+ /**
18
+ * @param a0 {Fragment} node to paste content
19
+ * @param a1 {*} 1st argument
20
+ * @param a2 {*} 2nd argument
21
+ * @param a3 {*} 3rd argument
22
+ * @param a4 {*} 4th argument
23
+ * @param a5 {*} 5th argument
24
+ * @param a6 {*} 6th argument
25
+ * @param a7 {*} 7th argument
26
+ * @param a8 {*} 8th argument
27
+ * @param a9 {*} 9th argument
28
+ */
29
+ release(a0: Fragment, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9): void;
30
+ /**
31
+ * Predefine a handler for a slot
32
+ * @param func {function(node : Fragment)} Function to run if no handler specified
33
+ * @param a0 {Fragment} node to paste content
34
+ * @param a1 {*} 1st argument
35
+ * @param a2 {*} 2nd argument
36
+ * @param a3 {*} 3rd argument
37
+ * @param a4 {*} 4th argument
38
+ * @param a5 {*} 5th argument
39
+ * @param a6 {*} 6th argument
40
+ * @param a7 {*} 7th argument
41
+ * @param a8 {*} 8th argument
42
+ * @param a9 {*} 9th argument
43
+ */
44
+ predefine(func: (a0: Fragment, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9) => void, a0: Fragment, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9): void;
45
+ }
package/types/index.d.ts CHANGED
@@ -1,21 +1,27 @@
1
- import { Expression } from "./bind.js";
2
- import { Destroyable } from "./interfaces/destroyable.js";
3
- import { IBind } from "./interfaces/ibind.js";
4
- import { IValue } from "./interfaces/ivalue.js";
5
- import { ArrayModel } from "./models.js";
6
- import { MapModel } from "./models.js";
7
- import { ObjectModel } from "./models.js";
8
- import { SetModel } from "./models.js";
9
- import { App } from "./node.js";
10
- import { INode } from "./node.js";
11
- import { Tag } from "./node.js";
12
- import { Extension } from "./node.js";
13
- import { TextNode } from "./node.js";
14
- import { Component } from "./node.js";
15
- import { Pointer } from "./value.js";
16
- import { Reference } from "./value.js";
17
- import { ArrayView } from "./views.js";
18
- import { MapView } from "./views.js";
19
- import { ObjectView } from "./views.js";
20
- import { SetView } from "./views.js";
21
- export { Expression, Destroyable, IBind, IValue, ArrayModel, MapModel, ObjectModel, SetModel, App, INode, Tag, Extension, TextNode, Component, Pointer, Reference, ArrayView, MapView, ObjectView, SetView };
1
+ import { Destroyable } from "./core/destroyable";
2
+ import { Executor, InstantExecutor, TimeoutExecutor } from "./core/executor";
3
+ import { Reactive } from "./core/core";
4
+ import { IValue } from "./core/ivalue";
5
+ import { Signal } from "./core/signal";
6
+ import { Slot } from "./core/slot";
7
+ import { ArrayModel } from "./models/array-model";
8
+ import { Listener } from "./models/listener";
9
+ import { MapModel } from "./models/map-model";
10
+ import { ObjectModel } from "./models/object-model";
11
+ import { SetModel } from "./models/set-model";
12
+ import { App, AppNode } from "./node/app";
13
+ import { Interceptor, InterceptorNode } from "./node/interceptor";
14
+ import { Component, Extension, Fragment, INode, Tag } from "./node/node";
15
+ import { Expression } from "./value/expression";
16
+ import { Mirror } from "./value/mirror";
17
+ import { Pointer } from "./value/pointer";
18
+ import { Reference } from "./value/reference";
19
+ import { ArrayView } from "./views/array-view";
20
+ import { BaseView } from "./views/base-view";
21
+ import { MapView } from "./views/map-view";
22
+ import { ObjectView } from "./views/object-view";
23
+ import { RepeatNode } from "./views/repeat-node";
24
+ import { Repeater } from "./views/repeater";
25
+ import { SetView } from "./views/set-view";
26
+ import { Binding } from "./binding/binding";
27
+ export { Destroyable, IValue, Reference, Mirror, Pointer, ArrayModel, MapModel, ObjectModel, SetModel, RepeatNode, Repeater, BaseView, Listener, ArrayView, MapView, ObjectView, SetView, Fragment, INode, Tag, Component, Extension, AppNode, App, Executor, InstantExecutor, TimeoutExecutor, Signal, Slot, Interceptor, InterceptorNode, Expression, Binding, Reactive, };
@@ -0,0 +1,103 @@
1
+ import { Listener } from "./listener";
2
+ import type { IModel } from "./model";
3
+ /**
4
+ * Model based on Array class
5
+ * @extends Array
6
+ * @implements IModel
7
+ */
8
+ export declare class ArrayModel<T> extends Array<T> implements IModel<T, T> {
9
+ listener: Listener<T, T>;
10
+ /**
11
+ * @param data {Array} input data
12
+ */
13
+ constructor(data?: Array<T>);
14
+ /**
15
+ * Gets the last item of array
16
+ * @return {*} the last item of array
17
+ */
18
+ get last(): T;
19
+ /**
20
+ * Calls Array.fill and notify about changes
21
+ * @param value {*} value to fill with
22
+ * @param start {?number} begin index
23
+ * @param end {?number} end index
24
+ */
25
+ fill(value: T, start?: number, end?: number): this;
26
+ /**
27
+ * Calls Array.pop and notify about changes
28
+ * @return {*} removed value
29
+ */
30
+ pop(): T;
31
+ /**
32
+ * Calls Array.push and notify about changes
33
+ * @param items {...*} values to push
34
+ * @return {number} new length of array
35
+ */
36
+ push(...items: Array<T>): number;
37
+ /**
38
+ * Calls Array.shift and notify about changed
39
+ * @return {*} the shifted value
40
+ */
41
+ shift(): T;
42
+ /**
43
+ * Calls Array.splice and notify about changed
44
+ * @param start {number} start index
45
+ * @param deleteCount {?number} delete count
46
+ * @param items {...*}
47
+ * @return {ArrayModel} a pointer to this
48
+ */
49
+ splice(start: number, deleteCount?: number, ...items: Array<T>): ArrayModel<T>;
50
+ /**
51
+ * Calls Array.unshift and notify about changed
52
+ * @param items {...*} values to insert
53
+ * @return {number} the length after prepend
54
+ */
55
+ unshift(...items: Array<T>): number;
56
+ /**
57
+ * Inserts a value to the end of array
58
+ * @param v {*} value to insert
59
+ */
60
+ append(v: T): this;
61
+ /**
62
+ * Clears array
63
+ * @return {this} a pointer to this
64
+ */
65
+ clear(): this;
66
+ /**
67
+ * Inserts a value to position `index`
68
+ * @param index {number} index to insert value
69
+ * @param v {*} value to insert
70
+ * @return {this} a pointer to this
71
+ */
72
+ insert(index: number, v: T): this;
73
+ /**
74
+ * Inserts a value to the beginning of array
75
+ * @param v {*} value to insert
76
+ * @return {this} a pointer to this
77
+ */
78
+ prepend(v: T): this;
79
+ /**
80
+ * Removes a value from an index
81
+ * @param index {number} index of value to remove
82
+ * @return {this} a pointer to this
83
+ */
84
+ removeAt(index: number): this;
85
+ /**
86
+ * Removes the first value of array
87
+ * @return {this} a pointer to this
88
+ */
89
+ removeFirst(): this;
90
+ /**
91
+ * Removes the ast value of array
92
+ * @return {this} a pointer to this
93
+ */
94
+ removeLast(): this;
95
+ /**
96
+ * Remove the first occurrence of value
97
+ * @param v {*} value to remove
98
+ * @return {this}
99
+ */
100
+ removeOne(v: T): this;
101
+ enableReactivity(): void;
102
+ disableReactivity(): void;
103
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Represent a listener for a model
3
+ * @class Listener
4
+ */
5
+ export declare class Listener<ValueT, IndexT = string | number> {
6
+ /**
7
+ * Functions to run on adding new items
8
+ * @type Set
9
+ */
10
+ private readonly onAdded;
11
+ /**
12
+ * Functions to run on item removing
13
+ * @type Set
14
+ */
15
+ private readonly onRemoved;
16
+ /**
17
+ * Describe the frozen state of model
18
+ * @type boolean
19
+ * @private
20
+ */
21
+ private frozen;
22
+ /**
23
+ * The queue of operations in frozen state
24
+ * @type Object[]
25
+ * @private
26
+ */
27
+ private readonly queue;
28
+ constructor();
29
+ /**
30
+ * Exclude the repeated operation in queue
31
+ * @private
32
+ */
33
+ private excludeRepeat;
34
+ /**
35
+ * Emits added event to listeners
36
+ * @param index {*} index of value
37
+ * @param value {*} value of added item
38
+ */
39
+ emitAdded(index: IndexT, value: ValueT): void;
40
+ /**
41
+ * Emits removed event to listeners
42
+ * @param index {*} index of removed value
43
+ * @param value {*} value of removed item
44
+ */
45
+ emitRemoved(index: IndexT, value: ValueT): void;
46
+ /**
47
+ * Adds a handler to added event
48
+ * @param handler {function} function to run on event emitting
49
+ */
50
+ onAdd(handler: (index: IndexT, value: ValueT) => void): void;
51
+ /**
52
+ * Adds a handler to removed event
53
+ * @param handler {function} function to run on event emitting
54
+ */
55
+ onRemove(handler: (index: IndexT, value: ValueT) => void): void;
56
+ /**
57
+ * Removes an handler from added event
58
+ * @param handler {function} handler to remove
59
+ */
60
+ offAdd(handler: (index: IndexT, value: ValueT) => void): void;
61
+ /**
62
+ * Removes an handler form removed event
63
+ * @param handler {function} handler to remove
64
+ */
65
+ offRemove(handler: (index: IndexT, value: ValueT) => void): void;
66
+ /**
67
+ * Run all queued operation and enable reactivity
68
+ */
69
+ enableReactivity(): void;
70
+ /**
71
+ * Disable the reactivity and enable the queue
72
+ */
73
+ disableReactivity(): void;
74
+ }