vasille 2.0.2 → 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/README.md CHANGED
@@ -4,8 +4,17 @@
4
4
 
5
5
  `Vasille` core library is frontend solution for `safe`, `fast` & `powerful` applications.
6
6
 
7
+ [![build](https://gitlab.com/vasille-js/vasille-js/badges/v2/pipeline.svg)](https://gitlab.com/vasille-js/vasille-js)
8
+ [![npm](https://img.shields.io/npm/v/vasille?style=flat-square)](https://www.npmjs.com/package/vasille)
9
+
7
10
  ## Table of content
8
- [[_TOC_]]
11
+
12
+ * [Installation](#installation)
13
+ * [How SAFE is Vasille](#how-safe-is-vasille)
14
+ * [How FAST is Vasille](#how-fast-is-vasille)
15
+ * [How POWERFUL is Vasille](#how-powerful-is-vasille)
16
+ * [How to use Vasille](#how-to-use-vasille)
17
+ * [Best Practices](#best-practices)
9
18
 
10
19
 
11
20
  <hr>
@@ -19,8 +28,10 @@ npm install vasille --save
19
28
  ### CDN
20
29
 
21
30
  ```html
22
- <script src="https://unpkg.com/vasille"></script> - ES215 version
23
- <script src="https://unpkg.com/vasille/cdn/es5.js"></script> - ES5 Compatible version
31
+ ES2015 version
32
+ <script src="https://unpkg.com/vasille"></script>
33
+ ES5 Compatible version
34
+ <script src="https://unpkg.com/vasille/cdn/es5.js"></script>
24
35
  ```
25
36
 
26
37
  ### Getting ready be example
@@ -162,12 +173,26 @@ which will be reflected into a browser DOM and keep up to date it.
162
173
  * `InterceptorNode` is used to send an event/signal from one child to other
163
174
  without manually creating of interceptors.
164
175
 
165
- ## API documentation
166
-
167
- There are several API, and most of it are WIP (Work In Progress):
168
- * [OOP API - Ready](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/pages/OOP-API.md)
169
- * [Procedural API - WIP](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/pages/Procedural-API.md)
170
- * [Final API - WIP](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/pages/API.md)
176
+ ## How to use Vasille
177
+
178
+ There are several modes, and most of it are WIP (Work In Progress):
179
+ * [Object-Oriented Programming - Ready](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/pages/OOP-API.md)
180
+ * [Procedural Programming - WIP](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/pages/Procedural-API.md)
181
+ * [Template Programming - WIP](https://gitlab.com/vasille-js/vasille-js/-/blob/v2/pages/API.md)
182
+
183
+ ## Best Practices
184
+
185
+ * [Reactive Object Practice](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/reactive-object.ts)
186
+ * [Application](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/application.ts)
187
+ * [Application in Application](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/application-in-application.ts)
188
+ * [Signaling](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/signaling.ts)
189
+ * [Forward Only Data Exchange](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/forward-only.ts)
190
+ * [Absolute, Relative & Auto Values](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/auto-value.ts)
191
+ * [Signaling Intercepting](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/singaling-intercepting.ts)
192
+ * [Debugging](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/debugging.ts)
193
+ * [Fragment vs Component](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/fragment-component.ts)
194
+ * [Extensions](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/extension.ts)
195
+ * [Model-View-Controller](https://gitlab.com/vasille-js/vasille-practices/-/blob/main/practices/model-view-controller.ts)
171
196
 
172
197
  ## Questions
173
198
 
package/cdn/es2015.js CHANGED
@@ -1305,10 +1305,18 @@ class Reactive extends Destroyable {
1305
1305
  /**
1306
1306
  * Create a mirror
1307
1307
  * @param value {IValue} value to mirror
1308
- * @param forwardOnly {boolean} forward only sync
1309
1308
  */
1310
- $mirror(value, forwardOnly = false) {
1311
- const mirror = new Mirror(value, forwardOnly);
1309
+ $mirror(value) {
1310
+ const mirror = new Mirror(value, false);
1311
+ this.$.watch.add(mirror);
1312
+ return mirror;
1313
+ }
1314
+ /**
1315
+ * Create a forward-only mirror
1316
+ * @param value {IValue} value to mirror
1317
+ */
1318
+ $forward(value) {
1319
+ const mirror = new Mirror(value, true);
1312
1320
  this.$.watch.add(mirror);
1313
1321
  return mirror;
1314
1322
  }
@@ -1589,9 +1597,11 @@ class Fragment extends Reactive {
1589
1597
  return this;
1590
1598
  }
1591
1599
  $debug(text) {
1592
- const node = new DebugNode();
1593
- node.$preinit(this.$.app, this, text);
1594
- this.$$pushNode(node);
1600
+ if (this.$.app.$debugUi) {
1601
+ const node = new DebugNode();
1602
+ node.$preinit(this.$.app, this, text);
1603
+ this.$$pushNode(node);
1604
+ }
1595
1605
  return this;
1596
1606
  }
1597
1607
  $tag(tagName, cb) {
@@ -2635,6 +2645,7 @@ class AppNode extends INode {
2635
2645
  constructor(options) {
2636
2646
  super();
2637
2647
  this.$run = (options === null || options === void 0 ? void 0 : options.executor) || ((options === null || options === void 0 ? void 0 : options.freezeUi) === false ? timeoutExecutor : instantExecutor);
2648
+ this.$debugUi = (options === null || options === void 0 ? void 0 : options.debugUi) || false;
2638
2649
  }
2639
2650
  }
2640
2651
  /**
@@ -3102,10 +3113,9 @@ window.BaseView = BaseView;
3102
3113
  * @extends BaseView
3103
3114
  */
3104
3115
  class ArrayView extends BaseView {
3105
- constructor() {
3116
+ constructor(model) {
3106
3117
  super();
3107
- this.model = new ArrayModel;
3108
- this.$seal();
3118
+ this.model = model;
3109
3119
  }
3110
3120
  createChild(id, item, before) {
3111
3121
  super.createChild(item, item, before || this.$.nodes.get(id));
@@ -3156,9 +3166,9 @@ window.Watch = Watch;
3156
3166
  * @extends BaseView
3157
3167
  */
3158
3168
  class ObjectView extends BaseView {
3159
- constructor() {
3169
+ constructor(model) {
3160
3170
  super();
3161
- this.model = new ObjectModel;
3171
+ this.model = model;
3162
3172
  }
3163
3173
  $ready() {
3164
3174
  const obj = this.model;
@@ -3178,9 +3188,9 @@ window.ObjectView = ObjectView;
3178
3188
  * @extends BaseView
3179
3189
  */
3180
3190
  class MapView extends BaseView {
3181
- constructor() {
3191
+ constructor(model) {
3182
3192
  super();
3183
- this.model = new MapModel;
3193
+ this.model = model;
3184
3194
  }
3185
3195
  $ready() {
3186
3196
  const map = this.model;
@@ -3200,9 +3210,9 @@ window.MapView = MapView;
3200
3210
  * @extends BaseView
3201
3211
  */
3202
3212
  class SetView extends BaseView {
3203
- constructor() {
3213
+ constructor(model) {
3204
3214
  super();
3205
- this.model = new SetModel();
3215
+ this.model = model;
3206
3216
  }
3207
3217
  $ready() {
3208
3218
  const $ = this.$;
package/cdn/es5.js CHANGED
@@ -12,166 +12,159 @@ var __spreadArray = function (to, from, pack) {
12
12
  return to.concat(ar || Array.prototype.slice.call(from));
13
13
  };
14
14
 
15
- // if (!window.Set) {
16
- var Set = /** @class */ (function (_super) {
17
- __extends(Set, _super);
18
- function Set(set) {
19
- if (set === void 0) { set = []; }
20
- var _this = this; _super.call(this);
21
- set.forEach(function (item) {
22
- _this.add (item)
23
- });
24
- Object.defineProperty(_this, 'hash', {
25
- value: Object.create(null),
26
- writable: true
27
- });
28
- return _this;
15
+ var Set = window.Set || /** @class */ (function (_super) {
16
+ __extends(Set, _super);
17
+ function Set(set) {
18
+ if (set === void 0) { set = []; }
19
+ var _this = this; _super.call(this);
20
+ set.forEach(function (item) {
21
+ _this.add (item)
22
+ });
23
+ Object.defineProperty(_this, 'hash', {
24
+ value: Object.create(null),
25
+ writable: true
26
+ });
27
+ return _this;
28
+ }
29
+
30
+ Set.prototype.has = function (value) {
31
+ if (typeof value === "string" || typeof value === "number") {
32
+ return this.hash[value] !== void 0;
29
33
  }
34
+ else {
35
+ return this.indexOf(value) !== -1;
36
+ }
37
+ };
30
38
 
31
- Set.prototype.has = function (value) {
32
- if (typeof value === "string" || typeof value === "number") {
33
- return this.hash[value] !== void 0;
39
+ Set.prototype.add = function (value) {
40
+ if (typeof value === "string" || typeof value === "number") {
41
+ if (this.hash[value]) {
42
+ return this;
34
43
  }
35
44
  else {
36
- return this.indexOf(value) !== -1;
45
+ this.hash[value] = true;
37
46
  }
38
- };
39
-
40
- Set.prototype.add = function (value) {
41
- if (typeof value === "string" || typeof value === "number") {
42
- if (this.hash[value]) {
43
- return this;
44
- }
45
- else {
46
- this.hash[value] = true;
47
- }
48
- }
49
- else {
50
- if (this.indexOf(value) !== -1) {
51
- return this;
52
- }
53
- this.push(value);
47
+ }
48
+ else {
49
+ if (this.indexOf(value) !== -1) {
50
+ return this;
54
51
  }
55
- return this;
56
- };
52
+ this.push(value);
53
+ }
54
+ return this;
55
+ };
57
56
 
58
- Set.prototype.clear = function () {
59
- this.hash = Object.create(null);
60
- this.splice(0);
61
- };
57
+ Set.prototype.clear = function () {
58
+ this.hash = Object.create(null);
59
+ this.splice(0);
60
+ };
62
61
 
63
- Set.prototype.delete = function (value) {
64
- if (typeof value === "string" || typeof value === "number") {
65
- if (this.hash[value] !== void 0) {
66
- delete this.hash[value];
67
- }
62
+ Set.prototype.delete = function (value) {
63
+ if (typeof value === "string" || typeof value === "number") {
64
+ if (this.hash[value] !== void 0) {
65
+ delete this.hash[value];
68
66
  }
69
- else {
70
- var index = this.indexOf(value);
71
- if (index !== -1) {
72
- this.splice(index, 1);
73
- }
67
+ }
68
+ else {
69
+ var index = this.indexOf(value);
70
+ if (index !== -1) {
71
+ this.splice(index, 1);
74
72
  }
75
- this.push(value);
76
- return this;
77
- };
78
- return Set;
79
- }(Array));
80
-
81
- window.Set = Set;
82
- // }
83
-
84
- // if (!window.Map) {
85
- var Map = /** @class */ (function (_super) {
86
- __extends(Map, _super);
87
-
88
- function Map(map) {
89
- if (map === void 0) { map = []; }
90
- var _this = this; _super.call(this);
91
- Object.defineProperty(_this, 'hash', {
92
- value: Object.create(null),
93
- writable: true
94
- });
95
- map.forEach(function (_a) {
96
- var key = _a[0], value = _a[1];
97
- this.set(key, value);
98
- });
99
- return _this;
100
73
  }
74
+ this.push(value);
75
+ return this;
76
+ };
77
+ return Set;
78
+ }(Array));
101
79
 
102
- Map.prototype.clear = function () {
103
- this.hash = Object.create(null);
104
- this.splice(0);
105
- };
80
+ var Map = window.Map || /** @class */ (function (_super) {
81
+ __extends(Map, _super);
106
82
 
107
- Map.prototype.delete = function (key) {
108
- if (typeof key === "string" || typeof key === "number") {
109
- if (this.hash[key] !== void 0) {
110
- delete this.hash[key];
111
- }
112
- }
113
- else {
114
- for (var i = 0; i < this.length; i++) {
115
- if (this[i][0] === key) {
116
- this.splice(i, 1);
117
- }
118
- }
119
- }
120
- };
83
+ function Map(map) {
84
+ if (map === void 0) { map = []; }
85
+ var _this = this; _super.call(this);
86
+ Object.defineProperty(_this, 'hash', {
87
+ value: Object.create(null),
88
+ writable: true
89
+ });
90
+ map.forEach(function (_a) {
91
+ var key = _a[0], value = _a[1];
92
+ this.set(key, value);
93
+ });
94
+ return _this;
95
+ }
121
96
 
122
- function indexOfKey(key) {
97
+ Map.prototype.clear = function () {
98
+ this.hash = Object.create(null);
99
+ this.splice(0);
100
+ };
101
+
102
+ Map.prototype.delete = function (key) {
103
+ if (typeof key === "string" || typeof key === "number") {
104
+ if (this.hash[key] !== void 0) {
105
+ delete this.hash[key];
106
+ }
107
+ }
108
+ else {
123
109
  for (var i = 0; i < this.length; i++) {
124
110
  if (this[i][0] === key) {
125
- return i;
111
+ this.splice(i, 1);
126
112
  }
127
113
  }
128
- return -1;
129
114
  }
115
+ };
130
116
 
131
- Map.prototype.set = function (key, value) {
132
- if (typeof key === "string" || typeof key === "number") {
133
- this.hash[key] = value;
117
+ function indexOfKey(key) {
118
+ for (var i = 0; i < this.length; i++) {
119
+ if (this[i][0] === key) {
120
+ return i;
134
121
  }
135
- else {
136
- var index = indexOfKey.call(this, key);
137
- if (index === -1) {
138
- this.push([key, value]);
139
- }
140
- else {
141
- this[index][1] = value;
142
- }
143
- }
144
- };
145
-
122
+ }
123
+ return -1;
124
+ }
146
125
 
147
- Map.prototype.has = function (key) {
148
- if (typeof key === "string" || typeof key === "number") {
149
- return !!this.hash[key];
126
+ Map.prototype.set = function (key, value) {
127
+ if (typeof key === "string" || typeof key === "number") {
128
+ this.hash[key] = value;
129
+ }
130
+ else {
131
+ var index = indexOfKey.call(this, key);
132
+ if (index === -1) {
133
+ this.push([key, value]);
150
134
  }
151
135
  else {
152
- return indexOfKey.call(this, key) !== -1;
136
+ this[index][1] = value;
153
137
  }
154
- };
138
+ }
139
+ };
155
140
 
156
- Map.prototype.get = function (key) {
157
- if (typeof key === "string" || typeof key === "number") {
158
- return this.hash[key];
141
+
142
+ Map.prototype.has = function (key) {
143
+ if (typeof key === "string" || typeof key === "number") {
144
+ return !!this.hash[key];
145
+ }
146
+ else {
147
+ return indexOfKey.call(this, key) !== -1;
148
+ }
149
+ };
150
+
151
+ Map.prototype.get = function (key) {
152
+ if (typeof key === "string" || typeof key === "number") {
153
+ return this.hash[key];
154
+ }
155
+ else {
156
+ var index = indexOfKey.call(this, key);
157
+ if (index !== -1) {
158
+ return this[index][1];
159
159
  }
160
160
  else {
161
- var index = indexOfKey.call(this, key);
162
- if (index !== -1) {
163
- return this[index][1];
164
- }
165
- else {
166
- return void 0;
167
- }
161
+ return void 0;
168
162
  }
169
- };
163
+ }
164
+ };
170
165
 
171
- return Map;
172
- }(Array));
173
- window.Map = Map;
174
- // }
166
+ return Map;
167
+ }(Array));
175
168
  // ./lib-es5/models/model.js
176
169
 
177
170
 
@@ -1605,11 +1598,18 @@ var Reactive = /** @class */ (function (_super) {
1605
1598
  /**
1606
1599
  * Create a mirror
1607
1600
  * @param value {IValue} value to mirror
1608
- * @param forwardOnly {boolean} forward only sync
1609
1601
  */
1610
- Reactive.prototype.$mirror = function (value, forwardOnly) {
1611
- if (forwardOnly === void 0) { forwardOnly = false; }
1612
- var mirror = new Mirror(value, forwardOnly);
1602
+ Reactive.prototype.$mirror = function (value) {
1603
+ var mirror = new Mirror(value, false);
1604
+ this.$.watch.add(mirror);
1605
+ return mirror;
1606
+ };
1607
+ /**
1608
+ * Create a forward-only mirror
1609
+ * @param value {IValue} value to mirror
1610
+ */
1611
+ Reactive.prototype.$forward = function (value) {
1612
+ var mirror = new Mirror(value, true);
1613
1613
  this.$.watch.add(mirror);
1614
1614
  return mirror;
1615
1615
  };
@@ -1904,9 +1904,11 @@ var Fragment = /** @class */ (function (_super) {
1904
1904
  return this;
1905
1905
  };
1906
1906
  Fragment.prototype.$debug = function (text) {
1907
- var node = new DebugNode();
1908
- node.$preinit(this.$.app, this, text);
1909
- this.$$pushNode(node);
1907
+ if (this.$.app.$debugUi) {
1908
+ var node = new DebugNode();
1909
+ node.$preinit(this.$.app, this, text);
1910
+ this.$$pushNode(node);
1911
+ }
1910
1912
  return this;
1911
1913
  };
1912
1914
  Fragment.prototype.$tag = function (tagName, cb) {
@@ -3012,6 +3014,7 @@ var AppNode = /** @class */ (function (_super) {
3012
3014
  function AppNode(options) {
3013
3015
  var _this = this; _super.call(this);
3014
3016
  _this.$run = (options === null || options === void 0 ? void 0 : options.executor) || ((options === null || options === void 0 ? void 0 : options.freezeUi) === false ? timeoutExecutor : instantExecutor);
3017
+ _this.$debugUi = (options === null || options === void 0 ? void 0 : options.debugUi) || false;
3015
3018
  return _this;
3016
3019
  }
3017
3020
  return AppNode;
@@ -3531,10 +3534,9 @@ window.BaseView = BaseView;
3531
3534
  */
3532
3535
  var ArrayView = /** @class */ (function (_super) {
3533
3536
  __extends(ArrayView, _super);
3534
- function ArrayView() {
3537
+ function ArrayView(model) {
3535
3538
  var _this = this; _super.call(this);
3536
- _this.model = new ArrayModel;
3537
- _this.$seal();
3539
+ _this.model = model;
3538
3540
  return _this;
3539
3541
  }
3540
3542
  ArrayView.prototype.createChild = function (id, item, before) {
@@ -3595,9 +3597,9 @@ window.Watch = Watch;
3595
3597
  */
3596
3598
  var ObjectView = /** @class */ (function (_super) {
3597
3599
  __extends(ObjectView, _super);
3598
- function ObjectView() {
3600
+ function ObjectView(model) {
3599
3601
  var _this = this; _super.call(this);
3600
- _this.model = new ObjectModel;
3602
+ _this.model = model;
3601
3603
  return _this;
3602
3604
  }
3603
3605
  ObjectView.prototype.$ready = function () {
@@ -3621,9 +3623,9 @@ window.ObjectView = ObjectView;
3621
3623
  */
3622
3624
  var MapView = /** @class */ (function (_super) {
3623
3625
  __extends(MapView, _super);
3624
- function MapView() {
3626
+ function MapView(model) {
3625
3627
  var _this = this; _super.call(this);
3626
- _this.model = new MapModel;
3628
+ _this.model = model;
3627
3629
  return _this;
3628
3630
  }
3629
3631
  MapView.prototype.$ready = function () {
@@ -3648,9 +3650,9 @@ window.MapView = MapView;
3648
3650
  */
3649
3651
  var SetView = /** @class */ (function (_super) {
3650
3652
  __extends(SetView, _super);
3651
- function SetView() {
3653
+ function SetView(model) {
3652
3654
  var _this = this; _super.call(this);
3653
- _this.model = new SetModel();
3655
+ _this.model = model;
3654
3656
  return _this;
3655
3657
  }
3656
3658
  SetView.prototype.$ready = function () {
@@ -7,6 +7,7 @@ interface IModel {
7
7
  disableReactivity () : void;
8
8
  }
9
9
  type AppOptions = ?{
10
+ debugUi?: boolean,
10
11
  freezeUi ?: boolean,
11
12
  executor ?: Executor
12
13
  }
@@ -34,7 +35,8 @@ declare module "vasille" {
34
35
  constructor ($ : ?ReactivePrivate) : void;
35
36
 
36
37
  $ref<T> (value : T) : IValue<T>;
37
- $mirror<T> (value : IValue<T>, forwardOnly?: boolean) : Mirror<T>;
38
+ $mirror<T> (value : IValue<T>) : Mirror<T>;
39
+ $forward<T> (value : IValue<T>) : Mirror<T>;
38
40
  $point<T>(value: T | IValue<T>, forwardOnly?: boolean): Pointer<T>;
39
41
  $register<T>(model: T): T;
40
42
 
@@ -161,7 +163,7 @@ declare module "vasille" {
161
163
  disable () : this;
162
164
  }
163
165
  declare export class Signal<
164
- T1 = void, T2 = void, T3 = void, T4 = void, T5 = void, T6 = void, T7 = void, T8 = void, T9 = void
166
+ T = Fragment, T1 = void, T2 = void, T3 = void, T4 = void, T5 = void, T6 = void, T7 = void, T8 = void, T9 = void
165
167
  > {
166
168
  handlers : Set<
167
169
  (a1 : T1, a2 : T2, a3 : T3, a4 : T4, a5 : T5, a6 : T6, a7 : T7, a8 : T8, a9 : T9) => void
@@ -178,17 +180,17 @@ declare module "vasille" {
178
180
  declare export class Slot<
179
181
  t1 = void, t2 = void, t3 = void, t4 = void, t5 = void, t6 = void, t7 = void, t8 = void, t9 = void
180
182
  > {
181
- runner : ?(a0 : Fragment, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9) => void;
183
+ runner : ?(a0 : T, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9) => void;
182
184
 
183
185
  insert (
184
- func : (a0 : Fragment, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9) => void
186
+ func : (a0 : T, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9) => void
185
187
  ) : void;
186
188
  release (
187
- a0 : Fragment, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9
189
+ a0 : T, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9
188
190
  ) : void;
189
191
  predefine (
190
- func : (a0 : Fragment, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9) => void,
191
- a0 : Fragment, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9
192
+ func : (a0 : T, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9) => void,
193
+ a0 : T, a1 : t1, a2 : t2, a3 : t3, a4 : t4, a5 : t5, a6 : t6, a7 : t7, a8 : t8, a9 : t9
192
194
  ) : void;
193
195
  }
194
196
  declare export class Listener<ValueT, IndexT = string | number> {
@@ -283,7 +285,7 @@ declare module "vasille" {
283
285
  t1 = void, t2 = void, t3 = void, t4 = void, t5 = void, t6 = void, t7 = void, t8 = void, t9 = void
284
286
  > extends Fragment {
285
287
  interceptor : Interceptor<t1, t2, t3, t4, t5, t6, t7, t8, t9>;
286
- slot : Slot<Interceptor<t1, t2, t3, t4, t5, t6, t7, t8, t9>>;
288
+ slot : Slot<Fragment, Interceptor<t1, t2, t3, t4, t5, t6, t7, t8, t9>>;
287
289
  }
288
290
  declare export class FragmentPrivate extends ReactivePrivate {
289
291
 
@@ -600,7 +602,7 @@ declare module "vasille" {
600
602
  $preinit (app : AppNode, parent : Fragment, text : ?IValue<string>) : void;
601
603
  }
602
604
  declare export class Watch<T> extends Fragment {
603
- slot : Slot<T>;
605
+ slot : Slot<Fragment, T>;
604
606
  model : IValue<T>;
605
607
 
606
608
  constructor () : void;
@@ -754,14 +756,14 @@ declare module "vasille" {
754
756
  constructor ($1 : ?BaseViewPrivate<K, T>) : void;
755
757
  }
756
758
  declare export class ArrayView<T> extends BaseView<?T, T, ArrayModel<T>> {
757
- constructor () : void;
759
+ constructor (model : ArrayModel<T>) : void;
758
760
  createChild (id : ?T, item : T, before : ?Fragment) : any;
759
761
  }
760
762
  declare export class MapView<K, T> extends BaseView<K, T, MapModel<K, T>> {
761
- constructor () : void;
763
+ constructor (model : MapModel<K, T>) : void;
762
764
  }
763
765
  declare export class ObjectView<T> extends BaseView<string, T, ObjectModel<T>> {
764
- constructor () : void;
766
+ constructor (model : ObjectModel<T>) : void;
765
767
  }
766
768
  declare export class RepeatNodePrivate<IdT> extends INodePrivate {
767
769
  nodes : Map<IdT, Fragment>;
@@ -769,7 +771,7 @@ declare module "vasille" {
769
771
  constructor () : void;
770
772
  }
771
773
  declare export class RepeatNode<IdT, T> extends Fragment {
772
- slot : Slot<T, IdT>;
774
+ slot : Slot<Fragment, T, IdT>;
773
775
  freezeUi : boolean;
774
776
 
775
777
  constructor ($ : ?RepeatNodePrivate<IdT>) : void;
@@ -791,7 +793,7 @@ declare module "vasille" {
791
793
  changeCount (number : number) : void;
792
794
  }
793
795
  declare export class SetView<T> extends BaseView<T, T, SetModel<T>> {
794
- constructor () : void;
796
+ constructor (model : SetModel<T>) : void;
795
797
  }
796
798
  declare export class AttributeBinding extends Binding<?string> {
797
799
  constructor (
package/lib/core/core.js CHANGED
@@ -72,10 +72,18 @@ export class Reactive extends Destroyable {
72
72
  /**
73
73
  * Create a mirror
74
74
  * @param value {IValue} value to mirror
75
- * @param forwardOnly {boolean} forward only sync
76
75
  */
77
- $mirror(value, forwardOnly = false) {
78
- const mirror = new Mirror(value, forwardOnly);
76
+ $mirror(value) {
77
+ const mirror = new Mirror(value, false);
78
+ this.$.watch.add(mirror);
79
+ return mirror;
80
+ }
81
+ /**
82
+ * Create a forward-only mirror
83
+ * @param value {IValue} value to mirror
84
+ */
85
+ $forward(value) {
86
+ const mirror = new Mirror(value, true);
79
87
  this.$.watch.add(mirror);
80
88
  return mirror;
81
89
  }
package/lib/node/app.js CHANGED
@@ -12,6 +12,7 @@ export class AppNode extends INode {
12
12
  constructor(options) {
13
13
  super();
14
14
  this.$run = (options === null || options === void 0 ? void 0 : options.executor) || ((options === null || options === void 0 ? void 0 : options.freezeUi) === false ? timeoutExecutor : instantExecutor);
15
+ this.$debugUi = (options === null || options === void 0 ? void 0 : options.debugUi) || false;
15
16
  }
16
17
  }
17
18
  /**
package/lib/node/node.js CHANGED
@@ -181,9 +181,11 @@ export class Fragment extends Reactive {
181
181
  return this;
182
182
  }
183
183
  $debug(text) {
184
- const node = new DebugNode();
185
- node.$preinit(this.$.app, this, text);
186
- this.$$pushNode(node);
184
+ if (this.$.app.$debugUi) {
185
+ const node = new DebugNode();
186
+ node.$preinit(this.$.app, this, text);
187
+ this.$$pushNode(node);
188
+ }
187
189
  return this;
188
190
  }
189
191
  $tag(tagName, cb) {
@@ -1,15 +1,13 @@
1
1
  import { BaseView } from "./base-view";
2
- import { ArrayModel } from "../models/array-model";
3
2
  /**
4
3
  * Represents a view of an array model
5
4
  * @class ArrayView
6
5
  * @extends BaseView
7
6
  */
8
7
  export class ArrayView extends BaseView {
9
- constructor() {
8
+ constructor(model) {
10
9
  super();
11
- this.model = new ArrayModel;
12
- this.$seal();
10
+ this.model = model;
13
11
  }
14
12
  createChild(id, item, before) {
15
13
  super.createChild(item, item, before || this.$.nodes.get(id));
@@ -1,14 +1,13 @@
1
1
  import { BaseView } from "./base-view";
2
- import { MapModel } from "../models/map-model";
3
2
  /**
4
3
  * Create a children pack for each map value
5
4
  * @class MapView
6
5
  * @extends BaseView
7
6
  */
8
7
  export class MapView extends BaseView {
9
- constructor() {
8
+ constructor(model) {
10
9
  super();
11
- this.model = new MapModel;
10
+ this.model = model;
12
11
  }
13
12
  $ready() {
14
13
  const map = this.model;
@@ -1,14 +1,13 @@
1
1
  import { BaseView } from "./base-view";
2
- import { ObjectModel } from "../models/object-model";
3
2
  /**
4
3
  * Create a children pack for each object field
5
4
  * @class ObjectView
6
5
  * @extends BaseView
7
6
  */
8
7
  export class ObjectView extends BaseView {
9
- constructor() {
8
+ constructor(model) {
10
9
  super();
11
- this.model = new ObjectModel;
10
+ this.model = model;
12
11
  }
13
12
  $ready() {
14
13
  const obj = this.model;
@@ -1,14 +1,13 @@
1
1
  import { BaseView } from "./base-view";
2
- import { SetModel } from "../models/set-model";
3
2
  /**
4
3
  * Create a children pack for each set value
5
4
  * @class SetView
6
5
  * @extends BaseView
7
6
  */
8
7
  export class SetView extends BaseView {
9
- constructor() {
8
+ constructor(model) {
10
9
  super();
11
- this.model = new SetModel();
10
+ this.model = model;
12
11
  }
13
12
  $ready() {
14
13
  const $ = this.$;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Vasille - Safe. Fast. Powerful.",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
- "version": "2.0.2",
6
+ "version": "2.0.3",
7
7
  "exports": {
8
8
  "import": "./lib/index.js",
9
9
  "browser": "./lib/index.js"
@@ -62,9 +62,13 @@ export declare class Reactive extends Destroyable {
62
62
  /**
63
63
  * Create a mirror
64
64
  * @param value {IValue} value to mirror
65
- * @param forwardOnly {boolean} forward only sync
66
65
  */
67
- $mirror<T>(value: IValue<T>, forwardOnly?: boolean): Mirror<T>;
66
+ $mirror<T>(value: IValue<T>): Mirror<T>;
67
+ /**
68
+ * Create a forward-only mirror
69
+ * @param value {IValue} value to mirror
70
+ */
71
+ $forward<T>(value: IValue<T>): Mirror<T>;
68
72
  /**
69
73
  * Creates a pointer
70
74
  * @param value {*} default value to point
@@ -112,15 +116,15 @@ export declare class Reactive extends Destroyable {
112
116
  * @param v9 {IValue} argument
113
117
  * @return {IValue} the created ivalue
114
118
  */
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;
119
+ $bind<T, T1>(func: (a1: T1) => T, v1: IValue<T1>): IValue<T>;
120
+ $bind<T, T1, T2>(func: (a1: T1, a2: T2) => T, v1: IValue<T1>, v2: IValue<T2>): IValue<T>;
121
+ $bind<T, T1, T2, T3>(func: (a1: T1, a2: T2, a3: T3) => T, v1: IValue<T1>, v2: IValue<T2>, v3: IValue<T3>): IValue<T>;
122
+ $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>): IValue<T>;
123
+ $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>): IValue<T>;
124
+ $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>): IValue<T>;
125
+ $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>): IValue<T>;
126
+ $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>): IValue<T>;
127
+ $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>): IValue<T>;
124
128
  /**
125
129
  * Enable reactivity of fields
126
130
  */
@@ -3,7 +3,7 @@ import { Fragment } from "../node/node";
3
3
  * Component slot
4
4
  * @class Slot
5
5
  */
6
- export declare class Slot<t1 = void, t2 = void, t3 = void, t4 = void, t5 = void, t6 = void, t7 = void, t8 = void, t9 = void> {
6
+ export declare class Slot<t extends Fragment = Fragment, t1 = void, t2 = void, t3 = void, t4 = void, t5 = void, t6 = void, t7 = void, t8 = void, t9 = void> {
7
7
  /**
8
8
  * Function to run
9
9
  * @type {function(node : Fragment)}
@@ -13,7 +13,7 @@ export declare class Slot<t1 = void, t2 = void, t3 = void, t4 = void, t5 = void,
13
13
  * Sets the runner
14
14
  * @param func {function} the function to run
15
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;
16
+ insert(func: (a0: t, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9) => void): void;
17
17
  /**
18
18
  * @param a0 {Fragment} node to paste content
19
19
  * @param a1 {*} 1st argument
@@ -26,7 +26,7 @@ export declare class Slot<t1 = void, t2 = void, t3 = void, t4 = void, t5 = void,
26
26
  * @param a8 {*} 8th argument
27
27
  * @param a9 {*} 9th argument
28
28
  */
29
- release(a0: Fragment, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9): void;
29
+ release(a0: t, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9): void;
30
30
  /**
31
31
  * Predefine a handler for a slot
32
32
  * @param func {function(node : Fragment)} Function to run if no handler specified
@@ -41,5 +41,5 @@ export declare class Slot<t1 = void, t2 = void, t3 = void, t4 = void, t5 = void,
41
41
  * @param a8 {*} 8th argument
42
42
  * @param a9 {*} 9th argument
43
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;
44
+ predefine(func: (a0: t, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9) => void, a0: t, a1: t1, a2: t2, a3: t3, a4: t4, a5: t5, a6: t6, a7: t7, a8: t8, a9: t9): void;
45
45
  }
@@ -1,6 +1,7 @@
1
1
  import { Executor } from "../core/executor";
2
2
  import { INode } from "./node";
3
3
  declare type AppOptions = {
4
+ debugUi?: boolean;
4
5
  freezeUi?: boolean;
5
6
  executor?: Executor;
6
7
  };
@@ -15,6 +16,10 @@ export declare class AppNode extends INode {
15
16
  * @type {Executor}
16
17
  */
17
18
  $run: Executor;
19
+ /**
20
+ * Enables debug comments
21
+ */
22
+ $debugUi: boolean;
18
23
  /**
19
24
  * @param options {Object} Application options
20
25
  */
@@ -45,6 +45,6 @@ export declare class InterceptorNode<t1 = void, t2 = void, t3 = void, t4 = void,
45
45
  * The default slot of node
46
46
  * @type Slot
47
47
  */
48
- slot: Slot<Interceptor<t1, t2, t3, t4, t5, t6, t7, t8, t9>>;
48
+ slot: Slot<Fragment, Interceptor<t1, t2, t3, t4, t5, t6, t7, t8, t9>>;
49
49
  $compose(): void;
50
50
  }
@@ -11,7 +11,7 @@ export declare class Watch<T> extends Fragment {
11
11
  * Default slot
12
12
  * @type Slot
13
13
  */
14
- slot: Slot<T>;
14
+ slot: Slot<Fragment, T>;
15
15
  /**
16
16
  * iValue to watch
17
17
  * @type IValue
@@ -7,7 +7,7 @@ import { Fragment } from "../node/node";
7
7
  * @extends BaseView
8
8
  */
9
9
  export declare class ArrayView<T> extends BaseView<T, T, ArrayModel<T>> {
10
- constructor();
10
+ constructor(model: ArrayModel<T>);
11
11
  createChild(id: T, item: T, before?: Fragment): any;
12
12
  $ready(): void;
13
13
  }
@@ -6,6 +6,6 @@ import { MapModel } from "../models/map-model";
6
6
  * @extends BaseView
7
7
  */
8
8
  export declare class MapView<K, T> extends BaseView<K, T, MapModel<K, T>> {
9
- constructor();
9
+ constructor(model: MapModel<K, T>);
10
10
  $ready(): void;
11
11
  }
@@ -6,6 +6,6 @@ import { ObjectModel } from "../models/object-model";
6
6
  * @extends BaseView
7
7
  */
8
8
  export declare class ObjectView<T> extends BaseView<string, T, ObjectModel<T>> {
9
- constructor();
9
+ constructor(model: ObjectModel<T>);
10
10
  $ready(): void;
11
11
  }
@@ -24,7 +24,7 @@ export declare class RepeatNode<IdT, T> extends Fragment {
24
24
  /**
25
25
  * Default slot
26
26
  */
27
- slot: Slot<T, IdT>;
27
+ slot: Slot<Fragment, T, IdT>;
28
28
  /**
29
29
  * If false will use timeout executor, otherwise the app executor
30
30
  */
@@ -6,6 +6,6 @@ import { SetModel } from "../models/set-model";
6
6
  * @extends BaseView
7
7
  */
8
8
  export declare class SetView<T> extends BaseView<T, T, SetModel<T>> {
9
- constructor();
9
+ constructor(model: SetModel<T>);
10
10
  $ready(): void;
11
11
  }
package/.gitlab-ci.yml DELETED
@@ -1,20 +0,0 @@
1
- # This file is a template, and might need editing before it works on your project.
2
- # To contribute improvements to CI/CD templates, please follow the Development guide at:
3
- # https://docs.gitlab.com/ee/development/cicd/templates.html
4
- # This specific template is located at:
5
- # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Nodejs.gitlab-ci.yml
6
-
7
- # Official framework image. Look for the different tagged releases at:
8
- # https://hub.docker.com/r/library/node/tags/
9
- image: node:latest
10
-
11
- # This folder is cached between builds
12
- # https://docs.gitlab.com/ee/ci/yaml/index.html#cache
13
- cache:
14
- paths:
15
- - node_modules/
16
-
17
- test_async:
18
- script:
19
- - npm install
20
- - npm run build