native-document 1.0.119 → 1.0.120

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.
@@ -363,16 +363,16 @@ var NativeComponents = (function (exports) {
363
363
  // });
364
364
  };
365
365
 
366
- let DebugManager$2 = {};
366
+ let DebugManager$1 = {};
367
367
  {
368
- DebugManager$2 = {
368
+ DebugManager$1 = {
369
369
  log() {},
370
370
  warn() {},
371
371
  error() {},
372
372
  disable() {}
373
373
  };
374
374
  }
375
- var DebugManager$1 = DebugManager$2;
375
+ var DebugManager$2 = DebugManager$1;
376
376
 
377
377
  /**
378
378
  *
@@ -846,17 +846,17 @@ var NativeComponents = (function (exports) {
846
846
  const method = methods[name];
847
847
 
848
848
  if (typeof method !== 'function') {
849
- DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
849
+ DebugManager$2.warn('NDElement.extend', `"${name}" is not a function, skipping`);
850
850
  continue;
851
851
  }
852
852
 
853
853
  if (protectedMethods.has(name)) {
854
- DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
854
+ DebugManager$2.error('NDElement.extend', `Cannot override protected method "${name}"`);
855
855
  throw new NativeDocumentError(`Cannot override protected method "${name}"`);
856
856
  }
857
857
 
858
858
  if (NDElement.prototype[name]) {
859
- DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
859
+ DebugManager$2.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
860
860
  }
861
861
 
862
862
  NDElement.prototype[name] = method;
@@ -1081,7 +1081,7 @@ var NativeComponents = (function (exports) {
1081
1081
  }
1082
1082
  }
1083
1083
  if (cleanedCount > 0) {
1084
- DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
1084
+ DebugManager$2.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
1085
1085
  }
1086
1086
  }
1087
1087
  };
@@ -1486,6 +1486,8 @@ var NativeComponents = (function (exports) {
1486
1486
  };
1487
1487
  ObservableItem.prototype.trigger = noneTrigger;
1488
1488
 
1489
+
1490
+ const $setOperation = { action: 'set' };
1489
1491
  ObservableItem.prototype.$updateWithNewValue = function(newValue) {
1490
1492
  newValue = newValue?.__$isObservable ? newValue.val() : newValue;
1491
1493
  if(this.$currentValue === newValue) {
@@ -1493,7 +1495,7 @@ var NativeComponents = (function (exports) {
1493
1495
  }
1494
1496
  this.$previousValue = this.$currentValue;
1495
1497
  this.$currentValue = newValue;
1496
- this.trigger();
1498
+ this.trigger($setOperation);
1497
1499
  this.$previousValue = null;
1498
1500
  };
1499
1501
 
@@ -2399,29 +2401,51 @@ var NativeComponents = (function (exports) {
2399
2401
  anchor.remove = () => {
2400
2402
  anchor.append.apply(anchor, parent.childNodes);
2401
2403
  };
2404
+ anchor.getParent = () => parent;
2402
2405
 
2403
2406
  anchor.appendChild = (child) => {
2404
2407
  child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2405
2408
  parent.appendChild(child);
2406
2409
  };
2407
2410
 
2411
+ anchor.appendChildRaw = parent.appendChild.bind(parent);
2412
+ anchor.append = anchor.appendChild;
2413
+ anchor.appendRaw = anchor.appendChildRaw;
2414
+
2415
+ anchor.insertAtStart = (child) => {
2416
+ child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2417
+ parent.firstChild ? parent.insertBefore(child, parent.firstChild) : parent.appendChild(child);
2418
+ };
2419
+ anchor.insertAtStartRaw = (child) => {
2420
+ parent.firstChild ? parent.insertBefore(child, parent.firstChild) : parent.appendChild(child);
2421
+ };
2422
+
2408
2423
  anchor.appendElement = anchor.appendChild;
2409
2424
 
2410
2425
  anchor.removeChildren = () => {
2411
- parent.replaceChildren();
2426
+ parent.textContent = '';
2412
2427
  };
2413
2428
 
2414
2429
  anchor.replaceContent = function(content) {
2415
2430
  const child = Validator.isElement(content) ? content : ElementCreator.getChild(content);
2416
2431
  parent.replaceChildren(child);
2417
2432
  };
2433
+
2434
+ anchor.replaceContentRaw = function(child) {
2435
+ parent.replaceChildren(child);
2436
+ };
2418
2437
  anchor.setContent = anchor.replaceContent;
2419
2438
 
2420
2439
  anchor.insertBefore = (child, anchor) => {
2421
2440
  child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2422
2441
  parent.insertBefore(child, anchor);
2423
2442
  };
2443
+ anchor.insertBeforeRaw = (child, anchor) => {
2444
+ parent.insertBefore(child, anchor);
2445
+ };
2446
+
2424
2447
  anchor.appendChildBefore = anchor.insertBefore;
2448
+ anchor.appendChildBeforeRaw = anchor.insertBeforeRaw;
2425
2449
 
2426
2450
  anchor.clear = anchor.remove;
2427
2451
  anchor.detach = anchor.remove;
@@ -2447,7 +2471,6 @@ var NativeComponents = (function (exports) {
2447
2471
 
2448
2472
  anchorFragment.onConnectedOnce((parent) => {
2449
2473
  if(isUniqueChild) {
2450
- console.log('Lets overwrite some functions with parent ', parent);
2451
2474
  oneChildAnchorOverwriting(anchorFragment, parent);
2452
2475
  }
2453
2476
  });
@@ -2469,15 +2492,19 @@ var NativeComponents = (function (exports) {
2469
2492
 
2470
2493
  const insertBefore = function(parent, child, target) {
2471
2494
  const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2495
+ insertBeforeRaw(parent, childElement, target);
2496
+ };
2497
+
2498
+ const insertBeforeRaw = function(parent, child, target) {
2472
2499
  if(parent === anchorFragment) {
2473
- parent.nativeInsertBefore(childElement, target);
2500
+ parent.nativeInsertBefore(child, target);
2474
2501
  return;
2475
2502
  }
2476
2503
  if(isParentUniqueChild(parent) && target === anchorEnd) {
2477
- parent.append(childElement, target);
2504
+ parent.append(child, target);
2478
2505
  return;
2479
2506
  }
2480
- parent.insertBefore(childElement, target);
2507
+ parent.insertBefore(child, target);
2481
2508
  };
2482
2509
 
2483
2510
  anchorFragment.appendElement = function(child) {
@@ -2499,8 +2526,32 @@ var NativeComponents = (function (exports) {
2499
2526
  insertBefore(parent, child, before);
2500
2527
  };
2501
2528
 
2502
- anchorFragment.append = function() {
2503
- return anchorFragment.appendChild(Array.from(arguments));
2529
+ anchorFragment.appendChildRaw = function(child, before = null) {
2530
+ const parent = anchorEnd.parentNode;
2531
+ if(!parent) {
2532
+ DebugManager.error('Anchor', 'Anchor : parent not found', child);
2533
+ return;
2534
+ }
2535
+ before = before ?? anchorEnd;
2536
+ insertBeforeRaw(parent, child, before);
2537
+ };
2538
+
2539
+ anchorFragment.getParent = () => anchorEnd.parentNode;
2540
+ anchorFragment.append = anchorFragment.appendChild;
2541
+ anchorFragment.appendRaw = anchorFragment.appendChildRaw;
2542
+
2543
+ anchorFragment.insertAtStart = function(child) {
2544
+ child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2545
+ anchorFragment.insertAtStartRaw(child);
2546
+ };
2547
+
2548
+ anchorFragment.insertAtStartRaw = function(child) {
2549
+ const parentNode = anchorStart.parentNode;
2550
+ if(parentNode === anchorFragment) {
2551
+ parentNode.nativeInsertBefore(child, anchorStart);
2552
+ return;
2553
+ }
2554
+ parentNode.insertBefore(child, anchorStart);
2504
2555
  };
2505
2556
 
2506
2557
  anchorFragment.removeChildren = function() {
@@ -2547,6 +2598,10 @@ var NativeComponents = (function (exports) {
2547
2598
 
2548
2599
  anchorFragment.replaceContent = function(child) {
2549
2600
  const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2601
+ anchorFragment.replaceContentRaw(childElement);
2602
+ };
2603
+
2604
+ anchorFragment.replaceContentRaw = function(child) {
2550
2605
  const parent = anchorEnd.parentNode;
2551
2606
  if(!parent) {
2552
2607
  return;
@@ -2560,10 +2615,10 @@ var NativeComponents = (function (exports) {
2560
2615
  };
2561
2616
 
2562
2617
  anchorFragment.setContent = anchorFragment.replaceContent;
2618
+ anchorFragment.setContentRaw = anchorFragment.replaceContentRaw;
2563
2619
 
2564
- anchorFragment.insertBefore = function(child, anchor = null) {
2565
- anchorFragment.appendChild(child, anchor);
2566
- };
2620
+ anchorFragment.insertBefore = anchorFragment.appendChild;
2621
+ anchorFragment.insertBeforeRaw = anchorFragment.appendChildRaw;
2567
2622
 
2568
2623
  anchorFragment.endElement = function() {
2569
2624
  return anchorEnd;
@@ -3254,6 +3309,8 @@ var NativeComponents = (function (exports) {
3254
3309
  };
3255
3310
  });
3256
3311
 
3312
+ const $clearEvent = { action: 'clear' };
3313
+
3257
3314
  /**
3258
3315
  * Removes all items from the array and triggers an update.
3259
3316
  *
@@ -3267,7 +3324,7 @@ var NativeComponents = (function (exports) {
3267
3324
  return;
3268
3325
  }
3269
3326
  this.$currentValue.length = 0;
3270
- this.trigger({ action: 'clear' });
3327
+ this.trigger($clearEvent);
3271
3328
  return true;
3272
3329
  };
3273
3330
 
@@ -3889,7 +3946,7 @@ var NativeComponents = (function (exports) {
3889
3946
  const $getStoreOrThrow = (method, name) => {
3890
3947
  const item = $stores.get(name);
3891
3948
  if (!item) {
3892
- DebugManager$1.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
3949
+ DebugManager$2.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
3893
3950
  throw new NativeDocumentError(
3894
3951
  `Store.${method}('${name}') : store not found.`
3895
3952
  );
@@ -3902,7 +3959,7 @@ var NativeComponents = (function (exports) {
3902
3959
  */
3903
3960
  const $applyReadOnly = (observer, name, context) => {
3904
3961
  const readOnlyError = (method) => () => {
3905
- DebugManager$1.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
3962
+ DebugManager$2.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
3906
3963
  throw new NativeDocumentError(
3907
3964
  `Store.${context}('${name}') is read-only.`
3908
3965
  );
@@ -3933,7 +3990,7 @@ var NativeComponents = (function (exports) {
3933
3990
  */
3934
3991
  create(name, value) {
3935
3992
  if ($stores.has(name)) {
3936
- DebugManager$1.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
3993
+ DebugManager$2.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
3937
3994
  throw new NativeDocumentError(
3938
3995
  `Store.create('${name}') : a store with this name already exists.`
3939
3996
  );
@@ -3954,7 +4011,7 @@ var NativeComponents = (function (exports) {
3954
4011
  */
3955
4012
  createResettable(name, value) {
3956
4013
  if ($stores.has(name)) {
3957
- DebugManager$1.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
4014
+ DebugManager$2.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
3958
4015
  throw new NativeDocumentError(
3959
4016
  `Store.createResettable('${name}') : a store with this name already exists.`
3960
4017
  );
@@ -3990,7 +4047,7 @@ var NativeComponents = (function (exports) {
3990
4047
  */
3991
4048
  createComposed(name, computation, dependencies) {
3992
4049
  if ($stores.has(name)) {
3993
- DebugManager$1.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
4050
+ DebugManager$2.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
3994
4051
  throw new NativeDocumentError(
3995
4052
  `Store.createComposed('${name}') : a store with this name already exists.`
3996
4053
  );
@@ -4013,7 +4070,7 @@ var NativeComponents = (function (exports) {
4013
4070
  }
4014
4071
  const depItem = $stores.get(depName);
4015
4072
  if (!depItem) {
4016
- DebugManager$1.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
4073
+ DebugManager$2.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
4017
4074
  throw new NativeDocumentError(
4018
4075
  `Store.createComposed('${name}') : dependency store '${depName}' not found.`
4019
4076
  );
@@ -4047,13 +4104,13 @@ var NativeComponents = (function (exports) {
4047
4104
  reset(name) {
4048
4105
  const item = $getStoreOrThrow('reset', name);
4049
4106
  if (item.composed) {
4050
- DebugManager$1.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
4107
+ DebugManager$2.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
4051
4108
  throw new NativeDocumentError(
4052
4109
  `Store.reset('${name}') : composed stores cannot be reset.`
4053
4110
  );
4054
4111
  }
4055
4112
  if (!item.resettable) {
4056
- DebugManager$1.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
4113
+ DebugManager$2.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
4057
4114
  throw new NativeDocumentError(
4058
4115
  `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
4059
4116
  );
@@ -4074,7 +4131,7 @@ var NativeComponents = (function (exports) {
4074
4131
  const item = $getStoreOrThrow('use', name);
4075
4132
 
4076
4133
  if (item.composed) {
4077
- DebugManager$1.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
4134
+ DebugManager$2.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
4078
4135
  throw new NativeDocumentError(
4079
4136
  `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
4080
4137
  );
@@ -4141,7 +4198,7 @@ var NativeComponents = (function (exports) {
4141
4198
  get(name) {
4142
4199
  const item = $stores.get(name);
4143
4200
  if (!item) {
4144
- DebugManager$1.warn('Store', `Store.get('${name}') : store not found.`);
4201
+ DebugManager$2.warn('Store', `Store.get('${name}') : store not found.`);
4145
4202
  return null;
4146
4203
  }
4147
4204
  return item.observer;
@@ -4163,7 +4220,7 @@ var NativeComponents = (function (exports) {
4163
4220
  delete(name) {
4164
4221
  const item = $stores.get(name);
4165
4222
  if (!item) {
4166
- DebugManager$1.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
4223
+ DebugManager$2.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
4167
4224
  return;
4168
4225
  }
4169
4226
  item.subscribers.forEach(follower => follower.destroy());
@@ -4265,7 +4322,7 @@ var NativeComponents = (function (exports) {
4265
4322
  return undefined;
4266
4323
  },
4267
4324
  set(target, prop, value) {
4268
- DebugManager$1.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
4325
+ DebugManager$2.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
4269
4326
  throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
4270
4327
  },
4271
4328
  deleteProperty(target, prop) {