native-document 1.0.163 → 1.0.164

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.
@@ -3307,6 +3307,23 @@ var NativeComponents = (function (exports) {
3307
3307
  return this;
3308
3308
  };
3309
3309
 
3310
+ NDElement.prototype.destroyOnUnmount = function() {
3311
+ this.unmounted(() => {
3312
+ this.$element?.querySelectorAll('[data--nd-before-unmount]').forEach(child => {
3313
+ child.remove();
3314
+ child.__$controller?.abort();
3315
+ child.__$controller = null;
3316
+ $lifeCycleObservers.delete(child);
3317
+ });
3318
+
3319
+ this.$element.__$controller?.abort();
3320
+ this.$element.__$controller = null;
3321
+ $lifeCycleObservers.delete(this.$element);
3322
+ this.$element = null;
3323
+ });
3324
+ return this;
3325
+ };
3326
+
3310
3327
  NDElement.prototype.mounted = function(callback) {
3311
3328
  return this.lifecycle({ mounted: callback });
3312
3329
  };
@@ -3323,6 +3340,7 @@ var NativeComponents = (function (exports) {
3323
3340
  const originalRemove = el.remove.bind(el);
3324
3341
 
3325
3342
  let $isUnmounting = false;
3343
+ this.$element.setAttribute('data--nd-before-unmount', '1');
3326
3344
 
3327
3345
  el.remove = async () => {
3328
3346
  if($isUnmounting) {
@@ -12167,14 +12185,10 @@ var NativeComponents = (function (exports) {
12167
12185
  });
12168
12186
 
12169
12187
  NDElement.prototype.$getSignal = function() {
12170
- if(!this.$controller) {
12171
- this.$controller = new AbortController();
12172
- this.beforeUnmount('abort-controller', () => {
12173
- this.$controller.abort();
12174
- this.$controller = null;
12175
- });
12188
+ if(!this.$element.__$controller) {
12189
+ this.$element.__$controller = new AbortController();
12176
12190
  }
12177
- return this.$controller.signal;
12191
+ return this.$element.__$controller.signal;
12178
12192
  };
12179
12193
 
12180
12194
  NDElement.prototype.on = function(name, callback, options) {
@@ -3837,6 +3837,23 @@ var NativeDocument = (function (exports) {
3837
3837
  return this;
3838
3838
  };
3839
3839
 
3840
+ NDElement.prototype.destroyOnUnmount = function() {
3841
+ this.unmounted(() => {
3842
+ this.$element?.querySelectorAll('[data--nd-before-unmount]').forEach(child => {
3843
+ child.remove();
3844
+ child.__$controller?.abort();
3845
+ child.__$controller = null;
3846
+ $lifeCycleObservers.delete(child);
3847
+ });
3848
+
3849
+ this.$element.__$controller?.abort();
3850
+ this.$element.__$controller = null;
3851
+ $lifeCycleObservers.delete(this.$element);
3852
+ this.$element = null;
3853
+ });
3854
+ return this;
3855
+ };
3856
+
3840
3857
  NDElement.prototype.mounted = function(callback) {
3841
3858
  return this.lifecycle({ mounted: callback });
3842
3859
  };
@@ -3853,6 +3870,7 @@ var NativeDocument = (function (exports) {
3853
3870
  const originalRemove = el.remove.bind(el);
3854
3871
 
3855
3872
  let $isUnmounting = false;
3873
+ this.$element.setAttribute('data--nd-before-unmount', '1');
3856
3874
 
3857
3875
  el.remove = async () => {
3858
3876
  if($isUnmounting) {
@@ -4251,14 +4269,10 @@ var NativeDocument = (function (exports) {
4251
4269
  });
4252
4270
 
4253
4271
  NDElement.prototype.$getSignal = function() {
4254
- if(!this.$controller) {
4255
- this.$controller = new AbortController();
4256
- this.beforeUnmount('abort-controller', () => {
4257
- this.$controller.abort();
4258
- this.$controller = null;
4259
- });
4272
+ if(!this.$element.__$controller) {
4273
+ this.$element.__$controller = new AbortController();
4260
4274
  }
4261
- return this.$controller.signal;
4275
+ return this.$element.__$controller.signal;
4262
4276
  };
4263
4277
 
4264
4278
  NDElement.prototype.on = function(name, callback, options) {
@@ -4926,27 +4940,30 @@ var NativeDocument = (function (exports) {
4926
4940
  if(!$cacheNode) {
4927
4941
  $cacheNode = $viewCreator(this);
4928
4942
  }
4929
- if(!$components) {
4930
- return $cacheNode;
4931
- }
4932
- for(const index in $components) {
4933
- const updater = $components[index];
4934
- updater(...data);
4943
+ if(!$components) return $cacheNode;
4944
+
4945
+ const updates = data[0];
4946
+ if(updates && typeof updates === 'object') {
4947
+ for(const key in updates) {
4948
+ if($components[key]) {
4949
+ $components[key](updates[key]);
4950
+ }
4951
+ }
4935
4952
  }
4936
4953
  return $cacheNode;
4937
4954
  };
4938
4955
 
4939
4956
  this.createSection = (name, fn) => {
4940
4957
  $components = $components || {};
4941
- const anchor = Anchor('Component '+name);
4958
+ const anchor = Anchor('Component ' + name);
4942
4959
 
4943
- $components[name] = function(...args) {
4960
+ $components[name] = function(content) {
4944
4961
  anchor.removeChildren();
4945
4962
  if(!fn) {
4946
- anchor.append(args);
4963
+ anchor.append(content);
4947
4964
  return;
4948
4965
  }
4949
- anchor.appendChild(fn(...args));
4966
+ anchor.appendChild(fn(content));
4950
4967
  };
4951
4968
  return anchor;
4952
4969
  };
@@ -7248,7 +7265,25 @@ var NativeDocument = (function (exports) {
7248
7265
  });
7249
7266
 
7250
7267
  const RouteParamPatterns = {
7268
+ id: '[0-9]+',
7269
+ uuid: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
7270
+ slug: '[a-z0-9]+(?:-[a-z0-9]+)*',
7271
+ hash: '[a-f0-9]{32,64}',
7272
+
7273
+ alpha: '[a-zA-Z]+',
7274
+ alphanum: '[a-zA-Z0-9]+',
7275
+ string: '[^/]+',
7276
+ any: '.*',
7277
+
7278
+ int: '[0-9]+',
7279
+ float: '[0-9]+\\.[0-9]+',
7280
+ number: '[0-9]+(\\.[0-9]+)?',
7281
+ positive: '[1-9][0-9]*',
7282
+
7283
+ locale: '[a-z]{2}(-[A-Z]{2})?',
7284
+ lang: '[a-z]{2}',
7251
7285
 
7286
+ token: '[A-Za-z0-9_\\-]+',
7252
7287
  };
7253
7288
 
7254
7289
  /**