native-document 1.0.90 → 1.0.91

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.
@@ -1426,9 +1426,7 @@ var NativeComponents = (function (exports) {
1426
1426
  * @param {Object} data
1427
1427
  */
1428
1428
  function bindClassAttribute(element, data) {
1429
- const classNames = Object.keys(data);
1430
- for(let i = 0, length = classNames.length; i < length; i++) {
1431
- const className = classNames[i];
1429
+ for(const className in data) {
1432
1430
  const value = data[className];
1433
1431
  if(value.__$isObservable) {
1434
1432
  element.classes.toggle(className, value.val());
@@ -1455,9 +1453,7 @@ var NativeComponents = (function (exports) {
1455
1453
  * @param {Object} data
1456
1454
  */
1457
1455
  function bindStyleAttribute(element, data) {
1458
- const keys = Object.keys(data);
1459
- for(let i = 0, length = keys.length; i < length; i++) {
1460
- const styleName = keys[i];
1456
+ for(const styleName in data) {
1461
1457
  const value = data[styleName];
1462
1458
  if(value.__$isObservable) {
1463
1459
  element.style[styleName] = value.val();
@@ -1523,10 +1519,8 @@ var NativeComponents = (function (exports) {
1523
1519
  * @param {Object} attributes
1524
1520
  */
1525
1521
  function AttributesWrapper(element, attributes) {
1526
- const attributesKeys = Object.keys(attributes);
1527
1522
 
1528
- for(let i = 0, length = attributesKeys.length; i < length; i++) {
1529
- const originalAttributeName = attributesKeys[i];
1523
+ for(const originalAttributeName in attributes) {
1530
1524
  const attributeName = originalAttributeName.toLowerCase();
1531
1525
  let value = attributes[originalAttributeName];
1532
1526
  if(value == null) {
@@ -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$1 = 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$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
87
+ DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
88
88
  }
89
89
  }
90
90
  };
@@ -141,10 +141,10 @@ var NativeDocument = (function (exports) {
141
141
  return this.observable.cleanup();
142
142
  };
143
143
 
144
- let PluginsManager = null;
144
+ let PluginsManager$1 = null;
145
145
 
146
146
  {
147
- PluginsManager = (function() {
147
+ PluginsManager$1 = (function() {
148
148
 
149
149
  const $plugins = new Map();
150
150
  const $pluginByEvents = new Map();
@@ -210,7 +210,7 @@ var NativeDocument = (function (exports) {
210
210
  try{
211
211
  callback.call(plugin, ...data);
212
212
  } catch (error) {
213
- DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
213
+ DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
214
214
  }
215
215
  }
216
216
  }
@@ -219,7 +219,7 @@ var NativeDocument = (function (exports) {
219
219
  }());
220
220
  }
221
221
 
222
- var PluginsManager$1 = PluginsManager;
222
+ var PluginsManager = PluginsManager$1;
223
223
 
224
224
  const ObservableWhen = function(observer, value) {
225
225
  this.$target = value;
@@ -341,7 +341,7 @@ var NativeDocument = (function (exports) {
341
341
  }
342
342
  }
343
343
  {
344
- PluginsManager$1.emit('CreateObservable', this);
344
+ PluginsManager.emit('CreateObservable', this);
345
345
  }
346
346
  }
347
347
 
@@ -469,12 +469,12 @@ var NativeDocument = (function (exports) {
469
469
  this.$previousValue = this.$currentValue;
470
470
  this.$currentValue = newValue;
471
471
  {
472
- PluginsManager$1.emit('ObservableBeforeChange', this);
472
+ PluginsManager.emit('ObservableBeforeChange', this);
473
473
  }
474
474
  this.trigger();
475
475
  this.$previousValue = null;
476
476
  {
477
- PluginsManager$1.emit('ObservableAfterChange', this);
477
+ PluginsManager.emit('ObservableAfterChange', this);
478
478
  }
479
479
  };
480
480
 
@@ -526,7 +526,7 @@ var NativeDocument = (function (exports) {
526
526
  ObservableItem.prototype.subscribe = function(callback, target = null) {
527
527
  this.$listeners = this.$listeners ?? [];
528
528
  if (this.$isCleanedUp) {
529
- DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
529
+ DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
530
530
  return () => {};
531
531
  }
532
532
  if (typeof callback !== 'function') {
@@ -536,13 +536,13 @@ var NativeDocument = (function (exports) {
536
536
  this.$listeners.push(callback);
537
537
  this.assocTrigger();
538
538
  {
539
- PluginsManager$1.emit('ObservableSubscribe', this, target);
539
+ PluginsManager.emit('ObservableSubscribe', this, target);
540
540
  }
541
541
  return () => {
542
542
  this.unsubscribe(callback);
543
543
  this.assocTrigger();
544
544
  {
545
- PluginsManager$1.emit('ObservableUnsubscribe', this);
545
+ PluginsManager.emit('ObservableUnsubscribe', this);
546
546
  }
547
547
  };
548
548
  };
@@ -757,7 +757,7 @@ var NativeDocument = (function (exports) {
757
757
  this.$element = element;
758
758
  this.$observer = null;
759
759
  {
760
- PluginsManager$1.emit('NDElementCreated', element, this);
760
+ PluginsManager.emit('NDElementCreated', element, this);
761
761
  }
762
762
  }
763
763
 
@@ -878,7 +878,7 @@ var NativeDocument = (function (exports) {
878
878
  }
879
879
  {
880
880
  if (this[name] && !this.$localExtensions.has(name)) {
881
- DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
881
+ DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
882
882
  }
883
883
  this.$localExtensions.set(name, method);
884
884
  }
@@ -912,23 +912,23 @@ var NativeDocument = (function (exports) {
912
912
  const method = methods[name];
913
913
 
914
914
  if (typeof method !== 'function') {
915
- DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
915
+ DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
916
916
  continue;
917
917
  }
918
918
 
919
919
  if (protectedMethods.has(name)) {
920
- DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
920
+ DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
921
921
  throw new NativeDocumentError(`Cannot override protected method "${name}"`);
922
922
  }
923
923
 
924
924
  if (NDElement.prototype[name]) {
925
- DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
925
+ DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
926
926
  }
927
927
 
928
928
  NDElement.prototype[name] = method;
929
929
  }
930
930
  {
931
- PluginsManager$1.emit('NDElementExtended', methods);
931
+ PluginsManager.emit('NDElementExtended', methods);
932
932
  }
933
933
 
934
934
  return NDElement;
@@ -1081,7 +1081,7 @@ var NativeDocument = (function (exports) {
1081
1081
  const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
1082
1082
 
1083
1083
  if (foundReserved.length > 0) {
1084
- DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
1084
+ DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
1085
1085
  }
1086
1086
 
1087
1087
  return attributes;
@@ -1129,7 +1129,7 @@ var NativeDocument = (function (exports) {
1129
1129
  anchorFragment.appendChild = function(child, before = null) {
1130
1130
  const parent = anchorEnd.parentNode;
1131
1131
  if(!parent) {
1132
- DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
1132
+ DebugManager.error('Anchor', 'Anchor : parent not found', child);
1133
1133
  return;
1134
1134
  }
1135
1135
  before = before ?? anchorEnd;
@@ -1349,9 +1349,7 @@ var NativeDocument = (function (exports) {
1349
1349
  * @param {Object} data
1350
1350
  */
1351
1351
  function bindClassAttribute(element, data) {
1352
- const classNames = Object.keys(data);
1353
- for(let i = 0, length = classNames.length; i < length; i++) {
1354
- const className = classNames[i];
1352
+ for(const className in data) {
1355
1353
  const value = data[className];
1356
1354
  if(value.__$isObservable) {
1357
1355
  element.classes.toggle(className, value.val());
@@ -1378,9 +1376,7 @@ var NativeDocument = (function (exports) {
1378
1376
  * @param {Object} data
1379
1377
  */
1380
1378
  function bindStyleAttribute(element, data) {
1381
- const keys = Object.keys(data);
1382
- for(let i = 0, length = keys.length; i < length; i++) {
1383
- const styleName = keys[i];
1379
+ for(const styleName in data) {
1384
1380
  const value = data[styleName];
1385
1381
  if(value.__$isObservable) {
1386
1382
  element.style[styleName] = value.val();
@@ -1448,10 +1444,8 @@ var NativeDocument = (function (exports) {
1448
1444
  function AttributesWrapper(element, attributes) {
1449
1445
 
1450
1446
  Validator.validateAttributes(attributes);
1451
- const attributesKeys = Object.keys(attributes);
1452
1447
 
1453
- for(let i = 0, length = attributesKeys.length; i < length; i++) {
1454
- const originalAttributeName = attributesKeys[i];
1448
+ for(const originalAttributeName in attributes) {
1455
1449
  const attributeName = originalAttributeName.toLowerCase();
1456
1450
  let value = attributes[originalAttributeName];
1457
1451
  if(value == null) {
@@ -1526,7 +1520,7 @@ var NativeDocument = (function (exports) {
1526
1520
  Function.prototype.toNdElement = function () {
1527
1521
  const child = this;
1528
1522
  {
1529
- PluginsManager$1.emit('BeforeProcessComponent', child);
1523
+ PluginsManager.emit('BeforeProcessComponent', child);
1530
1524
  }
1531
1525
  return ElementCreator.getChild(child());
1532
1526
  };
@@ -1632,14 +1626,14 @@ var NativeDocument = (function (exports) {
1632
1626
  processChildren(children, parent) {
1633
1627
  if(children === null) return;
1634
1628
  {
1635
- PluginsManager$1.emit('BeforeProcessChildren', parent);
1629
+ PluginsManager.emit('BeforeProcessChildren', parent);
1636
1630
  }
1637
1631
  let child = this.getChild(children);
1638
1632
  if(child) {
1639
1633
  parent.appendChild(child);
1640
1634
  }
1641
1635
  {
1642
- PluginsManager$1.emit('AfterProcessChildren', parent);
1636
+ PluginsManager.emit('AfterProcessChildren', parent);
1643
1637
  }
1644
1638
  },
1645
1639
  getChild(child) {
@@ -2864,7 +2858,7 @@ var NativeDocument = (function (exports) {
2864
2858
 
2865
2859
  ObservableItem.call(this, target, configs);
2866
2860
  {
2867
- PluginsManager$1.emit('CreateObservableArray', this);
2861
+ PluginsManager.emit('CreateObservableArray', this);
2868
2862
  }
2869
2863
  };
2870
2864
 
@@ -3265,7 +3259,7 @@ var NativeDocument = (function (exports) {
3265
3259
  const observable = new ObservableItem(initialValue);
3266
3260
  const updatedValue = nextTick(() => observable.set(callback()));
3267
3261
  {
3268
- PluginsManager$1.emit('CreateObservableComputed', observable, dependencies);
3262
+ PluginsManager.emit('CreateObservableComputed', observable, dependencies);
3269
3263
  }
3270
3264
 
3271
3265
  if(Validator.isFunction(dependencies)) {
@@ -3425,7 +3419,7 @@ var NativeDocument = (function (exports) {
3425
3419
  }
3426
3420
  cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
3427
3421
  } catch (e) {
3428
- DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
3422
+ DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
3429
3423
  throw e;
3430
3424
  }
3431
3425
  return keyId;
@@ -3771,7 +3765,7 @@ var NativeDocument = (function (exports) {
3771
3765
  */
3772
3766
  const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
3773
3767
  if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
3774
- return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
3768
+ return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
3775
3769
  }
3776
3770
  const element = Anchor('Show if : '+(comment || ''));
3777
3771
 
@@ -4558,7 +4552,7 @@ var NativeDocument = (function (exports) {
4558
4552
  window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
4559
4553
  this.handleRouteChange(route, params, query, path);
4560
4554
  } catch (e) {
4561
- DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
4555
+ DebugManager.error('HistoryRouter', 'Error in pushState', e);
4562
4556
  }
4563
4557
  };
4564
4558
  /**
@@ -4571,7 +4565,7 @@ var NativeDocument = (function (exports) {
4571
4565
  window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
4572
4566
  this.handleRouteChange(route, params, {}, path);
4573
4567
  } catch(e) {
4574
- DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
4568
+ DebugManager.error('HistoryRouter', 'Error in replaceState', e);
4575
4569
  }
4576
4570
  };
4577
4571
  this.forward = function() {
@@ -4598,7 +4592,7 @@ var NativeDocument = (function (exports) {
4598
4592
  }
4599
4593
  this.handleRouteChange(route, params, query, path);
4600
4594
  } catch(e) {
4601
- DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
4595
+ DebugManager.error('HistoryRouter', 'Error in popstate event', e);
4602
4596
  }
4603
4597
  });
4604
4598
  const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
@@ -4823,7 +4817,7 @@ var NativeDocument = (function (exports) {
4823
4817
  listener(request);
4824
4818
  next && next(request);
4825
4819
  } catch (e) {
4826
- DebugManager$1.warn('Route Listener', 'Error in listener:', e);
4820
+ DebugManager.warn('Route Listener', 'Error in listener:', e);
4827
4821
  }
4828
4822
  }
4829
4823
  };
@@ -4982,7 +4976,7 @@ var NativeDocument = (function (exports) {
4982
4976
  */
4983
4977
  Router.create = function(options, callback) {
4984
4978
  if(!Validator.isFunction(callback)) {
4985
- DebugManager$1.error('Router', 'Callback must be a function', e);
4979
+ DebugManager.error('Router', 'Callback must be a function', e);
4986
4980
  throw new RouterError('Callback must be a function');
4987
4981
  }
4988
4982
  const router = new Router(options);
@@ -5166,7 +5160,7 @@ var NativeDocument = (function (exports) {
5166
5160
  exports.HtmlElementWrapper = HtmlElementWrapper;
5167
5161
  exports.NDElement = NDElement;
5168
5162
  exports.Observable = Observable;
5169
- exports.PluginsManager = PluginsManager$1;
5163
+ exports.PluginsManager = PluginsManager;
5170
5164
  exports.SingletonView = SingletonView;
5171
5165
  exports.Store = Store;
5172
5166
  exports.TemplateCloner = TemplateCloner;