vasille 2.0.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/cdn/es2015.js +939 -1009
- package/cdn/es5.js +1048 -1029
- package/flow-typed/vasille.js +2641 -832
- package/lib/binding/attribute.js +11 -12
- package/lib/binding/binding.js +9 -19
- package/lib/binding/class.js +34 -42
- package/lib/binding/style.js +5 -11
- package/lib/core/core.js +78 -32
- package/lib/core/destroyable.js +2 -2
- package/lib/core/ivalue.js +15 -13
- package/lib/functional/components.js +17 -0
- package/lib/functional/merge.js +41 -0
- package/lib/functional/models.js +26 -0
- package/lib/functional/options.js +1 -0
- package/lib/functional/reactivity.js +33 -0
- package/lib/functional/stack.js +127 -0
- package/lib/index.js +2 -7
- package/lib/models/array-model.js +9 -0
- package/lib/models/object-model.js +28 -14
- package/lib/node/app.js +23 -14
- package/lib/node/interceptor.js +3 -3
- package/lib/node/node.js +338 -684
- package/lib/node/watch.js +9 -17
- package/lib/spec/html.js +1 -0
- package/lib/spec/react.js +1 -0
- package/lib/spec/svg.js +1 -0
- package/lib/v/index.js +23 -0
- package/lib/value/expression.js +11 -8
- package/lib/value/mirror.js +6 -8
- package/lib/value/reference.js +3 -7
- package/lib/views/array-view.js +6 -10
- package/lib/views/base-view.js +12 -23
- package/lib/views/map-view.js +4 -9
- package/lib/views/object-view.js +5 -8
- package/lib/views/repeat-node.js +20 -60
- package/lib/views/repeater.js +7 -7
- package/lib/views/set-view.js +4 -11
- package/package.json +7 -6
- package/types/binding/attribute.d.ts +2 -8
- package/types/binding/binding.d.ts +4 -13
- package/types/binding/class.d.ts +7 -19
- package/types/binding/style.d.ts +0 -6
- package/types/core/core.d.ts +40 -54
- package/types/core/destroyable.d.ts +2 -2
- package/types/core/ivalue.d.ts +13 -11
- package/types/functional/components.d.ts +4 -0
- package/types/functional/merge.d.ts +1 -0
- package/types/functional/models.d.ts +10 -0
- package/types/functional/options.d.ts +23 -0
- package/types/functional/reactivity.d.ts +11 -0
- package/types/functional/stack.d.ts +24 -0
- package/types/index.d.ts +3 -7
- package/types/models/array-model.d.ts +3 -2
- package/types/models/map-model.d.ts +2 -2
- package/types/models/model.d.ts +3 -1
- package/types/models/object-model.d.ts +4 -2
- package/types/models/set-model.d.ts +2 -2
- package/types/node/app.d.ts +21 -19
- package/types/node/node.d.ts +97 -422
- package/types/node/watch.d.ts +9 -15
- package/types/spec/html.d.ts +975 -0
- package/types/spec/react.d.ts +4 -0
- package/types/spec/svg.d.ts +314 -0
- package/types/v/index.d.ts +32 -0
- package/types/value/expression.d.ts +7 -20
- package/types/value/mirror.d.ts +3 -3
- package/types/value/reference.d.ts +5 -5
- package/types/views/array-view.d.ts +3 -4
- package/types/views/base-view.d.ts +9 -17
- package/types/views/map-view.d.ts +2 -3
- package/types/views/object-view.d.ts +2 -3
- package/types/views/repeat-node.d.ts +8 -9
- package/types/views/set-view.d.ts +2 -3
- package/types/core/executor.d.ts +0 -87
- package/types/core/signal.d.ts +0 -35
- package/types/core/slot.d.ts +0 -45
- package/types/node/interceptor.d.ts +0 -50
- package/types/views/repeater.d.ts +0 -38
package/cdn/es5.js
CHANGED
|
@@ -12,6 +12,14 @@ var __spreadArray = function (to, from, pack) {
|
|
|
12
12
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
var __assign = function(o1, o2) {
|
|
16
|
+
for (let i in o2) {
|
|
17
|
+
o1[i] = o2[i];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return o1;
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
var Set = window.Set || /** @class */ (function (_super) {
|
|
16
24
|
__extends(Set, _super);
|
|
17
25
|
function Set(set) {
|
|
@@ -165,6 +173,42 @@ var Map = window.Map || /** @class */ (function (_super) {
|
|
|
165
173
|
|
|
166
174
|
return Map;
|
|
167
175
|
}(Array));
|
|
176
|
+
|
|
177
|
+
window.Reflect = window.Reflect || {
|
|
178
|
+
has: function (obj, p) {
|
|
179
|
+
for (var i in obj) {
|
|
180
|
+
if (i == p) return true;
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
},
|
|
184
|
+
ownKeys: function (obj) {
|
|
185
|
+
let ret = [];
|
|
186
|
+
|
|
187
|
+
for (var i in obj) {
|
|
188
|
+
if (obj.hasOwnProperty(i)) {
|
|
189
|
+
ret.push(i);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return ret;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
window.Proxy = window.Proxy || function (obj) {
|
|
198
|
+
return obj;
|
|
199
|
+
};
|
|
200
|
+
// ./lib-es5/v/index.js
|
|
201
|
+
|
|
202
|
+
var v = __assign(__assign({ ref: function (value) {
|
|
203
|
+
return current.ref(value);
|
|
204
|
+
}, expr: expr, of: valueOf, sv: setValue, alwaysFalse: new Reference(false), app: app, component: component, fragment: fragment, extension: extension, text: text, tag: tag, create: create }, vx), { merge: merge, destructor: function () {
|
|
205
|
+
return current.destroy.bind(current);
|
|
206
|
+
}, runOnDestroy: function (callback) {
|
|
207
|
+
current.runOnDestroy(callback);
|
|
208
|
+
} });
|
|
209
|
+
|
|
210
|
+
window.v = v;
|
|
211
|
+
|
|
168
212
|
// ./lib-es5/models/model.js
|
|
169
213
|
|
|
170
214
|
|
|
@@ -321,13 +365,14 @@ var ObjectModel = /** @class */ (function (_super) {
|
|
|
321
365
|
function ObjectModel(obj) {
|
|
322
366
|
if (obj === void 0) { obj = {}; }
|
|
323
367
|
var _this = this; _super.call(this);
|
|
368
|
+
_this.container = Object.create(null);
|
|
324
369
|
Object.defineProperty(_this, 'listener', {
|
|
325
370
|
value: new Listener,
|
|
326
371
|
writable: false,
|
|
327
372
|
configurable: false
|
|
328
373
|
});
|
|
329
374
|
for (var i in obj) {
|
|
330
|
-
Object.defineProperty(_this, i, {
|
|
375
|
+
Object.defineProperty(_this.container, i, {
|
|
331
376
|
value: obj[i],
|
|
332
377
|
configurable: true,
|
|
333
378
|
writable: true,
|
|
@@ -343,8 +388,7 @@ var ObjectModel = /** @class */ (function (_super) {
|
|
|
343
388
|
* @return {*}
|
|
344
389
|
*/
|
|
345
390
|
ObjectModel.prototype.get = function (key) {
|
|
346
|
-
|
|
347
|
-
return ts[key];
|
|
391
|
+
return this.container[key];
|
|
348
392
|
};
|
|
349
393
|
/**
|
|
350
394
|
* Sets an object property value
|
|
@@ -353,21 +397,19 @@ var ObjectModel = /** @class */ (function (_super) {
|
|
|
353
397
|
* @return {ObjectModel} a pointer to this
|
|
354
398
|
*/
|
|
355
399
|
ObjectModel.prototype.set = function (key, v) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
this.listener.emitRemoved(key, ts[key]);
|
|
360
|
-
ts[key] = v;
|
|
400
|
+
if (Reflect.has(this.container, key)) {
|
|
401
|
+
this.listener.emitRemoved(key, this.container[key]);
|
|
402
|
+
this.container[key] = v;
|
|
361
403
|
}
|
|
362
404
|
else {
|
|
363
|
-
Object.defineProperty(
|
|
405
|
+
Object.defineProperty(this.container, key, {
|
|
364
406
|
value: v,
|
|
365
407
|
configurable: true,
|
|
366
408
|
writable: true,
|
|
367
409
|
enumerable: true
|
|
368
410
|
});
|
|
369
411
|
}
|
|
370
|
-
this.listener.emitAdded(key,
|
|
412
|
+
this.listener.emitAdded(key, this.container[key]);
|
|
371
413
|
return this;
|
|
372
414
|
};
|
|
373
415
|
/**
|
|
@@ -375,12 +417,28 @@ var ObjectModel = /** @class */ (function (_super) {
|
|
|
375
417
|
* @param key {string} property name
|
|
376
418
|
*/
|
|
377
419
|
ObjectModel.prototype.delete = function (key) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
this.
|
|
381
|
-
delete ts[key];
|
|
420
|
+
if (this.container[key]) {
|
|
421
|
+
this.listener.emitRemoved(key, this.container[key]);
|
|
422
|
+
delete this.container[key];
|
|
382
423
|
}
|
|
383
424
|
};
|
|
425
|
+
ObjectModel.prototype.proxy = function () {
|
|
426
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
427
|
+
var ts = this;
|
|
428
|
+
return new Proxy(this.container, {
|
|
429
|
+
get: function (target, p) {
|
|
430
|
+
return ts.get(p);
|
|
431
|
+
},
|
|
432
|
+
set: function (target, p, value) {
|
|
433
|
+
ts.set(p, value);
|
|
434
|
+
return true;
|
|
435
|
+
},
|
|
436
|
+
deleteProperty: function (target, p) {
|
|
437
|
+
ts.delete(p);
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
};
|
|
384
442
|
ObjectModel.prototype.enableReactivity = function () {
|
|
385
443
|
this.listener.enableReactivity();
|
|
386
444
|
};
|
|
@@ -564,6 +622,15 @@ var ArrayModel = /** @class */ (function (_super) {
|
|
|
564
622
|
}
|
|
565
623
|
return _this;
|
|
566
624
|
}
|
|
625
|
+
// proxy
|
|
626
|
+
ArrayModel.prototype.proxy = function () {
|
|
627
|
+
return new Proxy(this, {
|
|
628
|
+
set: function (target, p, value) {
|
|
629
|
+
target.splice(parseInt(p), 1, value);
|
|
630
|
+
return true;
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
};
|
|
567
634
|
Object.defineProperty(ArrayModel.prototype, "last", {
|
|
568
635
|
/* Array members */
|
|
569
636
|
/**
|
|
@@ -774,6 +841,287 @@ var ArrayModel = /** @class */ (function (_super) {
|
|
|
774
841
|
|
|
775
842
|
window.ArrayModel = ArrayModel;
|
|
776
843
|
|
|
844
|
+
// ./lib-es5/functional/merge.js
|
|
845
|
+
function merge(main) {
|
|
846
|
+
var targets = [];
|
|
847
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
848
|
+
targets[_i - 1] = arguments[_i];
|
|
849
|
+
}
|
|
850
|
+
function refactorClass(obj) {
|
|
851
|
+
if (Array.isArray(obj.class)) {
|
|
852
|
+
var out_1 = {
|
|
853
|
+
$: []
|
|
854
|
+
};
|
|
855
|
+
obj.class.forEach(function (item) {
|
|
856
|
+
if (item instanceof IValue) {
|
|
857
|
+
out_1.$.push(item);
|
|
858
|
+
}
|
|
859
|
+
else if (typeof item === 'string') {
|
|
860
|
+
out_1[item] = true;
|
|
861
|
+
}
|
|
862
|
+
else if (typeof item === 'object') {
|
|
863
|
+
Object.assign(out_1, item);
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
obj.class = out_1;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
refactorClass(main);
|
|
870
|
+
targets.forEach(function (target) {
|
|
871
|
+
Reflect.ownKeys(target).forEach(function (prop) {
|
|
872
|
+
var _a;
|
|
873
|
+
if (!Reflect.has(main, prop)) {
|
|
874
|
+
main[prop] = target[prop];
|
|
875
|
+
}
|
|
876
|
+
else if (typeof main[prop] === 'object' && typeof target[prop] === 'object') {
|
|
877
|
+
if (prop === 'class') {
|
|
878
|
+
refactorClass(target);
|
|
879
|
+
}
|
|
880
|
+
if (prop === '$' && Array.isArray(main[prop]) && Array.isArray(target[prop])) {
|
|
881
|
+
(_a = main.$).push.apply(_a, target.$);
|
|
882
|
+
}
|
|
883
|
+
else {
|
|
884
|
+
merge(main[prop], target[prop]);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
window.merge = merge;
|
|
892
|
+
|
|
893
|
+
// ./lib-es5/functional/stack.js
|
|
894
|
+
function app(renderer) {
|
|
895
|
+
return function (node, opts) {
|
|
896
|
+
return new App(node, opts).runFunctional(renderer, opts);
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
function component(renderer) {
|
|
900
|
+
return function (opts, callback) {
|
|
901
|
+
var component = new Component(opts);
|
|
902
|
+
if (!(current instanceof Fragment))
|
|
903
|
+
throw userError('missing parent node', 'out-of-context');
|
|
904
|
+
var ret;
|
|
905
|
+
if (callback)
|
|
906
|
+
opts.slot = callback;
|
|
907
|
+
current.create(component, function (node) {
|
|
908
|
+
ret = node.runFunctional(renderer, opts);
|
|
909
|
+
});
|
|
910
|
+
return ret;
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function fragment(renderer) {
|
|
914
|
+
return function (opts, callback) {
|
|
915
|
+
var frag = new Fragment(opts);
|
|
916
|
+
if (!(current instanceof Fragment))
|
|
917
|
+
throw userError('missing parent node', 'out-of-context');
|
|
918
|
+
if (callback)
|
|
919
|
+
opts.slot = callback;
|
|
920
|
+
current.create(frag);
|
|
921
|
+
return frag.runFunctional(renderer, opts);
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
function extension(renderer) {
|
|
925
|
+
return function (opts, callback) {
|
|
926
|
+
var ext = new Extension(opts);
|
|
927
|
+
if (!(current instanceof Fragment))
|
|
928
|
+
throw userError('missing parent node', 'out-of-context');
|
|
929
|
+
if (callback)
|
|
930
|
+
opts.slot = callback;
|
|
931
|
+
current.create(ext);
|
|
932
|
+
return ext.runFunctional(renderer, opts);
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
function tag(name, opts, callback) {
|
|
936
|
+
if (!(current instanceof Fragment))
|
|
937
|
+
throw userError('missing parent node', 'out-of-context');
|
|
938
|
+
return {
|
|
939
|
+
node: current.tag(name, opts, function (node) {
|
|
940
|
+
callback && node.runFunctional(callback);
|
|
941
|
+
})
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
function create(node, callback) {
|
|
945
|
+
if (!(current instanceof Fragment))
|
|
946
|
+
throw userError('missing current node', 'out-of-context');
|
|
947
|
+
current.create(node, function (node) {
|
|
948
|
+
var args = [];
|
|
949
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
950
|
+
args[_i - 1] = arguments[_i];
|
|
951
|
+
}
|
|
952
|
+
callback && node.runFunctional.apply(node, __spreadArray([callback], args, false));
|
|
953
|
+
});
|
|
954
|
+
return node;
|
|
955
|
+
}
|
|
956
|
+
var vx = {
|
|
957
|
+
if: function (condition, callback) {
|
|
958
|
+
if (current instanceof Fragment) {
|
|
959
|
+
current.if(condition, function (node) { return node.runFunctional(callback); });
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
throw userError("wrong use of `v.if` function", "logic-error");
|
|
963
|
+
}
|
|
964
|
+
},
|
|
965
|
+
else: function (callback) {
|
|
966
|
+
if (current instanceof Fragment) {
|
|
967
|
+
current.else(function (node) { return node.runFunctional(callback); });
|
|
968
|
+
}
|
|
969
|
+
else {
|
|
970
|
+
throw userError("wrong use of `v.else` function", "logic-error");
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
elif: function (condition, callback) {
|
|
974
|
+
if (current instanceof Fragment) {
|
|
975
|
+
current.elif(condition, function (node) { return node.runFunctional(callback); });
|
|
976
|
+
}
|
|
977
|
+
else {
|
|
978
|
+
throw userError("wrong use of `v.elif` function", "logic-error");
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
for: function (model, callback) {
|
|
982
|
+
if (model instanceof ArrayModel) {
|
|
983
|
+
// for arrays T & K are the same type
|
|
984
|
+
create(new ArrayView({ model: model }), callback);
|
|
985
|
+
}
|
|
986
|
+
else if (model instanceof MapModel) {
|
|
987
|
+
create(new MapView({ model: model }), callback);
|
|
988
|
+
}
|
|
989
|
+
else if (model instanceof SetModel) {
|
|
990
|
+
// for sets T & K are the same type
|
|
991
|
+
create(new SetView({ model: model }), callback);
|
|
992
|
+
}
|
|
993
|
+
else if (model instanceof ObjectModel) {
|
|
994
|
+
// for objects K is always string
|
|
995
|
+
create(new ObjectView({ model: model }), callback);
|
|
996
|
+
}
|
|
997
|
+
else {
|
|
998
|
+
throw userError("wrong use of `v.for` function", 'wrong-model');
|
|
999
|
+
}
|
|
1000
|
+
},
|
|
1001
|
+
watch: function (model, callback) {
|
|
1002
|
+
var opts = { model: model };
|
|
1003
|
+
create(new Watch(opts), callback);
|
|
1004
|
+
},
|
|
1005
|
+
nextTick: function (callback) {
|
|
1006
|
+
var node = current;
|
|
1007
|
+
window.setTimeout(function () {
|
|
1008
|
+
node.runFunctional(callback);
|
|
1009
|
+
}, 0);
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
window.app = app;
|
|
1014
|
+
window.component = component;
|
|
1015
|
+
window.fragment = fragment;
|
|
1016
|
+
window.extension = extension;
|
|
1017
|
+
window.tag = tag;
|
|
1018
|
+
window.create = create;
|
|
1019
|
+
window.vx = vx;
|
|
1020
|
+
|
|
1021
|
+
// ./lib-es5/functional/models.js
|
|
1022
|
+
function arrayModel(arr) {
|
|
1023
|
+
if (arr === void 0) { arr = []; }
|
|
1024
|
+
if (!current)
|
|
1025
|
+
throw userError('missing parent node', 'out-of-context');
|
|
1026
|
+
return current.register(new ArrayModel(arr)).proxy();
|
|
1027
|
+
}
|
|
1028
|
+
function mapModel(map) {
|
|
1029
|
+
if (map === void 0) { map = []; }
|
|
1030
|
+
if (!current)
|
|
1031
|
+
throw userError('missing parent node', 'out-of-context');
|
|
1032
|
+
return current.register(new MapModel(map));
|
|
1033
|
+
}
|
|
1034
|
+
function setModel(arr) {
|
|
1035
|
+
if (arr === void 0) { arr = []; }
|
|
1036
|
+
if (!current)
|
|
1037
|
+
throw userError('missing parent node', 'out-of-context');
|
|
1038
|
+
return current.register(new SetModel(arr));
|
|
1039
|
+
}
|
|
1040
|
+
function objectModel(obj) {
|
|
1041
|
+
if (obj === void 0) { obj = {}; }
|
|
1042
|
+
if (!current)
|
|
1043
|
+
throw userError('missing parent node', 'out-of-context');
|
|
1044
|
+
return current.register(new ObjectModel(obj));
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
window.arrayModel = arrayModel;
|
|
1048
|
+
window.mapModel = mapModel;
|
|
1049
|
+
window.setModel = setModel;
|
|
1050
|
+
window.objectModel = objectModel;
|
|
1051
|
+
|
|
1052
|
+
// ./lib-es5/functional/options.js
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
// ./lib-es5/functional/reactivity.js
|
|
1057
|
+
function ref(value) {
|
|
1058
|
+
var ref = current.ref(value);
|
|
1059
|
+
return [ref, function (value) { return ref.$ = value; }];
|
|
1060
|
+
}
|
|
1061
|
+
function mirror(value) {
|
|
1062
|
+
return current.mirror(value);
|
|
1063
|
+
}
|
|
1064
|
+
function forward(value) {
|
|
1065
|
+
return current.forward(value);
|
|
1066
|
+
}
|
|
1067
|
+
function point(value) {
|
|
1068
|
+
return current.point(value);
|
|
1069
|
+
}
|
|
1070
|
+
function expr(func) {
|
|
1071
|
+
var values = [];
|
|
1072
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1073
|
+
values[_i - 1] = arguments[_i];
|
|
1074
|
+
}
|
|
1075
|
+
return current.expr.apply(current, __spreadArray([func], values, false));
|
|
1076
|
+
}
|
|
1077
|
+
function watch(func) {
|
|
1078
|
+
var values = [];
|
|
1079
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1080
|
+
values[_i - 1] = arguments[_i];
|
|
1081
|
+
}
|
|
1082
|
+
current.watch.apply(current, __spreadArray([func], values, false));
|
|
1083
|
+
}
|
|
1084
|
+
function valueOf(value) {
|
|
1085
|
+
return value.$;
|
|
1086
|
+
}
|
|
1087
|
+
function setValue(ref, value) {
|
|
1088
|
+
if (ref instanceof Pointer && value instanceof IValue) {
|
|
1089
|
+
ref.point(value);
|
|
1090
|
+
}
|
|
1091
|
+
else {
|
|
1092
|
+
ref.$ = value instanceof IValue ? value.$ : value;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
window.ref = ref;
|
|
1097
|
+
window.mirror = mirror;
|
|
1098
|
+
window.forward = forward;
|
|
1099
|
+
window.point = point;
|
|
1100
|
+
window.expr = expr;
|
|
1101
|
+
window.watch = watch;
|
|
1102
|
+
window.valueOf = valueOf;
|
|
1103
|
+
window.setValue = setValue;
|
|
1104
|
+
|
|
1105
|
+
// ./lib-es5/functional/components.js
|
|
1106
|
+
function text(text) {
|
|
1107
|
+
if (!(current instanceof Fragment))
|
|
1108
|
+
throw userError('missing parent node', 'out-of-context');
|
|
1109
|
+
;
|
|
1110
|
+
current.text(text);
|
|
1111
|
+
}
|
|
1112
|
+
function debug(text) {
|
|
1113
|
+
if (!(current instanceof Fragment))
|
|
1114
|
+
throw userError('missing parent node', 'out-of-context');
|
|
1115
|
+
current.debug(text);
|
|
1116
|
+
}
|
|
1117
|
+
function predefine(slot, predefined) {
|
|
1118
|
+
return slot || predefined;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
window.text = text;
|
|
1122
|
+
window.debug = debug;
|
|
1123
|
+
window.predefine = predefine;
|
|
1124
|
+
|
|
777
1125
|
// ./lib-es5/core/signal.js
|
|
778
1126
|
/**
|
|
779
1127
|
* Signal is an event generator
|
|
@@ -1104,7 +1452,7 @@ var Destroyable = /** @class */ (function () {
|
|
|
1104
1452
|
* Make object fields non configurable
|
|
1105
1453
|
* @protected
|
|
1106
1454
|
*/
|
|
1107
|
-
Destroyable.prototype
|
|
1455
|
+
Destroyable.prototype.seal = function () {
|
|
1108
1456
|
var _this = this;
|
|
1109
1457
|
var $ = this;
|
|
1110
1458
|
Object.keys($).forEach(function (i) {
|
|
@@ -1137,7 +1485,7 @@ var Destroyable = /** @class */ (function () {
|
|
|
1137
1485
|
/**
|
|
1138
1486
|
* Garbage collector method
|
|
1139
1487
|
*/
|
|
1140
|
-
Destroyable.prototype
|
|
1488
|
+
Destroyable.prototype.destroy = function () {
|
|
1141
1489
|
// nothing here
|
|
1142
1490
|
};
|
|
1143
1491
|
return Destroyable;
|
|
@@ -1147,6 +1495,26 @@ var Destroyable = /** @class */ (function () {
|
|
|
1147
1495
|
window.Destroyable = Destroyable;
|
|
1148
1496
|
|
|
1149
1497
|
// ./lib-es5/core/ivalue.js
|
|
1498
|
+
var Switchable = /** @class */ (function (_super) {
|
|
1499
|
+
__extends(Switchable, _super);
|
|
1500
|
+
function Switchable() {
|
|
1501
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Enable update handlers triggering
|
|
1505
|
+
*/
|
|
1506
|
+
Switchable.prototype.enable = function () {
|
|
1507
|
+
throw notOverwritten();
|
|
1508
|
+
};
|
|
1509
|
+
/**
|
|
1510
|
+
* disable update handlers triggering
|
|
1511
|
+
*/
|
|
1512
|
+
Switchable.prototype.disable = function () {
|
|
1513
|
+
throw notOverwritten();
|
|
1514
|
+
};
|
|
1515
|
+
return Switchable;
|
|
1516
|
+
}(Destroyable));
|
|
1517
|
+
|
|
1150
1518
|
/**
|
|
1151
1519
|
* Interface which describes a value
|
|
1152
1520
|
* @class IValue
|
|
@@ -1194,28 +1562,29 @@ var IValue = /** @class */ (function (_super) {
|
|
|
1194
1562
|
IValue.prototype.off = function (handler) {
|
|
1195
1563
|
throw notOverwritten();
|
|
1196
1564
|
};
|
|
1197
|
-
/**
|
|
1198
|
-
* Enable update handlers triggering
|
|
1199
|
-
*/
|
|
1200
|
-
IValue.prototype.enable = function () {
|
|
1201
|
-
throw notOverwritten();
|
|
1202
|
-
};
|
|
1203
|
-
/**
|
|
1204
|
-
* disable update handlers triggering
|
|
1205
|
-
*/
|
|
1206
|
-
IValue.prototype.disable = function () {
|
|
1207
|
-
throw notOverwritten();
|
|
1208
|
-
};
|
|
1209
1565
|
return IValue;
|
|
1210
|
-
}(
|
|
1566
|
+
}(Switchable));
|
|
1211
1567
|
|
|
1212
1568
|
|
|
1569
|
+
window.Switchable = Switchable;
|
|
1213
1570
|
window.IValue = IValue;
|
|
1214
1571
|
|
|
1215
1572
|
// ./lib-es5/index.js
|
|
1216
1573
|
|
|
1217
1574
|
|
|
1218
1575
|
|
|
1576
|
+
// ./lib-es5/spec/svg.js
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
// ./lib-es5/spec/react.js
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
|
|
1584
|
+
// ./lib-es5/spec/html.js
|
|
1585
|
+
|
|
1586
|
+
|
|
1587
|
+
|
|
1219
1588
|
// ./lib-es5/value/expression.js
|
|
1220
1589
|
/**
|
|
1221
1590
|
* Bind some values to one expression
|
|
@@ -1224,13 +1593,22 @@ window.IValue = IValue;
|
|
|
1224
1593
|
*/
|
|
1225
1594
|
var Expression = /** @class */ (function (_super) {
|
|
1226
1595
|
__extends(Expression, _super);
|
|
1227
|
-
|
|
1596
|
+
/**
|
|
1597
|
+
* Creates a function bounded to N values
|
|
1598
|
+
* @param func {Function} the function to bound
|
|
1599
|
+
* @param values
|
|
1600
|
+
* @param link {Boolean} links immediately if true
|
|
1601
|
+
*/
|
|
1602
|
+
function Expression(func, link) {
|
|
1603
|
+
var values = [];
|
|
1604
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1605
|
+
values[_i - 2] = arguments[_i];
|
|
1606
|
+
}
|
|
1228
1607
|
var _this = _super.call(this, false) || this;
|
|
1229
1608
|
/**
|
|
1230
1609
|
* Expression will link different handler for each value of list
|
|
1231
1610
|
*/
|
|
1232
1611
|
_this.linkedFunc = [];
|
|
1233
|
-
var values = [v1, v2, v3, v4, v5, v6, v7, v8, v9].filter(function (v) { return v instanceof IValue; });
|
|
1234
1612
|
var handler = function (i) {
|
|
1235
1613
|
if (i != null) {
|
|
1236
1614
|
_this.valuesCache[i] = _this.values[i].$;
|
|
@@ -1239,14 +1617,12 @@ var Expression = /** @class */ (function (_super) {
|
|
|
1239
1617
|
};
|
|
1240
1618
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1241
1619
|
// @ts-ignore
|
|
1242
|
-
_this.valuesCache = values.map(function (
|
|
1620
|
+
_this.valuesCache = values.map(function (item) { return item.$; });
|
|
1243
1621
|
_this.sync = new Reference(func.apply(_this, _this.valuesCache));
|
|
1244
1622
|
var i = 0;
|
|
1245
1623
|
values.forEach(function () {
|
|
1246
1624
|
_this.linkedFunc.push(handler.bind(_this, Number(i++)));
|
|
1247
1625
|
});
|
|
1248
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1249
|
-
// @ts-ignore
|
|
1250
1626
|
_this.values = values;
|
|
1251
1627
|
_this.func = handler;
|
|
1252
1628
|
if (link) {
|
|
@@ -1255,7 +1631,7 @@ var Expression = /** @class */ (function (_super) {
|
|
|
1255
1631
|
else {
|
|
1256
1632
|
handler();
|
|
1257
1633
|
}
|
|
1258
|
-
_this
|
|
1634
|
+
_this.seal();
|
|
1259
1635
|
return _this;
|
|
1260
1636
|
}
|
|
1261
1637
|
Object.defineProperty(Expression.prototype, "$", {
|
|
@@ -1296,12 +1672,12 @@ var Expression = /** @class */ (function (_super) {
|
|
|
1296
1672
|
}
|
|
1297
1673
|
return this;
|
|
1298
1674
|
};
|
|
1299
|
-
Expression.prototype
|
|
1675
|
+
Expression.prototype.destroy = function () {
|
|
1300
1676
|
this.disable();
|
|
1301
1677
|
this.values.splice(0);
|
|
1302
1678
|
this.valuesCache.splice(0);
|
|
1303
1679
|
this.linkedFunc.splice(0);
|
|
1304
|
-
_super.prototype
|
|
1680
|
+
_super.prototype.destroy.call(this);
|
|
1305
1681
|
};
|
|
1306
1682
|
return Expression;
|
|
1307
1683
|
}(IValue));
|
|
@@ -1324,7 +1700,7 @@ var Reference = /** @class */ (function (_super) {
|
|
|
1324
1700
|
var _this = _super.call(this, true) || this;
|
|
1325
1701
|
_this.value = value;
|
|
1326
1702
|
_this.onchange = new Set;
|
|
1327
|
-
_this
|
|
1703
|
+
_this.seal();
|
|
1328
1704
|
return _this;
|
|
1329
1705
|
}
|
|
1330
1706
|
Object.defineProperty(Reference.prototype, "$", {
|
|
@@ -1352,22 +1728,18 @@ var Reference = /** @class */ (function (_super) {
|
|
|
1352
1728
|
});
|
|
1353
1729
|
this.isEnabled = true;
|
|
1354
1730
|
}
|
|
1355
|
-
return this;
|
|
1356
1731
|
};
|
|
1357
1732
|
Reference.prototype.disable = function () {
|
|
1358
1733
|
this.isEnabled = false;
|
|
1359
|
-
return this;
|
|
1360
1734
|
};
|
|
1361
1735
|
Reference.prototype.on = function (handler) {
|
|
1362
1736
|
this.onchange.add(handler);
|
|
1363
|
-
return this;
|
|
1364
1737
|
};
|
|
1365
1738
|
Reference.prototype.off = function (handler) {
|
|
1366
1739
|
this.onchange.delete(handler);
|
|
1367
|
-
return this;
|
|
1368
1740
|
};
|
|
1369
|
-
Reference.prototype
|
|
1370
|
-
_super.prototype
|
|
1741
|
+
Reference.prototype.destroy = function () {
|
|
1742
|
+
_super.prototype.destroy.call(this);
|
|
1371
1743
|
this.onchange.clear();
|
|
1372
1744
|
};
|
|
1373
1745
|
return Reference;
|
|
@@ -1399,7 +1771,7 @@ var Mirror = /** @class */ (function (_super) {
|
|
|
1399
1771
|
_this.pointedValue = value;
|
|
1400
1772
|
_this.forwardOnly = forwardOnly;
|
|
1401
1773
|
value.on(_this.handler);
|
|
1402
|
-
_this
|
|
1774
|
+
_this.seal();
|
|
1403
1775
|
return _this;
|
|
1404
1776
|
}
|
|
1405
1777
|
Object.defineProperty(Mirror.prototype, "$", {
|
|
@@ -1410,13 +1782,13 @@ var Mirror = /** @class */ (function (_super) {
|
|
|
1410
1782
|
return _super.prototype.$;
|
|
1411
1783
|
},
|
|
1412
1784
|
set: function (v) {
|
|
1785
|
+
if (!this.forwardOnly) {
|
|
1786
|
+
this.pointedValue.$ = v;
|
|
1787
|
+
}
|
|
1413
1788
|
// this is a ts bug
|
|
1414
1789
|
// eslint-disable-next-line
|
|
1415
1790
|
// @ts-ignore
|
|
1416
1791
|
_super.prototype.$ = v;
|
|
1417
|
-
if (!this.forwardOnly) {
|
|
1418
|
-
this.pointedValue.$ = v;
|
|
1419
|
-
}
|
|
1420
1792
|
},
|
|
1421
1793
|
enumerable: false,
|
|
1422
1794
|
configurable: true
|
|
@@ -1427,18 +1799,16 @@ var Mirror = /** @class */ (function (_super) {
|
|
|
1427
1799
|
this.pointedValue.on(this.handler);
|
|
1428
1800
|
this.$ = this.pointedValue.$;
|
|
1429
1801
|
}
|
|
1430
|
-
return this;
|
|
1431
1802
|
};
|
|
1432
1803
|
Mirror.prototype.disable = function () {
|
|
1433
1804
|
if (this.isEnabled) {
|
|
1434
1805
|
this.pointedValue.off(this.handler);
|
|
1435
1806
|
this.isEnabled = false;
|
|
1436
1807
|
}
|
|
1437
|
-
return this;
|
|
1438
1808
|
};
|
|
1439
|
-
Mirror.prototype
|
|
1809
|
+
Mirror.prototype.destroy = function () {
|
|
1440
1810
|
this.disable();
|
|
1441
|
-
_super.prototype
|
|
1811
|
+
_super.prototype.destroy.call(this);
|
|
1442
1812
|
};
|
|
1443
1813
|
return Mirror;
|
|
1444
1814
|
}(Reference));
|
|
@@ -1489,34 +1859,25 @@ var Binding = /** @class */ (function (_super) {
|
|
|
1489
1859
|
__extends(Binding, _super);
|
|
1490
1860
|
/**
|
|
1491
1861
|
* Constructs a common binding logic
|
|
1492
|
-
* @param node {INode} the vasille node
|
|
1493
|
-
* @param name {String} the name of property/attribute/class
|
|
1494
1862
|
* @param value {IValue} the value to bind
|
|
1495
1863
|
*/
|
|
1496
|
-
function Binding(
|
|
1864
|
+
function Binding(value) {
|
|
1497
1865
|
var _this = this; _super.call(this);
|
|
1498
|
-
_this.updateFunc = _this.bound(name).bind(null, node);
|
|
1499
1866
|
_this.binding = value;
|
|
1500
|
-
_this.
|
|
1501
|
-
_this.updateFunc(_this.binding.$);
|
|
1502
|
-
_this.$seal();
|
|
1867
|
+
_this.seal();
|
|
1503
1868
|
return _this;
|
|
1504
1869
|
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
* @throws Always throws and must be overloaded in child class
|
|
1510
|
-
*/
|
|
1511
|
-
Binding.prototype.bound = function (name) {
|
|
1512
|
-
throw notOverwritten();
|
|
1870
|
+
Binding.prototype.init = function (bounded) {
|
|
1871
|
+
this.func = bounded;
|
|
1872
|
+
this.binding.on(this.func);
|
|
1873
|
+
this.func(this.binding.$);
|
|
1513
1874
|
};
|
|
1514
1875
|
/**
|
|
1515
1876
|
* Just clear bindings
|
|
1516
1877
|
*/
|
|
1517
|
-
Binding.prototype
|
|
1518
|
-
this.binding.off(this.
|
|
1519
|
-
_super.prototype
|
|
1878
|
+
Binding.prototype.destroy = function () {
|
|
1879
|
+
this.binding.off(this.func);
|
|
1880
|
+
_super.prototype.destroy.call(this);
|
|
1520
1881
|
};
|
|
1521
1882
|
return Binding;
|
|
1522
1883
|
}(Destroyable));
|
|
@@ -1525,6 +1886,15 @@ var Binding = /** @class */ (function (_super) {
|
|
|
1525
1886
|
window.Binding = Binding;
|
|
1526
1887
|
|
|
1527
1888
|
// ./lib-es5/core/core.js
|
|
1889
|
+
var current = null;
|
|
1890
|
+
var currentStack = [];
|
|
1891
|
+
function stack(node) {
|
|
1892
|
+
currentStack.push(current);
|
|
1893
|
+
current = node;
|
|
1894
|
+
}
|
|
1895
|
+
function unstack() {
|
|
1896
|
+
current = currentStack.pop();
|
|
1897
|
+
}
|
|
1528
1898
|
/**
|
|
1529
1899
|
* Private stuff of a reactive object
|
|
1530
1900
|
* @class ReactivePrivate
|
|
@@ -1558,17 +1928,19 @@ var ReactivePrivate = /** @class */ (function (_super) {
|
|
|
1558
1928
|
* @type {boolean}
|
|
1559
1929
|
*/
|
|
1560
1930
|
_this.frozen = false;
|
|
1561
|
-
_this
|
|
1931
|
+
_this.seal();
|
|
1562
1932
|
return _this;
|
|
1563
1933
|
}
|
|
1564
|
-
ReactivePrivate.prototype
|
|
1565
|
-
|
|
1566
|
-
this.watch.forEach(function (value) { return value.$destroy(); });
|
|
1934
|
+
ReactivePrivate.prototype.destroy = function () {
|
|
1935
|
+
this.watch.forEach(function (value) { return value.destroy(); });
|
|
1567
1936
|
this.watch.clear();
|
|
1568
|
-
this.bindings.forEach(function (binding) { return binding
|
|
1937
|
+
this.bindings.forEach(function (binding) { return binding.destroy(); });
|
|
1569
1938
|
this.bindings.clear();
|
|
1570
|
-
(
|
|
1571
|
-
|
|
1939
|
+
this.models.forEach(function (model) { return model.disableReactivity(); });
|
|
1940
|
+
this.models.clear();
|
|
1941
|
+
this.freezeExpr && this.freezeExpr.destroy();
|
|
1942
|
+
this.onDestroy && this.onDestroy();
|
|
1943
|
+
_super.prototype.destroy.call(this);
|
|
1572
1944
|
};
|
|
1573
1945
|
return ReactivePrivate;
|
|
1574
1946
|
}(Destroyable));
|
|
@@ -1580,16 +1952,28 @@ var ReactivePrivate = /** @class */ (function (_super) {
|
|
|
1580
1952
|
*/
|
|
1581
1953
|
var Reactive = /** @class */ (function (_super) {
|
|
1582
1954
|
__extends(Reactive, _super);
|
|
1583
|
-
function Reactive($) {
|
|
1955
|
+
function Reactive(input, $) {
|
|
1584
1956
|
var _this = this; _super.call(this);
|
|
1957
|
+
_this.input = input;
|
|
1585
1958
|
_this.$ = $ || new ReactivePrivate;
|
|
1959
|
+
_this.seal();
|
|
1586
1960
|
return _this;
|
|
1587
1961
|
}
|
|
1962
|
+
Object.defineProperty(Reactive.prototype, "parent", {
|
|
1963
|
+
/**
|
|
1964
|
+
* Get parent node
|
|
1965
|
+
*/
|
|
1966
|
+
get: function () {
|
|
1967
|
+
return this.$.parent;
|
|
1968
|
+
},
|
|
1969
|
+
enumerable: false,
|
|
1970
|
+
configurable: true
|
|
1971
|
+
});
|
|
1588
1972
|
/**
|
|
1589
1973
|
* Create a reference
|
|
1590
1974
|
* @param value {*} value to reference
|
|
1591
1975
|
*/
|
|
1592
|
-
Reactive.prototype
|
|
1976
|
+
Reactive.prototype.ref = function (value) {
|
|
1593
1977
|
var $ = this.$;
|
|
1594
1978
|
var ref = new Reference(value);
|
|
1595
1979
|
$.watch.add(ref);
|
|
@@ -1599,7 +1983,7 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1599
1983
|
* Create a mirror
|
|
1600
1984
|
* @param value {IValue} value to mirror
|
|
1601
1985
|
*/
|
|
1602
|
-
Reactive.prototype
|
|
1986
|
+
Reactive.prototype.mirror = function (value) {
|
|
1603
1987
|
var mirror = new Mirror(value, false);
|
|
1604
1988
|
this.$.watch.add(mirror);
|
|
1605
1989
|
return mirror;
|
|
@@ -1608,7 +1992,7 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1608
1992
|
* Create a forward-only mirror
|
|
1609
1993
|
* @param value {IValue} value to mirror
|
|
1610
1994
|
*/
|
|
1611
|
-
Reactive.prototype
|
|
1995
|
+
Reactive.prototype.forward = function (value) {
|
|
1612
1996
|
var mirror = new Mirror(value, true);
|
|
1613
1997
|
this.$.watch.add(mirror);
|
|
1614
1998
|
return mirror;
|
|
@@ -1618,15 +2002,10 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1618
2002
|
* @param value {*} default value to point
|
|
1619
2003
|
* @param forwardOnly {boolean} forward only sync
|
|
1620
2004
|
*/
|
|
1621
|
-
Reactive.prototype
|
|
2005
|
+
Reactive.prototype.point = function (value, forwardOnly) {
|
|
1622
2006
|
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
1623
2007
|
var $ = this.$;
|
|
1624
|
-
var
|
|
1625
|
-
var pointer = new Pointer(ref, forwardOnly);
|
|
1626
|
-
// when value is an ivalue will be equal to ref
|
|
1627
|
-
if (value !== ref) {
|
|
1628
|
-
$.watch.add(ref);
|
|
1629
|
-
}
|
|
2008
|
+
var pointer = new Pointer(value, forwardOnly);
|
|
1630
2009
|
$.watch.add(pointer);
|
|
1631
2010
|
return pointer;
|
|
1632
2011
|
};
|
|
@@ -1634,16 +2013,35 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1634
2013
|
* Register a model
|
|
1635
2014
|
* @param model
|
|
1636
2015
|
*/
|
|
1637
|
-
Reactive.prototype
|
|
2016
|
+
Reactive.prototype.register = function (model) {
|
|
1638
2017
|
this.$.models.add(model);
|
|
1639
2018
|
return model;
|
|
1640
2019
|
};
|
|
1641
|
-
|
|
2020
|
+
/**
|
|
2021
|
+
* Creates a watcher
|
|
2022
|
+
* @param func {function} function to run on any argument change
|
|
2023
|
+
* @param values
|
|
2024
|
+
*/
|
|
2025
|
+
Reactive.prototype.watch = function (func) {
|
|
2026
|
+
var values = [];
|
|
2027
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2028
|
+
values[_i - 1] = arguments[_i];
|
|
2029
|
+
}
|
|
1642
2030
|
var $ = this.$;
|
|
1643
|
-
$.watch.add(new Expression(func, !this.$.frozen,
|
|
2031
|
+
$.watch.add(new (Expression.bind.apply(Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))());
|
|
1644
2032
|
};
|
|
1645
|
-
|
|
1646
|
-
|
|
2033
|
+
/**
|
|
2034
|
+
* Creates a computed value
|
|
2035
|
+
* @param func {function} function to run on any argument change
|
|
2036
|
+
* @param values
|
|
2037
|
+
* @return {IValue} the created ivalue
|
|
2038
|
+
*/
|
|
2039
|
+
Reactive.prototype.expr = function (func) {
|
|
2040
|
+
var values = [];
|
|
2041
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2042
|
+
values[_i - 1] = arguments[_i];
|
|
2043
|
+
}
|
|
2044
|
+
var res = new (Expression.bind.apply(Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))();
|
|
1647
2045
|
var $ = this.$;
|
|
1648
2046
|
$.watch.add(res);
|
|
1649
2047
|
return res;
|
|
@@ -1651,7 +2049,7 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1651
2049
|
/**
|
|
1652
2050
|
* Enable reactivity of fields
|
|
1653
2051
|
*/
|
|
1654
|
-
Reactive.prototype
|
|
2052
|
+
Reactive.prototype.enable = function () {
|
|
1655
2053
|
var $ = this.$;
|
|
1656
2054
|
if (!$.enabled) {
|
|
1657
2055
|
$.watch.forEach(function (watcher) {
|
|
@@ -1666,7 +2064,7 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1666
2064
|
/**
|
|
1667
2065
|
* Disable reactivity of fields
|
|
1668
2066
|
*/
|
|
1669
|
-
Reactive.prototype
|
|
2067
|
+
Reactive.prototype.disable = function () {
|
|
1670
2068
|
var $ = this.$;
|
|
1671
2069
|
if ($.enabled) {
|
|
1672
2070
|
$.watch.forEach(function (watcher) {
|
|
@@ -1684,7 +2082,7 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1684
2082
|
* @param onOff {function} on show feedback
|
|
1685
2083
|
* @param onOn {function} on hide feedback
|
|
1686
2084
|
*/
|
|
1687
|
-
Reactive.prototype
|
|
2085
|
+
Reactive.prototype.bindAlive = function (cond, onOff, onOn) {
|
|
1688
2086
|
var _this = this;
|
|
1689
2087
|
var $ = this.$;
|
|
1690
2088
|
if ($.freezeExpr) {
|
|
@@ -1697,24 +2095,51 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1697
2095
|
$.frozen = !cond;
|
|
1698
2096
|
if (cond) {
|
|
1699
2097
|
onOn === null || onOn === void 0 ? void 0 : onOn();
|
|
1700
|
-
_this
|
|
2098
|
+
_this.enable();
|
|
1701
2099
|
}
|
|
1702
2100
|
else {
|
|
1703
2101
|
onOff === null || onOff === void 0 ? void 0 : onOff();
|
|
1704
|
-
_this
|
|
2102
|
+
_this.disable();
|
|
1705
2103
|
}
|
|
1706
2104
|
}, true, cond);
|
|
1707
2105
|
return this;
|
|
1708
2106
|
};
|
|
1709
|
-
Reactive.prototype
|
|
1710
|
-
|
|
1711
|
-
this
|
|
2107
|
+
Reactive.prototype.init = function () {
|
|
2108
|
+
this.applyOptions(this.input);
|
|
2109
|
+
this.compose(this.input);
|
|
2110
|
+
};
|
|
2111
|
+
Reactive.prototype.applyOptions = function (input) {
|
|
2112
|
+
// empty
|
|
2113
|
+
};
|
|
2114
|
+
Reactive.prototype.compose = function (input) {
|
|
2115
|
+
// empty
|
|
2116
|
+
};
|
|
2117
|
+
Reactive.prototype.runFunctional = function (f) {
|
|
2118
|
+
var args = [];
|
|
2119
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2120
|
+
args[_i - 1] = arguments[_i];
|
|
2121
|
+
}
|
|
2122
|
+
stack(this);
|
|
2123
|
+
// yet another ts bug
|
|
2124
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2125
|
+
// @ts-ignore
|
|
2126
|
+
var result = f.apply(void 0, args);
|
|
2127
|
+
unstack();
|
|
2128
|
+
return result;
|
|
2129
|
+
};
|
|
2130
|
+
Reactive.prototype.runOnDestroy = function (func) {
|
|
2131
|
+
this.$.onDestroy = func;
|
|
2132
|
+
};
|
|
2133
|
+
Reactive.prototype.destroy = function () {
|
|
2134
|
+
_super.prototype.destroy.call(this);
|
|
2135
|
+
this.$.destroy();
|
|
1712
2136
|
this.$ = null;
|
|
1713
2137
|
};
|
|
1714
2138
|
return Reactive;
|
|
1715
2139
|
}(Destroyable));
|
|
1716
2140
|
|
|
1717
2141
|
|
|
2142
|
+
window.current = current;
|
|
1718
2143
|
window.ReactivePrivate = ReactivePrivate;
|
|
1719
2144
|
window.Reactive = Reactive;
|
|
1720
2145
|
|
|
@@ -1728,7 +2153,7 @@ var FragmentPrivate = /** @class */ (function (_super) {
|
|
|
1728
2153
|
__extends(FragmentPrivate, _super);
|
|
1729
2154
|
function FragmentPrivate() {
|
|
1730
2155
|
var _this = this; _super.call(this);
|
|
1731
|
-
_this
|
|
2156
|
+
_this.seal();
|
|
1732
2157
|
return _this;
|
|
1733
2158
|
}
|
|
1734
2159
|
/**
|
|
@@ -1743,10 +2168,10 @@ var FragmentPrivate = /** @class */ (function (_super) {
|
|
|
1743
2168
|
/**
|
|
1744
2169
|
* Unlinks all bindings
|
|
1745
2170
|
*/
|
|
1746
|
-
FragmentPrivate.prototype
|
|
2171
|
+
FragmentPrivate.prototype.destroy = function () {
|
|
1747
2172
|
this.next = null;
|
|
1748
2173
|
this.prev = null;
|
|
1749
|
-
_super.prototype
|
|
2174
|
+
_super.prototype.destroy.call(this);
|
|
1750
2175
|
};
|
|
1751
2176
|
return FragmentPrivate;
|
|
1752
2177
|
}(ReactivePrivate));
|
|
@@ -1759,16 +2184,17 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1759
2184
|
__extends(Fragment, _super);
|
|
1760
2185
|
/**
|
|
1761
2186
|
* Constructs a Vasille Node
|
|
2187
|
+
* @param input
|
|
1762
2188
|
* @param $ {FragmentPrivate}
|
|
1763
2189
|
*/
|
|
1764
|
-
function Fragment($) {
|
|
1765
|
-
var _this =
|
|
2190
|
+
function Fragment(input, $) {
|
|
2191
|
+
var _this = _super.call(this, input, $ || new FragmentPrivate) || this;
|
|
1766
2192
|
/**
|
|
1767
2193
|
* The children list
|
|
1768
2194
|
* @type Array
|
|
1769
2195
|
*/
|
|
1770
|
-
_this
|
|
1771
|
-
_this
|
|
2196
|
+
_this.children = new Set;
|
|
2197
|
+
_this.lastChild = null;
|
|
1772
2198
|
return _this;
|
|
1773
2199
|
}
|
|
1774
2200
|
Object.defineProperty(Fragment.prototype, "app", {
|
|
@@ -1787,43 +2213,16 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1787
2213
|
* @param parent {Fragment} parent of node
|
|
1788
2214
|
* @param data {*} additional data
|
|
1789
2215
|
*/
|
|
1790
|
-
Fragment.prototype
|
|
2216
|
+
Fragment.prototype.preinit = function (app, parent, data) {
|
|
1791
2217
|
var $ = this.$;
|
|
1792
2218
|
$.preinit(app, parent);
|
|
1793
2219
|
};
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
Fragment.prototype.$init = function () {
|
|
1798
|
-
this.$createSignals();
|
|
1799
|
-
this.$createWatchers();
|
|
1800
|
-
this.$created();
|
|
1801
|
-
this.$compose();
|
|
1802
|
-
this.$mounted();
|
|
1803
|
-
return this;
|
|
1804
|
-
};
|
|
1805
|
-
/** To be overloaded: created event handler */
|
|
1806
|
-
Fragment.prototype.$created = function () {
|
|
1807
|
-
// empty
|
|
1808
|
-
};
|
|
1809
|
-
/** To be overloaded: mounted event handler */
|
|
1810
|
-
Fragment.prototype.$mounted = function () {
|
|
1811
|
-
// empty
|
|
2220
|
+
Fragment.prototype.compose = function (input) {
|
|
2221
|
+
_super.prototype.compose.call(this, input);
|
|
2222
|
+
input.slot && input.slot(this);
|
|
1812
2223
|
};
|
|
1813
2224
|
/** To be overloaded: ready event handler */
|
|
1814
|
-
Fragment.prototype
|
|
1815
|
-
// empty
|
|
1816
|
-
};
|
|
1817
|
-
/** To be overloaded: signals creation milestone */
|
|
1818
|
-
Fragment.prototype.$createSignals = function () {
|
|
1819
|
-
// empty
|
|
1820
|
-
};
|
|
1821
|
-
/** To be overloaded: watchers creation milestone */
|
|
1822
|
-
Fragment.prototype.$createWatchers = function () {
|
|
1823
|
-
// empty
|
|
1824
|
-
};
|
|
1825
|
-
/** To be overloaded: DOM creation milestone */
|
|
1826
|
-
Fragment.prototype.$compose = function () {
|
|
2225
|
+
Fragment.prototype.ready = function () {
|
|
1827
2226
|
// empty
|
|
1828
2227
|
};
|
|
1829
2228
|
/**
|
|
@@ -1831,27 +2230,23 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1831
2230
|
* @param node {Fragment} A node to push
|
|
1832
2231
|
* @protected
|
|
1833
2232
|
*/
|
|
1834
|
-
Fragment.prototype
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
lastChild = this.$children[this.$children.length - 1];
|
|
2233
|
+
Fragment.prototype.pushNode = function (node) {
|
|
2234
|
+
if (this.lastChild) {
|
|
2235
|
+
this.lastChild.$.next = node;
|
|
1838
2236
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
node.$.prev = lastChild;
|
|
1843
|
-
node.$.parent = this;
|
|
1844
|
-
this.$children.push(node);
|
|
2237
|
+
node.$.prev = this.lastChild;
|
|
2238
|
+
this.lastChild = node;
|
|
2239
|
+
this.children.add(node);
|
|
1845
2240
|
};
|
|
1846
2241
|
/**
|
|
1847
2242
|
* Find first node in element if so exists
|
|
1848
2243
|
* @return {?Element}
|
|
1849
2244
|
* @protected
|
|
1850
2245
|
*/
|
|
1851
|
-
Fragment.prototype
|
|
2246
|
+
Fragment.prototype.findFirstChild = function () {
|
|
1852
2247
|
var first;
|
|
1853
|
-
this
|
|
1854
|
-
first = first || child
|
|
2248
|
+
this.children.forEach(function (child) {
|
|
2249
|
+
first = first || child.findFirstChild();
|
|
1855
2250
|
});
|
|
1856
2251
|
return first;
|
|
1857
2252
|
};
|
|
@@ -1859,30 +2254,30 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1859
2254
|
* Append a node to end of element
|
|
1860
2255
|
* @param node {Node} node to insert
|
|
1861
2256
|
*/
|
|
1862
|
-
Fragment.prototype
|
|
2257
|
+
Fragment.prototype.appendNode = function (node) {
|
|
1863
2258
|
var $ = this.$;
|
|
1864
2259
|
if ($.next) {
|
|
1865
|
-
$.next
|
|
2260
|
+
$.next.insertAdjacent(node);
|
|
1866
2261
|
}
|
|
1867
2262
|
else {
|
|
1868
|
-
$.parent
|
|
2263
|
+
$.parent.appendNode(node);
|
|
1869
2264
|
}
|
|
1870
2265
|
};
|
|
1871
2266
|
/**
|
|
1872
2267
|
* Insert a node as a sibling of this
|
|
1873
2268
|
* @param node {Node} node to insert
|
|
1874
2269
|
*/
|
|
1875
|
-
Fragment.prototype
|
|
1876
|
-
var child = this
|
|
2270
|
+
Fragment.prototype.insertAdjacent = function (node) {
|
|
2271
|
+
var child = this.findFirstChild();
|
|
1877
2272
|
var $ = this.$;
|
|
1878
2273
|
if (child) {
|
|
1879
|
-
|
|
2274
|
+
child.parentElement.insertBefore(node, child);
|
|
1880
2275
|
}
|
|
1881
2276
|
else if ($.next) {
|
|
1882
|
-
$.next
|
|
2277
|
+
$.next.insertAdjacent(node);
|
|
1883
2278
|
}
|
|
1884
2279
|
else {
|
|
1885
|
-
$.parent
|
|
2280
|
+
$.parent.appendNode(node);
|
|
1886
2281
|
}
|
|
1887
2282
|
};
|
|
1888
2283
|
/**
|
|
@@ -1890,60 +2285,49 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1890
2285
|
* @param text {String | IValue} A text fragment string
|
|
1891
2286
|
* @param cb {function (TextNode)} Callback if previous is slot name
|
|
1892
2287
|
*/
|
|
1893
|
-
Fragment.prototype
|
|
2288
|
+
Fragment.prototype.text = function (text, cb) {
|
|
1894
2289
|
var $ = this.$;
|
|
1895
2290
|
var node = new TextNode();
|
|
1896
|
-
|
|
1897
|
-
node
|
|
1898
|
-
|
|
1899
|
-
if (cb) {
|
|
1900
|
-
$.app.$run.callCallback(function () {
|
|
1901
|
-
cb(node);
|
|
1902
|
-
});
|
|
1903
|
-
}
|
|
1904
|
-
return this;
|
|
2291
|
+
node.preinit($.app, this, text);
|
|
2292
|
+
this.pushNode(node);
|
|
2293
|
+
cb && cb(node);
|
|
1905
2294
|
};
|
|
1906
|
-
Fragment.prototype
|
|
1907
|
-
if (this.$.app
|
|
2295
|
+
Fragment.prototype.debug = function (text) {
|
|
2296
|
+
if (this.$.app.debugUi) {
|
|
1908
2297
|
var node = new DebugNode();
|
|
1909
|
-
node
|
|
1910
|
-
this
|
|
2298
|
+
node.preinit(this.$.app, this, text);
|
|
2299
|
+
this.pushNode(node);
|
|
1911
2300
|
}
|
|
1912
|
-
return this;
|
|
1913
2301
|
};
|
|
1914
|
-
|
|
2302
|
+
/**
|
|
2303
|
+
* Defines a tag element
|
|
2304
|
+
* @param tagName {String} the tag name
|
|
2305
|
+
* @param input
|
|
2306
|
+
* @param cb {function(Tag, *)} callback
|
|
2307
|
+
*/
|
|
2308
|
+
Fragment.prototype.tag = function (tagName, input, cb) {
|
|
1915
2309
|
var $ = this.$;
|
|
1916
|
-
var node = new Tag();
|
|
1917
|
-
|
|
1918
|
-
node
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
}
|
|
1924
|
-
node.$ready();
|
|
1925
|
-
});
|
|
1926
|
-
return this;
|
|
2310
|
+
var node = new Tag(input);
|
|
2311
|
+
input.slot = cb || input.slot;
|
|
2312
|
+
node.preinit($.app, this, tagName);
|
|
2313
|
+
node.init();
|
|
2314
|
+
this.pushNode(node);
|
|
2315
|
+
node.ready();
|
|
2316
|
+
return node.node;
|
|
1927
2317
|
};
|
|
1928
2318
|
/**
|
|
1929
2319
|
* Defines a custom element
|
|
1930
2320
|
* @param node {Fragment} vasille element to insert
|
|
1931
2321
|
* @param callback {function($ : *)}
|
|
1932
|
-
* @param callback1 {function($ : *)}
|
|
1933
2322
|
*/
|
|
1934
|
-
Fragment.prototype
|
|
2323
|
+
Fragment.prototype.create = function (node, callback) {
|
|
1935
2324
|
var $ = this.$;
|
|
1936
2325
|
node.$.parent = this;
|
|
1937
|
-
node
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
callback1(node);
|
|
1943
|
-
}
|
|
1944
|
-
this.$$pushNode(node);
|
|
1945
|
-
node.$init().$ready();
|
|
1946
|
-
return this;
|
|
2326
|
+
node.preinit($.app, this);
|
|
2327
|
+
node.input.slot = callback || node.input.slot;
|
|
2328
|
+
this.pushNode(node);
|
|
2329
|
+
node.init();
|
|
2330
|
+
node.ready();
|
|
1947
2331
|
};
|
|
1948
2332
|
/**
|
|
1949
2333
|
* Defines an if node
|
|
@@ -1951,36 +2335,29 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1951
2335
|
* @param cb {function(Fragment)} callback to run on true
|
|
1952
2336
|
* @return {this}
|
|
1953
2337
|
*/
|
|
1954
|
-
Fragment.prototype
|
|
1955
|
-
|
|
2338
|
+
Fragment.prototype.if = function (cond, cb) {
|
|
2339
|
+
var node = new SwitchedNode();
|
|
2340
|
+
node.preinit(this.$.app, this);
|
|
2341
|
+
node.init();
|
|
2342
|
+
this.pushNode(node);
|
|
2343
|
+
node.addCase(this.case(cond, cb));
|
|
2344
|
+
node.ready();
|
|
1956
2345
|
};
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
return this.$switch({ cond: ifCond, cb: ifCb }, { cond: trueIValue, cb: elseCb });
|
|
2346
|
+
Fragment.prototype.else = function (cb) {
|
|
2347
|
+
if (this.lastChild instanceof SwitchedNode) {
|
|
2348
|
+
this.lastChild.addCase(this.default(cb));
|
|
2349
|
+
}
|
|
2350
|
+
else {
|
|
2351
|
+
throw userError('wrong `else` function use', 'logic-error');
|
|
2352
|
+
}
|
|
1965
2353
|
};
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
var cases = [];
|
|
1973
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1974
|
-
cases[_i] = arguments[_i];
|
|
2354
|
+
Fragment.prototype.elif = function (cond, cb) {
|
|
2355
|
+
if (this.lastChild instanceof SwitchedNode) {
|
|
2356
|
+
this.lastChild.addCase(this.case(cond, cb));
|
|
2357
|
+
}
|
|
2358
|
+
else {
|
|
2359
|
+
throw userError('wrong `elif` function use', 'logic-error');
|
|
1975
2360
|
}
|
|
1976
|
-
var $ = this.$;
|
|
1977
|
-
var node = new SwitchedNode();
|
|
1978
|
-
node.$preinit($.app, this);
|
|
1979
|
-
node.$init();
|
|
1980
|
-
this.$$pushNode(node);
|
|
1981
|
-
node.setCases(cases);
|
|
1982
|
-
node.$ready();
|
|
1983
|
-
return this;
|
|
1984
2361
|
};
|
|
1985
2362
|
/**
|
|
1986
2363
|
* Create a case for switch
|
|
@@ -1988,23 +2365,48 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1988
2365
|
* @param cb {function(Fragment) : void}
|
|
1989
2366
|
* @return {{cond : IValue, cb : (function(Fragment) : void)}}
|
|
1990
2367
|
*/
|
|
1991
|
-
Fragment.prototype
|
|
2368
|
+
Fragment.prototype.case = function (cond, cb) {
|
|
1992
2369
|
return { cond: cond, cb: cb };
|
|
1993
2370
|
};
|
|
1994
2371
|
/**
|
|
1995
2372
|
* @param cb {(function(Fragment) : void)}
|
|
1996
2373
|
* @return {{cond : IValue, cb : (function(Fragment) : void)}}
|
|
1997
2374
|
*/
|
|
1998
|
-
Fragment.prototype
|
|
2375
|
+
Fragment.prototype.default = function (cb) {
|
|
1999
2376
|
return { cond: trueIValue, cb: cb };
|
|
2000
2377
|
};
|
|
2001
|
-
Fragment.prototype
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2378
|
+
Fragment.prototype.insertBefore = function (node) {
|
|
2379
|
+
var $ = this.$;
|
|
2380
|
+
node.$.prev = $.prev;
|
|
2381
|
+
node.$.next = this;
|
|
2382
|
+
if ($.prev) {
|
|
2383
|
+
$.prev.$.next = node;
|
|
2384
|
+
}
|
|
2385
|
+
$.prev = node;
|
|
2386
|
+
};
|
|
2387
|
+
Fragment.prototype.insertAfter = function (node) {
|
|
2388
|
+
var $ = this.$;
|
|
2389
|
+
node.$.prev = this;
|
|
2390
|
+
node.$.next = $.next;
|
|
2391
|
+
$.next = node;
|
|
2392
|
+
};
|
|
2393
|
+
Fragment.prototype.remove = function () {
|
|
2394
|
+
var $ = this.$;
|
|
2395
|
+
if ($.next) {
|
|
2396
|
+
$.next.$.prev = $.prev;
|
|
2397
|
+
}
|
|
2398
|
+
if ($.prev) {
|
|
2399
|
+
$.prev.$.next = $.next;
|
|
2400
|
+
}
|
|
2401
|
+
};
|
|
2402
|
+
Fragment.prototype.destroy = function () {
|
|
2403
|
+
this.children.forEach(function (child) { return child.destroy(); });
|
|
2404
|
+
this.children.clear();
|
|
2405
|
+
this.lastChild = null;
|
|
2406
|
+
if (this.$.parent.lastChild === this) {
|
|
2407
|
+
this.$.parent.lastChild = this.$.prev;
|
|
2005
2408
|
}
|
|
2006
|
-
|
|
2007
|
-
_super.prototype.$destroy.call(this);
|
|
2409
|
+
_super.prototype.destroy.call(this);
|
|
2008
2410
|
};
|
|
2009
2411
|
return Fragment;
|
|
2010
2412
|
}(Reactive));
|
|
@@ -2019,28 +2421,30 @@ var TextNodePrivate = /** @class */ (function (_super) {
|
|
|
2019
2421
|
__extends(TextNodePrivate, _super);
|
|
2020
2422
|
function TextNodePrivate() {
|
|
2021
2423
|
var _this = this; _super.call(this);
|
|
2022
|
-
_this
|
|
2424
|
+
_this.seal();
|
|
2023
2425
|
return _this;
|
|
2024
2426
|
}
|
|
2025
2427
|
/**
|
|
2026
2428
|
* Pre-initializes a text node
|
|
2027
2429
|
* @param app {AppNode} the app node
|
|
2430
|
+
* @param parent
|
|
2028
2431
|
* @param text {IValue}
|
|
2029
2432
|
*/
|
|
2030
2433
|
TextNodePrivate.prototype.preinitText = function (app, parent, text) {
|
|
2031
2434
|
var _this = this;
|
|
2032
2435
|
_super.prototype.preinit.call(this, app, parent);
|
|
2033
|
-
this.node = document.createTextNode(text.$);
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2436
|
+
this.node = document.createTextNode(text instanceof IValue ? text.$ : text);
|
|
2437
|
+
if (text instanceof IValue) {
|
|
2438
|
+
this.bindings.add(new Expression(function (v) {
|
|
2439
|
+
_this.node.replaceData(0, -1, v);
|
|
2440
|
+
}, true, text));
|
|
2441
|
+
}
|
|
2038
2442
|
};
|
|
2039
2443
|
/**
|
|
2040
2444
|
* Clear node data
|
|
2041
2445
|
*/
|
|
2042
|
-
TextNodePrivate.prototype
|
|
2043
|
-
_super.prototype
|
|
2446
|
+
TextNodePrivate.prototype.destroy = function () {
|
|
2447
|
+
_super.prototype.destroy.call(this);
|
|
2044
2448
|
};
|
|
2045
2449
|
return TextNodePrivate;
|
|
2046
2450
|
}(FragmentPrivate));
|
|
@@ -2052,26 +2456,27 @@ var TextNodePrivate = /** @class */ (function (_super) {
|
|
|
2052
2456
|
*/
|
|
2053
2457
|
var TextNode = /** @class */ (function (_super) {
|
|
2054
2458
|
__extends(TextNode, _super);
|
|
2055
|
-
function TextNode() {
|
|
2056
|
-
|
|
2057
|
-
_this
|
|
2058
|
-
_this
|
|
2459
|
+
function TextNode($) {
|
|
2460
|
+
if ($ === void 0) { $ = new TextNodePrivate(); }
|
|
2461
|
+
var _this = _super.call(this, {}, $) || this;
|
|
2462
|
+
_this.seal();
|
|
2059
2463
|
return _this;
|
|
2060
2464
|
}
|
|
2061
|
-
TextNode.prototype
|
|
2465
|
+
TextNode.prototype.preinit = function (app, parent, text) {
|
|
2062
2466
|
var $ = this.$;
|
|
2063
2467
|
if (!text) {
|
|
2064
2468
|
throw internalError('wrong TextNode::$preninit call');
|
|
2065
2469
|
}
|
|
2066
2470
|
$.preinitText(app, parent, text);
|
|
2471
|
+
$.parent.appendNode($.node);
|
|
2067
2472
|
};
|
|
2068
|
-
TextNode.prototype
|
|
2473
|
+
TextNode.prototype.findFirstChild = function () {
|
|
2069
2474
|
return this.$.node;
|
|
2070
2475
|
};
|
|
2071
|
-
TextNode.prototype
|
|
2476
|
+
TextNode.prototype.destroy = function () {
|
|
2072
2477
|
this.$.node.remove();
|
|
2073
|
-
this
|
|
2074
|
-
_super.prototype
|
|
2478
|
+
this.$.destroy();
|
|
2479
|
+
_super.prototype.destroy.call(this);
|
|
2075
2480
|
};
|
|
2076
2481
|
return TextNode;
|
|
2077
2482
|
}(Fragment));
|
|
@@ -2090,11 +2495,11 @@ var INodePrivate = /** @class */ (function (_super) {
|
|
|
2090
2495
|
* @type {boolean}
|
|
2091
2496
|
*/
|
|
2092
2497
|
_this.unmounted = false;
|
|
2093
|
-
_this
|
|
2498
|
+
_this.seal();
|
|
2094
2499
|
return _this;
|
|
2095
2500
|
}
|
|
2096
|
-
INodePrivate.prototype
|
|
2097
|
-
_super.prototype
|
|
2501
|
+
INodePrivate.prototype.destroy = function () {
|
|
2502
|
+
_super.prototype.destroy.call(this);
|
|
2098
2503
|
};
|
|
2099
2504
|
return INodePrivate;
|
|
2100
2505
|
}(FragmentPrivate));
|
|
@@ -2108,11 +2513,12 @@ var INode = /** @class */ (function (_super) {
|
|
|
2108
2513
|
__extends(INode, _super);
|
|
2109
2514
|
/**
|
|
2110
2515
|
* Constructs a base node
|
|
2516
|
+
* @param input
|
|
2111
2517
|
* @param $ {?INodePrivate}
|
|
2112
2518
|
*/
|
|
2113
|
-
function INode($) {
|
|
2114
|
-
var _this = _super.call(this, $ || new INodePrivate) || this;
|
|
2115
|
-
_this
|
|
2519
|
+
function INode(input, $) {
|
|
2520
|
+
var _this = _super.call(this, input, $ || new INodePrivate) || this;
|
|
2521
|
+
_this.seal();
|
|
2116
2522
|
return _this;
|
|
2117
2523
|
}
|
|
2118
2524
|
Object.defineProperty(INode.prototype, "node", {
|
|
@@ -2126,82 +2532,54 @@ var INode = /** @class */ (function (_super) {
|
|
|
2126
2532
|
configurable: true
|
|
2127
2533
|
});
|
|
2128
2534
|
/**
|
|
2129
|
-
*
|
|
2535
|
+
* Bind attribute value
|
|
2536
|
+
* @param name {String} name of attribute
|
|
2537
|
+
* @param value {IValue} value
|
|
2130
2538
|
*/
|
|
2131
|
-
INode.prototype
|
|
2132
|
-
this
|
|
2133
|
-
this
|
|
2134
|
-
|
|
2135
|
-
this.$createStyle();
|
|
2136
|
-
this.$created();
|
|
2137
|
-
this.$compose();
|
|
2138
|
-
this.$mounted();
|
|
2139
|
-
return this;
|
|
2140
|
-
};
|
|
2141
|
-
/** To be overloaded: attributes creation milestone */
|
|
2142
|
-
INode.prototype.$createAttrs = function () {
|
|
2143
|
-
// empty
|
|
2144
|
-
};
|
|
2145
|
-
/** To be overloaded: $style attributes creation milestone */
|
|
2146
|
-
INode.prototype.$createStyle = function () {
|
|
2147
|
-
// empty
|
|
2148
|
-
};
|
|
2149
|
-
/**
|
|
2150
|
-
* Bind attribute value
|
|
2151
|
-
* @param name {String} name of attribute
|
|
2152
|
-
* @param value {IValue} value
|
|
2153
|
-
*/
|
|
2154
|
-
INode.prototype.$attr = function (name, value) {
|
|
2155
|
-
var $ = this.$;
|
|
2156
|
-
var attr = new AttributeBinding(this, name, value);
|
|
2157
|
-
$.bindings.add(attr);
|
|
2158
|
-
return this;
|
|
2159
|
-
};
|
|
2160
|
-
INode.prototype.$bindAttr = function (name, calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
|
2161
|
-
var $ = this.$;
|
|
2162
|
-
var expr = this.$bind(calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
|
2163
|
-
$.bindings.add(new AttributeBinding(this, name, expr));
|
|
2164
|
-
return this;
|
|
2539
|
+
INode.prototype.attr = function (name, value) {
|
|
2540
|
+
var $ = this.$;
|
|
2541
|
+
var attr = new AttributeBinding(this, name, value);
|
|
2542
|
+
$.bindings.add(attr);
|
|
2165
2543
|
};
|
|
2166
2544
|
/**
|
|
2167
2545
|
* Set attribute value
|
|
2168
2546
|
* @param name {string} name of attribute
|
|
2169
2547
|
* @param value {string} value
|
|
2170
2548
|
*/
|
|
2171
|
-
INode.prototype
|
|
2172
|
-
|
|
2549
|
+
INode.prototype.setAttr = function (name, value) {
|
|
2550
|
+
if (typeof value === 'boolean') {
|
|
2551
|
+
if (value) {
|
|
2552
|
+
this.$.node.setAttribute(name, "");
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
else {
|
|
2556
|
+
this.$.node.setAttribute(name, "".concat(value));
|
|
2557
|
+
}
|
|
2173
2558
|
return this;
|
|
2174
2559
|
};
|
|
2175
2560
|
/**
|
|
2176
2561
|
* Adds a CSS class
|
|
2177
2562
|
* @param cl {string} Class name
|
|
2178
2563
|
*/
|
|
2179
|
-
INode.prototype
|
|
2180
|
-
this.$.
|
|
2564
|
+
INode.prototype.addClass = function (cl) {
|
|
2565
|
+
this.$.node.classList.add(cl);
|
|
2181
2566
|
return this;
|
|
2182
2567
|
};
|
|
2183
2568
|
/**
|
|
2184
2569
|
* Adds some CSS classes
|
|
2185
2570
|
* @param cls {...string} classes names
|
|
2186
2571
|
*/
|
|
2187
|
-
INode.prototype
|
|
2188
|
-
|
|
2189
|
-
var cls = [];
|
|
2190
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2191
|
-
cls[_i] = arguments[_i];
|
|
2192
|
-
}
|
|
2193
|
-
cls.forEach(function (cl) {
|
|
2194
|
-
_this.$.app.$run.addClass(_this.$.node, cl);
|
|
2195
|
-
});
|
|
2572
|
+
INode.prototype.removeClasse = function (cl) {
|
|
2573
|
+
this.$.node.classList.remove(cl);
|
|
2196
2574
|
return this;
|
|
2197
2575
|
};
|
|
2198
2576
|
/**
|
|
2199
2577
|
* Bind a CSS class
|
|
2200
2578
|
* @param className {IValue}
|
|
2201
2579
|
*/
|
|
2202
|
-
INode.prototype
|
|
2580
|
+
INode.prototype.bindClass = function (className) {
|
|
2203
2581
|
var $ = this.$;
|
|
2204
|
-
$.bindings.add(new
|
|
2582
|
+
$.bindings.add(new DynamicalClassBinding(this, className));
|
|
2205
2583
|
return this;
|
|
2206
2584
|
};
|
|
2207
2585
|
/**
|
|
@@ -2209,8 +2587,8 @@ var INode = /** @class */ (function (_super) {
|
|
|
2209
2587
|
* @param cond {IValue} condition
|
|
2210
2588
|
* @param className {string} class name
|
|
2211
2589
|
*/
|
|
2212
|
-
INode.prototype
|
|
2213
|
-
this.$.bindings.add(new
|
|
2590
|
+
INode.prototype.floatingClass = function (cond, className) {
|
|
2591
|
+
this.$.bindings.add(new StaticClassBinding(this, className, cond));
|
|
2214
2592
|
return this;
|
|
2215
2593
|
};
|
|
2216
2594
|
/**
|
|
@@ -2218,7 +2596,7 @@ var INode = /** @class */ (function (_super) {
|
|
|
2218
2596
|
* @param name {String} name of style attribute
|
|
2219
2597
|
* @param value {IValue} value
|
|
2220
2598
|
*/
|
|
2221
|
-
INode.prototype
|
|
2599
|
+
INode.prototype.style = function (name, value) {
|
|
2222
2600
|
var $ = this.$;
|
|
2223
2601
|
if ($.node instanceof HTMLElement) {
|
|
2224
2602
|
$.bindings.add(new StyleBinding(this, name, value));
|
|
@@ -2228,28 +2606,17 @@ var INode = /** @class */ (function (_super) {
|
|
|
2228
2606
|
}
|
|
2229
2607
|
return this;
|
|
2230
2608
|
};
|
|
2231
|
-
INode.prototype.$bindStyle = function (name, calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
|
2232
|
-
var $ = this.$;
|
|
2233
|
-
var expr = this.$bind(calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
|
2234
|
-
if ($.node instanceof HTMLElement) {
|
|
2235
|
-
$.bindings.add(new StyleBinding(this, name, expr));
|
|
2236
|
-
}
|
|
2237
|
-
else {
|
|
2238
|
-
throw userError('style can be applied to HTML elements only', 'non-html-element');
|
|
2239
|
-
}
|
|
2240
|
-
return this;
|
|
2241
|
-
};
|
|
2242
2609
|
/**
|
|
2243
2610
|
* Sets a style property value
|
|
2244
2611
|
* @param prop {string} Property name
|
|
2245
2612
|
* @param value {string} Property value
|
|
2246
2613
|
*/
|
|
2247
|
-
INode.prototype
|
|
2614
|
+
INode.prototype.setStyle = function (prop, value) {
|
|
2248
2615
|
if (this.$.node instanceof HTMLElement) {
|
|
2249
|
-
this.$.
|
|
2616
|
+
this.$.node.style.setProperty(prop, value);
|
|
2250
2617
|
}
|
|
2251
2618
|
else {
|
|
2252
|
-
throw userError("Style can be
|
|
2619
|
+
throw userError("Style can be set for HTML elements only", "non-html-element");
|
|
2253
2620
|
}
|
|
2254
2621
|
return this;
|
|
2255
2622
|
};
|
|
@@ -2259,403 +2626,24 @@ var INode = /** @class */ (function (_super) {
|
|
|
2259
2626
|
* @param handler {function (Event)} Event handler
|
|
2260
2627
|
* @param options {Object | boolean} addEventListener options
|
|
2261
2628
|
*/
|
|
2262
|
-
INode.prototype
|
|
2629
|
+
INode.prototype.listen = function (name, handler, options) {
|
|
2263
2630
|
this.$.node.addEventListener(name, handler, options);
|
|
2264
2631
|
return this;
|
|
2265
2632
|
};
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
* @param options {Object | boolean}
|
|
2269
|
-
*/
|
|
2270
|
-
INode.prototype.$oncontextmenu = function (handler, options) {
|
|
2271
|
-
return this.$listen("contextmenu", handler, options);
|
|
2272
|
-
};
|
|
2273
|
-
/**
|
|
2274
|
-
* @param handler {function (MouseEvent)}
|
|
2275
|
-
* @param options {Object | boolean}
|
|
2276
|
-
*/
|
|
2277
|
-
INode.prototype.$onmousedown = function (handler, options) {
|
|
2278
|
-
return this.$listen("mousedown", handler, options);
|
|
2279
|
-
};
|
|
2280
|
-
/**
|
|
2281
|
-
* @param handler {function (MouseEvent)}
|
|
2282
|
-
* @param options {Object | boolean}
|
|
2283
|
-
*/
|
|
2284
|
-
INode.prototype.$onmouseenter = function (handler, options) {
|
|
2285
|
-
return this.$listen("mouseenter", handler, options);
|
|
2286
|
-
};
|
|
2287
|
-
/**
|
|
2288
|
-
* @param handler {function (MouseEvent)}
|
|
2289
|
-
* @param options {Object | boolean}
|
|
2290
|
-
*/
|
|
2291
|
-
INode.prototype.$onmouseleave = function (handler, options) {
|
|
2292
|
-
return this.$listen("mouseleave", handler, options);
|
|
2293
|
-
};
|
|
2294
|
-
/**
|
|
2295
|
-
* @param handler {function (MouseEvent)}
|
|
2296
|
-
* @param options {Object | boolean}
|
|
2297
|
-
*/
|
|
2298
|
-
INode.prototype.$onmousemove = function (handler, options) {
|
|
2299
|
-
return this.$listen("mousemove", handler, options);
|
|
2300
|
-
};
|
|
2301
|
-
/**
|
|
2302
|
-
* @param handler {function (MouseEvent)}
|
|
2303
|
-
* @param options {Object | boolean}
|
|
2304
|
-
*/
|
|
2305
|
-
INode.prototype.$onmouseout = function (handler, options) {
|
|
2306
|
-
return this.$listen("mouseout", handler, options);
|
|
2307
|
-
};
|
|
2308
|
-
/**
|
|
2309
|
-
* @param handler {function (MouseEvent)}
|
|
2310
|
-
* @param options {Object | boolean}
|
|
2311
|
-
*/
|
|
2312
|
-
INode.prototype.$onmouseover = function (handler, options) {
|
|
2313
|
-
return this.$listen("mouseover", handler, options);
|
|
2314
|
-
};
|
|
2315
|
-
/**
|
|
2316
|
-
* @param handler {function (MouseEvent)}
|
|
2317
|
-
* @param options {Object | boolean}
|
|
2318
|
-
*/
|
|
2319
|
-
INode.prototype.$onmouseup = function (handler, options) {
|
|
2320
|
-
return this.$listen("mouseup", handler, options);
|
|
2321
|
-
};
|
|
2322
|
-
/**
|
|
2323
|
-
* @param handler {function (MouseEvent)}
|
|
2324
|
-
* @param options {Object | boolean}
|
|
2325
|
-
*/
|
|
2326
|
-
INode.prototype.$onclick = function (handler, options) {
|
|
2327
|
-
return this.$listen("click", handler, options);
|
|
2328
|
-
};
|
|
2329
|
-
/**
|
|
2330
|
-
* @param handler {function (MouseEvent)}
|
|
2331
|
-
* @param options {Object | boolean}
|
|
2332
|
-
*/
|
|
2333
|
-
INode.prototype.$ondblclick = function (handler, options) {
|
|
2334
|
-
return this.$listen("dblclick", handler, options);
|
|
2335
|
-
};
|
|
2336
|
-
/**
|
|
2337
|
-
* @param handler {function (FocusEvent)}
|
|
2338
|
-
* @param options {Object | boolean}
|
|
2339
|
-
*/
|
|
2340
|
-
INode.prototype.$onblur = function (handler, options) {
|
|
2341
|
-
return this.$listen("blur", handler, options);
|
|
2342
|
-
};
|
|
2343
|
-
/**
|
|
2344
|
-
* @param handler {function (FocusEvent)}
|
|
2345
|
-
* @param options {Object | boolean}
|
|
2346
|
-
*/
|
|
2347
|
-
INode.prototype.$onfocus = function (handler, options) {
|
|
2348
|
-
return this.$listen("focus", handler, options);
|
|
2349
|
-
};
|
|
2350
|
-
/**
|
|
2351
|
-
* @param handler {function (FocusEvent)}
|
|
2352
|
-
* @param options {Object | boolean}
|
|
2353
|
-
*/
|
|
2354
|
-
INode.prototype.$onfocusin = function (handler, options) {
|
|
2355
|
-
return this.$listen("focusin", handler, options);
|
|
2356
|
-
};
|
|
2357
|
-
/**
|
|
2358
|
-
* @param handler {function (FocusEvent)}
|
|
2359
|
-
* @param options {Object | boolean}
|
|
2360
|
-
*/
|
|
2361
|
-
INode.prototype.$onfocusout = function (handler, options) {
|
|
2362
|
-
return this.$listen("focusout", handler, options);
|
|
2363
|
-
};
|
|
2364
|
-
/**
|
|
2365
|
-
* @param handler {function (KeyboardEvent)}
|
|
2366
|
-
* @param options {Object | boolean}
|
|
2367
|
-
*/
|
|
2368
|
-
INode.prototype.$onkeydown = function (handler, options) {
|
|
2369
|
-
return this.$listen("keydown", handler, options);
|
|
2370
|
-
};
|
|
2371
|
-
/**
|
|
2372
|
-
* @param handler {function (KeyboardEvent)}
|
|
2373
|
-
* @param options {Object | boolean}
|
|
2374
|
-
*/
|
|
2375
|
-
INode.prototype.$onkeyup = function (handler, options) {
|
|
2376
|
-
return this.$listen("keyup", handler, options);
|
|
2377
|
-
};
|
|
2378
|
-
/**
|
|
2379
|
-
* @param handler {function (KeyboardEvent)}
|
|
2380
|
-
* @param options {Object | boolean}
|
|
2381
|
-
*/
|
|
2382
|
-
INode.prototype.$onkeypress = function (handler, options) {
|
|
2383
|
-
return this.$listen("keypress", handler, options);
|
|
2384
|
-
};
|
|
2385
|
-
/**
|
|
2386
|
-
* @param handler {function (TouchEvent)}
|
|
2387
|
-
* @param options {Object | boolean}
|
|
2388
|
-
*/
|
|
2389
|
-
INode.prototype.$ontouchstart = function (handler, options) {
|
|
2390
|
-
return this.$listen("touchstart", handler, options);
|
|
2391
|
-
};
|
|
2392
|
-
/**
|
|
2393
|
-
* @param handler {function (TouchEvent)}
|
|
2394
|
-
* @param options {Object | boolean}
|
|
2395
|
-
*/
|
|
2396
|
-
INode.prototype.$ontouchmove = function (handler, options) {
|
|
2397
|
-
return this.$listen("touchmove", handler, options);
|
|
2398
|
-
};
|
|
2399
|
-
/**
|
|
2400
|
-
* @param handler {function (TouchEvent)}
|
|
2401
|
-
* @param options {Object | boolean}
|
|
2402
|
-
*/
|
|
2403
|
-
INode.prototype.$ontouchend = function (handler, options) {
|
|
2404
|
-
return this.$listen("touchend", handler, options);
|
|
2405
|
-
};
|
|
2406
|
-
/**
|
|
2407
|
-
* @param handler {function (TouchEvent)}
|
|
2408
|
-
* @param options {Object | boolean}
|
|
2409
|
-
*/
|
|
2410
|
-
INode.prototype.$ontouchcancel = function (handler, options) {
|
|
2411
|
-
return this.$listen("touchcancel", handler, options);
|
|
2412
|
-
};
|
|
2413
|
-
/**
|
|
2414
|
-
* @param handler {function (WheelEvent)}
|
|
2415
|
-
* @param options {Object | boolean}
|
|
2416
|
-
*/
|
|
2417
|
-
INode.prototype.$onwheel = function (handler, options) {
|
|
2418
|
-
return this.$listen("wheel", handler, options);
|
|
2419
|
-
};
|
|
2420
|
-
/**
|
|
2421
|
-
* @param handler {function (ProgressEvent)}
|
|
2422
|
-
* @param options {Object | boolean}
|
|
2423
|
-
*/
|
|
2424
|
-
INode.prototype.$onabort = function (handler, options) {
|
|
2425
|
-
return this.$listen("abort", handler, options);
|
|
2426
|
-
};
|
|
2427
|
-
/**
|
|
2428
|
-
* @param handler {function (ProgressEvent)}
|
|
2429
|
-
* @param options {Object | boolean}
|
|
2430
|
-
*/
|
|
2431
|
-
INode.prototype.$onerror = function (handler, options) {
|
|
2432
|
-
return this.$listen("error", handler, options);
|
|
2433
|
-
};
|
|
2434
|
-
/**
|
|
2435
|
-
* @param handler {function (ProgressEvent)}
|
|
2436
|
-
* @param options {Object | boolean}
|
|
2437
|
-
*/
|
|
2438
|
-
INode.prototype.$onload = function (handler, options) {
|
|
2439
|
-
return this.$listen("load", handler, options);
|
|
2440
|
-
};
|
|
2441
|
-
/**
|
|
2442
|
-
* @param handler {function (ProgressEvent)}
|
|
2443
|
-
* @param options {Object | boolean}
|
|
2444
|
-
*/
|
|
2445
|
-
INode.prototype.$onloadend = function (handler, options) {
|
|
2446
|
-
return this.$listen("loadend", handler, options);
|
|
2447
|
-
};
|
|
2448
|
-
/**
|
|
2449
|
-
* @param handler {function (ProgressEvent)}
|
|
2450
|
-
* @param options {Object | boolean}
|
|
2451
|
-
*/
|
|
2452
|
-
INode.prototype.$onloadstart = function (handler, options) {
|
|
2453
|
-
return this.$listen("loadstart", handler, options);
|
|
2454
|
-
};
|
|
2455
|
-
/**
|
|
2456
|
-
* @param handler {function (ProgressEvent)}
|
|
2457
|
-
* @param options {Object | boolean}
|
|
2458
|
-
*/
|
|
2459
|
-
INode.prototype.$onprogress = function (handler, options) {
|
|
2460
|
-
return this.$listen("progress", handler, options);
|
|
2461
|
-
};
|
|
2462
|
-
/**
|
|
2463
|
-
* @param handler {function (ProgressEvent)}
|
|
2464
|
-
* @param options {Object | boolean}
|
|
2465
|
-
*/
|
|
2466
|
-
INode.prototype.$ontimeout = function (handler, options) {
|
|
2467
|
-
return this.$listen("timeout", handler, options);
|
|
2468
|
-
};
|
|
2469
|
-
/**
|
|
2470
|
-
* @param handler {function (DragEvent)}
|
|
2471
|
-
* @param options {Object | boolean}
|
|
2472
|
-
*/
|
|
2473
|
-
INode.prototype.$ondrag = function (handler, options) {
|
|
2474
|
-
return this.$listen("drag", handler, options);
|
|
2475
|
-
};
|
|
2476
|
-
/**
|
|
2477
|
-
* @param handler {function (DragEvent)}
|
|
2478
|
-
* @param options {Object | boolean}
|
|
2479
|
-
*/
|
|
2480
|
-
INode.prototype.$ondragend = function (handler, options) {
|
|
2481
|
-
return this.$listen("dragend", handler, options);
|
|
2482
|
-
};
|
|
2483
|
-
/**
|
|
2484
|
-
* @param handler {function (DragEvent)}
|
|
2485
|
-
* @param options {Object | boolean}
|
|
2486
|
-
*/
|
|
2487
|
-
INode.prototype.$ondragenter = function (handler, options) {
|
|
2488
|
-
return this.$listen("dragenter", handler, options);
|
|
2489
|
-
};
|
|
2490
|
-
/**
|
|
2491
|
-
* @param handler {function (DragEvent)}
|
|
2492
|
-
* @param options {Object | boolean}
|
|
2493
|
-
*/
|
|
2494
|
-
INode.prototype.$ondragexit = function (handler, options) {
|
|
2495
|
-
return this.$listen("dragexit", handler, options);
|
|
2496
|
-
};
|
|
2497
|
-
/**
|
|
2498
|
-
* @param handler {function (DragEvent)}
|
|
2499
|
-
* @param options {Object | boolean}
|
|
2500
|
-
*/
|
|
2501
|
-
INode.prototype.$ondragleave = function (handler, options) {
|
|
2502
|
-
return this.$listen("dragleave", handler, options);
|
|
2503
|
-
};
|
|
2504
|
-
/**
|
|
2505
|
-
* @param handler {function (DragEvent)}
|
|
2506
|
-
* @param options {Object | boolean}
|
|
2507
|
-
*/
|
|
2508
|
-
INode.prototype.$ondragover = function (handler, options) {
|
|
2509
|
-
return this.$listen("dragover", handler, options);
|
|
2510
|
-
};
|
|
2511
|
-
/**
|
|
2512
|
-
* @param handler {function (DragEvent)}
|
|
2513
|
-
* @param options {Object | boolean}
|
|
2514
|
-
*/
|
|
2515
|
-
INode.prototype.$ondragstart = function (handler, options) {
|
|
2516
|
-
return this.$listen("dragstart", handler, options);
|
|
2517
|
-
};
|
|
2518
|
-
/**
|
|
2519
|
-
* @param handler {function (DragEvent)}
|
|
2520
|
-
* @param options {Object | boolean}
|
|
2521
|
-
*/
|
|
2522
|
-
INode.prototype.$ondrop = function (handler, options) {
|
|
2523
|
-
return this.$listen("drop", handler, options);
|
|
2524
|
-
};
|
|
2525
|
-
/**
|
|
2526
|
-
* @param handler {function (PointerEvent)}
|
|
2527
|
-
* @param options {Object | boolean}
|
|
2528
|
-
*/
|
|
2529
|
-
INode.prototype.$onpointerover = function (handler, options) {
|
|
2530
|
-
return this.$listen("pointerover", handler, options);
|
|
2531
|
-
};
|
|
2532
|
-
/**
|
|
2533
|
-
* @param handler {function (PointerEvent)}
|
|
2534
|
-
* @param options {Object | boolean}
|
|
2535
|
-
*/
|
|
2536
|
-
INode.prototype.$onpointerenter = function (handler, options) {
|
|
2537
|
-
return this.$listen("pointerenter", handler, options);
|
|
2538
|
-
};
|
|
2539
|
-
/**
|
|
2540
|
-
* @param handler {function (PointerEvent)}
|
|
2541
|
-
* @param options {Object | boolean}
|
|
2542
|
-
*/
|
|
2543
|
-
INode.prototype.$onpointerdown = function (handler, options) {
|
|
2544
|
-
return this.$listen("pointerdown", handler, options);
|
|
2545
|
-
};
|
|
2546
|
-
/**
|
|
2547
|
-
* @param handler {function (PointerEvent)}
|
|
2548
|
-
* @param options {Object | boolean}
|
|
2549
|
-
*/
|
|
2550
|
-
INode.prototype.$onpointermove = function (handler, options) {
|
|
2551
|
-
return this.$listen("pointermove", handler, options);
|
|
2552
|
-
};
|
|
2553
|
-
/**
|
|
2554
|
-
* @param handler {function (PointerEvent)}
|
|
2555
|
-
* @param options {Object | boolean}
|
|
2556
|
-
*/
|
|
2557
|
-
INode.prototype.$onpointerup = function (handler, options) {
|
|
2558
|
-
return this.$listen("pointerup", handler, options);
|
|
2559
|
-
};
|
|
2560
|
-
/**
|
|
2561
|
-
* @param handler {function (PointerEvent)}
|
|
2562
|
-
* @param options {Object | boolean}
|
|
2563
|
-
*/
|
|
2564
|
-
INode.prototype.$onpointercancel = function (handler, options) {
|
|
2565
|
-
return this.$listen("pointercancel", handler, options);
|
|
2566
|
-
};
|
|
2567
|
-
/**
|
|
2568
|
-
* @param handler {function (PointerEvent)}
|
|
2569
|
-
* @param options {Object | boolean}
|
|
2570
|
-
*/
|
|
2571
|
-
INode.prototype.$onpointerout = function (handler, options) {
|
|
2572
|
-
return this.$listen("pointerout", handler, options);
|
|
2573
|
-
};
|
|
2574
|
-
/**
|
|
2575
|
-
* @param handler {function (PointerEvent)}
|
|
2576
|
-
* @param options {Object | boolean}
|
|
2577
|
-
*/
|
|
2578
|
-
INode.prototype.$onpointerleave = function (handler, options) {
|
|
2579
|
-
return this.$listen("pointerleave", handler, options);
|
|
2580
|
-
};
|
|
2581
|
-
/**
|
|
2582
|
-
* @param handler {function (PointerEvent)}
|
|
2583
|
-
* @param options {Object | boolean}
|
|
2584
|
-
*/
|
|
2585
|
-
INode.prototype.$ongotpointercapture = function (handler, options) {
|
|
2586
|
-
return this.$listen("gotpointercapture", handler, options);
|
|
2587
|
-
};
|
|
2588
|
-
/**
|
|
2589
|
-
* @param handler {function (PointerEvent)}
|
|
2590
|
-
* @param options {Object | boolean}
|
|
2591
|
-
*/
|
|
2592
|
-
INode.prototype.$onlostpointercapture = function (handler, options) {
|
|
2593
|
-
return this.$listen("lostpointercapture", handler, options);
|
|
2594
|
-
};
|
|
2595
|
-
/**
|
|
2596
|
-
* @param handler {function (AnimationEvent)}
|
|
2597
|
-
* @param options {Object | boolean}
|
|
2598
|
-
*/
|
|
2599
|
-
INode.prototype.$onanimationstart = function (handler, options) {
|
|
2600
|
-
return this.$listen("animationstart", handler, options);
|
|
2601
|
-
};
|
|
2602
|
-
/**
|
|
2603
|
-
* @param handler {function (AnimationEvent)}
|
|
2604
|
-
* @param options {Object | boolean}
|
|
2605
|
-
*/
|
|
2606
|
-
INode.prototype.$onanimationend = function (handler, options) {
|
|
2607
|
-
return this.$listen("animationend", handler, options);
|
|
2608
|
-
};
|
|
2609
|
-
/**
|
|
2610
|
-
* @param handler {function (AnimationEvent)}
|
|
2611
|
-
* @param options {Object | boolean}
|
|
2612
|
-
*/
|
|
2613
|
-
INode.prototype.$onanimationiteraton = function (handler, options) {
|
|
2614
|
-
return this.$listen("animationiteration", handler, options);
|
|
2615
|
-
};
|
|
2616
|
-
/**
|
|
2617
|
-
* @param handler {function (ClipboardEvent)}
|
|
2618
|
-
* @param options {Object | boolean}
|
|
2619
|
-
*/
|
|
2620
|
-
INode.prototype.$onclipboardchange = function (handler, options) {
|
|
2621
|
-
return this.$listen("clipboardchange", handler, options);
|
|
2622
|
-
};
|
|
2623
|
-
/**
|
|
2624
|
-
* @param handler {function (ClipboardEvent)}
|
|
2625
|
-
* @param options {Object | boolean}
|
|
2626
|
-
*/
|
|
2627
|
-
INode.prototype.$oncut = function (handler, options) {
|
|
2628
|
-
return this.$listen("cut", handler, options);
|
|
2629
|
-
};
|
|
2630
|
-
/**
|
|
2631
|
-
* @param handler {function (ClipboardEvent)}
|
|
2632
|
-
* @param options {Object | boolean}
|
|
2633
|
-
*/
|
|
2634
|
-
INode.prototype.$oncopy = function (handler, options) {
|
|
2635
|
-
return this.$listen("copy", handler, options);
|
|
2636
|
-
};
|
|
2637
|
-
/**
|
|
2638
|
-
* @param handler {function (ClipboardEvent)}
|
|
2639
|
-
* @param options {Object | boolean}
|
|
2640
|
-
*/
|
|
2641
|
-
INode.prototype.$onpaste = function (handler, options) {
|
|
2642
|
-
return this.$listen("paste", handler, options);
|
|
2643
|
-
};
|
|
2644
|
-
INode.prototype.$$insertAdjacent = function (node) {
|
|
2645
|
-
var $ = this.$;
|
|
2646
|
-
$.app.$run.insertBefore($.node, node);
|
|
2633
|
+
INode.prototype.insertAdjacent = function (node) {
|
|
2634
|
+
this.$.node.parentNode.insertBefore(node, this.$.node);
|
|
2647
2635
|
};
|
|
2648
2636
|
/**
|
|
2649
2637
|
* A v-show & ngShow alternative
|
|
2650
2638
|
* @param cond {IValue} show condition
|
|
2651
2639
|
*/
|
|
2652
|
-
INode.prototype
|
|
2640
|
+
INode.prototype.bindShow = function (cond) {
|
|
2653
2641
|
var $ = this.$;
|
|
2654
2642
|
var node = $.node;
|
|
2655
2643
|
if (node instanceof HTMLElement) {
|
|
2656
2644
|
var lastDisplay_1 = node.style.display;
|
|
2657
2645
|
var htmlNode_1 = node;
|
|
2658
|
-
return this
|
|
2646
|
+
return this.bindAlive(cond, function () {
|
|
2659
2647
|
lastDisplay_1 = htmlNode_1.style.display;
|
|
2660
2648
|
htmlNode_1.style.display = 'none';
|
|
2661
2649
|
}, function () {
|
|
@@ -2670,19 +2658,106 @@ var INode = /** @class */ (function (_super) {
|
|
|
2670
2658
|
* bind HTML
|
|
2671
2659
|
* @param value {IValue}
|
|
2672
2660
|
*/
|
|
2673
|
-
INode.prototype
|
|
2661
|
+
INode.prototype.bindDomApi = function (name, value) {
|
|
2674
2662
|
var $ = this.$;
|
|
2675
2663
|
var node = $.node;
|
|
2676
2664
|
if (node instanceof HTMLElement) {
|
|
2677
|
-
node
|
|
2678
|
-
this
|
|
2679
|
-
node
|
|
2665
|
+
node[name] = value.$;
|
|
2666
|
+
this.watch(function (v) {
|
|
2667
|
+
node[name] = v;
|
|
2680
2668
|
}, value);
|
|
2681
2669
|
}
|
|
2682
2670
|
else {
|
|
2683
2671
|
throw userError("HTML can be bound for HTML nodes only", "dom-error");
|
|
2684
2672
|
}
|
|
2685
2673
|
};
|
|
2674
|
+
INode.prototype.applyOptions = function (options) {
|
|
2675
|
+
var _this = this;
|
|
2676
|
+
options["v:attr"] && Object.keys(options["v:attr"]).forEach(function (name) {
|
|
2677
|
+
var value = options["v:attr"][name];
|
|
2678
|
+
if (value instanceof IValue) {
|
|
2679
|
+
_this.attr(name, value);
|
|
2680
|
+
}
|
|
2681
|
+
else {
|
|
2682
|
+
_this.setAttr(name, value);
|
|
2683
|
+
}
|
|
2684
|
+
});
|
|
2685
|
+
if (options.class) {
|
|
2686
|
+
var handleClass_1 = function (name, value) {
|
|
2687
|
+
if (value instanceof IValue) {
|
|
2688
|
+
_this.floatingClass(value, name);
|
|
2689
|
+
}
|
|
2690
|
+
else if (value && name !== '$') {
|
|
2691
|
+
_this.addClass(name);
|
|
2692
|
+
}
|
|
2693
|
+
else {
|
|
2694
|
+
_this.removeClasse(name);
|
|
2695
|
+
}
|
|
2696
|
+
};
|
|
2697
|
+
if (Array.isArray(options.class)) {
|
|
2698
|
+
options.class.forEach(function (item) {
|
|
2699
|
+
if (item instanceof IValue) {
|
|
2700
|
+
_this.bindClass(item);
|
|
2701
|
+
}
|
|
2702
|
+
else if (typeof item == "string") {
|
|
2703
|
+
_this.addClass(item);
|
|
2704
|
+
}
|
|
2705
|
+
else {
|
|
2706
|
+
Reflect.ownKeys(item).forEach(function (name) {
|
|
2707
|
+
handleClass_1(name, item[name]);
|
|
2708
|
+
});
|
|
2709
|
+
}
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2712
|
+
else {
|
|
2713
|
+
options.class.$.forEach(function (item) {
|
|
2714
|
+
_this.bindClass(item);
|
|
2715
|
+
});
|
|
2716
|
+
Reflect.ownKeys(options.class).forEach(function (name) {
|
|
2717
|
+
handleClass_1(name, options.class[name]);
|
|
2718
|
+
});
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
options.style && Object.keys(options.style).forEach(function (name) {
|
|
2722
|
+
var value = options.style[name];
|
|
2723
|
+
if (value instanceof IValue) {
|
|
2724
|
+
_this.style(name, value);
|
|
2725
|
+
}
|
|
2726
|
+
else if (typeof value === "string") {
|
|
2727
|
+
_this.setStyle(name, value);
|
|
2728
|
+
}
|
|
2729
|
+
else {
|
|
2730
|
+
if (value[0] instanceof IValue) {
|
|
2731
|
+
_this.style(name, _this.expr(function (v) { return v + value[1]; }, value[0]));
|
|
2732
|
+
}
|
|
2733
|
+
else {
|
|
2734
|
+
_this.setStyle(name, value[0] + value[1]);
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
});
|
|
2738
|
+
options["v:events"] && Object.keys(options["v:events"]).forEach(function (name) {
|
|
2739
|
+
_this.listen(name, options["v:events"][name]);
|
|
2740
|
+
});
|
|
2741
|
+
if (options["v:bind"]) {
|
|
2742
|
+
var inode_1 = this.node;
|
|
2743
|
+
Reflect.ownKeys(options["v:bind"]).forEach(function (k) {
|
|
2744
|
+
var value = options["v:bind"][k];
|
|
2745
|
+
if (k === 'value' && (inode_1 instanceof HTMLInputElement || inode_1 instanceof HTMLTextAreaElement)) {
|
|
2746
|
+
inode_1.oninput = function () { return value.$ = inode_1.value; };
|
|
2747
|
+
}
|
|
2748
|
+
else if (k === 'checked' && inode_1 instanceof HTMLInputElement) {
|
|
2749
|
+
inode_1.oninput = function () { return value.$ = inode_1.checked; };
|
|
2750
|
+
}
|
|
2751
|
+
else if (k === 'volume' && inode_1 instanceof HTMLMediaElement) {
|
|
2752
|
+
inode_1.onvolumechange = function () { return value.$ = inode_1.volume; };
|
|
2753
|
+
}
|
|
2754
|
+
_this.bindDomApi(k, value);
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
options["v:set"] && Object.keys(options["v:set"]).forEach(function (key) {
|
|
2758
|
+
_this.node[key] = options["v:set"][key];
|
|
2759
|
+
});
|
|
2760
|
+
};
|
|
2686
2761
|
return INode;
|
|
2687
2762
|
}(Fragment));
|
|
2688
2763
|
|
|
@@ -2693,12 +2768,12 @@ var INode = /** @class */ (function (_super) {
|
|
|
2693
2768
|
*/
|
|
2694
2769
|
var Tag = /** @class */ (function (_super) {
|
|
2695
2770
|
__extends(Tag, _super);
|
|
2696
|
-
function Tag() {
|
|
2697
|
-
var _this =
|
|
2698
|
-
_this
|
|
2771
|
+
function Tag(input) {
|
|
2772
|
+
var _this = _super.call(this, input) || this;
|
|
2773
|
+
_this.seal();
|
|
2699
2774
|
return _this;
|
|
2700
2775
|
}
|
|
2701
|
-
Tag.prototype
|
|
2776
|
+
Tag.prototype.preinit = function (app, parent, tagName) {
|
|
2702
2777
|
if (!tagName || typeof tagName !== "string") {
|
|
2703
2778
|
throw internalError('wrong Tag::$preinit call');
|
|
2704
2779
|
}
|
|
@@ -2706,55 +2781,53 @@ var Tag = /** @class */ (function (_super) {
|
|
|
2706
2781
|
var $ = this.$;
|
|
2707
2782
|
$.preinit(app, parent);
|
|
2708
2783
|
$.node = node;
|
|
2709
|
-
$.parent
|
|
2784
|
+
$.parent.appendNode(node);
|
|
2785
|
+
};
|
|
2786
|
+
Tag.prototype.compose = function (input) {
|
|
2787
|
+
input.slot && input.slot(this);
|
|
2710
2788
|
};
|
|
2711
|
-
Tag.prototype
|
|
2789
|
+
Tag.prototype.findFirstChild = function () {
|
|
2712
2790
|
return this.$.unmounted ? null : this.$.node;
|
|
2713
2791
|
};
|
|
2714
|
-
Tag.prototype
|
|
2792
|
+
Tag.prototype.insertAdjacent = function (node) {
|
|
2715
2793
|
if (this.$.unmounted) {
|
|
2716
2794
|
if (this.$.next) {
|
|
2717
|
-
this.$.next
|
|
2795
|
+
this.$.next.insertAdjacent(node);
|
|
2718
2796
|
}
|
|
2719
2797
|
else {
|
|
2720
|
-
this.$.parent
|
|
2798
|
+
this.$.parent.appendNode(node);
|
|
2721
2799
|
}
|
|
2722
2800
|
}
|
|
2723
2801
|
else {
|
|
2724
|
-
_super.prototype
|
|
2802
|
+
_super.prototype.insertAdjacent.call(this, node);
|
|
2725
2803
|
}
|
|
2726
2804
|
};
|
|
2727
|
-
Tag.prototype
|
|
2728
|
-
|
|
2729
|
-
$.app.$run.appendChild($.node, node);
|
|
2805
|
+
Tag.prototype.appendNode = function (node) {
|
|
2806
|
+
this.$.node.appendChild(node);
|
|
2730
2807
|
};
|
|
2731
2808
|
/**
|
|
2732
2809
|
* Mount/Unmount a node
|
|
2733
2810
|
* @param cond {IValue} show condition
|
|
2734
2811
|
*/
|
|
2735
|
-
Tag.prototype
|
|
2812
|
+
Tag.prototype.bindMount = function (cond) {
|
|
2813
|
+
var _this = this;
|
|
2736
2814
|
var $ = this.$;
|
|
2737
|
-
|
|
2815
|
+
this.bindAlive(cond, function () {
|
|
2738
2816
|
$.node.remove();
|
|
2739
2817
|
$.unmounted = true;
|
|
2740
2818
|
}, function () {
|
|
2741
|
-
if (
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
$.next.$$insertAdjacent($.node);
|
|
2819
|
+
if ($.unmounted) {
|
|
2820
|
+
_this.insertAdjacent($.node);
|
|
2821
|
+
$.unmounted = false;
|
|
2745
2822
|
}
|
|
2746
|
-
else {
|
|
2747
|
-
$.parent.$$appendNode($.node);
|
|
2748
|
-
}
|
|
2749
|
-
$.unmounted = false;
|
|
2750
2823
|
});
|
|
2751
2824
|
};
|
|
2752
2825
|
/**
|
|
2753
2826
|
* Runs GC
|
|
2754
2827
|
*/
|
|
2755
|
-
Tag.prototype
|
|
2828
|
+
Tag.prototype.destroy = function () {
|
|
2756
2829
|
this.node.remove();
|
|
2757
|
-
_super.prototype
|
|
2830
|
+
_super.prototype.destroy.call(this);
|
|
2758
2831
|
};
|
|
2759
2832
|
return Tag;
|
|
2760
2833
|
}(INode));
|
|
@@ -2766,23 +2839,25 @@ var Tag = /** @class */ (function (_super) {
|
|
|
2766
2839
|
*/
|
|
2767
2840
|
var Extension = /** @class */ (function (_super) {
|
|
2768
2841
|
__extends(Extension, _super);
|
|
2769
|
-
function Extension(
|
|
2770
|
-
|
|
2771
|
-
_this.$seal();
|
|
2772
|
-
return _this;
|
|
2842
|
+
function Extension() {
|
|
2843
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2773
2844
|
}
|
|
2774
|
-
Extension.prototype
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2845
|
+
Extension.prototype.preinit = function (app, parent) {
|
|
2846
|
+
var $ = this.$;
|
|
2847
|
+
var it = parent;
|
|
2848
|
+
while (it && !(it instanceof INode)) {
|
|
2849
|
+
it = it.parent;
|
|
2779
2850
|
}
|
|
2780
|
-
|
|
2781
|
-
|
|
2851
|
+
if (it && it instanceof INode) {
|
|
2852
|
+
$.node = it.node;
|
|
2853
|
+
}
|
|
2854
|
+
$.preinit(app, parent);
|
|
2855
|
+
if (!it) {
|
|
2856
|
+
throw userError("A extension node can be encapsulated only in a tag/extension/component", "virtual-dom");
|
|
2782
2857
|
}
|
|
2783
2858
|
};
|
|
2784
|
-
Extension.prototype
|
|
2785
|
-
_super.prototype
|
|
2859
|
+
Extension.prototype.destroy = function () {
|
|
2860
|
+
_super.prototype.destroy.call(this);
|
|
2786
2861
|
};
|
|
2787
2862
|
return Extension;
|
|
2788
2863
|
}(INode));
|
|
@@ -2795,24 +2870,25 @@ var Extension = /** @class */ (function (_super) {
|
|
|
2795
2870
|
var Component = /** @class */ (function (_super) {
|
|
2796
2871
|
__extends(Component, _super);
|
|
2797
2872
|
function Component() {
|
|
2798
|
-
|
|
2799
|
-
_this.$seal();
|
|
2800
|
-
return _this;
|
|
2873
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2801
2874
|
}
|
|
2802
|
-
Component.prototype
|
|
2803
|
-
_super.prototype
|
|
2804
|
-
if (this
|
|
2805
|
-
throw userError("
|
|
2875
|
+
Component.prototype.ready = function () {
|
|
2876
|
+
_super.prototype.ready.call(this);
|
|
2877
|
+
if (this.children.size !== 1) {
|
|
2878
|
+
throw userError("Component must have a child only", "dom-error");
|
|
2806
2879
|
}
|
|
2807
|
-
var child = this
|
|
2880
|
+
var child = this.lastChild;
|
|
2808
2881
|
if (child instanceof Tag || child instanceof Component) {
|
|
2809
2882
|
var $ = this.$;
|
|
2810
2883
|
$.node = child.node;
|
|
2811
2884
|
}
|
|
2812
2885
|
else {
|
|
2813
|
-
throw userError("
|
|
2886
|
+
throw userError("Component child must be Tag or Component", "dom-error");
|
|
2814
2887
|
}
|
|
2815
2888
|
};
|
|
2889
|
+
Component.prototype.preinit = function (app, parent) {
|
|
2890
|
+
this.$.preinit(app, parent);
|
|
2891
|
+
};
|
|
2816
2892
|
return Component;
|
|
2817
2893
|
}(Extension));
|
|
2818
2894
|
|
|
@@ -2825,22 +2901,27 @@ var SwitchedNodePrivate = /** @class */ (function (_super) {
|
|
|
2825
2901
|
__extends(SwitchedNodePrivate, _super);
|
|
2826
2902
|
function SwitchedNodePrivate() {
|
|
2827
2903
|
var _this = this; _super.call(this);
|
|
2828
|
-
|
|
2904
|
+
/**
|
|
2905
|
+
* Array of possible cases
|
|
2906
|
+
* @type {Array<{cond : IValue<boolean>, cb : function(Fragment)}>}
|
|
2907
|
+
*/
|
|
2908
|
+
_this.cases = [];
|
|
2909
|
+
_this.seal();
|
|
2829
2910
|
return _this;
|
|
2830
2911
|
}
|
|
2831
2912
|
/**
|
|
2832
2913
|
* Runs GC
|
|
2833
2914
|
*/
|
|
2834
|
-
SwitchedNodePrivate.prototype
|
|
2915
|
+
SwitchedNodePrivate.prototype.destroy = function () {
|
|
2835
2916
|
this.cases.forEach(function (c) {
|
|
2836
2917
|
delete c.cond;
|
|
2837
2918
|
delete c.cb;
|
|
2838
2919
|
});
|
|
2839
2920
|
this.cases.splice(0);
|
|
2840
|
-
_super.prototype
|
|
2921
|
+
_super.prototype.destroy.call(this);
|
|
2841
2922
|
};
|
|
2842
2923
|
return SwitchedNodePrivate;
|
|
2843
|
-
}(
|
|
2924
|
+
}(FragmentPrivate));
|
|
2844
2925
|
|
|
2845
2926
|
/**
|
|
2846
2927
|
* Defines a node witch can switch its children conditionally
|
|
@@ -2851,7 +2932,7 @@ var SwitchedNode = /** @class */ (function (_super) {
|
|
|
2851
2932
|
* Constructs a switch node and define a sync function
|
|
2852
2933
|
*/
|
|
2853
2934
|
function SwitchedNode() {
|
|
2854
|
-
var _this = _super.call(this, new SwitchedNodePrivate) || this;
|
|
2935
|
+
var _this = _super.call(this, {}, new SwitchedNodePrivate) || this;
|
|
2855
2936
|
_this.$.sync = function () {
|
|
2856
2937
|
var $ = _this.$;
|
|
2857
2938
|
var i = 0;
|
|
@@ -2863,10 +2944,10 @@ var SwitchedNode = /** @class */ (function (_super) {
|
|
|
2863
2944
|
if (i === $.index) {
|
|
2864
2945
|
return;
|
|
2865
2946
|
}
|
|
2866
|
-
if (
|
|
2867
|
-
|
|
2868
|
-
_this
|
|
2869
|
-
|
|
2947
|
+
if (_this.lastChild) {
|
|
2948
|
+
_this.lastChild.destroy();
|
|
2949
|
+
_this.children.clear();
|
|
2950
|
+
_this.lastChild = null;
|
|
2870
2951
|
}
|
|
2871
2952
|
if (i !== $.cases.length) {
|
|
2872
2953
|
$.index = i;
|
|
@@ -2876,47 +2957,43 @@ var SwitchedNode = /** @class */ (function (_super) {
|
|
|
2876
2957
|
$.index = -1;
|
|
2877
2958
|
}
|
|
2878
2959
|
};
|
|
2879
|
-
_this
|
|
2960
|
+
_this.seal();
|
|
2880
2961
|
return _this;
|
|
2881
2962
|
}
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
SwitchedNode.prototype.setCases = function (cases) {
|
|
2887
|
-
var $ = this.$;
|
|
2888
|
-
$.cases = __spreadArray([], cases, true);
|
|
2963
|
+
SwitchedNode.prototype.addCase = function (case_) {
|
|
2964
|
+
this.$.cases.push(case_);
|
|
2965
|
+
case_.cond.on(this.$.sync);
|
|
2966
|
+
this.$.sync();
|
|
2889
2967
|
};
|
|
2890
2968
|
/**
|
|
2891
2969
|
* Creates a child node
|
|
2892
2970
|
* @param cb {function(Fragment)} Call-back
|
|
2893
2971
|
*/
|
|
2894
2972
|
SwitchedNode.prototype.createChild = function (cb) {
|
|
2895
|
-
var node = new Fragment();
|
|
2896
|
-
node
|
|
2897
|
-
node
|
|
2898
|
-
node
|
|
2899
|
-
this
|
|
2900
|
-
this.$children.push(node);
|
|
2973
|
+
var node = new Fragment({});
|
|
2974
|
+
node.preinit(this.$.app, this);
|
|
2975
|
+
node.init();
|
|
2976
|
+
this.lastChild = node;
|
|
2977
|
+
this.children.add(node);
|
|
2901
2978
|
cb(node);
|
|
2902
2979
|
};
|
|
2903
|
-
SwitchedNode.prototype
|
|
2980
|
+
SwitchedNode.prototype.ready = function () {
|
|
2904
2981
|
var $ = this.$;
|
|
2905
|
-
_super.prototype.$ready.call(this);
|
|
2906
2982
|
$.cases.forEach(function (c) {
|
|
2907
2983
|
c.cond.on($.sync);
|
|
2908
2984
|
});
|
|
2909
2985
|
$.sync();
|
|
2910
2986
|
};
|
|
2911
|
-
SwitchedNode.prototype
|
|
2987
|
+
SwitchedNode.prototype.destroy = function () {
|
|
2912
2988
|
var $ = this.$;
|
|
2913
2989
|
$.cases.forEach(function (c) {
|
|
2914
2990
|
c.cond.off($.sync);
|
|
2915
2991
|
});
|
|
2916
|
-
_super.prototype
|
|
2992
|
+
_super.prototype.destroy.call(this);
|
|
2917
2993
|
};
|
|
2918
2994
|
return SwitchedNode;
|
|
2919
2995
|
}(Fragment));
|
|
2996
|
+
|
|
2920
2997
|
/**
|
|
2921
2998
|
* The private part of a text node
|
|
2922
2999
|
*/
|
|
@@ -2924,7 +3001,7 @@ var DebugPrivate = /** @class */ (function (_super) {
|
|
|
2924
3001
|
__extends(DebugPrivate, _super);
|
|
2925
3002
|
function DebugPrivate() {
|
|
2926
3003
|
var _this = this; _super.call(this);
|
|
2927
|
-
_this
|
|
3004
|
+
_this.seal();
|
|
2928
3005
|
return _this;
|
|
2929
3006
|
}
|
|
2930
3007
|
/**
|
|
@@ -2940,14 +3017,14 @@ var DebugPrivate = /** @class */ (function (_super) {
|
|
|
2940
3017
|
this.bindings.add(new Expression(function (v) {
|
|
2941
3018
|
_this.node.replaceData(0, -1, v);
|
|
2942
3019
|
}, true, text));
|
|
2943
|
-
this.parent
|
|
3020
|
+
this.parent.appendNode(this.node);
|
|
2944
3021
|
};
|
|
2945
3022
|
/**
|
|
2946
3023
|
* Clear node data
|
|
2947
3024
|
*/
|
|
2948
|
-
DebugPrivate.prototype
|
|
3025
|
+
DebugPrivate.prototype.destroy = function () {
|
|
2949
3026
|
this.node.remove();
|
|
2950
|
-
_super.prototype
|
|
3027
|
+
_super.prototype.destroy.call(this);
|
|
2951
3028
|
};
|
|
2952
3029
|
return DebugPrivate;
|
|
2953
3030
|
}(FragmentPrivate));
|
|
@@ -2960,16 +3037,16 @@ var DebugPrivate = /** @class */ (function (_super) {
|
|
|
2960
3037
|
var DebugNode = /** @class */ (function (_super) {
|
|
2961
3038
|
__extends(DebugNode, _super);
|
|
2962
3039
|
function DebugNode() {
|
|
2963
|
-
var _this =
|
|
3040
|
+
var _this = _super.call(this, {}) || this;
|
|
2964
3041
|
/**
|
|
2965
3042
|
* private data
|
|
2966
3043
|
* @type {DebugNode}
|
|
2967
3044
|
*/
|
|
2968
3045
|
_this.$ = new DebugPrivate();
|
|
2969
|
-
_this
|
|
3046
|
+
_this.seal();
|
|
2970
3047
|
return _this;
|
|
2971
3048
|
}
|
|
2972
|
-
DebugNode.prototype
|
|
3049
|
+
DebugNode.prototype.preinit = function (app, parent, text) {
|
|
2973
3050
|
var $ = this.$;
|
|
2974
3051
|
if (!text) {
|
|
2975
3052
|
throw internalError('wrong DebugNode::$preninit call');
|
|
@@ -2979,9 +3056,9 @@ var DebugNode = /** @class */ (function (_super) {
|
|
|
2979
3056
|
/**
|
|
2980
3057
|
* Runs garbage collector
|
|
2981
3058
|
*/
|
|
2982
|
-
DebugNode.prototype
|
|
2983
|
-
this
|
|
2984
|
-
_super.prototype
|
|
3059
|
+
DebugNode.prototype.destroy = function () {
|
|
3060
|
+
this.$.destroy();
|
|
3061
|
+
_super.prototype.destroy.call(this);
|
|
2985
3062
|
};
|
|
2986
3063
|
return DebugNode;
|
|
2987
3064
|
}(Fragment));
|
|
@@ -2997,6 +3074,7 @@ window.Tag = Tag;
|
|
|
2997
3074
|
window.Extension = Extension;
|
|
2998
3075
|
window.Component = Component;
|
|
2999
3076
|
window.SwitchedNodePrivate = SwitchedNodePrivate;
|
|
3077
|
+
window.SwitchedNode = SwitchedNode;
|
|
3000
3078
|
window.DebugPrivate = DebugPrivate;
|
|
3001
3079
|
window.DebugNode = DebugNode;
|
|
3002
3080
|
|
|
@@ -3009,12 +3087,12 @@ window.DebugNode = DebugNode;
|
|
|
3009
3087
|
var AppNode = /** @class */ (function (_super) {
|
|
3010
3088
|
__extends(AppNode, _super);
|
|
3011
3089
|
/**
|
|
3012
|
-
* @param
|
|
3090
|
+
* @param input
|
|
3013
3091
|
*/
|
|
3014
|
-
function AppNode(
|
|
3015
|
-
var _this =
|
|
3016
|
-
_this
|
|
3017
|
-
_this
|
|
3092
|
+
function AppNode(input) {
|
|
3093
|
+
var _this = _super.call(this, input) || this;
|
|
3094
|
+
_this.debugUi = input.debugUi || false;
|
|
3095
|
+
_this.seal();
|
|
3018
3096
|
return _this;
|
|
3019
3097
|
}
|
|
3020
3098
|
return AppNode;
|
|
@@ -3030,25 +3108,40 @@ var App = /** @class */ (function (_super) {
|
|
|
3030
3108
|
/**
|
|
3031
3109
|
* Constructs an app node
|
|
3032
3110
|
* @param node {Element} The root of application
|
|
3033
|
-
* @param
|
|
3111
|
+
* @param input
|
|
3034
3112
|
*/
|
|
3035
|
-
function App(node,
|
|
3036
|
-
var _this = _super.call(this,
|
|
3113
|
+
function App(node, input) {
|
|
3114
|
+
var _this = _super.call(this, input) || this;
|
|
3037
3115
|
_this.$.node = node;
|
|
3038
|
-
_this
|
|
3039
|
-
_this
|
|
3116
|
+
_this.preinit(_this, _this);
|
|
3117
|
+
_this.init();
|
|
3118
|
+
_this.seal();
|
|
3040
3119
|
return _this;
|
|
3041
3120
|
}
|
|
3042
|
-
App.prototype
|
|
3043
|
-
|
|
3044
|
-
$.app.$run.appendChild($.node, node);
|
|
3121
|
+
App.prototype.appendNode = function (node) {
|
|
3122
|
+
this.$.node.appendChild(node);
|
|
3045
3123
|
};
|
|
3046
3124
|
return App;
|
|
3047
3125
|
}(AppNode));
|
|
3048
3126
|
|
|
3127
|
+
var Portal = /** @class */ (function (_super) {
|
|
3128
|
+
__extends(Portal, _super);
|
|
3129
|
+
function Portal(input) {
|
|
3130
|
+
var _this = _super.call(this, input) || this;
|
|
3131
|
+
_this.$.node = input.node;
|
|
3132
|
+
_this.seal();
|
|
3133
|
+
return _this;
|
|
3134
|
+
}
|
|
3135
|
+
Portal.prototype.appendNode = function (node) {
|
|
3136
|
+
this.$.node.appendChild(node);
|
|
3137
|
+
};
|
|
3138
|
+
return Portal;
|
|
3139
|
+
}(AppNode));
|
|
3140
|
+
|
|
3049
3141
|
|
|
3050
3142
|
window.AppNode = AppNode;
|
|
3051
3143
|
window.App = App;
|
|
3144
|
+
window.Portal = Portal;
|
|
3052
3145
|
|
|
3053
3146
|
// ./lib-es5/node/interceptor.js
|
|
3054
3147
|
/**
|
|
@@ -3100,9 +3193,9 @@ var Interceptor = /** @class */ (function (_super) {
|
|
|
3100
3193
|
signal.unsubscribe(handler);
|
|
3101
3194
|
});
|
|
3102
3195
|
};
|
|
3103
|
-
Interceptor.prototype
|
|
3196
|
+
Interceptor.prototype.destroy = function () {
|
|
3104
3197
|
var _this = this;
|
|
3105
|
-
_super.prototype
|
|
3198
|
+
_super.prototype.destroy.call(this);
|
|
3106
3199
|
this.signals.forEach(function (signal) {
|
|
3107
3200
|
_this.handlers.forEach(function (handler) {
|
|
3108
3201
|
signal.unsubscribe(handler);
|
|
@@ -3133,7 +3226,7 @@ var InterceptorNode = /** @class */ (function (_super) {
|
|
|
3133
3226
|
_this.slot = new Slot;
|
|
3134
3227
|
return _this;
|
|
3135
3228
|
}
|
|
3136
|
-
InterceptorNode.prototype
|
|
3229
|
+
InterceptorNode.prototype.compose = function () {
|
|
3137
3230
|
this.slot.release(this, this.interceptor);
|
|
3138
3231
|
};
|
|
3139
3232
|
return InterceptorNode;
|
|
@@ -3158,23 +3251,23 @@ var AttributeBinding = /** @class */ (function (_super) {
|
|
|
3158
3251
|
* @param value {IValue} value to bind
|
|
3159
3252
|
*/
|
|
3160
3253
|
function AttributeBinding(node, name, value) {
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
/**
|
|
3164
|
-
* Generates a function which updates the attribute value
|
|
3165
|
-
* @param name {String} The name of attribute
|
|
3166
|
-
* @returns {Function} a function which will update attribute value
|
|
3167
|
-
*/
|
|
3168
|
-
AttributeBinding.prototype.bound = function (name) {
|
|
3169
|
-
return function (node, value) {
|
|
3254
|
+
var _this = _super.call(this, value) || this;
|
|
3255
|
+
_this.init(function (value) {
|
|
3170
3256
|
if (value) {
|
|
3171
|
-
|
|
3257
|
+
if (typeof value === 'boolean') {
|
|
3258
|
+
node.node.setAttribute(name, "");
|
|
3259
|
+
}
|
|
3260
|
+
else {
|
|
3261
|
+
node.node.setAttribute(name, "".concat(value));
|
|
3262
|
+
}
|
|
3172
3263
|
}
|
|
3173
3264
|
else {
|
|
3174
|
-
node.
|
|
3265
|
+
node.node.removeAttribute(name);
|
|
3175
3266
|
}
|
|
3176
|
-
};
|
|
3177
|
-
|
|
3267
|
+
});
|
|
3268
|
+
_this.seal();
|
|
3269
|
+
return _this;
|
|
3270
|
+
}
|
|
3178
3271
|
return AttributeBinding;
|
|
3179
3272
|
}(Binding));
|
|
3180
3273
|
|
|
@@ -3196,20 +3289,15 @@ var StyleBinding = /** @class */ (function (_super) {
|
|
|
3196
3289
|
* @param value {IValue} the value to bind
|
|
3197
3290
|
*/
|
|
3198
3291
|
function StyleBinding(node, name, value) {
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
/**
|
|
3202
|
-
* Generates a function to update style property value
|
|
3203
|
-
* @param name {string}
|
|
3204
|
-
* @returns {Function} a function to update style property
|
|
3205
|
-
*/
|
|
3206
|
-
StyleBinding.prototype.bound = function (name) {
|
|
3207
|
-
return function (node, value) {
|
|
3292
|
+
var _this = _super.call(this, value) || this;
|
|
3293
|
+
_this.init(function (value) {
|
|
3208
3294
|
if (node.node instanceof HTMLElement) {
|
|
3209
|
-
node.
|
|
3295
|
+
node.node.style.setProperty(name, value);
|
|
3210
3296
|
}
|
|
3211
|
-
};
|
|
3212
|
-
|
|
3297
|
+
});
|
|
3298
|
+
_this.seal();
|
|
3299
|
+
return _this;
|
|
3300
|
+
}
|
|
3213
3301
|
return StyleBinding;
|
|
3214
3302
|
}(Binding));
|
|
3215
3303
|
|
|
@@ -3217,62 +3305,59 @@ var StyleBinding = /** @class */ (function (_super) {
|
|
|
3217
3305
|
window.StyleBinding = StyleBinding;
|
|
3218
3306
|
|
|
3219
3307
|
// ./lib-es5/binding/class.js
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3308
|
+
function addClass(node, cl) {
|
|
3309
|
+
node.node.classList.add(cl);
|
|
3310
|
+
}
|
|
3311
|
+
function removeClass(node, cl) {
|
|
3312
|
+
node.node.classList.remove(cl);
|
|
3313
|
+
}
|
|
3314
|
+
var StaticClassBinding = /** @class */ (function (_super) {
|
|
3315
|
+
__extends(StaticClassBinding, _super);
|
|
3316
|
+
function StaticClassBinding(node, name, value) {
|
|
3317
|
+
var _this = _super.call(this, value) || this;
|
|
3318
|
+
_this.current = false;
|
|
3319
|
+
_this.init(function (value) {
|
|
3320
|
+
if (value !== _this.current) {
|
|
3321
|
+
if (value) {
|
|
3322
|
+
addClass(node, name);
|
|
3323
|
+
}
|
|
3324
|
+
else {
|
|
3325
|
+
removeClass(node, name);
|
|
3326
|
+
}
|
|
3327
|
+
_this.current = value;
|
|
3328
|
+
}
|
|
3329
|
+
});
|
|
3330
|
+
_this.seal();
|
|
3236
3331
|
return _this;
|
|
3237
3332
|
}
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
var
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
}
|
|
3251
|
-
return function (node, value) {
|
|
3252
|
-
if (value !== current) {
|
|
3253
|
-
if (typeof current === "string" && current !== "") {
|
|
3254
|
-
removeClass(node, current);
|
|
3255
|
-
}
|
|
3256
|
-
if (typeof value === "boolean") {
|
|
3257
|
-
if (value) {
|
|
3258
|
-
addClass(node, name);
|
|
3259
|
-
}
|
|
3260
|
-
else {
|
|
3261
|
-
removeClass(node, name);
|
|
3262
|
-
}
|
|
3333
|
+
return StaticClassBinding;
|
|
3334
|
+
}(Binding));
|
|
3335
|
+
|
|
3336
|
+
var DynamicalClassBinding = /** @class */ (function (_super) {
|
|
3337
|
+
__extends(DynamicalClassBinding, _super);
|
|
3338
|
+
function DynamicalClassBinding(node, value) {
|
|
3339
|
+
var _this = _super.call(this, value) || this;
|
|
3340
|
+
_this.current = "";
|
|
3341
|
+
_this.init(function (value) {
|
|
3342
|
+
if (_this.current != value) {
|
|
3343
|
+
if (_this.current.length) {
|
|
3344
|
+
removeClass(node, _this.current);
|
|
3263
3345
|
}
|
|
3264
|
-
|
|
3346
|
+
if (value.length) {
|
|
3265
3347
|
addClass(node, value);
|
|
3266
3348
|
}
|
|
3267
|
-
current = value;
|
|
3349
|
+
_this.current = value;
|
|
3268
3350
|
}
|
|
3269
|
-
};
|
|
3270
|
-
|
|
3271
|
-
|
|
3351
|
+
});
|
|
3352
|
+
_this.seal();
|
|
3353
|
+
return _this;
|
|
3354
|
+
}
|
|
3355
|
+
return DynamicalClassBinding;
|
|
3272
3356
|
}(Binding));
|
|
3273
3357
|
|
|
3274
3358
|
|
|
3275
|
-
window.
|
|
3359
|
+
window.StaticClassBinding = StaticClassBinding;
|
|
3360
|
+
window.DynamicalClassBinding = DynamicalClassBinding;
|
|
3276
3361
|
|
|
3277
3362
|
// ./lib-es5/views/repeat-node.js
|
|
3278
3363
|
/**
|
|
@@ -3289,12 +3374,12 @@ var RepeatNodePrivate = /** @class */ (function (_super) {
|
|
|
3289
3374
|
* @type {Map}
|
|
3290
3375
|
*/
|
|
3291
3376
|
_this.nodes = new Map();
|
|
3292
|
-
_this
|
|
3377
|
+
_this.seal();
|
|
3293
3378
|
return _this;
|
|
3294
3379
|
}
|
|
3295
|
-
RepeatNodePrivate.prototype
|
|
3380
|
+
RepeatNodePrivate.prototype.destroy = function () {
|
|
3296
3381
|
this.nodes.clear();
|
|
3297
|
-
_super.prototype
|
|
3382
|
+
_super.prototype.destroy.call(this);
|
|
3298
3383
|
};
|
|
3299
3384
|
return RepeatNodePrivate;
|
|
3300
3385
|
}(INodePrivate));
|
|
@@ -3306,82 +3391,43 @@ var RepeatNodePrivate = /** @class */ (function (_super) {
|
|
|
3306
3391
|
*/
|
|
3307
3392
|
var RepeatNode = /** @class */ (function (_super) {
|
|
3308
3393
|
__extends(RepeatNode, _super);
|
|
3309
|
-
function RepeatNode($) {
|
|
3310
|
-
var _this = _super.call(this, $
|
|
3394
|
+
function RepeatNode(input, $) {
|
|
3395
|
+
var _this = _super.call(this, input, $) || this;
|
|
3311
3396
|
/**
|
|
3312
3397
|
* If false will use timeout executor, otherwise the app executor
|
|
3313
3398
|
*/
|
|
3314
3399
|
_this.freezeUi = true;
|
|
3315
|
-
_this.slot = new Slot;
|
|
3316
3400
|
return _this;
|
|
3317
3401
|
}
|
|
3318
|
-
RepeatNode.prototype.createChild = function (id, item, before) {
|
|
3319
|
-
|
|
3320
|
-
var _this = this;
|
|
3321
|
-
var node = new Fragment();
|
|
3322
|
-
// eslint-disable-next-line
|
|
3323
|
-
// @ts-ignore
|
|
3324
|
-
var $ = node.$;
|
|
3402
|
+
RepeatNode.prototype.createChild = function (opts, id, item, before) {
|
|
3403
|
+
var node = new Fragment({});
|
|
3325
3404
|
this.destroyChild(id, item);
|
|
3326
3405
|
if (before) {
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
// @ts-ignore
|
|
3330
|
-
$.prev = before.$.prev;
|
|
3331
|
-
// eslint-disable-next-line
|
|
3332
|
-
// @ts-ignore
|
|
3333
|
-
before.$.prev = node;
|
|
3334
|
-
if ($.prev) {
|
|
3335
|
-
// eslint-disable-next-line
|
|
3336
|
-
// @ts-ignore
|
|
3337
|
-
$.prev.$.next = node;
|
|
3338
|
-
}
|
|
3339
|
-
this.$children.splice(this.$children.indexOf(before), 0, node);
|
|
3406
|
+
this.children.add(node);
|
|
3407
|
+
before.insertBefore(node);
|
|
3340
3408
|
}
|
|
3341
3409
|
else {
|
|
3342
|
-
var lastChild = this
|
|
3410
|
+
var lastChild = this.lastChild;
|
|
3343
3411
|
if (lastChild) {
|
|
3344
|
-
|
|
3345
|
-
// @ts-ignore
|
|
3346
|
-
lastChild.$.next = node;
|
|
3412
|
+
lastChild.insertAfter(node);
|
|
3347
3413
|
}
|
|
3348
|
-
|
|
3349
|
-
this.$children.push(node);
|
|
3350
|
-
}
|
|
3351
|
-
node.$preinit(this.$.app, this);
|
|
3352
|
-
node.$init();
|
|
3353
|
-
var callback = function () {
|
|
3354
|
-
_this.slot.release(node, item, id);
|
|
3355
|
-
node.$ready();
|
|
3356
|
-
};
|
|
3357
|
-
if (this.freezeUi) {
|
|
3358
|
-
this.$.app.$run.callCallback(callback);
|
|
3359
|
-
}
|
|
3360
|
-
else {
|
|
3361
|
-
timeoutExecutor.callCallback(callback);
|
|
3414
|
+
this.children.add(node);
|
|
3362
3415
|
}
|
|
3416
|
+
this.lastChild = node;
|
|
3417
|
+
node.preinit(this.$.app, this);
|
|
3418
|
+
node.init();
|
|
3419
|
+
opts.slot && opts.slot(node, item, id);
|
|
3420
|
+
node.ready();
|
|
3363
3421
|
this.$.nodes.set(id, node);
|
|
3364
3422
|
};
|
|
3365
3423
|
RepeatNode.prototype.destroyChild = function (id, item) {
|
|
3366
3424
|
var $ = this.$;
|
|
3367
3425
|
var child = $.nodes.get(id);
|
|
3368
3426
|
if (child) {
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
var $_1 = child.$;
|
|
3372
|
-
if ($_1.prev) {
|
|
3373
|
-
// eslint-disable-next-line
|
|
3374
|
-
// @ts-ignore
|
|
3375
|
-
$_1.prev.$.next = $_1.next;
|
|
3376
|
-
}
|
|
3377
|
-
if ($_1.next) {
|
|
3378
|
-
// eslint-disable-next-line
|
|
3379
|
-
// @ts-ignore
|
|
3380
|
-
$_1.next.$.prev = $_1.prev;
|
|
3381
|
-
}
|
|
3382
|
-
child.$destroy();
|
|
3427
|
+
child.remove();
|
|
3428
|
+
child.destroy();
|
|
3383
3429
|
this.$.nodes.delete(id);
|
|
3384
|
-
this
|
|
3430
|
+
this.children.delete(child);
|
|
3385
3431
|
}
|
|
3386
3432
|
};
|
|
3387
3433
|
return RepeatNode;
|
|
@@ -3405,7 +3451,7 @@ var RepeaterPrivate = /** @class */ (function (_super) {
|
|
|
3405
3451
|
* Current count of child nodes
|
|
3406
3452
|
*/
|
|
3407
3453
|
_this.currentCount = 0;
|
|
3408
|
-
_this
|
|
3454
|
+
_this.seal();
|
|
3409
3455
|
return _this;
|
|
3410
3456
|
}
|
|
3411
3457
|
return RepeaterPrivate;
|
|
@@ -3424,7 +3470,7 @@ var Repeater = /** @class */ (function (_super) {
|
|
|
3424
3470
|
* The count of children
|
|
3425
3471
|
*/
|
|
3426
3472
|
_this.count = new Reference(0);
|
|
3427
|
-
_this
|
|
3473
|
+
_this.seal();
|
|
3428
3474
|
return _this;
|
|
3429
3475
|
}
|
|
3430
3476
|
/**
|
|
@@ -3444,18 +3490,18 @@ var Repeater = /** @class */ (function (_super) {
|
|
|
3444
3490
|
}
|
|
3445
3491
|
$.currentCount = number;
|
|
3446
3492
|
};
|
|
3447
|
-
Repeater.prototype
|
|
3493
|
+
Repeater.prototype.created = function () {
|
|
3448
3494
|
var $ = this.$;
|
|
3449
|
-
_super.prototype
|
|
3495
|
+
_super.prototype.created.call(this);
|
|
3450
3496
|
$.updateHandler = this.changeCount.bind(this);
|
|
3451
3497
|
this.count.on($.updateHandler);
|
|
3452
3498
|
};
|
|
3453
|
-
Repeater.prototype
|
|
3499
|
+
Repeater.prototype.ready = function () {
|
|
3454
3500
|
this.changeCount(this.count.$);
|
|
3455
3501
|
};
|
|
3456
|
-
Repeater.prototype
|
|
3502
|
+
Repeater.prototype.destroy = function () {
|
|
3457
3503
|
var $ = this.$;
|
|
3458
|
-
_super.prototype
|
|
3504
|
+
_super.prototype.destroy.call(this);
|
|
3459
3505
|
this.count.off($.updateHandler);
|
|
3460
3506
|
};
|
|
3461
3507
|
return Repeater;
|
|
@@ -3475,7 +3521,7 @@ var BaseViewPrivate = /** @class */ (function (_super) {
|
|
|
3475
3521
|
__extends(BaseViewPrivate, _super);
|
|
3476
3522
|
function BaseViewPrivate() {
|
|
3477
3523
|
var _this = this; _super.call(this);
|
|
3478
|
-
_this
|
|
3524
|
+
_this.seal();
|
|
3479
3525
|
return _this;
|
|
3480
3526
|
}
|
|
3481
3527
|
return BaseViewPrivate;
|
|
@@ -3489,35 +3535,24 @@ var BaseViewPrivate = /** @class */ (function (_super) {
|
|
|
3489
3535
|
*/
|
|
3490
3536
|
var BaseView = /** @class */ (function (_super) {
|
|
3491
3537
|
__extends(BaseView, _super);
|
|
3492
|
-
function BaseView($
|
|
3493
|
-
|
|
3494
|
-
|
|
3538
|
+
function BaseView(input, $) {
|
|
3539
|
+
return _super.call(this, input, $ || new BaseViewPrivate) || this;
|
|
3540
|
+
}
|
|
3541
|
+
BaseView.prototype.compose = function (input) {
|
|
3542
|
+
var _this = this;
|
|
3543
|
+
var $ = this.$;
|
|
3495
3544
|
$.addHandler = function (id, item) {
|
|
3496
|
-
_this.createChild(id, item);
|
|
3545
|
+
_this.createChild(input, id, item);
|
|
3497
3546
|
};
|
|
3498
3547
|
$.removeHandler = function (id, item) {
|
|
3499
3548
|
_this.destroyChild(id, item);
|
|
3500
3549
|
};
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
BaseView.prototype.$ready = function () {
|
|
3508
|
-
var $ = this.$;
|
|
3509
|
-
this.model.listener.onAdd($.addHandler);
|
|
3510
|
-
this.model.listener.onRemove($.removeHandler);
|
|
3511
|
-
_super.prototype.$ready.call(this);
|
|
3512
|
-
};
|
|
3513
|
-
/**
|
|
3514
|
-
* Handles destroy event
|
|
3515
|
-
*/
|
|
3516
|
-
BaseView.prototype.$destroy = function () {
|
|
3517
|
-
var $ = this.$;
|
|
3518
|
-
this.model.listener.offAdd($.addHandler);
|
|
3519
|
-
this.model.listener.offRemove($.removeHandler);
|
|
3520
|
-
_super.prototype.$destroy.call(this);
|
|
3550
|
+
input.model.listener.onAdd($.addHandler);
|
|
3551
|
+
input.model.listener.onRemove($.removeHandler);
|
|
3552
|
+
this.runOnDestroy(function () {
|
|
3553
|
+
input.model.listener.offAdd($.addHandler);
|
|
3554
|
+
input.model.listener.offRemove($.removeHandler);
|
|
3555
|
+
});
|
|
3521
3556
|
};
|
|
3522
3557
|
return BaseView;
|
|
3523
3558
|
}(RepeatNode));
|
|
@@ -3534,20 +3569,18 @@ window.BaseView = BaseView;
|
|
|
3534
3569
|
*/
|
|
3535
3570
|
var ArrayView = /** @class */ (function (_super) {
|
|
3536
3571
|
__extends(ArrayView, _super);
|
|
3537
|
-
function ArrayView(
|
|
3538
|
-
|
|
3539
|
-
_this.model = model;
|
|
3540
|
-
return _this;
|
|
3572
|
+
function ArrayView() {
|
|
3573
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3541
3574
|
}
|
|
3542
|
-
ArrayView.prototype.createChild = function (id, item, before) {
|
|
3543
|
-
_super.prototype.createChild.call(this, item, item, before || this.$.nodes.get(id));
|
|
3575
|
+
ArrayView.prototype.createChild = function (input, id, item, before) {
|
|
3576
|
+
_super.prototype.createChild.call(this, input, item, item, before || this.$.nodes.get(id));
|
|
3544
3577
|
};
|
|
3545
|
-
ArrayView.prototype
|
|
3578
|
+
ArrayView.prototype.compose = function (input) {
|
|
3546
3579
|
var _this = this;
|
|
3547
|
-
|
|
3548
|
-
|
|
3580
|
+
_super.prototype.compose.call(this, input);
|
|
3581
|
+
input.model.forEach(function (item) {
|
|
3582
|
+
_this.createChild(input, item, item);
|
|
3549
3583
|
});
|
|
3550
|
-
_super.prototype.$ready.call(this);
|
|
3551
3584
|
};
|
|
3552
3585
|
return ArrayView;
|
|
3553
3586
|
}(BaseView));
|
|
@@ -3564,24 +3597,19 @@ window.ArrayView = ArrayView;
|
|
|
3564
3597
|
var Watch = /** @class */ (function (_super) {
|
|
3565
3598
|
__extends(Watch, _super);
|
|
3566
3599
|
function Watch() {
|
|
3567
|
-
|
|
3568
|
-
_this.slot = new Slot;
|
|
3569
|
-
_this.model = _this.$ref(null);
|
|
3570
|
-
_this.$seal();
|
|
3571
|
-
return _this;
|
|
3600
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3572
3601
|
}
|
|
3573
|
-
Watch.prototype
|
|
3602
|
+
Watch.prototype.compose = function (input) {
|
|
3574
3603
|
var _this = this;
|
|
3575
|
-
this
|
|
3576
|
-
_this
|
|
3577
|
-
child
|
|
3604
|
+
this.watch(function (value) {
|
|
3605
|
+
_this.children.forEach(function (child) {
|
|
3606
|
+
child.destroy();
|
|
3578
3607
|
});
|
|
3579
|
-
_this
|
|
3580
|
-
_this.
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
this.slot.release(this, this.model.$);
|
|
3608
|
+
_this.children.clear();
|
|
3609
|
+
_this.lastChild = null;
|
|
3610
|
+
input.slot && input.slot(_this, value);
|
|
3611
|
+
}, input.model);
|
|
3612
|
+
input.slot(this, input.model.$);
|
|
3585
3613
|
};
|
|
3586
3614
|
return Watch;
|
|
3587
3615
|
}(Fragment));
|
|
@@ -3597,17 +3625,16 @@ window.Watch = Watch;
|
|
|
3597
3625
|
*/
|
|
3598
3626
|
var ObjectView = /** @class */ (function (_super) {
|
|
3599
3627
|
__extends(ObjectView, _super);
|
|
3600
|
-
function ObjectView(
|
|
3601
|
-
|
|
3602
|
-
_this.model = model;
|
|
3603
|
-
return _this;
|
|
3628
|
+
function ObjectView() {
|
|
3629
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3604
3630
|
}
|
|
3605
|
-
ObjectView.prototype
|
|
3606
|
-
|
|
3631
|
+
ObjectView.prototype.compose = function (input) {
|
|
3632
|
+
_super.prototype.compose.call(this, input);
|
|
3633
|
+
var obj = input.model.proxy();
|
|
3607
3634
|
for (var key in obj) {
|
|
3608
|
-
this.createChild(key, obj[key]);
|
|
3635
|
+
this.createChild(input, key, obj[key]);
|
|
3609
3636
|
}
|
|
3610
|
-
_super.prototype
|
|
3637
|
+
_super.prototype.ready.call(this);
|
|
3611
3638
|
};
|
|
3612
3639
|
return ObjectView;
|
|
3613
3640
|
}(BaseView));
|
|
@@ -3623,18 +3650,15 @@ window.ObjectView = ObjectView;
|
|
|
3623
3650
|
*/
|
|
3624
3651
|
var MapView = /** @class */ (function (_super) {
|
|
3625
3652
|
__extends(MapView, _super);
|
|
3626
|
-
function MapView(
|
|
3627
|
-
|
|
3628
|
-
_this.model = model;
|
|
3629
|
-
return _this;
|
|
3653
|
+
function MapView() {
|
|
3654
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3630
3655
|
}
|
|
3631
|
-
MapView.prototype
|
|
3656
|
+
MapView.prototype.compose = function (input) {
|
|
3632
3657
|
var _this = this;
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
_this.createChild(key, value);
|
|
3658
|
+
_super.prototype.compose.call(this, input);
|
|
3659
|
+
input.model.forEach(function (value, key) {
|
|
3660
|
+
_this.createChild(input, key, value);
|
|
3636
3661
|
});
|
|
3637
|
-
_super.prototype.$ready.call(this);
|
|
3638
3662
|
};
|
|
3639
3663
|
return MapView;
|
|
3640
3664
|
}(BaseView));
|
|
@@ -3650,21 +3674,16 @@ window.MapView = MapView;
|
|
|
3650
3674
|
*/
|
|
3651
3675
|
var SetView = /** @class */ (function (_super) {
|
|
3652
3676
|
__extends(SetView, _super);
|
|
3653
|
-
function SetView(
|
|
3654
|
-
|
|
3655
|
-
_this.model = model;
|
|
3656
|
-
return _this;
|
|
3677
|
+
function SetView() {
|
|
3678
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3657
3679
|
}
|
|
3658
|
-
SetView.prototype
|
|
3680
|
+
SetView.prototype.compose = function (input) {
|
|
3659
3681
|
var _this = this;
|
|
3660
|
-
|
|
3661
|
-
var set =
|
|
3682
|
+
_super.prototype.compose.call(this, input);
|
|
3683
|
+
var set = input.model;
|
|
3662
3684
|
set.forEach(function (item) {
|
|
3663
|
-
|
|
3664
|
-
_this.createChild(item, item);
|
|
3665
|
-
});
|
|
3685
|
+
_this.createChild(input, item, item);
|
|
3666
3686
|
});
|
|
3667
|
-
_super.prototype.$ready.call(this);
|
|
3668
3687
|
};
|
|
3669
3688
|
return SetView;
|
|
3670
3689
|
}(BaseView));
|