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.
@@ -1,10 +1,10 @@
1
1
  var NativeDocument = (function (exports) {
2
2
  'use strict';
3
3
 
4
- let DebugManager$2 = {};
4
+ let DebugManager$1 = {};
5
5
 
6
6
  {
7
- DebugManager$2 = {
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$2;
38
+ var DebugManager$2 = DebugManager$1;
39
39
 
40
40
  class NativeDocumentError extends Error {
41
41
  constructor(message, context = {}) {
@@ -313,10 +313,10 @@ var NativeDocument = (function (exports) {
313
313
  subtree: true,
314
314
  });
315
315
 
316
- let PluginsManager$1 = null;
316
+ let PluginsManager = null;
317
317
 
318
318
  {
319
- PluginsManager$1 = (function() {
319
+ PluginsManager = (function() {
320
320
 
321
321
  const $plugins = new Map();
322
322
  const $pluginByEvents = new Map();
@@ -382,7 +382,7 @@ var NativeDocument = (function (exports) {
382
382
  try{
383
383
  callback.call(plugin, ...data);
384
384
  } catch (error) {
385
- DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
385
+ DebugManager$2.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
386
386
  }
387
387
  }
388
388
  }
@@ -391,12 +391,12 @@ var NativeDocument = (function (exports) {
391
391
  }());
392
392
  }
393
393
 
394
- var PluginsManager = PluginsManager$1;
394
+ var PluginsManager$1 = PluginsManager;
395
395
 
396
396
  function NDElement(element) {
397
397
  this.$element = element;
398
398
  {
399
- PluginsManager.emit('NDElementCreated', element, this);
399
+ PluginsManager$1.emit('NDElementCreated', element, this);
400
400
  }
401
401
  }
402
402
 
@@ -561,7 +561,7 @@ var NativeDocument = (function (exports) {
561
561
  }
562
562
  {
563
563
  if (this[name] && !this.$localExtensions.has(name)) {
564
- DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
564
+ DebugManager$2.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
565
565
  }
566
566
  this.$localExtensions.set(name, method);
567
567
  }
@@ -612,23 +612,23 @@ var NativeDocument = (function (exports) {
612
612
  const method = methods[name];
613
613
 
614
614
  if (typeof method !== 'function') {
615
- DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
615
+ DebugManager$2.warn('NDElement.extend', `"${name}" is not a function, skipping`);
616
616
  continue;
617
617
  }
618
618
 
619
619
  if (protectedMethods.has(name)) {
620
- DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
620
+ DebugManager$2.error('NDElement.extend', `Cannot override protected method "${name}"`);
621
621
  throw new NativeDocumentError(`Cannot override protected method "${name}"`);
622
622
  }
623
623
 
624
624
  if (NDElement.prototype[name]) {
625
- DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
625
+ DebugManager$2.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
626
626
  }
627
627
 
628
628
  NDElement.prototype[name] = method;
629
629
  }
630
630
  {
631
- PluginsManager.emit('NDElementExtended', methods);
631
+ PluginsManager$1.emit('NDElementExtended', methods);
632
632
  }
633
633
 
634
634
  return NDElement;
@@ -779,7 +779,7 @@ var NativeDocument = (function (exports) {
779
779
  const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
780
780
 
781
781
  if (foundReserved.length > 0) {
782
- DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
782
+ DebugManager$2.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
783
783
  }
784
784
 
785
785
  return attributes;
@@ -866,7 +866,7 @@ var NativeDocument = (function (exports) {
866
866
  }
867
867
  }
868
868
  if (cleanedCount > 0) {
869
- DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
869
+ DebugManager$2.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
870
870
  }
871
871
  }
872
872
  };
@@ -1176,7 +1176,7 @@ var NativeDocument = (function (exports) {
1176
1176
  }
1177
1177
  }
1178
1178
  {
1179
- PluginsManager.emit('CreateObservable', this);
1179
+ PluginsManager$1.emit('CreateObservable', this);
1180
1180
  }
1181
1181
  }
1182
1182
 
@@ -1272,6 +1272,8 @@ var NativeDocument = (function (exports) {
1272
1272
  };
1273
1273
  ObservableItem.prototype.trigger = noneTrigger;
1274
1274
 
1275
+
1276
+ const $setOperation = { action: 'set' };
1275
1277
  ObservableItem.prototype.$updateWithNewValue = function(newValue) {
1276
1278
  newValue = newValue?.__$isObservable ? newValue.val() : newValue;
1277
1279
  if(this.$currentValue === newValue) {
@@ -1280,12 +1282,12 @@ var NativeDocument = (function (exports) {
1280
1282
  this.$previousValue = this.$currentValue;
1281
1283
  this.$currentValue = newValue;
1282
1284
  {
1283
- PluginsManager.emit('ObservableBeforeChange', this);
1285
+ PluginsManager$1.emit('ObservableBeforeChange', this);
1284
1286
  }
1285
- this.trigger();
1287
+ this.trigger($setOperation);
1286
1288
  this.$previousValue = null;
1287
1289
  {
1288
- PluginsManager.emit('ObservableAfterChange', this);
1290
+ PluginsManager$1.emit('ObservableAfterChange', this);
1289
1291
  }
1290
1292
  };
1291
1293
 
@@ -1363,7 +1365,7 @@ var NativeDocument = (function (exports) {
1363
1365
  ObservableItem.prototype.subscribe = function(callback) {
1364
1366
  {
1365
1367
  if (this.$isCleanedUp) {
1366
- DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
1368
+ DebugManager$2.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
1367
1369
  return;
1368
1370
  }
1369
1371
  if (typeof callback !== 'function') {
@@ -1375,7 +1377,7 @@ var NativeDocument = (function (exports) {
1375
1377
  this.$listeners.push(callback);
1376
1378
  this.assocTrigger();
1377
1379
  {
1378
- PluginsManager.emit('ObservableSubscribe', this);
1380
+ PluginsManager$1.emit('ObservableSubscribe', this);
1379
1381
  }
1380
1382
  };
1381
1383
 
@@ -1486,7 +1488,7 @@ var NativeDocument = (function (exports) {
1486
1488
  }
1487
1489
  this.assocTrigger();
1488
1490
  {
1489
- PluginsManager.emit('ObservableUnsubscribe', this);
1491
+ PluginsManager$1.emit('ObservableUnsubscribe', this);
1490
1492
  }
1491
1493
  };
1492
1494
 
@@ -1965,7 +1967,7 @@ var NativeDocument = (function (exports) {
1965
1967
  Function.prototype.toNdElement = function () {
1966
1968
  const child = this;
1967
1969
  {
1968
- PluginsManager.emit('BeforeProcessComponent', child);
1970
+ PluginsManager$1.emit('BeforeProcessComponent', child);
1969
1971
  }
1970
1972
  return ElementCreator.getChild(child());
1971
1973
  };
@@ -2152,14 +2154,14 @@ var NativeDocument = (function (exports) {
2152
2154
  processChildren: (children, parent) => {
2153
2155
  if(children === null) return;
2154
2156
  {
2155
- PluginsManager.emit('BeforeProcessChildren', parent);
2157
+ PluginsManager$1.emit('BeforeProcessChildren', parent);
2156
2158
  }
2157
2159
  let child = ElementCreator.getChild(children);
2158
2160
  if(child) {
2159
2161
  parent.appendChild(child);
2160
2162
  }
2161
2163
  {
2162
- PluginsManager.emit('AfterProcessChildren', parent);
2164
+ PluginsManager$1.emit('AfterProcessChildren', parent);
2163
2165
  }
2164
2166
  },
2165
2167
  async safeRemove(element) {
@@ -2245,29 +2247,51 @@ var NativeDocument = (function (exports) {
2245
2247
  anchor.remove = () => {
2246
2248
  anchor.append.apply(anchor, parent.childNodes);
2247
2249
  };
2250
+ anchor.getParent = () => parent;
2248
2251
 
2249
2252
  anchor.appendChild = (child) => {
2250
2253
  child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2251
2254
  parent.appendChild(child);
2252
2255
  };
2253
2256
 
2257
+ anchor.appendChildRaw = parent.appendChild.bind(parent);
2258
+ anchor.append = anchor.appendChild;
2259
+ anchor.appendRaw = anchor.appendChildRaw;
2260
+
2261
+ anchor.insertAtStart = (child) => {
2262
+ child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2263
+ parent.firstChild ? parent.insertBefore(child, parent.firstChild) : parent.appendChild(child);
2264
+ };
2265
+ anchor.insertAtStartRaw = (child) => {
2266
+ parent.firstChild ? parent.insertBefore(child, parent.firstChild) : parent.appendChild(child);
2267
+ };
2268
+
2254
2269
  anchor.appendElement = anchor.appendChild;
2255
2270
 
2256
2271
  anchor.removeChildren = () => {
2257
- parent.replaceChildren();
2272
+ parent.textContent = '';
2258
2273
  };
2259
2274
 
2260
2275
  anchor.replaceContent = function(content) {
2261
2276
  const child = Validator.isElement(content) ? content : ElementCreator.getChild(content);
2262
2277
  parent.replaceChildren(child);
2263
2278
  };
2279
+
2280
+ anchor.replaceContentRaw = function(child) {
2281
+ parent.replaceChildren(child);
2282
+ };
2264
2283
  anchor.setContent = anchor.replaceContent;
2265
2284
 
2266
2285
  anchor.insertBefore = (child, anchor) => {
2267
2286
  child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2268
2287
  parent.insertBefore(child, anchor);
2269
2288
  };
2289
+ anchor.insertBeforeRaw = (child, anchor) => {
2290
+ parent.insertBefore(child, anchor);
2291
+ };
2292
+
2270
2293
  anchor.appendChildBefore = anchor.insertBefore;
2294
+ anchor.appendChildBeforeRaw = anchor.insertBeforeRaw;
2271
2295
 
2272
2296
  anchor.clear = anchor.remove;
2273
2297
  anchor.detach = anchor.remove;
@@ -2293,7 +2317,6 @@ var NativeDocument = (function (exports) {
2293
2317
 
2294
2318
  anchorFragment.onConnectedOnce((parent) => {
2295
2319
  if(isUniqueChild) {
2296
- console.log('Lets overwrite some functions with parent ', parent);
2297
2320
  oneChildAnchorOverwriting(anchorFragment, parent);
2298
2321
  }
2299
2322
  });
@@ -2315,15 +2338,19 @@ var NativeDocument = (function (exports) {
2315
2338
 
2316
2339
  const insertBefore = function(parent, child, target) {
2317
2340
  const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2341
+ insertBeforeRaw(parent, childElement, target);
2342
+ };
2343
+
2344
+ const insertBeforeRaw = function(parent, child, target) {
2318
2345
  if(parent === anchorFragment) {
2319
- parent.nativeInsertBefore(childElement, target);
2346
+ parent.nativeInsertBefore(child, target);
2320
2347
  return;
2321
2348
  }
2322
2349
  if(isParentUniqueChild(parent) && target === anchorEnd) {
2323
- parent.append(childElement, target);
2350
+ parent.append(child, target);
2324
2351
  return;
2325
2352
  }
2326
- parent.insertBefore(childElement, target);
2353
+ parent.insertBefore(child, target);
2327
2354
  };
2328
2355
 
2329
2356
  anchorFragment.appendElement = function(child) {
@@ -2345,8 +2372,32 @@ var NativeDocument = (function (exports) {
2345
2372
  insertBefore(parent, child, before);
2346
2373
  };
2347
2374
 
2348
- anchorFragment.append = function() {
2349
- return anchorFragment.appendChild(Array.from(arguments));
2375
+ anchorFragment.appendChildRaw = function(child, before = null) {
2376
+ const parent = anchorEnd.parentNode;
2377
+ if(!parent) {
2378
+ DebugManager.error('Anchor', 'Anchor : parent not found', child);
2379
+ return;
2380
+ }
2381
+ before = before ?? anchorEnd;
2382
+ insertBeforeRaw(parent, child, before);
2383
+ };
2384
+
2385
+ anchorFragment.getParent = () => anchorEnd.parentNode;
2386
+ anchorFragment.append = anchorFragment.appendChild;
2387
+ anchorFragment.appendRaw = anchorFragment.appendChildRaw;
2388
+
2389
+ anchorFragment.insertAtStart = function(child) {
2390
+ child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2391
+ anchorFragment.insertAtStartRaw(child);
2392
+ };
2393
+
2394
+ anchorFragment.insertAtStartRaw = function(child) {
2395
+ const parentNode = anchorStart.parentNode;
2396
+ if(parentNode === anchorFragment) {
2397
+ parentNode.nativeInsertBefore(child, anchorStart);
2398
+ return;
2399
+ }
2400
+ parentNode.insertBefore(child, anchorStart);
2350
2401
  };
2351
2402
 
2352
2403
  anchorFragment.removeChildren = function() {
@@ -2393,6 +2444,10 @@ var NativeDocument = (function (exports) {
2393
2444
 
2394
2445
  anchorFragment.replaceContent = function(child) {
2395
2446
  const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2447
+ anchorFragment.replaceContentRaw(childElement);
2448
+ };
2449
+
2450
+ anchorFragment.replaceContentRaw = function(child) {
2396
2451
  const parent = anchorEnd.parentNode;
2397
2452
  if(!parent) {
2398
2453
  return;
@@ -2406,10 +2461,10 @@ var NativeDocument = (function (exports) {
2406
2461
  };
2407
2462
 
2408
2463
  anchorFragment.setContent = anchorFragment.replaceContent;
2464
+ anchorFragment.setContentRaw = anchorFragment.replaceContentRaw;
2409
2465
 
2410
- anchorFragment.insertBefore = function(child, anchor = null) {
2411
- anchorFragment.appendChild(child, anchor);
2412
- };
2466
+ anchorFragment.insertBefore = anchorFragment.appendChild;
2467
+ anchorFragment.insertBeforeRaw = anchorFragment.appendChildRaw;
2413
2468
 
2414
2469
  anchorFragment.endElement = function() {
2415
2470
  return anchorEnd;
@@ -3791,7 +3846,7 @@ var NativeDocument = (function (exports) {
3791
3846
 
3792
3847
  ObservableItem.call(this, target, configs);
3793
3848
  {
3794
- PluginsManager.emit('CreateObservableArray', this);
3849
+ PluginsManager$1.emit('CreateObservableArray', this);
3795
3850
  }
3796
3851
  };
3797
3852
 
@@ -3820,6 +3875,8 @@ var NativeDocument = (function (exports) {
3820
3875
  };
3821
3876
  });
3822
3877
 
3878
+ const $clearEvent = { action: 'clear' };
3879
+
3823
3880
  /**
3824
3881
  * Removes all items from the array and triggers an update.
3825
3882
  *
@@ -3833,7 +3890,7 @@ var NativeDocument = (function (exports) {
3833
3890
  return;
3834
3891
  }
3835
3892
  this.$currentValue.length = 0;
3836
- this.trigger({ action: 'clear' });
3893
+ this.trigger($clearEvent);
3837
3894
  return true;
3838
3895
  };
3839
3896
 
@@ -4423,7 +4480,7 @@ var NativeDocument = (function (exports) {
4423
4480
  const observable = new ObservableItem(initialValue);
4424
4481
  const updatedValue = nextTick(() => observable.set(callback()));
4425
4482
  {
4426
- PluginsManager.emit('CreateObservableComputed', observable, dependencies);
4483
+ PluginsManager$1.emit('CreateObservableComputed', observable, dependencies);
4427
4484
  }
4428
4485
 
4429
4486
  if(Validator.isFunction(dependencies)) {
@@ -4458,7 +4515,7 @@ var NativeDocument = (function (exports) {
4458
4515
  const $getStoreOrThrow = (method, name) => {
4459
4516
  const item = $stores.get(name);
4460
4517
  if (!item) {
4461
- DebugManager$1.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
4518
+ DebugManager$2.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
4462
4519
  throw new NativeDocumentError(
4463
4520
  `Store.${method}('${name}') : store not found.`
4464
4521
  );
@@ -4471,7 +4528,7 @@ var NativeDocument = (function (exports) {
4471
4528
  */
4472
4529
  const $applyReadOnly = (observer, name, context) => {
4473
4530
  const readOnlyError = (method) => () => {
4474
- DebugManager$1.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
4531
+ DebugManager$2.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
4475
4532
  throw new NativeDocumentError(
4476
4533
  `Store.${context}('${name}') is read-only.`
4477
4534
  );
@@ -4502,7 +4559,7 @@ var NativeDocument = (function (exports) {
4502
4559
  */
4503
4560
  create(name, value) {
4504
4561
  if ($stores.has(name)) {
4505
- DebugManager$1.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
4562
+ DebugManager$2.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
4506
4563
  throw new NativeDocumentError(
4507
4564
  `Store.create('${name}') : a store with this name already exists.`
4508
4565
  );
@@ -4523,7 +4580,7 @@ var NativeDocument = (function (exports) {
4523
4580
  */
4524
4581
  createResettable(name, value) {
4525
4582
  if ($stores.has(name)) {
4526
- DebugManager$1.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
4583
+ DebugManager$2.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
4527
4584
  throw new NativeDocumentError(
4528
4585
  `Store.createResettable('${name}') : a store with this name already exists.`
4529
4586
  );
@@ -4559,7 +4616,7 @@ var NativeDocument = (function (exports) {
4559
4616
  */
4560
4617
  createComposed(name, computation, dependencies) {
4561
4618
  if ($stores.has(name)) {
4562
- DebugManager$1.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
4619
+ DebugManager$2.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
4563
4620
  throw new NativeDocumentError(
4564
4621
  `Store.createComposed('${name}') : a store with this name already exists.`
4565
4622
  );
@@ -4582,7 +4639,7 @@ var NativeDocument = (function (exports) {
4582
4639
  }
4583
4640
  const depItem = $stores.get(depName);
4584
4641
  if (!depItem) {
4585
- DebugManager$1.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
4642
+ DebugManager$2.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
4586
4643
  throw new NativeDocumentError(
4587
4644
  `Store.createComposed('${name}') : dependency store '${depName}' not found.`
4588
4645
  );
@@ -4616,13 +4673,13 @@ var NativeDocument = (function (exports) {
4616
4673
  reset(name) {
4617
4674
  const item = $getStoreOrThrow('reset', name);
4618
4675
  if (item.composed) {
4619
- DebugManager$1.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
4676
+ DebugManager$2.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
4620
4677
  throw new NativeDocumentError(
4621
4678
  `Store.reset('${name}') : composed stores cannot be reset.`
4622
4679
  );
4623
4680
  }
4624
4681
  if (!item.resettable) {
4625
- DebugManager$1.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
4682
+ DebugManager$2.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
4626
4683
  throw new NativeDocumentError(
4627
4684
  `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
4628
4685
  );
@@ -4643,7 +4700,7 @@ var NativeDocument = (function (exports) {
4643
4700
  const item = $getStoreOrThrow('use', name);
4644
4701
 
4645
4702
  if (item.composed) {
4646
- DebugManager$1.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
4703
+ DebugManager$2.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
4647
4704
  throw new NativeDocumentError(
4648
4705
  `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
4649
4706
  );
@@ -4710,7 +4767,7 @@ var NativeDocument = (function (exports) {
4710
4767
  get(name) {
4711
4768
  const item = $stores.get(name);
4712
4769
  if (!item) {
4713
- DebugManager$1.warn('Store', `Store.get('${name}') : store not found.`);
4770
+ DebugManager$2.warn('Store', `Store.get('${name}') : store not found.`);
4714
4771
  return null;
4715
4772
  }
4716
4773
  return item.observer;
@@ -4732,7 +4789,7 @@ var NativeDocument = (function (exports) {
4732
4789
  delete(name) {
4733
4790
  const item = $stores.get(name);
4734
4791
  if (!item) {
4735
- DebugManager$1.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
4792
+ DebugManager$2.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
4736
4793
  return;
4737
4794
  }
4738
4795
  item.subscribers.forEach(follower => follower.destroy());
@@ -4834,7 +4891,7 @@ var NativeDocument = (function (exports) {
4834
4891
  return undefined;
4835
4892
  },
4836
4893
  set(target, prop, value) {
4837
- DebugManager$1.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
4894
+ DebugManager$2.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
4838
4895
  throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
4839
4896
  },
4840
4897
  deleteProperty(target, prop) {
@@ -4922,7 +4979,7 @@ var NativeDocument = (function (exports) {
4922
4979
  }
4923
4980
  cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
4924
4981
  } catch (e) {
4925
- DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
4982
+ DebugManager$2.error('ForEach', `Error creating element for key ${keyId}` , e);
4926
4983
  throw e;
4927
4984
  }
4928
4985
  return keyId;
@@ -5027,7 +5084,7 @@ var NativeDocument = (function (exports) {
5027
5084
  function ForEachArray(data, callback, configs = {}) {
5028
5085
  const element = Anchor('ForEach Array', configs.isParentUniqueChild);
5029
5086
  const blockEnd = element.endElement();
5030
- const blockStart = element.startElement();
5087
+ element.startElement();
5031
5088
 
5032
5089
  let cache = new Map();
5033
5090
  let lastNumberOfItems = 0;
@@ -5035,6 +5092,9 @@ var NativeDocument = (function (exports) {
5035
5092
 
5036
5093
  const clear = (items) => {
5037
5094
  element.removeChildren();
5095
+ clearCacheOnly(items);
5096
+ };
5097
+ const clearCacheOnly = (items) => {
5038
5098
  cleanCache(items);
5039
5099
  lastNumberOfItems = 0;
5040
5100
  };
@@ -5158,11 +5218,16 @@ var NativeDocument = (function (exports) {
5158
5218
  return fragment;
5159
5219
  },
5160
5220
  add: (items) => {
5161
- element.appendElement(Actions.toFragment(items));
5221
+ element.appendChildRaw(Actions.toFragment(items));
5162
5222
  },
5163
5223
  replace: (items) => {
5164
- clear(items);
5165
- Actions.add(items);
5224
+ clearCacheOnly(items);
5225
+ element.replaceContentRaw(Actions.toFragment(items));
5226
+ },
5227
+ set: () => {
5228
+ const items = data.val();
5229
+ clearCacheOnly(items);
5230
+ element.replaceContentRaw(Actions.toFragment(items));
5166
5231
  },
5167
5232
  reOrder: (items) => {
5168
5233
  let child = null;
@@ -5174,23 +5239,12 @@ var NativeDocument = (function (exports) {
5174
5239
  }
5175
5240
  }
5176
5241
  child = null;
5177
- element.appendElement(fragment, blockEnd);
5242
+ element.appendElementRaw(fragment);
5178
5243
  },
5179
5244
  removeOne: (element, index) => {
5180
5245
  removeCacheItem(element, true);
5181
5246
  },
5182
5247
  clear,
5183
- merge: (items) => {
5184
- Actions.add(items);
5185
- },
5186
- push: (items) => {
5187
- let delay = 0;
5188
- if(configs.pushDelay) {
5189
- delay = configs.pushDelay(items) ?? 0;
5190
- }
5191
-
5192
- Actions.add(items, delay);
5193
- },
5194
5248
  populate: ([target, iteration, callback]) => {
5195
5249
  const fragment = document.createDocumentFragment();
5196
5250
  for (let i = 0; i < iteration; i++) {
@@ -5199,11 +5253,11 @@ var NativeDocument = (function (exports) {
5199
5253
  fragment.append(buildItem(data, i));
5200
5254
  lastNumberOfItems++;
5201
5255
  }
5202
- element.appendChild(fragment);
5256
+ element.appendChildRaw(fragment);
5203
5257
  fragment.replaceChildren();
5204
5258
  },
5205
5259
  unshift: (values) => {
5206
- element.insertBefore(Actions.toFragment(values), blockStart.nextSibling);
5260
+ element.insertAtStartRaw(Actions.toFragment(values));
5207
5261
  },
5208
5262
  splice: (args, deleted) => {
5209
5263
  const [start, deleteCount, ...values] = args;
@@ -5228,7 +5282,7 @@ var NativeDocument = (function (exports) {
5228
5282
  garbageFragment.replaceChildren();
5229
5283
 
5230
5284
  if(values && values.length && elementBeforeFirst) {
5231
- element.insertBefore(Actions.toFragment(values), elementBeforeFirst.nextSibling);
5285
+ element.insertBeforeRaw(Actions.toFragment(values), elementBeforeFirst.nextSibling);
5232
5286
  }
5233
5287
 
5234
5288
  },
@@ -5248,7 +5302,7 @@ var NativeDocument = (function (exports) {
5248
5302
  Actions.removeOne(deleted);
5249
5303
  },
5250
5304
  swap: (args, elements) => {
5251
- const parent = blockEnd.parentNode;
5305
+ const parent = element.getParent();
5252
5306
 
5253
5307
  let childA = getItemChild(elements[0]);
5254
5308
  let childB = getItemChild(elements[1]);
@@ -5263,37 +5317,22 @@ var NativeDocument = (function (exports) {
5263
5317
  childB = null;
5264
5318
  }
5265
5319
  };
5320
+ Actions.merge = Actions.add;
5321
+ Actions.push = Actions.add;
5266
5322
 
5267
- const buildContent = (items, _, operations) => {
5268
- if(operations?.action === 'clear' || !items.length) {
5269
- if(lastNumberOfItems === 0) {
5270
- return;
5271
- }
5272
- clear();
5273
- return;
5274
- }
5275
- selectBuildStrategy(operations?.action);
5323
+ const buildContent = (items, _, operations = {}) => {
5324
+ selectBuildStrategy(operations.action);
5276
5325
 
5277
- if(!operations?.action) {
5278
- if(lastNumberOfItems === 0) {
5279
- Actions.add(items);
5280
- return;
5281
- }
5282
- Actions.replace(items);
5283
- }
5284
- else if(Actions[operations.action]) {
5326
+ if(Actions[operations.action]) {
5285
5327
  Actions[operations.action](operations.args, operations.result);
5286
5328
  }
5287
-
5288
5329
  updateIndexObservers(items, 0);
5289
5330
  };
5290
5331
 
5291
5332
  if(data.val().length) {
5292
5333
  buildContent(data.val(), null, {action: null});
5293
5334
  }
5294
- if(Validator.isObservable(data)) {
5295
- data.subscribe(buildContent);
5296
- }
5335
+ data.subscribe(buildContent);
5297
5336
 
5298
5337
  return element;
5299
5338
  }
@@ -5314,7 +5353,7 @@ var NativeDocument = (function (exports) {
5314
5353
  */
5315
5354
  const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
5316
5355
  if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
5317
- return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
5356
+ return DebugManager$2.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
5318
5357
  }
5319
5358
  const element = Anchor('Show if : '+(comment || ''));
5320
5359
 
@@ -6733,7 +6772,7 @@ var NativeDocument = (function (exports) {
6733
6772
  window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
6734
6773
  this.handleRouteChange(route, params, query, path);
6735
6774
  } catch (e) {
6736
- DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
6775
+ DebugManager$2.error('HistoryRouter', 'Error in pushState', e);
6737
6776
  }
6738
6777
  };
6739
6778
  /**
@@ -6746,7 +6785,7 @@ var NativeDocument = (function (exports) {
6746
6785
  window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
6747
6786
  this.handleRouteChange(route, params, {}, path);
6748
6787
  } catch(e) {
6749
- DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
6788
+ DebugManager$2.error('HistoryRouter', 'Error in replaceState', e);
6750
6789
  }
6751
6790
  };
6752
6791
  this.forward = function() {
@@ -6773,7 +6812,7 @@ var NativeDocument = (function (exports) {
6773
6812
  }
6774
6813
  this.handleRouteChange(route, params, query, path);
6775
6814
  } catch(e) {
6776
- DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
6815
+ DebugManager$2.error('HistoryRouter', 'Error in popstate event', e);
6777
6816
  }
6778
6817
  });
6779
6818
  const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
@@ -6998,7 +7037,7 @@ var NativeDocument = (function (exports) {
6998
7037
  listener(request);
6999
7038
  next && next(request);
7000
7039
  } catch (e) {
7001
- DebugManager$1.warn('Route Listener', 'Error in listener:', e);
7040
+ DebugManager$2.warn('Route Listener', 'Error in listener:', e);
7002
7041
  }
7003
7042
  }
7004
7043
  };
@@ -7176,7 +7215,7 @@ var NativeDocument = (function (exports) {
7176
7215
  */
7177
7216
  Router.create = function(options, callback) {
7178
7217
  if(!Validator.isFunction(callback)) {
7179
- DebugManager$1.error('Router', 'Callback must be a function');
7218
+ DebugManager$2.error('Router', 'Callback must be a function');
7180
7219
  throw new RouterError('Callback must be a function');
7181
7220
  }
7182
7221
  const router = new Router(options);
@@ -7380,7 +7419,7 @@ var NativeDocument = (function (exports) {
7380
7419
  exports.HtmlElementWrapper = HtmlElementWrapper;
7381
7420
  exports.NDElement = NDElement;
7382
7421
  exports.Observable = Observable;
7383
- exports.PluginsManager = PluginsManager;
7422
+ exports.PluginsManager = PluginsManager$1;
7384
7423
  exports.SingletonView = SingletonView;
7385
7424
  exports.Store = Store;
7386
7425
  exports.StoreFactory = StoreFactory;