vasille 1.2.6 → 2.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.
Files changed (122) hide show
  1. package/LICENSE.md +21 -0
  2. package/flow-typed/vasille.js +836 -0
  3. package/img/favicon.svg +17 -204
  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 +1185 -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 +24 -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 +739 -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 +44 -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/lib/attribute.js +0 -71
  73. package/lib/attribute.js.map +0 -1
  74. package/lib/bind.js +0 -286
  75. package/lib/bind.js.map +0 -1
  76. package/lib/class.js +0 -97
  77. package/lib/class.js.map +0 -1
  78. package/lib/executor.js +0 -167
  79. package/lib/executor.js.map +0 -1
  80. package/lib/index.js.map +0 -1
  81. package/lib/interfaces/core.js +0 -247
  82. package/lib/interfaces/core.js.map +0 -1
  83. package/lib/interfaces/destroyable.js +0 -39
  84. package/lib/interfaces/destroyable.js.map +0 -1
  85. package/lib/interfaces/errors.js +0 -49
  86. package/lib/interfaces/errors.js.map +0 -1
  87. package/lib/interfaces/ibind.js +0 -31
  88. package/lib/interfaces/ibind.js.map +0 -1
  89. package/lib/interfaces/idefinition.js +0 -64
  90. package/lib/interfaces/idefinition.js.map +0 -1
  91. package/lib/interfaces/ivalue.js +0 -60
  92. package/lib/interfaces/ivalue.js.map +0 -1
  93. package/lib/models.js +0 -579
  94. package/lib/models.js.map +0 -1
  95. package/lib/node.js +0 -2155
  96. package/lib/node.js.map +0 -1
  97. package/lib/property.js +0 -38
  98. package/lib/property.js.map +0 -1
  99. package/lib/style.js +0 -66
  100. package/lib/style.js.map +0 -1
  101. package/lib/value.js +0 -203
  102. package/lib/value.js.map +0 -1
  103. package/lib/views.js +0 -688
  104. package/lib/views.js.map +0 -1
  105. package/types/attribute.d.ts +0 -18
  106. package/types/bind.d.ts +0 -72
  107. package/types/class.d.ts +0 -19
  108. package/types/data.d.ts +0 -11
  109. package/types/event.d.ts +0 -10
  110. package/types/executor.d.ts +0 -57
  111. package/types/interfaces/core.d.ts +0 -129
  112. package/types/interfaces/destroyable.d.ts +0 -11
  113. package/types/interfaces/errors.d.ts +0 -24
  114. package/types/interfaces/ibind.d.ts +0 -19
  115. package/types/interfaces/idefinition.d.ts +0 -29
  116. package/types/interfaces/ivalue.d.ts +0 -40
  117. package/types/models.d.ts +0 -179
  118. package/types/node.d.ts +0 -906
  119. package/types/property.d.ts +0 -9
  120. package/types/style.d.ts +0 -28
  121. package/types/value.d.ts +0 -43
  122. package/types/views.d.ts +0 -135
