native-document 1.0.111 → 1.0.113-clear

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.
@@ -363,16 +363,16 @@ var NativeComponents = (function (exports) {
363
363
  // });
364
364
  };
365
365
 
366
- let DebugManager = {};
366
+ let DebugManager$1 = {};
367
367
  {
368
- DebugManager = {
368
+ DebugManager$1 = {
369
369
  log() {},
370
370
  warn() {},
371
371
  error() {},
372
372
  disable() {}
373
373
  };
374
374
  }
375
- var DebugManager$1 = DebugManager;
375
+ var DebugManager = DebugManager$1;
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$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
864
+ DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
865
865
  continue;
866
866
  }
867
867
 
868
868
  if (protectedMethods.has(name)) {
869
- DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
869
+ DebugManager.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$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
874
+ DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
875
875
  }
876
876
 
877
877
  NDElement.prototype[name] = method;
@@ -1060,7 +1060,7 @@ var NativeComponents = (function (exports) {
1060
1060
  anchorFragment.appendChild = function(child, before = null) {
1061
1061
  const parent = anchorEnd.parentNode;
1062
1062
  if(!parent) {
1063
- DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
1063
+ DebugManager.error('Anchor', 'Anchor : parent not found', child);
1064
1064
  return;
1065
1065
  }
1066
1066
  before = before ?? anchorEnd;
@@ -1240,7 +1240,7 @@ var NativeComponents = (function (exports) {
1240
1240
  }
1241
1241
  }
1242
1242
  if (cleanedCount > 0) {
1243
- DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
1243
+ DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
1244
1244
  }
1245
1245
  }
1246
1246
  };
@@ -1447,7 +1447,7 @@ var NativeComponents = (function (exports) {
1447
1447
  const $getStoreOrThrow = (method, name) => {
1448
1448
  const item = $stores.get(name);
1449
1449
  if (!item) {
1450
- DebugManager$1.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
1450
+ DebugManager.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
1451
1451
  throw new NativeDocumentError(
1452
1452
  `Store.${method}('${name}') : store not found.`
1453
1453
  );
@@ -1460,7 +1460,7 @@ var NativeComponents = (function (exports) {
1460
1460
  */
1461
1461
  const $applyReadOnly = (observer, name, context) => {
1462
1462
  const readOnlyError = (method) => () => {
1463
- DebugManager$1.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
1463
+ DebugManager.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
1464
1464
  throw new NativeDocumentError(
1465
1465
  `Store.${context}('${name}') is read-only.`
1466
1466
  );
@@ -1491,7 +1491,7 @@ var NativeComponents = (function (exports) {
1491
1491
  */
1492
1492
  create(name, value) {
1493
1493
  if ($stores.has(name)) {
1494
- DebugManager$1.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
1494
+ DebugManager.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
1495
1495
  throw new NativeDocumentError(
1496
1496
  `Store.create('${name}') : a store with this name already exists.`
1497
1497
  );
@@ -1512,7 +1512,7 @@ var NativeComponents = (function (exports) {
1512
1512
  */
1513
1513
  createResettable(name, value) {
1514
1514
  if ($stores.has(name)) {
1515
- DebugManager$1.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
1515
+ DebugManager.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
1516
1516
  throw new NativeDocumentError(
1517
1517
  `Store.createResettable('${name}') : a store with this name already exists.`
1518
1518
  );
@@ -1548,7 +1548,7 @@ var NativeComponents = (function (exports) {
1548
1548
  */
1549
1549
  createComposed(name, computation, dependencies) {
1550
1550
  if ($stores.has(name)) {
1551
- DebugManager$1.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
1551
+ DebugManager.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
1552
1552
  throw new NativeDocumentError(
1553
1553
  `Store.createComposed('${name}') : a store with this name already exists.`
1554
1554
  );
@@ -1571,7 +1571,7 @@ var NativeComponents = (function (exports) {
1571
1571
  }
1572
1572
  const depItem = $stores.get(depName);
1573
1573
  if (!depItem) {
1574
- DebugManager$1.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
1574
+ DebugManager.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
1575
1575
  throw new NativeDocumentError(
1576
1576
  `Store.createComposed('${name}') : dependency store '${depName}' not found.`
1577
1577
  );
@@ -1605,13 +1605,13 @@ var NativeComponents = (function (exports) {
1605
1605
  reset(name) {
1606
1606
  const item = $getStoreOrThrow('reset', name);
1607
1607
  if (item.composed) {
1608
- DebugManager$1.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
1608
+ DebugManager.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
1609
1609
  throw new NativeDocumentError(
1610
1610
  `Store.reset('${name}') : composed stores cannot be reset.`
1611
1611
  );
1612
1612
  }
1613
1613
  if (!item.resettable) {
1614
- DebugManager$1.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
1614
+ DebugManager.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
1615
1615
  throw new NativeDocumentError(
1616
1616
  `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
1617
1617
  );
@@ -1632,7 +1632,7 @@ var NativeComponents = (function (exports) {
1632
1632
  const item = $getStoreOrThrow('use', name);
1633
1633
 
1634
1634
  if (item.composed) {
1635
- DebugManager$1.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
1635
+ DebugManager.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
1636
1636
  throw new NativeDocumentError(
1637
1637
  `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
1638
1638
  );
@@ -1699,7 +1699,7 @@ var NativeComponents = (function (exports) {
1699
1699
  get(name) {
1700
1700
  const item = $stores.get(name);
1701
1701
  if (!item) {
1702
- DebugManager$1.warn('Store', `Store.get('${name}') : store not found.`);
1702
+ DebugManager.warn('Store', `Store.get('${name}') : store not found.`);
1703
1703
  return null;
1704
1704
  }
1705
1705
  return item.observer;
@@ -1721,7 +1721,7 @@ var NativeComponents = (function (exports) {
1721
1721
  delete(name) {
1722
1722
  const item = $stores.get(name);
1723
1723
  if (!item) {
1724
- DebugManager$1.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
1724
+ DebugManager.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
1725
1725
  return;
1726
1726
  }
1727
1727
  item.subscribers.forEach(follower => follower.destroy());
@@ -1823,7 +1823,7 @@ var NativeComponents = (function (exports) {
1823
1823
  return undefined;
1824
1824
  },
1825
1825
  set(target, prop, value) {
1826
- DebugManager$1.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
1826
+ DebugManager.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
1827
1827
  throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
1828
1828
  },
1829
1829
  deleteProperty(target, prop) {
@@ -2524,7 +2524,7 @@ var NativeComponents = (function (exports) {
2524
2524
  * @param {HTMLElement} element
2525
2525
  * @param {Object} data
2526
2526
  */
2527
- function bindClassAttribute(element, data) {
2527
+ const bindClassAttribute = (element, data) => {
2528
2528
  for(const className in data) {
2529
2529
  const value = data[className];
2530
2530
  if(value.__$isObservable) {
@@ -2544,14 +2544,14 @@ var NativeComponents = (function (exports) {
2544
2544
  element.classes.toggle(className, value);
2545
2545
  }
2546
2546
  data = null;
2547
- }
2547
+ };
2548
2548
 
2549
2549
  /**
2550
2550
  *
2551
2551
  * @param {HTMLElement} element
2552
2552
  * @param {Object} data
2553
2553
  */
2554
- function bindStyleAttribute(element, data) {
2554
+ const bindStyleAttribute = (element, data) => {
2555
2555
  for(const styleName in data) {
2556
2556
  const value = data[styleName];
2557
2557
  if(value.__$isObservable) {
@@ -2561,7 +2561,7 @@ var NativeComponents = (function (exports) {
2561
2561
  }
2562
2562
  element.style[styleName] = value;
2563
2563
  }
2564
- }
2564
+ };
2565
2565
 
2566
2566
  /**
2567
2567
  *
@@ -2569,7 +2569,7 @@ var NativeComponents = (function (exports) {
2569
2569
  * @param {string} attributeName
2570
2570
  * @param {boolean|number|Observable} value
2571
2571
  */
2572
- function bindBooleanAttribute(element, attributeName, value) {
2572
+ const bindBooleanAttribute = (element, attributeName, value) => {
2573
2573
  const isObservable = value.__$isObservable;
2574
2574
  const defaultValue = isObservable? value.val() : value;
2575
2575
  if(Validator.isBoolean(defaultValue)) {
@@ -2591,7 +2591,7 @@ var NativeComponents = (function (exports) {
2591
2591
  }
2592
2592
  value.subscribe((newValue) => element[attributeName] = (newValue === element.value));
2593
2593
  }
2594
- }
2594
+ };
2595
2595
 
2596
2596
 
2597
2597
  /**
@@ -2600,7 +2600,7 @@ var NativeComponents = (function (exports) {
2600
2600
  * @param {string} attributeName
2601
2601
  * @param {Observable} value
2602
2602
  */
2603
- function bindAttributeWithObservable(element, attributeName, value) {
2603
+ const bindAttributeWithObservable = (element, attributeName, value) => {
2604
2604
  const applyValue = attributeName === 'value' ? (newValue) => element.value = newValue : (newValue) => element.setAttribute(attributeName, newValue);
2605
2605
  value.subscribe(applyValue);
2606
2606
 
@@ -2610,14 +2610,14 @@ var NativeComponents = (function (exports) {
2610
2610
  return;
2611
2611
  }
2612
2612
  element.setAttribute(attributeName, value.val());
2613
- }
2613
+ };
2614
2614
 
2615
2615
  /**
2616
2616
  *
2617
2617
  * @param {HTMLElement} element
2618
2618
  * @param {Object} attributes
2619
2619
  */
2620
- function AttributesWrapper(element, attributes) {
2620
+ const AttributesWrapper = (element, attributes) => {
2621
2621
 
2622
2622
  for(const originalAttributeName in attributes) {
2623
2623
  const attributeName = originalAttributeName.toLowerCase();
@@ -2647,7 +2647,7 @@ var NativeComponents = (function (exports) {
2647
2647
  element.setAttribute(attributeName, value);
2648
2648
  }
2649
2649
  return element;
2650
- }
2650
+ };
2651
2651
 
2652
2652
  String.prototype.toNdElement = function () {
2653
2653
  return ElementCreator.createStaticTextNode(null, this);
@@ -2800,6 +2800,7 @@ var NativeComponents = (function (exports) {
2800
2800
  createTextNode() {
2801
2801
  if(!$textNodeCache) {
2802
2802
  $textNodeCache = document.createTextNode('');
2803
+ ElementCreator.createTextNode = () => $textNodeCache.cloneNode();
2803
2804
  }
2804
2805
  return $textNodeCache.cloneNode();
2805
2806
  },
@@ -2809,7 +2810,7 @@ var NativeComponents = (function (exports) {
2809
2810
  * @param {ObservableItem} observable
2810
2811
  * @returns {Text}
2811
2812
  */
2812
- createObservableNode(parent, observable) {
2813
+ createObservableNode: (parent, observable) => {
2813
2814
  const text = ElementCreator.createTextNode();
2814
2815
  observable.subscribe(value => text.nodeValue = value);
2815
2816
  text.nodeValue = observable.val();
@@ -2845,7 +2846,7 @@ var NativeComponents = (function (exports) {
2845
2846
  * @param {string} name
2846
2847
  * @returns {HTMLElement|DocumentFragment}
2847
2848
  */
2848
- createElement(name) {
2849
+ createElement: (name) => {
2849
2850
  if(name) {
2850
2851
  const cacheNode = $nodeCache.get(name);
2851
2852
  if(cacheNode) {
@@ -2857,7 +2858,7 @@ var NativeComponents = (function (exports) {
2857
2858
  }
2858
2859
  return Anchor('Fragment');
2859
2860
  },
2860
- bindTextNode(textNode, value) {
2861
+ bindTextNode: (textNode, value) => {
2861
2862
  if(value?.__$isObservable) {
2862
2863
  value.subscribe(newValue => textNode.nodeValue = newValue);
2863
2864
  textNode.nodeValue = value.val();
@@ -2881,7 +2882,7 @@ var NativeComponents = (function (exports) {
2881
2882
  await element.remove();
2882
2883
 
2883
2884
  },
2884
- getChild(child) {
2885
+ getChild: (child) => {
2885
2886
  if(child == null) {
2886
2887
  return null;
2887
2888
  }
@@ -2901,7 +2902,7 @@ var NativeComponents = (function (exports) {
2901
2902
  * @param {HTMLElement} element
2902
2903
  * @param {Object} attributes
2903
2904
  */
2904
- processAttributes(element, attributes) {
2905
+ processAttributes: (element, attributes) => {
2905
2906
  if (attributes) {
2906
2907
  AttributesWrapper(element, attributes);
2907
2908
  }