native-document 1.0.81 → 1.0.82

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.
@@ -362,80 +362,6 @@ var NativeComponents = (function (exports) {
362
362
  return this.observable.cleanup();
363
363
  };
364
364
 
365
- const PluginsManager = (function() {
366
-
367
- const $plugins = new Map();
368
- const $pluginByEvents = new Map();
369
-
370
- return {
371
- list() {
372
- return $pluginByEvents;
373
- },
374
- add(plugin, name){
375
- if (!plugin || typeof plugin !== 'object') {
376
- throw new Error(`Plugin ${name} must be an object`);
377
- }
378
- name = name || plugin.name;
379
- if (!name || typeof name !== 'string') {
380
- throw new Error(`Please, provide a valid plugin name`);
381
- }
382
- if($plugins.has(name)) {
383
- return;
384
- }
385
-
386
- plugin.$name = name;
387
- $plugins.set(name ,plugin);
388
- if(typeof plugin?.init === 'function') {
389
- plugin.init();
390
- }
391
- for(const methodName in plugin) {
392
- if(/^on[A-Z]/.test(methodName)) {
393
- const eventName = methodName.replace(/^on/, '');
394
- if(!$pluginByEvents.has(eventName)) {
395
- $pluginByEvents.set(eventName, new Set());
396
- }
397
- $pluginByEvents.get(eventName).add(plugin);
398
- }
399
- }
400
- },
401
- remove(pluginName){
402
- if(!$plugins.has(pluginName)) {
403
- return;
404
- }
405
- const plugin = $plugins.get(pluginName);
406
- if(typeof plugin.cleanup === 'function') {
407
- plugin.cleanup();
408
- }
409
- for(const [name, sets] of $pluginByEvents.entries() ) {
410
- if(sets.has(plugin)) {
411
- sets.delete(plugin);
412
- }
413
- if(sets.size === 0) {
414
- $pluginByEvents.delete(name);
415
- }
416
- }
417
- $plugins.delete(pluginName);
418
- },
419
- emit(eventName, ...data) {
420
- if(!$pluginByEvents.has(eventName)) {
421
- return;
422
- }
423
- const plugins = $pluginByEvents.get(eventName);
424
-
425
- for(const plugin of plugins) {
426
- const callback = plugin['on'+eventName];
427
- if(typeof callback === 'function') {
428
- try{
429
- callback.call(plugin, ...data);
430
- } catch (error) {
431
- DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
432
- }
433
- }
434
- }
435
- }
436
- };
437
- }());
438
-
439
365
  const ObservableWhen = function(observer, value) {
440
366
  this.$target = value;
441
367
  this.$observer = observer;
@@ -560,8 +486,6 @@ var NativeComponents = (function (exports) {
560
486
  this.$initialValue = Validator.isObject(value) ? deepClone(value) : value;
561
487
  }
562
488
  }
563
-
564
- PluginsManager.emit('CreateObservable', this);
565
489
  }
566
490
 
567
491
  Object.defineProperty(ObservableItem.prototype, '$value', {
@@ -686,10 +610,8 @@ var NativeComponents = (function (exports) {
686
610
  }
687
611
  this.$previousValue = this.$currentValue;
688
612
  this.$currentValue = newValue;
689
- PluginsManager.emit('ObservableBeforeChange', this);
690
613
  this.trigger();
691
614
  this.$previousValue = null;
692
- PluginsManager.emit('ObservableAfterChange', this);
693
615
  };
694
616
 
695
617
  ObservableItem.prototype.val = function() {
@@ -749,11 +671,9 @@ var NativeComponents = (function (exports) {
749
671
 
750
672
  this.$listeners.push(callback);
751
673
  this.assocTrigger();
752
- PluginsManager.emit('ObservableSubscribe', this, target);
753
674
  return () => {
754
675
  this.unsubscribe(callback);
755
676
  this.assocTrigger();
756
- PluginsManager.emit('ObservableUnsubscribe', this);
757
677
  };
758
678
  };
759
679
 
@@ -973,7 +893,6 @@ var NativeComponents = (function (exports) {
973
893
  function NDElement(element) {
974
894
  this.$element = element;
975
895
  this.$observer = null;
976
- PluginsManager.emit('NDElementCreated', element, this);
977
896
  }
978
897
 
979
898
  NDElement.prototype.__$isNDElement = true;
@@ -1132,8 +1051,6 @@ var NativeComponents = (function (exports) {
1132
1051
  NDElement.prototype[name] = method;
1133
1052
  }
1134
1053
 
1135
- PluginsManager.emit('NDElementExtended', methods);
1136
-
1137
1054
  return NDElement;
1138
1055
  };
1139
1056
 
@@ -1411,6 +1328,7 @@ var NativeComponents = (function (exports) {
1411
1328
 
1412
1329
  return anchorFragment;
1413
1330
  }
1331
+ DocumentFragment.prototype.setAttribute = () => {};
1414
1332
 
1415
1333
  const BOOLEAN_ATTRIBUTES = new Set([
1416
1334
  'checked',
@@ -1726,7 +1644,6 @@ var NativeComponents = (function (exports) {
1726
1644
 
1727
1645
  Function.prototype.toNdElement = function () {
1728
1646
  const child = this;
1729
- PluginsManager.emit('BeforeProcessComponent', child);
1730
1647
  return ElementCreator.getChild(child());
1731
1648
  };
1732
1649
 
@@ -1805,8 +1722,9 @@ var NativeComponents = (function (exports) {
1805
1722
  */
1806
1723
  createElement(name) {
1807
1724
  if(name) {
1808
- if($nodeCache.has(name)) {
1809
- return $nodeCache.get(name).cloneNode();
1725
+ const cacheNode = $nodeCache.get(name);
1726
+ if(cacheNode) {
1727
+ return cacheNode.cloneNode();
1810
1728
  }
1811
1729
  const node = document.createElement(name);
1812
1730
  $nodeCache.set(name, node);
@@ -1821,12 +1739,10 @@ var NativeComponents = (function (exports) {
1821
1739
  */
1822
1740
  processChildren(children, parent) {
1823
1741
  if(children === null) return;
1824
- PluginsManager.emit('BeforeProcessChildren', parent);
1825
1742
  let child = this.getChild(children);
1826
1743
  if(child) {
1827
1744
  parent.appendChild(child);
1828
1745
  }
1829
- PluginsManager.emit('AfterProcessChildren', parent);
1830
1746
  },
1831
1747
  getChild(child) {
1832
1748
  if(child == null) {
@@ -1849,7 +1765,6 @@ var NativeComponents = (function (exports) {
1849
1765
  * @param {Object} attributes
1850
1766
  */
1851
1767
  processAttributes(element, attributes) {
1852
- if(Validator.isFragment(element)) return;
1853
1768
  if (attributes) {
1854
1769
  AttributesWrapper(element, attributes);
1855
1770
  }
@@ -1862,7 +1777,6 @@ var NativeComponents = (function (exports) {
1862
1777
  * @returns {HTMLElement|DocumentFragment}
1863
1778
  */
1864
1779
  setup(element, attributes, customWrapper) {
1865
- PluginsManager.emit('Setup', element, attributes, customWrapper);
1866
1780
  return element;
1867
1781
  }
1868
1782
  };
@@ -2160,13 +2074,8 @@ var NativeComponents = (function (exports) {
2160
2074
  let element = ElementCreator.createElement($tagName);
2161
2075
  let finalElement = (customWrapper && typeof customWrapper === 'function') ? customWrapper(element) : element;
2162
2076
 
2163
- if(attributes) {
2164
- ElementCreator.processAttributes(finalElement, attributes);
2165
- }
2166
- if(children) {
2167
- ElementCreator.processChildren(children, finalElement);
2168
- }
2169
-
2077
+ ElementCreator.processAttributes(finalElement, attributes);
2078
+ ElementCreator.processChildren(children, finalElement);
2170
2079
  return ElementCreator.setup(finalElement, attributes, customWrapper);
2171
2080
  }
2172
2081
 
@@ -2292,7 +2201,6 @@ var NativeComponents = (function (exports) {
2292
2201
  }
2293
2202
 
2294
2203
  ObservableItem.call(this, target, configs);
2295
- PluginsManager.emit('CreateObservableArray', this);
2296
2204
  };
2297
2205
 
2298
2206
  ObservableArray.prototype = Object.create(ObservableItem.prototype);
@@ -2692,8 +2600,6 @@ var NativeComponents = (function (exports) {
2692
2600
  const observable = new ObservableItem(initialValue);
2693
2601
  const updatedValue = nextTick(() => observable.set(callback()));
2694
2602
 
2695
- PluginsManager.emit('CreateObservableComputed', observable, dependencies);
2696
-
2697
2603
  if(Validator.isFunction(dependencies)) {
2698
2604
  if(!Validator.isObservable(dependencies.$observer)) {
2699
2605
  throw new NativeDocumentError('Observable.computed : dependencies must be valid batch function');
@@ -141,79 +141,85 @@ var NativeDocument = (function (exports) {
141
141
  return this.observable.cleanup();
142
142
  };
143
143
 
144
- const PluginsManager = (function() {
144
+ let PluginsManager$1 = null;
145
145
 
146
- const $plugins = new Map();
147
- const $pluginByEvents = new Map();
146
+ {
147
+ PluginsManager$1 = (function() {
148
148
 
149
- return {
150
- list() {
151
- return $pluginByEvents;
152
- },
153
- add(plugin, name){
154
- if (!plugin || typeof plugin !== 'object') {
155
- throw new Error(`Plugin ${name} must be an object`);
156
- }
157
- name = name || plugin.name;
158
- if (!name || typeof name !== 'string') {
159
- throw new Error(`Please, provide a valid plugin name`);
160
- }
161
- if($plugins.has(name)) {
162
- return;
163
- }
149
+ const $plugins = new Map();
150
+ const $pluginByEvents = new Map();
164
151
 
165
- plugin.$name = name;
166
- $plugins.set(name ,plugin);
167
- if(typeof plugin?.init === 'function') {
168
- plugin.init();
169
- }
170
- for(const methodName in plugin) {
171
- if(/^on[A-Z]/.test(methodName)) {
172
- const eventName = methodName.replace(/^on/, '');
173
- if(!$pluginByEvents.has(eventName)) {
174
- $pluginByEvents.set(eventName, new Set());
152
+ return {
153
+ list() {
154
+ return $pluginByEvents;
155
+ },
156
+ add(plugin, name){
157
+ if (!plugin || typeof plugin !== 'object') {
158
+ throw new Error(`Plugin ${name} must be an object`);
159
+ }
160
+ name = name || plugin.name;
161
+ if (!name || typeof name !== 'string') {
162
+ throw new Error(`Please, provide a valid plugin name`);
163
+ }
164
+ if($plugins.has(name)) {
165
+ return;
166
+ }
167
+
168
+ plugin.$name = name;
169
+ $plugins.set(name ,plugin);
170
+ if(typeof plugin?.init === 'function') {
171
+ plugin.init();
172
+ }
173
+ for(const methodName in plugin) {
174
+ if(/^on[A-Z]/.test(methodName)) {
175
+ const eventName = methodName.replace(/^on/, '');
176
+ if(!$pluginByEvents.has(eventName)) {
177
+ $pluginByEvents.set(eventName, new Set());
178
+ }
179
+ $pluginByEvents.get(eventName).add(plugin);
175
180
  }
176
- $pluginByEvents.get(eventName).add(plugin);
177
181
  }
178
- }
179
- },
180
- remove(pluginName){
181
- if(!$plugins.has(pluginName)) {
182
- return;
183
- }
184
- const plugin = $plugins.get(pluginName);
185
- if(typeof plugin.cleanup === 'function') {
186
- plugin.cleanup();
187
- }
188
- for(const [name, sets] of $pluginByEvents.entries() ) {
189
- if(sets.has(plugin)) {
190
- sets.delete(plugin);
182
+ },
183
+ remove(pluginName){
184
+ if(!$plugins.has(pluginName)) {
185
+ return;
191
186
  }
192
- if(sets.size === 0) {
193
- $pluginByEvents.delete(name);
187
+ const plugin = $plugins.get(pluginName);
188
+ if(typeof plugin.cleanup === 'function') {
189
+ plugin.cleanup();
194
190
  }
195
- }
196
- $plugins.delete(pluginName);
197
- },
198
- emit(eventName, ...data) {
199
- if(!$pluginByEvents.has(eventName)) {
200
- return;
201
- }
202
- const plugins = $pluginByEvents.get(eventName);
203
-
204
- for(const plugin of plugins) {
205
- const callback = plugin['on'+eventName];
206
- if(typeof callback === 'function') {
207
- try{
208
- callback.call(plugin, ...data);
209
- } catch (error) {
210
- DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
191
+ for(const [name, sets] of $pluginByEvents.entries() ) {
192
+ if(sets.has(plugin)) {
193
+ sets.delete(plugin);
194
+ }
195
+ if(sets.size === 0) {
196
+ $pluginByEvents.delete(name);
197
+ }
198
+ }
199
+ $plugins.delete(pluginName);
200
+ },
201
+ emit(eventName, ...data) {
202
+ if(!$pluginByEvents.has(eventName)) {
203
+ return;
204
+ }
205
+ const plugins = $pluginByEvents.get(eventName);
206
+
207
+ for(const plugin of plugins) {
208
+ const callback = plugin['on'+eventName];
209
+ if(typeof callback === 'function') {
210
+ try{
211
+ callback.call(plugin, ...data);
212
+ } catch (error) {
213
+ DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
214
+ }
211
215
  }
212
216
  }
213
217
  }
214
- }
215
- };
216
- }());
218
+ };
219
+ }());
220
+ }
221
+
222
+ var PluginsManager = PluginsManager$1;
217
223
 
218
224
  const ObservableWhen = function(observer, value) {
219
225
  this.$target = value;
@@ -334,8 +340,9 @@ var NativeDocument = (function (exports) {
334
340
  this.$initialValue = Validator.isObject(value) ? deepClone(value) : value;
335
341
  }
336
342
  }
337
-
338
- PluginsManager.emit('CreateObservable', this);
343
+ {
344
+ PluginsManager.emit('CreateObservable', this);
345
+ }
339
346
  }
340
347
 
341
348
  Object.defineProperty(ObservableItem.prototype, '$value', {
@@ -460,10 +467,14 @@ var NativeDocument = (function (exports) {
460
467
  }
461
468
  this.$previousValue = this.$currentValue;
462
469
  this.$currentValue = newValue;
463
- PluginsManager.emit('ObservableBeforeChange', this);
470
+ {
471
+ PluginsManager.emit('ObservableBeforeChange', this);
472
+ }
464
473
  this.trigger();
465
474
  this.$previousValue = null;
466
- PluginsManager.emit('ObservableAfterChange', this);
475
+ {
476
+ PluginsManager.emit('ObservableAfterChange', this);
477
+ }
467
478
  };
468
479
 
469
480
  ObservableItem.prototype.val = function() {
@@ -523,11 +534,15 @@ var NativeDocument = (function (exports) {
523
534
 
524
535
  this.$listeners.push(callback);
525
536
  this.assocTrigger();
526
- PluginsManager.emit('ObservableSubscribe', this, target);
537
+ {
538
+ PluginsManager.emit('ObservableSubscribe', this, target);
539
+ }
527
540
  return () => {
528
541
  this.unsubscribe(callback);
529
542
  this.assocTrigger();
530
- PluginsManager.emit('ObservableUnsubscribe', this);
543
+ {
544
+ PluginsManager.emit('ObservableUnsubscribe', this);
545
+ }
531
546
  };
532
547
  };
533
548
 
@@ -747,7 +762,9 @@ var NativeDocument = (function (exports) {
747
762
  function NDElement(element) {
748
763
  this.$element = element;
749
764
  this.$observer = null;
750
- PluginsManager.emit('NDElementCreated', element, this);
765
+ {
766
+ PluginsManager.emit('NDElementCreated', element, this);
767
+ }
751
768
  }
752
769
 
753
770
  NDElement.prototype.__$isNDElement = true;
@@ -916,8 +933,9 @@ var NativeDocument = (function (exports) {
916
933
 
917
934
  NDElement.prototype[name] = method;
918
935
  }
919
-
920
- PluginsManager.emit('NDElementExtended', methods);
936
+ {
937
+ PluginsManager.emit('NDElementExtended', methods);
938
+ }
921
939
 
922
940
  return NDElement;
923
941
  };
@@ -1227,6 +1245,8 @@ var NativeDocument = (function (exports) {
1227
1245
  return anchor;
1228
1246
  }
1229
1247
 
1248
+ DocumentFragment.prototype.setAttribute = () => {};
1249
+
1230
1250
  const BOOLEAN_ATTRIBUTES = new Set([
1231
1251
  'checked',
1232
1252
  'selected',
@@ -1544,7 +1564,9 @@ var NativeDocument = (function (exports) {
1544
1564
 
1545
1565
  Function.prototype.toNdElement = function () {
1546
1566
  const child = this;
1547
- PluginsManager.emit('BeforeProcessComponent', child);
1567
+ {
1568
+ PluginsManager.emit('BeforeProcessComponent', child);
1569
+ }
1548
1570
  return ElementCreator.getChild(child());
1549
1571
  };
1550
1572
 
@@ -1623,8 +1645,9 @@ var NativeDocument = (function (exports) {
1623
1645
  */
1624
1646
  createElement(name) {
1625
1647
  if(name) {
1626
- if($nodeCache.has(name)) {
1627
- return $nodeCache.get(name).cloneNode();
1648
+ const cacheNode = $nodeCache.get(name);
1649
+ if(cacheNode) {
1650
+ return cacheNode.cloneNode();
1628
1651
  }
1629
1652
  const node = document.createElement(name);
1630
1653
  $nodeCache.set(name, node);
@@ -1639,12 +1662,16 @@ var NativeDocument = (function (exports) {
1639
1662
  */
1640
1663
  processChildren(children, parent) {
1641
1664
  if(children === null) return;
1642
- PluginsManager.emit('BeforeProcessChildren', parent);
1665
+ {
1666
+ PluginsManager.emit('BeforeProcessChildren', parent);
1667
+ }
1643
1668
  let child = this.getChild(children);
1644
1669
  if(child) {
1645
1670
  parent.appendChild(child);
1646
1671
  }
1647
- PluginsManager.emit('AfterProcessChildren', parent);
1672
+ {
1673
+ PluginsManager.emit('AfterProcessChildren', parent);
1674
+ }
1648
1675
  },
1649
1676
  getChild(child) {
1650
1677
  if(child == null) {
@@ -1667,7 +1694,6 @@ var NativeDocument = (function (exports) {
1667
1694
  * @param {Object} attributes
1668
1695
  */
1669
1696
  processAttributes(element, attributes) {
1670
- if(Validator.isFragment(element)) return;
1671
1697
  if (attributes) {
1672
1698
  AttributesWrapper(element, attributes);
1673
1699
  }
@@ -1680,7 +1706,9 @@ var NativeDocument = (function (exports) {
1680
1706
  * @returns {HTMLElement|DocumentFragment}
1681
1707
  */
1682
1708
  setup(element, attributes, customWrapper) {
1683
- PluginsManager.emit('Setup', element, attributes, customWrapper);
1709
+ {
1710
+ PluginsManager.emit('Setup', element, attributes, customWrapper);
1711
+ }
1684
1712
  return element;
1685
1713
  }
1686
1714
  };
@@ -2099,13 +2127,8 @@ var NativeDocument = (function (exports) {
2099
2127
  let element = ElementCreator.createElement($tagName);
2100
2128
  let finalElement = (customWrapper && typeof customWrapper === 'function') ? customWrapper(element) : element;
2101
2129
 
2102
- if(attributes) {
2103
- ElementCreator.processAttributes(finalElement, attributes);
2104
- }
2105
- if(children) {
2106
- ElementCreator.processChildren(children, finalElement);
2107
- }
2108
-
2130
+ ElementCreator.processAttributes(finalElement, attributes);
2131
+ ElementCreator.processChildren(children, finalElement);
2109
2132
  return ElementCreator.setup(finalElement, attributes, customWrapper);
2110
2133
  }
2111
2134
 
@@ -2897,7 +2920,9 @@ var NativeDocument = (function (exports) {
2897
2920
  }
2898
2921
 
2899
2922
  ObservableItem.call(this, target, configs);
2900
- PluginsManager.emit('CreateObservableArray', this);
2923
+ {
2924
+ PluginsManager.emit('CreateObservableArray', this);
2925
+ }
2901
2926
  };
2902
2927
 
2903
2928
  ObservableArray.prototype = Object.create(ObservableItem.prototype);
@@ -3296,8 +3321,9 @@ var NativeDocument = (function (exports) {
3296
3321
  const initialValue = callback();
3297
3322
  const observable = new ObservableItem(initialValue);
3298
3323
  const updatedValue = nextTick(() => observable.set(callback()));
3299
-
3300
- PluginsManager.emit('CreateObservableComputed', observable, dependencies);
3324
+ {
3325
+ PluginsManager.emit('CreateObservableComputed', observable, dependencies);
3326
+ }
3301
3327
 
3302
3328
  if(Validator.isFunction(dependencies)) {
3303
3329
  if(!Validator.isObservable(dependencies.$observer)) {
@@ -3618,7 +3644,7 @@ var NativeDocument = (function (exports) {
3618
3644
  if(child) {
3619
3645
  cache.set(item, {
3620
3646
  child,
3621
- indexObserver: (indexObserver ? new WeakRef(indexObserver) : null)
3647
+ indexObserver
3622
3648
  });
3623
3649
  return child;
3624
3650
  }