native-document 1.0.49 → 1.0.51

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,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
  };
@@ -207,7 +207,7 @@ var NativeDocument = (function (exports) {
207
207
  try{
208
208
  callback.call(plugin, ...data);
209
209
  } catch (error) {
210
- DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
210
+ DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
211
211
  }
212
212
  }
213
213
  }
@@ -395,7 +395,7 @@ var NativeDocument = (function (exports) {
395
395
  ObservableItem.prototype.subscribe = function(callback, target = null) {
396
396
  this.$listeners = this.$listeners ?? [];
397
397
  if (this.$isCleanedUp) {
398
- DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
398
+ DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
399
399
  return () => {};
400
400
  }
401
401
  if (typeof callback !== 'function') {
@@ -1017,7 +1017,7 @@ var NativeDocument = (function (exports) {
1017
1017
  const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
1018
1018
 
1019
1019
  if (foundReserved.length > 0) {
1020
- DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
1020
+ DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
1021
1021
  }
1022
1022
 
1023
1023
  return attributes;
@@ -1065,7 +1065,7 @@ var NativeDocument = (function (exports) {
1065
1065
  element.appendChild = function(child, before = null) {
1066
1066
  const parent = anchorEnd.parentNode;
1067
1067
  if(!parent) {
1068
- DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
1068
+ DebugManager.error('Anchor', 'Anchor : parent not found', child);
1069
1069
  return;
1070
1070
  }
1071
1071
  before = before ?? anchorEnd;
@@ -1183,6 +1183,9 @@ var NativeDocument = (function (exports) {
1183
1183
  return new ObservableItem(value);
1184
1184
  }
1185
1185
 
1186
+ const $ = Observable;
1187
+ const obs = Observable;
1188
+
1186
1189
  /**
1187
1190
  *
1188
1191
  * @param {string} propertyName
@@ -2639,7 +2642,7 @@ var NativeDocument = (function (exports) {
2639
2642
  }
2640
2643
  cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
2641
2644
  } catch (e) {
2642
- DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
2645
+ DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
2643
2646
  throw e;
2644
2647
  }
2645
2648
  return keyId;
@@ -3009,9 +3012,9 @@ var NativeDocument = (function (exports) {
3009
3012
  * @param {{comment?: string|null, shouldKeepInCache?: Boolean}} configs
3010
3013
  * @returns {DocumentFragment}
3011
3014
  */
3012
- const ShowIf$1 = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
3015
+ const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
3013
3016
  if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
3014
- return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
3017
+ return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
3015
3018
  }
3016
3019
  const element = new Anchor('Show if : '+(comment || ''));
3017
3020
 
@@ -3054,7 +3057,7 @@ var NativeDocument = (function (exports) {
3054
3057
  const hideCondition = Observable(!condition.val());
3055
3058
  condition.subscribe(value => hideCondition.set(!value));
3056
3059
 
3057
- return ShowIf$1(hideCondition, child, configs);
3060
+ return ShowIf(hideCondition, child, configs);
3058
3061
  };
3059
3062
 
3060
3063
  /**
@@ -3066,7 +3069,7 @@ var NativeDocument = (function (exports) {
3066
3069
  * @returns {DocumentFragment}
3067
3070
  */
3068
3071
  const HideIfNot = function(condition, child, configs) {
3069
- return ShowIf$1(condition, child, configs);
3072
+ return ShowIf(condition, child, configs);
3070
3073
  };
3071
3074
 
3072
3075
  const ShowWhen = function() {
@@ -3078,7 +3081,7 @@ var NativeDocument = (function (exports) {
3078
3081
  'help': 'Use observer.when(target) to create an ObservableWhenResult'
3079
3082
  });
3080
3083
  }
3081
- return ShowIf$1(observer, target);
3084
+ return ShowIf(observer, target);
3082
3085
  }
3083
3086
  if(arguments.length === 3) {
3084
3087
  const [observer, target, view] = arguments;
@@ -3087,7 +3090,7 @@ var NativeDocument = (function (exports) {
3087
3090
  data: observer,
3088
3091
  });
3089
3092
  }
3090
- return ShowIf$1(observer.when(target), view);
3093
+ return ShowIf(observer.when(target), view);
3091
3094
  }
3092
3095
  throw new NativeDocumentError('showWhen must have 2 or 3 arguments', {
3093
3096
  data: [
@@ -3479,7 +3482,7 @@ var NativeDocument = (function (exports) {
3479
3482
  SearchInput: SearchInput,
3480
3483
  Section: Section,
3481
3484
  Select: Select,
3482
- ShowIf: ShowIf$1,
3485
+ ShowIf: ShowIf,
3483
3486
  ShowWhen: ShowWhen,
3484
3487
  SimpleButton: SimpleButton,
3485
3488
  Small: Small,
@@ -3787,7 +3790,7 @@ var NativeDocument = (function (exports) {
3787
3790
  window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
3788
3791
  this.handleRouteChange(route, params, query, path);
3789
3792
  } catch (e) {
3790
- DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
3793
+ DebugManager.error('HistoryRouter', 'Error in pushState', e);
3791
3794
  }
3792
3795
  };
3793
3796
  /**
@@ -3800,7 +3803,7 @@ var NativeDocument = (function (exports) {
3800
3803
  window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
3801
3804
  this.handleRouteChange(route, params, {}, path);
3802
3805
  } catch(e) {
3803
- DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
3806
+ DebugManager.error('HistoryRouter', 'Error in replaceState', e);
3804
3807
  }
3805
3808
  };
3806
3809
  this.forward = function() {
@@ -3827,7 +3830,7 @@ var NativeDocument = (function (exports) {
3827
3830
  }
3828
3831
  this.handleRouteChange(route, params, query, path);
3829
3832
  } catch(e) {
3830
- DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
3833
+ DebugManager.error('HistoryRouter', 'Error in popstate event', e);
3831
3834
  }
3832
3835
  });
3833
3836
  const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
@@ -3981,7 +3984,7 @@ var NativeDocument = (function (exports) {
3981
3984
  listener(request);
3982
3985
  next && next(request);
3983
3986
  } catch (e) {
3984
- DebugManager$1.warn('Route Listener', 'Error in listener:', e);
3987
+ DebugManager.warn('Route Listener', 'Error in listener:', e);
3985
3988
  }
3986
3989
  }
3987
3990
  };
@@ -4140,7 +4143,7 @@ var NativeDocument = (function (exports) {
4140
4143
  */
4141
4144
  Router.create = function(options, callback) {
4142
4145
  if(!Validator.isFunction(callback)) {
4143
- DebugManager$1.error('Router', 'Callback must be a function', e);
4146
+ DebugManager.error('Router', 'Callback must be a function', e);
4144
4147
  throw new RouterError('Callback must be a function');
4145
4148
  }
4146
4149
  const router = new Router(options);
@@ -4220,6 +4223,7 @@ var NativeDocument = (function (exports) {
4220
4223
  Router: Router
4221
4224
  });
4222
4225
 
4226
+ exports.$ = $;
4223
4227
  exports.ElementCreator = ElementCreator;
4224
4228
  exports.HtmlElementWrapper = HtmlElementWrapper;
4225
4229
  exports.NDElement = NDElement;
@@ -4238,6 +4242,7 @@ var NativeDocument = (function (exports) {
4238
4242
  exports.elements = elements;
4239
4243
  exports.memoize = memoize;
4240
4244
  exports.normalizeComponentArgs = normalizeComponentArgs;
4245
+ exports.obs = obs;
4241
4246
  exports.once = once;
4242
4247
  exports.router = router;
4243
4248
  exports.useCache = useCache;