native-document 1.0.122 → 1.0.124
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 +41 -53
- package/dist/native-document.dev.js +89 -106
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/core/data/ObservableChecker.js +1 -0
- package/src/core/data/ObservableItem.js +1 -0
- package/src/core/data/ObservableWhen.js +1 -0
- package/src/core/wrappers/AttributesWrapper.js +34 -32
- package/src/core/wrappers/prototypes/bind-class-extensions.js +0 -22
- package/src/core/wrappers/template-cloner/NodeCloner.js +4 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var NativeDocument = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager$
|
|
4
|
+
let DebugManager$2 = {};
|
|
5
5
|
|
|
6
6
|
{
|
|
7
|
-
DebugManager$
|
|
7
|
+
DebugManager$2 = {
|
|
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$1 = DebugManager$2;
|
|
39
39
|
|
|
40
40
|
class NativeDocumentError extends Error {
|
|
41
41
|
constructor(message, context = {}) {
|
|
@@ -58,6 +58,7 @@ var NativeDocument = (function (exports) {
|
|
|
58
58
|
this.unSubscriptions = [];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
ObservableChecker.prototype.__$Observable = true;
|
|
61
62
|
ObservableChecker.prototype.__$isObservableChecker = true;
|
|
62
63
|
|
|
63
64
|
/**
|
|
@@ -313,10 +314,10 @@ var NativeDocument = (function (exports) {
|
|
|
313
314
|
subtree: true,
|
|
314
315
|
});
|
|
315
316
|
|
|
316
|
-
let PluginsManager = null;
|
|
317
|
+
let PluginsManager$1 = null;
|
|
317
318
|
|
|
318
319
|
{
|
|
319
|
-
PluginsManager = (function() {
|
|
320
|
+
PluginsManager$1 = (function() {
|
|
320
321
|
|
|
321
322
|
const $plugins = new Map();
|
|
322
323
|
const $pluginByEvents = new Map();
|
|
@@ -382,7 +383,7 @@ var NativeDocument = (function (exports) {
|
|
|
382
383
|
try{
|
|
383
384
|
callback.call(plugin, ...data);
|
|
384
385
|
} catch (error) {
|
|
385
|
-
DebugManager$
|
|
386
|
+
DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
386
387
|
}
|
|
387
388
|
}
|
|
388
389
|
}
|
|
@@ -391,12 +392,12 @@ var NativeDocument = (function (exports) {
|
|
|
391
392
|
}());
|
|
392
393
|
}
|
|
393
394
|
|
|
394
|
-
var PluginsManager
|
|
395
|
+
var PluginsManager = PluginsManager$1;
|
|
395
396
|
|
|
396
397
|
function NDElement(element) {
|
|
397
398
|
this.$element = element;
|
|
398
399
|
{
|
|
399
|
-
PluginsManager
|
|
400
|
+
PluginsManager.emit('NDElementCreated', element, this);
|
|
400
401
|
}
|
|
401
402
|
}
|
|
402
403
|
|
|
@@ -561,7 +562,7 @@ var NativeDocument = (function (exports) {
|
|
|
561
562
|
}
|
|
562
563
|
{
|
|
563
564
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
564
|
-
DebugManager$
|
|
565
|
+
DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
565
566
|
}
|
|
566
567
|
this.$localExtensions.set(name, method);
|
|
567
568
|
}
|
|
@@ -612,23 +613,23 @@ var NativeDocument = (function (exports) {
|
|
|
612
613
|
const method = methods[name];
|
|
613
614
|
|
|
614
615
|
if (typeof method !== 'function') {
|
|
615
|
-
DebugManager$
|
|
616
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
616
617
|
continue;
|
|
617
618
|
}
|
|
618
619
|
|
|
619
620
|
if (protectedMethods.has(name)) {
|
|
620
|
-
DebugManager$
|
|
621
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
621
622
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
622
623
|
}
|
|
623
624
|
|
|
624
625
|
if (NDElement.prototype[name]) {
|
|
625
|
-
DebugManager$
|
|
626
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
626
627
|
}
|
|
627
628
|
|
|
628
629
|
NDElement.prototype[name] = method;
|
|
629
630
|
}
|
|
630
631
|
{
|
|
631
|
-
PluginsManager
|
|
632
|
+
PluginsManager.emit('NDElementExtended', methods);
|
|
632
633
|
}
|
|
633
634
|
|
|
634
635
|
return NDElement;
|
|
@@ -779,7 +780,7 @@ var NativeDocument = (function (exports) {
|
|
|
779
780
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
780
781
|
|
|
781
782
|
if (foundReserved.length > 0) {
|
|
782
|
-
DebugManager$
|
|
783
|
+
DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
783
784
|
}
|
|
784
785
|
|
|
785
786
|
return attributes;
|
|
@@ -866,7 +867,7 @@ var NativeDocument = (function (exports) {
|
|
|
866
867
|
}
|
|
867
868
|
}
|
|
868
869
|
if (cleanedCount > 0) {
|
|
869
|
-
DebugManager$
|
|
870
|
+
DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
870
871
|
}
|
|
871
872
|
}
|
|
872
873
|
};
|
|
@@ -884,6 +885,7 @@ var NativeDocument = (function (exports) {
|
|
|
884
885
|
this.$observer = observer;
|
|
885
886
|
};
|
|
886
887
|
|
|
888
|
+
ObservableWhen.prototype.__$Observable = true;
|
|
887
889
|
ObservableWhen.prototype.__$isObservableWhen = true;
|
|
888
890
|
|
|
889
891
|
/**
|
|
@@ -1176,7 +1178,7 @@ var NativeDocument = (function (exports) {
|
|
|
1176
1178
|
}
|
|
1177
1179
|
}
|
|
1178
1180
|
{
|
|
1179
|
-
PluginsManager
|
|
1181
|
+
PluginsManager.emit('CreateObservable', this);
|
|
1180
1182
|
}
|
|
1181
1183
|
}
|
|
1182
1184
|
|
|
@@ -1190,6 +1192,7 @@ var NativeDocument = (function (exports) {
|
|
|
1190
1192
|
configurable: true,
|
|
1191
1193
|
});
|
|
1192
1194
|
|
|
1195
|
+
ObservableItem.prototype.__$Observable = true;
|
|
1193
1196
|
ObservableItem.prototype.__$isObservable = true;
|
|
1194
1197
|
const noneTrigger = function() {};
|
|
1195
1198
|
|
|
@@ -1282,12 +1285,12 @@ var NativeDocument = (function (exports) {
|
|
|
1282
1285
|
this.$previousValue = this.$currentValue;
|
|
1283
1286
|
this.$currentValue = newValue;
|
|
1284
1287
|
{
|
|
1285
|
-
PluginsManager
|
|
1288
|
+
PluginsManager.emit('ObservableBeforeChange', this);
|
|
1286
1289
|
}
|
|
1287
1290
|
this.trigger($setOperation);
|
|
1288
1291
|
this.$previousValue = null;
|
|
1289
1292
|
{
|
|
1290
|
-
PluginsManager
|
|
1293
|
+
PluginsManager.emit('ObservableAfterChange', this);
|
|
1291
1294
|
}
|
|
1292
1295
|
};
|
|
1293
1296
|
|
|
@@ -1365,7 +1368,7 @@ var NativeDocument = (function (exports) {
|
|
|
1365
1368
|
ObservableItem.prototype.subscribe = function(callback) {
|
|
1366
1369
|
{
|
|
1367
1370
|
if (this.$isCleanedUp) {
|
|
1368
|
-
DebugManager$
|
|
1371
|
+
DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
1369
1372
|
return;
|
|
1370
1373
|
}
|
|
1371
1374
|
if (typeof callback !== 'function') {
|
|
@@ -1377,7 +1380,7 @@ var NativeDocument = (function (exports) {
|
|
|
1377
1380
|
this.$listeners.push(callback);
|
|
1378
1381
|
this.assocTrigger();
|
|
1379
1382
|
{
|
|
1380
|
-
PluginsManager
|
|
1383
|
+
PluginsManager.emit('ObservableSubscribe', this);
|
|
1381
1384
|
}
|
|
1382
1385
|
};
|
|
1383
1386
|
|
|
@@ -1488,7 +1491,7 @@ var NativeDocument = (function (exports) {
|
|
|
1488
1491
|
}
|
|
1489
1492
|
this.assocTrigger();
|
|
1490
1493
|
{
|
|
1491
|
-
PluginsManager
|
|
1494
|
+
PluginsManager.emit('ObservableUnsubscribe', this);
|
|
1492
1495
|
}
|
|
1493
1496
|
};
|
|
1494
1497
|
|
|
@@ -1788,7 +1791,17 @@ var NativeDocument = (function (exports) {
|
|
|
1788
1791
|
*/
|
|
1789
1792
|
const bindClassAttribute = (element, data) => {
|
|
1790
1793
|
for(const className in data) {
|
|
1791
|
-
data[className]
|
|
1794
|
+
const value = data[className];
|
|
1795
|
+
if(value.__$Observable) {
|
|
1796
|
+
element.classes.toggle(className, value.val());
|
|
1797
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1798
|
+
continue;
|
|
1799
|
+
}
|
|
1800
|
+
if(value.$hydrate) {
|
|
1801
|
+
value.$hydrate(element, className);
|
|
1802
|
+
continue;
|
|
1803
|
+
}
|
|
1804
|
+
element.classes.toggle(className, value);
|
|
1792
1805
|
}
|
|
1793
1806
|
};
|
|
1794
1807
|
|
|
@@ -1858,35 +1871,6 @@ var NativeDocument = (function (exports) {
|
|
|
1858
1871
|
element.setAttribute(attributeName, value.val());
|
|
1859
1872
|
};
|
|
1860
1873
|
|
|
1861
|
-
|
|
1862
|
-
const AttributeHandlers = {
|
|
1863
|
-
string: (element, attributeName, value) => element.setAttribute(attributeName, value),
|
|
1864
|
-
number: (element, attributeName, value) => element.setAttribute(attributeName, value),
|
|
1865
|
-
boolean: (element, attributeName, value) => bindBooleanAttribute(element, attributeName, value),
|
|
1866
|
-
object: (element, attributeName, value) => {
|
|
1867
|
-
if(value == null) {
|
|
1868
|
-
return;
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
|
-
if(value.handleNdAttribute) {
|
|
1872
|
-
value.handleNdAttribute(element, attributeName);
|
|
1873
|
-
return;
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
|
-
if(attributeName === 'class') {
|
|
1877
|
-
bindClassAttribute(element, value);
|
|
1878
|
-
return;
|
|
1879
|
-
}
|
|
1880
|
-
if(attributeName === 'style') {
|
|
1881
|
-
bindStyleAttribute(element, value);
|
|
1882
|
-
return;
|
|
1883
|
-
}
|
|
1884
|
-
if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
|
|
1885
|
-
bindBooleanAttribute(element, attributeName, value);
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
};
|
|
1889
|
-
|
|
1890
1874
|
/**
|
|
1891
1875
|
*
|
|
1892
1876
|
* @param {HTMLElement} element
|
|
@@ -1901,8 +1885,29 @@ var NativeDocument = (function (exports) {
|
|
|
1901
1885
|
for(const originalAttributeName in attributes) {
|
|
1902
1886
|
const attributeName = originalAttributeName.toLowerCase();
|
|
1903
1887
|
let value = attributes[originalAttributeName];
|
|
1904
|
-
|
|
1905
|
-
|
|
1888
|
+
if(value == null) {
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
if(value.handleNdAttribute) {
|
|
1892
|
+
value.handleNdAttribute(element, attributeName, value);
|
|
1893
|
+
continue;
|
|
1894
|
+
}
|
|
1895
|
+
if(typeof value === 'object') {
|
|
1896
|
+
if(attributeName === 'class') {
|
|
1897
|
+
bindClassAttribute(element, value);
|
|
1898
|
+
continue;
|
|
1899
|
+
}
|
|
1900
|
+
if(attributeName === 'style') {
|
|
1901
|
+
bindStyleAttribute(element, value);
|
|
1902
|
+
continue;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
|
|
1906
|
+
bindBooleanAttribute(element, attributeName, value);
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
element.setAttribute(attributeName, value);
|
|
1906
1911
|
}
|
|
1907
1912
|
return element;
|
|
1908
1913
|
};
|
|
@@ -1960,7 +1965,7 @@ var NativeDocument = (function (exports) {
|
|
|
1960
1965
|
Function.prototype.toNdElement = function () {
|
|
1961
1966
|
const child = this;
|
|
1962
1967
|
{
|
|
1963
|
-
PluginsManager
|
|
1968
|
+
PluginsManager.emit('BeforeProcessComponent', child);
|
|
1964
1969
|
}
|
|
1965
1970
|
return ElementCreator.getChild(child());
|
|
1966
1971
|
};
|
|
@@ -2068,24 +2073,6 @@ var NativeDocument = (function (exports) {
|
|
|
2068
2073
|
this.$hydrate(element, attributeName);
|
|
2069
2074
|
};
|
|
2070
2075
|
|
|
2071
|
-
ObservableItem.prototype.bindClassProperty = function(element, className) {
|
|
2072
|
-
element.classes.toggle(className, this.val());
|
|
2073
|
-
this.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
2074
|
-
};
|
|
2075
|
-
|
|
2076
|
-
ObservableWhen.prototype.bindClassProperty = function(element, className) {
|
|
2077
|
-
element.classes.toggle(className, this.isActive());
|
|
2078
|
-
this.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
2079
|
-
};
|
|
2080
|
-
|
|
2081
|
-
TemplateBinding.prototype.bindClassProperty = function(element, className) {
|
|
2082
|
-
this.$hydrate(element, className);
|
|
2083
|
-
};
|
|
2084
|
-
|
|
2085
|
-
Boolean.prototype.bindClassProperty = function(element, className) {
|
|
2086
|
-
element.classes.toggle(className, this);
|
|
2087
|
-
};
|
|
2088
|
-
|
|
2089
2076
|
let $textNodeCache = null;
|
|
2090
2077
|
|
|
2091
2078
|
const ElementCreator = {
|
|
@@ -2161,14 +2148,14 @@ var NativeDocument = (function (exports) {
|
|
|
2161
2148
|
processChildren: (children, parent) => {
|
|
2162
2149
|
if(children === null) return;
|
|
2163
2150
|
{
|
|
2164
|
-
PluginsManager
|
|
2151
|
+
PluginsManager.emit('BeforeProcessChildren', parent);
|
|
2165
2152
|
}
|
|
2166
2153
|
let child = ElementCreator.getChild(children);
|
|
2167
2154
|
if(child) {
|
|
2168
2155
|
parent.appendChild(child);
|
|
2169
2156
|
}
|
|
2170
2157
|
{
|
|
2171
|
-
PluginsManager
|
|
2158
|
+
PluginsManager.emit('AfterProcessChildren', parent);
|
|
2172
2159
|
}
|
|
2173
2160
|
},
|
|
2174
2161
|
async safeRemove(element) {
|
|
@@ -3046,22 +3033,19 @@ var NativeDocument = (function (exports) {
|
|
|
3046
3033
|
}
|
|
3047
3034
|
}
|
|
3048
3035
|
if(this.$classes) {
|
|
3036
|
+
const cache = {};
|
|
3049
3037
|
const keys = Object.keys(this.$classes);
|
|
3050
3038
|
|
|
3051
3039
|
if(keys.length === 1) {
|
|
3052
3040
|
const key = keys[0];
|
|
3053
3041
|
const callback = this.$classes[key];
|
|
3054
3042
|
steps.push((clonedNode, data) => {
|
|
3055
|
-
callback.apply(null, data)
|
|
3043
|
+
cache[key] = callback.apply(null, data);
|
|
3044
|
+
ElementCreator.processClassAttribute(clonedNode, cache);
|
|
3056
3045
|
});
|
|
3057
3046
|
} else {
|
|
3058
|
-
const properties = this.$classes;
|
|
3059
|
-
const keysLength = keys.length;
|
|
3060
3047
|
steps.push((clonedNode, data) => {
|
|
3061
|
-
|
|
3062
|
-
const key = keys[i];
|
|
3063
|
-
properties[key].apply(null, data).bindClassProperty(clonedNode, key);
|
|
3064
|
-
}
|
|
3048
|
+
ElementCreator.processClassAttribute(clonedNode, buildProperties(cache, this.$classes, data));
|
|
3065
3049
|
});
|
|
3066
3050
|
}
|
|
3067
3051
|
}
|
|
@@ -3856,7 +3840,7 @@ var NativeDocument = (function (exports) {
|
|
|
3856
3840
|
|
|
3857
3841
|
ObservableItem.call(this, target, configs);
|
|
3858
3842
|
{
|
|
3859
|
-
PluginsManager
|
|
3843
|
+
PluginsManager.emit('CreateObservableArray', this);
|
|
3860
3844
|
}
|
|
3861
3845
|
};
|
|
3862
3846
|
|
|
@@ -4490,7 +4474,7 @@ var NativeDocument = (function (exports) {
|
|
|
4490
4474
|
const observable = new ObservableItem(initialValue);
|
|
4491
4475
|
const updatedValue = nextTick(() => observable.set(callback()));
|
|
4492
4476
|
{
|
|
4493
|
-
PluginsManager
|
|
4477
|
+
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
4494
4478
|
}
|
|
4495
4479
|
|
|
4496
4480
|
if(Validator.isFunction(dependencies)) {
|
|
@@ -4525,7 +4509,7 @@ var NativeDocument = (function (exports) {
|
|
|
4525
4509
|
const $getStoreOrThrow = (method, name) => {
|
|
4526
4510
|
const item = $stores.get(name);
|
|
4527
4511
|
if (!item) {
|
|
4528
|
-
DebugManager$
|
|
4512
|
+
DebugManager$1.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
|
|
4529
4513
|
throw new NativeDocumentError(
|
|
4530
4514
|
`Store.${method}('${name}') : store not found.`
|
|
4531
4515
|
);
|
|
@@ -4538,7 +4522,7 @@ var NativeDocument = (function (exports) {
|
|
|
4538
4522
|
*/
|
|
4539
4523
|
const $applyReadOnly = (observer, name, context) => {
|
|
4540
4524
|
const readOnlyError = (method) => () => {
|
|
4541
|
-
DebugManager$
|
|
4525
|
+
DebugManager$1.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
|
|
4542
4526
|
throw new NativeDocumentError(
|
|
4543
4527
|
`Store.${context}('${name}') is read-only.`
|
|
4544
4528
|
);
|
|
@@ -4569,7 +4553,7 @@ var NativeDocument = (function (exports) {
|
|
|
4569
4553
|
*/
|
|
4570
4554
|
create(name, value) {
|
|
4571
4555
|
if ($stores.has(name)) {
|
|
4572
|
-
DebugManager$
|
|
4556
|
+
DebugManager$1.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
|
|
4573
4557
|
throw new NativeDocumentError(
|
|
4574
4558
|
`Store.create('${name}') : a store with this name already exists.`
|
|
4575
4559
|
);
|
|
@@ -4590,7 +4574,7 @@ var NativeDocument = (function (exports) {
|
|
|
4590
4574
|
*/
|
|
4591
4575
|
createResettable(name, value) {
|
|
4592
4576
|
if ($stores.has(name)) {
|
|
4593
|
-
DebugManager$
|
|
4577
|
+
DebugManager$1.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
|
|
4594
4578
|
throw new NativeDocumentError(
|
|
4595
4579
|
`Store.createResettable('${name}') : a store with this name already exists.`
|
|
4596
4580
|
);
|
|
@@ -4626,7 +4610,7 @@ var NativeDocument = (function (exports) {
|
|
|
4626
4610
|
*/
|
|
4627
4611
|
createComposed(name, computation, dependencies) {
|
|
4628
4612
|
if ($stores.has(name)) {
|
|
4629
|
-
DebugManager$
|
|
4613
|
+
DebugManager$1.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
|
|
4630
4614
|
throw new NativeDocumentError(
|
|
4631
4615
|
`Store.createComposed('${name}') : a store with this name already exists.`
|
|
4632
4616
|
);
|
|
@@ -4649,7 +4633,7 @@ var NativeDocument = (function (exports) {
|
|
|
4649
4633
|
}
|
|
4650
4634
|
const depItem = $stores.get(depName);
|
|
4651
4635
|
if (!depItem) {
|
|
4652
|
-
DebugManager$
|
|
4636
|
+
DebugManager$1.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
|
|
4653
4637
|
throw new NativeDocumentError(
|
|
4654
4638
|
`Store.createComposed('${name}') : dependency store '${depName}' not found.`
|
|
4655
4639
|
);
|
|
@@ -4683,13 +4667,13 @@ var NativeDocument = (function (exports) {
|
|
|
4683
4667
|
reset(name) {
|
|
4684
4668
|
const item = $getStoreOrThrow('reset', name);
|
|
4685
4669
|
if (item.composed) {
|
|
4686
|
-
DebugManager$
|
|
4670
|
+
DebugManager$1.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
|
|
4687
4671
|
throw new NativeDocumentError(
|
|
4688
4672
|
`Store.reset('${name}') : composed stores cannot be reset.`
|
|
4689
4673
|
);
|
|
4690
4674
|
}
|
|
4691
4675
|
if (!item.resettable) {
|
|
4692
|
-
DebugManager$
|
|
4676
|
+
DebugManager$1.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
|
|
4693
4677
|
throw new NativeDocumentError(
|
|
4694
4678
|
`Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
|
|
4695
4679
|
);
|
|
@@ -4710,7 +4694,7 @@ var NativeDocument = (function (exports) {
|
|
|
4710
4694
|
const item = $getStoreOrThrow('use', name);
|
|
4711
4695
|
|
|
4712
4696
|
if (item.composed) {
|
|
4713
|
-
DebugManager$
|
|
4697
|
+
DebugManager$1.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
|
|
4714
4698
|
throw new NativeDocumentError(
|
|
4715
4699
|
`Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
|
|
4716
4700
|
);
|
|
@@ -4777,7 +4761,7 @@ var NativeDocument = (function (exports) {
|
|
|
4777
4761
|
get(name) {
|
|
4778
4762
|
const item = $stores.get(name);
|
|
4779
4763
|
if (!item) {
|
|
4780
|
-
DebugManager$
|
|
4764
|
+
DebugManager$1.warn('Store', `Store.get('${name}') : store not found.`);
|
|
4781
4765
|
return null;
|
|
4782
4766
|
}
|
|
4783
4767
|
return item.observer;
|
|
@@ -4799,7 +4783,7 @@ var NativeDocument = (function (exports) {
|
|
|
4799
4783
|
delete(name) {
|
|
4800
4784
|
const item = $stores.get(name);
|
|
4801
4785
|
if (!item) {
|
|
4802
|
-
DebugManager$
|
|
4786
|
+
DebugManager$1.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
|
|
4803
4787
|
return;
|
|
4804
4788
|
}
|
|
4805
4789
|
item.subscribers.forEach(follower => follower.destroy());
|
|
@@ -4901,7 +4885,7 @@ var NativeDocument = (function (exports) {
|
|
|
4901
4885
|
return undefined;
|
|
4902
4886
|
},
|
|
4903
4887
|
set(target, prop, value) {
|
|
4904
|
-
DebugManager$
|
|
4888
|
+
DebugManager$1.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
|
|
4905
4889
|
throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
|
|
4906
4890
|
},
|
|
4907
4891
|
deleteProperty(target, prop) {
|
|
@@ -4989,7 +4973,7 @@ var NativeDocument = (function (exports) {
|
|
|
4989
4973
|
}
|
|
4990
4974
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
4991
4975
|
} catch (e) {
|
|
4992
|
-
DebugManager$
|
|
4976
|
+
DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
4993
4977
|
throw e;
|
|
4994
4978
|
}
|
|
4995
4979
|
return keyId;
|
|
@@ -5094,7 +5078,6 @@ var NativeDocument = (function (exports) {
|
|
|
5094
5078
|
function ForEachArray(data, callback, configs = {}) {
|
|
5095
5079
|
const element = Anchor('ForEach Array', configs.isParentUniqueChild);
|
|
5096
5080
|
const blockEnd = element.endElement();
|
|
5097
|
-
element.startElement();
|
|
5098
5081
|
|
|
5099
5082
|
let cache = new Map();
|
|
5100
5083
|
let lastNumberOfItems = 0;
|
|
@@ -5142,7 +5125,7 @@ var NativeDocument = (function (exports) {
|
|
|
5142
5125
|
};
|
|
5143
5126
|
|
|
5144
5127
|
const createAndCache = (item) => {
|
|
5145
|
-
const child =
|
|
5128
|
+
const child = callback(item, null);
|
|
5146
5129
|
{
|
|
5147
5130
|
if(!child) {
|
|
5148
5131
|
throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
|
|
@@ -5154,7 +5137,7 @@ var NativeDocument = (function (exports) {
|
|
|
5154
5137
|
|
|
5155
5138
|
const createWithIndexAndCache = (item, indexKey) => {
|
|
5156
5139
|
const indexObserver = Observable(indexKey);
|
|
5157
|
-
const child =
|
|
5140
|
+
const child = callback(item, indexObserver);
|
|
5158
5141
|
{
|
|
5159
5142
|
if(!child) {
|
|
5160
5143
|
throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
|
|
@@ -5363,7 +5346,7 @@ var NativeDocument = (function (exports) {
|
|
|
5363
5346
|
*/
|
|
5364
5347
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
5365
5348
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
5366
|
-
return DebugManager$
|
|
5349
|
+
return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
5367
5350
|
}
|
|
5368
5351
|
const element = Anchor('Show if : '+(comment || ''));
|
|
5369
5352
|
|
|
@@ -6782,7 +6765,7 @@ var NativeDocument = (function (exports) {
|
|
|
6782
6765
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
6783
6766
|
this.handleRouteChange(route, params, query, path);
|
|
6784
6767
|
} catch (e) {
|
|
6785
|
-
DebugManager$
|
|
6768
|
+
DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
|
|
6786
6769
|
}
|
|
6787
6770
|
};
|
|
6788
6771
|
/**
|
|
@@ -6795,7 +6778,7 @@ var NativeDocument = (function (exports) {
|
|
|
6795
6778
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
6796
6779
|
this.handleRouteChange(route, params, {}, path);
|
|
6797
6780
|
} catch(e) {
|
|
6798
|
-
DebugManager$
|
|
6781
|
+
DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
|
|
6799
6782
|
}
|
|
6800
6783
|
};
|
|
6801
6784
|
this.forward = function() {
|
|
@@ -6822,7 +6805,7 @@ var NativeDocument = (function (exports) {
|
|
|
6822
6805
|
}
|
|
6823
6806
|
this.handleRouteChange(route, params, query, path);
|
|
6824
6807
|
} catch(e) {
|
|
6825
|
-
DebugManager$
|
|
6808
|
+
DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
|
|
6826
6809
|
}
|
|
6827
6810
|
});
|
|
6828
6811
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -7047,7 +7030,7 @@ var NativeDocument = (function (exports) {
|
|
|
7047
7030
|
listener(request);
|
|
7048
7031
|
next && next(request);
|
|
7049
7032
|
} catch (e) {
|
|
7050
|
-
DebugManager$
|
|
7033
|
+
DebugManager$1.warn('Route Listener', 'Error in listener:', e);
|
|
7051
7034
|
}
|
|
7052
7035
|
}
|
|
7053
7036
|
};
|
|
@@ -7225,7 +7208,7 @@ var NativeDocument = (function (exports) {
|
|
|
7225
7208
|
*/
|
|
7226
7209
|
Router.create = function(options, callback) {
|
|
7227
7210
|
if(!Validator.isFunction(callback)) {
|
|
7228
|
-
DebugManager$
|
|
7211
|
+
DebugManager$1.error('Router', 'Callback must be a function');
|
|
7229
7212
|
throw new RouterError('Callback must be a function');
|
|
7230
7213
|
}
|
|
7231
7214
|
const router = new Router(options);
|
|
@@ -7429,7 +7412,7 @@ var NativeDocument = (function (exports) {
|
|
|
7429
7412
|
exports.HtmlElementWrapper = HtmlElementWrapper;
|
|
7430
7413
|
exports.NDElement = NDElement;
|
|
7431
7414
|
exports.Observable = Observable;
|
|
7432
|
-
exports.PluginsManager = PluginsManager
|
|
7415
|
+
exports.PluginsManager = PluginsManager;
|
|
7433
7416
|
exports.SingletonView = SingletonView;
|
|
7434
7417
|
exports.Store = Store;
|
|
7435
7418
|
exports.StoreFactory = StoreFactory;
|