native-document 1.0.60 → 1.0.62
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.dev.js +30 -27
- 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/devtools/hrm/ComponentRegistry.js +0 -1
- package/src/devtools/hrm/transformComponent.js +1 -1
- package/src/elements/anchor.js +3 -2
- package/src/elements/control/for-each-array.js +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var NativeDocument = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager
|
|
4
|
+
let DebugManager = {};
|
|
5
5
|
|
|
6
6
|
{
|
|
7
|
-
DebugManager
|
|
7
|
+
DebugManager = {
|
|
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 = DebugManager
|
|
38
|
+
var DebugManager$1 = DebugManager;
|
|
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.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
87
|
+
DebugManager$1.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.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
210
|
+
DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -459,7 +459,7 @@ var NativeDocument = (function (exports) {
|
|
|
459
459
|
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
460
460
|
this.$listeners = this.$listeners ?? [];
|
|
461
461
|
if (this.$isCleanedUp) {
|
|
462
|
-
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
462
|
+
DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
463
463
|
return () => {};
|
|
464
464
|
}
|
|
465
465
|
if (typeof callback !== 'function') {
|
|
@@ -959,7 +959,7 @@ var NativeDocument = (function (exports) {
|
|
|
959
959
|
}
|
|
960
960
|
{
|
|
961
961
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
962
|
-
DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
962
|
+
DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
963
963
|
}
|
|
964
964
|
this.$localExtensions.set(name, method);
|
|
965
965
|
}
|
|
@@ -993,17 +993,17 @@ var NativeDocument = (function (exports) {
|
|
|
993
993
|
const method = methods[name];
|
|
994
994
|
|
|
995
995
|
if (typeof method !== 'function') {
|
|
996
|
-
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
996
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
997
997
|
continue;
|
|
998
998
|
}
|
|
999
999
|
|
|
1000
1000
|
if (protectedMethods.has(name)) {
|
|
1001
|
-
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
1001
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
1002
1002
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
1003
1003
|
}
|
|
1004
1004
|
|
|
1005
1005
|
if (NDElement.prototype[name]) {
|
|
1006
|
-
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
1006
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
1007
1007
|
}
|
|
1008
1008
|
|
|
1009
1009
|
NDElement.prototype[name] = method;
|
|
@@ -1149,7 +1149,7 @@ var NativeDocument = (function (exports) {
|
|
|
1149
1149
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
1150
1150
|
|
|
1151
1151
|
if (foundReserved.length > 0) {
|
|
1152
|
-
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1152
|
+
DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1153
1153
|
}
|
|
1154
1154
|
|
|
1155
1155
|
return attributes;
|
|
@@ -1197,7 +1197,7 @@ var NativeDocument = (function (exports) {
|
|
|
1197
1197
|
element.appendChild = function(child, before = null) {
|
|
1198
1198
|
const parent = anchorEnd.parentNode;
|
|
1199
1199
|
if(!parent) {
|
|
1200
|
-
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1200
|
+
DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
|
|
1201
1201
|
return;
|
|
1202
1202
|
}
|
|
1203
1203
|
before = before ?? anchorEnd;
|
|
@@ -1246,18 +1246,21 @@ var NativeDocument = (function (exports) {
|
|
|
1246
1246
|
};
|
|
1247
1247
|
|
|
1248
1248
|
element.replaceContent = function(child) {
|
|
1249
|
+
const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
|
|
1249
1250
|
const parent = anchorEnd.parentNode;
|
|
1250
1251
|
if(!parent) {
|
|
1251
1252
|
return;
|
|
1252
1253
|
}
|
|
1253
1254
|
if(isParentUniqueChild(parent)) {
|
|
1254
|
-
parent.replaceChildren(anchorStart,
|
|
1255
|
+
parent.replaceChildren(anchorStart, childElement, anchorEnd);
|
|
1255
1256
|
return;
|
|
1256
1257
|
}
|
|
1257
1258
|
element.removeChildren();
|
|
1258
|
-
parent.insertBefore(
|
|
1259
|
+
parent.insertBefore(childElement, anchorEnd);
|
|
1259
1260
|
};
|
|
1260
1261
|
|
|
1262
|
+
element.setContent = element.replaceContent;
|
|
1263
|
+
|
|
1261
1264
|
element.insertBefore = function(child, anchor = null) {
|
|
1262
1265
|
element.appendChild(child, anchor);
|
|
1263
1266
|
};
|
|
@@ -1601,7 +1604,7 @@ var NativeDocument = (function (exports) {
|
|
|
1601
1604
|
$nodeCache.set(name, node);
|
|
1602
1605
|
return node.cloneNode();
|
|
1603
1606
|
}
|
|
1604
|
-
return
|
|
1607
|
+
return Anchor('Fragment');
|
|
1605
1608
|
},
|
|
1606
1609
|
/**
|
|
1607
1610
|
*
|
|
@@ -2100,7 +2103,7 @@ var NativeDocument = (function (exports) {
|
|
|
2100
2103
|
|
|
2101
2104
|
this.createSection = (name, fn) => {
|
|
2102
2105
|
$components = $components || {};
|
|
2103
|
-
const anchor =
|
|
2106
|
+
const anchor = Anchor('Component '+name);
|
|
2104
2107
|
|
|
2105
2108
|
$components[name] = function(...args) {
|
|
2106
2109
|
anchor.removeChildren();
|
|
@@ -2724,7 +2727,7 @@ var NativeDocument = (function (exports) {
|
|
|
2724
2727
|
* @returns {DocumentFragment}
|
|
2725
2728
|
*/
|
|
2726
2729
|
function ForEach(data, callback, key, { shouldKeepItemsInCache = false } = {}) {
|
|
2727
|
-
const element =
|
|
2730
|
+
const element = Anchor('ForEach');
|
|
2728
2731
|
const blockEnd = element.endElement();
|
|
2729
2732
|
element.startElement();
|
|
2730
2733
|
|
|
@@ -2778,7 +2781,7 @@ var NativeDocument = (function (exports) {
|
|
|
2778
2781
|
}
|
|
2779
2782
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
2780
2783
|
} catch (e) {
|
|
2781
|
-
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
2784
|
+
DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
2782
2785
|
throw e;
|
|
2783
2786
|
}
|
|
2784
2787
|
return keyId;
|
|
@@ -2861,7 +2864,7 @@ var NativeDocument = (function (exports) {
|
|
|
2861
2864
|
}
|
|
2862
2865
|
|
|
2863
2866
|
function ForEachArray(data, callback, key, configs = {}) {
|
|
2864
|
-
const element =
|
|
2867
|
+
const element = Anchor('ForEach Array');
|
|
2865
2868
|
const blockEnd = element.endElement();
|
|
2866
2869
|
const blockStart = element.startElement();
|
|
2867
2870
|
|
|
@@ -3150,9 +3153,9 @@ var NativeDocument = (function (exports) {
|
|
|
3150
3153
|
*/
|
|
3151
3154
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
3152
3155
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
3153
|
-
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3156
|
+
return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3154
3157
|
}
|
|
3155
|
-
const element =
|
|
3158
|
+
const element = Anchor('Show if : '+(comment || ''));
|
|
3156
3159
|
|
|
3157
3160
|
let childElement = null;
|
|
3158
3161
|
const getChildElement = () => {
|
|
@@ -3249,7 +3252,7 @@ var NativeDocument = (function (exports) {
|
|
|
3249
3252
|
throw new NativeDocumentError("Toggle : condition must be an Observable");
|
|
3250
3253
|
}
|
|
3251
3254
|
|
|
3252
|
-
const anchor =
|
|
3255
|
+
const anchor = Anchor('Match');
|
|
3253
3256
|
const cache = new Map();
|
|
3254
3257
|
|
|
3255
3258
|
const getItem = function(key) {
|
|
@@ -3937,7 +3940,7 @@ var NativeDocument = (function (exports) {
|
|
|
3937
3940
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
3938
3941
|
this.handleRouteChange(route, params, query, path);
|
|
3939
3942
|
} catch (e) {
|
|
3940
|
-
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
3943
|
+
DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
|
|
3941
3944
|
}
|
|
3942
3945
|
};
|
|
3943
3946
|
/**
|
|
@@ -3950,7 +3953,7 @@ var NativeDocument = (function (exports) {
|
|
|
3950
3953
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
3951
3954
|
this.handleRouteChange(route, params, {}, path);
|
|
3952
3955
|
} catch(e) {
|
|
3953
|
-
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
3956
|
+
DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
|
|
3954
3957
|
}
|
|
3955
3958
|
};
|
|
3956
3959
|
this.forward = function() {
|
|
@@ -3977,7 +3980,7 @@ var NativeDocument = (function (exports) {
|
|
|
3977
3980
|
}
|
|
3978
3981
|
this.handleRouteChange(route, params, query, path);
|
|
3979
3982
|
} catch(e) {
|
|
3980
|
-
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
3983
|
+
DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
|
|
3981
3984
|
}
|
|
3982
3985
|
});
|
|
3983
3986
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -4131,7 +4134,7 @@ var NativeDocument = (function (exports) {
|
|
|
4131
4134
|
listener(request);
|
|
4132
4135
|
next && next(request);
|
|
4133
4136
|
} catch (e) {
|
|
4134
|
-
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
4137
|
+
DebugManager$1.warn('Route Listener', 'Error in listener:', e);
|
|
4135
4138
|
}
|
|
4136
4139
|
}
|
|
4137
4140
|
};
|
|
@@ -4290,7 +4293,7 @@ var NativeDocument = (function (exports) {
|
|
|
4290
4293
|
*/
|
|
4291
4294
|
Router.create = function(options, callback) {
|
|
4292
4295
|
if(!Validator.isFunction(callback)) {
|
|
4293
|
-
DebugManager.error('Router', 'Callback must be a function', e);
|
|
4296
|
+
DebugManager$1.error('Router', 'Callback must be a function', e);
|
|
4294
4297
|
throw new RouterError('Callback must be a function');
|
|
4295
4298
|
}
|
|
4296
4299
|
const router = new Router(options);
|