vasille 2.0.5 → 2.2.2
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 +4 -0
- package/cdn/es2015.js +827 -827
- package/cdn/es5.js +909 -829
- package/flow-typed/vasille.js +2647 -835
- package/lib/binding/attribute.js +8 -3
- package/lib/binding/binding.js +5 -5
- package/lib/binding/class.js +4 -4
- package/lib/binding/style.js +2 -2
- package/lib/core/core.js +73 -17
- package/lib/core/destroyable.js +2 -2
- package/lib/core/ivalue.js +4 -4
- 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 +21 -12
- package/lib/node/node.js +229 -573
- package/lib/node/watch.js +6 -14
- 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 +21 -18
- package/lib/value/mirror.js +15 -15
- package/lib/value/pointer.js +5 -5
- package/lib/value/reference.js +18 -18
- 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 +4 -7
- package/lib/views/repeat-node.js +10 -22
- package/lib/views/set-view.js +4 -11
- package/package.json +3 -1
- package/types/binding/attribute.d.ts +2 -2
- package/types/binding/binding.d.ts +1 -1
- package/types/core/core.d.ts +31 -43
- package/types/core/destroyable.d.ts +2 -2
- package/types/core/ivalue.d.ts +4 -4
- 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 +1 -0
- package/types/models/object-model.d.ts +2 -0
- package/types/node/app.d.ts +19 -17
- package/types/node/node.d.ts +67 -388
- 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 +36 -0
- package/types/value/expression.d.ts +11 -24
- package/types/value/mirror.d.ts +6 -6
- package/types/value/pointer.d.ts +1 -1
- package/types/value/reference.d.ts +7 -7
- package/types/views/array-view.d.ts +3 -4
- package/types/views/base-view.d.ts +8 -16
- 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 (var 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,30 @@ 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
|
+
var 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
|
+
};
|
|
168
200
|
// ./lib-es5/models/model.js
|
|
169
201
|
|
|
170
202
|
|
|
@@ -321,13 +353,14 @@ var ObjectModel = /** @class */ (function (_super) {
|
|
|
321
353
|
function ObjectModel(obj) {
|
|
322
354
|
if (obj === void 0) { obj = {}; }
|
|
323
355
|
var _this = this; _super.call(this);
|
|
356
|
+
_this.container = Object.create(null);
|
|
324
357
|
Object.defineProperty(_this, 'listener', {
|
|
325
358
|
value: new Listener,
|
|
326
359
|
writable: false,
|
|
327
360
|
configurable: false
|
|
328
361
|
});
|
|
329
362
|
for (var i in obj) {
|
|
330
|
-
Object.defineProperty(_this, i, {
|
|
363
|
+
Object.defineProperty(_this.container, i, {
|
|
331
364
|
value: obj[i],
|
|
332
365
|
configurable: true,
|
|
333
366
|
writable: true,
|
|
@@ -343,8 +376,7 @@ var ObjectModel = /** @class */ (function (_super) {
|
|
|
343
376
|
* @return {*}
|
|
344
377
|
*/
|
|
345
378
|
ObjectModel.prototype.get = function (key) {
|
|
346
|
-
|
|
347
|
-
return ts[key];
|
|
379
|
+
return this.container[key];
|
|
348
380
|
};
|
|
349
381
|
/**
|
|
350
382
|
* Sets an object property value
|
|
@@ -353,21 +385,19 @@ var ObjectModel = /** @class */ (function (_super) {
|
|
|
353
385
|
* @return {ObjectModel} a pointer to this
|
|
354
386
|
*/
|
|
355
387
|
ObjectModel.prototype.set = function (key, v) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
this.listener.emitRemoved(key, ts[key]);
|
|
360
|
-
ts[key] = v;
|
|
388
|
+
if (Reflect.has(this.container, key)) {
|
|
389
|
+
this.listener.emitRemoved(key, this.container[key]);
|
|
390
|
+
this.container[key] = v;
|
|
361
391
|
}
|
|
362
392
|
else {
|
|
363
|
-
Object.defineProperty(
|
|
393
|
+
Object.defineProperty(this.container, key, {
|
|
364
394
|
value: v,
|
|
365
395
|
configurable: true,
|
|
366
396
|
writable: true,
|
|
367
397
|
enumerable: true
|
|
368
398
|
});
|
|
369
399
|
}
|
|
370
|
-
this.listener.emitAdded(key,
|
|
400
|
+
this.listener.emitAdded(key, this.container[key]);
|
|
371
401
|
return this;
|
|
372
402
|
};
|
|
373
403
|
/**
|
|
@@ -375,12 +405,28 @@ var ObjectModel = /** @class */ (function (_super) {
|
|
|
375
405
|
* @param key {string} property name
|
|
376
406
|
*/
|
|
377
407
|
ObjectModel.prototype.delete = function (key) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
this.
|
|
381
|
-
delete ts[key];
|
|
408
|
+
if (this.container[key]) {
|
|
409
|
+
this.listener.emitRemoved(key, this.container[key]);
|
|
410
|
+
delete this.container[key];
|
|
382
411
|
}
|
|
383
412
|
};
|
|
413
|
+
ObjectModel.prototype.proxy = function () {
|
|
414
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
415
|
+
var ts = this;
|
|
416
|
+
return new Proxy(this.container, {
|
|
417
|
+
get: function (target, p) {
|
|
418
|
+
return ts.get(p);
|
|
419
|
+
},
|
|
420
|
+
set: function (target, p, value) {
|
|
421
|
+
ts.set(p, value);
|
|
422
|
+
return true;
|
|
423
|
+
},
|
|
424
|
+
deleteProperty: function (target, p) {
|
|
425
|
+
ts.delete(p);
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
};
|
|
384
430
|
ObjectModel.prototype.enableReactivity = function () {
|
|
385
431
|
this.listener.enableReactivity();
|
|
386
432
|
};
|
|
@@ -564,6 +610,15 @@ var ArrayModel = /** @class */ (function (_super) {
|
|
|
564
610
|
}
|
|
565
611
|
return _this;
|
|
566
612
|
}
|
|
613
|
+
// proxy
|
|
614
|
+
ArrayModel.prototype.proxy = function () {
|
|
615
|
+
return new Proxy(this, {
|
|
616
|
+
set: function (target, p, value) {
|
|
617
|
+
target.splice(parseInt(p), 1, value);
|
|
618
|
+
return true;
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
};
|
|
567
622
|
Object.defineProperty(ArrayModel.prototype, "last", {
|
|
568
623
|
/* Array members */
|
|
569
624
|
/**
|
|
@@ -1104,7 +1159,7 @@ var Destroyable = /** @class */ (function () {
|
|
|
1104
1159
|
* Make object fields non configurable
|
|
1105
1160
|
* @protected
|
|
1106
1161
|
*/
|
|
1107
|
-
Destroyable.prototype
|
|
1162
|
+
Destroyable.prototype.$seal = function () {
|
|
1108
1163
|
var _this = this;
|
|
1109
1164
|
var $ = this;
|
|
1110
1165
|
Object.keys($).forEach(function (i) {
|
|
@@ -1137,7 +1192,7 @@ var Destroyable = /** @class */ (function () {
|
|
|
1137
1192
|
/**
|
|
1138
1193
|
* Garbage collector method
|
|
1139
1194
|
*/
|
|
1140
|
-
Destroyable.prototype
|
|
1195
|
+
Destroyable.prototype.$destroy = function () {
|
|
1141
1196
|
// nothing here
|
|
1142
1197
|
};
|
|
1143
1198
|
return Destroyable;
|
|
@@ -1155,13 +1210,13 @@ var Switchable = /** @class */ (function (_super) {
|
|
|
1155
1210
|
/**
|
|
1156
1211
|
* Enable update handlers triggering
|
|
1157
1212
|
*/
|
|
1158
|
-
Switchable.prototype
|
|
1213
|
+
Switchable.prototype.$enable = function () {
|
|
1159
1214
|
throw notOverwritten();
|
|
1160
1215
|
};
|
|
1161
1216
|
/**
|
|
1162
1217
|
* disable update handlers triggering
|
|
1163
1218
|
*/
|
|
1164
|
-
Switchable.prototype
|
|
1219
|
+
Switchable.prototype.$disable = function () {
|
|
1165
1220
|
throw notOverwritten();
|
|
1166
1221
|
};
|
|
1167
1222
|
return Switchable;
|
|
@@ -1204,14 +1259,14 @@ var IValue = /** @class */ (function (_super) {
|
|
|
1204
1259
|
* Add a new handler to value change
|
|
1205
1260
|
* @param handler {function(value : *)} the handler to add
|
|
1206
1261
|
*/
|
|
1207
|
-
IValue.prototype
|
|
1262
|
+
IValue.prototype.$on = function (handler) {
|
|
1208
1263
|
throw notOverwritten();
|
|
1209
1264
|
};
|
|
1210
1265
|
/**
|
|
1211
1266
|
* Removes a handler of value change
|
|
1212
1267
|
* @param handler {function(value : *)} the handler to remove
|
|
1213
1268
|
*/
|
|
1214
|
-
IValue.prototype
|
|
1269
|
+
IValue.prototype.$off = function (handler) {
|
|
1215
1270
|
throw notOverwritten();
|
|
1216
1271
|
};
|
|
1217
1272
|
return IValue;
|
|
@@ -1225,6 +1280,18 @@ window.IValue = IValue;
|
|
|
1225
1280
|
|
|
1226
1281
|
|
|
1227
1282
|
|
|
1283
|
+
// ./lib-es5/spec/svg.js
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
// ./lib-es5/spec/react.js
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
// ./lib-es5/spec/html.js
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1228
1295
|
// ./lib-es5/value/expression.js
|
|
1229
1296
|
/**
|
|
1230
1297
|
* Bind some values to one expression
|
|
@@ -1233,13 +1300,22 @@ window.IValue = IValue;
|
|
|
1233
1300
|
*/
|
|
1234
1301
|
var Expression = /** @class */ (function (_super) {
|
|
1235
1302
|
__extends(Expression, _super);
|
|
1236
|
-
|
|
1303
|
+
/**
|
|
1304
|
+
* Creates a function bounded to N values
|
|
1305
|
+
* @param func {Function} the function to bound
|
|
1306
|
+
* @param values
|
|
1307
|
+
* @param link {Boolean} links immediately if true
|
|
1308
|
+
*/
|
|
1309
|
+
function Expression(func, link) {
|
|
1310
|
+
var values = [];
|
|
1311
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1312
|
+
values[_i - 2] = arguments[_i];
|
|
1313
|
+
}
|
|
1237
1314
|
var _this = _super.call(this, false) || this;
|
|
1238
1315
|
/**
|
|
1239
1316
|
* Expression will link different handler for each value of list
|
|
1240
1317
|
*/
|
|
1241
1318
|
_this.linkedFunc = [];
|
|
1242
|
-
var values = [v1, v2, v3, v4, v5, v6, v7, v8, v9].filter(function (v) { return v instanceof IValue; });
|
|
1243
1319
|
var handler = function (i) {
|
|
1244
1320
|
if (i != null) {
|
|
1245
1321
|
_this.valuesCache[i] = _this.values[i].$;
|
|
@@ -1248,23 +1324,21 @@ var Expression = /** @class */ (function (_super) {
|
|
|
1248
1324
|
};
|
|
1249
1325
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1250
1326
|
// @ts-ignore
|
|
1251
|
-
_this.valuesCache = values.map(function (
|
|
1327
|
+
_this.valuesCache = values.map(function (item) { return item.$; });
|
|
1252
1328
|
_this.sync = new Reference(func.apply(_this, _this.valuesCache));
|
|
1253
1329
|
var i = 0;
|
|
1254
1330
|
values.forEach(function () {
|
|
1255
1331
|
_this.linkedFunc.push(handler.bind(_this, Number(i++)));
|
|
1256
1332
|
});
|
|
1257
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1258
|
-
// @ts-ignore
|
|
1259
1333
|
_this.values = values;
|
|
1260
1334
|
_this.func = handler;
|
|
1261
1335
|
if (link) {
|
|
1262
|
-
_this
|
|
1336
|
+
_this.$enable();
|
|
1263
1337
|
}
|
|
1264
1338
|
else {
|
|
1265
1339
|
handler();
|
|
1266
1340
|
}
|
|
1267
|
-
_this
|
|
1341
|
+
_this.$seal();
|
|
1268
1342
|
return _this;
|
|
1269
1343
|
}
|
|
1270
1344
|
Object.defineProperty(Expression.prototype, "$", {
|
|
@@ -1277,18 +1351,18 @@ var Expression = /** @class */ (function (_super) {
|
|
|
1277
1351
|
enumerable: false,
|
|
1278
1352
|
configurable: true
|
|
1279
1353
|
});
|
|
1280
|
-
Expression.prototype
|
|
1281
|
-
this.sync
|
|
1354
|
+
Expression.prototype.$on = function (handler) {
|
|
1355
|
+
this.sync.$on(handler);
|
|
1282
1356
|
return this;
|
|
1283
1357
|
};
|
|
1284
|
-
Expression.prototype
|
|
1285
|
-
this.sync
|
|
1358
|
+
Expression.prototype.$off = function (handler) {
|
|
1359
|
+
this.sync.$off(handler);
|
|
1286
1360
|
return this;
|
|
1287
1361
|
};
|
|
1288
|
-
Expression.prototype
|
|
1362
|
+
Expression.prototype.$enable = function () {
|
|
1289
1363
|
if (!this.isEnabled) {
|
|
1290
1364
|
for (var i = 0; i < this.values.length; i++) {
|
|
1291
|
-
this.values[i]
|
|
1365
|
+
this.values[i].$on(this.linkedFunc[i]);
|
|
1292
1366
|
this.valuesCache[i] = this.values[i].$;
|
|
1293
1367
|
}
|
|
1294
1368
|
this.func();
|
|
@@ -1296,21 +1370,21 @@ var Expression = /** @class */ (function (_super) {
|
|
|
1296
1370
|
}
|
|
1297
1371
|
return this;
|
|
1298
1372
|
};
|
|
1299
|
-
Expression.prototype
|
|
1373
|
+
Expression.prototype.$disable = function () {
|
|
1300
1374
|
if (this.isEnabled) {
|
|
1301
1375
|
for (var i = 0; i < this.values.length; i++) {
|
|
1302
|
-
this.values[i]
|
|
1376
|
+
this.values[i].$off(this.linkedFunc[i]);
|
|
1303
1377
|
}
|
|
1304
1378
|
this.isEnabled = false;
|
|
1305
1379
|
}
|
|
1306
1380
|
return this;
|
|
1307
1381
|
};
|
|
1308
|
-
Expression.prototype
|
|
1309
|
-
this
|
|
1382
|
+
Expression.prototype.$destroy = function () {
|
|
1383
|
+
this.$disable();
|
|
1310
1384
|
this.values.splice(0);
|
|
1311
1385
|
this.valuesCache.splice(0);
|
|
1312
1386
|
this.linkedFunc.splice(0);
|
|
1313
|
-
_super.prototype
|
|
1387
|
+
_super.prototype.$destroy.call(this);
|
|
1314
1388
|
};
|
|
1315
1389
|
return Expression;
|
|
1316
1390
|
}(IValue));
|
|
@@ -1331,20 +1405,20 @@ var Reference = /** @class */ (function (_super) {
|
|
|
1331
1405
|
*/
|
|
1332
1406
|
function Reference(value) {
|
|
1333
1407
|
var _this = _super.call(this, true) || this;
|
|
1334
|
-
_this
|
|
1335
|
-
_this
|
|
1336
|
-
_this
|
|
1408
|
+
_this.$value = value;
|
|
1409
|
+
_this.$onchange = new Set;
|
|
1410
|
+
_this.$seal();
|
|
1337
1411
|
return _this;
|
|
1338
1412
|
}
|
|
1339
1413
|
Object.defineProperty(Reference.prototype, "$", {
|
|
1340
1414
|
get: function () {
|
|
1341
|
-
return this
|
|
1415
|
+
return this.$value;
|
|
1342
1416
|
},
|
|
1343
1417
|
set: function (value) {
|
|
1344
|
-
if (this
|
|
1345
|
-
this
|
|
1418
|
+
if (this.$value !== value) {
|
|
1419
|
+
this.$value = value;
|
|
1346
1420
|
if (this.isEnabled) {
|
|
1347
|
-
this
|
|
1421
|
+
this.$onchange.forEach(function (handler) {
|
|
1348
1422
|
handler(value);
|
|
1349
1423
|
});
|
|
1350
1424
|
}
|
|
@@ -1353,27 +1427,27 @@ var Reference = /** @class */ (function (_super) {
|
|
|
1353
1427
|
enumerable: false,
|
|
1354
1428
|
configurable: true
|
|
1355
1429
|
});
|
|
1356
|
-
Reference.prototype
|
|
1430
|
+
Reference.prototype.$enable = function () {
|
|
1357
1431
|
var _this = this;
|
|
1358
1432
|
if (!this.isEnabled) {
|
|
1359
|
-
this
|
|
1360
|
-
handler(_this
|
|
1433
|
+
this.$onchange.forEach(function (handler) {
|
|
1434
|
+
handler(_this.$value);
|
|
1361
1435
|
});
|
|
1362
1436
|
this.isEnabled = true;
|
|
1363
1437
|
}
|
|
1364
1438
|
};
|
|
1365
|
-
Reference.prototype
|
|
1439
|
+
Reference.prototype.$disable = function () {
|
|
1366
1440
|
this.isEnabled = false;
|
|
1367
1441
|
};
|
|
1368
|
-
Reference.prototype
|
|
1369
|
-
this
|
|
1442
|
+
Reference.prototype.$on = function (handler) {
|
|
1443
|
+
this.$onchange.add(handler);
|
|
1370
1444
|
};
|
|
1371
|
-
Reference.prototype
|
|
1372
|
-
this
|
|
1445
|
+
Reference.prototype.$off = function (handler) {
|
|
1446
|
+
this.$onchange.delete(handler);
|
|
1373
1447
|
};
|
|
1374
|
-
Reference.prototype
|
|
1375
|
-
_super.prototype
|
|
1376
|
-
this
|
|
1448
|
+
Reference.prototype.$destroy = function () {
|
|
1449
|
+
_super.prototype.$destroy.call(this);
|
|
1450
|
+
this.$onchange.clear();
|
|
1377
1451
|
};
|
|
1378
1452
|
return Reference;
|
|
1379
1453
|
}(IValue));
|
|
@@ -1398,13 +1472,13 @@ var Mirror = /** @class */ (function (_super) {
|
|
|
1398
1472
|
function Mirror(value, forwardOnly) {
|
|
1399
1473
|
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
1400
1474
|
var _this = _super.call(this, value.$) || this;
|
|
1401
|
-
_this
|
|
1475
|
+
_this.$handler = function (v) {
|
|
1402
1476
|
_this.$ = v;
|
|
1403
1477
|
};
|
|
1404
|
-
_this
|
|
1405
|
-
_this
|
|
1406
|
-
value
|
|
1407
|
-
_this
|
|
1478
|
+
_this.$pointedValue = value;
|
|
1479
|
+
_this.$forwardOnly = forwardOnly;
|
|
1480
|
+
value.$on(_this.$handler);
|
|
1481
|
+
_this.$seal();
|
|
1408
1482
|
return _this;
|
|
1409
1483
|
}
|
|
1410
1484
|
Object.defineProperty(Mirror.prototype, "$", {
|
|
@@ -1415,8 +1489,8 @@ var Mirror = /** @class */ (function (_super) {
|
|
|
1415
1489
|
return _super.prototype.$;
|
|
1416
1490
|
},
|
|
1417
1491
|
set: function (v) {
|
|
1418
|
-
if (!this
|
|
1419
|
-
this
|
|
1492
|
+
if (!this.$forwardOnly) {
|
|
1493
|
+
this.$pointedValue.$ = v;
|
|
1420
1494
|
}
|
|
1421
1495
|
// this is a ts bug
|
|
1422
1496
|
// eslint-disable-next-line
|
|
@@ -1426,22 +1500,22 @@ var Mirror = /** @class */ (function (_super) {
|
|
|
1426
1500
|
enumerable: false,
|
|
1427
1501
|
configurable: true
|
|
1428
1502
|
});
|
|
1429
|
-
Mirror.prototype
|
|
1503
|
+
Mirror.prototype.$enable = function () {
|
|
1430
1504
|
if (!this.isEnabled) {
|
|
1431
1505
|
this.isEnabled = true;
|
|
1432
|
-
this
|
|
1433
|
-
this.$ = this
|
|
1506
|
+
this.$pointedValue.$on(this.$handler);
|
|
1507
|
+
this.$ = this.$pointedValue.$;
|
|
1434
1508
|
}
|
|
1435
1509
|
};
|
|
1436
|
-
Mirror.prototype
|
|
1510
|
+
Mirror.prototype.$disable = function () {
|
|
1437
1511
|
if (this.isEnabled) {
|
|
1438
|
-
this
|
|
1512
|
+
this.$pointedValue.$off(this.$handler);
|
|
1439
1513
|
this.isEnabled = false;
|
|
1440
1514
|
}
|
|
1441
1515
|
};
|
|
1442
|
-
Mirror.prototype
|
|
1443
|
-
this
|
|
1444
|
-
_super.prototype
|
|
1516
|
+
Mirror.prototype.$destroy = function () {
|
|
1517
|
+
this.$disable();
|
|
1518
|
+
_super.prototype.$destroy.call(this);
|
|
1445
1519
|
};
|
|
1446
1520
|
return Mirror;
|
|
1447
1521
|
}(Reference));
|
|
@@ -1465,17 +1539,21 @@ var Pointer = /** @class */ (function (_super) {
|
|
|
1465
1539
|
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
1466
1540
|
return _super.call(this, value, forwardOnly) || this;
|
|
1467
1541
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
this
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1542
|
+
Object.defineProperty(Pointer.prototype, "$$", {
|
|
1543
|
+
/**
|
|
1544
|
+
* Point a new ivalue
|
|
1545
|
+
* @param value {IValue} value to point
|
|
1546
|
+
*/
|
|
1547
|
+
set: function (value) {
|
|
1548
|
+
if (this.$pointedValue !== value) {
|
|
1549
|
+
this.$disable();
|
|
1550
|
+
this.$pointedValue = value;
|
|
1551
|
+
this.$enable();
|
|
1552
|
+
}
|
|
1553
|
+
},
|
|
1554
|
+
enumerable: false,
|
|
1555
|
+
configurable: true
|
|
1556
|
+
});
|
|
1479
1557
|
return Pointer;
|
|
1480
1558
|
}(Mirror));
|
|
1481
1559
|
|
|
@@ -1497,20 +1575,20 @@ var Binding = /** @class */ (function (_super) {
|
|
|
1497
1575
|
function Binding(value) {
|
|
1498
1576
|
var _this = this; _super.call(this);
|
|
1499
1577
|
_this.binding = value;
|
|
1500
|
-
_this
|
|
1578
|
+
_this.$seal();
|
|
1501
1579
|
return _this;
|
|
1502
1580
|
}
|
|
1503
1581
|
Binding.prototype.init = function (bounded) {
|
|
1504
1582
|
this.func = bounded;
|
|
1505
|
-
this.binding
|
|
1583
|
+
this.binding.$on(this.func);
|
|
1506
1584
|
this.func(this.binding.$);
|
|
1507
1585
|
};
|
|
1508
1586
|
/**
|
|
1509
1587
|
* Just clear bindings
|
|
1510
1588
|
*/
|
|
1511
|
-
Binding.prototype
|
|
1512
|
-
this.binding
|
|
1513
|
-
_super.prototype
|
|
1589
|
+
Binding.prototype.$destroy = function () {
|
|
1590
|
+
this.binding.$off(this.func);
|
|
1591
|
+
_super.prototype.$destroy.call(this);
|
|
1514
1592
|
};
|
|
1515
1593
|
return Binding;
|
|
1516
1594
|
}(Destroyable));
|
|
@@ -1519,6 +1597,15 @@ var Binding = /** @class */ (function (_super) {
|
|
|
1519
1597
|
window.Binding = Binding;
|
|
1520
1598
|
|
|
1521
1599
|
// ./lib-es5/core/core.js
|
|
1600
|
+
var current = null;
|
|
1601
|
+
var currentStack = [];
|
|
1602
|
+
function stack(node) {
|
|
1603
|
+
currentStack.push(current);
|
|
1604
|
+
current = node;
|
|
1605
|
+
}
|
|
1606
|
+
function unstack() {
|
|
1607
|
+
current = currentStack.pop();
|
|
1608
|
+
}
|
|
1522
1609
|
/**
|
|
1523
1610
|
* Private stuff of a reactive object
|
|
1524
1611
|
* @class ReactivePrivate
|
|
@@ -1552,19 +1639,19 @@ var ReactivePrivate = /** @class */ (function (_super) {
|
|
|
1552
1639
|
* @type {boolean}
|
|
1553
1640
|
*/
|
|
1554
1641
|
_this.frozen = false;
|
|
1555
|
-
_this
|
|
1642
|
+
_this.$seal();
|
|
1556
1643
|
return _this;
|
|
1557
1644
|
}
|
|
1558
|
-
ReactivePrivate.prototype
|
|
1559
|
-
|
|
1560
|
-
this.watch.forEach(function (value) { return value.destroy(); });
|
|
1645
|
+
ReactivePrivate.prototype.$destroy = function () {
|
|
1646
|
+
this.watch.forEach(function (value) { return value.$destroy(); });
|
|
1561
1647
|
this.watch.clear();
|
|
1562
|
-
this.bindings.forEach(function (binding) { return binding
|
|
1648
|
+
this.bindings.forEach(function (binding) { return binding.$destroy(); });
|
|
1563
1649
|
this.bindings.clear();
|
|
1564
1650
|
this.models.forEach(function (model) { return model.disableReactivity(); });
|
|
1565
1651
|
this.models.clear();
|
|
1566
|
-
|
|
1567
|
-
|
|
1652
|
+
this.freezeExpr && this.freezeExpr.$destroy();
|
|
1653
|
+
this.onDestroy && this.onDestroy();
|
|
1654
|
+
_super.prototype.$destroy.call(this);
|
|
1568
1655
|
};
|
|
1569
1656
|
return ReactivePrivate;
|
|
1570
1657
|
}(Destroyable));
|
|
@@ -1576,11 +1663,23 @@ var ReactivePrivate = /** @class */ (function (_super) {
|
|
|
1576
1663
|
*/
|
|
1577
1664
|
var Reactive = /** @class */ (function (_super) {
|
|
1578
1665
|
__extends(Reactive, _super);
|
|
1579
|
-
function Reactive($) {
|
|
1666
|
+
function Reactive(input, $) {
|
|
1580
1667
|
var _this = this; _super.call(this);
|
|
1668
|
+
_this.input = input;
|
|
1581
1669
|
_this.$ = $ || new ReactivePrivate;
|
|
1670
|
+
_this.$seal();
|
|
1582
1671
|
return _this;
|
|
1583
1672
|
}
|
|
1673
|
+
Object.defineProperty(Reactive.prototype, "parent", {
|
|
1674
|
+
/**
|
|
1675
|
+
* Get parent node
|
|
1676
|
+
*/
|
|
1677
|
+
get: function () {
|
|
1678
|
+
return this.$.parent;
|
|
1679
|
+
},
|
|
1680
|
+
enumerable: false,
|
|
1681
|
+
configurable: true
|
|
1682
|
+
});
|
|
1584
1683
|
/**
|
|
1585
1684
|
* Create a reference
|
|
1586
1685
|
* @param value {*} value to reference
|
|
@@ -1629,12 +1728,31 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1629
1728
|
this.$.models.add(model);
|
|
1630
1729
|
return model;
|
|
1631
1730
|
};
|
|
1632
|
-
|
|
1731
|
+
/**
|
|
1732
|
+
* Creates a watcher
|
|
1733
|
+
* @param func {function} function to run on any argument change
|
|
1734
|
+
* @param values
|
|
1735
|
+
*/
|
|
1736
|
+
Reactive.prototype.watch = function (func) {
|
|
1737
|
+
var values = [];
|
|
1738
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1739
|
+
values[_i - 1] = arguments[_i];
|
|
1740
|
+
}
|
|
1633
1741
|
var $ = this.$;
|
|
1634
|
-
$.watch.add(new Expression(func, !this.$.frozen,
|
|
1742
|
+
$.watch.add(new (Expression.bind.apply(Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))());
|
|
1635
1743
|
};
|
|
1636
|
-
|
|
1637
|
-
|
|
1744
|
+
/**
|
|
1745
|
+
* Creates a computed value
|
|
1746
|
+
* @param func {function} function to run on any argument change
|
|
1747
|
+
* @param values
|
|
1748
|
+
* @return {IValue} the created ivalue
|
|
1749
|
+
*/
|
|
1750
|
+
Reactive.prototype.expr = function (func) {
|
|
1751
|
+
var values = [];
|
|
1752
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1753
|
+
values[_i - 1] = arguments[_i];
|
|
1754
|
+
}
|
|
1755
|
+
var res = new (Expression.bind.apply(Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))();
|
|
1638
1756
|
var $ = this.$;
|
|
1639
1757
|
$.watch.add(res);
|
|
1640
1758
|
return res;
|
|
@@ -1646,7 +1764,7 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1646
1764
|
var $ = this.$;
|
|
1647
1765
|
if (!$.enabled) {
|
|
1648
1766
|
$.watch.forEach(function (watcher) {
|
|
1649
|
-
watcher
|
|
1767
|
+
watcher.$enable();
|
|
1650
1768
|
});
|
|
1651
1769
|
$.models.forEach(function (model) {
|
|
1652
1770
|
model.enableReactivity();
|
|
@@ -1661,7 +1779,7 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1661
1779
|
var $ = this.$;
|
|
1662
1780
|
if ($.enabled) {
|
|
1663
1781
|
$.watch.forEach(function (watcher) {
|
|
1664
|
-
watcher
|
|
1782
|
+
watcher.$disable();
|
|
1665
1783
|
});
|
|
1666
1784
|
$.models.forEach(function (model) {
|
|
1667
1785
|
model.disableReactivity();
|
|
@@ -1697,15 +1815,48 @@ var Reactive = /** @class */ (function (_super) {
|
|
|
1697
1815
|
}, true, cond);
|
|
1698
1816
|
return this;
|
|
1699
1817
|
};
|
|
1700
|
-
Reactive.prototype.
|
|
1701
|
-
|
|
1702
|
-
this
|
|
1818
|
+
Reactive.prototype.init = function () {
|
|
1819
|
+
this.applyOptions(this.input);
|
|
1820
|
+
this.compose(this.input);
|
|
1821
|
+
};
|
|
1822
|
+
Reactive.prototype.applyOptions = function (input) {
|
|
1823
|
+
// empty
|
|
1824
|
+
};
|
|
1825
|
+
Reactive.prototype.applyOptionsNow = function () {
|
|
1826
|
+
this.applyOptions(this.input);
|
|
1827
|
+
};
|
|
1828
|
+
Reactive.prototype.compose = function (input) {
|
|
1829
|
+
// empty
|
|
1830
|
+
};
|
|
1831
|
+
Reactive.prototype.composeNow = function () {
|
|
1832
|
+
this.compose(this.input);
|
|
1833
|
+
};
|
|
1834
|
+
Reactive.prototype.runFunctional = function (f) {
|
|
1835
|
+
var args = [];
|
|
1836
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1837
|
+
args[_i - 1] = arguments[_i];
|
|
1838
|
+
}
|
|
1839
|
+
stack(this);
|
|
1840
|
+
// yet another ts bug
|
|
1841
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1842
|
+
// @ts-ignore
|
|
1843
|
+
var result = f.apply(void 0, args);
|
|
1844
|
+
unstack();
|
|
1845
|
+
return result;
|
|
1846
|
+
};
|
|
1847
|
+
Reactive.prototype.runOnDestroy = function (func) {
|
|
1848
|
+
this.$.onDestroy = func;
|
|
1849
|
+
};
|
|
1850
|
+
Reactive.prototype.$destroy = function () {
|
|
1851
|
+
_super.prototype.$destroy.call(this);
|
|
1852
|
+
this.$.$destroy();
|
|
1703
1853
|
this.$ = null;
|
|
1704
1854
|
};
|
|
1705
1855
|
return Reactive;
|
|
1706
1856
|
}(Destroyable));
|
|
1707
1857
|
|
|
1708
1858
|
|
|
1859
|
+
window.current = current;
|
|
1709
1860
|
window.ReactivePrivate = ReactivePrivate;
|
|
1710
1861
|
window.Reactive = Reactive;
|
|
1711
1862
|
|
|
@@ -1719,7 +1870,7 @@ var FragmentPrivate = /** @class */ (function (_super) {
|
|
|
1719
1870
|
__extends(FragmentPrivate, _super);
|
|
1720
1871
|
function FragmentPrivate() {
|
|
1721
1872
|
var _this = this; _super.call(this);
|
|
1722
|
-
_this
|
|
1873
|
+
_this.$seal();
|
|
1723
1874
|
return _this;
|
|
1724
1875
|
}
|
|
1725
1876
|
/**
|
|
@@ -1734,10 +1885,10 @@ var FragmentPrivate = /** @class */ (function (_super) {
|
|
|
1734
1885
|
/**
|
|
1735
1886
|
* Unlinks all bindings
|
|
1736
1887
|
*/
|
|
1737
|
-
FragmentPrivate.prototype
|
|
1888
|
+
FragmentPrivate.prototype.$destroy = function () {
|
|
1738
1889
|
this.next = null;
|
|
1739
1890
|
this.prev = null;
|
|
1740
|
-
_super.prototype
|
|
1891
|
+
_super.prototype.$destroy.call(this);
|
|
1741
1892
|
};
|
|
1742
1893
|
return FragmentPrivate;
|
|
1743
1894
|
}(ReactivePrivate));
|
|
@@ -1750,10 +1901,11 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1750
1901
|
__extends(Fragment, _super);
|
|
1751
1902
|
/**
|
|
1752
1903
|
* Constructs a Vasille Node
|
|
1904
|
+
* @param input
|
|
1753
1905
|
* @param $ {FragmentPrivate}
|
|
1754
1906
|
*/
|
|
1755
|
-
function Fragment($) {
|
|
1756
|
-
var _this = _super.call(this, $ || new FragmentPrivate) || this;
|
|
1907
|
+
function Fragment(input, $) {
|
|
1908
|
+
var _this = _super.call(this, input, $ || new FragmentPrivate) || this;
|
|
1757
1909
|
/**
|
|
1758
1910
|
* The children list
|
|
1759
1911
|
* @type Array
|
|
@@ -1782,36 +1934,18 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1782
1934
|
var $ = this.$;
|
|
1783
1935
|
$.preinit(app, parent);
|
|
1784
1936
|
};
|
|
1785
|
-
/**
|
|
1786
|
-
* Initialize node
|
|
1787
|
-
*/
|
|
1788
1937
|
Fragment.prototype.init = function () {
|
|
1789
|
-
|
|
1790
|
-
this.
|
|
1791
|
-
this.compose();
|
|
1792
|
-
this.mounted();
|
|
1793
|
-
return this;
|
|
1794
|
-
};
|
|
1795
|
-
/** To be overloaded: created event handler */
|
|
1796
|
-
Fragment.prototype.created = function () {
|
|
1797
|
-
// empty
|
|
1938
|
+
_super.prototype.init.call(this);
|
|
1939
|
+
this.ready();
|
|
1798
1940
|
};
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1941
|
+
Fragment.prototype.compose = function (input) {
|
|
1942
|
+
_super.prototype.compose.call(this, input);
|
|
1943
|
+
input.slot && input.slot(this);
|
|
1802
1944
|
};
|
|
1803
1945
|
/** To be overloaded: ready event handler */
|
|
1804
1946
|
Fragment.prototype.ready = function () {
|
|
1805
1947
|
// empty
|
|
1806
1948
|
};
|
|
1807
|
-
/** To be overloaded: watchers creation milestone */
|
|
1808
|
-
Fragment.prototype.createWatchers = function () {
|
|
1809
|
-
// empty
|
|
1810
|
-
};
|
|
1811
|
-
/** To be overloaded: DOM creation milestone */
|
|
1812
|
-
Fragment.prototype.compose = function () {
|
|
1813
|
-
// empty
|
|
1814
|
-
};
|
|
1815
1949
|
/**
|
|
1816
1950
|
* Pushes a node to children immediately
|
|
1817
1951
|
* @param node {Fragment} A node to push
|
|
@@ -1858,7 +1992,7 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1858
1992
|
var child = this.findFirstChild();
|
|
1859
1993
|
var $ = this.$;
|
|
1860
1994
|
if (child) {
|
|
1861
|
-
|
|
1995
|
+
child.parentElement.insertBefore(node, child);
|
|
1862
1996
|
}
|
|
1863
1997
|
else if ($.next) {
|
|
1864
1998
|
$.next.insertAdjacent(node);
|
|
@@ -1875,14 +2009,9 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1875
2009
|
Fragment.prototype.text = function (text, cb) {
|
|
1876
2010
|
var $ = this.$;
|
|
1877
2011
|
var node = new TextNode();
|
|
1878
|
-
|
|
1879
|
-
node.preinit($.app, this, textValue);
|
|
2012
|
+
node.preinit($.app, this, text);
|
|
1880
2013
|
this.pushNode(node);
|
|
1881
|
-
|
|
1882
|
-
$.app.run.callCallback(function () {
|
|
1883
|
-
cb(node);
|
|
1884
|
-
});
|
|
1885
|
-
}
|
|
2014
|
+
cb && cb(node);
|
|
1886
2015
|
};
|
|
1887
2016
|
Fragment.prototype.debug = function (text) {
|
|
1888
2017
|
if (this.$.app.debugUi) {
|
|
@@ -1890,39 +2019,35 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1890
2019
|
node.preinit(this.$.app, this, text);
|
|
1891
2020
|
this.pushNode(node);
|
|
1892
2021
|
}
|
|
1893
|
-
return this;
|
|
1894
2022
|
};
|
|
1895
|
-
|
|
2023
|
+
/**
|
|
2024
|
+
* Defines a tag element
|
|
2025
|
+
* @param tagName {String} the tag name
|
|
2026
|
+
* @param input
|
|
2027
|
+
* @param cb {function(Tag, *)} callback
|
|
2028
|
+
*/
|
|
2029
|
+
Fragment.prototype.tag = function (tagName, input, cb) {
|
|
1896
2030
|
var $ = this.$;
|
|
1897
|
-
var node = new Tag();
|
|
2031
|
+
var node = new Tag(input);
|
|
2032
|
+
input.slot = cb || input.slot;
|
|
1898
2033
|
node.preinit($.app, this, tagName);
|
|
1899
2034
|
node.init();
|
|
1900
2035
|
this.pushNode(node);
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
cb(node, node.node);
|
|
1904
|
-
}
|
|
1905
|
-
node.ready();
|
|
1906
|
-
});
|
|
2036
|
+
node.ready();
|
|
2037
|
+
return node.node;
|
|
1907
2038
|
};
|
|
1908
2039
|
/**
|
|
1909
2040
|
* Defines a custom element
|
|
1910
2041
|
* @param node {Fragment} vasille element to insert
|
|
1911
2042
|
* @param callback {function($ : *)}
|
|
1912
|
-
* @param callback1 {function($ : *)}
|
|
1913
2043
|
*/
|
|
1914
|
-
Fragment.prototype.create = function (node, callback
|
|
2044
|
+
Fragment.prototype.create = function (node, callback) {
|
|
1915
2045
|
var $ = this.$;
|
|
1916
2046
|
node.$.parent = this;
|
|
1917
2047
|
node.preinit($.app, this);
|
|
1918
|
-
|
|
1919
|
-
callback(node);
|
|
1920
|
-
}
|
|
1921
|
-
if (callback1) {
|
|
1922
|
-
callback1(node);
|
|
1923
|
-
}
|
|
2048
|
+
node.input.slot = callback || node.input.slot;
|
|
1924
2049
|
this.pushNode(node);
|
|
1925
|
-
node.init()
|
|
2050
|
+
node.init();
|
|
1926
2051
|
};
|
|
1927
2052
|
/**
|
|
1928
2053
|
* Defines an if node
|
|
@@ -1931,35 +2056,28 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
1931
2056
|
* @return {this}
|
|
1932
2057
|
*/
|
|
1933
2058
|
Fragment.prototype.if = function (cond, cb) {
|
|
1934
|
-
return this.switch({ cond: cond, cb: cb });
|
|
1935
|
-
};
|
|
1936
|
-
/**
|
|
1937
|
-
* Defines a if-else node
|
|
1938
|
-
* @param ifCond {IValue} `if` condition
|
|
1939
|
-
* @param ifCb {function(Fragment)} Call-back to create `if` child nodes
|
|
1940
|
-
* @param elseCb {function(Fragment)} Call-back to create `else` child nodes
|
|
1941
|
-
*/
|
|
1942
|
-
Fragment.prototype.if_else = function (ifCond, ifCb, elseCb) {
|
|
1943
|
-
return this.switch({ cond: ifCond, cb: ifCb }, { cond: trueIValue, cb: elseCb });
|
|
1944
|
-
};
|
|
1945
|
-
/**
|
|
1946
|
-
* Defines a switch nodes: Will break after first true condition
|
|
1947
|
-
* @param cases {...{ cond : IValue, cb : function(Fragment) }} cases
|
|
1948
|
-
* @return {INode}
|
|
1949
|
-
*/
|
|
1950
|
-
Fragment.prototype.switch = function () {
|
|
1951
|
-
var cases = [];
|
|
1952
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1953
|
-
cases[_i] = arguments[_i];
|
|
1954
|
-
}
|
|
1955
|
-
var $ = this.$;
|
|
1956
2059
|
var node = new SwitchedNode();
|
|
1957
|
-
node.preinit(
|
|
2060
|
+
node.preinit(this.$.app, this);
|
|
1958
2061
|
node.init();
|
|
1959
2062
|
this.pushNode(node);
|
|
1960
|
-
node.
|
|
2063
|
+
node.addCase(this.case(cond, cb));
|
|
1961
2064
|
node.ready();
|
|
1962
|
-
|
|
2065
|
+
};
|
|
2066
|
+
Fragment.prototype.else = function (cb) {
|
|
2067
|
+
if (this.lastChild instanceof SwitchedNode) {
|
|
2068
|
+
this.lastChild.addCase(this.default(cb));
|
|
2069
|
+
}
|
|
2070
|
+
else {
|
|
2071
|
+
throw userError('wrong `else` function use', 'logic-error');
|
|
2072
|
+
}
|
|
2073
|
+
};
|
|
2074
|
+
Fragment.prototype.elif = function (cond, cb) {
|
|
2075
|
+
if (this.lastChild instanceof SwitchedNode) {
|
|
2076
|
+
this.lastChild.addCase(this.case(cond, cb));
|
|
2077
|
+
}
|
|
2078
|
+
else {
|
|
2079
|
+
throw userError('wrong `elif` function use', 'logic-error');
|
|
2080
|
+
}
|
|
1963
2081
|
};
|
|
1964
2082
|
/**
|
|
1965
2083
|
* Create a case for switch
|
|
@@ -2001,14 +2119,14 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
2001
2119
|
$.prev.$.next = $.next;
|
|
2002
2120
|
}
|
|
2003
2121
|
};
|
|
2004
|
-
Fragment.prototype
|
|
2005
|
-
this.children.forEach(function (child) { return child
|
|
2122
|
+
Fragment.prototype.$destroy = function () {
|
|
2123
|
+
this.children.forEach(function (child) { return child.$destroy(); });
|
|
2006
2124
|
this.children.clear();
|
|
2007
2125
|
this.lastChild = null;
|
|
2008
2126
|
if (this.$.parent.lastChild === this) {
|
|
2009
2127
|
this.$.parent.lastChild = this.$.prev;
|
|
2010
2128
|
}
|
|
2011
|
-
_super.prototype
|
|
2129
|
+
_super.prototype.$destroy.call(this);
|
|
2012
2130
|
};
|
|
2013
2131
|
return Fragment;
|
|
2014
2132
|
}(Reactive));
|
|
@@ -2023,27 +2141,30 @@ var TextNodePrivate = /** @class */ (function (_super) {
|
|
|
2023
2141
|
__extends(TextNodePrivate, _super);
|
|
2024
2142
|
function TextNodePrivate() {
|
|
2025
2143
|
var _this = this; _super.call(this);
|
|
2026
|
-
_this
|
|
2144
|
+
_this.$seal();
|
|
2027
2145
|
return _this;
|
|
2028
2146
|
}
|
|
2029
2147
|
/**
|
|
2030
2148
|
* Pre-initializes a text node
|
|
2031
2149
|
* @param app {AppNode} the app node
|
|
2150
|
+
* @param parent
|
|
2032
2151
|
* @param text {IValue}
|
|
2033
2152
|
*/
|
|
2034
2153
|
TextNodePrivate.prototype.preinitText = function (app, parent, text) {
|
|
2035
2154
|
var _this = this;
|
|
2036
2155
|
_super.prototype.preinit.call(this, app, parent);
|
|
2037
|
-
this.node = document.createTextNode(text.$);
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2156
|
+
this.node = document.createTextNode(text instanceof IValue ? text.$ : text);
|
|
2157
|
+
if (text instanceof IValue) {
|
|
2158
|
+
this.bindings.add(new Expression(function (v) {
|
|
2159
|
+
_this.node.replaceData(0, -1, v);
|
|
2160
|
+
}, true, text));
|
|
2161
|
+
}
|
|
2041
2162
|
};
|
|
2042
2163
|
/**
|
|
2043
2164
|
* Clear node data
|
|
2044
2165
|
*/
|
|
2045
|
-
TextNodePrivate.prototype
|
|
2046
|
-
_super.prototype
|
|
2166
|
+
TextNodePrivate.prototype.$destroy = function () {
|
|
2167
|
+
_super.prototype.$destroy.call(this);
|
|
2047
2168
|
};
|
|
2048
2169
|
return TextNodePrivate;
|
|
2049
2170
|
}(FragmentPrivate));
|
|
@@ -2057,8 +2178,8 @@ var TextNode = /** @class */ (function (_super) {
|
|
|
2057
2178
|
__extends(TextNode, _super);
|
|
2058
2179
|
function TextNode($) {
|
|
2059
2180
|
if ($ === void 0) { $ = new TextNodePrivate(); }
|
|
2060
|
-
var _this = _super.call(this, $) || this;
|
|
2061
|
-
_this
|
|
2181
|
+
var _this = _super.call(this, {}, $) || this;
|
|
2182
|
+
_this.$seal();
|
|
2062
2183
|
return _this;
|
|
2063
2184
|
}
|
|
2064
2185
|
TextNode.prototype.preinit = function (app, parent, text) {
|
|
@@ -2072,10 +2193,10 @@ var TextNode = /** @class */ (function (_super) {
|
|
|
2072
2193
|
TextNode.prototype.findFirstChild = function () {
|
|
2073
2194
|
return this.$.node;
|
|
2074
2195
|
};
|
|
2075
|
-
TextNode.prototype
|
|
2196
|
+
TextNode.prototype.$destroy = function () {
|
|
2076
2197
|
this.$.node.remove();
|
|
2077
|
-
this
|
|
2078
|
-
_super.prototype
|
|
2198
|
+
this.$.$destroy();
|
|
2199
|
+
_super.prototype.$destroy.call(this);
|
|
2079
2200
|
};
|
|
2080
2201
|
return TextNode;
|
|
2081
2202
|
}(Fragment));
|
|
@@ -2094,11 +2215,11 @@ var INodePrivate = /** @class */ (function (_super) {
|
|
|
2094
2215
|
* @type {boolean}
|
|
2095
2216
|
*/
|
|
2096
2217
|
_this.unmounted = false;
|
|
2097
|
-
_this
|
|
2218
|
+
_this.$seal();
|
|
2098
2219
|
return _this;
|
|
2099
2220
|
}
|
|
2100
|
-
INodePrivate.prototype
|
|
2101
|
-
_super.prototype
|
|
2221
|
+
INodePrivate.prototype.$destroy = function () {
|
|
2222
|
+
_super.prototype.$destroy.call(this);
|
|
2102
2223
|
};
|
|
2103
2224
|
return INodePrivate;
|
|
2104
2225
|
}(FragmentPrivate));
|
|
@@ -2112,11 +2233,12 @@ var INode = /** @class */ (function (_super) {
|
|
|
2112
2233
|
__extends(INode, _super);
|
|
2113
2234
|
/**
|
|
2114
2235
|
* Constructs a base node
|
|
2236
|
+
* @param input
|
|
2115
2237
|
* @param $ {?INodePrivate}
|
|
2116
2238
|
*/
|
|
2117
|
-
function INode($) {
|
|
2118
|
-
var _this = _super.call(this, $ || new INodePrivate) || this;
|
|
2119
|
-
_this
|
|
2239
|
+
function INode(input, $) {
|
|
2240
|
+
var _this = _super.call(this, input, $ || new INodePrivate) || this;
|
|
2241
|
+
_this.$seal();
|
|
2120
2242
|
return _this;
|
|
2121
2243
|
}
|
|
2122
2244
|
Object.defineProperty(INode.prototype, "node", {
|
|
@@ -2129,26 +2251,6 @@ var INode = /** @class */ (function (_super) {
|
|
|
2129
2251
|
enumerable: false,
|
|
2130
2252
|
configurable: true
|
|
2131
2253
|
});
|
|
2132
|
-
/**
|
|
2133
|
-
* Initialize node
|
|
2134
|
-
*/
|
|
2135
|
-
INode.prototype.init = function () {
|
|
2136
|
-
this.createWatchers();
|
|
2137
|
-
this.createAttrs();
|
|
2138
|
-
this.createStyle();
|
|
2139
|
-
this.created();
|
|
2140
|
-
this.compose();
|
|
2141
|
-
this.mounted();
|
|
2142
|
-
return this;
|
|
2143
|
-
};
|
|
2144
|
-
/** To be overloaded: attributes creation milestone */
|
|
2145
|
-
INode.prototype.createAttrs = function () {
|
|
2146
|
-
// empty
|
|
2147
|
-
};
|
|
2148
|
-
/** To be overloaded: $style attributes creation milestone */
|
|
2149
|
-
INode.prototype.createStyle = function () {
|
|
2150
|
-
// empty
|
|
2151
|
-
};
|
|
2152
2254
|
/**
|
|
2153
2255
|
* Bind attribute value
|
|
2154
2256
|
* @param name {String} name of attribute
|
|
@@ -2159,18 +2261,20 @@ var INode = /** @class */ (function (_super) {
|
|
|
2159
2261
|
var attr = new AttributeBinding(this, name, value);
|
|
2160
2262
|
$.bindings.add(attr);
|
|
2161
2263
|
};
|
|
2162
|
-
INode.prototype.bindAttr = function (name, calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
|
2163
|
-
var $ = this.$;
|
|
2164
|
-
var expr = this.bind(calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
|
2165
|
-
$.bindings.add(new AttributeBinding(this, name, expr));
|
|
2166
|
-
};
|
|
2167
2264
|
/**
|
|
2168
2265
|
* Set attribute value
|
|
2169
2266
|
* @param name {string} name of attribute
|
|
2170
2267
|
* @param value {string} value
|
|
2171
2268
|
*/
|
|
2172
2269
|
INode.prototype.setAttr = function (name, value) {
|
|
2173
|
-
|
|
2270
|
+
if (typeof value === 'boolean') {
|
|
2271
|
+
if (value) {
|
|
2272
|
+
this.$.node.setAttribute(name, "");
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
else {
|
|
2276
|
+
this.$.node.setAttribute(name, "".concat(value));
|
|
2277
|
+
}
|
|
2174
2278
|
return this;
|
|
2175
2279
|
};
|
|
2176
2280
|
/**
|
|
@@ -2178,22 +2282,15 @@ var INode = /** @class */ (function (_super) {
|
|
|
2178
2282
|
* @param cl {string} Class name
|
|
2179
2283
|
*/
|
|
2180
2284
|
INode.prototype.addClass = function (cl) {
|
|
2181
|
-
this.$.
|
|
2285
|
+
this.$.node.classList.add(cl);
|
|
2182
2286
|
return this;
|
|
2183
2287
|
};
|
|
2184
2288
|
/**
|
|
2185
2289
|
* Adds some CSS classes
|
|
2186
2290
|
* @param cls {...string} classes names
|
|
2187
2291
|
*/
|
|
2188
|
-
INode.prototype.
|
|
2189
|
-
|
|
2190
|
-
var cls = [];
|
|
2191
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2192
|
-
cls[_i] = arguments[_i];
|
|
2193
|
-
}
|
|
2194
|
-
cls.forEach(function (cl) {
|
|
2195
|
-
_this.$.app.run.addClass(_this.$.node, cl);
|
|
2196
|
-
});
|
|
2292
|
+
INode.prototype.removeClasse = function (cl) {
|
|
2293
|
+
this.$.node.classList.remove(cl);
|
|
2197
2294
|
return this;
|
|
2198
2295
|
};
|
|
2199
2296
|
/**
|
|
@@ -2229,17 +2326,6 @@ var INode = /** @class */ (function (_super) {
|
|
|
2229
2326
|
}
|
|
2230
2327
|
return this;
|
|
2231
2328
|
};
|
|
2232
|
-
INode.prototype.bindStyle = function (name, calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
|
2233
|
-
var $ = this.$;
|
|
2234
|
-
var expr = this.bind(calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
|
2235
|
-
if ($.node instanceof HTMLElement) {
|
|
2236
|
-
$.bindings.add(new StyleBinding(this, name, expr));
|
|
2237
|
-
}
|
|
2238
|
-
else {
|
|
2239
|
-
throw userError('style can be applied to HTML elements only', 'non-html-element');
|
|
2240
|
-
}
|
|
2241
|
-
return this;
|
|
2242
|
-
};
|
|
2243
2329
|
/**
|
|
2244
2330
|
* Sets a style property value
|
|
2245
2331
|
* @param prop {string} Property name
|
|
@@ -2247,10 +2333,10 @@ var INode = /** @class */ (function (_super) {
|
|
|
2247
2333
|
*/
|
|
2248
2334
|
INode.prototype.setStyle = function (prop, value) {
|
|
2249
2335
|
if (this.$.node instanceof HTMLElement) {
|
|
2250
|
-
this.$.
|
|
2336
|
+
this.$.node.style.setProperty(prop, value);
|
|
2251
2337
|
}
|
|
2252
2338
|
else {
|
|
2253
|
-
throw userError("Style can be
|
|
2339
|
+
throw userError("Style can be set for HTML elements only", "non-html-element");
|
|
2254
2340
|
}
|
|
2255
2341
|
return this;
|
|
2256
2342
|
};
|
|
@@ -2264,425 +2350,133 @@ var INode = /** @class */ (function (_super) {
|
|
|
2264
2350
|
this.$.node.addEventListener(name, handler, options);
|
|
2265
2351
|
return this;
|
|
2266
2352
|
};
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
* @param options {Object | boolean}
|
|
2270
|
-
*/
|
|
2271
|
-
INode.prototype.oncontextmenu = function (handler, options) {
|
|
2272
|
-
return this.listen("contextmenu", handler, options);
|
|
2273
|
-
};
|
|
2274
|
-
/**
|
|
2275
|
-
* @param handler {function (MouseEvent)}
|
|
2276
|
-
* @param options {Object | boolean}
|
|
2277
|
-
*/
|
|
2278
|
-
INode.prototype.onmousedown = function (handler, options) {
|
|
2279
|
-
return this.listen("mousedown", handler, options);
|
|
2280
|
-
};
|
|
2281
|
-
/**
|
|
2282
|
-
* @param handler {function (MouseEvent)}
|
|
2283
|
-
* @param options {Object | boolean}
|
|
2284
|
-
*/
|
|
2285
|
-
INode.prototype.onmouseenter = function (handler, options) {
|
|
2286
|
-
return this.listen("mouseenter", handler, options);
|
|
2353
|
+
INode.prototype.insertAdjacent = function (node) {
|
|
2354
|
+
this.$.node.parentNode.insertBefore(node, this.$.node);
|
|
2287
2355
|
};
|
|
2288
2356
|
/**
|
|
2289
|
-
*
|
|
2290
|
-
* @param
|
|
2357
|
+
* A v-show & ngShow alternative
|
|
2358
|
+
* @param cond {IValue} show condition
|
|
2291
2359
|
*/
|
|
2292
|
-
INode.prototype.
|
|
2293
|
-
|
|
2360
|
+
INode.prototype.bindShow = function (cond) {
|
|
2361
|
+
var $ = this.$;
|
|
2362
|
+
var node = $.node;
|
|
2363
|
+
if (node instanceof HTMLElement) {
|
|
2364
|
+
var lastDisplay_1 = node.style.display;
|
|
2365
|
+
var htmlNode_1 = node;
|
|
2366
|
+
return this.bindAlive(cond, function () {
|
|
2367
|
+
lastDisplay_1 = htmlNode_1.style.display;
|
|
2368
|
+
htmlNode_1.style.display = 'none';
|
|
2369
|
+
}, function () {
|
|
2370
|
+
htmlNode_1.style.display = lastDisplay_1;
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
else {
|
|
2374
|
+
throw userError('the element must be a html element', 'bind-show');
|
|
2375
|
+
}
|
|
2294
2376
|
};
|
|
2295
2377
|
/**
|
|
2296
|
-
*
|
|
2297
|
-
* @param
|
|
2378
|
+
* bind HTML
|
|
2379
|
+
* @param value {IValue}
|
|
2298
2380
|
*/
|
|
2299
|
-
INode.prototype.
|
|
2300
|
-
|
|
2381
|
+
INode.prototype.bindDomApi = function (name, value) {
|
|
2382
|
+
var $ = this.$;
|
|
2383
|
+
var node = $.node;
|
|
2384
|
+
if (node instanceof HTMLElement) {
|
|
2385
|
+
node[name] = value.$;
|
|
2386
|
+
this.watch(function (v) {
|
|
2387
|
+
node[name] = v;
|
|
2388
|
+
}, value);
|
|
2389
|
+
}
|
|
2390
|
+
else {
|
|
2391
|
+
throw userError("HTML can be bound for HTML nodes only", "dom-error");
|
|
2392
|
+
}
|
|
2301
2393
|
};
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
* @param options {Object | boolean}
|
|
2389
|
-
*/
|
|
2390
|
-
INode.prototype.ontouchstart = function (handler, options) {
|
|
2391
|
-
return this.listen("touchstart", handler, options);
|
|
2392
|
-
};
|
|
2393
|
-
/**
|
|
2394
|
-
* @param handler {function (TouchEvent)}
|
|
2395
|
-
* @param options {Object | boolean}
|
|
2396
|
-
*/
|
|
2397
|
-
INode.prototype.ontouchmove = function (handler, options) {
|
|
2398
|
-
return this.listen("touchmove", handler, options);
|
|
2399
|
-
};
|
|
2400
|
-
/**
|
|
2401
|
-
* @param handler {function (TouchEvent)}
|
|
2402
|
-
* @param options {Object | boolean}
|
|
2403
|
-
*/
|
|
2404
|
-
INode.prototype.ontouchend = function (handler, options) {
|
|
2405
|
-
return this.listen("touchend", handler, options);
|
|
2406
|
-
};
|
|
2407
|
-
/**
|
|
2408
|
-
* @param handler {function (TouchEvent)}
|
|
2409
|
-
* @param options {Object | boolean}
|
|
2410
|
-
*/
|
|
2411
|
-
INode.prototype.ontouchcancel = function (handler, options) {
|
|
2412
|
-
return this.listen("touchcancel", handler, options);
|
|
2413
|
-
};
|
|
2414
|
-
/**
|
|
2415
|
-
* @param handler {function (WheelEvent)}
|
|
2416
|
-
* @param options {Object | boolean}
|
|
2417
|
-
*/
|
|
2418
|
-
INode.prototype.onwheel = function (handler, options) {
|
|
2419
|
-
return this.listen("wheel", handler, options);
|
|
2420
|
-
};
|
|
2421
|
-
/**
|
|
2422
|
-
* @param handler {function (ProgressEvent)}
|
|
2423
|
-
* @param options {Object | boolean}
|
|
2424
|
-
*/
|
|
2425
|
-
INode.prototype.onabort = function (handler, options) {
|
|
2426
|
-
return this.listen("abort", handler, options);
|
|
2427
|
-
};
|
|
2428
|
-
/**
|
|
2429
|
-
* @param handler {function (ProgressEvent)}
|
|
2430
|
-
* @param options {Object | boolean}
|
|
2431
|
-
*/
|
|
2432
|
-
INode.prototype.onerror = function (handler, options) {
|
|
2433
|
-
return this.listen("error", handler, options);
|
|
2434
|
-
};
|
|
2435
|
-
/**
|
|
2436
|
-
* @param handler {function (ProgressEvent)}
|
|
2437
|
-
* @param options {Object | boolean}
|
|
2438
|
-
*/
|
|
2439
|
-
INode.prototype.onload = function (handler, options) {
|
|
2440
|
-
return this.listen("load", handler, options);
|
|
2441
|
-
};
|
|
2442
|
-
/**
|
|
2443
|
-
* @param handler {function (ProgressEvent)}
|
|
2444
|
-
* @param options {Object | boolean}
|
|
2445
|
-
*/
|
|
2446
|
-
INode.prototype.onloadend = function (handler, options) {
|
|
2447
|
-
return this.listen("loadend", handler, options);
|
|
2448
|
-
};
|
|
2449
|
-
/**
|
|
2450
|
-
* @param handler {function (ProgressEvent)}
|
|
2451
|
-
* @param options {Object | boolean}
|
|
2452
|
-
*/
|
|
2453
|
-
INode.prototype.onloadstart = function (handler, options) {
|
|
2454
|
-
return this.listen("loadstart", handler, options);
|
|
2455
|
-
};
|
|
2456
|
-
/**
|
|
2457
|
-
* @param handler {function (ProgressEvent)}
|
|
2458
|
-
* @param options {Object | boolean}
|
|
2459
|
-
*/
|
|
2460
|
-
INode.prototype.onprogress = function (handler, options) {
|
|
2461
|
-
return this.listen("progress", handler, options);
|
|
2462
|
-
};
|
|
2463
|
-
/**
|
|
2464
|
-
* @param handler {function (ProgressEvent)}
|
|
2465
|
-
* @param options {Object | boolean}
|
|
2466
|
-
*/
|
|
2467
|
-
INode.prototype.ontimeout = function (handler, options) {
|
|
2468
|
-
return this.listen("timeout", handler, options);
|
|
2469
|
-
};
|
|
2470
|
-
/**
|
|
2471
|
-
* @param handler {function (DragEvent)}
|
|
2472
|
-
* @param options {Object | boolean}
|
|
2473
|
-
*/
|
|
2474
|
-
INode.prototype.ondrag = function (handler, options) {
|
|
2475
|
-
return this.listen("drag", handler, options);
|
|
2476
|
-
};
|
|
2477
|
-
/**
|
|
2478
|
-
* @param handler {function (DragEvent)}
|
|
2479
|
-
* @param options {Object | boolean}
|
|
2480
|
-
*/
|
|
2481
|
-
INode.prototype.ondragend = function (handler, options) {
|
|
2482
|
-
return this.listen("dragend", handler, options);
|
|
2483
|
-
};
|
|
2484
|
-
/**
|
|
2485
|
-
* @param handler {function (DragEvent)}
|
|
2486
|
-
* @param options {Object | boolean}
|
|
2487
|
-
*/
|
|
2488
|
-
INode.prototype.ondragenter = function (handler, options) {
|
|
2489
|
-
return this.listen("dragenter", handler, options);
|
|
2490
|
-
};
|
|
2491
|
-
/**
|
|
2492
|
-
* @param handler {function (DragEvent)}
|
|
2493
|
-
* @param options {Object | boolean}
|
|
2494
|
-
*/
|
|
2495
|
-
INode.prototype.ondragexit = function (handler, options) {
|
|
2496
|
-
return this.listen("dragexit", handler, options);
|
|
2497
|
-
};
|
|
2498
|
-
/**
|
|
2499
|
-
* @param handler {function (DragEvent)}
|
|
2500
|
-
* @param options {Object | boolean}
|
|
2501
|
-
*/
|
|
2502
|
-
INode.prototype.ondragleave = function (handler, options) {
|
|
2503
|
-
return this.listen("dragleave", handler, options);
|
|
2504
|
-
};
|
|
2505
|
-
/**
|
|
2506
|
-
* @param handler {function (DragEvent)}
|
|
2507
|
-
* @param options {Object | boolean}
|
|
2508
|
-
*/
|
|
2509
|
-
INode.prototype.ondragover = function (handler, options) {
|
|
2510
|
-
return this.listen("dragover", handler, options);
|
|
2511
|
-
};
|
|
2512
|
-
/**
|
|
2513
|
-
* @param handler {function (DragEvent)}
|
|
2514
|
-
* @param options {Object | boolean}
|
|
2515
|
-
*/
|
|
2516
|
-
INode.prototype.ondragstart = function (handler, options) {
|
|
2517
|
-
return this.listen("dragstart", handler, options);
|
|
2518
|
-
};
|
|
2519
|
-
/**
|
|
2520
|
-
* @param handler {function (DragEvent)}
|
|
2521
|
-
* @param options {Object | boolean}
|
|
2522
|
-
*/
|
|
2523
|
-
INode.prototype.ondrop = function (handler, options) {
|
|
2524
|
-
return this.listen("drop", handler, options);
|
|
2525
|
-
};
|
|
2526
|
-
/**
|
|
2527
|
-
* @param handler {function (PointerEvent)}
|
|
2528
|
-
* @param options {Object | boolean}
|
|
2529
|
-
*/
|
|
2530
|
-
INode.prototype.onpointerover = function (handler, options) {
|
|
2531
|
-
return this.listen("pointerover", handler, options);
|
|
2532
|
-
};
|
|
2533
|
-
/**
|
|
2534
|
-
* @param handler {function (PointerEvent)}
|
|
2535
|
-
* @param options {Object | boolean}
|
|
2536
|
-
*/
|
|
2537
|
-
INode.prototype.onpointerenter = function (handler, options) {
|
|
2538
|
-
return this.listen("pointerenter", handler, options);
|
|
2539
|
-
};
|
|
2540
|
-
/**
|
|
2541
|
-
* @param handler {function (PointerEvent)}
|
|
2542
|
-
* @param options {Object | boolean}
|
|
2543
|
-
*/
|
|
2544
|
-
INode.prototype.onpointerdown = function (handler, options) {
|
|
2545
|
-
return this.listen("pointerdown", handler, options);
|
|
2546
|
-
};
|
|
2547
|
-
/**
|
|
2548
|
-
* @param handler {function (PointerEvent)}
|
|
2549
|
-
* @param options {Object | boolean}
|
|
2550
|
-
*/
|
|
2551
|
-
INode.prototype.onpointermove = function (handler, options) {
|
|
2552
|
-
return this.listen("pointermove", handler, options);
|
|
2553
|
-
};
|
|
2554
|
-
/**
|
|
2555
|
-
* @param handler {function (PointerEvent)}
|
|
2556
|
-
* @param options {Object | boolean}
|
|
2557
|
-
*/
|
|
2558
|
-
INode.prototype.onpointerup = function (handler, options) {
|
|
2559
|
-
return this.listen("pointerup", handler, options);
|
|
2560
|
-
};
|
|
2561
|
-
/**
|
|
2562
|
-
* @param handler {function (PointerEvent)}
|
|
2563
|
-
* @param options {Object | boolean}
|
|
2564
|
-
*/
|
|
2565
|
-
INode.prototype.onpointercancel = function (handler, options) {
|
|
2566
|
-
return this.listen("pointercancel", handler, options);
|
|
2567
|
-
};
|
|
2568
|
-
/**
|
|
2569
|
-
* @param handler {function (PointerEvent)}
|
|
2570
|
-
* @param options {Object | boolean}
|
|
2571
|
-
*/
|
|
2572
|
-
INode.prototype.onpointerout = function (handler, options) {
|
|
2573
|
-
return this.listen("pointerout", handler, options);
|
|
2574
|
-
};
|
|
2575
|
-
/**
|
|
2576
|
-
* @param handler {function (PointerEvent)}
|
|
2577
|
-
* @param options {Object | boolean}
|
|
2578
|
-
*/
|
|
2579
|
-
INode.prototype.onpointerleave = function (handler, options) {
|
|
2580
|
-
return this.listen("pointerleave", handler, options);
|
|
2581
|
-
};
|
|
2582
|
-
/**
|
|
2583
|
-
* @param handler {function (PointerEvent)}
|
|
2584
|
-
* @param options {Object | boolean}
|
|
2585
|
-
*/
|
|
2586
|
-
INode.prototype.ongotpointercapture = function (handler, options) {
|
|
2587
|
-
return this.listen("gotpointercapture", handler, options);
|
|
2588
|
-
};
|
|
2589
|
-
/**
|
|
2590
|
-
* @param handler {function (PointerEvent)}
|
|
2591
|
-
* @param options {Object | boolean}
|
|
2592
|
-
*/
|
|
2593
|
-
INode.prototype.onlostpointercapture = function (handler, options) {
|
|
2594
|
-
return this.listen("lostpointercapture", handler, options);
|
|
2595
|
-
};
|
|
2596
|
-
/**
|
|
2597
|
-
* @param handler {function (AnimationEvent)}
|
|
2598
|
-
* @param options {Object | boolean}
|
|
2599
|
-
*/
|
|
2600
|
-
INode.prototype.onanimationstart = function (handler, options) {
|
|
2601
|
-
return this.listen("animationstart", handler, options);
|
|
2602
|
-
};
|
|
2603
|
-
/**
|
|
2604
|
-
* @param handler {function (AnimationEvent)}
|
|
2605
|
-
* @param options {Object | boolean}
|
|
2606
|
-
*/
|
|
2607
|
-
INode.prototype.onanimationend = function (handler, options) {
|
|
2608
|
-
return this.listen("animationend", handler, options);
|
|
2609
|
-
};
|
|
2610
|
-
/**
|
|
2611
|
-
* @param handler {function (AnimationEvent)}
|
|
2612
|
-
* @param options {Object | boolean}
|
|
2613
|
-
*/
|
|
2614
|
-
INode.prototype.onanimationiteraton = function (handler, options) {
|
|
2615
|
-
return this.listen("animationiteration", handler, options);
|
|
2616
|
-
};
|
|
2617
|
-
/**
|
|
2618
|
-
* @param handler {function (ClipboardEvent)}
|
|
2619
|
-
* @param options {Object | boolean}
|
|
2620
|
-
*/
|
|
2621
|
-
INode.prototype.onclipboardchange = function (handler, options) {
|
|
2622
|
-
return this.listen("clipboardchange", handler, options);
|
|
2623
|
-
};
|
|
2624
|
-
/**
|
|
2625
|
-
* @param handler {function (ClipboardEvent)}
|
|
2626
|
-
* @param options {Object | boolean}
|
|
2627
|
-
*/
|
|
2628
|
-
INode.prototype.oncut = function (handler, options) {
|
|
2629
|
-
return this.listen("cut", handler, options);
|
|
2630
|
-
};
|
|
2631
|
-
/**
|
|
2632
|
-
* @param handler {function (ClipboardEvent)}
|
|
2633
|
-
* @param options {Object | boolean}
|
|
2634
|
-
*/
|
|
2635
|
-
INode.prototype.oncopy = function (handler, options) {
|
|
2636
|
-
return this.listen("copy", handler, options);
|
|
2637
|
-
};
|
|
2638
|
-
/**
|
|
2639
|
-
* @param handler {function (ClipboardEvent)}
|
|
2640
|
-
* @param options {Object | boolean}
|
|
2641
|
-
*/
|
|
2642
|
-
INode.prototype.onpaste = function (handler, options) {
|
|
2643
|
-
return this.listen("paste", handler, options);
|
|
2644
|
-
};
|
|
2645
|
-
INode.prototype.insertAdjacent = function (node) {
|
|
2646
|
-
var $ = this.$;
|
|
2647
|
-
$.app.run.insertBefore($.node, node);
|
|
2648
|
-
};
|
|
2649
|
-
/**
|
|
2650
|
-
* A v-show & ngShow alternative
|
|
2651
|
-
* @param cond {IValue} show condition
|
|
2652
|
-
*/
|
|
2653
|
-
INode.prototype.bindShow = function (cond) {
|
|
2654
|
-
var $ = this.$;
|
|
2655
|
-
var node = $.node;
|
|
2656
|
-
if (node instanceof HTMLElement) {
|
|
2657
|
-
var lastDisplay_1 = node.style.display;
|
|
2658
|
-
var htmlNode_1 = node;
|
|
2659
|
-
return this.bindAlive(cond, function () {
|
|
2660
|
-
lastDisplay_1 = htmlNode_1.style.display;
|
|
2661
|
-
htmlNode_1.style.display = 'none';
|
|
2662
|
-
}, function () {
|
|
2663
|
-
htmlNode_1.style.display = lastDisplay_1;
|
|
2664
|
-
});
|
|
2665
|
-
}
|
|
2666
|
-
else {
|
|
2667
|
-
throw userError('the element must be a html element', 'bind-show');
|
|
2668
|
-
}
|
|
2669
|
-
};
|
|
2670
|
-
/**
|
|
2671
|
-
* bind HTML
|
|
2672
|
-
* @param value {IValue}
|
|
2673
|
-
*/
|
|
2674
|
-
INode.prototype.html = function (value) {
|
|
2675
|
-
var $ = this.$;
|
|
2676
|
-
var node = $.node;
|
|
2677
|
-
if (node instanceof HTMLElement) {
|
|
2678
|
-
node.innerHTML = value.$;
|
|
2679
|
-
this.watch(function (v) {
|
|
2680
|
-
node.innerHTML = v;
|
|
2681
|
-
}, value);
|
|
2682
|
-
}
|
|
2683
|
-
else {
|
|
2684
|
-
throw userError("HTML can be bound for HTML nodes only", "dom-error");
|
|
2685
|
-
}
|
|
2394
|
+
INode.prototype.applyOptions = function (options) {
|
|
2395
|
+
var _this = this;
|
|
2396
|
+
options["v:attr"] && Object.keys(options["v:attr"]).forEach(function (name) {
|
|
2397
|
+
var value = options["v:attr"][name];
|
|
2398
|
+
if (value instanceof IValue) {
|
|
2399
|
+
_this.attr(name, value);
|
|
2400
|
+
}
|
|
2401
|
+
else {
|
|
2402
|
+
_this.setAttr(name, value);
|
|
2403
|
+
}
|
|
2404
|
+
});
|
|
2405
|
+
if (options.class) {
|
|
2406
|
+
var handleClass_1 = function (name, value) {
|
|
2407
|
+
if (value instanceof IValue) {
|
|
2408
|
+
_this.floatingClass(value, name);
|
|
2409
|
+
}
|
|
2410
|
+
else if (value && name !== '$') {
|
|
2411
|
+
_this.addClass(name);
|
|
2412
|
+
}
|
|
2413
|
+
else {
|
|
2414
|
+
_this.removeClasse(name);
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
if (Array.isArray(options.class)) {
|
|
2418
|
+
options.class.forEach(function (item) {
|
|
2419
|
+
if (item instanceof IValue) {
|
|
2420
|
+
_this.bindClass(item);
|
|
2421
|
+
}
|
|
2422
|
+
else if (typeof item == "string") {
|
|
2423
|
+
_this.addClass(item);
|
|
2424
|
+
}
|
|
2425
|
+
else {
|
|
2426
|
+
Reflect.ownKeys(item).forEach(function (name) {
|
|
2427
|
+
handleClass_1(name, item[name]);
|
|
2428
|
+
});
|
|
2429
|
+
}
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
else {
|
|
2433
|
+
options.class.$.forEach(function (item) {
|
|
2434
|
+
_this.bindClass(item);
|
|
2435
|
+
});
|
|
2436
|
+
Reflect.ownKeys(options.class).forEach(function (name) {
|
|
2437
|
+
handleClass_1(name, options.class[name]);
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
options.style && Object.keys(options.style).forEach(function (name) {
|
|
2442
|
+
var value = options.style[name];
|
|
2443
|
+
if (value instanceof IValue) {
|
|
2444
|
+
_this.style(name, value);
|
|
2445
|
+
}
|
|
2446
|
+
else if (typeof value === "string") {
|
|
2447
|
+
_this.setStyle(name, value);
|
|
2448
|
+
}
|
|
2449
|
+
else {
|
|
2450
|
+
if (value[0] instanceof IValue) {
|
|
2451
|
+
_this.style(name, _this.expr(function (v) { return v + value[1]; }, value[0]));
|
|
2452
|
+
}
|
|
2453
|
+
else {
|
|
2454
|
+
_this.setStyle(name, value[0] + value[1]);
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
});
|
|
2458
|
+
options["v:events"] && Object.keys(options["v:events"]).forEach(function (name) {
|
|
2459
|
+
_this.listen(name, options["v:events"][name]);
|
|
2460
|
+
});
|
|
2461
|
+
if (options["v:bind"]) {
|
|
2462
|
+
var inode_1 = this.node;
|
|
2463
|
+
Reflect.ownKeys(options["v:bind"]).forEach(function (k) {
|
|
2464
|
+
var value = options["v:bind"][k];
|
|
2465
|
+
if (k === 'value' && (inode_1 instanceof HTMLInputElement || inode_1 instanceof HTMLTextAreaElement)) {
|
|
2466
|
+
inode_1.oninput = function () { return value.$ = inode_1.value; };
|
|
2467
|
+
}
|
|
2468
|
+
else if (k === 'checked' && inode_1 instanceof HTMLInputElement) {
|
|
2469
|
+
inode_1.oninput = function () { return value.$ = inode_1.checked; };
|
|
2470
|
+
}
|
|
2471
|
+
else if (k === 'volume' && inode_1 instanceof HTMLMediaElement) {
|
|
2472
|
+
inode_1.onvolumechange = function () { return value.$ = inode_1.volume; };
|
|
2473
|
+
}
|
|
2474
|
+
_this.bindDomApi(k, value);
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
options["v:set"] && Object.keys(options["v:set"]).forEach(function (key) {
|
|
2478
|
+
_this.node[key] = options["v:set"][key];
|
|
2479
|
+
});
|
|
2686
2480
|
};
|
|
2687
2481
|
return INode;
|
|
2688
2482
|
}(Fragment));
|
|
@@ -2694,9 +2488,9 @@ var INode = /** @class */ (function (_super) {
|
|
|
2694
2488
|
*/
|
|
2695
2489
|
var Tag = /** @class */ (function (_super) {
|
|
2696
2490
|
__extends(Tag, _super);
|
|
2697
|
-
function Tag() {
|
|
2698
|
-
var _this =
|
|
2699
|
-
_this
|
|
2491
|
+
function Tag(input) {
|
|
2492
|
+
var _this = _super.call(this, input) || this;
|
|
2493
|
+
_this.$seal();
|
|
2700
2494
|
return _this;
|
|
2701
2495
|
}
|
|
2702
2496
|
Tag.prototype.preinit = function (app, parent, tagName) {
|
|
@@ -2709,6 +2503,9 @@ var Tag = /** @class */ (function (_super) {
|
|
|
2709
2503
|
$.node = node;
|
|
2710
2504
|
$.parent.appendNode(node);
|
|
2711
2505
|
};
|
|
2506
|
+
Tag.prototype.compose = function (input) {
|
|
2507
|
+
input.slot && input.slot(this);
|
|
2508
|
+
};
|
|
2712
2509
|
Tag.prototype.findFirstChild = function () {
|
|
2713
2510
|
return this.$.unmounted ? null : this.$.node;
|
|
2714
2511
|
};
|
|
@@ -2726,8 +2523,7 @@ var Tag = /** @class */ (function (_super) {
|
|
|
2726
2523
|
}
|
|
2727
2524
|
};
|
|
2728
2525
|
Tag.prototype.appendNode = function (node) {
|
|
2729
|
-
|
|
2730
|
-
$.app.run.appendChild($.node, node);
|
|
2526
|
+
this.$.node.appendChild(node);
|
|
2731
2527
|
};
|
|
2732
2528
|
/**
|
|
2733
2529
|
* Mount/Unmount a node
|
|
@@ -2749,9 +2545,9 @@ var Tag = /** @class */ (function (_super) {
|
|
|
2749
2545
|
/**
|
|
2750
2546
|
* Runs GC
|
|
2751
2547
|
*/
|
|
2752
|
-
Tag.prototype
|
|
2548
|
+
Tag.prototype.$destroy = function () {
|
|
2753
2549
|
this.node.remove();
|
|
2754
|
-
_super.prototype
|
|
2550
|
+
_super.prototype.$destroy.call(this);
|
|
2755
2551
|
};
|
|
2756
2552
|
return Tag;
|
|
2757
2553
|
}(INode));
|
|
@@ -2763,23 +2559,25 @@ var Tag = /** @class */ (function (_super) {
|
|
|
2763
2559
|
*/
|
|
2764
2560
|
var Extension = /** @class */ (function (_super) {
|
|
2765
2561
|
__extends(Extension, _super);
|
|
2766
|
-
function Extension(
|
|
2767
|
-
|
|
2768
|
-
_this.seal();
|
|
2769
|
-
return _this;
|
|
2562
|
+
function Extension() {
|
|
2563
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2770
2564
|
}
|
|
2771
2565
|
Extension.prototype.preinit = function (app, parent) {
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2566
|
+
var $ = this.$;
|
|
2567
|
+
var it = parent;
|
|
2568
|
+
while (it && !(it instanceof INode)) {
|
|
2569
|
+
it = it.parent;
|
|
2776
2570
|
}
|
|
2777
|
-
|
|
2571
|
+
if (it && it instanceof INode) {
|
|
2572
|
+
$.node = it.node;
|
|
2573
|
+
}
|
|
2574
|
+
$.preinit(app, parent);
|
|
2575
|
+
if (!it) {
|
|
2778
2576
|
throw userError("A extension node can be encapsulated only in a tag/extension/component", "virtual-dom");
|
|
2779
2577
|
}
|
|
2780
2578
|
};
|
|
2781
|
-
Extension.prototype
|
|
2782
|
-
_super.prototype
|
|
2579
|
+
Extension.prototype.$destroy = function () {
|
|
2580
|
+
_super.prototype.$destroy.call(this);
|
|
2783
2581
|
};
|
|
2784
2582
|
return Extension;
|
|
2785
2583
|
}(INode));
|
|
@@ -2792,12 +2590,15 @@ var Extension = /** @class */ (function (_super) {
|
|
|
2792
2590
|
var Component = /** @class */ (function (_super) {
|
|
2793
2591
|
__extends(Component, _super);
|
|
2794
2592
|
function Component() {
|
|
2795
|
-
|
|
2796
|
-
_this.seal();
|
|
2797
|
-
return _this;
|
|
2593
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2798
2594
|
}
|
|
2799
|
-
Component.prototype.
|
|
2800
|
-
_super.prototype.
|
|
2595
|
+
Component.prototype.init = function () {
|
|
2596
|
+
_super.prototype.composeNow.call(this);
|
|
2597
|
+
this.ready();
|
|
2598
|
+
_super.prototype.applyOptionsNow.call(this);
|
|
2599
|
+
};
|
|
2600
|
+
Component.prototype.ready = function () {
|
|
2601
|
+
_super.prototype.ready.call(this);
|
|
2801
2602
|
if (this.children.size !== 1) {
|
|
2802
2603
|
throw userError("Component must have a child only", "dom-error");
|
|
2803
2604
|
}
|
|
@@ -2825,19 +2626,24 @@ var SwitchedNodePrivate = /** @class */ (function (_super) {
|
|
|
2825
2626
|
__extends(SwitchedNodePrivate, _super);
|
|
2826
2627
|
function SwitchedNodePrivate() {
|
|
2827
2628
|
var _this = this; _super.call(this);
|
|
2828
|
-
|
|
2629
|
+
/**
|
|
2630
|
+
* Array of possible cases
|
|
2631
|
+
* @type {Array<{cond : IValue<boolean>, cb : function(Fragment)}>}
|
|
2632
|
+
*/
|
|
2633
|
+
_this.cases = [];
|
|
2634
|
+
_this.$seal();
|
|
2829
2635
|
return _this;
|
|
2830
2636
|
}
|
|
2831
2637
|
/**
|
|
2832
2638
|
* Runs GC
|
|
2833
2639
|
*/
|
|
2834
|
-
SwitchedNodePrivate.prototype
|
|
2640
|
+
SwitchedNodePrivate.prototype.$destroy = function () {
|
|
2835
2641
|
this.cases.forEach(function (c) {
|
|
2836
2642
|
delete c.cond;
|
|
2837
2643
|
delete c.cb;
|
|
2838
2644
|
});
|
|
2839
2645
|
this.cases.splice(0);
|
|
2840
|
-
_super.prototype
|
|
2646
|
+
_super.prototype.$destroy.call(this);
|
|
2841
2647
|
};
|
|
2842
2648
|
return SwitchedNodePrivate;
|
|
2843
2649
|
}(FragmentPrivate));
|
|
@@ -2851,7 +2657,7 @@ var SwitchedNode = /** @class */ (function (_super) {
|
|
|
2851
2657
|
* Constructs a switch node and define a sync function
|
|
2852
2658
|
*/
|
|
2853
2659
|
function SwitchedNode() {
|
|
2854
|
-
var _this = _super.call(this, new SwitchedNodePrivate) || this;
|
|
2660
|
+
var _this = _super.call(this, {}, new SwitchedNodePrivate) || this;
|
|
2855
2661
|
_this.$.sync = function () {
|
|
2856
2662
|
var $ = _this.$;
|
|
2857
2663
|
var i = 0;
|
|
@@ -2864,7 +2670,7 @@ var SwitchedNode = /** @class */ (function (_super) {
|
|
|
2864
2670
|
return;
|
|
2865
2671
|
}
|
|
2866
2672
|
if (_this.lastChild) {
|
|
2867
|
-
_this.lastChild
|
|
2673
|
+
_this.lastChild.$destroy();
|
|
2868
2674
|
_this.children.clear();
|
|
2869
2675
|
_this.lastChild = null;
|
|
2870
2676
|
}
|
|
@@ -2876,23 +2682,20 @@ var SwitchedNode = /** @class */ (function (_super) {
|
|
|
2876
2682
|
$.index = -1;
|
|
2877
2683
|
}
|
|
2878
2684
|
};
|
|
2879
|
-
_this
|
|
2685
|
+
_this.$seal();
|
|
2880
2686
|
return _this;
|
|
2881
2687
|
}
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
SwitchedNode.prototype.setCases = function (cases) {
|
|
2887
|
-
var $ = this.$;
|
|
2888
|
-
$.cases = __spreadArray([], cases, true);
|
|
2688
|
+
SwitchedNode.prototype.addCase = function (case_) {
|
|
2689
|
+
this.$.cases.push(case_);
|
|
2690
|
+
case_.cond.$on(this.$.sync);
|
|
2691
|
+
this.$.sync();
|
|
2889
2692
|
};
|
|
2890
2693
|
/**
|
|
2891
2694
|
* Creates a child node
|
|
2892
2695
|
* @param cb {function(Fragment)} Call-back
|
|
2893
2696
|
*/
|
|
2894
2697
|
SwitchedNode.prototype.createChild = function (cb) {
|
|
2895
|
-
var node = new Fragment();
|
|
2698
|
+
var node = new Fragment({});
|
|
2896
2699
|
node.preinit(this.$.app, this);
|
|
2897
2700
|
node.init();
|
|
2898
2701
|
this.lastChild = node;
|
|
@@ -2902,19 +2705,20 @@ var SwitchedNode = /** @class */ (function (_super) {
|
|
|
2902
2705
|
SwitchedNode.prototype.ready = function () {
|
|
2903
2706
|
var $ = this.$;
|
|
2904
2707
|
$.cases.forEach(function (c) {
|
|
2905
|
-
c.cond
|
|
2708
|
+
c.cond.$on($.sync);
|
|
2906
2709
|
});
|
|
2907
2710
|
$.sync();
|
|
2908
2711
|
};
|
|
2909
|
-
SwitchedNode.prototype
|
|
2712
|
+
SwitchedNode.prototype.$destroy = function () {
|
|
2910
2713
|
var $ = this.$;
|
|
2911
2714
|
$.cases.forEach(function (c) {
|
|
2912
|
-
c.cond
|
|
2715
|
+
c.cond.$off($.sync);
|
|
2913
2716
|
});
|
|
2914
|
-
_super.prototype
|
|
2717
|
+
_super.prototype.$destroy.call(this);
|
|
2915
2718
|
};
|
|
2916
2719
|
return SwitchedNode;
|
|
2917
2720
|
}(Fragment));
|
|
2721
|
+
|
|
2918
2722
|
/**
|
|
2919
2723
|
* The private part of a text node
|
|
2920
2724
|
*/
|
|
@@ -2922,7 +2726,7 @@ var DebugPrivate = /** @class */ (function (_super) {
|
|
|
2922
2726
|
__extends(DebugPrivate, _super);
|
|
2923
2727
|
function DebugPrivate() {
|
|
2924
2728
|
var _this = this; _super.call(this);
|
|
2925
|
-
_this
|
|
2729
|
+
_this.$seal();
|
|
2926
2730
|
return _this;
|
|
2927
2731
|
}
|
|
2928
2732
|
/**
|
|
@@ -2943,9 +2747,9 @@ var DebugPrivate = /** @class */ (function (_super) {
|
|
|
2943
2747
|
/**
|
|
2944
2748
|
* Clear node data
|
|
2945
2749
|
*/
|
|
2946
|
-
DebugPrivate.prototype
|
|
2750
|
+
DebugPrivate.prototype.$destroy = function () {
|
|
2947
2751
|
this.node.remove();
|
|
2948
|
-
_super.prototype
|
|
2752
|
+
_super.prototype.$destroy.call(this);
|
|
2949
2753
|
};
|
|
2950
2754
|
return DebugPrivate;
|
|
2951
2755
|
}(FragmentPrivate));
|
|
@@ -2958,13 +2762,13 @@ var DebugPrivate = /** @class */ (function (_super) {
|
|
|
2958
2762
|
var DebugNode = /** @class */ (function (_super) {
|
|
2959
2763
|
__extends(DebugNode, _super);
|
|
2960
2764
|
function DebugNode() {
|
|
2961
|
-
var _this =
|
|
2765
|
+
var _this = _super.call(this, {}) || this;
|
|
2962
2766
|
/**
|
|
2963
2767
|
* private data
|
|
2964
2768
|
* @type {DebugNode}
|
|
2965
2769
|
*/
|
|
2966
2770
|
_this.$ = new DebugPrivate();
|
|
2967
|
-
_this
|
|
2771
|
+
_this.$seal();
|
|
2968
2772
|
return _this;
|
|
2969
2773
|
}
|
|
2970
2774
|
DebugNode.prototype.preinit = function (app, parent, text) {
|
|
@@ -2977,9 +2781,9 @@ var DebugNode = /** @class */ (function (_super) {
|
|
|
2977
2781
|
/**
|
|
2978
2782
|
* Runs garbage collector
|
|
2979
2783
|
*/
|
|
2980
|
-
DebugNode.prototype
|
|
2981
|
-
this
|
|
2982
|
-
_super.prototype
|
|
2784
|
+
DebugNode.prototype.$destroy = function () {
|
|
2785
|
+
this.$.$destroy();
|
|
2786
|
+
_super.prototype.$destroy.call(this);
|
|
2983
2787
|
};
|
|
2984
2788
|
return DebugNode;
|
|
2985
2789
|
}(Fragment));
|
|
@@ -2995,6 +2799,7 @@ window.Tag = Tag;
|
|
|
2995
2799
|
window.Extension = Extension;
|
|
2996
2800
|
window.Component = Component;
|
|
2997
2801
|
window.SwitchedNodePrivate = SwitchedNodePrivate;
|
|
2802
|
+
window.SwitchedNode = SwitchedNode;
|
|
2998
2803
|
window.DebugPrivate = DebugPrivate;
|
|
2999
2804
|
window.DebugNode = DebugNode;
|
|
3000
2805
|
|
|
@@ -3007,12 +2812,12 @@ window.DebugNode = DebugNode;
|
|
|
3007
2812
|
var AppNode = /** @class */ (function (_super) {
|
|
3008
2813
|
__extends(AppNode, _super);
|
|
3009
2814
|
/**
|
|
3010
|
-
* @param
|
|
2815
|
+
* @param input
|
|
3011
2816
|
*/
|
|
3012
|
-
function AppNode(
|
|
3013
|
-
var _this =
|
|
3014
|
-
_this.
|
|
3015
|
-
_this
|
|
2817
|
+
function AppNode(input) {
|
|
2818
|
+
var _this = _super.call(this, input) || this;
|
|
2819
|
+
_this.debugUi = input.debugUi || false;
|
|
2820
|
+
_this.$seal();
|
|
3016
2821
|
return _this;
|
|
3017
2822
|
}
|
|
3018
2823
|
return AppNode;
|
|
@@ -3028,25 +2833,40 @@ var App = /** @class */ (function (_super) {
|
|
|
3028
2833
|
/**
|
|
3029
2834
|
* Constructs an app node
|
|
3030
2835
|
* @param node {Element} The root of application
|
|
3031
|
-
* @param
|
|
2836
|
+
* @param input
|
|
3032
2837
|
*/
|
|
3033
|
-
function App(node,
|
|
3034
|
-
var _this = _super.call(this,
|
|
2838
|
+
function App(node, input) {
|
|
2839
|
+
var _this = _super.call(this, input) || this;
|
|
3035
2840
|
_this.$.node = node;
|
|
3036
2841
|
_this.preinit(_this, _this);
|
|
3037
|
-
_this.
|
|
2842
|
+
_this.init();
|
|
2843
|
+
_this.$seal();
|
|
3038
2844
|
return _this;
|
|
3039
2845
|
}
|
|
3040
2846
|
App.prototype.appendNode = function (node) {
|
|
3041
|
-
|
|
3042
|
-
this.run.appendChild($.node, node);
|
|
2847
|
+
this.$.node.appendChild(node);
|
|
3043
2848
|
};
|
|
3044
2849
|
return App;
|
|
3045
2850
|
}(AppNode));
|
|
3046
2851
|
|
|
2852
|
+
var Portal = /** @class */ (function (_super) {
|
|
2853
|
+
__extends(Portal, _super);
|
|
2854
|
+
function Portal(input) {
|
|
2855
|
+
var _this = _super.call(this, input) || this;
|
|
2856
|
+
_this.$.node = input.node;
|
|
2857
|
+
_this.$seal();
|
|
2858
|
+
return _this;
|
|
2859
|
+
}
|
|
2860
|
+
Portal.prototype.appendNode = function (node) {
|
|
2861
|
+
this.$.node.appendChild(node);
|
|
2862
|
+
};
|
|
2863
|
+
return Portal;
|
|
2864
|
+
}(AppNode));
|
|
2865
|
+
|
|
3047
2866
|
|
|
3048
2867
|
window.AppNode = AppNode;
|
|
3049
2868
|
window.App = App;
|
|
2869
|
+
window.Portal = Portal;
|
|
3050
2870
|
|
|
3051
2871
|
// ./lib-es5/node/interceptor.js
|
|
3052
2872
|
/**
|
|
@@ -3159,13 +2979,18 @@ var AttributeBinding = /** @class */ (function (_super) {
|
|
|
3159
2979
|
var _this = _super.call(this, value) || this;
|
|
3160
2980
|
_this.init(function (value) {
|
|
3161
2981
|
if (value) {
|
|
3162
|
-
|
|
2982
|
+
if (typeof value === 'boolean') {
|
|
2983
|
+
node.node.setAttribute(name, "");
|
|
2984
|
+
}
|
|
2985
|
+
else {
|
|
2986
|
+
node.node.setAttribute(name, "".concat(value));
|
|
2987
|
+
}
|
|
3163
2988
|
}
|
|
3164
2989
|
else {
|
|
3165
|
-
node.
|
|
2990
|
+
node.node.removeAttribute(name);
|
|
3166
2991
|
}
|
|
3167
2992
|
});
|
|
3168
|
-
_this
|
|
2993
|
+
_this.$seal();
|
|
3169
2994
|
return _this;
|
|
3170
2995
|
}
|
|
3171
2996
|
return AttributeBinding;
|
|
@@ -3192,10 +3017,10 @@ var StyleBinding = /** @class */ (function (_super) {
|
|
|
3192
3017
|
var _this = _super.call(this, value) || this;
|
|
3193
3018
|
_this.init(function (value) {
|
|
3194
3019
|
if (node.node instanceof HTMLElement) {
|
|
3195
|
-
node.
|
|
3020
|
+
node.node.style.setProperty(name, value);
|
|
3196
3021
|
}
|
|
3197
3022
|
});
|
|
3198
|
-
_this
|
|
3023
|
+
_this.$seal();
|
|
3199
3024
|
return _this;
|
|
3200
3025
|
}
|
|
3201
3026
|
return StyleBinding;
|
|
@@ -3206,10 +3031,10 @@ window.StyleBinding = StyleBinding;
|
|
|
3206
3031
|
|
|
3207
3032
|
// ./lib-es5/binding/class.js
|
|
3208
3033
|
function addClass(node, cl) {
|
|
3209
|
-
node.
|
|
3034
|
+
node.node.classList.add(cl);
|
|
3210
3035
|
}
|
|
3211
3036
|
function removeClass(node, cl) {
|
|
3212
|
-
node.
|
|
3037
|
+
node.node.classList.remove(cl);
|
|
3213
3038
|
}
|
|
3214
3039
|
var StaticClassBinding = /** @class */ (function (_super) {
|
|
3215
3040
|
__extends(StaticClassBinding, _super);
|
|
@@ -3227,7 +3052,7 @@ var StaticClassBinding = /** @class */ (function (_super) {
|
|
|
3227
3052
|
_this.current = value;
|
|
3228
3053
|
}
|
|
3229
3054
|
});
|
|
3230
|
-
_this
|
|
3055
|
+
_this.$seal();
|
|
3231
3056
|
return _this;
|
|
3232
3057
|
}
|
|
3233
3058
|
return StaticClassBinding;
|
|
@@ -3249,7 +3074,7 @@ var DynamicalClassBinding = /** @class */ (function (_super) {
|
|
|
3249
3074
|
_this.current = value;
|
|
3250
3075
|
}
|
|
3251
3076
|
});
|
|
3252
|
-
_this
|
|
3077
|
+
_this.$seal();
|
|
3253
3078
|
return _this;
|
|
3254
3079
|
}
|
|
3255
3080
|
return DynamicalClassBinding;
|
|
@@ -3274,12 +3099,12 @@ var RepeatNodePrivate = /** @class */ (function (_super) {
|
|
|
3274
3099
|
* @type {Map}
|
|
3275
3100
|
*/
|
|
3276
3101
|
_this.nodes = new Map();
|
|
3277
|
-
_this
|
|
3102
|
+
_this.$seal();
|
|
3278
3103
|
return _this;
|
|
3279
3104
|
}
|
|
3280
|
-
RepeatNodePrivate.prototype
|
|
3105
|
+
RepeatNodePrivate.prototype.$destroy = function () {
|
|
3281
3106
|
this.nodes.clear();
|
|
3282
|
-
_super.prototype
|
|
3107
|
+
_super.prototype.$destroy.call(this);
|
|
3283
3108
|
};
|
|
3284
3109
|
return RepeatNodePrivate;
|
|
3285
3110
|
}(INodePrivate));
|
|
@@ -3291,19 +3116,16 @@ var RepeatNodePrivate = /** @class */ (function (_super) {
|
|
|
3291
3116
|
*/
|
|
3292
3117
|
var RepeatNode = /** @class */ (function (_super) {
|
|
3293
3118
|
__extends(RepeatNode, _super);
|
|
3294
|
-
function RepeatNode($) {
|
|
3295
|
-
var _this = _super.call(this, $
|
|
3119
|
+
function RepeatNode(input, $) {
|
|
3120
|
+
var _this = _super.call(this, input, $) || this;
|
|
3296
3121
|
/**
|
|
3297
3122
|
* If false will use timeout executor, otherwise the app executor
|
|
3298
3123
|
*/
|
|
3299
3124
|
_this.freezeUi = true;
|
|
3300
|
-
_this.slot = new Slot;
|
|
3301
3125
|
return _this;
|
|
3302
3126
|
}
|
|
3303
|
-
RepeatNode.prototype.createChild = function (id, item, before) {
|
|
3304
|
-
|
|
3305
|
-
var _this = this;
|
|
3306
|
-
var node = new Fragment();
|
|
3127
|
+
RepeatNode.prototype.createChild = function (opts, id, item, before) {
|
|
3128
|
+
var node = new Fragment({});
|
|
3307
3129
|
this.destroyChild(id, item);
|
|
3308
3130
|
if (before) {
|
|
3309
3131
|
this.children.add(node);
|
|
@@ -3319,16 +3141,8 @@ var RepeatNode = /** @class */ (function (_super) {
|
|
|
3319
3141
|
this.lastChild = node;
|
|
3320
3142
|
node.preinit(this.$.app, this);
|
|
3321
3143
|
node.init();
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
node.ready();
|
|
3325
|
-
};
|
|
3326
|
-
if (this.freezeUi) {
|
|
3327
|
-
this.$.app.run.callCallback(callback);
|
|
3328
|
-
}
|
|
3329
|
-
else {
|
|
3330
|
-
timeoutExecutor.callCallback(callback);
|
|
3331
|
-
}
|
|
3144
|
+
opts.slot && opts.slot(node, item, id);
|
|
3145
|
+
node.ready();
|
|
3332
3146
|
this.$.nodes.set(id, node);
|
|
3333
3147
|
};
|
|
3334
3148
|
RepeatNode.prototype.destroyChild = function (id, item) {
|
|
@@ -3336,7 +3150,7 @@ var RepeatNode = /** @class */ (function (_super) {
|
|
|
3336
3150
|
var child = $.nodes.get(id);
|
|
3337
3151
|
if (child) {
|
|
3338
3152
|
child.remove();
|
|
3339
|
-
child
|
|
3153
|
+
child.$destroy();
|
|
3340
3154
|
this.$.nodes.delete(id);
|
|
3341
3155
|
this.children.delete(child);
|
|
3342
3156
|
}
|
|
@@ -3432,7 +3246,7 @@ var BaseViewPrivate = /** @class */ (function (_super) {
|
|
|
3432
3246
|
__extends(BaseViewPrivate, _super);
|
|
3433
3247
|
function BaseViewPrivate() {
|
|
3434
3248
|
var _this = this; _super.call(this);
|
|
3435
|
-
_this
|
|
3249
|
+
_this.$seal();
|
|
3436
3250
|
return _this;
|
|
3437
3251
|
}
|
|
3438
3252
|
return BaseViewPrivate;
|
|
@@ -3446,35 +3260,24 @@ var BaseViewPrivate = /** @class */ (function (_super) {
|
|
|
3446
3260
|
*/
|
|
3447
3261
|
var BaseView = /** @class */ (function (_super) {
|
|
3448
3262
|
__extends(BaseView, _super);
|
|
3449
|
-
function BaseView($
|
|
3450
|
-
|
|
3451
|
-
|
|
3263
|
+
function BaseView(input, $) {
|
|
3264
|
+
return _super.call(this, input, $ || new BaseViewPrivate) || this;
|
|
3265
|
+
}
|
|
3266
|
+
BaseView.prototype.compose = function (input) {
|
|
3267
|
+
var _this = this;
|
|
3268
|
+
var $ = this.$;
|
|
3452
3269
|
$.addHandler = function (id, item) {
|
|
3453
|
-
_this.createChild(id, item);
|
|
3270
|
+
_this.createChild(input, id, item);
|
|
3454
3271
|
};
|
|
3455
3272
|
$.removeHandler = function (id, item) {
|
|
3456
3273
|
_this.destroyChild(id, item);
|
|
3457
3274
|
};
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
BaseView.prototype.ready = function () {
|
|
3465
|
-
var $ = this.$;
|
|
3466
|
-
this.model.listener.onAdd($.addHandler);
|
|
3467
|
-
this.model.listener.onRemove($.removeHandler);
|
|
3468
|
-
_super.prototype.ready.call(this);
|
|
3469
|
-
};
|
|
3470
|
-
/**
|
|
3471
|
-
* Handles destroy event
|
|
3472
|
-
*/
|
|
3473
|
-
BaseView.prototype.destroy = function () {
|
|
3474
|
-
var $ = this.$;
|
|
3475
|
-
this.model.listener.offAdd($.addHandler);
|
|
3476
|
-
this.model.listener.offRemove($.removeHandler);
|
|
3477
|
-
_super.prototype.destroy.call(this);
|
|
3275
|
+
input.model.listener.onAdd($.addHandler);
|
|
3276
|
+
input.model.listener.onRemove($.removeHandler);
|
|
3277
|
+
this.runOnDestroy(function () {
|
|
3278
|
+
input.model.listener.offAdd($.addHandler);
|
|
3279
|
+
input.model.listener.offRemove($.removeHandler);
|
|
3280
|
+
});
|
|
3478
3281
|
};
|
|
3479
3282
|
return BaseView;
|
|
3480
3283
|
}(RepeatNode));
|
|
@@ -3491,20 +3294,18 @@ window.BaseView = BaseView;
|
|
|
3491
3294
|
*/
|
|
3492
3295
|
var ArrayView = /** @class */ (function (_super) {
|
|
3493
3296
|
__extends(ArrayView, _super);
|
|
3494
|
-
function ArrayView(
|
|
3495
|
-
|
|
3496
|
-
_this.model = model;
|
|
3497
|
-
return _this;
|
|
3297
|
+
function ArrayView() {
|
|
3298
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3498
3299
|
}
|
|
3499
|
-
ArrayView.prototype.createChild = function (id, item, before) {
|
|
3500
|
-
_super.prototype.createChild.call(this, item, item, before || this.$.nodes.get(id));
|
|
3300
|
+
ArrayView.prototype.createChild = function (input, id, item, before) {
|
|
3301
|
+
_super.prototype.createChild.call(this, input, item, item, before || this.$.nodes.get(id));
|
|
3501
3302
|
};
|
|
3502
|
-
ArrayView.prototype.
|
|
3303
|
+
ArrayView.prototype.compose = function (input) {
|
|
3503
3304
|
var _this = this;
|
|
3504
|
-
|
|
3505
|
-
|
|
3305
|
+
_super.prototype.compose.call(this, input);
|
|
3306
|
+
input.model.forEach(function (item) {
|
|
3307
|
+
_this.createChild(input, item, item);
|
|
3506
3308
|
});
|
|
3507
|
-
_super.prototype.ready.call(this);
|
|
3508
3309
|
};
|
|
3509
3310
|
return ArrayView;
|
|
3510
3311
|
}(BaseView));
|
|
@@ -3521,24 +3322,19 @@ window.ArrayView = ArrayView;
|
|
|
3521
3322
|
var Watch = /** @class */ (function (_super) {
|
|
3522
3323
|
__extends(Watch, _super);
|
|
3523
3324
|
function Watch() {
|
|
3524
|
-
|
|
3525
|
-
_this.slot = new Slot;
|
|
3526
|
-
_this.model = _this.ref(null);
|
|
3527
|
-
_this.seal();
|
|
3528
|
-
return _this;
|
|
3325
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3529
3326
|
}
|
|
3530
|
-
Watch.prototype.
|
|
3327
|
+
Watch.prototype.compose = function (input) {
|
|
3531
3328
|
var _this = this;
|
|
3532
3329
|
this.watch(function (value) {
|
|
3533
3330
|
_this.children.forEach(function (child) {
|
|
3534
|
-
child
|
|
3331
|
+
child.$destroy();
|
|
3535
3332
|
});
|
|
3536
3333
|
_this.children.clear();
|
|
3537
|
-
_this.
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
this.slot.release(this, this.model.$);
|
|
3334
|
+
_this.lastChild = null;
|
|
3335
|
+
input.slot && input.slot(_this, value);
|
|
3336
|
+
}, input.model);
|
|
3337
|
+
input.slot(this, input.model.$);
|
|
3542
3338
|
};
|
|
3543
3339
|
return Watch;
|
|
3544
3340
|
}(Fragment));
|
|
@@ -3554,15 +3350,14 @@ window.Watch = Watch;
|
|
|
3554
3350
|
*/
|
|
3555
3351
|
var ObjectView = /** @class */ (function (_super) {
|
|
3556
3352
|
__extends(ObjectView, _super);
|
|
3557
|
-
function ObjectView(
|
|
3558
|
-
|
|
3559
|
-
_this.model = model;
|
|
3560
|
-
return _this;
|
|
3353
|
+
function ObjectView() {
|
|
3354
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3561
3355
|
}
|
|
3562
|
-
ObjectView.prototype.
|
|
3563
|
-
|
|
3356
|
+
ObjectView.prototype.compose = function (input) {
|
|
3357
|
+
_super.prototype.compose.call(this, input);
|
|
3358
|
+
var obj = input.model.proxy();
|
|
3564
3359
|
for (var key in obj) {
|
|
3565
|
-
this.createChild(key, obj[key]);
|
|
3360
|
+
this.createChild(input, key, obj[key]);
|
|
3566
3361
|
}
|
|
3567
3362
|
_super.prototype.ready.call(this);
|
|
3568
3363
|
};
|
|
@@ -3580,18 +3375,15 @@ window.ObjectView = ObjectView;
|
|
|
3580
3375
|
*/
|
|
3581
3376
|
var MapView = /** @class */ (function (_super) {
|
|
3582
3377
|
__extends(MapView, _super);
|
|
3583
|
-
function MapView(
|
|
3584
|
-
|
|
3585
|
-
_this.model = model;
|
|
3586
|
-
return _this;
|
|
3378
|
+
function MapView() {
|
|
3379
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3587
3380
|
}
|
|
3588
|
-
MapView.prototype.
|
|
3381
|
+
MapView.prototype.compose = function (input) {
|
|
3589
3382
|
var _this = this;
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
_this.createChild(key, value);
|
|
3383
|
+
_super.prototype.compose.call(this, input);
|
|
3384
|
+
input.model.forEach(function (value, key) {
|
|
3385
|
+
_this.createChild(input, key, value);
|
|
3593
3386
|
});
|
|
3594
|
-
_super.prototype.ready.call(this);
|
|
3595
3387
|
};
|
|
3596
3388
|
return MapView;
|
|
3597
3389
|
}(BaseView));
|
|
@@ -3607,21 +3399,16 @@ window.MapView = MapView;
|
|
|
3607
3399
|
*/
|
|
3608
3400
|
var SetView = /** @class */ (function (_super) {
|
|
3609
3401
|
__extends(SetView, _super);
|
|
3610
|
-
function SetView(
|
|
3611
|
-
|
|
3612
|
-
_this.model = model;
|
|
3613
|
-
return _this;
|
|
3402
|
+
function SetView() {
|
|
3403
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3614
3404
|
}
|
|
3615
|
-
SetView.prototype.
|
|
3405
|
+
SetView.prototype.compose = function (input) {
|
|
3616
3406
|
var _this = this;
|
|
3617
|
-
|
|
3618
|
-
var set =
|
|
3407
|
+
_super.prototype.compose.call(this, input);
|
|
3408
|
+
var set = input.model;
|
|
3619
3409
|
set.forEach(function (item) {
|
|
3620
|
-
|
|
3621
|
-
_this.createChild(item, item);
|
|
3622
|
-
});
|
|
3410
|
+
_this.createChild(input, item, item);
|
|
3623
3411
|
});
|
|
3624
|
-
_super.prototype.ready.call(this);
|
|
3625
3412
|
};
|
|
3626
3413
|
return SetView;
|
|
3627
3414
|
}(BaseView));
|
|
@@ -3629,4 +3416,297 @@ var SetView = /** @class */ (function (_super) {
|
|
|
3629
3416
|
|
|
3630
3417
|
window.SetView = SetView;
|
|
3631
3418
|
|
|
3419
|
+
// ./lib-es5/functional/merge.js
|
|
3420
|
+
function merge(main) {
|
|
3421
|
+
var targets = [];
|
|
3422
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3423
|
+
targets[_i - 1] = arguments[_i];
|
|
3424
|
+
}
|
|
3425
|
+
function refactorClass(obj) {
|
|
3426
|
+
if (Array.isArray(obj.class)) {
|
|
3427
|
+
var out_1 = {
|
|
3428
|
+
$: []
|
|
3429
|
+
};
|
|
3430
|
+
obj.class.forEach(function (item) {
|
|
3431
|
+
if (item instanceof IValue) {
|
|
3432
|
+
out_1.$.push(item);
|
|
3433
|
+
}
|
|
3434
|
+
else if (typeof item === 'string') {
|
|
3435
|
+
out_1[item] = true;
|
|
3436
|
+
}
|
|
3437
|
+
else if (typeof item === 'object') {
|
|
3438
|
+
Object.assign(out_1, item);
|
|
3439
|
+
}
|
|
3440
|
+
});
|
|
3441
|
+
obj.class = out_1;
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
refactorClass(main);
|
|
3445
|
+
targets.forEach(function (target) {
|
|
3446
|
+
Reflect.ownKeys(target).forEach(function (prop) {
|
|
3447
|
+
var _a;
|
|
3448
|
+
if (!Reflect.has(main, prop)) {
|
|
3449
|
+
main[prop] = target[prop];
|
|
3450
|
+
}
|
|
3451
|
+
else if (typeof main[prop] === 'object' && typeof target[prop] === 'object') {
|
|
3452
|
+
if (prop === 'class') {
|
|
3453
|
+
refactorClass(target);
|
|
3454
|
+
}
|
|
3455
|
+
if (prop === '$' && Array.isArray(main[prop]) && Array.isArray(target[prop])) {
|
|
3456
|
+
(_a = main.$).push.apply(_a, target.$);
|
|
3457
|
+
}
|
|
3458
|
+
else {
|
|
3459
|
+
merge(main[prop], target[prop]);
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
});
|
|
3463
|
+
});
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
window.merge = merge;
|
|
3467
|
+
|
|
3468
|
+
// ./lib-es5/functional/stack.js
|
|
3469
|
+
function app(renderer) {
|
|
3470
|
+
return function (node, opts) {
|
|
3471
|
+
return new App(node, opts).runFunctional(renderer, opts);
|
|
3472
|
+
};
|
|
3473
|
+
}
|
|
3474
|
+
function component(renderer) {
|
|
3475
|
+
return function (opts, callback) {
|
|
3476
|
+
var component = new Component(opts);
|
|
3477
|
+
if (!(current instanceof Fragment))
|
|
3478
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3479
|
+
var ret;
|
|
3480
|
+
if (callback)
|
|
3481
|
+
opts.slot = callback;
|
|
3482
|
+
current.create(component, function (node) {
|
|
3483
|
+
ret = node.runFunctional(renderer, opts);
|
|
3484
|
+
});
|
|
3485
|
+
return ret;
|
|
3486
|
+
};
|
|
3487
|
+
}
|
|
3488
|
+
function fragment(renderer) {
|
|
3489
|
+
return function (opts, callback) {
|
|
3490
|
+
var frag = new Fragment(opts);
|
|
3491
|
+
if (!(current instanceof Fragment))
|
|
3492
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3493
|
+
if (callback)
|
|
3494
|
+
opts.slot = callback;
|
|
3495
|
+
current.create(frag);
|
|
3496
|
+
return frag.runFunctional(renderer, opts);
|
|
3497
|
+
};
|
|
3498
|
+
}
|
|
3499
|
+
function extension(renderer) {
|
|
3500
|
+
return function (opts, callback) {
|
|
3501
|
+
var ext = new Extension(opts);
|
|
3502
|
+
if (!(current instanceof Fragment))
|
|
3503
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3504
|
+
if (callback)
|
|
3505
|
+
opts.slot = callback;
|
|
3506
|
+
current.create(ext);
|
|
3507
|
+
return ext.runFunctional(renderer, opts);
|
|
3508
|
+
};
|
|
3509
|
+
}
|
|
3510
|
+
function tag(name, opts, callback) {
|
|
3511
|
+
if (!(current instanceof Fragment))
|
|
3512
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3513
|
+
return {
|
|
3514
|
+
node: current.tag(name, opts, function (node) {
|
|
3515
|
+
callback && node.runFunctional(callback);
|
|
3516
|
+
})
|
|
3517
|
+
};
|
|
3518
|
+
}
|
|
3519
|
+
function create(node, callback) {
|
|
3520
|
+
if (!(current instanceof Fragment))
|
|
3521
|
+
throw userError('missing current node', 'out-of-context');
|
|
3522
|
+
current.create(node, function (node) {
|
|
3523
|
+
var args = [];
|
|
3524
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3525
|
+
args[_i - 1] = arguments[_i];
|
|
3526
|
+
}
|
|
3527
|
+
callback && node.runFunctional.apply(node, __spreadArray([callback], args, false));
|
|
3528
|
+
});
|
|
3529
|
+
return node;
|
|
3530
|
+
}
|
|
3531
|
+
var vx = {
|
|
3532
|
+
if: function (condition, callback) {
|
|
3533
|
+
if (current instanceof Fragment) {
|
|
3534
|
+
current.if(condition, function (node) { return node.runFunctional(callback); });
|
|
3535
|
+
}
|
|
3536
|
+
else {
|
|
3537
|
+
throw userError("wrong use of `v.if` function", "logic-error");
|
|
3538
|
+
}
|
|
3539
|
+
},
|
|
3540
|
+
else: function (callback) {
|
|
3541
|
+
if (current instanceof Fragment) {
|
|
3542
|
+
current.else(function (node) { return node.runFunctional(callback); });
|
|
3543
|
+
}
|
|
3544
|
+
else {
|
|
3545
|
+
throw userError("wrong use of `v.else` function", "logic-error");
|
|
3546
|
+
}
|
|
3547
|
+
},
|
|
3548
|
+
elif: function (condition, callback) {
|
|
3549
|
+
if (current instanceof Fragment) {
|
|
3550
|
+
current.elif(condition, function (node) { return node.runFunctional(callback); });
|
|
3551
|
+
}
|
|
3552
|
+
else {
|
|
3553
|
+
throw userError("wrong use of `v.elif` function", "logic-error");
|
|
3554
|
+
}
|
|
3555
|
+
},
|
|
3556
|
+
for: function (model, callback) {
|
|
3557
|
+
if (model instanceof ArrayModel) {
|
|
3558
|
+
// for arrays T & K are the same type
|
|
3559
|
+
create(new ArrayView({ model: model }), callback);
|
|
3560
|
+
}
|
|
3561
|
+
else if (model instanceof MapModel) {
|
|
3562
|
+
create(new MapView({ model: model }), callback);
|
|
3563
|
+
}
|
|
3564
|
+
else if (model instanceof SetModel) {
|
|
3565
|
+
// for sets T & K are the same type
|
|
3566
|
+
create(new SetView({ model: model }), callback);
|
|
3567
|
+
}
|
|
3568
|
+
else if (model instanceof ObjectModel) {
|
|
3569
|
+
// for objects K is always string
|
|
3570
|
+
create(new ObjectView({ model: model }), callback);
|
|
3571
|
+
}
|
|
3572
|
+
else {
|
|
3573
|
+
throw userError("wrong use of `v.for` function", 'wrong-model');
|
|
3574
|
+
}
|
|
3575
|
+
},
|
|
3576
|
+
watch: function (model, callback) {
|
|
3577
|
+
var opts = { model: model };
|
|
3578
|
+
create(new Watch(opts), callback);
|
|
3579
|
+
},
|
|
3580
|
+
nextTick: function (callback) {
|
|
3581
|
+
var node = current;
|
|
3582
|
+
window.setTimeout(function () {
|
|
3583
|
+
node.runFunctional(callback);
|
|
3584
|
+
}, 0);
|
|
3585
|
+
}
|
|
3586
|
+
};
|
|
3587
|
+
|
|
3588
|
+
window.app = app;
|
|
3589
|
+
window.component = component;
|
|
3590
|
+
window.fragment = fragment;
|
|
3591
|
+
window.extension = extension;
|
|
3592
|
+
window.tag = tag;
|
|
3593
|
+
window.create = create;
|
|
3594
|
+
window.vx = vx;
|
|
3595
|
+
|
|
3596
|
+
// ./lib-es5/functional/models.js
|
|
3597
|
+
function arrayModel(arr) {
|
|
3598
|
+
if (arr === void 0) { arr = []; }
|
|
3599
|
+
if (!current)
|
|
3600
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3601
|
+
return current.register(new ArrayModel(arr)).proxy();
|
|
3602
|
+
}
|
|
3603
|
+
function mapModel(map) {
|
|
3604
|
+
if (map === void 0) { map = []; }
|
|
3605
|
+
if (!current)
|
|
3606
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3607
|
+
return current.register(new MapModel(map));
|
|
3608
|
+
}
|
|
3609
|
+
function setModel(arr) {
|
|
3610
|
+
if (arr === void 0) { arr = []; }
|
|
3611
|
+
if (!current)
|
|
3612
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3613
|
+
return current.register(new SetModel(arr));
|
|
3614
|
+
}
|
|
3615
|
+
function objectModel(obj) {
|
|
3616
|
+
if (obj === void 0) { obj = {}; }
|
|
3617
|
+
if (!current)
|
|
3618
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3619
|
+
return current.register(new ObjectModel(obj));
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
window.arrayModel = arrayModel;
|
|
3623
|
+
window.mapModel = mapModel;
|
|
3624
|
+
window.setModel = setModel;
|
|
3625
|
+
window.objectModel = objectModel;
|
|
3626
|
+
|
|
3627
|
+
// ./lib-es5/functional/options.js
|
|
3628
|
+
|
|
3629
|
+
|
|
3630
|
+
|
|
3631
|
+
// ./lib-es5/functional/reactivity.js
|
|
3632
|
+
function ref(value) {
|
|
3633
|
+
var ref = current.ref(value);
|
|
3634
|
+
return [ref, function (value) { return ref.$ = value; }];
|
|
3635
|
+
}
|
|
3636
|
+
function mirror(value) {
|
|
3637
|
+
return current.mirror(value);
|
|
3638
|
+
}
|
|
3639
|
+
function forward(value) {
|
|
3640
|
+
return current.forward(value);
|
|
3641
|
+
}
|
|
3642
|
+
function point(value) {
|
|
3643
|
+
return current.point(value);
|
|
3644
|
+
}
|
|
3645
|
+
function expr(func) {
|
|
3646
|
+
var values = [];
|
|
3647
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3648
|
+
values[_i - 1] = arguments[_i];
|
|
3649
|
+
}
|
|
3650
|
+
return current.expr.apply(current, __spreadArray([func], values, false));
|
|
3651
|
+
}
|
|
3652
|
+
function watch(func) {
|
|
3653
|
+
var values = [];
|
|
3654
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3655
|
+
values[_i - 1] = arguments[_i];
|
|
3656
|
+
}
|
|
3657
|
+
current.watch.apply(current, __spreadArray([func], values, false));
|
|
3658
|
+
}
|
|
3659
|
+
function valueOf(value) {
|
|
3660
|
+
return value.$;
|
|
3661
|
+
}
|
|
3662
|
+
function setValue(ref, value) {
|
|
3663
|
+
if (ref instanceof Pointer && value instanceof IValue) {
|
|
3664
|
+
ref.$$ = value;
|
|
3665
|
+
}
|
|
3666
|
+
else {
|
|
3667
|
+
ref.$ = value instanceof IValue ? value.$ : value;
|
|
3668
|
+
}
|
|
3669
|
+
}
|
|
3670
|
+
|
|
3671
|
+
window.ref = ref;
|
|
3672
|
+
window.mirror = mirror;
|
|
3673
|
+
window.forward = forward;
|
|
3674
|
+
window.point = point;
|
|
3675
|
+
window.expr = expr;
|
|
3676
|
+
window.watch = watch;
|
|
3677
|
+
window.valueOf = valueOf;
|
|
3678
|
+
window.setValue = setValue;
|
|
3679
|
+
|
|
3680
|
+
// ./lib-es5/functional/components.js
|
|
3681
|
+
function text(text) {
|
|
3682
|
+
if (!(current instanceof Fragment))
|
|
3683
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3684
|
+
;
|
|
3685
|
+
current.text(text);
|
|
3686
|
+
}
|
|
3687
|
+
function debug(text) {
|
|
3688
|
+
if (!(current instanceof Fragment))
|
|
3689
|
+
throw userError('missing parent node', 'out-of-context');
|
|
3690
|
+
current.debug(text);
|
|
3691
|
+
}
|
|
3692
|
+
function predefine(slot, predefined) {
|
|
3693
|
+
return slot || predefined;
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
window.text = text;
|
|
3697
|
+
window.debug = debug;
|
|
3698
|
+
window.predefine = predefine;
|
|
3699
|
+
|
|
3700
|
+
// ./lib-es5/v/index.js
|
|
3701
|
+
|
|
3702
|
+
var v = __assign(__assign({ ref: function (value) {
|
|
3703
|
+
return current.ref(value);
|
|
3704
|
+
}, 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 () {
|
|
3705
|
+
return current.$destroy.bind(current);
|
|
3706
|
+
}, runOnDestroy: function (callback) {
|
|
3707
|
+
current.runOnDestroy(callback);
|
|
3708
|
+
} });
|
|
3709
|
+
|
|
3710
|
+
window.v = v;
|
|
3711
|
+
|
|
3632
3712
|
})();
|