native-document 1.0.18 โ†’ 1.0.20

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.
@@ -1,35 +1,41 @@
1
1
  var NativeDocument = (function (exports) {
2
2
  'use strict';
3
3
 
4
- const DebugManager = {
5
- enabled: false,
4
+ let DebugManager = {};
6
5
 
7
- enable() {
8
- this.enabled = true;
9
- console.log('๐Ÿ” NativeDocument Debug Mode enabled');
10
- },
6
+ {
7
+ DebugManager = {
8
+ enabled: false,
11
9
 
12
- disable() {
13
- this.enabled = false;
14
- },
10
+ enable() {
11
+ this.enabled = true;
12
+ console.log('๐Ÿ” NativeDocument Debug Mode enabled');
13
+ },
15
14
 
16
- log(category, message, data) {
17
- if (!this.enabled) return;
18
- console.group(`๐Ÿ” [${category}] ${message}`);
19
- if (data) console.log(data);
20
- console.trace();
21
- console.groupEnd();
22
- },
15
+ disable() {
16
+ this.enabled = false;
17
+ },
23
18
 
24
- warn(category, message, data) {
25
- if (!this.enabled) return;
26
- console.warn(`โš ๏ธ [${category}] ${message}`, data);
27
- },
19
+ log(category, message, data) {
20
+ if (!this.enabled) return;
21
+ console.group(`๐Ÿ” [${category}] ${message}`);
22
+ if (data) console.log(data);
23
+ console.trace();
24
+ console.groupEnd();
25
+ },
28
26
 
29
- error(category, message, error) {
30
- console.error(`โŒ [${category}] ${message}`, error);
31
- }
32
- };
27
+ warn(category, message, data) {
28
+ if (!this.enabled) return;
29
+ console.warn(`โš ๏ธ [${category}] ${message}`, data);
30
+ },
31
+
32
+ error(category, message, error) {
33
+ console.error(`โŒ [${category}] ${message}`, error);
34
+ }
35
+ };
36
+
37
+ }
38
+ var DebugManager$1 = DebugManager;
33
39
 
34
40
  const MemoryManager = (function() {
35
41
 
@@ -78,7 +84,7 @@ var NativeDocument = (function (exports) {
78
84
  }
79
85
  }
80
86
  if (cleanedCount > 0) {
81
- DebugManager.log('Memory Auto Clean', `๐Ÿงน Cleaned ${cleanedCount} orphaned observables`);
87
+ DebugManager$1.log('Memory Auto Clean', `๐Ÿงน Cleaned ${cleanedCount} orphaned observables`);
82
88
  }
83
89
  }
84
90
  };
@@ -264,7 +270,7 @@ var NativeDocument = (function (exports) {
264
270
  ObservableItem.prototype.subscribe = function(callback) {
265
271
  this.$listeners = this.$listeners ?? [];
266
272
  if (this.$isCleanedUp) {
267
- DebugManager.warn('Observable subscription', 'โš ๏ธ Attempted to subscribe to a cleaned up observable.');
273
+ DebugManager$1.warn('Observable subscription', 'โš ๏ธ Attempted to subscribe to a cleaned up observable.');
268
274
  return () => {};
269
275
  }
270
276
  if (typeof callback !== 'function') {
@@ -569,6 +575,12 @@ var NativeDocument = (function (exports) {
569
575
  return this.lifecycle({ unmounted: callback });
570
576
  };
571
577
 
578
+ NDElement.prototype.htmlElement = function() {
579
+ return this.$element;
580
+ };
581
+
582
+ NDElement.prototype.node = NDElement.prototype.htmlElement;
583
+
572
584
  const Validator = {
573
585
  isObservable(value) {
574
586
  return value instanceof ObservableItem || value instanceof ObservableChecker;
@@ -674,7 +686,7 @@ var NativeDocument = (function (exports) {
674
686
  const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
675
687
 
676
688
  if (foundReserved.length > 0) {
677
- DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
689
+ DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
678
690
  }
679
691
 
680
692
  return attributes;
@@ -718,7 +730,7 @@ var NativeDocument = (function (exports) {
718
730
  element.appendChild = function(child, before = null) {
719
731
  const parent = anchorEnd.parentNode;
720
732
  if(!parent) {
721
- DebugManager.error('Anchor', 'Anchor : parent not found', child);
733
+ DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
722
734
  return;
723
735
  }
724
736
  before = before ?? anchorEnd;
@@ -1150,7 +1162,7 @@ var NativeDocument = (function (exports) {
1150
1162
 
1151
1163
  return ElementCreator.setup(finalElement, attributes, customWrapper);
1152
1164
  } catch (error) {
1153
- DebugManager.error('ElementCreation', `Error creating ${$tagName}`, error);
1165
+ DebugManager$1.error('ElementCreation', `Error creating ${$tagName}`, error);
1154
1166
  }
1155
1167
  };
1156
1168
  }
@@ -1658,7 +1670,7 @@ var NativeDocument = (function (exports) {
1658
1670
  let child = ElementCreator.getChild(callback(item, indexObserver));
1659
1671
  cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
1660
1672
  } catch (e) {
1661
- DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
1673
+ DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
1662
1674
  throw e;
1663
1675
  }
1664
1676
  return keyId;
@@ -1836,7 +1848,7 @@ var NativeDocument = (function (exports) {
1836
1848
  }
1837
1849
  return child;
1838
1850
  } catch (e) {
1839
- DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
1851
+ DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
1840
1852
  throw e;
1841
1853
  }
1842
1854
  };
@@ -2041,7 +2053,7 @@ var NativeDocument = (function (exports) {
2041
2053
  */
2042
2054
  const ShowIf = function(condition, child, comment = null) {
2043
2055
  if(!(Validator.isObservable(condition))) {
2044
- return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
2056
+ return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
2045
2057
  }
2046
2058
  const element = new Anchor('Show if : '+(comment || ''));
2047
2059
 
@@ -2771,7 +2783,7 @@ var NativeDocument = (function (exports) {
2771
2783
  window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
2772
2784
  this.handleRouteChange(route, params, query, path);
2773
2785
  } catch (e) {
2774
- DebugManager.error('HistoryRouter', 'Error in pushState', e);
2786
+ DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
2775
2787
  }
2776
2788
  };
2777
2789
  /**
@@ -2784,7 +2796,7 @@ var NativeDocument = (function (exports) {
2784
2796
  window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
2785
2797
  this.handleRouteChange(route, params, {}, path);
2786
2798
  } catch(e) {
2787
- DebugManager.error('HistoryRouter', 'Error in replaceState', e);
2799
+ DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
2788
2800
  }
2789
2801
  };
2790
2802
  this.forward = function() {
@@ -2811,7 +2823,7 @@ var NativeDocument = (function (exports) {
2811
2823
  }
2812
2824
  this.handleRouteChange(route, params, query, path);
2813
2825
  } catch(e) {
2814
- DebugManager.error('HistoryRouter', 'Error in popstate event', e);
2826
+ DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
2815
2827
  }
2816
2828
  });
2817
2829
  const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
@@ -2960,7 +2972,7 @@ var NativeDocument = (function (exports) {
2960
2972
  listener(request);
2961
2973
  next && next(request);
2962
2974
  } catch (e) {
2963
- DebugManager.warn('Route Listener', 'Error in listener:', e);
2975
+ DebugManager$1.warn('Route Listener', 'Error in listener:', e);
2964
2976
  }
2965
2977
  }
2966
2978
  };
@@ -3118,7 +3130,7 @@ var NativeDocument = (function (exports) {
3118
3130
  */
3119
3131
  Router.create = function(options, callback) {
3120
3132
  if(!Validator.isFunction(callback)) {
3121
- DebugManager.error('Router', 'Callback must be a function', e);
3133
+ DebugManager$1.error('Router', 'Callback must be a function', e);
3122
3134
  throw new RouterError('Callback must be a function');
3123
3135
  }
3124
3136
  const router = new Router(options);
@@ -3202,6 +3214,7 @@ var NativeDocument = (function (exports) {
3202
3214
  exports.ArgTypes = ArgTypes;
3203
3215
  exports.ElementCreator = ElementCreator;
3204
3216
  exports.HtmlElementWrapper = HtmlElementWrapper;
3217
+ exports.NDElement = NDElement;
3205
3218
  exports.Observable = Observable;
3206
3219
  exports.Store = Store;
3207
3220
  exports.elements = elements;
@@ -3211,3 +3224,4 @@ var NativeDocument = (function (exports) {
3211
3224
  return exports;
3212
3225
 
3213
3226
  })({});
3227
+ //# sourceMappingURL=native-document.dev.js.map