@@ -0,0 +1,23 @@
1
+ import { Fragment } from "./node";
2
+ import { Slot } from "../core/slot";
3
+ import { IValue } from "../core/ivalue";
4
+ /**
5
+ * Watch Node
6
+ * @class Watch
7
+ * @extends Fragment
8
+ */
9
+ export declare class Watch extends Fragment {
10
+ /**
11
+ * Default slot
12
+ * @type Slot
13
+ */
14
+ slot: Slot;
15
+ /**
16
+ * iValue to watch
17
+ * @type IValue
18
+ */
19
+ model: IValue<unknown>;
20
+ constructor();
21
+ $createWatchers(): void;
22
+ $compose(): void;
23
+ }
@@ -0,0 +1,60 @@
1
+ import { IValue } from "../core/ivalue";
2
+ /**
3
+ * Bind some values to one expression
4
+ * @class Expression
5
+ * @extends IValue
6
+ */
7
+ export declare class Expression<T, T1 = void, T2 = void, T3 = void, T4 = void, T5 = void, T6 = void, T7 = void, T8 = void, T9 = void> extends IValue<T> {
8
+ /**
9
+ * The array of value which will trigger recalculation
10
+ * @type {Array}
11
+ */
12
+ private values;
13
+ /**
14
+ * Cache the values of expression variables
15
+ * @type {Array}
16
+ */
17
+ private readonly valuesCache;
18
+ /**
19
+ * The function which will be executed on recalculation
20
+ */
21
+ private readonly func;
22
+ /**
23
+ * Expression will link different handler for each value of list
24
+ */
25
+ private linkedFunc;
26
+ /**
27
+ * The buffer to keep the last calculated value
28
+ */
29
+ private sync;
30
+ /**
31
+ * Creates a function bounded to N values
32
+ * @param func {Function} the function to bound
33
+ * @param link {Boolean} links immediately if true
34
+ * @param v1 {*} argument
35
+ * @param v2 {*} argument
36
+ * @param v3 {*} argument
37
+ * @param v4 {*} argument
38
+ * @param v5 {*} argument
39
+ * @param v6 {*} argument
40
+ * @param v7 {*} argument
41
+ * @param v8 {*} argument
42
+ * @param v9 {*} argument
43
+ */
44
+ constructor(func: (a1: T1) => T, link: boolean, v1: IValue<T1>, v2?: IValue<void>, v3?: IValue<void>, v4?: IValue<void>, v5?: IValue<void>, v6?: IValue<void>, v7?: IValue<void>, v8?: IValue<void>, v9?: IValue<void>);
45
+ constructor(func: (a1: T1, a2: T2) => T, link: boolean, v1: IValue<T1>, v2: IValue<T2>, v3?: IValue<void>, v4?: IValue<void>, v5?: IValue<void>, v6?: IValue<void>, v7?: IValue<void>, v8?: IValue<void>, v9?: IValue<void>);
46
+ constructor(func: (a1: T1, a2: T2, a3: T3) => T, link: boolean, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4?: IValue<void>, v5?: IValue<void>, v6?: IValue<void>, v7?: IValue<void>, v8?: IValue<void>, v9?: IValue<void>);
47
+ constructor(func: (a1: T1, a2: T2, a3: T3, a4: T4) => T, link: boolean, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5?: IValue<void>, v6?: IValue<void>, v7?: IValue<void>, v8?: IValue<void>, v9?: IValue<void>);
48
+ constructor(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5) => T, link: boolean, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6?: IValue<void>, v7?: IValue<void>, v8?: IValue<void>, v9?: IValue<void>);
49
+ constructor(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6) => T, link: boolean, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>, v7?: IValue<void>, v8?: IValue<void>, v9?: IValue<void>);
50
+ constructor(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7) => T, link: boolean, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>, v4: IValue<T4>, v5: IValue<T5>, v6: IValue<T6>, v7: IValue<T7>, v8?: IValue<void>, v9?: IValue<void>);
51
+ constructor(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8) => T, link: boolean, 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<void>);
52
+ constructor(func: (a1: T1, a2: T2, a3: T3, a4: T4, a5: T5, a6: T6, a7: T7, a8: T8, a9: T9) => T, link: boolean, 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>);
53
+ get $(): T;
54
+ set $(value: T);
55
+ on(handler: (value: T) => void): this;
56
+ off(handler: (value: T) => void): this;
57
+ enable(): this;
58
+ disable(): this;
59
+ $destroy(): void;
60
+ }
@@ -0,0 +1,35 @@
1
+ import { IValue } from "../core/ivalue";
2
+ import { Reference } from "./reference";
3
+ /**
4
+ * Declares a notifiable bind to a value
5
+ * @class Mirror
6
+ * @extends IValue
7
+ * @version 2
8
+ */
9
+ export declare class Mirror<T> extends Reference<T> {
10
+ /**
11
+ * pointed value
12
+ * @type IValue
13
+ */
14
+ protected pointedValue: IValue<T>;
15
+ /**
16
+ * Collection of handlers
17
+ * @type Set
18
+ */
19
+ private readonly handler;
20
+ /**
21
+ * Ensure forward only synchronization
22
+ */
23
+ forwardOnly: boolean;
24
+ /**
25
+ * Constructs a notifiable bind to a value
26
+ * @param value {IValue} is initial value
27
+ * @param forwardOnly {boolean} ensure forward only synchronization
28
+ */
29
+ constructor(value: IValue<T>, forwardOnly?: boolean);
30
+ get $(): T;
31
+ set $(v: T);
32
+ enable(): this;
33
+ disable(): this;
34
+ $destroy(): void;
35
+ }
@@ -0,0 +1,19 @@
1
+ import { Mirror } from "./mirror";
2
+ import { IValue } from "../core/ivalue";
3
+ /**
4
+ * r/w pointer to a value
5
+ * @class Pointer
6
+ * @extends Mirror
7
+ */
8
+ export declare class Pointer<T> extends Mirror<T> {
9
+ /**
10
+ * @param value {IValue} value to point
11
+ * @param forwardOnly {boolean} forward only data flow
12
+ */
13
+ constructor(value: IValue<T>, forwardOnly?: boolean);
14
+ /**
15
+ * Point a new ivalue
16
+ * @param value {IValue} value to point
17
+ */
18
+ point(value: IValue<T>): void;
19
+ }
@@ -0,0 +1,30 @@
1
+ import { IValue } from "../core/ivalue";
2
+ /**
3
+ * Declares a notifiable value
4
+ * @class Reference
5
+ * @extends IValue
6
+ */
7
+ export declare class Reference<T> extends IValue<T> {
8
+ /**
9
+ * The encapsulated value
10
+ * @type {*}
11
+ */
12
+ private value;
13
+ /**
14
+ * Array of handlers
15
+ * @type {Set}
16
+ * @readonly
17
+ */
18
+ private readonly onchange;
19
+ /**
20
+ * @param value {any} the initial value
21
+ */
22
+ constructor(value: T);
23
+ get $(): T;
24
+ set $(value: T);
25
+ enable(): this;
26
+ disable(): this;
27
+ on(handler: (value: T) => void): this;
28
+ off(handler: (value: T) => void): this;
29
+ $destroy(): void;
30
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseView } from "./base-view";
2
+ import { ArrayModel } from "../models/array-model";
3
+ import { Fragment } from "../node/node";
4
+ /**
5
+ * Represents a view of an array model
6
+ * @class ArrayView
7
+ * @extends BaseView
8
+ */
9
+ export declare class ArrayView<T> extends BaseView<T, T, ArrayModel<T>> {
10
+ constructor();
11
+ createChild(id: T, item: T, before?: Fragment): any;
12
+ $ready(): void;
13
+ }
@@ -0,0 +1,44 @@
1
+ import { RepeatNode, RepeatNodePrivate } from "./repeat-node";
2
+ import { IValue } from "../core/ivalue";
3
+ import { IModel } from "../models/model";
4
+ /**
5
+ * Private part of BaseView
6
+ * @class BaseViewPrivate
7
+ * @extends RepeatNodePrivate
8
+ */
9
+ export declare class BaseViewPrivate<K, T> extends RepeatNodePrivate<K> {
10
+ /**
11
+ * Handler to catch values addition
12
+ * @type {Function}
13
+ */
14
+ addHandler: (index: K, value: T) => void;
15
+ /**
16
+ * Handler to catch values removes
17
+ * @type {Function}
18
+ */
19
+ removeHandler: (index: K, value: T) => void;
20
+ constructor();
21
+ }
22
+ /**
23
+ * Base class of default views
24
+ * @class BaseView
25
+ * @extends RepeatNode
26
+ * @implements IModel
27
+ */
28
+ export declare class BaseView<K, T, Model extends IModel<K, T>> extends RepeatNode<K, T> {
29
+ protected $: BaseViewPrivate<K, T>;
30
+ /**
31
+ * Property which will contain a model
32
+ * @type {IValue<*>}
33
+ */
34
+ model: IValue<Model>;
35
+ constructor($1?: BaseViewPrivate<K, T>);
36
+ /**
37
+ * Handle ready event
38
+ */
39
+ $ready(): void;
40
+ /**
41
+ * Handles destroy event
42
+ */
43
+ $destroy(): void;
44
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseView } from "./base-view";
2
+ import { MapModel } from "../models/map-model";
3
+ /**
4
+ * Create a children pack for each map value
5
+ * @class MapView
6
+ * @extends BaseView
7
+ */
8
+ export declare class MapView<K, T> extends BaseView<K, T, MapModel<K, T>> {
9
+ constructor();
10
+ $ready(): void;
11
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseView } from "./base-view";
2
+ import { ObjectModel } from "../models/object-model";
3
+ /**
4
+ * Create a children pack for each object field
5
+ * @class ObjectView
6
+ * @extends BaseView
7
+ */
8
+ export declare class ObjectView<T> extends BaseView<string, T, ObjectModel<T>> {
9
+ constructor();
10
+ $ready(): void;
11
+ }
@@ -0,0 +1,35 @@
1
+ import { Fragment, INodePrivate } from "../node/node";
2
+ import { Slot } from "../core/slot";
3
+ /**
4
+ * Private part of repeat node
5
+ * @class RepeatNodePrivate
6
+ * @extends INodePrivate
7
+ */
8
+ export declare class RepeatNodePrivate<IdT> extends INodePrivate {
9
+ /**
10
+ * Children node hash
11
+ * @type {Map}
12
+ */
13
+ nodes: Map<IdT, Fragment>;
14
+ constructor();
15
+ $destroy(): void;
16
+ }
17
+ /**
18
+ * Repeat node repeats its children
19
+ * @class RepeatNode
20
+ * @extends Fragment
21
+ */
22
+ export declare class RepeatNode<IdT, T> extends Fragment {
23
+ protected $: RepeatNodePrivate<IdT>;
24
+ /**
25
+ * Default slot
26
+ */
27
+ slot: Slot<T, IdT>;
28
+ /**
29
+ * If false will use timeout executor, otherwise the app executor
30
+ */
31
+ freezeUi: boolean;
32
+ constructor($?: RepeatNodePrivate<IdT>);
33
+ createChild(id: IdT, item: T, before?: Fragment): any;
34
+ destroyChild(id: IdT, item: T): void;
35
+ }
@@ -0,0 +1,38 @@
1
+ import { RepeatNode, RepeatNodePrivate } from "./repeat-node";
2
+ import { IValue } from "../core/ivalue";
3
+ /**
4
+ * Private part of repeater
5
+ * @class RepeaterPrivate
6
+ * @extends RepeatNodePrivate
7
+ */
8
+ export declare class RepeaterPrivate<IdT> extends RepeatNodePrivate<IdT> {
9
+ /**
10
+ * Handler to catch count updates
11
+ */
12
+ updateHandler: (value: number) => void;
13
+ /**
14
+ * Current count of child nodes
15
+ */
16
+ currentCount: number;
17
+ constructor();
18
+ }
19
+ /**
20
+ * The simplest repeat node interpretation, repeat children pack a several times
21
+ * @class Repeater
22
+ * @extends RepeatNode
23
+ */
24
+ export declare class Repeater extends RepeatNode<number, number> {
25
+ protected $: RepeaterPrivate<number>;
26
+ /**
27
+ * The count of children
28
+ */
29
+ count: IValue<number>;
30
+ constructor($?: RepeaterPrivate<number>);
31
+ /**
32
+ * Changes the children count
33
+ */
34
+ changeCount(number: number): void;
35
+ $created(): void;
36
+ $ready(): void;
37
+ $destroy(): void;
38
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseView } from "./base-view";
2
+ import { SetModel } from "../models/set-model";
3
+ /**
4
+ * Create a children pack for each set value
5
+ * @class SetView
6
+ * @extends BaseView
7
+ */
8
+ export declare class SetView<T> extends BaseView<T, T, SetModel<T>> {
9
+ constructor();
10
+ $ready(): void;
11
+ }
package/CHANGELOG.md DELETED
@@ -1,23 +0,0 @@
1
- # Changelog
2
-
3
- ## 1.2
4
-
5
- * `:alive` directive
6
- * `:mount` directive
7
- * `on$destroy` & `on$mount` events
8
-
9
- ## 1.1
10
-
11
- * Boost up **Reactive References**
12
- * `:show` directive
13
- * Small bug fixes
14
-
15
- ## 1.0
16
-
17
- Initial version which includes:
18
- * **Vasille.js node** classes (Component, Fragment, App)
19
- * **Reactive Reference** library: Reference, Pointer & Expression
20
- * **Conditional** node: SwitchNode
21
- * **Loop nodes**: Repeater, ObjectView, ArrayView, SetView & MapView
22
- * **Bindings**: class, attribute, event
23
- * **DOM** creation tools
package/lib/attribute.js DELETED
@@ -1,71 +0,0 @@
1
- //
2
- import { Binding } from "./bind.js";
3
- import { Callable } from "./interfaces/idefinition.js";
4
- import { IValue } from "./interfaces/ivalue.js";
5
- import { propertify } from "./property.js";
6
-
7
-
8
-
9
- /**
10
- * Creates a attribute 1 to 1 bind
11
- * @param rt {INode} is the root component
12
- * @param ts {INode} is the this component
13
- * @param name {String} is attribute name
14
- * @param value {?any} is attribute value
15
- * @param func {?Callable} is attribute value calculation function
16
- * @returns {AttributeBinding} 1 to 1 bind of attribute
17
- */
18
- export function attributify (
19
- rt,
20
- ts,
21
- name,
22
- value = null,
23
- func = null
24
- ) {
25
- return new AttributeBinding(rt, ts, name, null, propertify(value, func));
26
- }
27
-
28
- /**
29
- * Represents a Attribute binding description
30
- * @extends Binding
31
- */
32
- export class AttributeBinding extends Binding {
33
- /**
34
- * Constructs a attribute binding description
35
- * @param rt {INode} is root component
36
- * @param ts {INode} is this component
37
- * @param name {String} is the name of attribute
38
- * @param func {?Function} is the function to bound
39
- * @param values {Array<IValue>} is the array of values to bind to
40
- */
41
- constructor (
42
- rt,
43
- ts,
44
- name,
45
- func,
46
- ...values
47
- ) {
48
- super(rt, ts, name, func, ...values);
49
- }
50
-
51
- /**
52
- * Generates a function which updates the attribute value
53
- * @param name {String} The name of attribute
54
- * @returns {Function} a function which will update attribute value
55
- */
56
- bound (name) {
57
- return function (rt, ts, value) {
58
-
59
- if (value) {
60
- rt.$.app.$run.setAttribute(ts.el, name, value);
61
- }
62
- else {
63
- rt.$.app.$run.removeAttribute(ts.el, name);
64
- }
65
-
66
- return value;
67
- };
68
- }
69
- }
70
-
71
- //# sourceMappingURL=attribute.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/attribute.js"],"names":[],"mappings":"GAAG,AAAK;;;;AAIR,AAAoC,AAAA;;;;;;;;;;;;;;;OAe7B,AAAA,AAAO;OACP,AAAA,AAAO;SACL,AAAA,AAAQ;UACP,AAAA,AAAM;SACP,AAAA,AAAW;EAClB,AAAA,AAAkB;;;;;;;;;;;;;;;;;;WAkBT,AAAA,AAAO;WACP,AAAA,AAAO;aACL,AAAA,AAAQ;aACR,AAAA,AAAW;kBACN,AAAA,AAAoB;;;;;;;;;;gBAUtB,AAAA,AAAQ,EAAE,AAAA,AAAU;4BACR,AAAA,AAAK,KAAK,AAAA,AAAK,QAAQ,AAAA,AAAQ"}