vasille 2.3.2 → 2.3.4
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/cdn/es2015.js +1077 -1072
- package/cdn/es5.js +1726 -1719
- package/flow-typed/vasille.js +2170 -2168
- package/lib/core/core.js +2 -2
- package/lib/index.js +2 -2
- package/lib/node/node.js +4 -1
- package/lib-node/core/core.js +3 -1
- package/lib-node/index.js +3 -1
- package/lib-node/node/node.js +4 -1
- package/package.json +4 -1
- package/types/core/core.d.ts +2 -0
- package/types/index.d.ts +2 -2
package/cdn/es5.js
CHANGED
|
@@ -197,152 +197,89 @@ window.Reflect = window.Reflect || {
|
|
|
197
197
|
window.Proxy = window.Proxy || function (obj) {
|
|
198
198
|
return obj;
|
|
199
199
|
};
|
|
200
|
-
// ./lib-es5/
|
|
201
|
-
"use strict";
|
|
202
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// ./lib-es5/models/listener.js
|
|
200
|
+
// ./lib-es5/core/destroyable.js
|
|
206
201
|
"use strict";
|
|
207
202
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
208
|
-
exports.
|
|
203
|
+
exports.Destroyable = void 0;
|
|
209
204
|
/**
|
|
210
|
-
*
|
|
211
|
-
* @class
|
|
205
|
+
* Mark an object which can be destroyed
|
|
206
|
+
* @class Destroyable
|
|
212
207
|
*/
|
|
213
|
-
var
|
|
214
|
-
function
|
|
215
|
-
Object.defineProperties(this, {
|
|
216
|
-
onAdded: {
|
|
217
|
-
value: new Set,
|
|
218
|
-
writable: false,
|
|
219
|
-
configurable: false
|
|
220
|
-
},
|
|
221
|
-
onRemoved: {
|
|
222
|
-
value: new Set,
|
|
223
|
-
writable: false,
|
|
224
|
-
configurable: false
|
|
225
|
-
},
|
|
226
|
-
frozen: {
|
|
227
|
-
value: false,
|
|
228
|
-
writable: true,
|
|
229
|
-
configurable: false
|
|
230
|
-
},
|
|
231
|
-
queue: {
|
|
232
|
-
value: [],
|
|
233
|
-
writable: false,
|
|
234
|
-
configurable: false
|
|
235
|
-
}
|
|
236
|
-
});
|
|
208
|
+
var Destroyable = /** @class */ (function () {
|
|
209
|
+
function Destroyable() {
|
|
237
210
|
}
|
|
238
211
|
/**
|
|
239
|
-
*
|
|
240
|
-
* @
|
|
241
|
-
*/
|
|
242
|
-
Listener.prototype.excludeRepeat = function (index) {
|
|
243
|
-
var _this = this;
|
|
244
|
-
this.queue.forEach(function (item, i) {
|
|
245
|
-
if (item.index === index) {
|
|
246
|
-
_this.queue.splice(i, 1);
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
return false;
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* Emits added event to listeners
|
|
254
|
-
* @param index {*} index of value
|
|
255
|
-
* @param value {*} value of added item
|
|
256
|
-
*/
|
|
257
|
-
Listener.prototype.emitAdded = function (index, value) {
|
|
258
|
-
if (this.frozen) {
|
|
259
|
-
if (!this.excludeRepeat(index)) {
|
|
260
|
-
this.queue.push({ sign: true, index: index, value: value });
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
this.onAdded.forEach(function (handler) {
|
|
265
|
-
handler(index, value);
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* Emits removed event to listeners
|
|
271
|
-
* @param index {*} index of removed value
|
|
272
|
-
* @param value {*} value of removed item
|
|
273
|
-
*/
|
|
274
|
-
Listener.prototype.emitRemoved = function (index, value) {
|
|
275
|
-
if (this.frozen) {
|
|
276
|
-
if (!this.excludeRepeat(index)) {
|
|
277
|
-
this.queue.push({ sign: false, index: index, value: value });
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
this.onRemoved.forEach(function (handler) {
|
|
282
|
-
handler(index, value);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
/**
|
|
287
|
-
* Adds a handler to added event
|
|
288
|
-
* @param handler {function} function to run on event emitting
|
|
289
|
-
*/
|
|
290
|
-
Listener.prototype.onAdd = function (handler) {
|
|
291
|
-
this.onAdded.add(handler);
|
|
292
|
-
};
|
|
293
|
-
/**
|
|
294
|
-
* Adds a handler to removed event
|
|
295
|
-
* @param handler {function} function to run on event emitting
|
|
296
|
-
*/
|
|
297
|
-
Listener.prototype.onRemove = function (handler) {
|
|
298
|
-
this.onRemoved.add(handler);
|
|
299
|
-
};
|
|
300
|
-
/**
|
|
301
|
-
* Removes an handler from added event
|
|
302
|
-
* @param handler {function} handler to remove
|
|
303
|
-
*/
|
|
304
|
-
Listener.prototype.offAdd = function (handler) {
|
|
305
|
-
this.onAdded.delete(handler);
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* Removes an handler form removed event
|
|
309
|
-
* @param handler {function} handler to remove
|
|
310
|
-
*/
|
|
311
|
-
Listener.prototype.offRemove = function (handler) {
|
|
312
|
-
this.onRemoved.delete(handler);
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Run all queued operation and enable reactivity
|
|
212
|
+
* Make object fields non configurable
|
|
213
|
+
* @protected
|
|
316
214
|
*/
|
|
317
|
-
|
|
215
|
+
Destroyable.prototype.$seal = function () {
|
|
318
216
|
var _this = this;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
217
|
+
var $ = this;
|
|
218
|
+
Object.keys($).forEach(function (i) {
|
|
219
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
220
|
+
if (_this.hasOwnProperty(i)) {
|
|
221
|
+
var config = Object.getOwnPropertyDescriptor($, i);
|
|
222
|
+
if (config.configurable) {
|
|
223
|
+
var descriptor = void 0;
|
|
224
|
+
if (config.set || config.get) {
|
|
225
|
+
descriptor = {
|
|
226
|
+
configurable: false,
|
|
227
|
+
get: config.get,
|
|
228
|
+
set: config.set,
|
|
229
|
+
enumerable: config.enumerable
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
descriptor = {
|
|
234
|
+
value: $[i],
|
|
235
|
+
configurable: false,
|
|
236
|
+
writable: config.writable,
|
|
237
|
+
enumerable: config.enumerable
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
Object.defineProperty($, i, descriptor);
|
|
241
|
+
}
|
|
329
242
|
}
|
|
330
243
|
});
|
|
331
|
-
this.queue.splice(0);
|
|
332
|
-
this.frozen = false;
|
|
333
244
|
};
|
|
334
245
|
/**
|
|
335
|
-
*
|
|
246
|
+
* Garbage collector method
|
|
336
247
|
*/
|
|
337
|
-
|
|
338
|
-
|
|
248
|
+
Destroyable.prototype.$destroy = function () {
|
|
249
|
+
// nothing here
|
|
339
250
|
};
|
|
340
|
-
return
|
|
251
|
+
return Destroyable;
|
|
341
252
|
}());
|
|
342
|
-
exports.
|
|
253
|
+
exports.Destroyable = Destroyable;
|
|
343
254
|
|
|
344
255
|
|
|
345
|
-
// ./lib-es5/
|
|
256
|
+
// ./lib-es5/core/errors.js
|
|
257
|
+
"use strict";
|
|
258
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
259
|
+
exports.wrongBinding = exports.userError = exports.internalError = exports.notOverwritten = void 0;
|
|
260
|
+
var reportIt = "Report it here: https://gitlab.com/vasille-js/vasille-js/-/issues";
|
|
261
|
+
function notOverwritten() {
|
|
262
|
+
console.error("Vasille-SFP: Internal error", "Must be overwritten", reportIt);
|
|
263
|
+
return "not-overwritten";
|
|
264
|
+
}
|
|
265
|
+
exports.notOverwritten = notOverwritten;
|
|
266
|
+
function internalError(msg) {
|
|
267
|
+
console.error("Vasille-SFP: Internal error", msg, reportIt);
|
|
268
|
+
return "internal-error";
|
|
269
|
+
}
|
|
270
|
+
exports.internalError = internalError;
|
|
271
|
+
function userError(msg, err) {
|
|
272
|
+
console.error("Vasille-SFP: User error", msg);
|
|
273
|
+
return err;
|
|
274
|
+
}
|
|
275
|
+
exports.userError = userError;
|
|
276
|
+
function wrongBinding(msg) {
|
|
277
|
+
return userError(msg, "wrong-binding");
|
|
278
|
+
}
|
|
279
|
+
exports.wrongBinding = wrongBinding;
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
// ./lib-es5/core/ivalue.js
|
|
346
283
|
"use strict";
|
|
347
284
|
var __extends = (this && this.__extends) || (function () {
|
|
348
285
|
var extendStatics = function (d, b) {
|
|
@@ -360,97 +297,82 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
360
297
|
};
|
|
361
298
|
})();
|
|
362
299
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
363
|
-
exports.
|
|
364
|
-
var
|
|
300
|
+
exports.IValue = exports.Switchable = void 0;
|
|
301
|
+
var destroyable_js_1 = require("./destroyable.js");
|
|
302
|
+
var errors_1 = require("./errors");
|
|
303
|
+
var Switchable = /** @class */ (function (_super) {
|
|
304
|
+
__extends(Switchable, _super);
|
|
305
|
+
function Switchable() {
|
|
306
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Enable update handlers triggering
|
|
310
|
+
*/
|
|
311
|
+
Switchable.prototype.$enable = function () {
|
|
312
|
+
throw (0, errors_1.notOverwritten)();
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* disable update handlers triggering
|
|
316
|
+
*/
|
|
317
|
+
Switchable.prototype.$disable = function () {
|
|
318
|
+
throw (0, errors_1.notOverwritten)();
|
|
319
|
+
};
|
|
320
|
+
return Switchable;
|
|
321
|
+
}(destroyable_js_1.Destroyable));
|
|
322
|
+
exports.Switchable = Switchable;
|
|
365
323
|
/**
|
|
366
|
-
*
|
|
367
|
-
* @
|
|
324
|
+
* Interface which describes a value
|
|
325
|
+
* @class IValue
|
|
326
|
+
* @extends Destroyable
|
|
368
327
|
*/
|
|
369
|
-
var
|
|
370
|
-
__extends(
|
|
328
|
+
var IValue = /** @class */ (function (_super) {
|
|
329
|
+
__extends(IValue, _super);
|
|
371
330
|
/**
|
|
372
|
-
*
|
|
373
|
-
* @param obj {Object} input data
|
|
331
|
+
* @param isEnabled {boolean} initial is enabled state
|
|
374
332
|
*/
|
|
375
|
-
function
|
|
376
|
-
if (obj === void 0) { obj = {}; }
|
|
333
|
+
function IValue(isEnabled) {
|
|
377
334
|
var _this = this; _super.call(this);
|
|
378
|
-
_this.
|
|
379
|
-
Object.defineProperty(_this, 'listener', {
|
|
380
|
-
value: new listener_1.Listener,
|
|
381
|
-
writable: false,
|
|
382
|
-
configurable: false
|
|
383
|
-
});
|
|
384
|
-
for (var i in obj) {
|
|
385
|
-
Object.defineProperty(_this.container, i, {
|
|
386
|
-
value: obj[i],
|
|
387
|
-
configurable: true,
|
|
388
|
-
writable: true,
|
|
389
|
-
enumerable: true
|
|
390
|
-
});
|
|
391
|
-
_this.listener.emitAdded(i, obj[i]);
|
|
392
|
-
}
|
|
335
|
+
_this.isEnabled = isEnabled;
|
|
393
336
|
return _this;
|
|
394
337
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
ObjectModel.prototype.get = function (key) {
|
|
401
|
-
return this.container[key];
|
|
402
|
-
};
|
|
403
|
-
/**
|
|
404
|
-
* Sets an object property value
|
|
405
|
-
* @param key {string} property name
|
|
406
|
-
* @param v {*} property value
|
|
407
|
-
* @return {ObjectModel} a pointer to this
|
|
408
|
-
*/
|
|
409
|
-
ObjectModel.prototype.set = function (key, v) {
|
|
410
|
-
if (Reflect.has(this.container, key)) {
|
|
411
|
-
this.listener.emitRemoved(key, this.container[key]);
|
|
412
|
-
this.container[key] = v;
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
Object.defineProperty(this.container, key, {
|
|
416
|
-
value: v,
|
|
417
|
-
configurable: true,
|
|
418
|
-
writable: true,
|
|
419
|
-
enumerable: true
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
this.listener.emitAdded(key, this.container[key]);
|
|
423
|
-
return this;
|
|
424
|
-
};
|
|
425
|
-
Object.defineProperty(ObjectModel.prototype, "values", {
|
|
338
|
+
Object.defineProperty(IValue.prototype, "$", {
|
|
339
|
+
/**
|
|
340
|
+
* Get the encapsulated value
|
|
341
|
+
* @return {*} the encapsulated value
|
|
342
|
+
*/
|
|
426
343
|
get: function () {
|
|
427
|
-
|
|
344
|
+
throw (0, errors_1.notOverwritten)();
|
|
345
|
+
},
|
|
346
|
+
/**
|
|
347
|
+
* Sets the encapsulated value
|
|
348
|
+
* @param value {*} value to encapsulate
|
|
349
|
+
*/
|
|
350
|
+
set: function (value) {
|
|
351
|
+
throw (0, errors_1.notOverwritten)();
|
|
428
352
|
},
|
|
429
353
|
enumerable: false,
|
|
430
354
|
configurable: true
|
|
431
355
|
});
|
|
432
356
|
/**
|
|
433
|
-
*
|
|
434
|
-
* @param
|
|
357
|
+
* Add a new handler to value change
|
|
358
|
+
* @param handler {function(value : *)} the handler to add
|
|
435
359
|
*/
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
this.listener.emitRemoved(key, this.container[key]);
|
|
439
|
-
delete this.container[key];
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
ObjectModel.prototype.enableReactivity = function () {
|
|
443
|
-
this.listener.enableReactivity();
|
|
360
|
+
IValue.prototype.$on = function (handler) {
|
|
361
|
+
throw (0, errors_1.notOverwritten)();
|
|
444
362
|
};
|
|
445
|
-
|
|
446
|
-
|
|
363
|
+
/**
|
|
364
|
+
* Removes a handler of value change
|
|
365
|
+
* @param handler {function(value : *)} the handler to remove
|
|
366
|
+
*/
|
|
367
|
+
IValue.prototype.$off = function (handler) {
|
|
368
|
+
throw (0, errors_1.notOverwritten)();
|
|
447
369
|
};
|
|
448
|
-
return
|
|
449
|
-
}(
|
|
450
|
-
exports.
|
|
370
|
+
return IValue;
|
|
371
|
+
}(Switchable));
|
|
372
|
+
exports.IValue = IValue;
|
|
451
373
|
|
|
452
374
|
|
|
453
|
-
// ./lib-es5/
|
|
375
|
+
// ./lib-es5/core/core.js
|
|
454
376
|
"use strict";
|
|
455
377
|
var __extends = (this && this.__extends) || (function () {
|
|
456
378
|
var extendStatics = function (d, b) {
|
|
@@ -467,79 +389,286 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
467
389
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
468
390
|
};
|
|
469
391
|
})();
|
|
392
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
393
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
394
|
+
if (ar || !(i in from)) {
|
|
395
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
396
|
+
ar[i] = from[i];
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
400
|
+
};
|
|
470
401
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
471
|
-
exports.
|
|
472
|
-
var
|
|
402
|
+
exports.Reactive = exports.ReactivePrivate = exports.unstack = exports.stack = exports.current = void 0;
|
|
403
|
+
var destroyable_js_1 = require("./destroyable.js");
|
|
404
|
+
var errors_1 = require("./errors");
|
|
405
|
+
var expression_1 = require("../value/expression");
|
|
406
|
+
var reference_1 = require("../value/reference");
|
|
407
|
+
var pointer_1 = require("../value/pointer");
|
|
408
|
+
var mirror_1 = require("../value/mirror");
|
|
409
|
+
exports.current = null;
|
|
410
|
+
var currentStack = [];
|
|
411
|
+
function stack(node) {
|
|
412
|
+
currentStack.push(exports.current);
|
|
413
|
+
exports.current = node;
|
|
414
|
+
}
|
|
415
|
+
exports.stack = stack;
|
|
416
|
+
function unstack() {
|
|
417
|
+
exports.current = currentStack.pop();
|
|
418
|
+
}
|
|
419
|
+
exports.unstack = unstack;
|
|
473
420
|
/**
|
|
474
|
-
*
|
|
475
|
-
* @class
|
|
476
|
-
* @extends
|
|
477
|
-
* @implements IModel
|
|
421
|
+
* Private stuff of a reactive object
|
|
422
|
+
* @class ReactivePrivate
|
|
423
|
+
* @extends Destroyable
|
|
478
424
|
*/
|
|
479
|
-
var
|
|
480
|
-
__extends(
|
|
481
|
-
|
|
482
|
-
* Constructs a set model based on a set
|
|
483
|
-
* @param set {Set} input data
|
|
484
|
-
*/
|
|
485
|
-
function SetModel(set) {
|
|
486
|
-
if (set === void 0) { set = []; }
|
|
425
|
+
var ReactivePrivate = /** @class */ (function (_super) {
|
|
426
|
+
__extends(ReactivePrivate, _super);
|
|
427
|
+
function ReactivePrivate() {
|
|
487
428
|
var _this = this; _super.call(this);
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
429
|
+
/**
|
|
430
|
+
* A list of user-defined values
|
|
431
|
+
* @type {Set}
|
|
432
|
+
*/
|
|
433
|
+
_this.watch = new Set;
|
|
434
|
+
/**
|
|
435
|
+
* A list of user-defined bindings
|
|
436
|
+
* @type {Set}
|
|
437
|
+
*/
|
|
438
|
+
_this.bindings = new Set;
|
|
439
|
+
/**
|
|
440
|
+
* A list of user defined models
|
|
441
|
+
*/
|
|
442
|
+
_this.models = new Set;
|
|
443
|
+
/**
|
|
444
|
+
* Reactivity switch state
|
|
445
|
+
* @type {boolean}
|
|
446
|
+
*/
|
|
447
|
+
_this.enabled = true;
|
|
448
|
+
/**
|
|
449
|
+
* The frozen state of object
|
|
450
|
+
* @type {boolean}
|
|
451
|
+
*/
|
|
452
|
+
_this.frozen = false;
|
|
453
|
+
_this.$seal();
|
|
454
|
+
return _this;
|
|
455
|
+
}
|
|
456
|
+
ReactivePrivate.prototype.$destroy = function () {
|
|
457
|
+
this.watch.forEach(function (value) { return value.$destroy(); });
|
|
458
|
+
this.watch.clear();
|
|
459
|
+
this.bindings.forEach(function (binding) { return binding.$destroy(); });
|
|
460
|
+
this.bindings.clear();
|
|
461
|
+
this.models.forEach(function (model) { return model.disableReactivity(); });
|
|
462
|
+
this.models.clear();
|
|
463
|
+
this.freezeExpr && this.freezeExpr.$destroy();
|
|
464
|
+
this.onDestroy && this.onDestroy();
|
|
465
|
+
_super.prototype.$destroy.call(this);
|
|
466
|
+
};
|
|
467
|
+
return ReactivePrivate;
|
|
468
|
+
}(destroyable_js_1.Destroyable));
|
|
469
|
+
exports.ReactivePrivate = ReactivePrivate;
|
|
470
|
+
/**
|
|
471
|
+
* A reactive object
|
|
472
|
+
* @class Reactive
|
|
473
|
+
* @extends Destroyable
|
|
474
|
+
*/
|
|
475
|
+
var Reactive = /** @class */ (function (_super) {
|
|
476
|
+
__extends(Reactive, _super);
|
|
477
|
+
function Reactive(input, $) {
|
|
478
|
+
var _this = this; _super.call(this);
|
|
479
|
+
_this.input = input;
|
|
480
|
+
_this.$ = $ || new ReactivePrivate;
|
|
481
|
+
_this.$seal();
|
|
496
482
|
return _this;
|
|
497
483
|
}
|
|
484
|
+
Object.defineProperty(Reactive.prototype, "parent", {
|
|
485
|
+
/**
|
|
486
|
+
* Get parent node
|
|
487
|
+
*/
|
|
488
|
+
get: function () {
|
|
489
|
+
return this.$.parent;
|
|
490
|
+
},
|
|
491
|
+
enumerable: false,
|
|
492
|
+
configurable: true
|
|
493
|
+
});
|
|
498
494
|
/**
|
|
499
|
-
*
|
|
500
|
-
* @param value {*} value
|
|
501
|
-
* @return {this} a pointer to this
|
|
495
|
+
* Create a reference
|
|
496
|
+
* @param value {*} value to reference
|
|
502
497
|
*/
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
return this;
|
|
498
|
+
Reactive.prototype.ref = function (value) {
|
|
499
|
+
var $ = this.$;
|
|
500
|
+
var ref = new reference_1.Reference(value);
|
|
501
|
+
$.watch.add(ref);
|
|
502
|
+
return ref;
|
|
509
503
|
};
|
|
510
504
|
/**
|
|
511
|
-
*
|
|
505
|
+
* Create a mirror
|
|
506
|
+
* @param value {IValue} value to mirror
|
|
512
507
|
*/
|
|
513
|
-
|
|
514
|
-
var
|
|
515
|
-
this.
|
|
516
|
-
|
|
517
|
-
});
|
|
518
|
-
_super.prototype.clear.call(this);
|
|
508
|
+
Reactive.prototype.mirror = function (value) {
|
|
509
|
+
var mirror = new mirror_1.Mirror(value, false);
|
|
510
|
+
this.$.watch.add(mirror);
|
|
511
|
+
return mirror;
|
|
519
512
|
};
|
|
520
513
|
/**
|
|
521
|
-
*
|
|
522
|
-
* @param value {
|
|
523
|
-
* @return {boolean} true if a value was deleted, otherwise false
|
|
514
|
+
* Create a forward-only mirror
|
|
515
|
+
* @param value {IValue} value to mirror
|
|
524
516
|
*/
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
return _super.prototype.delete.call(this, value);
|
|
517
|
+
Reactive.prototype.forward = function (value) {
|
|
518
|
+
var mirror = new mirror_1.Mirror(value, true);
|
|
519
|
+
this.$.watch.add(mirror);
|
|
520
|
+
return mirror;
|
|
530
521
|
};
|
|
531
|
-
|
|
532
|
-
|
|
522
|
+
/**
|
|
523
|
+
* Creates a pointer
|
|
524
|
+
* @param value {*} default value to point
|
|
525
|
+
* @param forwardOnly {boolean} forward only sync
|
|
526
|
+
*/
|
|
527
|
+
Reactive.prototype.point = function (value, forwardOnly) {
|
|
528
|
+
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
529
|
+
var $ = this.$;
|
|
530
|
+
var pointer = new pointer_1.Pointer(value, forwardOnly);
|
|
531
|
+
$.watch.add(pointer);
|
|
532
|
+
return pointer;
|
|
533
533
|
};
|
|
534
|
-
|
|
535
|
-
|
|
534
|
+
/**
|
|
535
|
+
* Register a model
|
|
536
|
+
* @param model
|
|
537
|
+
*/
|
|
538
|
+
Reactive.prototype.register = function (model) {
|
|
539
|
+
this.$.models.add(model);
|
|
540
|
+
return model;
|
|
536
541
|
};
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
542
|
+
/**
|
|
543
|
+
* Creates a watcher
|
|
544
|
+
* @param func {function} function to run on any argument change
|
|
545
|
+
* @param values
|
|
546
|
+
*/
|
|
547
|
+
Reactive.prototype.watch = function (func) {
|
|
548
|
+
var values = [];
|
|
549
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
550
|
+
values[_i - 1] = arguments[_i];
|
|
551
|
+
}
|
|
552
|
+
var $ = this.$;
|
|
553
|
+
$.watch.add(new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))());
|
|
554
|
+
};
|
|
555
|
+
/**
|
|
556
|
+
* Creates a computed value
|
|
557
|
+
* @param func {function} function to run on any argument change
|
|
558
|
+
* @param values
|
|
559
|
+
* @return {IValue} the created ivalue
|
|
560
|
+
*/
|
|
561
|
+
Reactive.prototype.expr = function (func) {
|
|
562
|
+
var values = [];
|
|
563
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
564
|
+
values[_i - 1] = arguments[_i];
|
|
565
|
+
}
|
|
566
|
+
var res = new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))();
|
|
567
|
+
var $ = this.$;
|
|
568
|
+
$.watch.add(res);
|
|
569
|
+
return res;
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* Enable reactivity of fields
|
|
573
|
+
*/
|
|
574
|
+
Reactive.prototype.enable = function () {
|
|
575
|
+
var $ = this.$;
|
|
576
|
+
if (!$.enabled) {
|
|
577
|
+
$.watch.forEach(function (watcher) {
|
|
578
|
+
watcher.$enable();
|
|
579
|
+
});
|
|
580
|
+
$.models.forEach(function (model) {
|
|
581
|
+
model.enableReactivity();
|
|
582
|
+
});
|
|
583
|
+
$.enabled = true;
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
/**
|
|
587
|
+
* Disable reactivity of fields
|
|
588
|
+
*/
|
|
589
|
+
Reactive.prototype.disable = function () {
|
|
590
|
+
var $ = this.$;
|
|
591
|
+
if ($.enabled) {
|
|
592
|
+
$.watch.forEach(function (watcher) {
|
|
593
|
+
watcher.$disable();
|
|
594
|
+
});
|
|
595
|
+
$.models.forEach(function (model) {
|
|
596
|
+
model.disableReactivity();
|
|
597
|
+
});
|
|
598
|
+
$.enabled = false;
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
/**
|
|
602
|
+
* Disable/Enable reactivity of object fields with feedback
|
|
603
|
+
* @param cond {IValue} show condition
|
|
604
|
+
* @param onOff {function} on show feedback
|
|
605
|
+
* @param onOn {function} on hide feedback
|
|
606
|
+
*/
|
|
607
|
+
Reactive.prototype.bindAlive = function (cond, onOff, onOn) {
|
|
608
|
+
var _this = this;
|
|
609
|
+
var $ = this.$;
|
|
610
|
+
if ($.freezeExpr) {
|
|
611
|
+
throw (0, errors_1.wrongBinding)("this component already have a freeze state");
|
|
612
|
+
}
|
|
613
|
+
if ($.watch.has(cond)) {
|
|
614
|
+
throw (0, errors_1.wrongBinding)("freeze state must be bound to an external component");
|
|
615
|
+
}
|
|
616
|
+
$.freezeExpr = new expression_1.Expression(function (cond) {
|
|
617
|
+
$.frozen = !cond;
|
|
618
|
+
if (cond) {
|
|
619
|
+
onOn === null || onOn === void 0 ? void 0 : onOn();
|
|
620
|
+
_this.enable();
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
onOff === null || onOff === void 0 ? void 0 : onOff();
|
|
624
|
+
_this.disable();
|
|
625
|
+
}
|
|
626
|
+
}, true, cond);
|
|
627
|
+
return this;
|
|
628
|
+
};
|
|
629
|
+
Reactive.prototype.init = function () {
|
|
630
|
+
this.applyOptions(this.input);
|
|
631
|
+
return this.compose(this.input);
|
|
632
|
+
};
|
|
633
|
+
Reactive.prototype.applyOptions = function (input) {
|
|
634
|
+
// empty
|
|
635
|
+
};
|
|
636
|
+
Reactive.prototype.applyOptionsNow = function () {
|
|
637
|
+
this.applyOptions(this.input);
|
|
638
|
+
};
|
|
639
|
+
Reactive.prototype.compose = function (input) {
|
|
640
|
+
throw (0, errors_1.notOverwritten)();
|
|
641
|
+
};
|
|
642
|
+
Reactive.prototype.composeNow = function () {
|
|
643
|
+
this.compose(this.input);
|
|
644
|
+
};
|
|
645
|
+
Reactive.prototype.runFunctional = function (f) {
|
|
646
|
+
var args = [];
|
|
647
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
648
|
+
args[_i - 1] = arguments[_i];
|
|
649
|
+
}
|
|
650
|
+
stack(this);
|
|
651
|
+
// yet another ts bug
|
|
652
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
653
|
+
// @ts-ignore
|
|
654
|
+
var result = f.apply(void 0, args);
|
|
655
|
+
unstack();
|
|
656
|
+
return result;
|
|
657
|
+
};
|
|
658
|
+
Reactive.prototype.runOnDestroy = function (func) {
|
|
659
|
+
this.$.onDestroy = func;
|
|
660
|
+
};
|
|
661
|
+
Reactive.prototype.$destroy = function () {
|
|
662
|
+
_super.prototype.$destroy.call(this);
|
|
663
|
+
this.$.$destroy();
|
|
664
|
+
this.$ = null;
|
|
665
|
+
};
|
|
666
|
+
return Reactive;
|
|
667
|
+
}(destroyable_js_1.Destroyable));
|
|
668
|
+
exports.Reactive = Reactive;
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
// ./lib-es5/value/reference.js
|
|
543
672
|
"use strict";
|
|
544
673
|
var __extends = (this && this.__extends) || (function () {
|
|
545
674
|
var extendStatics = function (d, b) {
|
|
@@ -557,83 +686,70 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
557
686
|
};
|
|
558
687
|
})();
|
|
559
688
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
560
|
-
exports.
|
|
561
|
-
var
|
|
689
|
+
exports.Reference = void 0;
|
|
690
|
+
var ivalue_1 = require("../core/ivalue");
|
|
562
691
|
/**
|
|
563
|
-
*
|
|
564
|
-
* @class
|
|
565
|
-
* @extends
|
|
566
|
-
* @implements IModel
|
|
692
|
+
* Declares a notifiable value
|
|
693
|
+
* @class Reference
|
|
694
|
+
* @extends IValue
|
|
567
695
|
*/
|
|
568
|
-
var
|
|
569
|
-
__extends(
|
|
696
|
+
var Reference = /** @class */ (function (_super) {
|
|
697
|
+
__extends(Reference, _super);
|
|
570
698
|
/**
|
|
571
|
-
*
|
|
572
|
-
* @param map {[*, *][]} input data
|
|
699
|
+
* @param value {any} the initial value
|
|
573
700
|
*/
|
|
574
|
-
function
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
writable: false,
|
|
580
|
-
configurable: false
|
|
581
|
-
});
|
|
582
|
-
map.forEach(function (_a) {
|
|
583
|
-
var key = _a[0], value = _a[1];
|
|
584
|
-
_super.prototype.set.call(_this, key, value);
|
|
585
|
-
});
|
|
701
|
+
function Reference(value) {
|
|
702
|
+
var _this = _super.call(this, true) || this;
|
|
703
|
+
_this.$value = value;
|
|
704
|
+
_this.$onchange = new Set;
|
|
705
|
+
_this.$seal();
|
|
586
706
|
return _this;
|
|
587
707
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
708
|
+
Object.defineProperty(Reference.prototype, "$", {
|
|
709
|
+
get: function () {
|
|
710
|
+
return this.$value;
|
|
711
|
+
},
|
|
712
|
+
set: function (value) {
|
|
713
|
+
if (this.$value !== value) {
|
|
714
|
+
this.$value = value;
|
|
715
|
+
if (this.isEnabled) {
|
|
716
|
+
this.$onchange.forEach(function (handler) {
|
|
717
|
+
handler(value);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
enumerable: false,
|
|
723
|
+
configurable: true
|
|
724
|
+
});
|
|
725
|
+
Reference.prototype.$enable = function () {
|
|
592
726
|
var _this = this;
|
|
593
|
-
this.
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Calls Map.delete and notify abut changes
|
|
600
|
-
* @param key {*} key
|
|
601
|
-
* @return {boolean} true if removed something, otherwise false
|
|
602
|
-
*/
|
|
603
|
-
MapModel.prototype.delete = function (key) {
|
|
604
|
-
var tmp = _super.prototype.get.call(this, key);
|
|
605
|
-
if (tmp) {
|
|
606
|
-
this.listener.emitRemoved(key, tmp);
|
|
727
|
+
if (!this.isEnabled) {
|
|
728
|
+
this.$onchange.forEach(function (handler) {
|
|
729
|
+
handler(_this.$value);
|
|
730
|
+
});
|
|
731
|
+
this.isEnabled = true;
|
|
607
732
|
}
|
|
608
|
-
return _super.prototype.delete.call(this, key);
|
|
609
733
|
};
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
* @param key {*} key
|
|
613
|
-
* @param value {*} value
|
|
614
|
-
* @return {MapModel} a pointer to this
|
|
615
|
-
*/
|
|
616
|
-
MapModel.prototype.set = function (key, value) {
|
|
617
|
-
var tmp = _super.prototype.get.call(this, key);
|
|
618
|
-
if (tmp) {
|
|
619
|
-
this.listener.emitRemoved(key, tmp);
|
|
620
|
-
}
|
|
621
|
-
_super.prototype.set.call(this, key, value);
|
|
622
|
-
this.listener.emitAdded(key, value);
|
|
623
|
-
return this;
|
|
734
|
+
Reference.prototype.$disable = function () {
|
|
735
|
+
this.isEnabled = false;
|
|
624
736
|
};
|
|
625
|
-
|
|
626
|
-
this.
|
|
737
|
+
Reference.prototype.$on = function (handler) {
|
|
738
|
+
this.$onchange.add(handler);
|
|
627
739
|
};
|
|
628
|
-
|
|
629
|
-
this.
|
|
740
|
+
Reference.prototype.$off = function (handler) {
|
|
741
|
+
this.$onchange.delete(handler);
|
|
630
742
|
};
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
743
|
+
Reference.prototype.$destroy = function () {
|
|
744
|
+
_super.prototype.$destroy.call(this);
|
|
745
|
+
this.$onchange.clear();
|
|
746
|
+
};
|
|
747
|
+
return Reference;
|
|
748
|
+
}(ivalue_1.IValue));
|
|
749
|
+
exports.Reference = Reference;
|
|
634
750
|
|
|
635
751
|
|
|
636
|
-
// ./lib-es5/
|
|
752
|
+
// ./lib-es5/value/expression.js
|
|
637
753
|
"use strict";
|
|
638
754
|
var __extends = (this && this.__extends) || (function () {
|
|
639
755
|
var extendStatics = function (d, b) {
|
|
@@ -650,339 +766,195 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
650
766
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
651
767
|
};
|
|
652
768
|
})();
|
|
653
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
654
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
655
|
-
if (ar || !(i in from)) {
|
|
656
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
657
|
-
ar[i] = from[i];
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
661
|
-
};
|
|
662
769
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
663
|
-
exports.
|
|
664
|
-
var
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
*
|
|
668
|
-
* @
|
|
770
|
+
exports.Expression = void 0;
|
|
771
|
+
var reference_js_1 = require("./reference.js");
|
|
772
|
+
var ivalue_1 = require("../core/ivalue");
|
|
773
|
+
/**
|
|
774
|
+
* Bind some values to one expression
|
|
775
|
+
* @class Expression
|
|
776
|
+
* @extends IValue
|
|
669
777
|
*/
|
|
670
|
-
var
|
|
671
|
-
__extends(
|
|
778
|
+
var Expression = /** @class */ (function (_super) {
|
|
779
|
+
__extends(Expression, _super);
|
|
672
780
|
/**
|
|
673
|
-
*
|
|
781
|
+
* Creates a function bounded to N values
|
|
782
|
+
* @param func {Function} the function to bound
|
|
783
|
+
* @param values
|
|
784
|
+
* @param link {Boolean} links immediately if true
|
|
674
785
|
*/
|
|
675
|
-
function
|
|
676
|
-
|
|
677
|
-
var
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
786
|
+
function Expression(func, link) {
|
|
787
|
+
var values = [];
|
|
788
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
789
|
+
values[_i - 2] = arguments[_i];
|
|
790
|
+
}
|
|
791
|
+
var _this = _super.call(this, false) || this;
|
|
792
|
+
/**
|
|
793
|
+
* Expression will link different handler for each value of list
|
|
794
|
+
*/
|
|
795
|
+
_this.linkedFunc = [];
|
|
796
|
+
var handler = function (i) {
|
|
797
|
+
if (i != null) {
|
|
798
|
+
_this.valuesCache[i] = _this.values[i].$;
|
|
799
|
+
}
|
|
800
|
+
_this.sync.$ = func.apply(_this, _this.valuesCache);
|
|
801
|
+
};
|
|
802
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
803
|
+
// @ts-ignore
|
|
804
|
+
_this.valuesCache = values.map(function (item) { return item.$; });
|
|
805
|
+
_this.sync = new reference_js_1.Reference(func.apply(_this, _this.valuesCache));
|
|
806
|
+
var i = 0;
|
|
807
|
+
values.forEach(function () {
|
|
808
|
+
_this.linkedFunc.push(handler.bind(_this, Number(i++)));
|
|
682
809
|
});
|
|
683
|
-
|
|
684
|
-
|
|
810
|
+
_this.values = values;
|
|
811
|
+
_this.func = handler;
|
|
812
|
+
if (link) {
|
|
813
|
+
_this.$enable();
|
|
814
|
+
}
|
|
815
|
+
else {
|
|
816
|
+
handler();
|
|
685
817
|
}
|
|
818
|
+
_this.$seal();
|
|
686
819
|
return _this;
|
|
687
820
|
}
|
|
688
|
-
Object.defineProperty(
|
|
689
|
-
/* Array members */
|
|
690
|
-
/**
|
|
691
|
-
* Gets the last item of array
|
|
692
|
-
* @return {*} the last item of array
|
|
693
|
-
*/
|
|
821
|
+
Object.defineProperty(Expression.prototype, "$", {
|
|
694
822
|
get: function () {
|
|
695
|
-
return this.
|
|
823
|
+
return this.sync.$;
|
|
824
|
+
},
|
|
825
|
+
set: function (value) {
|
|
826
|
+
this.sync.$ = value;
|
|
696
827
|
},
|
|
697
828
|
enumerable: false,
|
|
698
829
|
configurable: true
|
|
699
830
|
});
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
* @param value {*} value to fill with
|
|
703
|
-
* @param start {?number} begin index
|
|
704
|
-
* @param end {?number} end index
|
|
705
|
-
*/
|
|
706
|
-
ArrayModel.prototype.fill = function (value, start, end) {
|
|
707
|
-
if (!start) {
|
|
708
|
-
start = 0;
|
|
709
|
-
}
|
|
710
|
-
if (!end) {
|
|
711
|
-
end = this.length;
|
|
712
|
-
}
|
|
713
|
-
for (var i = start; i < end; i++) {
|
|
714
|
-
this.listener.emitRemoved(this[i], this[i]);
|
|
715
|
-
this[i] = value;
|
|
716
|
-
this.listener.emitAdded(value, value);
|
|
717
|
-
}
|
|
831
|
+
Expression.prototype.$on = function (handler) {
|
|
832
|
+
this.sync.$on(handler);
|
|
718
833
|
return this;
|
|
719
834
|
};
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
*/
|
|
724
|
-
ArrayModel.prototype.pop = function () {
|
|
725
|
-
var v = _super.prototype.pop.call(this);
|
|
726
|
-
if (v !== undefined) {
|
|
727
|
-
this.listener.emitRemoved(v, v);
|
|
728
|
-
}
|
|
729
|
-
return v;
|
|
730
|
-
};
|
|
731
|
-
/**
|
|
732
|
-
* Calls Array.push and notify about changes
|
|
733
|
-
* @param items {...*} values to push
|
|
734
|
-
* @return {number} new length of array
|
|
735
|
-
*/
|
|
736
|
-
ArrayModel.prototype.push = function () {
|
|
737
|
-
var _this = this;
|
|
738
|
-
var items = [];
|
|
739
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
740
|
-
items[_i] = arguments[_i];
|
|
741
|
-
}
|
|
742
|
-
items.forEach(function (item) {
|
|
743
|
-
_this.listener.emitAdded(item, item);
|
|
744
|
-
_super.prototype.push.call(_this, item);
|
|
745
|
-
});
|
|
746
|
-
return this.length;
|
|
747
|
-
};
|
|
748
|
-
/**
|
|
749
|
-
* Calls Array.shift and notify about changed
|
|
750
|
-
* @return {*} the shifted value
|
|
751
|
-
*/
|
|
752
|
-
ArrayModel.prototype.shift = function () {
|
|
753
|
-
var v = _super.prototype.shift.call(this);
|
|
754
|
-
if (v !== undefined) {
|
|
755
|
-
this.listener.emitRemoved(v, v);
|
|
756
|
-
}
|
|
757
|
-
return v;
|
|
835
|
+
Expression.prototype.$off = function (handler) {
|
|
836
|
+
this.sync.$off(handler);
|
|
837
|
+
return this;
|
|
758
838
|
};
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
* @return {ArrayModel} a pointer to this
|
|
765
|
-
*/
|
|
766
|
-
ArrayModel.prototype.splice = function (start, deleteCount) {
|
|
767
|
-
var items = [];
|
|
768
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
769
|
-
items[_i - 2] = arguments[_i];
|
|
770
|
-
}
|
|
771
|
-
start = Math.min(start, this.length);
|
|
772
|
-
deleteCount = deleteCount || this.length - start;
|
|
773
|
-
var before = this[start + deleteCount];
|
|
774
|
-
for (var i = 0; i < deleteCount; i++) {
|
|
775
|
-
var index = start + deleteCount - i - 1;
|
|
776
|
-
if (this[index] !== undefined) {
|
|
777
|
-
this.listener.emitRemoved(this[index], this[index]);
|
|
839
|
+
Expression.prototype.$enable = function () {
|
|
840
|
+
if (!this.isEnabled) {
|
|
841
|
+
for (var i = 0; i < this.values.length; i++) {
|
|
842
|
+
this.values[i].$on(this.linkedFunc[i]);
|
|
843
|
+
this.valuesCache[i] = this.values[i].$;
|
|
778
844
|
}
|
|
845
|
+
this.func();
|
|
846
|
+
this.isEnabled = true;
|
|
779
847
|
}
|
|
780
|
-
|
|
781
|
-
this.listener.emitAdded(before, items[i]);
|
|
782
|
-
}
|
|
783
|
-
return new ArrayModel(_super.prototype.splice.apply(this, __spreadArray([start, deleteCount], items, false)));
|
|
848
|
+
return this;
|
|
784
849
|
};
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
var items = [];
|
|
792
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
793
|
-
items[_i] = arguments[_i];
|
|
794
|
-
}
|
|
795
|
-
for (var i = 0; i < items.length; i++) {
|
|
796
|
-
this.listener.emitAdded(this[i], items[i]);
|
|
850
|
+
Expression.prototype.$disable = function () {
|
|
851
|
+
if (this.isEnabled) {
|
|
852
|
+
for (var i = 0; i < this.values.length; i++) {
|
|
853
|
+
this.values[i].$off(this.linkedFunc[i]);
|
|
854
|
+
}
|
|
855
|
+
this.isEnabled = false;
|
|
797
856
|
}
|
|
798
|
-
return _super.prototype.unshift.apply(this, items);
|
|
799
|
-
};
|
|
800
|
-
/**
|
|
801
|
-
* Inserts a value to the end of array
|
|
802
|
-
* @param v {*} value to insert
|
|
803
|
-
*/
|
|
804
|
-
ArrayModel.prototype.append = function (v) {
|
|
805
|
-
this.listener.emitAdded(null, v);
|
|
806
|
-
_super.prototype.push.call(this, v);
|
|
807
857
|
return this;
|
|
808
858
|
};
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
this.forEach(function (v) {
|
|
816
|
-
_this.listener.emitRemoved(v, v);
|
|
817
|
-
});
|
|
818
|
-
_super.prototype.splice.call(this, 0);
|
|
819
|
-
return this;
|
|
859
|
+
Expression.prototype.$destroy = function () {
|
|
860
|
+
this.$disable();
|
|
861
|
+
this.values.splice(0);
|
|
862
|
+
this.valuesCache.splice(0);
|
|
863
|
+
this.linkedFunc.splice(0);
|
|
864
|
+
_super.prototype.$destroy.call(this);
|
|
820
865
|
};
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
866
|
+
return Expression;
|
|
867
|
+
}(ivalue_1.IValue));
|
|
868
|
+
exports.Expression = Expression;
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
// ./lib-es5/value/mirror.js
|
|
872
|
+
"use strict";
|
|
873
|
+
var __extends = (this && this.__extends) || (function () {
|
|
874
|
+
var extendStatics = function (d, b) {
|
|
875
|
+
extendStatics = Object.setPrototypeOf ||
|
|
876
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
877
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
878
|
+
return extendStatics(d, b);
|
|
831
879
|
};
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
this.listener.emitAdded(this[0], v);
|
|
839
|
-
_super.prototype.unshift.call(this, v);
|
|
840
|
-
return this;
|
|
880
|
+
return function (d, b) {
|
|
881
|
+
if (typeof b !== "function" && b !== null)
|
|
882
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
883
|
+
extendStatics(d, b);
|
|
884
|
+
function __() { this.constructor = d; }
|
|
885
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
841
886
|
};
|
|
887
|
+
})();
|
|
888
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
889
|
+
exports.Mirror = void 0;
|
|
890
|
+
var reference_1 = require("./reference");
|
|
891
|
+
/**
|
|
892
|
+
* Declares a notifiable bind to a value
|
|
893
|
+
* @class Mirror
|
|
894
|
+
* @extends IValue
|
|
895
|
+
* @version 2
|
|
896
|
+
*/
|
|
897
|
+
var Mirror = /** @class */ (function (_super) {
|
|
898
|
+
__extends(Mirror, _super);
|
|
842
899
|
/**
|
|
843
|
-
*
|
|
844
|
-
* @param
|
|
845
|
-
* @
|
|
846
|
-
*/
|
|
847
|
-
ArrayModel.prototype.removeAt = function (index) {
|
|
848
|
-
if (index > 0 && index < this.length) {
|
|
849
|
-
this.listener.emitRemoved(this[index], this[index]);
|
|
850
|
-
_super.prototype.splice.call(this, index, 1);
|
|
851
|
-
}
|
|
852
|
-
return this;
|
|
853
|
-
};
|
|
854
|
-
/**
|
|
855
|
-
* Removes the first value of array
|
|
856
|
-
* @return {this} a pointer to this
|
|
900
|
+
* Constructs a notifiable bind to a value
|
|
901
|
+
* @param value {IValue} is initial value
|
|
902
|
+
* @param forwardOnly {boolean} ensure forward only synchronization
|
|
857
903
|
*/
|
|
858
|
-
|
|
859
|
-
if (
|
|
860
|
-
|
|
861
|
-
|
|
904
|
+
function Mirror(value, forwardOnly) {
|
|
905
|
+
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
906
|
+
var _this = _super.call(this, value.$) || this;
|
|
907
|
+
_this.$handler = function (v) {
|
|
908
|
+
_this.$ = v;
|
|
909
|
+
};
|
|
910
|
+
_this.$pointedValue = value;
|
|
911
|
+
_this.$forwardOnly = forwardOnly;
|
|
912
|
+
value.$on(_this.$handler);
|
|
913
|
+
_this.$seal();
|
|
914
|
+
return _this;
|
|
915
|
+
}
|
|
916
|
+
Object.defineProperty(Mirror.prototype, "$", {
|
|
917
|
+
get: function () {
|
|
918
|
+
// this is a ts bug
|
|
919
|
+
// eslint-disable-next-line
|
|
920
|
+
// @ts-ignore
|
|
921
|
+
return _super.prototype.$;
|
|
922
|
+
},
|
|
923
|
+
set: function (v) {
|
|
924
|
+
if (!this.$forwardOnly) {
|
|
925
|
+
this.$pointedValue.$ = v;
|
|
926
|
+
}
|
|
927
|
+
// this is a ts bug
|
|
928
|
+
// eslint-disable-next-line
|
|
929
|
+
// @ts-ignore
|
|
930
|
+
_super.prototype.$ = v;
|
|
931
|
+
},
|
|
932
|
+
enumerable: false,
|
|
933
|
+
configurable: true
|
|
934
|
+
});
|
|
935
|
+
Mirror.prototype.$enable = function () {
|
|
936
|
+
if (!this.isEnabled) {
|
|
937
|
+
this.isEnabled = true;
|
|
938
|
+
this.$pointedValue.$on(this.$handler);
|
|
939
|
+
this.$ = this.$pointedValue.$;
|
|
862
940
|
}
|
|
863
|
-
return this;
|
|
864
941
|
};
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
ArrayModel.prototype.removeLast = function () {
|
|
870
|
-
var last = this.last;
|
|
871
|
-
if (last != null) {
|
|
872
|
-
this.listener.emitRemoved(this[this.length - 1], last);
|
|
873
|
-
_super.prototype.pop.call(this);
|
|
942
|
+
Mirror.prototype.$disable = function () {
|
|
943
|
+
if (this.isEnabled) {
|
|
944
|
+
this.$pointedValue.$off(this.$handler);
|
|
945
|
+
this.isEnabled = false;
|
|
874
946
|
}
|
|
875
|
-
return this;
|
|
876
|
-
};
|
|
877
|
-
/**
|
|
878
|
-
* Remove the first occurrence of value
|
|
879
|
-
* @param v {*} value to remove
|
|
880
|
-
* @return {this}
|
|
881
|
-
*/
|
|
882
|
-
ArrayModel.prototype.removeOne = function (v) {
|
|
883
|
-
this.removeAt(this.indexOf(v));
|
|
884
|
-
return this;
|
|
885
|
-
};
|
|
886
|
-
ArrayModel.prototype.replace = function (at, with_) {
|
|
887
|
-
this.listener.emitAdded(this[at], with_);
|
|
888
|
-
this.listener.emitRemoved(this[at], this[at]);
|
|
889
|
-
this[at] = with_;
|
|
890
|
-
return this;
|
|
891
|
-
};
|
|
892
|
-
ArrayModel.prototype.enableReactivity = function () {
|
|
893
|
-
this.listener.enableReactivity();
|
|
894
|
-
};
|
|
895
|
-
ArrayModel.prototype.disableReactivity = function () {
|
|
896
|
-
this.listener.disableReactivity();
|
|
897
|
-
};
|
|
898
|
-
return ArrayModel;
|
|
899
|
-
}(Array));
|
|
900
|
-
exports.ArrayModel = ArrayModel;
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
// ./lib-es5/core/errors.js
|
|
904
|
-
"use strict";
|
|
905
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
906
|
-
exports.wrongBinding = exports.userError = exports.internalError = exports.notOverwritten = void 0;
|
|
907
|
-
var reportIt = "Report it here: https://gitlab.com/vasille-js/vasille-js/-/issues";
|
|
908
|
-
function notOverwritten() {
|
|
909
|
-
console.error("Vasille-SFP: Internal error", "Must be overwritten", reportIt);
|
|
910
|
-
return "not-overwritten";
|
|
911
|
-
}
|
|
912
|
-
exports.notOverwritten = notOverwritten;
|
|
913
|
-
function internalError(msg) {
|
|
914
|
-
console.error("Vasille-SFP: Internal error", msg, reportIt);
|
|
915
|
-
return "internal-error";
|
|
916
|
-
}
|
|
917
|
-
exports.internalError = internalError;
|
|
918
|
-
function userError(msg, err) {
|
|
919
|
-
console.error("Vasille-SFP: User error", msg);
|
|
920
|
-
return err;
|
|
921
|
-
}
|
|
922
|
-
exports.userError = userError;
|
|
923
|
-
function wrongBinding(msg) {
|
|
924
|
-
return userError(msg, "wrong-binding");
|
|
925
|
-
}
|
|
926
|
-
exports.wrongBinding = wrongBinding;
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
// ./lib-es5/core/destroyable.js
|
|
930
|
-
"use strict";
|
|
931
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
932
|
-
exports.Destroyable = void 0;
|
|
933
|
-
/**
|
|
934
|
-
* Mark an object which can be destroyed
|
|
935
|
-
* @class Destroyable
|
|
936
|
-
*/
|
|
937
|
-
var Destroyable = /** @class */ (function () {
|
|
938
|
-
function Destroyable() {
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* Make object fields non configurable
|
|
942
|
-
* @protected
|
|
943
|
-
*/
|
|
944
|
-
Destroyable.prototype.$seal = function () {
|
|
945
|
-
var _this = this;
|
|
946
|
-
var $ = this;
|
|
947
|
-
Object.keys($).forEach(function (i) {
|
|
948
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
949
|
-
if (_this.hasOwnProperty(i)) {
|
|
950
|
-
var config = Object.getOwnPropertyDescriptor($, i);
|
|
951
|
-
if (config.configurable) {
|
|
952
|
-
var descriptor = void 0;
|
|
953
|
-
if (config.set || config.get) {
|
|
954
|
-
descriptor = {
|
|
955
|
-
configurable: false,
|
|
956
|
-
get: config.get,
|
|
957
|
-
set: config.set,
|
|
958
|
-
enumerable: config.enumerable
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
descriptor = {
|
|
963
|
-
value: $[i],
|
|
964
|
-
configurable: false,
|
|
965
|
-
writable: config.writable,
|
|
966
|
-
enumerable: config.enumerable
|
|
967
|
-
};
|
|
968
|
-
}
|
|
969
|
-
Object.defineProperty($, i, descriptor);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
947
|
};
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
Destroyable.prototype.$destroy = function () {
|
|
978
|
-
// nothing here
|
|
948
|
+
Mirror.prototype.$destroy = function () {
|
|
949
|
+
this.$disable();
|
|
950
|
+
_super.prototype.$destroy.call(this);
|
|
979
951
|
};
|
|
980
|
-
return
|
|
981
|
-
}());
|
|
982
|
-
exports.
|
|
952
|
+
return Mirror;
|
|
953
|
+
}(reference_1.Reference));
|
|
954
|
+
exports.Mirror = Mirror;
|
|
983
955
|
|
|
984
956
|
|
|
985
|
-
// ./lib-es5/
|
|
957
|
+
// ./lib-es5/value/pointer.js
|
|
986
958
|
"use strict";
|
|
987
959
|
var __extends = (this && this.__extends) || (function () {
|
|
988
960
|
var extendStatics = function (d, b) {
|
|
@@ -1000,154 +972,189 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1000
972
|
};
|
|
1001
973
|
})();
|
|
1002
974
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1003
|
-
exports.
|
|
1004
|
-
var
|
|
1005
|
-
var errors_1 = require("./errors");
|
|
1006
|
-
var Switchable = /** @class */ (function (_super) {
|
|
1007
|
-
__extends(Switchable, _super);
|
|
1008
|
-
function Switchable() {
|
|
1009
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Enable update handlers triggering
|
|
1013
|
-
*/
|
|
1014
|
-
Switchable.prototype.$enable = function () {
|
|
1015
|
-
throw (0, errors_1.notOverwritten)();
|
|
1016
|
-
};
|
|
1017
|
-
/**
|
|
1018
|
-
* disable update handlers triggering
|
|
1019
|
-
*/
|
|
1020
|
-
Switchable.prototype.$disable = function () {
|
|
1021
|
-
throw (0, errors_1.notOverwritten)();
|
|
1022
|
-
};
|
|
1023
|
-
return Switchable;
|
|
1024
|
-
}(destroyable_js_1.Destroyable));
|
|
1025
|
-
exports.Switchable = Switchable;
|
|
975
|
+
exports.Pointer = void 0;
|
|
976
|
+
var mirror_1 = require("./mirror");
|
|
1026
977
|
/**
|
|
1027
|
-
*
|
|
1028
|
-
* @class
|
|
1029
|
-
* @extends
|
|
978
|
+
* r/w pointer to a value
|
|
979
|
+
* @class Pointer
|
|
980
|
+
* @extends Mirror
|
|
1030
981
|
*/
|
|
1031
|
-
var
|
|
1032
|
-
__extends(
|
|
982
|
+
var Pointer = /** @class */ (function (_super) {
|
|
983
|
+
__extends(Pointer, _super);
|
|
1033
984
|
/**
|
|
1034
|
-
* @param
|
|
985
|
+
* @param value {IValue} value to point
|
|
986
|
+
* @param forwardOnly {boolean} forward only data flow
|
|
1035
987
|
*/
|
|
1036
|
-
function
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
return _this;
|
|
988
|
+
function Pointer(value, forwardOnly) {
|
|
989
|
+
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
990
|
+
return _super.call(this, value, forwardOnly) || this;
|
|
1040
991
|
}
|
|
1041
|
-
Object.defineProperty(
|
|
1042
|
-
/**
|
|
1043
|
-
* Get the encapsulated value
|
|
1044
|
-
* @return {*} the encapsulated value
|
|
1045
|
-
*/
|
|
1046
|
-
get: function () {
|
|
1047
|
-
throw (0, errors_1.notOverwritten)();
|
|
1048
|
-
},
|
|
992
|
+
Object.defineProperty(Pointer.prototype, "$$", {
|
|
1049
993
|
/**
|
|
1050
|
-
*
|
|
1051
|
-
* @param value {
|
|
994
|
+
* Point a new ivalue
|
|
995
|
+
* @param value {IValue} value to point
|
|
1052
996
|
*/
|
|
1053
997
|
set: function (value) {
|
|
1054
|
-
|
|
998
|
+
if (this.$pointedValue !== value) {
|
|
999
|
+
this.$disable();
|
|
1000
|
+
this.$pointedValue = value;
|
|
1001
|
+
this.$enable();
|
|
1002
|
+
}
|
|
1055
1003
|
},
|
|
1056
1004
|
enumerable: false,
|
|
1057
1005
|
configurable: true
|
|
1058
1006
|
});
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
*/
|
|
1063
|
-
IValue.prototype.$on = function (handler) {
|
|
1064
|
-
throw (0, errors_1.notOverwritten)();
|
|
1065
|
-
};
|
|
1066
|
-
/**
|
|
1067
|
-
* Removes a handler of value change
|
|
1068
|
-
* @param handler {function(value : *)} the handler to remove
|
|
1069
|
-
*/
|
|
1070
|
-
IValue.prototype.$off = function (handler) {
|
|
1071
|
-
throw (0, errors_1.notOverwritten)();
|
|
1072
|
-
};
|
|
1073
|
-
return IValue;
|
|
1074
|
-
}(Switchable));
|
|
1075
|
-
exports.IValue = IValue;
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
// ./lib-es5/index.js
|
|
1079
|
-
"use strict";
|
|
1080
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1081
|
-
exports.current = exports.userError = exports.Watch = exports.Reactive = exports.Binding = exports.Expression = exports.Portal = exports.App = exports.AppNode = exports.Extension = exports.Component = exports.Tag = exports.INode = exports.Fragment = exports.SetView = exports.ObjectView = exports.MapView = exports.ArrayView = exports.Listener = exports.BaseView = exports.SetModel = exports.ObjectModel = exports.MapModel = exports.ArrayModel = exports.Pointer = exports.Mirror = exports.Reference = exports.IValue = exports.Destroyable = void 0;
|
|
1082
|
-
var destroyable_1 = require("./core/destroyable");
|
|
1083
|
-
Object.defineProperty(exports, "Destroyable", { enumerable: true, get: function () { return destroyable_1.Destroyable; } });
|
|
1084
|
-
var core_1 = require("./core/core");
|
|
1085
|
-
Object.defineProperty(exports, "current", { enumerable: true, get: function () { return core_1.current; } });
|
|
1086
|
-
Object.defineProperty(exports, "Reactive", { enumerable: true, get: function () { return core_1.Reactive; } });
|
|
1087
|
-
var ivalue_1 = require("./core/ivalue");
|
|
1088
|
-
Object.defineProperty(exports, "IValue", { enumerable: true, get: function () { return ivalue_1.IValue; } });
|
|
1089
|
-
var array_model_1 = require("./models/array-model");
|
|
1090
|
-
Object.defineProperty(exports, "ArrayModel", { enumerable: true, get: function () { return array_model_1.ArrayModel; } });
|
|
1091
|
-
var listener_1 = require("./models/listener");
|
|
1092
|
-
Object.defineProperty(exports, "Listener", { enumerable: true, get: function () { return listener_1.Listener; } });
|
|
1093
|
-
var map_model_1 = require("./models/map-model");
|
|
1094
|
-
Object.defineProperty(exports, "MapModel", { enumerable: true, get: function () { return map_model_1.MapModel; } });
|
|
1095
|
-
var object_model_1 = require("./models/object-model");
|
|
1096
|
-
Object.defineProperty(exports, "ObjectModel", { enumerable: true, get: function () { return object_model_1.ObjectModel; } });
|
|
1097
|
-
var set_model_1 = require("./models/set-model");
|
|
1098
|
-
Object.defineProperty(exports, "SetModel", { enumerable: true, get: function () { return set_model_1.SetModel; } });
|
|
1099
|
-
var app_1 = require("./node/app");
|
|
1100
|
-
Object.defineProperty(exports, "App", { enumerable: true, get: function () { return app_1.App; } });
|
|
1101
|
-
Object.defineProperty(exports, "AppNode", { enumerable: true, get: function () { return app_1.AppNode; } });
|
|
1102
|
-
Object.defineProperty(exports, "Portal", { enumerable: true, get: function () { return app_1.Portal; } });
|
|
1103
|
-
var node_1 = require("./node/node");
|
|
1104
|
-
Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return node_1.Component; } });
|
|
1105
|
-
Object.defineProperty(exports, "Extension", { enumerable: true, get: function () { return node_1.Extension; } });
|
|
1106
|
-
Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return node_1.Fragment; } });
|
|
1107
|
-
Object.defineProperty(exports, "INode", { enumerable: true, get: function () { return node_1.INode; } });
|
|
1108
|
-
Object.defineProperty(exports, "Tag", { enumerable: true, get: function () { return node_1.Tag; } });
|
|
1109
|
-
var expression_1 = require("./value/expression");
|
|
1110
|
-
Object.defineProperty(exports, "Expression", { enumerable: true, get: function () { return expression_1.Expression; } });
|
|
1111
|
-
var mirror_1 = require("./value/mirror");
|
|
1112
|
-
Object.defineProperty(exports, "Mirror", { enumerable: true, get: function () { return mirror_1.Mirror; } });
|
|
1113
|
-
var pointer_1 = require("./value/pointer");
|
|
1114
|
-
Object.defineProperty(exports, "Pointer", { enumerable: true, get: function () { return pointer_1.Pointer; } });
|
|
1115
|
-
var reference_1 = require("./value/reference");
|
|
1116
|
-
Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return reference_1.Reference; } });
|
|
1117
|
-
var array_view_1 = require("./views/array-view");
|
|
1118
|
-
Object.defineProperty(exports, "ArrayView", { enumerable: true, get: function () { return array_view_1.ArrayView; } });
|
|
1119
|
-
var base_view_1 = require("./views/base-view");
|
|
1120
|
-
Object.defineProperty(exports, "BaseView", { enumerable: true, get: function () { return base_view_1.BaseView; } });
|
|
1121
|
-
var map_view_1 = require("./views/map-view");
|
|
1122
|
-
Object.defineProperty(exports, "MapView", { enumerable: true, get: function () { return map_view_1.MapView; } });
|
|
1123
|
-
var object_view_1 = require("./views/object-view");
|
|
1124
|
-
Object.defineProperty(exports, "ObjectView", { enumerable: true, get: function () { return object_view_1.ObjectView; } });
|
|
1125
|
-
var set_view_1 = require("./views/set-view");
|
|
1126
|
-
Object.defineProperty(exports, "SetView", { enumerable: true, get: function () { return set_view_1.SetView; } });
|
|
1127
|
-
var binding_1 = require("./binding/binding");
|
|
1128
|
-
Object.defineProperty(exports, "Binding", { enumerable: true, get: function () { return binding_1.Binding; } });
|
|
1129
|
-
var errors_1 = require("./core/errors");
|
|
1130
|
-
Object.defineProperty(exports, "userError", { enumerable: true, get: function () { return errors_1.userError; } });
|
|
1131
|
-
var watch_1 = require("./node/watch");
|
|
1132
|
-
Object.defineProperty(exports, "Watch", { enumerable: true, get: function () { return watch_1.Watch; } });
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
// ./lib-es5/spec/svg.js
|
|
1136
|
-
"use strict";
|
|
1137
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1007
|
+
return Pointer;
|
|
1008
|
+
}(mirror_1.Mirror));
|
|
1009
|
+
exports.Pointer = Pointer;
|
|
1138
1010
|
|
|
1139
1011
|
|
|
1140
|
-
// ./lib-es5/
|
|
1012
|
+
// ./lib-es5/models/listener.js
|
|
1141
1013
|
"use strict";
|
|
1142
1014
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1015
|
+
exports.Listener = void 0;
|
|
1016
|
+
/**
|
|
1017
|
+
* Represent a listener for a model
|
|
1018
|
+
* @class Listener
|
|
1019
|
+
*/
|
|
1020
|
+
var Listener = /** @class */ (function () {
|
|
1021
|
+
function Listener() {
|
|
1022
|
+
Object.defineProperties(this, {
|
|
1023
|
+
onAdded: {
|
|
1024
|
+
value: new Set,
|
|
1025
|
+
writable: false,
|
|
1026
|
+
configurable: false
|
|
1027
|
+
},
|
|
1028
|
+
onRemoved: {
|
|
1029
|
+
value: new Set,
|
|
1030
|
+
writable: false,
|
|
1031
|
+
configurable: false
|
|
1032
|
+
},
|
|
1033
|
+
frozen: {
|
|
1034
|
+
value: false,
|
|
1035
|
+
writable: true,
|
|
1036
|
+
configurable: false
|
|
1037
|
+
},
|
|
1038
|
+
queue: {
|
|
1039
|
+
value: [],
|
|
1040
|
+
writable: false,
|
|
1041
|
+
configurable: false
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Exclude the repeated operation in queue
|
|
1047
|
+
* @private
|
|
1048
|
+
*/
|
|
1049
|
+
Listener.prototype.excludeRepeat = function (index) {
|
|
1050
|
+
var _this = this;
|
|
1051
|
+
this.queue.forEach(function (item, i) {
|
|
1052
|
+
if (item.index === index) {
|
|
1053
|
+
_this.queue.splice(i, 1);
|
|
1054
|
+
return true;
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
return false;
|
|
1058
|
+
};
|
|
1059
|
+
/**
|
|
1060
|
+
* Emits added event to listeners
|
|
1061
|
+
* @param index {*} index of value
|
|
1062
|
+
* @param value {*} value of added item
|
|
1063
|
+
*/
|
|
1064
|
+
Listener.prototype.emitAdded = function (index, value) {
|
|
1065
|
+
if (this.frozen) {
|
|
1066
|
+
if (!this.excludeRepeat(index)) {
|
|
1067
|
+
this.queue.push({ sign: true, index: index, value: value });
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
this.onAdded.forEach(function (handler) {
|
|
1072
|
+
handler(index, value);
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
/**
|
|
1077
|
+
* Emits removed event to listeners
|
|
1078
|
+
* @param index {*} index of removed value
|
|
1079
|
+
* @param value {*} value of removed item
|
|
1080
|
+
*/
|
|
1081
|
+
Listener.prototype.emitRemoved = function (index, value) {
|
|
1082
|
+
if (this.frozen) {
|
|
1083
|
+
if (!this.excludeRepeat(index)) {
|
|
1084
|
+
this.queue.push({ sign: false, index: index, value: value });
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
this.onRemoved.forEach(function (handler) {
|
|
1089
|
+
handler(index, value);
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
/**
|
|
1094
|
+
* Adds a handler to added event
|
|
1095
|
+
* @param handler {function} function to run on event emitting
|
|
1096
|
+
*/
|
|
1097
|
+
Listener.prototype.onAdd = function (handler) {
|
|
1098
|
+
this.onAdded.add(handler);
|
|
1099
|
+
};
|
|
1100
|
+
/**
|
|
1101
|
+
* Adds a handler to removed event
|
|
1102
|
+
* @param handler {function} function to run on event emitting
|
|
1103
|
+
*/
|
|
1104
|
+
Listener.prototype.onRemove = function (handler) {
|
|
1105
|
+
this.onRemoved.add(handler);
|
|
1106
|
+
};
|
|
1107
|
+
/**
|
|
1108
|
+
* Removes an handler from added event
|
|
1109
|
+
* @param handler {function} handler to remove
|
|
1110
|
+
*/
|
|
1111
|
+
Listener.prototype.offAdd = function (handler) {
|
|
1112
|
+
this.onAdded.delete(handler);
|
|
1113
|
+
};
|
|
1114
|
+
/**
|
|
1115
|
+
* Removes an handler form removed event
|
|
1116
|
+
* @param handler {function} handler to remove
|
|
1117
|
+
*/
|
|
1118
|
+
Listener.prototype.offRemove = function (handler) {
|
|
1119
|
+
this.onRemoved.delete(handler);
|
|
1120
|
+
};
|
|
1121
|
+
/**
|
|
1122
|
+
* Run all queued operation and enable reactivity
|
|
1123
|
+
*/
|
|
1124
|
+
Listener.prototype.enableReactivity = function () {
|
|
1125
|
+
var _this = this;
|
|
1126
|
+
this.queue.forEach(function (item) {
|
|
1127
|
+
if (item.sign) {
|
|
1128
|
+
_this.onAdded.forEach(function (handler) {
|
|
1129
|
+
handler(item.index, item.value);
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
else {
|
|
1133
|
+
_this.onRemoved.forEach(function (handler) {
|
|
1134
|
+
handler(item.index, item.value);
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
this.queue.splice(0);
|
|
1139
|
+
this.frozen = false;
|
|
1140
|
+
};
|
|
1141
|
+
/**
|
|
1142
|
+
* Disable the reactivity and enable the queue
|
|
1143
|
+
*/
|
|
1144
|
+
Listener.prototype.disableReactivity = function () {
|
|
1145
|
+
this.frozen = true;
|
|
1146
|
+
};
|
|
1147
|
+
return Listener;
|
|
1148
|
+
}());
|
|
1149
|
+
exports.Listener = Listener;
|
|
1143
1150
|
|
|
1144
1151
|
|
|
1145
|
-
// ./lib-es5/
|
|
1152
|
+
// ./lib-es5/models/model.js
|
|
1146
1153
|
"use strict";
|
|
1147
1154
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1148
1155
|
|
|
1149
1156
|
|
|
1150
|
-
// ./lib-es5/
|
|
1157
|
+
// ./lib-es5/models/array-model.js
|
|
1151
1158
|
"use strict";
|
|
1152
1159
|
var __extends = (this && this.__extends) || (function () {
|
|
1153
1160
|
var extendStatics = function (d, b) {
|
|
@@ -1164,276 +1171,257 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1164
1171
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1165
1172
|
};
|
|
1166
1173
|
})();
|
|
1174
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
1175
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1176
|
+
if (ar || !(i in from)) {
|
|
1177
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1178
|
+
ar[i] = from[i];
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1182
|
+
};
|
|
1167
1183
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1168
|
-
exports.
|
|
1169
|
-
var
|
|
1170
|
-
var ivalue_1 = require("../core/ivalue");
|
|
1184
|
+
exports.ArrayModel = void 0;
|
|
1185
|
+
var listener_1 = require("./listener");
|
|
1171
1186
|
/**
|
|
1172
|
-
*
|
|
1173
|
-
* @
|
|
1174
|
-
* @
|
|
1187
|
+
* Model based on Array class
|
|
1188
|
+
* @extends Array
|
|
1189
|
+
* @implements IModel
|
|
1175
1190
|
*/
|
|
1176
|
-
var
|
|
1177
|
-
__extends(
|
|
1191
|
+
var ArrayModel = /** @class */ (function (_super) {
|
|
1192
|
+
__extends(ArrayModel, _super);
|
|
1178
1193
|
/**
|
|
1179
|
-
*
|
|
1180
|
-
* @param func {Function} the function to bound
|
|
1181
|
-
* @param values
|
|
1182
|
-
* @param link {Boolean} links immediately if true
|
|
1194
|
+
* @param data {Array} input data
|
|
1183
1195
|
*/
|
|
1184
|
-
function
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
* Expression will link different handler for each value of list
|
|
1192
|
-
*/
|
|
1193
|
-
_this.linkedFunc = [];
|
|
1194
|
-
var handler = function (i) {
|
|
1195
|
-
if (i != null) {
|
|
1196
|
-
_this.valuesCache[i] = _this.values[i].$;
|
|
1197
|
-
}
|
|
1198
|
-
_this.sync.$ = func.apply(_this, _this.valuesCache);
|
|
1199
|
-
};
|
|
1200
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1201
|
-
// @ts-ignore
|
|
1202
|
-
_this.valuesCache = values.map(function (item) { return item.$; });
|
|
1203
|
-
_this.sync = new reference_js_1.Reference(func.apply(_this, _this.valuesCache));
|
|
1204
|
-
var i = 0;
|
|
1205
|
-
values.forEach(function () {
|
|
1206
|
-
_this.linkedFunc.push(handler.bind(_this, Number(i++)));
|
|
1196
|
+
function ArrayModel(data) {
|
|
1197
|
+
if (data === void 0) { data = []; }
|
|
1198
|
+
var _this = this; _super.call(this);
|
|
1199
|
+
Object.defineProperty(_this, 'listener', {
|
|
1200
|
+
value: new listener_1.Listener,
|
|
1201
|
+
writable: false,
|
|
1202
|
+
configurable: false
|
|
1207
1203
|
});
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
if (link) {
|
|
1211
|
-
_this.$enable();
|
|
1212
|
-
}
|
|
1213
|
-
else {
|
|
1214
|
-
handler();
|
|
1204
|
+
for (var i = 0; i < data.length; i++) {
|
|
1205
|
+
_super.prototype.push.call(_this, data[i]);
|
|
1215
1206
|
}
|
|
1216
|
-
_this.$seal();
|
|
1217
1207
|
return _this;
|
|
1218
1208
|
}
|
|
1219
|
-
Object.defineProperty(
|
|
1209
|
+
Object.defineProperty(ArrayModel.prototype, "last", {
|
|
1210
|
+
/* Array members */
|
|
1211
|
+
/**
|
|
1212
|
+
* Gets the last item of array
|
|
1213
|
+
* @return {*} the last item of array
|
|
1214
|
+
*/
|
|
1220
1215
|
get: function () {
|
|
1221
|
-
return this.
|
|
1222
|
-
},
|
|
1223
|
-
set: function (value) {
|
|
1224
|
-
this.sync.$ = value;
|
|
1216
|
+
return this.length ? this[this.length - 1] : null;
|
|
1225
1217
|
},
|
|
1226
1218
|
enumerable: false,
|
|
1227
1219
|
configurable: true
|
|
1228
1220
|
});
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
if (!this.isEnabled) {
|
|
1239
|
-
for (var i = 0; i < this.values.length; i++) {
|
|
1240
|
-
this.values[i].$on(this.linkedFunc[i]);
|
|
1241
|
-
this.valuesCache[i] = this.values[i].$;
|
|
1242
|
-
}
|
|
1243
|
-
this.func();
|
|
1244
|
-
this.isEnabled = true;
|
|
1221
|
+
/**
|
|
1222
|
+
* Calls Array.fill and notify about changes
|
|
1223
|
+
* @param value {*} value to fill with
|
|
1224
|
+
* @param start {?number} begin index
|
|
1225
|
+
* @param end {?number} end index
|
|
1226
|
+
*/
|
|
1227
|
+
ArrayModel.prototype.fill = function (value, start, end) {
|
|
1228
|
+
if (!start) {
|
|
1229
|
+
start = 0;
|
|
1245
1230
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
this.isEnabled = false;
|
|
1231
|
+
if (!end) {
|
|
1232
|
+
end = this.length;
|
|
1233
|
+
}
|
|
1234
|
+
for (var i = start; i < end; i++) {
|
|
1235
|
+
this.listener.emitRemoved(this[i], this[i]);
|
|
1236
|
+
this[i] = value;
|
|
1237
|
+
this.listener.emitAdded(value, value);
|
|
1254
1238
|
}
|
|
1255
1239
|
return this;
|
|
1256
1240
|
};
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
_super.prototype
|
|
1241
|
+
/**
|
|
1242
|
+
* Calls Array.pop and notify about changes
|
|
1243
|
+
* @return {*} removed value
|
|
1244
|
+
*/
|
|
1245
|
+
ArrayModel.prototype.pop = function () {
|
|
1246
|
+
var v = _super.prototype.pop.call(this);
|
|
1247
|
+
if (v !== undefined) {
|
|
1248
|
+
this.listener.emitRemoved(v, v);
|
|
1249
|
+
}
|
|
1250
|
+
return v;
|
|
1263
1251
|
};
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
var
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1252
|
+
/**
|
|
1253
|
+
* Calls Array.push and notify about changes
|
|
1254
|
+
* @param items {...*} values to push
|
|
1255
|
+
* @return {number} new length of array
|
|
1256
|
+
*/
|
|
1257
|
+
ArrayModel.prototype.push = function () {
|
|
1258
|
+
var _this = this;
|
|
1259
|
+
var items = [];
|
|
1260
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1261
|
+
items[_i] = arguments[_i];
|
|
1262
|
+
}
|
|
1263
|
+
items.forEach(function (item) {
|
|
1264
|
+
_this.listener.emitAdded(item, item);
|
|
1265
|
+
_super.prototype.push.call(_this, item);
|
|
1266
|
+
});
|
|
1267
|
+
return this.length;
|
|
1277
1268
|
};
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1269
|
+
/**
|
|
1270
|
+
* Calls Array.shift and notify about changed
|
|
1271
|
+
* @return {*} the shifted value
|
|
1272
|
+
*/
|
|
1273
|
+
ArrayModel.prototype.shift = function () {
|
|
1274
|
+
var v = _super.prototype.shift.call(this);
|
|
1275
|
+
if (v !== undefined) {
|
|
1276
|
+
this.listener.emitRemoved(v, v);
|
|
1277
|
+
}
|
|
1278
|
+
return v;
|
|
1284
1279
|
};
|
|
1285
|
-
})();
|
|
1286
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1287
|
-
exports.Reference = void 0;
|
|
1288
|
-
var ivalue_1 = require("../core/ivalue");
|
|
1289
|
-
/**
|
|
1290
|
-
* Declares a notifiable value
|
|
1291
|
-
* @class Reference
|
|
1292
|
-
* @extends IValue
|
|
1293
|
-
*/
|
|
1294
|
-
var Reference = /** @class */ (function (_super) {
|
|
1295
|
-
__extends(Reference, _super);
|
|
1296
1280
|
/**
|
|
1297
|
-
*
|
|
1281
|
+
* Calls Array.splice and notify about changed
|
|
1282
|
+
* @param start {number} start index
|
|
1283
|
+
* @param deleteCount {?number} delete count
|
|
1284
|
+
* @param items {...*}
|
|
1285
|
+
* @return {ArrayModel} a pointer to this
|
|
1298
1286
|
*/
|
|
1299
|
-
function
|
|
1300
|
-
var
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
if (this.$value !== value) {
|
|
1312
|
-
this.$value = value;
|
|
1313
|
-
if (this.isEnabled) {
|
|
1314
|
-
this.$onchange.forEach(function (handler) {
|
|
1315
|
-
handler(value);
|
|
1316
|
-
});
|
|
1317
|
-
}
|
|
1287
|
+
ArrayModel.prototype.splice = function (start, deleteCount) {
|
|
1288
|
+
var items = [];
|
|
1289
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1290
|
+
items[_i - 2] = arguments[_i];
|
|
1291
|
+
}
|
|
1292
|
+
start = Math.min(start, this.length);
|
|
1293
|
+
deleteCount = deleteCount || this.length - start;
|
|
1294
|
+
var before = this[start + deleteCount];
|
|
1295
|
+
for (var i = 0; i < deleteCount; i++) {
|
|
1296
|
+
var index = start + deleteCount - i - 1;
|
|
1297
|
+
if (this[index] !== undefined) {
|
|
1298
|
+
this.listener.emitRemoved(this[index], this[index]);
|
|
1318
1299
|
}
|
|
1319
|
-
},
|
|
1320
|
-
enumerable: false,
|
|
1321
|
-
configurable: true
|
|
1322
|
-
});
|
|
1323
|
-
Reference.prototype.$enable = function () {
|
|
1324
|
-
var _this = this;
|
|
1325
|
-
if (!this.isEnabled) {
|
|
1326
|
-
this.$onchange.forEach(function (handler) {
|
|
1327
|
-
handler(_this.$value);
|
|
1328
|
-
});
|
|
1329
|
-
this.isEnabled = true;
|
|
1330
1300
|
}
|
|
1301
|
+
for (var i = 0; i < items.length; i++) {
|
|
1302
|
+
this.listener.emitAdded(before, items[i]);
|
|
1303
|
+
}
|
|
1304
|
+
return new ArrayModel(_super.prototype.splice.apply(this, __spreadArray([start, deleteCount], items, false)));
|
|
1331
1305
|
};
|
|
1332
|
-
|
|
1333
|
-
|
|
1306
|
+
/**
|
|
1307
|
+
* Calls Array.unshift and notify about changed
|
|
1308
|
+
* @param items {...*} values to insert
|
|
1309
|
+
* @return {number} the length after prepend
|
|
1310
|
+
*/
|
|
1311
|
+
ArrayModel.prototype.unshift = function () {
|
|
1312
|
+
var items = [];
|
|
1313
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1314
|
+
items[_i] = arguments[_i];
|
|
1315
|
+
}
|
|
1316
|
+
for (var i = 0; i < items.length; i++) {
|
|
1317
|
+
this.listener.emitAdded(this[i], items[i]);
|
|
1318
|
+
}
|
|
1319
|
+
return _super.prototype.unshift.apply(this, items);
|
|
1334
1320
|
};
|
|
1335
|
-
|
|
1336
|
-
|
|
1321
|
+
/**
|
|
1322
|
+
* Inserts a value to the end of array
|
|
1323
|
+
* @param v {*} value to insert
|
|
1324
|
+
*/
|
|
1325
|
+
ArrayModel.prototype.append = function (v) {
|
|
1326
|
+
this.listener.emitAdded(null, v);
|
|
1327
|
+
_super.prototype.push.call(this, v);
|
|
1328
|
+
return this;
|
|
1337
1329
|
};
|
|
1338
|
-
|
|
1339
|
-
|
|
1330
|
+
/**
|
|
1331
|
+
* Clears array
|
|
1332
|
+
* @return {this} a pointer to this
|
|
1333
|
+
*/
|
|
1334
|
+
ArrayModel.prototype.clear = function () {
|
|
1335
|
+
var _this = this;
|
|
1336
|
+
this.forEach(function (v) {
|
|
1337
|
+
_this.listener.emitRemoved(v, v);
|
|
1338
|
+
});
|
|
1339
|
+
_super.prototype.splice.call(this, 0);
|
|
1340
|
+
return this;
|
|
1340
1341
|
};
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1342
|
+
/**
|
|
1343
|
+
* Inserts a value to position `index`
|
|
1344
|
+
* @param index {number} index to insert value
|
|
1345
|
+
* @param v {*} value to insert
|
|
1346
|
+
* @return {this} a pointer to this
|
|
1347
|
+
*/
|
|
1348
|
+
ArrayModel.prototype.insert = function (index, v) {
|
|
1349
|
+
this.listener.emitAdded(this[index], v);
|
|
1350
|
+
_super.prototype.splice.call(this, index, 0, v);
|
|
1351
|
+
return this;
|
|
1344
1352
|
};
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
extendStatics = Object.setPrototypeOf ||
|
|
1355
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1356
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1357
|
-
return extendStatics(d, b);
|
|
1353
|
+
/**
|
|
1354
|
+
* Inserts a value to the beginning of array
|
|
1355
|
+
* @param v {*} value to insert
|
|
1356
|
+
* @return {this} a pointer to this
|
|
1357
|
+
*/
|
|
1358
|
+
ArrayModel.prototype.prepend = function (v) {
|
|
1359
|
+
this.listener.emitAdded(this[0], v);
|
|
1360
|
+
_super.prototype.unshift.call(this, v);
|
|
1361
|
+
return this;
|
|
1358
1362
|
};
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1363
|
+
/**
|
|
1364
|
+
* Removes a value from an index
|
|
1365
|
+
* @param index {number} index of value to remove
|
|
1366
|
+
* @return {this} a pointer to this
|
|
1367
|
+
*/
|
|
1368
|
+
ArrayModel.prototype.removeAt = function (index) {
|
|
1369
|
+
if (index > 0 && index < this.length) {
|
|
1370
|
+
this.listener.emitRemoved(this[index], this[index]);
|
|
1371
|
+
_super.prototype.splice.call(this, index, 1);
|
|
1372
|
+
}
|
|
1373
|
+
return this;
|
|
1365
1374
|
};
|
|
1366
|
-
})();
|
|
1367
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1368
|
-
exports.Mirror = void 0;
|
|
1369
|
-
var reference_1 = require("./reference");
|
|
1370
|
-
/**
|
|
1371
|
-
* Declares a notifiable bind to a value
|
|
1372
|
-
* @class Mirror
|
|
1373
|
-
* @extends IValue
|
|
1374
|
-
* @version 2
|
|
1375
|
-
*/
|
|
1376
|
-
var Mirror = /** @class */ (function (_super) {
|
|
1377
|
-
__extends(Mirror, _super);
|
|
1378
1375
|
/**
|
|
1379
|
-
*
|
|
1380
|
-
* @
|
|
1381
|
-
* @param forwardOnly {boolean} ensure forward only synchronization
|
|
1376
|
+
* Removes the first value of array
|
|
1377
|
+
* @return {this} a pointer to this
|
|
1382
1378
|
*/
|
|
1383
|
-
function
|
|
1384
|
-
if (
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
_this.$ = v;
|
|
1388
|
-
};
|
|
1389
|
-
_this.$pointedValue = value;
|
|
1390
|
-
_this.$forwardOnly = forwardOnly;
|
|
1391
|
-
value.$on(_this.$handler);
|
|
1392
|
-
_this.$seal();
|
|
1393
|
-
return _this;
|
|
1394
|
-
}
|
|
1395
|
-
Object.defineProperty(Mirror.prototype, "$", {
|
|
1396
|
-
get: function () {
|
|
1397
|
-
// this is a ts bug
|
|
1398
|
-
// eslint-disable-next-line
|
|
1399
|
-
// @ts-ignore
|
|
1400
|
-
return _super.prototype.$;
|
|
1401
|
-
},
|
|
1402
|
-
set: function (v) {
|
|
1403
|
-
if (!this.$forwardOnly) {
|
|
1404
|
-
this.$pointedValue.$ = v;
|
|
1405
|
-
}
|
|
1406
|
-
// this is a ts bug
|
|
1407
|
-
// eslint-disable-next-line
|
|
1408
|
-
// @ts-ignore
|
|
1409
|
-
_super.prototype.$ = v;
|
|
1410
|
-
},
|
|
1411
|
-
enumerable: false,
|
|
1412
|
-
configurable: true
|
|
1413
|
-
});
|
|
1414
|
-
Mirror.prototype.$enable = function () {
|
|
1415
|
-
if (!this.isEnabled) {
|
|
1416
|
-
this.isEnabled = true;
|
|
1417
|
-
this.$pointedValue.$on(this.$handler);
|
|
1418
|
-
this.$ = this.$pointedValue.$;
|
|
1379
|
+
ArrayModel.prototype.removeFirst = function () {
|
|
1380
|
+
if (this.length) {
|
|
1381
|
+
this.listener.emitRemoved(this[0], this[0]);
|
|
1382
|
+
_super.prototype.shift.call(this);
|
|
1419
1383
|
}
|
|
1384
|
+
return this;
|
|
1420
1385
|
};
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1386
|
+
/**
|
|
1387
|
+
* Removes the ast value of array
|
|
1388
|
+
* @return {this} a pointer to this
|
|
1389
|
+
*/
|
|
1390
|
+
ArrayModel.prototype.removeLast = function () {
|
|
1391
|
+
var last = this.last;
|
|
1392
|
+
if (last != null) {
|
|
1393
|
+
this.listener.emitRemoved(this[this.length - 1], last);
|
|
1394
|
+
_super.prototype.pop.call(this);
|
|
1425
1395
|
}
|
|
1396
|
+
return this;
|
|
1426
1397
|
};
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1398
|
+
/**
|
|
1399
|
+
* Remove the first occurrence of value
|
|
1400
|
+
* @param v {*} value to remove
|
|
1401
|
+
* @return {this}
|
|
1402
|
+
*/
|
|
1403
|
+
ArrayModel.prototype.removeOne = function (v) {
|
|
1404
|
+
this.removeAt(this.indexOf(v));
|
|
1405
|
+
return this;
|
|
1430
1406
|
};
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1407
|
+
ArrayModel.prototype.replace = function (at, with_) {
|
|
1408
|
+
this.listener.emitAdded(this[at], with_);
|
|
1409
|
+
this.listener.emitRemoved(this[at], this[at]);
|
|
1410
|
+
this[at] = with_;
|
|
1411
|
+
return this;
|
|
1412
|
+
};
|
|
1413
|
+
ArrayModel.prototype.enableReactivity = function () {
|
|
1414
|
+
this.listener.enableReactivity();
|
|
1415
|
+
};
|
|
1416
|
+
ArrayModel.prototype.disableReactivity = function () {
|
|
1417
|
+
this.listener.disableReactivity();
|
|
1418
|
+
};
|
|
1419
|
+
return ArrayModel;
|
|
1420
|
+
}(Array));
|
|
1421
|
+
exports.ArrayModel = ArrayModel;
|
|
1434
1422
|
|
|
1435
1423
|
|
|
1436
|
-
// ./lib-es5/
|
|
1424
|
+
// ./lib-es5/models/map-model.js
|
|
1437
1425
|
"use strict";
|
|
1438
1426
|
var __extends = (this && this.__extends) || (function () {
|
|
1439
1427
|
var extendStatics = function (d, b) {
|
|
@@ -1451,44 +1439,83 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1451
1439
|
};
|
|
1452
1440
|
})();
|
|
1453
1441
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1454
|
-
exports.
|
|
1455
|
-
var
|
|
1442
|
+
exports.MapModel = void 0;
|
|
1443
|
+
var listener_1 = require("./listener");
|
|
1456
1444
|
/**
|
|
1457
|
-
*
|
|
1458
|
-
* @class
|
|
1459
|
-
* @extends
|
|
1445
|
+
* A Map based memory
|
|
1446
|
+
* @class MapModel
|
|
1447
|
+
* @extends Map
|
|
1448
|
+
* @implements IModel
|
|
1460
1449
|
*/
|
|
1461
|
-
var
|
|
1462
|
-
__extends(
|
|
1450
|
+
var MapModel = /** @class */ (function (_super) {
|
|
1451
|
+
__extends(MapModel, _super);
|
|
1463
1452
|
/**
|
|
1464
|
-
*
|
|
1465
|
-
* @param
|
|
1453
|
+
* Constructs a map model
|
|
1454
|
+
* @param map {[*, *][]} input data
|
|
1466
1455
|
*/
|
|
1467
|
-
function
|
|
1468
|
-
if (
|
|
1469
|
-
|
|
1456
|
+
function MapModel(map) {
|
|
1457
|
+
if (map === void 0) { map = []; }
|
|
1458
|
+
var _this = this; _super.call(this);
|
|
1459
|
+
Object.defineProperty(_this, 'listener', {
|
|
1460
|
+
value: new listener_1.Listener,
|
|
1461
|
+
writable: false,
|
|
1462
|
+
configurable: false
|
|
1463
|
+
});
|
|
1464
|
+
map.forEach(function (_a) {
|
|
1465
|
+
var key = _a[0], value = _a[1];
|
|
1466
|
+
_super.prototype.set.call(_this, key, value);
|
|
1467
|
+
});
|
|
1468
|
+
return _this;
|
|
1470
1469
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1470
|
+
/**
|
|
1471
|
+
* Calls Map.clear and notify abut changes
|
|
1472
|
+
*/
|
|
1473
|
+
MapModel.prototype.clear = function () {
|
|
1474
|
+
var _this = this;
|
|
1475
|
+
this.forEach(function (value, key) {
|
|
1476
|
+
_this.listener.emitRemoved(key, value);
|
|
1477
|
+
});
|
|
1478
|
+
_super.prototype.clear.call(this);
|
|
1479
|
+
};
|
|
1480
|
+
/**
|
|
1481
|
+
* Calls Map.delete and notify abut changes
|
|
1482
|
+
* @param key {*} key
|
|
1483
|
+
* @return {boolean} true if removed something, otherwise false
|
|
1484
|
+
*/
|
|
1485
|
+
MapModel.prototype.delete = function (key) {
|
|
1486
|
+
var tmp = _super.prototype.get.call(this, key);
|
|
1487
|
+
if (tmp) {
|
|
1488
|
+
this.listener.emitRemoved(key, tmp);
|
|
1489
|
+
}
|
|
1490
|
+
return _super.prototype.delete.call(this, key);
|
|
1491
|
+
};
|
|
1492
|
+
/**
|
|
1493
|
+
* Calls Map.set and notify abut changes
|
|
1494
|
+
* @param key {*} key
|
|
1495
|
+
* @param value {*} value
|
|
1496
|
+
* @return {MapModel} a pointer to this
|
|
1497
|
+
*/
|
|
1498
|
+
MapModel.prototype.set = function (key, value) {
|
|
1499
|
+
var tmp = _super.prototype.get.call(this, key);
|
|
1500
|
+
if (tmp) {
|
|
1501
|
+
this.listener.emitRemoved(key, tmp);
|
|
1502
|
+
}
|
|
1503
|
+
_super.prototype.set.call(this, key, value);
|
|
1504
|
+
this.listener.emitAdded(key, value);
|
|
1505
|
+
return this;
|
|
1506
|
+
};
|
|
1507
|
+
MapModel.prototype.enableReactivity = function () {
|
|
1508
|
+
this.listener.enableReactivity();
|
|
1509
|
+
};
|
|
1510
|
+
MapModel.prototype.disableReactivity = function () {
|
|
1511
|
+
this.listener.disableReactivity();
|
|
1512
|
+
};
|
|
1513
|
+
return MapModel;
|
|
1514
|
+
}(Map));
|
|
1515
|
+
exports.MapModel = MapModel;
|
|
1489
1516
|
|
|
1490
1517
|
|
|
1491
|
-
// ./lib-es5/
|
|
1518
|
+
// ./lib-es5/models/object-model.js
|
|
1492
1519
|
"use strict";
|
|
1493
1520
|
var __extends = (this && this.__extends) || (function () {
|
|
1494
1521
|
var extendStatics = function (d, b) {
|
|
@@ -1506,15 +1533,227 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1506
1533
|
};
|
|
1507
1534
|
})();
|
|
1508
1535
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1509
|
-
exports.
|
|
1510
|
-
var
|
|
1536
|
+
exports.ObjectModel = void 0;
|
|
1537
|
+
var listener_1 = require("./listener");
|
|
1511
1538
|
/**
|
|
1512
|
-
*
|
|
1513
|
-
* @
|
|
1514
|
-
* @extends Destroyable
|
|
1539
|
+
* Object based model
|
|
1540
|
+
* @extends Object
|
|
1515
1541
|
*/
|
|
1516
|
-
var
|
|
1517
|
-
__extends(
|
|
1542
|
+
var ObjectModel = /** @class */ (function (_super) {
|
|
1543
|
+
__extends(ObjectModel, _super);
|
|
1544
|
+
/**
|
|
1545
|
+
* Constructs a object model
|
|
1546
|
+
* @param obj {Object} input data
|
|
1547
|
+
*/
|
|
1548
|
+
function ObjectModel(obj) {
|
|
1549
|
+
if (obj === void 0) { obj = {}; }
|
|
1550
|
+
var _this = this; _super.call(this);
|
|
1551
|
+
_this.container = Object.create(null);
|
|
1552
|
+
Object.defineProperty(_this, 'listener', {
|
|
1553
|
+
value: new listener_1.Listener,
|
|
1554
|
+
writable: false,
|
|
1555
|
+
configurable: false
|
|
1556
|
+
});
|
|
1557
|
+
for (var i in obj) {
|
|
1558
|
+
Object.defineProperty(_this.container, i, {
|
|
1559
|
+
value: obj[i],
|
|
1560
|
+
configurable: true,
|
|
1561
|
+
writable: true,
|
|
1562
|
+
enumerable: true
|
|
1563
|
+
});
|
|
1564
|
+
_this.listener.emitAdded(i, obj[i]);
|
|
1565
|
+
}
|
|
1566
|
+
return _this;
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Gets a value of a field
|
|
1570
|
+
* @param key {string}
|
|
1571
|
+
* @return {*}
|
|
1572
|
+
*/
|
|
1573
|
+
ObjectModel.prototype.get = function (key) {
|
|
1574
|
+
return this.container[key];
|
|
1575
|
+
};
|
|
1576
|
+
/**
|
|
1577
|
+
* Sets an object property value
|
|
1578
|
+
* @param key {string} property name
|
|
1579
|
+
* @param v {*} property value
|
|
1580
|
+
* @return {ObjectModel} a pointer to this
|
|
1581
|
+
*/
|
|
1582
|
+
ObjectModel.prototype.set = function (key, v) {
|
|
1583
|
+
if (Reflect.has(this.container, key)) {
|
|
1584
|
+
this.listener.emitRemoved(key, this.container[key]);
|
|
1585
|
+
this.container[key] = v;
|
|
1586
|
+
}
|
|
1587
|
+
else {
|
|
1588
|
+
Object.defineProperty(this.container, key, {
|
|
1589
|
+
value: v,
|
|
1590
|
+
configurable: true,
|
|
1591
|
+
writable: true,
|
|
1592
|
+
enumerable: true
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
this.listener.emitAdded(key, this.container[key]);
|
|
1596
|
+
return this;
|
|
1597
|
+
};
|
|
1598
|
+
Object.defineProperty(ObjectModel.prototype, "values", {
|
|
1599
|
+
get: function () {
|
|
1600
|
+
return this.container;
|
|
1601
|
+
},
|
|
1602
|
+
enumerable: false,
|
|
1603
|
+
configurable: true
|
|
1604
|
+
});
|
|
1605
|
+
/**
|
|
1606
|
+
* Deletes an object property
|
|
1607
|
+
* @param key {string} property name
|
|
1608
|
+
*/
|
|
1609
|
+
ObjectModel.prototype.delete = function (key) {
|
|
1610
|
+
if (this.container[key]) {
|
|
1611
|
+
this.listener.emitRemoved(key, this.container[key]);
|
|
1612
|
+
delete this.container[key];
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
ObjectModel.prototype.enableReactivity = function () {
|
|
1616
|
+
this.listener.enableReactivity();
|
|
1617
|
+
};
|
|
1618
|
+
ObjectModel.prototype.disableReactivity = function () {
|
|
1619
|
+
this.listener.disableReactivity();
|
|
1620
|
+
};
|
|
1621
|
+
return ObjectModel;
|
|
1622
|
+
}(Object));
|
|
1623
|
+
exports.ObjectModel = ObjectModel;
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
// ./lib-es5/models/set-model.js
|
|
1627
|
+
"use strict";
|
|
1628
|
+
var __extends = (this && this.__extends) || (function () {
|
|
1629
|
+
var extendStatics = function (d, b) {
|
|
1630
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1631
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1632
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1633
|
+
return extendStatics(d, b);
|
|
1634
|
+
};
|
|
1635
|
+
return function (d, b) {
|
|
1636
|
+
if (typeof b !== "function" && b !== null)
|
|
1637
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1638
|
+
extendStatics(d, b);
|
|
1639
|
+
function __() { this.constructor = d; }
|
|
1640
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1641
|
+
};
|
|
1642
|
+
})();
|
|
1643
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1644
|
+
exports.SetModel = void 0;
|
|
1645
|
+
var listener_1 = require("./listener");
|
|
1646
|
+
/**
|
|
1647
|
+
* A Set based model
|
|
1648
|
+
* @class SetModel
|
|
1649
|
+
* @extends Set
|
|
1650
|
+
* @implements IModel
|
|
1651
|
+
*/
|
|
1652
|
+
var SetModel = /** @class */ (function (_super) {
|
|
1653
|
+
__extends(SetModel, _super);
|
|
1654
|
+
/**
|
|
1655
|
+
* Constructs a set model based on a set
|
|
1656
|
+
* @param set {Set} input data
|
|
1657
|
+
*/
|
|
1658
|
+
function SetModel(set) {
|
|
1659
|
+
if (set === void 0) { set = []; }
|
|
1660
|
+
var _this = this; _super.call(this);
|
|
1661
|
+
Object.defineProperty(_this, 'listener', {
|
|
1662
|
+
value: new listener_1.Listener,
|
|
1663
|
+
writable: false,
|
|
1664
|
+
configurable: false
|
|
1665
|
+
});
|
|
1666
|
+
set.forEach(function (item) {
|
|
1667
|
+
_super.prototype.add.call(_this, item);
|
|
1668
|
+
});
|
|
1669
|
+
return _this;
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Calls Set.add and notify abut changes
|
|
1673
|
+
* @param value {*} value
|
|
1674
|
+
* @return {this} a pointer to this
|
|
1675
|
+
*/
|
|
1676
|
+
SetModel.prototype.add = function (value) {
|
|
1677
|
+
if (!_super.prototype.has.call(this, value)) {
|
|
1678
|
+
this.listener.emitAdded(value, value);
|
|
1679
|
+
_super.prototype.add.call(this, value);
|
|
1680
|
+
}
|
|
1681
|
+
return this;
|
|
1682
|
+
};
|
|
1683
|
+
/**
|
|
1684
|
+
* Calls Set.clear and notify abut changes
|
|
1685
|
+
*/
|
|
1686
|
+
SetModel.prototype.clear = function () {
|
|
1687
|
+
var _this = this;
|
|
1688
|
+
this.forEach(function (item) {
|
|
1689
|
+
_this.listener.emitRemoved(item, item);
|
|
1690
|
+
});
|
|
1691
|
+
_super.prototype.clear.call(this);
|
|
1692
|
+
};
|
|
1693
|
+
/**
|
|
1694
|
+
* Calls Set.delete and notify abut changes
|
|
1695
|
+
* @param value {*}
|
|
1696
|
+
* @return {boolean} true if a value was deleted, otherwise false
|
|
1697
|
+
*/
|
|
1698
|
+
SetModel.prototype.delete = function (value) {
|
|
1699
|
+
if (_super.prototype.has.call(this, value)) {
|
|
1700
|
+
this.listener.emitRemoved(value, value);
|
|
1701
|
+
}
|
|
1702
|
+
return _super.prototype.delete.call(this, value);
|
|
1703
|
+
};
|
|
1704
|
+
SetModel.prototype.enableReactivity = function () {
|
|
1705
|
+
this.listener.enableReactivity();
|
|
1706
|
+
};
|
|
1707
|
+
SetModel.prototype.disableReactivity = function () {
|
|
1708
|
+
this.listener.disableReactivity();
|
|
1709
|
+
};
|
|
1710
|
+
return SetModel;
|
|
1711
|
+
}(Set));
|
|
1712
|
+
exports.SetModel = SetModel;
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
// ./lib-es5/spec/html.js
|
|
1716
|
+
"use strict";
|
|
1717
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1718
|
+
|
|
1719
|
+
|
|
1720
|
+
// ./lib-es5/spec/svg.js
|
|
1721
|
+
"use strict";
|
|
1722
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
// ./lib-es5/spec/react.js
|
|
1726
|
+
"use strict";
|
|
1727
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
// ./lib-es5/binding/binding.js
|
|
1731
|
+
"use strict";
|
|
1732
|
+
var __extends = (this && this.__extends) || (function () {
|
|
1733
|
+
var extendStatics = function (d, b) {
|
|
1734
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1735
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1736
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1737
|
+
return extendStatics(d, b);
|
|
1738
|
+
};
|
|
1739
|
+
return function (d, b) {
|
|
1740
|
+
if (typeof b !== "function" && b !== null)
|
|
1741
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1742
|
+
extendStatics(d, b);
|
|
1743
|
+
function __() { this.constructor = d; }
|
|
1744
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1745
|
+
};
|
|
1746
|
+
})();
|
|
1747
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1748
|
+
exports.Binding = void 0;
|
|
1749
|
+
var destroyable_1 = require("../core/destroyable");
|
|
1750
|
+
/**
|
|
1751
|
+
* Describe a common binding logic
|
|
1752
|
+
* @class Binding
|
|
1753
|
+
* @extends Destroyable
|
|
1754
|
+
*/
|
|
1755
|
+
var Binding = /** @class */ (function (_super) {
|
|
1756
|
+
__extends(Binding, _super);
|
|
1518
1757
|
/**
|
|
1519
1758
|
* Constructs a common binding logic
|
|
1520
1759
|
* @param value {IValue} the value to bind
|
|
@@ -1542,7 +1781,7 @@ var Binding = /** @class */ (function (_super) {
|
|
|
1542
1781
|
exports.Binding = Binding;
|
|
1543
1782
|
|
|
1544
1783
|
|
|
1545
|
-
// ./lib-es5/
|
|
1784
|
+
// ./lib-es5/binding/attribute.js
|
|
1546
1785
|
"use strict";
|
|
1547
1786
|
var __extends = (this && this.__extends) || (function () {
|
|
1548
1787
|
var extendStatics = function (d, b) {
|
|
@@ -1559,281 +1798,163 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1559
1798
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1560
1799
|
};
|
|
1561
1800
|
})();
|
|
1562
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
1563
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1564
|
-
if (ar || !(i in from)) {
|
|
1565
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1566
|
-
ar[i] = from[i];
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1570
|
-
};
|
|
1571
1801
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1572
|
-
exports.
|
|
1573
|
-
var
|
|
1574
|
-
var errors_1 = require("./errors");
|
|
1575
|
-
var expression_1 = require("../value/expression");
|
|
1576
|
-
var reference_1 = require("../value/reference");
|
|
1577
|
-
var pointer_1 = require("../value/pointer");
|
|
1578
|
-
var mirror_1 = require("../value/mirror");
|
|
1579
|
-
exports.current = null;
|
|
1580
|
-
var currentStack = [];
|
|
1581
|
-
function stack(node) {
|
|
1582
|
-
currentStack.push(exports.current);
|
|
1583
|
-
exports.current = node;
|
|
1584
|
-
}
|
|
1585
|
-
function unstack() {
|
|
1586
|
-
exports.current = currentStack.pop();
|
|
1587
|
-
}
|
|
1802
|
+
exports.AttributeBinding = void 0;
|
|
1803
|
+
var binding_1 = require("./binding");
|
|
1588
1804
|
/**
|
|
1589
|
-
*
|
|
1590
|
-
* @class
|
|
1591
|
-
* @extends
|
|
1805
|
+
* Represents an Attribute binding description
|
|
1806
|
+
* @class AttributeBinding
|
|
1807
|
+
* @extends Binding
|
|
1592
1808
|
*/
|
|
1593
|
-
var
|
|
1594
|
-
__extends(
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
/**
|
|
1617
|
-
* The frozen state of object
|
|
1618
|
-
* @type {boolean}
|
|
1619
|
-
*/
|
|
1620
|
-
_this.frozen = false;
|
|
1809
|
+
var AttributeBinding = /** @class */ (function (_super) {
|
|
1810
|
+
__extends(AttributeBinding, _super);
|
|
1811
|
+
/**
|
|
1812
|
+
* Constructs an attribute binding description
|
|
1813
|
+
* @param node {INode} the vasille node
|
|
1814
|
+
* @param name {String} the name of attribute
|
|
1815
|
+
* @param value {IValue} value to bind
|
|
1816
|
+
*/
|
|
1817
|
+
function AttributeBinding(node, name, value) {
|
|
1818
|
+
var _this = _super.call(this, value) || this;
|
|
1819
|
+
_this.init(function (value) {
|
|
1820
|
+
if (value) {
|
|
1821
|
+
if (typeof value === 'boolean') {
|
|
1822
|
+
node.node.setAttribute(name, "");
|
|
1823
|
+
}
|
|
1824
|
+
else {
|
|
1825
|
+
node.node.setAttribute(name, "".concat(value));
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
else {
|
|
1829
|
+
node.node.removeAttribute(name);
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1621
1832
|
_this.$seal();
|
|
1622
1833
|
return _this;
|
|
1623
1834
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1835
|
+
return AttributeBinding;
|
|
1836
|
+
}(binding_1.Binding));
|
|
1837
|
+
exports.AttributeBinding = AttributeBinding;
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
// ./lib-es5/binding/class.js
|
|
1841
|
+
"use strict";
|
|
1842
|
+
var __extends = (this && this.__extends) || (function () {
|
|
1843
|
+
var extendStatics = function (d, b) {
|
|
1844
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1845
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1846
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1847
|
+
return extendStatics(d, b);
|
|
1634
1848
|
};
|
|
1635
|
-
return
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1849
|
+
return function (d, b) {
|
|
1850
|
+
if (typeof b !== "function" && b !== null)
|
|
1851
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1852
|
+
extendStatics(d, b);
|
|
1853
|
+
function __() { this.constructor = d; }
|
|
1854
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1855
|
+
};
|
|
1856
|
+
})();
|
|
1857
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1858
|
+
exports.DynamicalClassBinding = exports.StaticClassBinding = void 0;
|
|
1859
|
+
var binding_1 = require("./binding");
|
|
1860
|
+
function addClass(node, cl) {
|
|
1861
|
+
node.node.classList.add(cl);
|
|
1862
|
+
}
|
|
1863
|
+
function removeClass(node, cl) {
|
|
1864
|
+
node.node.classList.remove(cl);
|
|
1865
|
+
}
|
|
1866
|
+
var StaticClassBinding = /** @class */ (function (_super) {
|
|
1867
|
+
__extends(StaticClassBinding, _super);
|
|
1868
|
+
function StaticClassBinding(node, name, value) {
|
|
1869
|
+
var _this = _super.call(this, value) || this;
|
|
1870
|
+
_this.current = false;
|
|
1871
|
+
_this.init(function (value) {
|
|
1872
|
+
if (value !== _this.current) {
|
|
1873
|
+
if (value) {
|
|
1874
|
+
addClass(node, name);
|
|
1875
|
+
}
|
|
1876
|
+
else {
|
|
1877
|
+
removeClass(node, name);
|
|
1878
|
+
}
|
|
1879
|
+
_this.current = value;
|
|
1880
|
+
}
|
|
1881
|
+
});
|
|
1649
1882
|
_this.$seal();
|
|
1650
1883
|
return _this;
|
|
1651
1884
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
this.$.watch.add(mirror);
|
|
1688
|
-
return mirror;
|
|
1689
|
-
};
|
|
1690
|
-
/**
|
|
1691
|
-
* Creates a pointer
|
|
1692
|
-
* @param value {*} default value to point
|
|
1693
|
-
* @param forwardOnly {boolean} forward only sync
|
|
1694
|
-
*/
|
|
1695
|
-
Reactive.prototype.point = function (value, forwardOnly) {
|
|
1696
|
-
if (forwardOnly === void 0) { forwardOnly = false; }
|
|
1697
|
-
var $ = this.$;
|
|
1698
|
-
var pointer = new pointer_1.Pointer(value, forwardOnly);
|
|
1699
|
-
$.watch.add(pointer);
|
|
1700
|
-
return pointer;
|
|
1701
|
-
};
|
|
1702
|
-
/**
|
|
1703
|
-
* Register a model
|
|
1704
|
-
* @param model
|
|
1705
|
-
*/
|
|
1706
|
-
Reactive.prototype.register = function (model) {
|
|
1707
|
-
this.$.models.add(model);
|
|
1708
|
-
return model;
|
|
1709
|
-
};
|
|
1710
|
-
/**
|
|
1711
|
-
* Creates a watcher
|
|
1712
|
-
* @param func {function} function to run on any argument change
|
|
1713
|
-
* @param values
|
|
1714
|
-
*/
|
|
1715
|
-
Reactive.prototype.watch = function (func) {
|
|
1716
|
-
var values = [];
|
|
1717
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1718
|
-
values[_i - 1] = arguments[_i];
|
|
1719
|
-
}
|
|
1720
|
-
var $ = this.$;
|
|
1721
|
-
$.watch.add(new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))());
|
|
1722
|
-
};
|
|
1723
|
-
/**
|
|
1724
|
-
* Creates a computed value
|
|
1725
|
-
* @param func {function} function to run on any argument change
|
|
1726
|
-
* @param values
|
|
1727
|
-
* @return {IValue} the created ivalue
|
|
1728
|
-
*/
|
|
1729
|
-
Reactive.prototype.expr = function (func) {
|
|
1730
|
-
var values = [];
|
|
1731
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1732
|
-
values[_i - 1] = arguments[_i];
|
|
1733
|
-
}
|
|
1734
|
-
var res = new (expression_1.Expression.bind.apply(expression_1.Expression, __spreadArray([void 0, func, !this.$.frozen], values, false)))();
|
|
1735
|
-
var $ = this.$;
|
|
1736
|
-
$.watch.add(res);
|
|
1737
|
-
return res;
|
|
1738
|
-
};
|
|
1739
|
-
/**
|
|
1740
|
-
* Enable reactivity of fields
|
|
1741
|
-
*/
|
|
1742
|
-
Reactive.prototype.enable = function () {
|
|
1743
|
-
var $ = this.$;
|
|
1744
|
-
if (!$.enabled) {
|
|
1745
|
-
$.watch.forEach(function (watcher) {
|
|
1746
|
-
watcher.$enable();
|
|
1747
|
-
});
|
|
1748
|
-
$.models.forEach(function (model) {
|
|
1749
|
-
model.enableReactivity();
|
|
1750
|
-
});
|
|
1751
|
-
$.enabled = true;
|
|
1752
|
-
}
|
|
1885
|
+
return StaticClassBinding;
|
|
1886
|
+
}(binding_1.Binding));
|
|
1887
|
+
exports.StaticClassBinding = StaticClassBinding;
|
|
1888
|
+
var DynamicalClassBinding = /** @class */ (function (_super) {
|
|
1889
|
+
__extends(DynamicalClassBinding, _super);
|
|
1890
|
+
function DynamicalClassBinding(node, value) {
|
|
1891
|
+
var _this = _super.call(this, value) || this;
|
|
1892
|
+
_this.current = "";
|
|
1893
|
+
_this.init(function (value) {
|
|
1894
|
+
if (_this.current != value) {
|
|
1895
|
+
if (_this.current.length) {
|
|
1896
|
+
removeClass(node, _this.current);
|
|
1897
|
+
}
|
|
1898
|
+
if (value.length) {
|
|
1899
|
+
addClass(node, value);
|
|
1900
|
+
}
|
|
1901
|
+
_this.current = value;
|
|
1902
|
+
}
|
|
1903
|
+
});
|
|
1904
|
+
_this.$seal();
|
|
1905
|
+
return _this;
|
|
1906
|
+
}
|
|
1907
|
+
return DynamicalClassBinding;
|
|
1908
|
+
}(binding_1.Binding));
|
|
1909
|
+
exports.DynamicalClassBinding = DynamicalClassBinding;
|
|
1910
|
+
|
|
1911
|
+
|
|
1912
|
+
// ./lib-es5/binding/style.js
|
|
1913
|
+
"use strict";
|
|
1914
|
+
var __extends = (this && this.__extends) || (function () {
|
|
1915
|
+
var extendStatics = function (d, b) {
|
|
1916
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1917
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1918
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1919
|
+
return extendStatics(d, b);
|
|
1753
1920
|
};
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
$.watch.forEach(function (watcher) {
|
|
1761
|
-
watcher.$disable();
|
|
1762
|
-
});
|
|
1763
|
-
$.models.forEach(function (model) {
|
|
1764
|
-
model.disableReactivity();
|
|
1765
|
-
});
|
|
1766
|
-
$.enabled = false;
|
|
1767
|
-
}
|
|
1921
|
+
return function (d, b) {
|
|
1922
|
+
if (typeof b !== "function" && b !== null)
|
|
1923
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1924
|
+
extendStatics(d, b);
|
|
1925
|
+
function __() { this.constructor = d; }
|
|
1926
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1768
1927
|
};
|
|
1928
|
+
})();
|
|
1929
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1930
|
+
exports.StyleBinding = void 0;
|
|
1931
|
+
var binding_1 = require("./binding");
|
|
1932
|
+
/**
|
|
1933
|
+
* Describes a style attribute binding
|
|
1934
|
+
* @class StyleBinding
|
|
1935
|
+
* @extends Binding
|
|
1936
|
+
*/
|
|
1937
|
+
var StyleBinding = /** @class */ (function (_super) {
|
|
1938
|
+
__extends(StyleBinding, _super);
|
|
1769
1939
|
/**
|
|
1770
|
-
*
|
|
1771
|
-
* @param
|
|
1772
|
-
* @param
|
|
1773
|
-
* @param
|
|
1940
|
+
* Constructs a style binding attribute
|
|
1941
|
+
* @param node {INode} the vasille node
|
|
1942
|
+
* @param name {string} the name of style property
|
|
1943
|
+
* @param value {IValue} the value to bind
|
|
1774
1944
|
*/
|
|
1775
|
-
|
|
1776
|
-
var _this = this;
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
}
|
|
1781
|
-
if ($.watch.has(cond)) {
|
|
1782
|
-
throw (0, errors_1.wrongBinding)("freeze state must be bound to an external component");
|
|
1783
|
-
}
|
|
1784
|
-
$.freezeExpr = new expression_1.Expression(function (cond) {
|
|
1785
|
-
$.frozen = !cond;
|
|
1786
|
-
if (cond) {
|
|
1787
|
-
onOn === null || onOn === void 0 ? void 0 : onOn();
|
|
1788
|
-
_this.enable();
|
|
1789
|
-
}
|
|
1790
|
-
else {
|
|
1791
|
-
onOff === null || onOff === void 0 ? void 0 : onOff();
|
|
1792
|
-
_this.disable();
|
|
1945
|
+
function StyleBinding(node, name, value) {
|
|
1946
|
+
var _this = _super.call(this, value) || this;
|
|
1947
|
+
_this.init(function (value) {
|
|
1948
|
+
if (node.node instanceof HTMLElement) {
|
|
1949
|
+
node.node.style.setProperty(name, value);
|
|
1793
1950
|
}
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
Reactive.prototype.applyOptions = function (input) {
|
|
1802
|
-
// empty
|
|
1803
|
-
};
|
|
1804
|
-
Reactive.prototype.applyOptionsNow = function () {
|
|
1805
|
-
this.applyOptions(this.input);
|
|
1806
|
-
};
|
|
1807
|
-
Reactive.prototype.compose = function (input) {
|
|
1808
|
-
throw (0, errors_1.notOverwritten)();
|
|
1809
|
-
};
|
|
1810
|
-
Reactive.prototype.composeNow = function () {
|
|
1811
|
-
this.compose(this.input);
|
|
1812
|
-
};
|
|
1813
|
-
Reactive.prototype.runFunctional = function (f) {
|
|
1814
|
-
var args = [];
|
|
1815
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1816
|
-
args[_i - 1] = arguments[_i];
|
|
1817
|
-
}
|
|
1818
|
-
stack(this);
|
|
1819
|
-
// yet another ts bug
|
|
1820
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1821
|
-
// @ts-ignore
|
|
1822
|
-
var result = f.apply(void 0, args);
|
|
1823
|
-
unstack();
|
|
1824
|
-
return result;
|
|
1825
|
-
};
|
|
1826
|
-
Reactive.prototype.runOnDestroy = function (func) {
|
|
1827
|
-
this.$.onDestroy = func;
|
|
1828
|
-
};
|
|
1829
|
-
Reactive.prototype.$destroy = function () {
|
|
1830
|
-
_super.prototype.$destroy.call(this);
|
|
1831
|
-
this.$.$destroy();
|
|
1832
|
-
this.$ = null;
|
|
1833
|
-
};
|
|
1834
|
-
return Reactive;
|
|
1835
|
-
}(destroyable_js_1.Destroyable));
|
|
1836
|
-
exports.Reactive = Reactive;
|
|
1951
|
+
});
|
|
1952
|
+
_this.$seal();
|
|
1953
|
+
return _this;
|
|
1954
|
+
}
|
|
1955
|
+
return StyleBinding;
|
|
1956
|
+
}(binding_1.Binding));
|
|
1957
|
+
exports.StyleBinding = StyleBinding;
|
|
1837
1958
|
|
|
1838
1959
|
|
|
1839
1960
|
// ./lib-es5/node/node.js
|
|
@@ -2028,7 +2149,9 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
2028
2149
|
* @param input
|
|
2029
2150
|
* @param cb {function(Tag, *)} callback
|
|
2030
2151
|
*/
|
|
2031
|
-
Fragment.prototype.tag = function (tagName, input, cb
|
|
2152
|
+
Fragment.prototype.tag = function (tagName, input, cb
|
|
2153
|
+
// @ts-ignore
|
|
2154
|
+
) {
|
|
2032
2155
|
var $ = this.$;
|
|
2033
2156
|
var node = new Tag(input);
|
|
2034
2157
|
input.slot = cb || input.slot;
|
|
@@ -2036,6 +2159,7 @@ var Fragment = /** @class */ (function (_super) {
|
|
|
2036
2159
|
node.init();
|
|
2037
2160
|
this.pushNode(node);
|
|
2038
2161
|
node.ready();
|
|
2162
|
+
// @ts-ignore
|
|
2039
2163
|
return node.node;
|
|
2040
2164
|
};
|
|
2041
2165
|
/**
|
|
@@ -2635,421 +2759,211 @@ var SwitchedNodePrivate = /** @class */ (function (_super) {
|
|
|
2635
2759
|
* Array of possible cases
|
|
2636
2760
|
* @type {Array<{cond : IValue<boolean>, cb : function(Fragment)}>}
|
|
2637
2761
|
*/
|
|
2638
|
-
_this.cases = [];
|
|
2639
|
-
_this.$seal();
|
|
2640
|
-
return _this;
|
|
2641
|
-
}
|
|
2642
|
-
/**
|
|
2643
|
-
* Runs GC
|
|
2644
|
-
*/
|
|
2645
|
-
SwitchedNodePrivate.prototype.$destroy = function () {
|
|
2646
|
-
this.cases.forEach(function (c) {
|
|
2647
|
-
delete c.cond;
|
|
2648
|
-
delete c.cb;
|
|
2649
|
-
});
|
|
2650
|
-
this.cases.splice(0);
|
|
2651
|
-
_super.prototype.$destroy.call(this);
|
|
2652
|
-
};
|
|
2653
|
-
return SwitchedNodePrivate;
|
|
2654
|
-
}(FragmentPrivate));
|
|
2655
|
-
exports.SwitchedNodePrivate = SwitchedNodePrivate;
|
|
2656
|
-
/**
|
|
2657
|
-
* Defines a node witch can switch its children conditionally
|
|
2658
|
-
*/
|
|
2659
|
-
var SwitchedNode = /** @class */ (function (_super) {
|
|
2660
|
-
__extends(SwitchedNode, _super);
|
|
2661
|
-
/**
|
|
2662
|
-
* Constructs a switch node and define a sync function
|
|
2663
|
-
*/
|
|
2664
|
-
function SwitchedNode() {
|
|
2665
|
-
var _this = _super.call(this, {}, new SwitchedNodePrivate) || this;
|
|
2666
|
-
_this.$.sync = function () {
|
|
2667
|
-
var $ = _this.$;
|
|
2668
|
-
var i = 0;
|
|
2669
|
-
for (; i < $.cases.length; i++) {
|
|
2670
|
-
if ($.cases[i].cond.$) {
|
|
2671
|
-
break;
|
|
2672
|
-
}
|
|
2673
|
-
}
|
|
2674
|
-
if (i === $.index) {
|
|
2675
|
-
return;
|
|
2676
|
-
}
|
|
2677
|
-
if (_this.lastChild) {
|
|
2678
|
-
_this.lastChild.$destroy();
|
|
2679
|
-
_this.children.clear();
|
|
2680
|
-
_this.lastChild = null;
|
|
2681
|
-
}
|
|
2682
|
-
if (i !== $.cases.length) {
|
|
2683
|
-
$.index = i;
|
|
2684
|
-
_this.createChild($.cases[i].cb);
|
|
2685
|
-
}
|
|
2686
|
-
else {
|
|
2687
|
-
$.index = -1;
|
|
2688
|
-
}
|
|
2689
|
-
};
|
|
2690
|
-
_this.$seal();
|
|
2691
|
-
return _this;
|
|
2692
|
-
}
|
|
2693
|
-
SwitchedNode.prototype.addCase = function (case_) {
|
|
2694
|
-
this.$.cases.push(case_);
|
|
2695
|
-
case_.cond.$on(this.$.sync);
|
|
2696
|
-
this.$.sync();
|
|
2697
|
-
};
|
|
2698
|
-
/**
|
|
2699
|
-
* Creates a child node
|
|
2700
|
-
* @param cb {function(Fragment)} Call-back
|
|
2701
|
-
*/
|
|
2702
|
-
SwitchedNode.prototype.createChild = function (cb) {
|
|
2703
|
-
var node = new Fragment({});
|
|
2704
|
-
node.preinit(this.$.app, this);
|
|
2705
|
-
node.init();
|
|
2706
|
-
this.lastChild = node;
|
|
2707
|
-
this.children.add(node);
|
|
2708
|
-
cb(node);
|
|
2709
|
-
};
|
|
2710
|
-
SwitchedNode.prototype.ready = function () {
|
|
2711
|
-
var $ = this.$;
|
|
2712
|
-
$.cases.forEach(function (c) {
|
|
2713
|
-
c.cond.$on($.sync);
|
|
2714
|
-
});
|
|
2715
|
-
$.sync();
|
|
2716
|
-
};
|
|
2717
|
-
SwitchedNode.prototype.$destroy = function () {
|
|
2718
|
-
var $ = this.$;
|
|
2719
|
-
$.cases.forEach(function (c) {
|
|
2720
|
-
c.cond.$off($.sync);
|
|
2721
|
-
});
|
|
2722
|
-
_super.prototype.$destroy.call(this);
|
|
2723
|
-
};
|
|
2724
|
-
return SwitchedNode;
|
|
2725
|
-
}(Fragment));
|
|
2726
|
-
exports.SwitchedNode = SwitchedNode;
|
|
2727
|
-
/**
|
|
2728
|
-
* The private part of a text node
|
|
2729
|
-
*/
|
|
2730
|
-
var DebugPrivate = /** @class */ (function (_super) {
|
|
2731
|
-
__extends(DebugPrivate, _super);
|
|
2732
|
-
function DebugPrivate() {
|
|
2733
|
-
var _this = this; _super.call(this);
|
|
2734
|
-
_this.$seal();
|
|
2735
|
-
return _this;
|
|
2736
|
-
}
|
|
2737
|
-
/**
|
|
2738
|
-
* Pre-initializes a text node
|
|
2739
|
-
* @param app {App} the app node
|
|
2740
|
-
* @param parent {Fragment} parent node
|
|
2741
|
-
* @param text {String | IValue}
|
|
2742
|
-
*/
|
|
2743
|
-
DebugPrivate.prototype.preinitComment = function (app, parent, text) {
|
|
2744
|
-
var _this = this;
|
|
2745
|
-
_super.prototype.preinit.call(this, app, parent);
|
|
2746
|
-
this.node = document.createComment(text.$);
|
|
2747
|
-
this.bindings.add(new expression_1.Expression(function (v) {
|
|
2748
|
-
_this.node.replaceData(0, -1, v);
|
|
2749
|
-
}, true, text));
|
|
2750
|
-
this.parent.appendNode(this.node);
|
|
2751
|
-
};
|
|
2752
|
-
/**
|
|
2753
|
-
* Clear node data
|
|
2754
|
-
*/
|
|
2755
|
-
DebugPrivate.prototype.$destroy = function () {
|
|
2756
|
-
this.node.remove();
|
|
2757
|
-
_super.prototype.$destroy.call(this);
|
|
2758
|
-
};
|
|
2759
|
-
return DebugPrivate;
|
|
2760
|
-
}(FragmentPrivate));
|
|
2761
|
-
exports.DebugPrivate = DebugPrivate;
|
|
2762
|
-
/**
|
|
2763
|
-
* Represents a debug node
|
|
2764
|
-
* @class DebugNode
|
|
2765
|
-
* @extends Fragment
|
|
2766
|
-
*/
|
|
2767
|
-
var DebugNode = /** @class */ (function (_super) {
|
|
2768
|
-
__extends(DebugNode, _super);
|
|
2769
|
-
function DebugNode() {
|
|
2770
|
-
var _this = _super.call(this, {}) || this;
|
|
2771
|
-
/**
|
|
2772
|
-
* private data
|
|
2773
|
-
* @type {DebugNode}
|
|
2774
|
-
*/
|
|
2775
|
-
_this.$ = new DebugPrivate();
|
|
2776
|
-
_this.$seal();
|
|
2777
|
-
return _this;
|
|
2778
|
-
}
|
|
2779
|
-
DebugNode.prototype.preinit = function (app, parent, text) {
|
|
2780
|
-
var $ = this.$;
|
|
2781
|
-
if (!text) {
|
|
2782
|
-
throw (0, errors_1.internalError)('wrong DebugNode::$preninit call');
|
|
2783
|
-
}
|
|
2784
|
-
$.preinitComment(app, parent, text);
|
|
2785
|
-
};
|
|
2786
|
-
/**
|
|
2787
|
-
* Runs garbage collector
|
|
2788
|
-
*/
|
|
2789
|
-
DebugNode.prototype.$destroy = function () {
|
|
2790
|
-
this.$.$destroy();
|
|
2791
|
-
_super.prototype.$destroy.call(this);
|
|
2792
|
-
};
|
|
2793
|
-
return DebugNode;
|
|
2794
|
-
}(Fragment));
|
|
2795
|
-
exports.DebugNode = DebugNode;
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
// ./lib-es5/node/app.js
|
|
2799
|
-
"use strict";
|
|
2800
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2801
|
-
var extendStatics = function (d, b) {
|
|
2802
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2803
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2804
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
2805
|
-
return extendStatics(d, b);
|
|
2806
|
-
};
|
|
2807
|
-
return function (d, b) {
|
|
2808
|
-
if (typeof b !== "function" && b !== null)
|
|
2809
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2810
|
-
extendStatics(d, b);
|
|
2811
|
-
function __() { this.constructor = d; }
|
|
2812
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2813
|
-
};
|
|
2814
|
-
})();
|
|
2815
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2816
|
-
exports.Portal = exports.App = exports.AppNode = void 0;
|
|
2817
|
-
var node_1 = require("./node");
|
|
2818
|
-
/**
|
|
2819
|
-
* Application Node
|
|
2820
|
-
* @class AppNode
|
|
2821
|
-
* @extends INode
|
|
2822
|
-
*/
|
|
2823
|
-
var AppNode = /** @class */ (function (_super) {
|
|
2824
|
-
__extends(AppNode, _super);
|
|
2825
|
-
/**
|
|
2826
|
-
* @param input
|
|
2827
|
-
*/
|
|
2828
|
-
function AppNode(input) {
|
|
2829
|
-
var _this = _super.call(this, input) || this;
|
|
2830
|
-
_this.debugUi = input.debugUi || false;
|
|
2831
|
-
_this.$seal();
|
|
2832
|
-
return _this;
|
|
2833
|
-
}
|
|
2834
|
-
return AppNode;
|
|
2835
|
-
}(node_1.INode));
|
|
2836
|
-
exports.AppNode = AppNode;
|
|
2837
|
-
/**
|
|
2838
|
-
* Represents a Vasille.js application
|
|
2839
|
-
* @class App
|
|
2840
|
-
* @extends AppNode
|
|
2841
|
-
*/
|
|
2842
|
-
var App = /** @class */ (function (_super) {
|
|
2843
|
-
__extends(App, _super);
|
|
2844
|
-
/**
|
|
2845
|
-
* Constructs an app node
|
|
2846
|
-
* @param node {Element} The root of application
|
|
2847
|
-
* @param input
|
|
2848
|
-
*/
|
|
2849
|
-
function App(node, input) {
|
|
2850
|
-
var _this = _super.call(this, input) || this;
|
|
2851
|
-
_this.$.node = node;
|
|
2852
|
-
_this.preinit(_this, _this);
|
|
2853
|
-
_this.init();
|
|
2854
|
-
_this.$seal();
|
|
2855
|
-
return _this;
|
|
2856
|
-
}
|
|
2857
|
-
App.prototype.appendNode = function (node) {
|
|
2858
|
-
this.$.node.appendChild(node);
|
|
2859
|
-
};
|
|
2860
|
-
return App;
|
|
2861
|
-
}(AppNode));
|
|
2862
|
-
exports.App = App;
|
|
2863
|
-
var Portal = /** @class */ (function (_super) {
|
|
2864
|
-
__extends(Portal, _super);
|
|
2865
|
-
function Portal(input) {
|
|
2866
|
-
var _this = _super.call(this, input) || this;
|
|
2867
|
-
_this.$.node = input.node;
|
|
2868
|
-
_this.$seal();
|
|
2869
|
-
return _this;
|
|
2870
|
-
}
|
|
2871
|
-
Portal.prototype.appendNode = function (node) {
|
|
2872
|
-
this.$.node.appendChild(node);
|
|
2873
|
-
};
|
|
2874
|
-
return Portal;
|
|
2875
|
-
}(AppNode));
|
|
2876
|
-
exports.Portal = Portal;
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
// ./lib-es5/binding/attribute.js
|
|
2880
|
-
"use strict";
|
|
2881
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2882
|
-
var extendStatics = function (d, b) {
|
|
2883
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2884
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2885
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
2886
|
-
return extendStatics(d, b);
|
|
2887
|
-
};
|
|
2888
|
-
return function (d, b) {
|
|
2889
|
-
if (typeof b !== "function" && b !== null)
|
|
2890
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2891
|
-
extendStatics(d, b);
|
|
2892
|
-
function __() { this.constructor = d; }
|
|
2893
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2762
|
+
_this.cases = [];
|
|
2763
|
+
_this.$seal();
|
|
2764
|
+
return _this;
|
|
2765
|
+
}
|
|
2766
|
+
/**
|
|
2767
|
+
* Runs GC
|
|
2768
|
+
*/
|
|
2769
|
+
SwitchedNodePrivate.prototype.$destroy = function () {
|
|
2770
|
+
this.cases.forEach(function (c) {
|
|
2771
|
+
delete c.cond;
|
|
2772
|
+
delete c.cb;
|
|
2773
|
+
});
|
|
2774
|
+
this.cases.splice(0);
|
|
2775
|
+
_super.prototype.$destroy.call(this);
|
|
2894
2776
|
};
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
exports.
|
|
2898
|
-
var binding_1 = require("./binding");
|
|
2777
|
+
return SwitchedNodePrivate;
|
|
2778
|
+
}(FragmentPrivate));
|
|
2779
|
+
exports.SwitchedNodePrivate = SwitchedNodePrivate;
|
|
2899
2780
|
/**
|
|
2900
|
-
*
|
|
2901
|
-
* @class AttributeBinding
|
|
2902
|
-
* @extends Binding
|
|
2781
|
+
* Defines a node witch can switch its children conditionally
|
|
2903
2782
|
*/
|
|
2904
|
-
var
|
|
2905
|
-
__extends(
|
|
2783
|
+
var SwitchedNode = /** @class */ (function (_super) {
|
|
2784
|
+
__extends(SwitchedNode, _super);
|
|
2906
2785
|
/**
|
|
2907
|
-
* Constructs
|
|
2908
|
-
* @param node {INode} the vasille node
|
|
2909
|
-
* @param name {String} the name of attribute
|
|
2910
|
-
* @param value {IValue} value to bind
|
|
2786
|
+
* Constructs a switch node and define a sync function
|
|
2911
2787
|
*/
|
|
2912
|
-
function
|
|
2913
|
-
var _this = _super.call(this,
|
|
2914
|
-
_this
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
node.node.setAttribute(name, "".concat(value));
|
|
2788
|
+
function SwitchedNode() {
|
|
2789
|
+
var _this = _super.call(this, {}, new SwitchedNodePrivate) || this;
|
|
2790
|
+
_this.$.sync = function () {
|
|
2791
|
+
var $ = _this.$;
|
|
2792
|
+
var i = 0;
|
|
2793
|
+
for (; i < $.cases.length; i++) {
|
|
2794
|
+
if ($.cases[i].cond.$) {
|
|
2795
|
+
break;
|
|
2921
2796
|
}
|
|
2922
2797
|
}
|
|
2798
|
+
if (i === $.index) {
|
|
2799
|
+
return;
|
|
2800
|
+
}
|
|
2801
|
+
if (_this.lastChild) {
|
|
2802
|
+
_this.lastChild.$destroy();
|
|
2803
|
+
_this.children.clear();
|
|
2804
|
+
_this.lastChild = null;
|
|
2805
|
+
}
|
|
2806
|
+
if (i !== $.cases.length) {
|
|
2807
|
+
$.index = i;
|
|
2808
|
+
_this.createChild($.cases[i].cb);
|
|
2809
|
+
}
|
|
2923
2810
|
else {
|
|
2924
|
-
|
|
2811
|
+
$.index = -1;
|
|
2925
2812
|
}
|
|
2926
|
-
}
|
|
2813
|
+
};
|
|
2927
2814
|
_this.$seal();
|
|
2928
2815
|
return _this;
|
|
2929
2816
|
}
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
// ./lib-es5/binding/style.js
|
|
2936
|
-
"use strict";
|
|
2937
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2938
|
-
var extendStatics = function (d, b) {
|
|
2939
|
-
extendStatics = Object.setPrototypeOf ||
|
|
2940
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2941
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
2942
|
-
return extendStatics(d, b);
|
|
2943
|
-
};
|
|
2944
|
-
return function (d, b) {
|
|
2945
|
-
if (typeof b !== "function" && b !== null)
|
|
2946
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2947
|
-
extendStatics(d, b);
|
|
2948
|
-
function __() { this.constructor = d; }
|
|
2949
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2817
|
+
SwitchedNode.prototype.addCase = function (case_) {
|
|
2818
|
+
this.$.cases.push(case_);
|
|
2819
|
+
case_.cond.$on(this.$.sync);
|
|
2820
|
+
this.$.sync();
|
|
2950
2821
|
};
|
|
2951
|
-
})();
|
|
2952
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2953
|
-
exports.StyleBinding = void 0;
|
|
2954
|
-
var binding_1 = require("./binding");
|
|
2955
|
-
/**
|
|
2956
|
-
* Describes a style attribute binding
|
|
2957
|
-
* @class StyleBinding
|
|
2958
|
-
* @extends Binding
|
|
2959
|
-
*/
|
|
2960
|
-
var StyleBinding = /** @class */ (function (_super) {
|
|
2961
|
-
__extends(StyleBinding, _super);
|
|
2962
2822
|
/**
|
|
2963
|
-
*
|
|
2964
|
-
* @param
|
|
2965
|
-
* @param name {string} the name of style property
|
|
2966
|
-
* @param value {IValue} the value to bind
|
|
2823
|
+
* Creates a child node
|
|
2824
|
+
* @param cb {function(Fragment)} Call-back
|
|
2967
2825
|
*/
|
|
2968
|
-
function
|
|
2969
|
-
var
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2826
|
+
SwitchedNode.prototype.createChild = function (cb) {
|
|
2827
|
+
var node = new Fragment({});
|
|
2828
|
+
node.preinit(this.$.app, this);
|
|
2829
|
+
node.init();
|
|
2830
|
+
this.lastChild = node;
|
|
2831
|
+
this.children.add(node);
|
|
2832
|
+
cb(node);
|
|
2833
|
+
};
|
|
2834
|
+
SwitchedNode.prototype.ready = function () {
|
|
2835
|
+
var $ = this.$;
|
|
2836
|
+
$.cases.forEach(function (c) {
|
|
2837
|
+
c.cond.$on($.sync);
|
|
2838
|
+
});
|
|
2839
|
+
$.sync();
|
|
2840
|
+
};
|
|
2841
|
+
SwitchedNode.prototype.$destroy = function () {
|
|
2842
|
+
var $ = this.$;
|
|
2843
|
+
$.cases.forEach(function (c) {
|
|
2844
|
+
c.cond.$off($.sync);
|
|
2974
2845
|
});
|
|
2846
|
+
_super.prototype.$destroy.call(this);
|
|
2847
|
+
};
|
|
2848
|
+
return SwitchedNode;
|
|
2849
|
+
}(Fragment));
|
|
2850
|
+
exports.SwitchedNode = SwitchedNode;
|
|
2851
|
+
/**
|
|
2852
|
+
* The private part of a text node
|
|
2853
|
+
*/
|
|
2854
|
+
var DebugPrivate = /** @class */ (function (_super) {
|
|
2855
|
+
__extends(DebugPrivate, _super);
|
|
2856
|
+
function DebugPrivate() {
|
|
2857
|
+
var _this = this; _super.call(this);
|
|
2975
2858
|
_this.$seal();
|
|
2976
2859
|
return _this;
|
|
2977
2860
|
}
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
var
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2861
|
+
/**
|
|
2862
|
+
* Pre-initializes a text node
|
|
2863
|
+
* @param app {App} the app node
|
|
2864
|
+
* @param parent {Fragment} parent node
|
|
2865
|
+
* @param text {String | IValue}
|
|
2866
|
+
*/
|
|
2867
|
+
DebugPrivate.prototype.preinitComment = function (app, parent, text) {
|
|
2868
|
+
var _this = this;
|
|
2869
|
+
_super.prototype.preinit.call(this, app, parent);
|
|
2870
|
+
this.node = document.createComment(text.$);
|
|
2871
|
+
this.bindings.add(new expression_1.Expression(function (v) {
|
|
2872
|
+
_this.node.replaceData(0, -1, v);
|
|
2873
|
+
}, true, text));
|
|
2874
|
+
this.parent.appendNode(this.node);
|
|
2991
2875
|
};
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2876
|
+
/**
|
|
2877
|
+
* Clear node data
|
|
2878
|
+
*/
|
|
2879
|
+
DebugPrivate.prototype.$destroy = function () {
|
|
2880
|
+
this.node.remove();
|
|
2881
|
+
_super.prototype.$destroy.call(this);
|
|
2998
2882
|
};
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
exports.
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
if (value) {
|
|
3017
|
-
addClass(node, name);
|
|
3018
|
-
}
|
|
3019
|
-
else {
|
|
3020
|
-
removeClass(node, name);
|
|
3021
|
-
}
|
|
3022
|
-
_this.current = value;
|
|
3023
|
-
}
|
|
3024
|
-
});
|
|
2883
|
+
return DebugPrivate;
|
|
2884
|
+
}(FragmentPrivate));
|
|
2885
|
+
exports.DebugPrivate = DebugPrivate;
|
|
2886
|
+
/**
|
|
2887
|
+
* Represents a debug node
|
|
2888
|
+
* @class DebugNode
|
|
2889
|
+
* @extends Fragment
|
|
2890
|
+
*/
|
|
2891
|
+
var DebugNode = /** @class */ (function (_super) {
|
|
2892
|
+
__extends(DebugNode, _super);
|
|
2893
|
+
function DebugNode() {
|
|
2894
|
+
var _this = _super.call(this, {}) || this;
|
|
2895
|
+
/**
|
|
2896
|
+
* private data
|
|
2897
|
+
* @type {DebugNode}
|
|
2898
|
+
*/
|
|
2899
|
+
_this.$ = new DebugPrivate();
|
|
3025
2900
|
_this.$seal();
|
|
3026
2901
|
return _this;
|
|
3027
2902
|
}
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
2903
|
+
DebugNode.prototype.preinit = function (app, parent, text) {
|
|
2904
|
+
var $ = this.$;
|
|
2905
|
+
if (!text) {
|
|
2906
|
+
throw (0, errors_1.internalError)('wrong DebugNode::$preninit call');
|
|
2907
|
+
}
|
|
2908
|
+
$.preinitComment(app, parent, text);
|
|
2909
|
+
};
|
|
2910
|
+
/**
|
|
2911
|
+
* Runs garbage collector
|
|
2912
|
+
*/
|
|
2913
|
+
DebugNode.prototype.$destroy = function () {
|
|
2914
|
+
this.$.$destroy();
|
|
2915
|
+
_super.prototype.$destroy.call(this);
|
|
2916
|
+
};
|
|
2917
|
+
return DebugNode;
|
|
2918
|
+
}(Fragment));
|
|
2919
|
+
exports.DebugNode = DebugNode;
|
|
2920
|
+
|
|
2921
|
+
|
|
2922
|
+
// ./lib-es5/node/watch.js
|
|
2923
|
+
"use strict";
|
|
2924
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2925
|
+
var extendStatics = function (d, b) {
|
|
2926
|
+
extendStatics = Object.setPrototypeOf ||
|
|
2927
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2928
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
2929
|
+
return extendStatics(d, b);
|
|
2930
|
+
};
|
|
2931
|
+
return function (d, b) {
|
|
2932
|
+
if (typeof b !== "function" && b !== null)
|
|
2933
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2934
|
+
extendStatics(d, b);
|
|
2935
|
+
function __() { this.constructor = d; }
|
|
2936
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2937
|
+
};
|
|
2938
|
+
})();
|
|
2939
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2940
|
+
exports.Watch = void 0;
|
|
2941
|
+
var node_1 = require("./node");
|
|
2942
|
+
/**
|
|
2943
|
+
* Watch Node
|
|
2944
|
+
* @class Watch
|
|
2945
|
+
* @extends Fragment
|
|
2946
|
+
*/
|
|
2947
|
+
var Watch = /** @class */ (function (_super) {
|
|
2948
|
+
__extends(Watch, _super);
|
|
2949
|
+
function Watch() {
|
|
2950
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3049
2951
|
}
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
2952
|
+
Watch.prototype.compose = function (input) {
|
|
2953
|
+
var _this = this;
|
|
2954
|
+
this.watch(function (value) {
|
|
2955
|
+
_this.children.forEach(function (child) {
|
|
2956
|
+
child.$destroy();
|
|
2957
|
+
});
|
|
2958
|
+
_this.children.clear();
|
|
2959
|
+
_this.lastChild = null;
|
|
2960
|
+
input.slot && input.slot(_this, value);
|
|
2961
|
+
}, input.model);
|
|
2962
|
+
input.slot(this, input.model.$);
|
|
2963
|
+
};
|
|
2964
|
+
return Watch;
|
|
2965
|
+
}(node_1.Fragment));
|
|
2966
|
+
exports.Watch = Watch;
|
|
3053
2967
|
|
|
3054
2968
|
|
|
3055
2969
|
// ./lib-es5/views/repeat-node.js
|
|
@@ -3259,7 +3173,7 @@ var ArrayView = /** @class */ (function (_super) {
|
|
|
3259
3173
|
exports.ArrayView = ArrayView;
|
|
3260
3174
|
|
|
3261
3175
|
|
|
3262
|
-
// ./lib-es5/
|
|
3176
|
+
// ./lib-es5/views/map-view.js
|
|
3263
3177
|
"use strict";
|
|
3264
3178
|
var __extends = (this && this.__extends) || (function () {
|
|
3265
3179
|
var extendStatics = function (d, b) {
|
|
@@ -3277,33 +3191,28 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3277
3191
|
};
|
|
3278
3192
|
})();
|
|
3279
3193
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3280
|
-
exports.
|
|
3281
|
-
var
|
|
3194
|
+
exports.MapView = void 0;
|
|
3195
|
+
var base_view_1 = require("./base-view");
|
|
3282
3196
|
/**
|
|
3283
|
-
*
|
|
3284
|
-
* @class
|
|
3285
|
-
* @extends
|
|
3197
|
+
* Create a children pack for each map value
|
|
3198
|
+
* @class MapView
|
|
3199
|
+
* @extends BaseView
|
|
3286
3200
|
*/
|
|
3287
|
-
var
|
|
3288
|
-
__extends(
|
|
3289
|
-
function
|
|
3201
|
+
var MapView = /** @class */ (function (_super) {
|
|
3202
|
+
__extends(MapView, _super);
|
|
3203
|
+
function MapView() {
|
|
3290
3204
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3291
3205
|
}
|
|
3292
|
-
|
|
3206
|
+
MapView.prototype.compose = function (input) {
|
|
3293
3207
|
var _this = this;
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
_this.children.clear();
|
|
3299
|
-
_this.lastChild = null;
|
|
3300
|
-
input.slot && input.slot(_this, value);
|
|
3301
|
-
}, input.model);
|
|
3302
|
-
input.slot(this, input.model.$);
|
|
3208
|
+
_super.prototype.compose.call(this, input);
|
|
3209
|
+
input.model.forEach(function (value, key) {
|
|
3210
|
+
_this.createChild(input, key, value);
|
|
3211
|
+
});
|
|
3303
3212
|
};
|
|
3304
|
-
return
|
|
3305
|
-
}(
|
|
3306
|
-
exports.
|
|
3213
|
+
return MapView;
|
|
3214
|
+
}(base_view_1.BaseView));
|
|
3215
|
+
exports.MapView = MapView;
|
|
3307
3216
|
|
|
3308
3217
|
|
|
3309
3218
|
// ./lib-es5/views/object-view.js
|
|
@@ -3349,7 +3258,7 @@ var ObjectView = /** @class */ (function (_super) {
|
|
|
3349
3258
|
exports.ObjectView = ObjectView;
|
|
3350
3259
|
|
|
3351
3260
|
|
|
3352
|
-
// ./lib-es5/views/
|
|
3261
|
+
// ./lib-es5/views/set-view.js
|
|
3353
3262
|
"use strict";
|
|
3354
3263
|
var __extends = (this && this.__extends) || (function () {
|
|
3355
3264
|
var extendStatics = function (d, b) {
|
|
@@ -3367,31 +3276,91 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3367
3276
|
};
|
|
3368
3277
|
})();
|
|
3369
3278
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3370
|
-
exports.
|
|
3279
|
+
exports.SetView = void 0;
|
|
3371
3280
|
var base_view_1 = require("./base-view");
|
|
3372
3281
|
/**
|
|
3373
|
-
* Create a children pack for each
|
|
3374
|
-
* @class
|
|
3282
|
+
* Create a children pack for each set value
|
|
3283
|
+
* @class SetView
|
|
3375
3284
|
* @extends BaseView
|
|
3376
3285
|
*/
|
|
3377
|
-
var
|
|
3378
|
-
__extends(
|
|
3379
|
-
function
|
|
3286
|
+
var SetView = /** @class */ (function (_super) {
|
|
3287
|
+
__extends(SetView, _super);
|
|
3288
|
+
function SetView() {
|
|
3380
3289
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
3381
3290
|
}
|
|
3382
|
-
|
|
3291
|
+
SetView.prototype.compose = function (input) {
|
|
3383
3292
|
var _this = this;
|
|
3384
3293
|
_super.prototype.compose.call(this, input);
|
|
3385
|
-
input.model
|
|
3386
|
-
|
|
3294
|
+
var set = input.model;
|
|
3295
|
+
set.forEach(function (item) {
|
|
3296
|
+
_this.createChild(input, item, item);
|
|
3387
3297
|
});
|
|
3388
3298
|
};
|
|
3389
|
-
return
|
|
3299
|
+
return SetView;
|
|
3390
3300
|
}(base_view_1.BaseView));
|
|
3391
|
-
exports.
|
|
3301
|
+
exports.SetView = SetView;
|
|
3392
3302
|
|
|
3393
3303
|
|
|
3394
|
-
// ./lib-es5/
|
|
3304
|
+
// ./lib-es5/index.js
|
|
3305
|
+
"use strict";
|
|
3306
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3307
|
+
exports.current = exports.userError = exports.unstack = exports.stack = exports.Watch = exports.Reactive = exports.Binding = exports.Expression = exports.Portal = exports.App = exports.AppNode = exports.Extension = exports.Component = exports.Tag = exports.INode = exports.Fragment = exports.SetView = exports.ObjectView = exports.MapView = exports.ArrayView = exports.Listener = exports.BaseView = exports.SetModel = exports.ObjectModel = exports.MapModel = exports.ArrayModel = exports.Pointer = exports.Mirror = exports.Reference = exports.IValue = exports.Destroyable = void 0;
|
|
3308
|
+
var destroyable_1 = require("./core/destroyable");
|
|
3309
|
+
Object.defineProperty(exports, "Destroyable", { enumerable: true, get: function () { return destroyable_1.Destroyable; } });
|
|
3310
|
+
var core_1 = require("./core/core");
|
|
3311
|
+
Object.defineProperty(exports, "current", { enumerable: true, get: function () { return core_1.current; } });
|
|
3312
|
+
Object.defineProperty(exports, "Reactive", { enumerable: true, get: function () { return core_1.Reactive; } });
|
|
3313
|
+
Object.defineProperty(exports, "stack", { enumerable: true, get: function () { return core_1.stack; } });
|
|
3314
|
+
Object.defineProperty(exports, "unstack", { enumerable: true, get: function () { return core_1.unstack; } });
|
|
3315
|
+
var ivalue_1 = require("./core/ivalue");
|
|
3316
|
+
Object.defineProperty(exports, "IValue", { enumerable: true, get: function () { return ivalue_1.IValue; } });
|
|
3317
|
+
var array_model_1 = require("./models/array-model");
|
|
3318
|
+
Object.defineProperty(exports, "ArrayModel", { enumerable: true, get: function () { return array_model_1.ArrayModel; } });
|
|
3319
|
+
var listener_1 = require("./models/listener");
|
|
3320
|
+
Object.defineProperty(exports, "Listener", { enumerable: true, get: function () { return listener_1.Listener; } });
|
|
3321
|
+
var map_model_1 = require("./models/map-model");
|
|
3322
|
+
Object.defineProperty(exports, "MapModel", { enumerable: true, get: function () { return map_model_1.MapModel; } });
|
|
3323
|
+
var object_model_1 = require("./models/object-model");
|
|
3324
|
+
Object.defineProperty(exports, "ObjectModel", { enumerable: true, get: function () { return object_model_1.ObjectModel; } });
|
|
3325
|
+
var set_model_1 = require("./models/set-model");
|
|
3326
|
+
Object.defineProperty(exports, "SetModel", { enumerable: true, get: function () { return set_model_1.SetModel; } });
|
|
3327
|
+
var app_1 = require("./node/app");
|
|
3328
|
+
Object.defineProperty(exports, "App", { enumerable: true, get: function () { return app_1.App; } });
|
|
3329
|
+
Object.defineProperty(exports, "AppNode", { enumerable: true, get: function () { return app_1.AppNode; } });
|
|
3330
|
+
Object.defineProperty(exports, "Portal", { enumerable: true, get: function () { return app_1.Portal; } });
|
|
3331
|
+
var node_1 = require("./node/node");
|
|
3332
|
+
Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return node_1.Component; } });
|
|
3333
|
+
Object.defineProperty(exports, "Extension", { enumerable: true, get: function () { return node_1.Extension; } });
|
|
3334
|
+
Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return node_1.Fragment; } });
|
|
3335
|
+
Object.defineProperty(exports, "INode", { enumerable: true, get: function () { return node_1.INode; } });
|
|
3336
|
+
Object.defineProperty(exports, "Tag", { enumerable: true, get: function () { return node_1.Tag; } });
|
|
3337
|
+
var expression_1 = require("./value/expression");
|
|
3338
|
+
Object.defineProperty(exports, "Expression", { enumerable: true, get: function () { return expression_1.Expression; } });
|
|
3339
|
+
var mirror_1 = require("./value/mirror");
|
|
3340
|
+
Object.defineProperty(exports, "Mirror", { enumerable: true, get: function () { return mirror_1.Mirror; } });
|
|
3341
|
+
var pointer_1 = require("./value/pointer");
|
|
3342
|
+
Object.defineProperty(exports, "Pointer", { enumerable: true, get: function () { return pointer_1.Pointer; } });
|
|
3343
|
+
var reference_1 = require("./value/reference");
|
|
3344
|
+
Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return reference_1.Reference; } });
|
|
3345
|
+
var array_view_1 = require("./views/array-view");
|
|
3346
|
+
Object.defineProperty(exports, "ArrayView", { enumerable: true, get: function () { return array_view_1.ArrayView; } });
|
|
3347
|
+
var base_view_1 = require("./views/base-view");
|
|
3348
|
+
Object.defineProperty(exports, "BaseView", { enumerable: true, get: function () { return base_view_1.BaseView; } });
|
|
3349
|
+
var map_view_1 = require("./views/map-view");
|
|
3350
|
+
Object.defineProperty(exports, "MapView", { enumerable: true, get: function () { return map_view_1.MapView; } });
|
|
3351
|
+
var object_view_1 = require("./views/object-view");
|
|
3352
|
+
Object.defineProperty(exports, "ObjectView", { enumerable: true, get: function () { return object_view_1.ObjectView; } });
|
|
3353
|
+
var set_view_1 = require("./views/set-view");
|
|
3354
|
+
Object.defineProperty(exports, "SetView", { enumerable: true, get: function () { return set_view_1.SetView; } });
|
|
3355
|
+
var binding_1 = require("./binding/binding");
|
|
3356
|
+
Object.defineProperty(exports, "Binding", { enumerable: true, get: function () { return binding_1.Binding; } });
|
|
3357
|
+
var errors_1 = require("./core/errors");
|
|
3358
|
+
Object.defineProperty(exports, "userError", { enumerable: true, get: function () { return errors_1.userError; } });
|
|
3359
|
+
var watch_1 = require("./node/watch");
|
|
3360
|
+
Object.defineProperty(exports, "Watch", { enumerable: true, get: function () { return watch_1.Watch; } });
|
|
3361
|
+
|
|
3362
|
+
|
|
3363
|
+
// ./lib-es5/node/app.js
|
|
3395
3364
|
"use strict";
|
|
3396
3365
|
var __extends = (this && this.__extends) || (function () {
|
|
3397
3366
|
var extendStatics = function (d, b) {
|
|
@@ -3409,29 +3378,67 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3409
3378
|
};
|
|
3410
3379
|
})();
|
|
3411
3380
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3412
|
-
exports.
|
|
3413
|
-
var
|
|
3381
|
+
exports.Portal = exports.App = exports.AppNode = void 0;
|
|
3382
|
+
var node_1 = require("./node");
|
|
3414
3383
|
/**
|
|
3415
|
-
*
|
|
3416
|
-
* @class
|
|
3417
|
-
* @extends
|
|
3384
|
+
* Application Node
|
|
3385
|
+
* @class AppNode
|
|
3386
|
+
* @extends INode
|
|
3418
3387
|
*/
|
|
3419
|
-
var
|
|
3420
|
-
__extends(
|
|
3421
|
-
|
|
3422
|
-
|
|
3388
|
+
var AppNode = /** @class */ (function (_super) {
|
|
3389
|
+
__extends(AppNode, _super);
|
|
3390
|
+
/**
|
|
3391
|
+
* @param input
|
|
3392
|
+
*/
|
|
3393
|
+
function AppNode(input) {
|
|
3394
|
+
var _this = _super.call(this, input) || this;
|
|
3395
|
+
_this.debugUi = input.debugUi || false;
|
|
3396
|
+
_this.$seal();
|
|
3397
|
+
return _this;
|
|
3423
3398
|
}
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3399
|
+
return AppNode;
|
|
3400
|
+
}(node_1.INode));
|
|
3401
|
+
exports.AppNode = AppNode;
|
|
3402
|
+
/**
|
|
3403
|
+
* Represents a Vasille.js application
|
|
3404
|
+
* @class App
|
|
3405
|
+
* @extends AppNode
|
|
3406
|
+
*/
|
|
3407
|
+
var App = /** @class */ (function (_super) {
|
|
3408
|
+
__extends(App, _super);
|
|
3409
|
+
/**
|
|
3410
|
+
* Constructs an app node
|
|
3411
|
+
* @param node {Element} The root of application
|
|
3412
|
+
* @param input
|
|
3413
|
+
*/
|
|
3414
|
+
function App(node, input) {
|
|
3415
|
+
var _this = _super.call(this, input) || this;
|
|
3416
|
+
_this.$.node = node;
|
|
3417
|
+
_this.preinit(_this, _this);
|
|
3418
|
+
_this.init();
|
|
3419
|
+
_this.$seal();
|
|
3420
|
+
return _this;
|
|
3421
|
+
}
|
|
3422
|
+
App.prototype.appendNode = function (node) {
|
|
3423
|
+
this.$.node.appendChild(node);
|
|
3431
3424
|
};
|
|
3432
|
-
return
|
|
3433
|
-
}(
|
|
3434
|
-
exports.
|
|
3425
|
+
return App;
|
|
3426
|
+
}(AppNode));
|
|
3427
|
+
exports.App = App;
|
|
3428
|
+
var Portal = /** @class */ (function (_super) {
|
|
3429
|
+
__extends(Portal, _super);
|
|
3430
|
+
function Portal(input) {
|
|
3431
|
+
var _this = _super.call(this, input) || this;
|
|
3432
|
+
_this.$.node = input.node;
|
|
3433
|
+
_this.$seal();
|
|
3434
|
+
return _this;
|
|
3435
|
+
}
|
|
3436
|
+
Portal.prototype.appendNode = function (node) {
|
|
3437
|
+
this.$.node.appendChild(node);
|
|
3438
|
+
};
|
|
3439
|
+
return Portal;
|
|
3440
|
+
}(AppNode));
|
|
3441
|
+
exports.Portal = Portal;
|
|
3435
3442
|
|
|
3436
3443
|
|
|
3437
3444
|
// ./lib-es5/functional/options.js
|