native-document 1.0.119 → 1.0.121

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
 
@@ -1786,22 +1788,7 @@ var NativeDocument = (function (exports) {
1786
1788
  */
1787
1789
  const bindClassAttribute = (element, data) => {
1788
1790
  for(const className in data) {
1789
- const value = data[className];
1790
- if(value.__$isObservable) {
1791
- element.classes.toggle(className, value.val());
1792
- value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
1793
- continue;
1794
- }
1795
- if(value.__$isObservableWhen) {
1796
- element.classes.toggle(className, value.isActive());
1797
- value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
1798
- continue;
1799
- }
1800
- if(value.$hydrate) {
1801
- value.$hydrate(element, className);
1802
- continue;
1803
- }
1804
- element.classes.toggle(className, value);
1791
+ data[className].bindClassProperty(element, className);
1805
1792
  }
1806
1793
  };
1807
1794
 
@@ -1871,6 +1858,35 @@ var NativeDocument = (function (exports) {
1871
1858
  element.setAttribute(attributeName, value.val());
1872
1859
  };
1873
1860
 
1861
+
1862
+ const AttributeHandlers = {
1863
+ string: (element, attributeName, value) => element.setAttribute(attributeName, value),
1864
+ number: (element, attributeName, value) => element.setAttribute(attributeName, value),
1865
+ boolean: (element, attributeName, value) => bindBooleanAttribute(element, attributeName, value),
1866
+ object: (element, attributeName, value) => {
1867
+ if(value == null) {
1868
+ return;
1869
+ }
1870
+
1871
+ if(value.handleNdAttribute) {
1872
+ value.handleNdAttribute(element, attributeName);
1873
+ return;
1874
+ }
1875
+
1876
+ if(attributeName === 'class') {
1877
+ bindClassAttribute(element, value);
1878
+ return;
1879
+ }
1880
+ if(attributeName === 'style') {
1881
+ bindStyleAttribute(element, value);
1882
+ return;
1883
+ }
1884
+ if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
1885
+ bindBooleanAttribute(element, attributeName, value);
1886
+ }
1887
+ }
1888
+ };
1889
+
1874
1890
  /**
1875
1891
  *
1876
1892
  * @param {HTMLElement} element
@@ -1885,29 +1901,8 @@ var NativeDocument = (function (exports) {
1885
1901
  for(const originalAttributeName in attributes) {
1886
1902
  const attributeName = originalAttributeName.toLowerCase();
1887
1903
  let value = attributes[originalAttributeName];
1888
- if(value == null) {
1889
- continue;
1890
- }
1891
- if(value.handleNdAttribute) {
1892
- value.handleNdAttribute(element, attributeName, value);
1893
- continue;
1894
- }
1895
- if(typeof value === 'object') {
1896
- if(attributeName === 'class') {
1897
- bindClassAttribute(element, value);
1898
- continue;
1899
- }
1900
- if(attributeName === 'style') {
1901
- bindStyleAttribute(element, value);
1902
- continue;
1903
- }
1904
- }
1905
- if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
1906
- bindBooleanAttribute(element, attributeName, value);
1907
- continue;
1908
- }
1909
-
1910
- element.setAttribute(attributeName, value);
1904
+ const typeOf = typeof value;
1905
+ AttributeHandlers[typeOf](element, attributeName, value);
1911
1906
  }
1912
1907
  return element;
1913
1908
  };
@@ -1965,7 +1960,7 @@ var NativeDocument = (function (exports) {
1965
1960
  Function.prototype.toNdElement = function () {
1966
1961
  const child = this;
1967
1962
  {
1968
- PluginsManager.emit('BeforeProcessComponent', child);
1963
+ PluginsManager$1.emit('BeforeProcessComponent', child);
1969
1964
  }
1970
1965
  return ElementCreator.getChild(child());
1971
1966
  };
@@ -2060,10 +2055,6 @@ var NativeDocument = (function (exports) {
2060
2055
  return this;
2061
2056
  };
2062
2057
 
2063
- String.prototype.handleNdAttribute = function(element, attributeName) {
2064
- element.setAttribute(attributeName, this);
2065
- };
2066
-
2067
2058
  ObservableItem.prototype.handleNdAttribute = function(element, attributeName) {
2068
2059
  if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
2069
2060
  bindBooleanAttribute(element, attributeName, this);
@@ -2077,6 +2068,24 @@ var NativeDocument = (function (exports) {
2077
2068
  this.$hydrate(element, attributeName);
2078
2069
  };
2079
2070
 
2071
+ ObservableItem.prototype.bindClassProperty = function(element, className) {
2072
+ element.classes.toggle(className, this.val());
2073
+ this.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
2074
+ };
2075
+
2076
+ ObservableWhen.prototype.bindClassProperty = function(element, className) {
2077
+ element.classes.toggle(className, this.isActive());
2078
+ this.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
2079
+ };
2080
+
2081
+ TemplateBinding.prototype.bindClassProperty = function(element, className) {
2082
+ this.$hydrate(element, className);
2083
+ };
2084
+
2085
+ Boolean.prototype.bindClassProperty = function(element, className) {
2086
+ element.classes.toggle(className, this);
2087
+ };
2088
+
2080
2089
  let $textNodeCache = null;
2081
2090
 
2082
2091
  const ElementCreator = {
@@ -2152,14 +2161,14 @@ var NativeDocument = (function (exports) {
2152
2161
  processChildren: (children, parent) => {
2153
2162
  if(children === null) return;
2154
2163
  {
2155
- PluginsManager.emit('BeforeProcessChildren', parent);
2164
+ PluginsManager$1.emit('BeforeProcessChildren', parent);
2156
2165
  }
2157
2166
  let child = ElementCreator.getChild(children);
2158
2167
  if(child) {
2159
2168
  parent.appendChild(child);
2160
2169
  }
2161
2170
  {
2162
- PluginsManager.emit('AfterProcessChildren', parent);
2171
+ PluginsManager$1.emit('AfterProcessChildren', parent);
2163
2172
  }
2164
2173
  },
2165
2174
  async safeRemove(element) {
@@ -2245,29 +2254,51 @@ var NativeDocument = (function (exports) {
2245
2254
  anchor.remove = () => {
2246
2255
  anchor.append.apply(anchor, parent.childNodes);
2247
2256
  };
2257
+ anchor.getParent = () => parent;
2248
2258
 
2249
2259
  anchor.appendChild = (child) => {
2250
2260
  child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2251
2261
  parent.appendChild(child);
2252
2262
  };
2253
2263
 
2264
+ anchor.appendChildRaw = parent.appendChild.bind(parent);
2265
+ anchor.append = anchor.appendChild;
2266
+ anchor.appendRaw = anchor.appendChildRaw;
2267
+
2268
+ anchor.insertAtStart = (child) => {
2269
+ child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2270
+ parent.firstChild ? parent.insertBefore(child, parent.firstChild) : parent.appendChild(child);
2271
+ };
2272
+ anchor.insertAtStartRaw = (child) => {
2273
+ parent.firstChild ? parent.insertBefore(child, parent.firstChild) : parent.appendChild(child);
2274
+ };
2275
+
2254
2276
  anchor.appendElement = anchor.appendChild;
2255
2277
 
2256
2278
  anchor.removeChildren = () => {
2257
- parent.replaceChildren();
2279
+ parent.textContent = '';
2258
2280
  };
2259
2281
 
2260
2282
  anchor.replaceContent = function(content) {
2261
2283
  const child = Validator.isElement(content) ? content : ElementCreator.getChild(content);
2262
2284
  parent.replaceChildren(child);
2263
2285
  };
2286
+
2287
+ anchor.replaceContentRaw = function(child) {
2288
+ parent.replaceChildren(child);
2289
+ };
2264
2290
  anchor.setContent = anchor.replaceContent;
2265
2291
 
2266
2292
  anchor.insertBefore = (child, anchor) => {
2267
2293
  child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2268
2294
  parent.insertBefore(child, anchor);
2269
2295
  };
2296
+ anchor.insertBeforeRaw = (child, anchor) => {
2297
+ parent.insertBefore(child, anchor);
2298
+ };
2299
+
2270
2300
  anchor.appendChildBefore = anchor.insertBefore;
2301
+ anchor.appendChildBeforeRaw = anchor.insertBeforeRaw;
2271
2302
 
2272
2303
  anchor.clear = anchor.remove;
2273
2304
  anchor.detach = anchor.remove;
@@ -2293,7 +2324,6 @@ var NativeDocument = (function (exports) {
2293
2324
 
2294
2325
  anchorFragment.onConnectedOnce((parent) => {
2295
2326
  if(isUniqueChild) {
2296
- console.log('Lets overwrite some functions with parent ', parent);
2297
2327
  oneChildAnchorOverwriting(anchorFragment, parent);
2298
2328
  }
2299
2329
  });
@@ -2315,15 +2345,19 @@ var NativeDocument = (function (exports) {
2315
2345
 
2316
2346
  const insertBefore = function(parent, child, target) {
2317
2347
  const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2348
+ insertBeforeRaw(parent, childElement, target);
2349
+ };
2350
+
2351
+ const insertBeforeRaw = function(parent, child, target) {
2318
2352
  if(parent === anchorFragment) {
2319
- parent.nativeInsertBefore(childElement, target);
2353
+ parent.nativeInsertBefore(child, target);
2320
2354
  return;
2321
2355
  }
2322
2356
  if(isParentUniqueChild(parent) && target === anchorEnd) {
2323
- parent.append(childElement, target);
2357
+ parent.append(child, target);
2324
2358
  return;
2325
2359
  }
2326
- parent.insertBefore(childElement, target);
2360
+ parent.insertBefore(child, target);
2327
2361
  };
2328
2362
 
2329
2363
  anchorFragment.appendElement = function(child) {
@@ -2345,8 +2379,32 @@ var NativeDocument = (function (exports) {
2345
2379
  insertBefore(parent, child, before);
2346
2380
  };
2347
2381
 
2348
- anchorFragment.append = function() {
2349
- return anchorFragment.appendChild(Array.from(arguments));
2382
+ anchorFragment.appendChildRaw = function(child, before = null) {
2383
+ const parent = anchorEnd.parentNode;
2384
+ if(!parent) {
2385
+ DebugManager.error('Anchor', 'Anchor : parent not found', child);
2386
+ return;
2387
+ }
2388
+ before = before ?? anchorEnd;
2389
+ insertBeforeRaw(parent, child, before);
2390
+ };
2391
+
2392
+ anchorFragment.getParent = () => anchorEnd.parentNode;
2393
+ anchorFragment.append = anchorFragment.appendChild;
2394
+ anchorFragment.appendRaw = anchorFragment.appendChildRaw;
2395
+
2396
+ anchorFragment.insertAtStart = function(child) {
2397
+ child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2398
+ anchorFragment.insertAtStartRaw(child);
2399
+ };
2400
+
2401
+ anchorFragment.insertAtStartRaw = function(child) {
2402
+ const parentNode = anchorStart.parentNode;
2403
+ if(parentNode === anchorFragment) {
2404
+ parentNode.nativeInsertBefore(child, anchorStart);
2405
+ return;
2406
+ }
2407
+ parentNode.insertBefore(child, anchorStart);
2350
2408
  };
2351
2409
 
2352
2410
  anchorFragment.removeChildren = function() {
@@ -2393,6 +2451,10 @@ var NativeDocument = (function (exports) {
2393
2451
 
2394
2452
  anchorFragment.replaceContent = function(child) {
2395
2453
  const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
2454
+ anchorFragment.replaceContentRaw(childElement);
2455
+ };
2456
+
2457
+ anchorFragment.replaceContentRaw = function(child) {
2396
2458
  const parent = anchorEnd.parentNode;
2397
2459
  if(!parent) {
2398
2460
  return;
@@ -2406,10 +2468,10 @@ var NativeDocument = (function (exports) {
2406
2468
  };
2407
2469
 
2408
2470
  anchorFragment.setContent = anchorFragment.replaceContent;
2471
+ anchorFragment.setContentRaw = anchorFragment.replaceContentRaw;
2409
2472
 
2410
- anchorFragment.insertBefore = function(child, anchor = null) {
2411
- anchorFragment.appendChild(child, anchor);
2412
- };
2473
+ anchorFragment.insertBefore = anchorFragment.appendChild;
2474
+ anchorFragment.insertBeforeRaw = anchorFragment.appendChildRaw;
2413
2475
 
2414
2476
  anchorFragment.endElement = function() {
2415
2477
  return anchorEnd;
@@ -2984,19 +3046,22 @@ var NativeDocument = (function (exports) {
2984
3046
  }
2985
3047
  }
2986
3048
  if(this.$classes) {
2987
- const cache = {};
2988
3049
  const keys = Object.keys(this.$classes);
2989
3050
 
2990
3051
  if(keys.length === 1) {
2991
3052
  const key = keys[0];
2992
3053
  const callback = this.$classes[key];
2993
3054
  steps.push((clonedNode, data) => {
2994
- cache[key] = callback.apply(null, data);
2995
- ElementCreator.processClassAttribute(clonedNode, cache);
3055
+ callback.apply(null, data).bindClassProperty(clonedNode, key);
2996
3056
  });
2997
3057
  } else {
3058
+ const properties = this.$classes;
3059
+ const keysLength = keys.length;
2998
3060
  steps.push((clonedNode, data) => {
2999
- ElementCreator.processClassAttribute(clonedNode, buildProperties(cache, this.$classes, data));
3061
+ for(let i = 0; i < keysLength; i++) {
3062
+ const key = keys[i];
3063
+ properties[key].apply(null, data).bindClassProperty(clonedNode, key);
3064
+ }
3000
3065
  });
3001
3066
  }
3002
3067
  }
@@ -3791,7 +3856,7 @@ var NativeDocument = (function (exports) {
3791
3856
 
3792
3857
  ObservableItem.call(this, target, configs);
3793
3858
  {
3794
- PluginsManager.emit('CreateObservableArray', this);
3859
+ PluginsManager$1.emit('CreateObservableArray', this);
3795
3860
  }
3796
3861
  };
3797
3862
 
@@ -3820,6 +3885,8 @@ var NativeDocument = (function (exports) {
3820
3885
  };
3821
3886
  });
3822
3887
 
3888
+ const $clearEvent = { action: 'clear' };
3889
+
3823
3890
  /**
3824
3891
  * Removes all items from the array and triggers an update.
3825
3892
  *
@@ -3833,7 +3900,7 @@ var NativeDocument = (function (exports) {
3833
3900
  return;
3834
3901
  }
3835
3902
  this.$currentValue.length = 0;
3836
- this.trigger({ action: 'clear' });
3903
+ this.trigger($clearEvent);
3837
3904
  return true;
3838
3905
  };
3839
3906
 
@@ -4423,7 +4490,7 @@ var NativeDocument = (function (exports) {
4423
4490
  const observable = new ObservableItem(initialValue);
4424
4491
  const updatedValue = nextTick(() => observable.set(callback()));
4425
4492
  {
4426
- PluginsManager.emit('CreateObservableComputed', observable, dependencies);
4493
+ PluginsManager$1.emit('CreateObservableComputed', observable, dependencies);
4427
4494
  }
4428
4495
 
4429
4496
  if(Validator.isFunction(dependencies)) {
@@ -4458,7 +4525,7 @@ var NativeDocument = (function (exports) {
4458
4525
  const $getStoreOrThrow = (method, name) => {
4459
4526
  const item = $stores.get(name);
4460
4527
  if (!item) {
4461
- DebugManager$1.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
4528
+ DebugManager$2.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
4462
4529
  throw new NativeDocumentError(
4463
4530
  `Store.${method}('${name}') : store not found.`
4464
4531
  );
@@ -4471,7 +4538,7 @@ var NativeDocument = (function (exports) {
4471
4538
  */
4472
4539
  const $applyReadOnly = (observer, name, context) => {
4473
4540
  const readOnlyError = (method) => () => {
4474
- DebugManager$1.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
4541
+ DebugManager$2.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
4475
4542
  throw new NativeDocumentError(
4476
4543
  `Store.${context}('${name}') is read-only.`
4477
4544
  );
@@ -4502,7 +4569,7 @@ var NativeDocument = (function (exports) {
4502
4569
  */
4503
4570
  create(name, value) {
4504
4571
  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.`);
4572
+ DebugManager$2.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
4506
4573
  throw new NativeDocumentError(
4507
4574
  `Store.create('${name}') : a store with this name already exists.`
4508
4575
  );
@@ -4523,7 +4590,7 @@ var NativeDocument = (function (exports) {
4523
4590
  */
4524
4591
  createResettable(name, value) {
4525
4592
  if ($stores.has(name)) {
4526
- DebugManager$1.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
4593
+ DebugManager$2.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
4527
4594
  throw new NativeDocumentError(
4528
4595
  `Store.createResettable('${name}') : a store with this name already exists.`
4529
4596
  );
@@ -4559,7 +4626,7 @@ var NativeDocument = (function (exports) {
4559
4626
  */
4560
4627
  createComposed(name, computation, dependencies) {
4561
4628
  if ($stores.has(name)) {
4562
- DebugManager$1.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
4629
+ DebugManager$2.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
4563
4630
  throw new NativeDocumentError(
4564
4631
  `Store.createComposed('${name}') : a store with this name already exists.`
4565
4632
  );
@@ -4582,7 +4649,7 @@ var NativeDocument = (function (exports) {
4582
4649
  }
4583
4650
  const depItem = $stores.get(depName);
4584
4651
  if (!depItem) {
4585
- DebugManager$1.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
4652
+ DebugManager$2.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
4586
4653
  throw new NativeDocumentError(
4587
4654
  `Store.createComposed('${name}') : dependency store '${depName}' not found.`
4588
4655
  );
@@ -4616,13 +4683,13 @@ var NativeDocument = (function (exports) {
4616
4683
  reset(name) {
4617
4684
  const item = $getStoreOrThrow('reset', name);
4618
4685
  if (item.composed) {
4619
- DebugManager$1.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
4686
+ DebugManager$2.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
4620
4687
  throw new NativeDocumentError(
4621
4688
  `Store.reset('${name}') : composed stores cannot be reset.`
4622
4689
  );
4623
4690
  }
4624
4691
  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().`);
4692
+ DebugManager$2.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
4626
4693
  throw new NativeDocumentError(
4627
4694
  `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
4628
4695
  );
@@ -4643,7 +4710,7 @@ var NativeDocument = (function (exports) {
4643
4710
  const item = $getStoreOrThrow('use', name);
4644
4711
 
4645
4712
  if (item.composed) {
4646
- DebugManager$1.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
4713
+ DebugManager$2.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
4647
4714
  throw new NativeDocumentError(
4648
4715
  `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
4649
4716
  );
@@ -4710,7 +4777,7 @@ var NativeDocument = (function (exports) {
4710
4777
  get(name) {
4711
4778
  const item = $stores.get(name);
4712
4779
  if (!item) {
4713
- DebugManager$1.warn('Store', `Store.get('${name}') : store not found.`);
4780
+ DebugManager$2.warn('Store', `Store.get('${name}') : store not found.`);
4714
4781
  return null;
4715
4782
  }
4716
4783
  return item.observer;
@@ -4732,7 +4799,7 @@ var NativeDocument = (function (exports) {
4732
4799
  delete(name) {
4733
4800
  const item = $stores.get(name);
4734
4801
  if (!item) {
4735
- DebugManager$1.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
4802
+ DebugManager$2.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
4736
4803
  return;
4737
4804
  }
4738
4805
  item.subscribers.forEach(follower => follower.destroy());
@@ -4834,7 +4901,7 @@ var NativeDocument = (function (exports) {
4834
4901
  return undefined;
4835
4902
  },
4836
4903
  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.`);
4904
+ DebugManager$2.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
4838
4905
  throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
4839
4906
  },
4840
4907
  deleteProperty(target, prop) {
@@ -4922,7 +4989,7 @@ var NativeDocument = (function (exports) {
4922
4989
  }
4923
4990
  cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
4924
4991
  } catch (e) {
4925
- DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
4992
+ DebugManager$2.error('ForEach', `Error creating element for key ${keyId}` , e);
4926
4993
  throw e;
4927
4994
  }
4928
4995
  return keyId;
@@ -5027,7 +5094,7 @@ var NativeDocument = (function (exports) {
5027
5094
  function ForEachArray(data, callback, configs = {}) {
5028
5095
  const element = Anchor('ForEach Array', configs.isParentUniqueChild);
5029
5096
  const blockEnd = element.endElement();
5030
- const blockStart = element.startElement();
5097
+ element.startElement();
5031
5098
 
5032
5099
  let cache = new Map();
5033
5100
  let lastNumberOfItems = 0;
@@ -5035,6 +5102,9 @@ var NativeDocument = (function (exports) {
5035
5102
 
5036
5103
  const clear = (items) => {
5037
5104
  element.removeChildren();
5105
+ clearCacheOnly(items);
5106
+ };
5107
+ const clearCacheOnly = (items) => {
5038
5108
  cleanCache(items);
5039
5109
  lastNumberOfItems = 0;
5040
5110
  };
@@ -5158,11 +5228,16 @@ var NativeDocument = (function (exports) {
5158
5228
  return fragment;
5159
5229
  },
5160
5230
  add: (items) => {
5161
- element.appendElement(Actions.toFragment(items));
5231
+ element.appendChildRaw(Actions.toFragment(items));
5162
5232
  },
5163
5233
  replace: (items) => {
5164
- clear(items);
5165
- Actions.add(items);
5234
+ clearCacheOnly(items);
5235
+ element.replaceContentRaw(Actions.toFragment(items));
5236
+ },
5237
+ set: () => {
5238
+ const items = data.val();
5239
+ clearCacheOnly(items);
5240
+ element.replaceContentRaw(Actions.toFragment(items));
5166
5241
  },
5167
5242
  reOrder: (items) => {
5168
5243
  let child = null;
@@ -5174,23 +5249,12 @@ var NativeDocument = (function (exports) {
5174
5249
  }
5175
5250
  }
5176
5251
  child = null;
5177
- element.appendElement(fragment, blockEnd);
5252
+ element.appendElementRaw(fragment);
5178
5253
  },
5179
5254
  removeOne: (element, index) => {
5180
5255
  removeCacheItem(element, true);
5181
5256
  },
5182
5257
  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
5258
  populate: ([target, iteration, callback]) => {
5195
5259
  const fragment = document.createDocumentFragment();
5196
5260
  for (let i = 0; i < iteration; i++) {
@@ -5199,11 +5263,11 @@ var NativeDocument = (function (exports) {
5199
5263
  fragment.append(buildItem(data, i));
5200
5264
  lastNumberOfItems++;
5201
5265
  }
5202
- element.appendChild(fragment);
5266
+ element.appendChildRaw(fragment);
5203
5267
  fragment.replaceChildren();
5204
5268
  },
5205
5269
  unshift: (values) => {
5206
- element.insertBefore(Actions.toFragment(values), blockStart.nextSibling);
5270
+ element.insertAtStartRaw(Actions.toFragment(values));
5207
5271
  },
5208
5272
  splice: (args, deleted) => {
5209
5273
  const [start, deleteCount, ...values] = args;
@@ -5228,7 +5292,7 @@ var NativeDocument = (function (exports) {
5228
5292
  garbageFragment.replaceChildren();
5229
5293
 
5230
5294
  if(values && values.length && elementBeforeFirst) {
5231
- element.insertBefore(Actions.toFragment(values), elementBeforeFirst.nextSibling);
5295
+ element.insertBeforeRaw(Actions.toFragment(values), elementBeforeFirst.nextSibling);
5232
5296
  }
5233
5297
 
5234
5298
  },
@@ -5248,7 +5312,7 @@ var NativeDocument = (function (exports) {
5248
5312
  Actions.removeOne(deleted);
5249
5313
  },
5250
5314
  swap: (args, elements) => {
5251
- const parent = blockEnd.parentNode;
5315
+ const parent = element.getParent();
5252
5316
 
5253
5317
  let childA = getItemChild(elements[0]);
5254
5318
  let childB = getItemChild(elements[1]);
@@ -5263,37 +5327,22 @@ var NativeDocument = (function (exports) {
5263
5327
  childB = null;
5264
5328
  }
5265
5329
  };
5330
+ Actions.merge = Actions.add;
5331
+ Actions.push = Actions.add;
5266
5332
 
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);
5333
+ const buildContent = (items, _, operations = {}) => {
5334
+ selectBuildStrategy(operations.action);
5276
5335
 
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]) {
5336
+ if(Actions[operations.action]) {
5285
5337
  Actions[operations.action](operations.args, operations.result);
5286
5338
  }
5287
-
5288
5339
  updateIndexObservers(items, 0);
5289
5340
  };
5290
5341
 
5291
5342
  if(data.val().length) {
5292
5343
  buildContent(data.val(), null, {action: null});
5293
5344
  }
5294
- if(Validator.isObservable(data)) {
5295
- data.subscribe(buildContent);
5296
- }
5345
+ data.subscribe(buildContent);
5297
5346
 
5298
5347
  return element;
5299
5348
  }
@@ -5314,7 +5363,7 @@ var NativeDocument = (function (exports) {
5314
5363
  */
5315
5364
  const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
5316
5365
  if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
5317
- return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
5366
+ return DebugManager$2.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
5318
5367
  }
5319
5368
  const element = Anchor('Show if : '+(comment || ''));
5320
5369
 
@@ -6733,7 +6782,7 @@ var NativeDocument = (function (exports) {
6733
6782
  window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
6734
6783
  this.handleRouteChange(route, params, query, path);
6735
6784
  } catch (e) {
6736
- DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
6785
+ DebugManager$2.error('HistoryRouter', 'Error in pushState', e);
6737
6786
  }
6738
6787
  };
6739
6788
  /**
@@ -6746,7 +6795,7 @@ var NativeDocument = (function (exports) {
6746
6795
  window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
6747
6796
  this.handleRouteChange(route, params, {}, path);
6748
6797
  } catch(e) {
6749
- DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
6798
+ DebugManager$2.error('HistoryRouter', 'Error in replaceState', e);
6750
6799
  }
6751
6800
  };
6752
6801
  this.forward = function() {
@@ -6773,7 +6822,7 @@ var NativeDocument = (function (exports) {
6773
6822
  }
6774
6823
  this.handleRouteChange(route, params, query, path);
6775
6824
  } catch(e) {
6776
- DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
6825
+ DebugManager$2.error('HistoryRouter', 'Error in popstate event', e);
6777
6826
  }
6778
6827
  });
6779
6828
  const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
@@ -6998,7 +7047,7 @@ var NativeDocument = (function (exports) {
6998
7047
  listener(request);
6999
7048
  next && next(request);
7000
7049
  } catch (e) {
7001
- DebugManager$1.warn('Route Listener', 'Error in listener:', e);
7050
+ DebugManager$2.warn('Route Listener', 'Error in listener:', e);
7002
7051
  }
7003
7052
  }
7004
7053
  };
@@ -7176,7 +7225,7 @@ var NativeDocument = (function (exports) {
7176
7225
  */
7177
7226
  Router.create = function(options, callback) {
7178
7227
  if(!Validator.isFunction(callback)) {
7179
- DebugManager$1.error('Router', 'Callback must be a function');
7228
+ DebugManager$2.error('Router', 'Callback must be a function');
7180
7229
  throw new RouterError('Callback must be a function');
7181
7230
  }
7182
7231
  const router = new Router(options);
@@ -7380,7 +7429,7 @@ var NativeDocument = (function (exports) {
7380
7429
  exports.HtmlElementWrapper = HtmlElementWrapper;
7381
7430
  exports.NDElement = NDElement;
7382
7431
  exports.Observable = Observable;
7383
- exports.PluginsManager = PluginsManager;
7432
+ exports.PluginsManager = PluginsManager$1;
7384
7433
  exports.SingletonView = SingletonView;
7385
7434
  exports.Store = Store;
7386
7435
  exports.StoreFactory = StoreFactory;