native-document 1.0.90 → 1.0.92
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/dist/native-document.components.min.js +86 -85
- package/dist/native-document.dev.js +138 -122
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.devtools.min.js +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/core/data/ObservableItem.js +102 -80
- package/src/core/elements/control/for-each-array.js +1 -1
- package/src/core/wrappers/AttributesWrapper.js +3 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var NativeDocument = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager = {};
|
|
4
|
+
let DebugManager$1 = {};
|
|
5
5
|
|
|
6
6
|
{
|
|
7
|
-
DebugManager = {
|
|
7
|
+
DebugManager$1 = {
|
|
8
8
|
enabled: false,
|
|
9
9
|
|
|
10
10
|
enable() {
|
|
@@ -35,7 +35,7 @@ var NativeDocument = (function (exports) {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
}
|
|
38
|
-
var DebugManager
|
|
38
|
+
var DebugManager = DebugManager$1;
|
|
39
39
|
|
|
40
40
|
const MemoryManager = (function() {
|
|
41
41
|
|
|
@@ -84,7 +84,7 @@ var NativeDocument = (function (exports) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
if (cleanedCount > 0) {
|
|
87
|
-
DebugManager
|
|
87
|
+
DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -141,10 +141,10 @@ var NativeDocument = (function (exports) {
|
|
|
141
141
|
return this.observable.cleanup();
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
let PluginsManager = null;
|
|
144
|
+
let PluginsManager$1 = null;
|
|
145
145
|
|
|
146
146
|
{
|
|
147
|
-
PluginsManager = (function() {
|
|
147
|
+
PluginsManager$1 = (function() {
|
|
148
148
|
|
|
149
149
|
const $plugins = new Map();
|
|
150
150
|
const $pluginByEvents = new Map();
|
|
@@ -210,7 +210,7 @@ var NativeDocument = (function (exports) {
|
|
|
210
210
|
try{
|
|
211
211
|
callback.call(plugin, ...data);
|
|
212
212
|
} catch (error) {
|
|
213
|
-
DebugManager
|
|
213
|
+
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -219,7 +219,7 @@ var NativeDocument = (function (exports) {
|
|
|
219
219
|
}());
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
var PluginsManager
|
|
222
|
+
var PluginsManager = PluginsManager$1;
|
|
223
223
|
|
|
224
224
|
const ObservableWhen = function(observer, value) {
|
|
225
225
|
this.$target = value;
|
|
@@ -326,7 +326,9 @@ var NativeDocument = (function (exports) {
|
|
|
326
326
|
|
|
327
327
|
this.$previousValue = null;
|
|
328
328
|
this.$currentValue = value;
|
|
329
|
-
|
|
329
|
+
{
|
|
330
|
+
this.$isCleanedUp = false;
|
|
331
|
+
}
|
|
330
332
|
|
|
331
333
|
this.$firstListener = null;
|
|
332
334
|
this.$listeners = null;
|
|
@@ -341,7 +343,7 @@ var NativeDocument = (function (exports) {
|
|
|
341
343
|
}
|
|
342
344
|
}
|
|
343
345
|
{
|
|
344
|
-
PluginsManager
|
|
346
|
+
PluginsManager.emit('CreateObservable', this);
|
|
345
347
|
}
|
|
346
348
|
}
|
|
347
349
|
|
|
@@ -356,16 +358,16 @@ var NativeDocument = (function (exports) {
|
|
|
356
358
|
});
|
|
357
359
|
|
|
358
360
|
ObservableItem.prototype.__$isObservable = true;
|
|
359
|
-
const DEFAULT_OPERATIONS = {};
|
|
360
361
|
const noneTrigger = function() {};
|
|
361
362
|
|
|
362
363
|
ObservableItem.prototype.intercept = function(callback) {
|
|
363
364
|
this.$interceptor = callback;
|
|
365
|
+
this.set = this.$setWithInterceptor;
|
|
364
366
|
return this;
|
|
365
367
|
};
|
|
366
368
|
|
|
367
369
|
ObservableItem.prototype.triggerFirstListener = function(operations) {
|
|
368
|
-
this.$firstListener(this.$currentValue, this.$previousValue, operations
|
|
370
|
+
this.$firstListener(this.$currentValue, this.$previousValue, operations);
|
|
369
371
|
};
|
|
370
372
|
|
|
371
373
|
ObservableItem.prototype.triggerListeners = function(operations) {
|
|
@@ -373,33 +375,12 @@ var NativeDocument = (function (exports) {
|
|
|
373
375
|
const $previousValue = this.$previousValue;
|
|
374
376
|
const $currentValue = this.$currentValue;
|
|
375
377
|
|
|
376
|
-
operations = operations || DEFAULT_OPERATIONS;
|
|
377
378
|
for(let i = 0, length = $listeners.length; i < length; i++) {
|
|
378
379
|
$listeners[i]($currentValue, $previousValue, operations);
|
|
379
380
|
}
|
|
380
381
|
};
|
|
381
382
|
|
|
382
|
-
|
|
383
|
-
if(typeof callbacks === "function") {
|
|
384
|
-
callbacks(value);
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
if (callbacks.set) {
|
|
388
|
-
callbacks.set(value);
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
for(let i = 0, length = callbacks.length; i < length; i++) {
|
|
392
|
-
const callback = callbacks[i];
|
|
393
|
-
callback.set ? callback.set(value) : callback(value);
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
ObservableItem.prototype.triggerWatchers = function() {
|
|
399
|
-
if(!this.$watchers) {
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
|
|
383
|
+
ObservableItem.prototype.triggerWatchers = function(operations) {
|
|
403
384
|
const $watchers = this.$watchers;
|
|
404
385
|
const $previousValue = this.$previousValue;
|
|
405
386
|
const $currentValue = this.$currentValue;
|
|
@@ -407,20 +388,20 @@ var NativeDocument = (function (exports) {
|
|
|
407
388
|
const $currentValueCallbacks = $watchers.get($currentValue);
|
|
408
389
|
const $previousValueCallbacks = $watchers.get($previousValue);
|
|
409
390
|
if($currentValueCallbacks) {
|
|
410
|
-
|
|
391
|
+
$currentValueCallbacks(true, $previousValue, operations);
|
|
411
392
|
}
|
|
412
393
|
if($previousValueCallbacks) {
|
|
413
|
-
|
|
394
|
+
$previousValueCallbacks(false, $currentValue, operations);
|
|
414
395
|
}
|
|
415
396
|
};
|
|
416
397
|
|
|
417
398
|
ObservableItem.prototype.triggerAll = function(operations) {
|
|
418
|
-
this.triggerWatchers();
|
|
399
|
+
this.triggerWatchers(operations);
|
|
419
400
|
this.triggerListeners(operations);
|
|
420
401
|
};
|
|
421
402
|
|
|
422
403
|
ObservableItem.prototype.triggerWatchersAndFirstListener = function(operations) {
|
|
423
|
-
this.triggerWatchers();
|
|
404
|
+
this.triggerWatchers(operations);
|
|
424
405
|
this.triggerFirstListener(operations);
|
|
425
406
|
};
|
|
426
407
|
|
|
@@ -448,36 +429,47 @@ var NativeDocument = (function (exports) {
|
|
|
448
429
|
};
|
|
449
430
|
ObservableItem.prototype.trigger = noneTrigger;
|
|
450
431
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
*/
|
|
454
|
-
ObservableItem.prototype.set = function(data) {
|
|
455
|
-
let newValue = (typeof data === 'function') ? data(this.$currentValue) : data;
|
|
456
|
-
newValue = Validator.isObservable(newValue) ? newValue.val() : newValue;
|
|
457
|
-
|
|
458
|
-
if (this.$interceptor) {
|
|
459
|
-
const result = this.$interceptor(newValue, this.$currentValue);
|
|
460
|
-
|
|
461
|
-
if (result !== undefined) {
|
|
462
|
-
newValue = result;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
432
|
+
ObservableItem.prototype.$updateWithNewValue = function(newValue) {
|
|
433
|
+
newValue = newValue?.__$isObservable ? newValue.val() : newValue;
|
|
466
434
|
if(this.$currentValue === newValue) {
|
|
467
435
|
return;
|
|
468
436
|
}
|
|
469
437
|
this.$previousValue = this.$currentValue;
|
|
470
438
|
this.$currentValue = newValue;
|
|
471
439
|
{
|
|
472
|
-
PluginsManager
|
|
440
|
+
PluginsManager.emit('ObservableBeforeChange', this);
|
|
473
441
|
}
|
|
474
442
|
this.trigger();
|
|
475
443
|
this.$previousValue = null;
|
|
476
444
|
{
|
|
477
|
-
PluginsManager
|
|
445
|
+
PluginsManager.emit('ObservableAfterChange', this);
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @param {*} data
|
|
451
|
+
*/
|
|
452
|
+
ObservableItem.prototype.$setWithInterceptor = function(data) {
|
|
453
|
+
let newValue = (typeof data === 'function') ? data(this.$currentValue) : data;
|
|
454
|
+
const result = this.$interceptor(newValue, this.$currentValue);
|
|
455
|
+
|
|
456
|
+
if (result !== undefined) {
|
|
457
|
+
newValue = result;
|
|
478
458
|
}
|
|
459
|
+
|
|
460
|
+
this.$updateWithNewValue(newValue);
|
|
479
461
|
};
|
|
480
462
|
|
|
463
|
+
/**
|
|
464
|
+
* @param {*} data
|
|
465
|
+
*/
|
|
466
|
+
ObservableItem.prototype.$basicSet = function(data) {
|
|
467
|
+
let newValue = (typeof data === 'function') ? data(this.$currentValue) : data;
|
|
468
|
+
this.$updateWithNewValue(newValue);
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
ObservableItem.prototype.set = ObservableItem.prototype.$basicSet;
|
|
472
|
+
|
|
481
473
|
ObservableItem.prototype.val = function() {
|
|
482
474
|
return this.$currentValue;
|
|
483
475
|
};
|
|
@@ -513,38 +505,34 @@ var NativeDocument = (function (exports) {
|
|
|
513
505
|
}
|
|
514
506
|
MemoryManager.unregister(this.$memoryId);
|
|
515
507
|
this.disconnectAll();
|
|
516
|
-
|
|
508
|
+
{
|
|
509
|
+
this.$isCleanedUp = true;
|
|
510
|
+
}
|
|
517
511
|
delete this.$value;
|
|
518
512
|
};
|
|
519
513
|
|
|
520
514
|
/**
|
|
521
515
|
*
|
|
522
516
|
* @param {Function} callback
|
|
523
|
-
* @param {any} target
|
|
524
517
|
* @returns {(function(): void)}
|
|
525
518
|
*/
|
|
526
|
-
ObservableItem.prototype.subscribe = function(callback
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
519
|
+
ObservableItem.prototype.subscribe = function(callback) {
|
|
520
|
+
{
|
|
521
|
+
if (this.$isCleanedUp) {
|
|
522
|
+
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (typeof callback !== 'function') {
|
|
526
|
+
throw new NativeDocumentError('Callback must be a function');
|
|
527
|
+
}
|
|
534
528
|
}
|
|
529
|
+
this.$listeners = this.$listeners ?? [];
|
|
535
530
|
|
|
536
531
|
this.$listeners.push(callback);
|
|
537
532
|
this.assocTrigger();
|
|
538
533
|
{
|
|
539
|
-
PluginsManager
|
|
534
|
+
PluginsManager.emit('ObservableSubscribe', this);
|
|
540
535
|
}
|
|
541
|
-
return () => {
|
|
542
|
-
this.unsubscribe(callback);
|
|
543
|
-
this.assocTrigger();
|
|
544
|
-
{
|
|
545
|
-
PluginsManager$1.emit('ObservableUnsubscribe', this);
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
536
|
};
|
|
549
537
|
|
|
550
538
|
ObservableItem.prototype.on = function(value, callback) {
|
|
@@ -552,40 +540,66 @@ var NativeDocument = (function (exports) {
|
|
|
552
540
|
|
|
553
541
|
let watchValueList = this.$watchers.get(value);
|
|
554
542
|
|
|
543
|
+
if(callback.__$isObservable) {
|
|
544
|
+
callback = callback.set.bind(callback);
|
|
545
|
+
}
|
|
546
|
+
|
|
555
547
|
if(!watchValueList) {
|
|
548
|
+
watchValueList = callback;
|
|
556
549
|
this.$watchers.set(value, callback);
|
|
557
|
-
} else if(!Validator.isArray(watchValueList)) {
|
|
550
|
+
} else if(!Validator.isArray(watchValueList.list)) {
|
|
558
551
|
watchValueList = [watchValueList, callback];
|
|
559
|
-
|
|
552
|
+
callback = (value) => {
|
|
553
|
+
for(let i = 0, length = watchValueList.length; i < length; i++) {
|
|
554
|
+
watchValueList[i](value);
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
callback.list = watchValueList;
|
|
558
|
+
this.$watchers.set(value, callback);
|
|
560
559
|
} else {
|
|
561
|
-
watchValueList.push(callback);
|
|
560
|
+
watchValueList.list.push(callback);
|
|
562
561
|
}
|
|
563
562
|
|
|
564
563
|
this.assocTrigger();
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* @param {*} value
|
|
568
|
+
* @param {Function} callback - if omitted, removes all watchers for this value
|
|
569
|
+
*/
|
|
570
|
+
ObservableItem.prototype.off = function(value, callback) {
|
|
571
|
+
if(!this.$watchers) return;
|
|
572
|
+
|
|
573
|
+
const watchValueList = this.$watchers.get(value);
|
|
574
|
+
if(!watchValueList) return;
|
|
575
|
+
|
|
576
|
+
if(!callback || !Array.isArray(watchValueList.list)) {
|
|
577
|
+
this.$watchers?.delete(value);
|
|
575
578
|
this.assocTrigger();
|
|
576
|
-
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
const index = watchValueList.indexOf(callback);
|
|
582
|
+
watchValueList?.splice(index, 1);
|
|
583
|
+
if(watchValueList.length === 1) {
|
|
584
|
+
this.$watchers.set(value, watchValueList[0]);
|
|
585
|
+
}
|
|
586
|
+
else if(watchValueList.length === 0) {
|
|
587
|
+
this.$watchers?.delete(value);
|
|
588
|
+
watchValueList = null;
|
|
589
|
+
}
|
|
590
|
+
this.assocTrigger();
|
|
577
591
|
};
|
|
578
592
|
|
|
579
593
|
ObservableItem.prototype.once = function(predicate, callback) {
|
|
580
594
|
const fn = typeof predicate === 'function' ? predicate : (v) => v === predicate;
|
|
581
595
|
|
|
582
|
-
const
|
|
596
|
+
const handler = (val) => {
|
|
583
597
|
if (fn(val)) {
|
|
584
|
-
|
|
598
|
+
this.unsubscribe(handler);
|
|
585
599
|
callback(val);
|
|
586
600
|
}
|
|
587
|
-
}
|
|
588
|
-
|
|
601
|
+
};
|
|
602
|
+
this.subscribe(handler);
|
|
589
603
|
};
|
|
590
604
|
|
|
591
605
|
/**
|
|
@@ -593,11 +607,15 @@ var NativeDocument = (function (exports) {
|
|
|
593
607
|
* @param {Function} callback
|
|
594
608
|
*/
|
|
595
609
|
ObservableItem.prototype.unsubscribe = function(callback) {
|
|
610
|
+
if(!this.$listeners) return;
|
|
596
611
|
const index = this.$listeners.indexOf(callback);
|
|
597
612
|
if (index > -1) {
|
|
598
613
|
this.$listeners.splice(index, 1);
|
|
599
614
|
}
|
|
600
615
|
this.assocTrigger();
|
|
616
|
+
{
|
|
617
|
+
PluginsManager.emit('ObservableUnsubscribe', this);
|
|
618
|
+
}
|
|
601
619
|
};
|
|
602
620
|
|
|
603
621
|
/**
|
|
@@ -650,6 +668,10 @@ var NativeDocument = (function (exports) {
|
|
|
650
668
|
return String(this.$currentValue);
|
|
651
669
|
};
|
|
652
670
|
|
|
671
|
+
ObservableItem.prototype.valueOf = function() {
|
|
672
|
+
return this.$currentValue;
|
|
673
|
+
};
|
|
674
|
+
|
|
653
675
|
const DocumentObserver = {
|
|
654
676
|
mounted: new WeakMap(),
|
|
655
677
|
mountedSupposedSize: 0,
|
|
@@ -757,7 +779,7 @@ var NativeDocument = (function (exports) {
|
|
|
757
779
|
this.$element = element;
|
|
758
780
|
this.$observer = null;
|
|
759
781
|
{
|
|
760
|
-
PluginsManager
|
|
782
|
+
PluginsManager.emit('NDElementCreated', element, this);
|
|
761
783
|
}
|
|
762
784
|
}
|
|
763
785
|
|
|
@@ -878,7 +900,7 @@ var NativeDocument = (function (exports) {
|
|
|
878
900
|
}
|
|
879
901
|
{
|
|
880
902
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
881
|
-
DebugManager
|
|
903
|
+
DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
882
904
|
}
|
|
883
905
|
this.$localExtensions.set(name, method);
|
|
884
906
|
}
|
|
@@ -912,23 +934,23 @@ var NativeDocument = (function (exports) {
|
|
|
912
934
|
const method = methods[name];
|
|
913
935
|
|
|
914
936
|
if (typeof method !== 'function') {
|
|
915
|
-
DebugManager
|
|
937
|
+
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
916
938
|
continue;
|
|
917
939
|
}
|
|
918
940
|
|
|
919
941
|
if (protectedMethods.has(name)) {
|
|
920
|
-
DebugManager
|
|
942
|
+
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
921
943
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
922
944
|
}
|
|
923
945
|
|
|
924
946
|
if (NDElement.prototype[name]) {
|
|
925
|
-
DebugManager
|
|
947
|
+
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
926
948
|
}
|
|
927
949
|
|
|
928
950
|
NDElement.prototype[name] = method;
|
|
929
951
|
}
|
|
930
952
|
{
|
|
931
|
-
PluginsManager
|
|
953
|
+
PluginsManager.emit('NDElementExtended', methods);
|
|
932
954
|
}
|
|
933
955
|
|
|
934
956
|
return NDElement;
|
|
@@ -1081,7 +1103,7 @@ var NativeDocument = (function (exports) {
|
|
|
1081
1103
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
1082
1104
|
|
|
1083
1105
|
if (foundReserved.length > 0) {
|
|
1084
|
-
DebugManager
|
|
1106
|
+
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1085
1107
|
}
|
|
1086
1108
|
|
|
1087
1109
|
return attributes;
|
|
@@ -1129,7 +1151,7 @@ var NativeDocument = (function (exports) {
|
|
|
1129
1151
|
anchorFragment.appendChild = function(child, before = null) {
|
|
1130
1152
|
const parent = anchorEnd.parentNode;
|
|
1131
1153
|
if(!parent) {
|
|
1132
|
-
DebugManager
|
|
1154
|
+
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1133
1155
|
return;
|
|
1134
1156
|
}
|
|
1135
1157
|
before = before ?? anchorEnd;
|
|
@@ -1349,9 +1371,7 @@ var NativeDocument = (function (exports) {
|
|
|
1349
1371
|
* @param {Object} data
|
|
1350
1372
|
*/
|
|
1351
1373
|
function bindClassAttribute(element, data) {
|
|
1352
|
-
const
|
|
1353
|
-
for(let i = 0, length = classNames.length; i < length; i++) {
|
|
1354
|
-
const className = classNames[i];
|
|
1374
|
+
for(const className in data) {
|
|
1355
1375
|
const value = data[className];
|
|
1356
1376
|
if(value.__$isObservable) {
|
|
1357
1377
|
element.classes.toggle(className, value.val());
|
|
@@ -1378,9 +1398,7 @@ var NativeDocument = (function (exports) {
|
|
|
1378
1398
|
* @param {Object} data
|
|
1379
1399
|
*/
|
|
1380
1400
|
function bindStyleAttribute(element, data) {
|
|
1381
|
-
const
|
|
1382
|
-
for(let i = 0, length = keys.length; i < length; i++) {
|
|
1383
|
-
const styleName = keys[i];
|
|
1401
|
+
for(const styleName in data) {
|
|
1384
1402
|
const value = data[styleName];
|
|
1385
1403
|
if(value.__$isObservable) {
|
|
1386
1404
|
element.style[styleName] = value.val();
|
|
@@ -1448,10 +1466,8 @@ var NativeDocument = (function (exports) {
|
|
|
1448
1466
|
function AttributesWrapper(element, attributes) {
|
|
1449
1467
|
|
|
1450
1468
|
Validator.validateAttributes(attributes);
|
|
1451
|
-
const attributesKeys = Object.keys(attributes);
|
|
1452
1469
|
|
|
1453
|
-
for(
|
|
1454
|
-
const originalAttributeName = attributesKeys[i];
|
|
1470
|
+
for(const originalAttributeName in attributes) {
|
|
1455
1471
|
const attributeName = originalAttributeName.toLowerCase();
|
|
1456
1472
|
let value = attributes[originalAttributeName];
|
|
1457
1473
|
if(value == null) {
|
|
@@ -1526,7 +1542,7 @@ var NativeDocument = (function (exports) {
|
|
|
1526
1542
|
Function.prototype.toNdElement = function () {
|
|
1527
1543
|
const child = this;
|
|
1528
1544
|
{
|
|
1529
|
-
PluginsManager
|
|
1545
|
+
PluginsManager.emit('BeforeProcessComponent', child);
|
|
1530
1546
|
}
|
|
1531
1547
|
return ElementCreator.getChild(child());
|
|
1532
1548
|
};
|
|
@@ -1632,14 +1648,14 @@ var NativeDocument = (function (exports) {
|
|
|
1632
1648
|
processChildren(children, parent) {
|
|
1633
1649
|
if(children === null) return;
|
|
1634
1650
|
{
|
|
1635
|
-
PluginsManager
|
|
1651
|
+
PluginsManager.emit('BeforeProcessChildren', parent);
|
|
1636
1652
|
}
|
|
1637
1653
|
let child = this.getChild(children);
|
|
1638
1654
|
if(child) {
|
|
1639
1655
|
parent.appendChild(child);
|
|
1640
1656
|
}
|
|
1641
1657
|
{
|
|
1642
|
-
PluginsManager
|
|
1658
|
+
PluginsManager.emit('AfterProcessChildren', parent);
|
|
1643
1659
|
}
|
|
1644
1660
|
},
|
|
1645
1661
|
getChild(child) {
|
|
@@ -2864,7 +2880,7 @@ var NativeDocument = (function (exports) {
|
|
|
2864
2880
|
|
|
2865
2881
|
ObservableItem.call(this, target, configs);
|
|
2866
2882
|
{
|
|
2867
|
-
PluginsManager
|
|
2883
|
+
PluginsManager.emit('CreateObservableArray', this);
|
|
2868
2884
|
}
|
|
2869
2885
|
};
|
|
2870
2886
|
|
|
@@ -3265,7 +3281,7 @@ var NativeDocument = (function (exports) {
|
|
|
3265
3281
|
const observable = new ObservableItem(initialValue);
|
|
3266
3282
|
const updatedValue = nextTick(() => observable.set(callback()));
|
|
3267
3283
|
{
|
|
3268
|
-
PluginsManager
|
|
3284
|
+
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
3269
3285
|
}
|
|
3270
3286
|
|
|
3271
3287
|
if(Validator.isFunction(dependencies)) {
|
|
@@ -3425,7 +3441,7 @@ var NativeDocument = (function (exports) {
|
|
|
3425
3441
|
}
|
|
3426
3442
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
3427
3443
|
} catch (e) {
|
|
3428
|
-
DebugManager
|
|
3444
|
+
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3429
3445
|
throw e;
|
|
3430
3446
|
}
|
|
3431
3447
|
return keyId;
|
|
@@ -3729,7 +3745,7 @@ var NativeDocument = (function (exports) {
|
|
|
3729
3745
|
};
|
|
3730
3746
|
|
|
3731
3747
|
const buildContent = (items, _, operations) => {
|
|
3732
|
-
if(operations
|
|
3748
|
+
if(operations?.action === 'clear' || !items.length) {
|
|
3733
3749
|
if(lastNumberOfItems === 0) {
|
|
3734
3750
|
return;
|
|
3735
3751
|
}
|
|
@@ -3771,7 +3787,7 @@ var NativeDocument = (function (exports) {
|
|
|
3771
3787
|
*/
|
|
3772
3788
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
3773
3789
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
3774
|
-
return DebugManager
|
|
3790
|
+
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3775
3791
|
}
|
|
3776
3792
|
const element = Anchor('Show if : '+(comment || ''));
|
|
3777
3793
|
|
|
@@ -4558,7 +4574,7 @@ var NativeDocument = (function (exports) {
|
|
|
4558
4574
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4559
4575
|
this.handleRouteChange(route, params, query, path);
|
|
4560
4576
|
} catch (e) {
|
|
4561
|
-
DebugManager
|
|
4577
|
+
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
4562
4578
|
}
|
|
4563
4579
|
};
|
|
4564
4580
|
/**
|
|
@@ -4571,7 +4587,7 @@ var NativeDocument = (function (exports) {
|
|
|
4571
4587
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4572
4588
|
this.handleRouteChange(route, params, {}, path);
|
|
4573
4589
|
} catch(e) {
|
|
4574
|
-
DebugManager
|
|
4590
|
+
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
4575
4591
|
}
|
|
4576
4592
|
};
|
|
4577
4593
|
this.forward = function() {
|
|
@@ -4598,7 +4614,7 @@ var NativeDocument = (function (exports) {
|
|
|
4598
4614
|
}
|
|
4599
4615
|
this.handleRouteChange(route, params, query, path);
|
|
4600
4616
|
} catch(e) {
|
|
4601
|
-
DebugManager
|
|
4617
|
+
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
4602
4618
|
}
|
|
4603
4619
|
});
|
|
4604
4620
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -4823,7 +4839,7 @@ var NativeDocument = (function (exports) {
|
|
|
4823
4839
|
listener(request);
|
|
4824
4840
|
next && next(request);
|
|
4825
4841
|
} catch (e) {
|
|
4826
|
-
DebugManager
|
|
4842
|
+
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
4827
4843
|
}
|
|
4828
4844
|
}
|
|
4829
4845
|
};
|
|
@@ -4982,7 +4998,7 @@ var NativeDocument = (function (exports) {
|
|
|
4982
4998
|
*/
|
|
4983
4999
|
Router.create = function(options, callback) {
|
|
4984
5000
|
if(!Validator.isFunction(callback)) {
|
|
4985
|
-
DebugManager
|
|
5001
|
+
DebugManager.error('Router', 'Callback must be a function', e);
|
|
4986
5002
|
throw new RouterError('Callback must be a function');
|
|
4987
5003
|
}
|
|
4988
5004
|
const router = new Router(options);
|
|
@@ -5166,7 +5182,7 @@ var NativeDocument = (function (exports) {
|
|
|
5166
5182
|
exports.HtmlElementWrapper = HtmlElementWrapper;
|
|
5167
5183
|
exports.NDElement = NDElement;
|
|
5168
5184
|
exports.Observable = Observable;
|
|
5169
|
-
exports.PluginsManager = PluginsManager
|
|
5185
|
+
exports.PluginsManager = PluginsManager;
|
|
5170
5186
|
exports.SingletonView = SingletonView;
|
|
5171
5187
|
exports.Store = Store;
|
|
5172
5188
|
exports.TemplateCloner = TemplateCloner;
|