native-document 1.0.72 → 1.0.73
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 +13 -13
- package/dist/native-document.dev.js +33 -33
- 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/wrappers/NDElement.js +2 -2
- package/src/core/wrappers/TemplateCloner.js +12 -12
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var NativeComponents = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager
|
|
4
|
+
let DebugManager = {};
|
|
5
5
|
{
|
|
6
|
-
DebugManager
|
|
6
|
+
DebugManager = {
|
|
7
7
|
log() {},
|
|
8
8
|
warn() {},
|
|
9
9
|
error() {},
|
|
10
10
|
disable() {}
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
var DebugManager = DebugManager
|
|
13
|
+
var DebugManager$1 = DebugManager;
|
|
14
14
|
|
|
15
15
|
const MemoryManager = (function() {
|
|
16
16
|
|
|
@@ -59,7 +59,7 @@ var NativeComponents = (function (exports) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
if (cleanedCount > 0) {
|
|
62
|
-
DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
62
|
+
DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
};
|
|
@@ -182,7 +182,7 @@ var NativeComponents = (function (exports) {
|
|
|
182
182
|
try{
|
|
183
183
|
callback.call(plugin, ...data);
|
|
184
184
|
} catch (error) {
|
|
185
|
-
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
185
|
+
DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
}
|
|
@@ -486,7 +486,7 @@ var NativeComponents = (function (exports) {
|
|
|
486
486
|
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
487
487
|
this.$listeners = this.$listeners ?? [];
|
|
488
488
|
if (this.$isCleanedUp) {
|
|
489
|
-
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
489
|
+
DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
490
490
|
return () => {};
|
|
491
491
|
}
|
|
492
492
|
if (typeof callback !== 'function') {
|
|
@@ -814,8 +814,8 @@ var NativeComponents = (function (exports) {
|
|
|
814
814
|
return this.shadow('closed', style);
|
|
815
815
|
};
|
|
816
816
|
|
|
817
|
-
NDElement.prototype.attach = function(bindingHydrator) {
|
|
818
|
-
bindingHydrator.$hydrate(this.$element);
|
|
817
|
+
NDElement.prototype.attach = function(methodName, bindingHydrator) {
|
|
818
|
+
bindingHydrator.$hydrate(this.$element, methodName);
|
|
819
819
|
return this.$element;
|
|
820
820
|
};
|
|
821
821
|
|
|
@@ -862,17 +862,17 @@ var NativeComponents = (function (exports) {
|
|
|
862
862
|
const method = methods[name];
|
|
863
863
|
|
|
864
864
|
if (typeof method !== 'function') {
|
|
865
|
-
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
865
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
866
866
|
continue;
|
|
867
867
|
}
|
|
868
868
|
|
|
869
869
|
if (protectedMethods.has(name)) {
|
|
870
|
-
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
870
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
871
871
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
872
872
|
}
|
|
873
873
|
|
|
874
874
|
if (NDElement.prototype[name]) {
|
|
875
|
-
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
875
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
876
876
|
}
|
|
877
877
|
|
|
878
878
|
NDElement.prototype[name] = method;
|
|
@@ -1062,7 +1062,7 @@ var NativeComponents = (function (exports) {
|
|
|
1062
1062
|
anchorFragment.appendChild = function(child, before = null) {
|
|
1063
1063
|
const parent = anchorEnd.parentNode;
|
|
1064
1064
|
if(!parent) {
|
|
1065
|
-
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1065
|
+
DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
|
|
1066
1066
|
return;
|
|
1067
1067
|
}
|
|
1068
1068
|
before = before ?? anchorEnd;
|
|
@@ -2367,7 +2367,7 @@ var NativeComponents = (function (exports) {
|
|
|
2367
2367
|
*/
|
|
2368
2368
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
2369
2369
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
2370
|
-
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
2370
|
+
return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
2371
2371
|
}
|
|
2372
2372
|
const element = Anchor('Show if : '+(comment || ''));
|
|
2373
2373
|
|
|
@@ -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
|
};
|
|
@@ -207,7 +207,7 @@ var NativeDocument = (function (exports) {
|
|
|
207
207
|
try{
|
|
208
208
|
callback.call(plugin, ...data);
|
|
209
209
|
} catch (error) {
|
|
210
|
-
DebugManager
|
|
210
|
+
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -503,7 +503,7 @@ var NativeDocument = (function (exports) {
|
|
|
503
503
|
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
504
504
|
this.$listeners = this.$listeners ?? [];
|
|
505
505
|
if (this.$isCleanedUp) {
|
|
506
|
-
DebugManager
|
|
506
|
+
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
507
507
|
return () => {};
|
|
508
508
|
}
|
|
509
509
|
if (typeof callback !== 'function') {
|
|
@@ -831,8 +831,8 @@ var NativeDocument = (function (exports) {
|
|
|
831
831
|
return this.shadow('closed', style);
|
|
832
832
|
};
|
|
833
833
|
|
|
834
|
-
NDElement.prototype.attach = function(bindingHydrator) {
|
|
835
|
-
bindingHydrator.$hydrate(this.$element);
|
|
834
|
+
NDElement.prototype.attach = function(methodName, bindingHydrator) {
|
|
835
|
+
bindingHydrator.$hydrate(this.$element, methodName);
|
|
836
836
|
return this.$element;
|
|
837
837
|
};
|
|
838
838
|
|
|
@@ -856,7 +856,7 @@ var NativeDocument = (function (exports) {
|
|
|
856
856
|
}
|
|
857
857
|
{
|
|
858
858
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
859
|
-
DebugManager
|
|
859
|
+
DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
860
860
|
}
|
|
861
861
|
this.$localExtensions.set(name, method);
|
|
862
862
|
}
|
|
@@ -890,17 +890,17 @@ var NativeDocument = (function (exports) {
|
|
|
890
890
|
const method = methods[name];
|
|
891
891
|
|
|
892
892
|
if (typeof method !== 'function') {
|
|
893
|
-
DebugManager
|
|
893
|
+
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
894
894
|
continue;
|
|
895
895
|
}
|
|
896
896
|
|
|
897
897
|
if (protectedMethods.has(name)) {
|
|
898
|
-
DebugManager
|
|
898
|
+
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
899
899
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
900
900
|
}
|
|
901
901
|
|
|
902
902
|
if (NDElement.prototype[name]) {
|
|
903
|
-
DebugManager
|
|
903
|
+
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
904
904
|
}
|
|
905
905
|
|
|
906
906
|
NDElement.prototype[name] = method;
|
|
@@ -1058,7 +1058,7 @@ var NativeDocument = (function (exports) {
|
|
|
1058
1058
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
1059
1059
|
|
|
1060
1060
|
if (foundReserved.length > 0) {
|
|
1061
|
-
DebugManager
|
|
1061
|
+
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
1064
|
return attributes;
|
|
@@ -1106,7 +1106,7 @@ var NativeDocument = (function (exports) {
|
|
|
1106
1106
|
anchorFragment.appendChild = function(child, before = null) {
|
|
1107
1107
|
const parent = anchorEnd.parentNode;
|
|
1108
1108
|
if(!parent) {
|
|
1109
|
-
DebugManager
|
|
1109
|
+
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1110
1110
|
return;
|
|
1111
1111
|
}
|
|
1112
1112
|
before = before ?? anchorEnd;
|
|
@@ -2017,7 +2017,7 @@ var NativeDocument = (function (exports) {
|
|
|
2017
2017
|
const bindAttributes = (node, bindDingData, data) => {
|
|
2018
2018
|
let attributes = null;
|
|
2019
2019
|
if(bindDingData.attributes) {
|
|
2020
|
-
attributes =
|
|
2020
|
+
attributes = {};
|
|
2021
2021
|
for (const attr in bindDingData.attributes) {
|
|
2022
2022
|
attributes[attr] = bindDingData.attributes[attr](...data);
|
|
2023
2023
|
}
|
|
@@ -2047,29 +2047,29 @@ var NativeDocument = (function (exports) {
|
|
|
2047
2047
|
return null;
|
|
2048
2048
|
};
|
|
2049
2049
|
|
|
2050
|
-
const $hydrateFn = function(hydrateFunction,
|
|
2050
|
+
const $hydrateFn = function(hydrateFunction, targetType, element, property) {
|
|
2051
2051
|
if(!cloneBindingsDataCache.has(element)) {
|
|
2052
2052
|
// { classes, styles, attributes, value, attach }
|
|
2053
2053
|
cloneBindingsDataCache.set(element, {});
|
|
2054
2054
|
}
|
|
2055
2055
|
const hydrationState = cloneBindingsDataCache.get(element);
|
|
2056
|
-
if(
|
|
2056
|
+
if(targetType === 'value') {
|
|
2057
2057
|
hydrationState.value = hydrateFunction;
|
|
2058
2058
|
return;
|
|
2059
2059
|
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
return;
|
|
2063
|
-
}
|
|
2064
|
-
hydrationState[target] = hydrationState[target] || {};
|
|
2065
|
-
hydrationState[target][property] = hydrateFunction;
|
|
2060
|
+
hydrationState[targetType] = hydrationState[targetType] || {};
|
|
2061
|
+
hydrationState[targetType][property] = hydrateFunction;
|
|
2066
2062
|
};
|
|
2067
2063
|
|
|
2068
2064
|
const bindAttachMethods = function(node, bindDingData, data) {
|
|
2069
2065
|
if(!bindDingData.attach) {
|
|
2070
2066
|
return null;
|
|
2071
2067
|
}
|
|
2072
|
-
bindDingData.attach
|
|
2068
|
+
for(const methodName in bindDingData.attach) {
|
|
2069
|
+
node.nd[methodName](function(...args) {
|
|
2070
|
+
bindDingData.attach[methodName].call(this, ...[...args, ...data]);
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
2073
|
};
|
|
2074
2074
|
|
|
2075
2075
|
function TemplateCloner($fn) {
|
|
@@ -2117,10 +2117,10 @@ var NativeDocument = (function (exports) {
|
|
|
2117
2117
|
};
|
|
2118
2118
|
|
|
2119
2119
|
|
|
2120
|
-
const createBinding = (hydrateFunction,
|
|
2120
|
+
const createBinding = (hydrateFunction, targetType) => {
|
|
2121
2121
|
return new TemplateBinding((element, property) => {
|
|
2122
2122
|
$hasBindingData = true;
|
|
2123
|
-
$hydrateFn(hydrateFunction,
|
|
2123
|
+
$hydrateFn(hydrateFunction, targetType, element, property);
|
|
2124
2124
|
});
|
|
2125
2125
|
};
|
|
2126
2126
|
|
|
@@ -3290,7 +3290,7 @@ var NativeDocument = (function (exports) {
|
|
|
3290
3290
|
}
|
|
3291
3291
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
3292
3292
|
} catch (e) {
|
|
3293
|
-
DebugManager
|
|
3293
|
+
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3294
3294
|
throw e;
|
|
3295
3295
|
}
|
|
3296
3296
|
return keyId;
|
|
@@ -3664,7 +3664,7 @@ var NativeDocument = (function (exports) {
|
|
|
3664
3664
|
*/
|
|
3665
3665
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
3666
3666
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
3667
|
-
return DebugManager
|
|
3667
|
+
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3668
3668
|
}
|
|
3669
3669
|
const element = Anchor('Show if : '+(comment || ''));
|
|
3670
3670
|
|
|
@@ -4451,7 +4451,7 @@ var NativeDocument = (function (exports) {
|
|
|
4451
4451
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4452
4452
|
this.handleRouteChange(route, params, query, path);
|
|
4453
4453
|
} catch (e) {
|
|
4454
|
-
DebugManager
|
|
4454
|
+
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
4455
4455
|
}
|
|
4456
4456
|
};
|
|
4457
4457
|
/**
|
|
@@ -4464,7 +4464,7 @@ var NativeDocument = (function (exports) {
|
|
|
4464
4464
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4465
4465
|
this.handleRouteChange(route, params, {}, path);
|
|
4466
4466
|
} catch(e) {
|
|
4467
|
-
DebugManager
|
|
4467
|
+
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
4468
4468
|
}
|
|
4469
4469
|
};
|
|
4470
4470
|
this.forward = function() {
|
|
@@ -4491,7 +4491,7 @@ var NativeDocument = (function (exports) {
|
|
|
4491
4491
|
}
|
|
4492
4492
|
this.handleRouteChange(route, params, query, path);
|
|
4493
4493
|
} catch(e) {
|
|
4494
|
-
DebugManager
|
|
4494
|
+
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
4495
4495
|
}
|
|
4496
4496
|
});
|
|
4497
4497
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -4654,7 +4654,7 @@ var NativeDocument = (function (exports) {
|
|
|
4654
4654
|
listener(request);
|
|
4655
4655
|
next && next(request);
|
|
4656
4656
|
} catch (e) {
|
|
4657
|
-
DebugManager
|
|
4657
|
+
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
4658
4658
|
}
|
|
4659
4659
|
}
|
|
4660
4660
|
};
|
|
@@ -4813,7 +4813,7 @@ var NativeDocument = (function (exports) {
|
|
|
4813
4813
|
*/
|
|
4814
4814
|
Router.create = function(options, callback) {
|
|
4815
4815
|
if(!Validator.isFunction(callback)) {
|
|
4816
|
-
DebugManager
|
|
4816
|
+
DebugManager.error('Router', 'Callback must be a function', e);
|
|
4817
4817
|
throw new RouterError('Callback must be a function');
|
|
4818
4818
|
}
|
|
4819
4819
|
const router = new Router(options);
|