native-document 1.0.109 → 1.0.111
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 +34 -27
- package/dist/native-document.dev.js +280 -125
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/core/wrappers/ElementCreator.js +10 -2
- package/src/core/wrappers/template-cloner/TemplateCloner.js +163 -0
- package/src/core/wrappers/template-cloner/attributes-hydrator.js +86 -0
- package/src/core/wrappers/template-cloner/utils.js +135 -0
- package/src/core/wrappers/TemplateCloner.js +0 -317
|
@@ -363,16 +363,16 @@ var NativeComponents = (function (exports) {
|
|
|
363
363
|
// });
|
|
364
364
|
};
|
|
365
365
|
|
|
366
|
-
let DebugManager
|
|
366
|
+
let DebugManager = {};
|
|
367
367
|
{
|
|
368
|
-
DebugManager
|
|
368
|
+
DebugManager = {
|
|
369
369
|
log() {},
|
|
370
370
|
warn() {},
|
|
371
371
|
error() {},
|
|
372
372
|
disable() {}
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
-
var DebugManager = DebugManager
|
|
375
|
+
var DebugManager$1 = DebugManager;
|
|
376
376
|
|
|
377
377
|
/**
|
|
378
378
|
*
|
|
@@ -861,17 +861,17 @@ var NativeComponents = (function (exports) {
|
|
|
861
861
|
const method = methods[name];
|
|
862
862
|
|
|
863
863
|
if (typeof method !== 'function') {
|
|
864
|
-
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
864
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
865
865
|
continue;
|
|
866
866
|
}
|
|
867
867
|
|
|
868
868
|
if (protectedMethods.has(name)) {
|
|
869
|
-
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
869
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
870
870
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
871
871
|
}
|
|
872
872
|
|
|
873
873
|
if (NDElement.prototype[name]) {
|
|
874
|
-
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
874
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
875
875
|
}
|
|
876
876
|
|
|
877
877
|
NDElement.prototype[name] = method;
|
|
@@ -887,12 +887,11 @@ var NativeComponents = (function (exports) {
|
|
|
887
887
|
DOCUMENT_FRAGMENT: 11
|
|
888
888
|
};
|
|
889
889
|
|
|
890
|
-
const VALID_TYPES =
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
};
|
|
890
|
+
const VALID_TYPES = [];
|
|
891
|
+
VALID_TYPES[COMMON_NODE_TYPES.ELEMENT] = true;
|
|
892
|
+
VALID_TYPES[COMMON_NODE_TYPES.TEXT] = true;
|
|
893
|
+
VALID_TYPES[COMMON_NODE_TYPES.DOCUMENT_FRAGMENT] = true;
|
|
894
|
+
VALID_TYPES[COMMON_NODE_TYPES.COMMENT] = true;
|
|
896
895
|
|
|
897
896
|
const Validator = {
|
|
898
897
|
isObservable(value) {
|
|
@@ -1061,7 +1060,7 @@ var NativeComponents = (function (exports) {
|
|
|
1061
1060
|
anchorFragment.appendChild = function(child, before = null) {
|
|
1062
1061
|
const parent = anchorEnd.parentNode;
|
|
1063
1062
|
if(!parent) {
|
|
1064
|
-
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1063
|
+
DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
|
|
1065
1064
|
return;
|
|
1066
1065
|
}
|
|
1067
1066
|
before = before ?? anchorEnd;
|
|
@@ -1241,7 +1240,7 @@ var NativeComponents = (function (exports) {
|
|
|
1241
1240
|
}
|
|
1242
1241
|
}
|
|
1243
1242
|
if (cleanedCount > 0) {
|
|
1244
|
-
DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
1243
|
+
DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
1245
1244
|
}
|
|
1246
1245
|
}
|
|
1247
1246
|
};
|
|
@@ -1448,7 +1447,7 @@ var NativeComponents = (function (exports) {
|
|
|
1448
1447
|
const $getStoreOrThrow = (method, name) => {
|
|
1449
1448
|
const item = $stores.get(name);
|
|
1450
1449
|
if (!item) {
|
|
1451
|
-
DebugManager.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
|
|
1450
|
+
DebugManager$1.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
|
|
1452
1451
|
throw new NativeDocumentError(
|
|
1453
1452
|
`Store.${method}('${name}') : store not found.`
|
|
1454
1453
|
);
|
|
@@ -1461,7 +1460,7 @@ var NativeComponents = (function (exports) {
|
|
|
1461
1460
|
*/
|
|
1462
1461
|
const $applyReadOnly = (observer, name, context) => {
|
|
1463
1462
|
const readOnlyError = (method) => () => {
|
|
1464
|
-
DebugManager.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
|
|
1463
|
+
DebugManager$1.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
|
|
1465
1464
|
throw new NativeDocumentError(
|
|
1466
1465
|
`Store.${context}('${name}') is read-only.`
|
|
1467
1466
|
);
|
|
@@ -1492,7 +1491,7 @@ var NativeComponents = (function (exports) {
|
|
|
1492
1491
|
*/
|
|
1493
1492
|
create(name, value) {
|
|
1494
1493
|
if ($stores.has(name)) {
|
|
1495
|
-
DebugManager.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
|
|
1494
|
+
DebugManager$1.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
|
|
1496
1495
|
throw new NativeDocumentError(
|
|
1497
1496
|
`Store.create('${name}') : a store with this name already exists.`
|
|
1498
1497
|
);
|
|
@@ -1513,7 +1512,7 @@ var NativeComponents = (function (exports) {
|
|
|
1513
1512
|
*/
|
|
1514
1513
|
createResettable(name, value) {
|
|
1515
1514
|
if ($stores.has(name)) {
|
|
1516
|
-
DebugManager.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
|
|
1515
|
+
DebugManager$1.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
|
|
1517
1516
|
throw new NativeDocumentError(
|
|
1518
1517
|
`Store.createResettable('${name}') : a store with this name already exists.`
|
|
1519
1518
|
);
|
|
@@ -1549,7 +1548,7 @@ var NativeComponents = (function (exports) {
|
|
|
1549
1548
|
*/
|
|
1550
1549
|
createComposed(name, computation, dependencies) {
|
|
1551
1550
|
if ($stores.has(name)) {
|
|
1552
|
-
DebugManager.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
|
|
1551
|
+
DebugManager$1.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
|
|
1553
1552
|
throw new NativeDocumentError(
|
|
1554
1553
|
`Store.createComposed('${name}') : a store with this name already exists.`
|
|
1555
1554
|
);
|
|
@@ -1572,7 +1571,7 @@ var NativeComponents = (function (exports) {
|
|
|
1572
1571
|
}
|
|
1573
1572
|
const depItem = $stores.get(depName);
|
|
1574
1573
|
if (!depItem) {
|
|
1575
|
-
DebugManager.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
|
|
1574
|
+
DebugManager$1.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
|
|
1576
1575
|
throw new NativeDocumentError(
|
|
1577
1576
|
`Store.createComposed('${name}') : dependency store '${depName}' not found.`
|
|
1578
1577
|
);
|
|
@@ -1606,13 +1605,13 @@ var NativeComponents = (function (exports) {
|
|
|
1606
1605
|
reset(name) {
|
|
1607
1606
|
const item = $getStoreOrThrow('reset', name);
|
|
1608
1607
|
if (item.composed) {
|
|
1609
|
-
DebugManager.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
|
|
1608
|
+
DebugManager$1.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
|
|
1610
1609
|
throw new NativeDocumentError(
|
|
1611
1610
|
`Store.reset('${name}') : composed stores cannot be reset.`
|
|
1612
1611
|
);
|
|
1613
1612
|
}
|
|
1614
1613
|
if (!item.resettable) {
|
|
1615
|
-
DebugManager.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
|
|
1614
|
+
DebugManager$1.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
|
|
1616
1615
|
throw new NativeDocumentError(
|
|
1617
1616
|
`Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
|
|
1618
1617
|
);
|
|
@@ -1633,7 +1632,7 @@ var NativeComponents = (function (exports) {
|
|
|
1633
1632
|
const item = $getStoreOrThrow('use', name);
|
|
1634
1633
|
|
|
1635
1634
|
if (item.composed) {
|
|
1636
|
-
DebugManager.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
|
|
1635
|
+
DebugManager$1.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
|
|
1637
1636
|
throw new NativeDocumentError(
|
|
1638
1637
|
`Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
|
|
1639
1638
|
);
|
|
@@ -1700,7 +1699,7 @@ var NativeComponents = (function (exports) {
|
|
|
1700
1699
|
get(name) {
|
|
1701
1700
|
const item = $stores.get(name);
|
|
1702
1701
|
if (!item) {
|
|
1703
|
-
DebugManager.warn('Store', `Store.get('${name}') : store not found.`);
|
|
1702
|
+
DebugManager$1.warn('Store', `Store.get('${name}') : store not found.`);
|
|
1704
1703
|
return null;
|
|
1705
1704
|
}
|
|
1706
1705
|
return item.observer;
|
|
@@ -1722,7 +1721,7 @@ var NativeComponents = (function (exports) {
|
|
|
1722
1721
|
delete(name) {
|
|
1723
1722
|
const item = $stores.get(name);
|
|
1724
1723
|
if (!item) {
|
|
1725
|
-
DebugManager.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
|
|
1724
|
+
DebugManager$1.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
|
|
1726
1725
|
return;
|
|
1727
1726
|
}
|
|
1728
1727
|
item.subscribers.forEach(follower => follower.destroy());
|
|
@@ -1824,7 +1823,7 @@ var NativeComponents = (function (exports) {
|
|
|
1824
1823
|
return undefined;
|
|
1825
1824
|
},
|
|
1826
1825
|
set(target, prop, value) {
|
|
1827
|
-
DebugManager.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
|
|
1826
|
+
DebugManager$1.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
|
|
1828
1827
|
throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
|
|
1829
1828
|
},
|
|
1830
1829
|
deleteProperty(target, prop) {
|
|
@@ -2906,7 +2905,15 @@ var NativeComponents = (function (exports) {
|
|
|
2906
2905
|
if (attributes) {
|
|
2907
2906
|
AttributesWrapper(element, attributes);
|
|
2908
2907
|
}
|
|
2909
|
-
}
|
|
2908
|
+
},
|
|
2909
|
+
/**
|
|
2910
|
+
*
|
|
2911
|
+
* @param {HTMLElement} element
|
|
2912
|
+
* @param {Object} attributes
|
|
2913
|
+
*/
|
|
2914
|
+
processAttributesDirect: AttributesWrapper,
|
|
2915
|
+
processClassAttribute: bindClassAttribute,
|
|
2916
|
+
processStyleAttribute: bindStyleAttribute,
|
|
2910
2917
|
};
|
|
2911
2918
|
|
|
2912
2919
|
const EVENTS = [
|