native-document 1.0.111 → 1.0.112
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 +20 -20
- package/dist/native-document.dev.js +81 -75
- 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/wrappers/template-cloner/TemplateCloner.js +13 -16
- package/src/core/wrappers/template-cloner/utils.js +21 -11
|
@@ -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
|
class NativeDocumentError extends Error {
|
|
41
41
|
constructor(message, context = {}) {
|
|
@@ -313,10 +313,10 @@ var NativeDocument = (function (exports) {
|
|
|
313
313
|
subtree: true,
|
|
314
314
|
});
|
|
315
315
|
|
|
316
|
-
let PluginsManager = null;
|
|
316
|
+
let PluginsManager$1 = null;
|
|
317
317
|
|
|
318
318
|
{
|
|
319
|
-
PluginsManager = (function() {
|
|
319
|
+
PluginsManager$1 = (function() {
|
|
320
320
|
|
|
321
321
|
const $plugins = new Map();
|
|
322
322
|
const $pluginByEvents = new Map();
|
|
@@ -382,7 +382,7 @@ var NativeDocument = (function (exports) {
|
|
|
382
382
|
try{
|
|
383
383
|
callback.call(plugin, ...data);
|
|
384
384
|
} catch (error) {
|
|
385
|
-
DebugManager
|
|
385
|
+
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
}
|
|
@@ -391,12 +391,12 @@ var NativeDocument = (function (exports) {
|
|
|
391
391
|
}());
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
var PluginsManager
|
|
394
|
+
var PluginsManager = PluginsManager$1;
|
|
395
395
|
|
|
396
396
|
function NDElement(element) {
|
|
397
397
|
this.$element = element;
|
|
398
398
|
{
|
|
399
|
-
PluginsManager
|
|
399
|
+
PluginsManager.emit('NDElementCreated', element, this);
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
|
|
@@ -576,7 +576,7 @@ var NativeDocument = (function (exports) {
|
|
|
576
576
|
}
|
|
577
577
|
{
|
|
578
578
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
579
|
-
DebugManager
|
|
579
|
+
DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
580
580
|
}
|
|
581
581
|
this.$localExtensions.set(name, method);
|
|
582
582
|
}
|
|
@@ -627,23 +627,23 @@ var NativeDocument = (function (exports) {
|
|
|
627
627
|
const method = methods[name];
|
|
628
628
|
|
|
629
629
|
if (typeof method !== 'function') {
|
|
630
|
-
DebugManager
|
|
630
|
+
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
631
631
|
continue;
|
|
632
632
|
}
|
|
633
633
|
|
|
634
634
|
if (protectedMethods.has(name)) {
|
|
635
|
-
DebugManager
|
|
635
|
+
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
636
636
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
637
637
|
}
|
|
638
638
|
|
|
639
639
|
if (NDElement.prototype[name]) {
|
|
640
|
-
DebugManager
|
|
640
|
+
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
641
641
|
}
|
|
642
642
|
|
|
643
643
|
NDElement.prototype[name] = method;
|
|
644
644
|
}
|
|
645
645
|
{
|
|
646
|
-
PluginsManager
|
|
646
|
+
PluginsManager.emit('NDElementExtended', methods);
|
|
647
647
|
}
|
|
648
648
|
|
|
649
649
|
return NDElement;
|
|
@@ -794,7 +794,7 @@ var NativeDocument = (function (exports) {
|
|
|
794
794
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
795
795
|
|
|
796
796
|
if (foundReserved.length > 0) {
|
|
797
|
-
DebugManager
|
|
797
|
+
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
798
798
|
}
|
|
799
799
|
|
|
800
800
|
return attributes;
|
|
@@ -845,7 +845,7 @@ var NativeDocument = (function (exports) {
|
|
|
845
845
|
anchorFragment.appendChild = function(child, before = null) {
|
|
846
846
|
const parent = anchorEnd.parentNode;
|
|
847
847
|
if(!parent) {
|
|
848
|
-
DebugManager
|
|
848
|
+
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
849
849
|
return;
|
|
850
850
|
}
|
|
851
851
|
before = before ?? anchorEnd;
|
|
@@ -1039,7 +1039,7 @@ var NativeDocument = (function (exports) {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
1041
|
if (cleanedCount > 0) {
|
|
1042
|
-
DebugManager
|
|
1042
|
+
DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
1043
1043
|
}
|
|
1044
1044
|
}
|
|
1045
1045
|
};
|
|
@@ -1241,7 +1241,7 @@ var NativeDocument = (function (exports) {
|
|
|
1241
1241
|
const $getStoreOrThrow = (method, name) => {
|
|
1242
1242
|
const item = $stores.get(name);
|
|
1243
1243
|
if (!item) {
|
|
1244
|
-
DebugManager
|
|
1244
|
+
DebugManager.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
|
|
1245
1245
|
throw new NativeDocumentError(
|
|
1246
1246
|
`Store.${method}('${name}') : store not found.`
|
|
1247
1247
|
);
|
|
@@ -1254,7 +1254,7 @@ var NativeDocument = (function (exports) {
|
|
|
1254
1254
|
*/
|
|
1255
1255
|
const $applyReadOnly = (observer, name, context) => {
|
|
1256
1256
|
const readOnlyError = (method) => () => {
|
|
1257
|
-
DebugManager
|
|
1257
|
+
DebugManager.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
|
|
1258
1258
|
throw new NativeDocumentError(
|
|
1259
1259
|
`Store.${context}('${name}') is read-only.`
|
|
1260
1260
|
);
|
|
@@ -1285,7 +1285,7 @@ var NativeDocument = (function (exports) {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
create(name, value) {
|
|
1287
1287
|
if ($stores.has(name)) {
|
|
1288
|
-
DebugManager
|
|
1288
|
+
DebugManager.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
|
|
1289
1289
|
throw new NativeDocumentError(
|
|
1290
1290
|
`Store.create('${name}') : a store with this name already exists.`
|
|
1291
1291
|
);
|
|
@@ -1306,7 +1306,7 @@ var NativeDocument = (function (exports) {
|
|
|
1306
1306
|
*/
|
|
1307
1307
|
createResettable(name, value) {
|
|
1308
1308
|
if ($stores.has(name)) {
|
|
1309
|
-
DebugManager
|
|
1309
|
+
DebugManager.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
|
|
1310
1310
|
throw new NativeDocumentError(
|
|
1311
1311
|
`Store.createResettable('${name}') : a store with this name already exists.`
|
|
1312
1312
|
);
|
|
@@ -1342,7 +1342,7 @@ var NativeDocument = (function (exports) {
|
|
|
1342
1342
|
*/
|
|
1343
1343
|
createComposed(name, computation, dependencies) {
|
|
1344
1344
|
if ($stores.has(name)) {
|
|
1345
|
-
DebugManager
|
|
1345
|
+
DebugManager.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
|
|
1346
1346
|
throw new NativeDocumentError(
|
|
1347
1347
|
`Store.createComposed('${name}') : a store with this name already exists.`
|
|
1348
1348
|
);
|
|
@@ -1365,7 +1365,7 @@ var NativeDocument = (function (exports) {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
const depItem = $stores.get(depName);
|
|
1367
1367
|
if (!depItem) {
|
|
1368
|
-
DebugManager
|
|
1368
|
+
DebugManager.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
|
|
1369
1369
|
throw new NativeDocumentError(
|
|
1370
1370
|
`Store.createComposed('${name}') : dependency store '${depName}' not found.`
|
|
1371
1371
|
);
|
|
@@ -1399,13 +1399,13 @@ var NativeDocument = (function (exports) {
|
|
|
1399
1399
|
reset(name) {
|
|
1400
1400
|
const item = $getStoreOrThrow('reset', name);
|
|
1401
1401
|
if (item.composed) {
|
|
1402
|
-
DebugManager
|
|
1402
|
+
DebugManager.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
|
|
1403
1403
|
throw new NativeDocumentError(
|
|
1404
1404
|
`Store.reset('${name}') : composed stores cannot be reset.`
|
|
1405
1405
|
);
|
|
1406
1406
|
}
|
|
1407
1407
|
if (!item.resettable) {
|
|
1408
|
-
DebugManager
|
|
1408
|
+
DebugManager.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
|
|
1409
1409
|
throw new NativeDocumentError(
|
|
1410
1410
|
`Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
|
|
1411
1411
|
);
|
|
@@ -1426,7 +1426,7 @@ var NativeDocument = (function (exports) {
|
|
|
1426
1426
|
const item = $getStoreOrThrow('use', name);
|
|
1427
1427
|
|
|
1428
1428
|
if (item.composed) {
|
|
1429
|
-
DebugManager
|
|
1429
|
+
DebugManager.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
|
|
1430
1430
|
throw new NativeDocumentError(
|
|
1431
1431
|
`Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
|
|
1432
1432
|
);
|
|
@@ -1493,7 +1493,7 @@ var NativeDocument = (function (exports) {
|
|
|
1493
1493
|
get(name) {
|
|
1494
1494
|
const item = $stores.get(name);
|
|
1495
1495
|
if (!item) {
|
|
1496
|
-
DebugManager
|
|
1496
|
+
DebugManager.warn('Store', `Store.get('${name}') : store not found.`);
|
|
1497
1497
|
return null;
|
|
1498
1498
|
}
|
|
1499
1499
|
return item.observer;
|
|
@@ -1515,7 +1515,7 @@ var NativeDocument = (function (exports) {
|
|
|
1515
1515
|
delete(name) {
|
|
1516
1516
|
const item = $stores.get(name);
|
|
1517
1517
|
if (!item) {
|
|
1518
|
-
DebugManager
|
|
1518
|
+
DebugManager.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
|
|
1519
1519
|
return;
|
|
1520
1520
|
}
|
|
1521
1521
|
item.subscribers.forEach(follower => follower.destroy());
|
|
@@ -1617,7 +1617,7 @@ var NativeDocument = (function (exports) {
|
|
|
1617
1617
|
return undefined;
|
|
1618
1618
|
},
|
|
1619
1619
|
set(target, prop, value) {
|
|
1620
|
-
DebugManager
|
|
1620
|
+
DebugManager.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
|
|
1621
1621
|
throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
|
|
1622
1622
|
},
|
|
1623
1623
|
deleteProperty(target, prop) {
|
|
@@ -1749,7 +1749,7 @@ var NativeDocument = (function (exports) {
|
|
|
1749
1749
|
}
|
|
1750
1750
|
}
|
|
1751
1751
|
{
|
|
1752
|
-
PluginsManager
|
|
1752
|
+
PluginsManager.emit('CreateObservable', this);
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
1755
|
|
|
@@ -1853,12 +1853,12 @@ var NativeDocument = (function (exports) {
|
|
|
1853
1853
|
this.$previousValue = this.$currentValue;
|
|
1854
1854
|
this.$currentValue = newValue;
|
|
1855
1855
|
{
|
|
1856
|
-
PluginsManager
|
|
1856
|
+
PluginsManager.emit('ObservableBeforeChange', this);
|
|
1857
1857
|
}
|
|
1858
1858
|
this.trigger();
|
|
1859
1859
|
this.$previousValue = null;
|
|
1860
1860
|
{
|
|
1861
|
-
PluginsManager
|
|
1861
|
+
PluginsManager.emit('ObservableAfterChange', this);
|
|
1862
1862
|
}
|
|
1863
1863
|
};
|
|
1864
1864
|
|
|
@@ -1936,7 +1936,7 @@ var NativeDocument = (function (exports) {
|
|
|
1936
1936
|
ObservableItem.prototype.subscribe = function(callback) {
|
|
1937
1937
|
{
|
|
1938
1938
|
if (this.$isCleanedUp) {
|
|
1939
|
-
DebugManager
|
|
1939
|
+
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
1940
1940
|
return;
|
|
1941
1941
|
}
|
|
1942
1942
|
if (typeof callback !== 'function') {
|
|
@@ -1948,7 +1948,7 @@ var NativeDocument = (function (exports) {
|
|
|
1948
1948
|
this.$listeners.push(callback);
|
|
1949
1949
|
this.assocTrigger();
|
|
1950
1950
|
{
|
|
1951
|
-
PluginsManager
|
|
1951
|
+
PluginsManager.emit('ObservableSubscribe', this);
|
|
1952
1952
|
}
|
|
1953
1953
|
};
|
|
1954
1954
|
|
|
@@ -2059,7 +2059,7 @@ var NativeDocument = (function (exports) {
|
|
|
2059
2059
|
}
|
|
2060
2060
|
this.assocTrigger();
|
|
2061
2061
|
{
|
|
2062
|
-
PluginsManager
|
|
2062
|
+
PluginsManager.emit('ObservableUnsubscribe', this);
|
|
2063
2063
|
}
|
|
2064
2064
|
};
|
|
2065
2065
|
|
|
@@ -2535,7 +2535,7 @@ var NativeDocument = (function (exports) {
|
|
|
2535
2535
|
Function.prototype.toNdElement = function () {
|
|
2536
2536
|
const child = this;
|
|
2537
2537
|
{
|
|
2538
|
-
PluginsManager
|
|
2538
|
+
PluginsManager.emit('BeforeProcessComponent', child);
|
|
2539
2539
|
}
|
|
2540
2540
|
return ElementCreator.getChild(child());
|
|
2541
2541
|
};
|
|
@@ -2727,14 +2727,14 @@ var NativeDocument = (function (exports) {
|
|
|
2727
2727
|
processChildren(children, parent) {
|
|
2728
2728
|
if(children === null) return;
|
|
2729
2729
|
{
|
|
2730
|
-
PluginsManager
|
|
2730
|
+
PluginsManager.emit('BeforeProcessChildren', parent);
|
|
2731
2731
|
}
|
|
2732
2732
|
let child = this.getChild(children);
|
|
2733
2733
|
if(child) {
|
|
2734
2734
|
parent.appendChild(child);
|
|
2735
2735
|
}
|
|
2736
2736
|
{
|
|
2737
|
-
PluginsManager
|
|
2737
|
+
PluginsManager.emit('AfterProcessChildren', parent);
|
|
2738
2738
|
}
|
|
2739
2739
|
},
|
|
2740
2740
|
async safeRemove(element) {
|
|
@@ -3217,22 +3217,15 @@ var NativeDocument = (function (exports) {
|
|
|
3217
3217
|
return createHtmlElement.bind(null, name, customWrapper);
|
|
3218
3218
|
}
|
|
3219
3219
|
|
|
3220
|
-
const
|
|
3221
|
-
HYDRATE_TEXT: 1,
|
|
3222
|
-
ATTACH_METHOD: 2,
|
|
3223
|
-
HYDRATE_ATTRIBUTES: 3,
|
|
3224
|
-
HYDRATE_FULL: 4,
|
|
3225
|
-
};
|
|
3226
|
-
|
|
3227
|
-
|
|
3220
|
+
const cloneBindingsDataCache = new WeakMap();
|
|
3228
3221
|
|
|
3229
3222
|
const pathProcess = (target, path, data) => {
|
|
3230
|
-
if(path.
|
|
3223
|
+
if(path.HYDRATE_TEXT) {
|
|
3231
3224
|
const value = path.value;
|
|
3232
3225
|
ElementCreator.bindTextNode(target, path.isString ? data[0][value] : value.apply(null, data));
|
|
3233
3226
|
return;
|
|
3234
3227
|
}
|
|
3235
|
-
if(path.
|
|
3228
|
+
if(path.ATTACH_METHOD) {
|
|
3236
3229
|
const bindingData = path.bindingData;
|
|
3237
3230
|
for(let i = 0, length = bindingData._attachLength; i < length; i++) {
|
|
3238
3231
|
const method = bindingData.attach[i];
|
|
@@ -3241,7 +3234,7 @@ var NativeDocument = (function (exports) {
|
|
|
3241
3234
|
});
|
|
3242
3235
|
}
|
|
3243
3236
|
}
|
|
3244
|
-
if(path.
|
|
3237
|
+
if(path.HYDRATE_ATTRIBUTES) {
|
|
3245
3238
|
path.hydrator(target, path.bindingData, data);
|
|
3246
3239
|
}
|
|
3247
3240
|
};
|
|
@@ -3343,7 +3336,23 @@ var NativeDocument = (function (exports) {
|
|
|
3343
3336
|
target = $applyBindingParents[path.parentId].childNodes[path.index];
|
|
3344
3337
|
$applyBindingParents[path.id] = target;
|
|
3345
3338
|
|
|
3346
|
-
|
|
3339
|
+
if(path.HYDRATE_TEXT) {
|
|
3340
|
+
const value = path.value;
|
|
3341
|
+
ElementCreator.bindTextNode(target, path.isString ? data[0][value] : value.apply(null, data));
|
|
3342
|
+
continue;
|
|
3343
|
+
}
|
|
3344
|
+
if(path.ATTACH_METHOD) {
|
|
3345
|
+
const bindingData = path.bindingData;
|
|
3346
|
+
for(let i = 0, length = bindingData._attachLength; i < length; i++) {
|
|
3347
|
+
const method = bindingData.attach[i];
|
|
3348
|
+
target.nd[method.methodName](function() {
|
|
3349
|
+
method.fn.call(this, ...data, ...arguments);
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
if(path.HYDRATE_ATTRIBUTES) {
|
|
3354
|
+
path.hydrator(target, path.bindingData, data);
|
|
3355
|
+
}
|
|
3347
3356
|
}
|
|
3348
3357
|
|
|
3349
3358
|
for (let i = 0; i <= pathSize; i++) {
|
|
@@ -3436,8 +3445,6 @@ var NativeDocument = (function (exports) {
|
|
|
3436
3445
|
return hydrateStyleAttribute;
|
|
3437
3446
|
};
|
|
3438
3447
|
|
|
3439
|
-
const cloneBindingsDataCache$1 = new WeakMap();
|
|
3440
|
-
|
|
3441
3448
|
function TemplateCloner($fn) {
|
|
3442
3449
|
let $node = null;
|
|
3443
3450
|
let $hasBindingData = false;
|
|
@@ -3452,7 +3459,7 @@ var NativeDocument = (function (exports) {
|
|
|
3452
3459
|
|
|
3453
3460
|
let pathCounter = 0;
|
|
3454
3461
|
const clone = (node, data, currentPath) => {
|
|
3455
|
-
const bindDingData = cloneBindingsDataCache
|
|
3462
|
+
const bindDingData = cloneBindingsDataCache.get(node);
|
|
3456
3463
|
if(bindDingData) {
|
|
3457
3464
|
optimizeBindingData(bindDingData);
|
|
3458
3465
|
}
|
|
@@ -3461,7 +3468,8 @@ var NativeDocument = (function (exports) {
|
|
|
3461
3468
|
const value = bindDingData.value;
|
|
3462
3469
|
const textNode = node.cloneNode();
|
|
3463
3470
|
currentPath.value = value;
|
|
3464
|
-
currentPath.
|
|
3471
|
+
currentPath.HYDRATE_TEXT = true;
|
|
3472
|
+
currentPath.operation = true;
|
|
3465
3473
|
currentPath.isString = (typeof value === 'string');
|
|
3466
3474
|
ElementCreator.bindTextNode(textNode, (currentPath.isString ? data[0][value] : value.apply(null, data)));
|
|
3467
3475
|
return textNode;
|
|
@@ -3480,14 +3488,13 @@ var NativeDocument = (function (exports) {
|
|
|
3480
3488
|
currentPath.bindingData = bindDingData;
|
|
3481
3489
|
currentPath.hydrator = hydrator;
|
|
3482
3490
|
|
|
3483
|
-
if(hasAttributes
|
|
3484
|
-
currentPath.
|
|
3491
|
+
if(hasAttributes) {
|
|
3492
|
+
currentPath.HYDRATE_ATTRIBUTES = true;
|
|
3493
|
+
currentPath.operation = true;
|
|
3485
3494
|
}
|
|
3486
|
-
|
|
3487
|
-
currentPath.
|
|
3488
|
-
|
|
3489
|
-
else if(hasAttachMethods) {
|
|
3490
|
-
currentPath.operation = OPERATIONS.ATTACH_METHOD;
|
|
3495
|
+
if(hasAttachMethods) {
|
|
3496
|
+
currentPath.ATTACH_METHOD = true;
|
|
3497
|
+
currentPath.operation = true;
|
|
3491
3498
|
}
|
|
3492
3499
|
}
|
|
3493
3500
|
const childNodes = node.childNodes;
|
|
@@ -3557,7 +3564,6 @@ var NativeDocument = (function (exports) {
|
|
|
3557
3564
|
return createBinding(fn, 'attach');
|
|
3558
3565
|
};
|
|
3559
3566
|
this.callback = this.attach;
|
|
3560
|
-
|
|
3561
3567
|
}
|
|
3562
3568
|
|
|
3563
3569
|
|
|
@@ -3576,21 +3582,21 @@ var NativeDocument = (function (exports) {
|
|
|
3576
3582
|
function useCache(fn) {
|
|
3577
3583
|
let $cache = null;
|
|
3578
3584
|
|
|
3579
|
-
let wrapper =
|
|
3585
|
+
let wrapper = (args) => {
|
|
3580
3586
|
$cache = new TemplateCloner(fn);
|
|
3581
3587
|
|
|
3582
|
-
wrapper =
|
|
3588
|
+
wrapper = (args) => {
|
|
3583
3589
|
return $cache.clone(args);
|
|
3584
3590
|
};
|
|
3585
3591
|
return $cache.clone(args);
|
|
3586
3592
|
};
|
|
3587
3593
|
|
|
3588
3594
|
if(fn.length < 2) {
|
|
3589
|
-
return
|
|
3595
|
+
return (...args) => {
|
|
3590
3596
|
return wrapper(args);
|
|
3591
3597
|
};
|
|
3592
3598
|
}
|
|
3593
|
-
return
|
|
3599
|
+
return (_, __, ...args) => {
|
|
3594
3600
|
return wrapper([_, __, ...args]);
|
|
3595
3601
|
};
|
|
3596
3602
|
}
|
|
@@ -4172,7 +4178,7 @@ var NativeDocument = (function (exports) {
|
|
|
4172
4178
|
|
|
4173
4179
|
ObservableItem.call(this, target, configs);
|
|
4174
4180
|
{
|
|
4175
|
-
PluginsManager
|
|
4181
|
+
PluginsManager.emit('CreateObservableArray', this);
|
|
4176
4182
|
}
|
|
4177
4183
|
};
|
|
4178
4184
|
|
|
@@ -4804,7 +4810,7 @@ var NativeDocument = (function (exports) {
|
|
|
4804
4810
|
const observable = new ObservableItem(initialValue);
|
|
4805
4811
|
const updatedValue = nextTick(() => observable.set(callback()));
|
|
4806
4812
|
{
|
|
4807
|
-
PluginsManager
|
|
4813
|
+
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
4808
4814
|
}
|
|
4809
4815
|
|
|
4810
4816
|
if(Validator.isFunction(dependencies)) {
|
|
@@ -4903,7 +4909,7 @@ var NativeDocument = (function (exports) {
|
|
|
4903
4909
|
}
|
|
4904
4910
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
4905
4911
|
} catch (e) {
|
|
4906
|
-
DebugManager
|
|
4912
|
+
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
4907
4913
|
throw e;
|
|
4908
4914
|
}
|
|
4909
4915
|
return keyId;
|
|
@@ -5293,7 +5299,7 @@ var NativeDocument = (function (exports) {
|
|
|
5293
5299
|
*/
|
|
5294
5300
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
5295
5301
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
5296
|
-
return DebugManager
|
|
5302
|
+
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
5297
5303
|
}
|
|
5298
5304
|
const element = Anchor('Show if : '+(comment || ''));
|
|
5299
5305
|
|
|
@@ -6712,7 +6718,7 @@ var NativeDocument = (function (exports) {
|
|
|
6712
6718
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
6713
6719
|
this.handleRouteChange(route, params, query, path);
|
|
6714
6720
|
} catch (e) {
|
|
6715
|
-
DebugManager
|
|
6721
|
+
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
6716
6722
|
}
|
|
6717
6723
|
};
|
|
6718
6724
|
/**
|
|
@@ -6725,7 +6731,7 @@ var NativeDocument = (function (exports) {
|
|
|
6725
6731
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
6726
6732
|
this.handleRouteChange(route, params, {}, path);
|
|
6727
6733
|
} catch(e) {
|
|
6728
|
-
DebugManager
|
|
6734
|
+
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
6729
6735
|
}
|
|
6730
6736
|
};
|
|
6731
6737
|
this.forward = function() {
|
|
@@ -6752,7 +6758,7 @@ var NativeDocument = (function (exports) {
|
|
|
6752
6758
|
}
|
|
6753
6759
|
this.handleRouteChange(route, params, query, path);
|
|
6754
6760
|
} catch(e) {
|
|
6755
|
-
DebugManager
|
|
6761
|
+
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
6756
6762
|
}
|
|
6757
6763
|
});
|
|
6758
6764
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -6977,7 +6983,7 @@ var NativeDocument = (function (exports) {
|
|
|
6977
6983
|
listener(request);
|
|
6978
6984
|
next && next(request);
|
|
6979
6985
|
} catch (e) {
|
|
6980
|
-
DebugManager
|
|
6986
|
+
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
6981
6987
|
}
|
|
6982
6988
|
}
|
|
6983
6989
|
};
|
|
@@ -7155,7 +7161,7 @@ var NativeDocument = (function (exports) {
|
|
|
7155
7161
|
*/
|
|
7156
7162
|
Router.create = function(options, callback) {
|
|
7157
7163
|
if(!Validator.isFunction(callback)) {
|
|
7158
|
-
DebugManager
|
|
7164
|
+
DebugManager.error('Router', 'Callback must be a function');
|
|
7159
7165
|
throw new RouterError('Callback must be a function');
|
|
7160
7166
|
}
|
|
7161
7167
|
const router = new Router(options);
|
|
@@ -7359,7 +7365,7 @@ var NativeDocument = (function (exports) {
|
|
|
7359
7365
|
exports.HtmlElementWrapper = HtmlElementWrapper;
|
|
7360
7366
|
exports.NDElement = NDElement;
|
|
7361
7367
|
exports.Observable = Observable;
|
|
7362
|
-
exports.PluginsManager = PluginsManager
|
|
7368
|
+
exports.PluginsManager = PluginsManager;
|
|
7363
7369
|
exports.SingletonView = SingletonView;
|
|
7364
7370
|
exports.Store = Store;
|
|
7365
7371
|
exports.StoreFactory = StoreFactory;
|