native-document 1.0.98 → 1.0.100

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$1 = {};
4
+ let DebugManager = {};
5
5
 
6
6
  {
7
- DebugManager$1 = {
7
+ DebugManager = {
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 = DebugManager$1;
38
+ var DebugManager$1 = DebugManager;
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.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
385
+ DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
386
386
  }
387
387
  }
388
388
  }
@@ -391,13 +391,13 @@ 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
  this.$observer = null;
399
399
  {
400
- PluginsManager.emit('NDElementCreated', element, this);
400
+ PluginsManager$1.emit('NDElementCreated', element, this);
401
401
  }
402
402
  }
403
403
 
@@ -572,7 +572,7 @@ var NativeDocument = (function (exports) {
572
572
  }
573
573
  {
574
574
  if (this[name] && !this.$localExtensions.has(name)) {
575
- DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
575
+ DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
576
576
  }
577
577
  this.$localExtensions.set(name, method);
578
578
  }
@@ -623,23 +623,23 @@ var NativeDocument = (function (exports) {
623
623
  const method = methods[name];
624
624
 
625
625
  if (typeof method !== 'function') {
626
- DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
626
+ DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
627
627
  continue;
628
628
  }
629
629
 
630
630
  if (protectedMethods.has(name)) {
631
- DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
631
+ DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
632
632
  throw new NativeDocumentError(`Cannot override protected method "${name}"`);
633
633
  }
634
634
 
635
635
  if (NDElement.prototype[name]) {
636
- DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
636
+ DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
637
637
  }
638
638
 
639
639
  NDElement.prototype[name] = method;
640
640
  }
641
641
  {
642
- PluginsManager.emit('NDElementExtended', methods);
642
+ PluginsManager$1.emit('NDElementExtended', methods);
643
643
  }
644
644
 
645
645
  return NDElement;
@@ -786,7 +786,7 @@ var NativeDocument = (function (exports) {
786
786
  const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
787
787
 
788
788
  if (foundReserved.length > 0) {
789
- DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
789
+ DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
790
790
  }
791
791
 
792
792
  return attributes;
@@ -835,7 +835,7 @@ var NativeDocument = (function (exports) {
835
835
  anchorFragment.appendChild = function(child, before = null) {
836
836
  const parent = anchorEnd.parentNode;
837
837
  if(!parent) {
838
- DebugManager.error('Anchor', 'Anchor : parent not found', child);
838
+ DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
839
839
  return;
840
840
  }
841
841
  before = before ?? anchorEnd;
@@ -1033,7 +1033,7 @@ var NativeDocument = (function (exports) {
1033
1033
  }
1034
1034
  }
1035
1035
  if (cleanedCount > 0) {
1036
- DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
1036
+ DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
1037
1037
  }
1038
1038
  }
1039
1039
  };
@@ -1168,7 +1168,7 @@ var NativeDocument = (function (exports) {
1168
1168
  return cloned;
1169
1169
  };
1170
1170
 
1171
- const LocalStorage$1 = {
1171
+ const LocalStorage = {
1172
1172
  getJson(key) {
1173
1173
  let value = localStorage.getItem(key);
1174
1174
  try {
@@ -1204,23 +1204,23 @@ var NativeDocument = (function (exports) {
1204
1204
  }
1205
1205
  };
1206
1206
 
1207
- const $getFromStorage$1 = (key, value) => {
1208
- if(!LocalStorage$1.has(key)) {
1207
+ const $getFromStorage = (key, value) => {
1208
+ if(!LocalStorage.has(key)) {
1209
1209
  return value;
1210
1210
  }
1211
1211
  switch (typeof value) {
1212
- case 'object': return LocalStorage$1.getJson(key) ?? value;
1213
- case 'boolean': return LocalStorage$1.getBool(key) ?? value;
1214
- case 'number': return LocalStorage$1.getNumber(key) ?? value;
1215
- default: return LocalStorage$1.get(key, value) ?? value;
1212
+ case 'object': return LocalStorage.getJson(key) ?? value;
1213
+ case 'boolean': return LocalStorage.getBool(key) ?? value;
1214
+ case 'number': return LocalStorage.getNumber(key) ?? value;
1215
+ default: return LocalStorage.get(key, value) ?? value;
1216
1216
  }
1217
1217
  };
1218
1218
 
1219
- const $saveToStorage$1 = (value) => {
1219
+ const $saveToStorage = (value) => {
1220
1220
  switch (typeof value) {
1221
- case 'object': return LocalStorage$1.setJson;
1222
- case 'boolean': return LocalStorage$1.setBool;
1223
- default: return LocalStorage$1.set;
1221
+ case 'object': return LocalStorage.setJson;
1222
+ case 'boolean': return LocalStorage.setBool;
1223
+ default: return LocalStorage.set;
1224
1224
  }
1225
1225
  };
1226
1226
 
@@ -1235,7 +1235,7 @@ var NativeDocument = (function (exports) {
1235
1235
  const $getStoreOrThrow = (method, name) => {
1236
1236
  const item = $stores.get(name);
1237
1237
  if (!item) {
1238
- DebugManager.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
1238
+ DebugManager$1.error('Store', `Store.${method}('${name}') : store not found. Did you call Store.create('${name}') first?`);
1239
1239
  throw new NativeDocumentError(
1240
1240
  `Store.${method}('${name}') : store not found.`
1241
1241
  );
@@ -1248,7 +1248,7 @@ var NativeDocument = (function (exports) {
1248
1248
  */
1249
1249
  const $applyReadOnly = (observer, name, context) => {
1250
1250
  const readOnlyError = (method) => () => {
1251
- DebugManager.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
1251
+ DebugManager$1.error('Store', `Store.${context}('${name}') is read-only. '${method}()' is not allowed.`);
1252
1252
  throw new NativeDocumentError(
1253
1253
  `Store.${context}('${name}') is read-only.`
1254
1254
  );
@@ -1260,12 +1260,12 @@ var NativeDocument = (function (exports) {
1260
1260
 
1261
1261
  const $createObservable = (value, options = {}) => {
1262
1262
  if(Array.isArray(value)) {
1263
- return Observable$1.array(value, options);
1263
+ return Observable.array(value, options);
1264
1264
  }
1265
1265
  if(typeof value === 'object') {
1266
- return Observable$1.object(value, options);
1266
+ return Observable.object(value, options);
1267
1267
  }
1268
- return Observable$1(value, options);
1268
+ return Observable(value, options);
1269
1269
  };
1270
1270
 
1271
1271
  const $api = {
@@ -1279,7 +1279,7 @@ var NativeDocument = (function (exports) {
1279
1279
  */
1280
1280
  create(name, value) {
1281
1281
  if ($stores.has(name)) {
1282
- DebugManager.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
1282
+ DebugManager$1.warn('Store', `Store.create('${name}') : a store with this name already exists. Use Store.get('${name}') to retrieve it.`);
1283
1283
  throw new NativeDocumentError(
1284
1284
  `Store.create('${name}') : a store with this name already exists.`
1285
1285
  );
@@ -1300,7 +1300,7 @@ var NativeDocument = (function (exports) {
1300
1300
  */
1301
1301
  createResettable(name, value) {
1302
1302
  if ($stores.has(name)) {
1303
- DebugManager.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
1303
+ DebugManager$1.warn('Store', `Store.createResettable('${name}') : a store with this name already exists.`);
1304
1304
  throw new NativeDocumentError(
1305
1305
  `Store.createResettable('${name}') : a store with this name already exists.`
1306
1306
  );
@@ -1336,7 +1336,7 @@ var NativeDocument = (function (exports) {
1336
1336
  */
1337
1337
  createComposed(name, computation, dependencies) {
1338
1338
  if ($stores.has(name)) {
1339
- DebugManager.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
1339
+ DebugManager$1.warn('Store', `Store.createComposed('${name}') : a store with this name already exists.`);
1340
1340
  throw new NativeDocumentError(
1341
1341
  `Store.createComposed('${name}') : a store with this name already exists.`
1342
1342
  );
@@ -1359,7 +1359,7 @@ var NativeDocument = (function (exports) {
1359
1359
  }
1360
1360
  const depItem = $stores.get(depName);
1361
1361
  if (!depItem) {
1362
- DebugManager.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
1362
+ DebugManager$1.error('Store', `Store.createComposed('${name}') : dependency '${depName}' not found. Create it first.`);
1363
1363
  throw new NativeDocumentError(
1364
1364
  `Store.createComposed('${name}') : dependency store '${depName}' not found.`
1365
1365
  );
@@ -1368,7 +1368,7 @@ var NativeDocument = (function (exports) {
1368
1368
  });
1369
1369
 
1370
1370
  // Create computed observable from dependency observers
1371
- const observer = Observable$1.computed(computation, depObservers);
1371
+ const observer = Observable.computed(computation, depObservers);
1372
1372
 
1373
1373
  $stores.set(name, { observer, subscribers: new Set(), resettable: false, composed: true });
1374
1374
  return observer;
@@ -1393,13 +1393,13 @@ var NativeDocument = (function (exports) {
1393
1393
  reset(name) {
1394
1394
  const item = $getStoreOrThrow('reset', name);
1395
1395
  if (item.composed) {
1396
- DebugManager.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
1396
+ DebugManager$1.error('Store', `Store.reset('${name}') : composed stores cannot be reset. Their value is derived from dependencies.`);
1397
1397
  throw new NativeDocumentError(
1398
1398
  `Store.reset('${name}') : composed stores cannot be reset.`
1399
1399
  );
1400
1400
  }
1401
1401
  if (!item.resettable) {
1402
- DebugManager.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
1402
+ DebugManager$1.error('Store', `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`);
1403
1403
  throw new NativeDocumentError(
1404
1404
  `Store.reset('${name}') : this store is not resettable. Use Store.createResettable('${name}', value) instead of Store.create().`
1405
1405
  );
@@ -1420,7 +1420,7 @@ var NativeDocument = (function (exports) {
1420
1420
  const item = $getStoreOrThrow('use', name);
1421
1421
 
1422
1422
  if (item.composed) {
1423
- DebugManager.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
1423
+ DebugManager$1.error('Store', `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`);
1424
1424
  throw new NativeDocumentError(
1425
1425
  `Store.use('${name}') : composed stores are read-only. Use Store.follow('${name}') instead.`
1426
1426
  );
@@ -1487,7 +1487,7 @@ var NativeDocument = (function (exports) {
1487
1487
  get(name) {
1488
1488
  const item = $stores.get(name);
1489
1489
  if (!item) {
1490
- DebugManager.warn('Store', `Store.get('${name}') : store not found.`);
1490
+ DebugManager$1.warn('Store', `Store.get('${name}') : store not found.`);
1491
1491
  return null;
1492
1492
  }
1493
1493
  return item.observer;
@@ -1509,7 +1509,7 @@ var NativeDocument = (function (exports) {
1509
1509
  delete(name) {
1510
1510
  const item = $stores.get(name);
1511
1511
  if (!item) {
1512
- DebugManager.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
1512
+ DebugManager$1.warn('Store', `Store.delete('${name}') : store not found, nothing to delete.`);
1513
1513
  return;
1514
1514
  }
1515
1515
  item.subscribers.forEach(follower => follower.destroy());
@@ -1572,21 +1572,21 @@ var NativeDocument = (function (exports) {
1572
1572
  },
1573
1573
  createPersistent(name, value, localstorage_key) {
1574
1574
  localstorage_key = localstorage_key || name;
1575
- const observer = this.create(name, $getFromStorage$1(localstorage_key, value));
1576
- const saver = $saveToStorage$1(value);
1575
+ const observer = this.create(name, $getFromStorage(localstorage_key, value));
1576
+ const saver = $saveToStorage(value);
1577
1577
 
1578
1578
  observer.subscribe((val) => saver(localstorage_key, val));
1579
1579
  return observer;
1580
1580
  },
1581
1581
  createPersistentResettable(name, value, localstorage_key) {
1582
1582
  localstorage_key = localstorage_key || name;
1583
- const observer = this.createResettable(name, $getFromStorage$1(localstorage_key, value));
1584
- const saver = $saveToStorage$1(value);
1583
+ const observer = this.createResettable(name, $getFromStorage(localstorage_key, value));
1584
+ const saver = $saveToStorage(value);
1585
1585
  observer.subscribe((val) => saver(localstorage_key, val));
1586
1586
 
1587
1587
  const originalReset = observer.reset.bind(observer);
1588
1588
  observer.reset = () => {
1589
- LocalStorage$1.remove(localstorage_key);
1589
+ LocalStorage.remove(localstorage_key);
1590
1590
  originalReset();
1591
1591
  };
1592
1592
 
@@ -1611,7 +1611,7 @@ var NativeDocument = (function (exports) {
1611
1611
  return undefined;
1612
1612
  },
1613
1613
  set(target, prop, value) {
1614
- DebugManager.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
1614
+ DebugManager$1.error('Store', `Forbidden: You cannot overwrite the store key '${String(prop)}'. Use .use('${String(prop)}').set(value) instead.`);
1615
1615
  throw new NativeDocumentError(`Store structure is immutable. Use .set() on the observable.`);
1616
1616
  },
1617
1617
  deleteProperty(target, prop) {
@@ -1622,7 +1622,7 @@ var NativeDocument = (function (exports) {
1622
1622
 
1623
1623
  const Store = StoreFactory();
1624
1624
 
1625
- Store.create('locale', 'fr');
1625
+ Store.create('locale', navigator.language.split('-')[0] || 'en');
1626
1626
 
1627
1627
  const $parseDateParts = (value, locale) => {
1628
1628
  const d = new Date(value);
@@ -1658,7 +1658,6 @@ var NativeDocument = (function (exports) {
1658
1658
  };
1659
1659
 
1660
1660
  const Formatters = {
1661
-
1662
1661
  currency: (value, locale, { currency = 'XOF', notation, minimumFractionDigits, maximumFractionDigits } = {}) =>
1663
1662
  new Intl.NumberFormat(locale, {
1664
1663
  style: 'currency',
@@ -1744,7 +1743,7 @@ var NativeDocument = (function (exports) {
1744
1743
  }
1745
1744
  }
1746
1745
  {
1747
- PluginsManager.emit('CreateObservable', this);
1746
+ PluginsManager$1.emit('CreateObservable', this);
1748
1747
  }
1749
1748
  }
1750
1749
 
@@ -1848,12 +1847,12 @@ var NativeDocument = (function (exports) {
1848
1847
  this.$previousValue = this.$currentValue;
1849
1848
  this.$currentValue = newValue;
1850
1849
  {
1851
- PluginsManager.emit('ObservableBeforeChange', this);
1850
+ PluginsManager$1.emit('ObservableBeforeChange', this);
1852
1851
  }
1853
1852
  this.trigger();
1854
1853
  this.$previousValue = null;
1855
1854
  {
1856
- PluginsManager.emit('ObservableAfterChange', this);
1855
+ PluginsManager$1.emit('ObservableAfterChange', this);
1857
1856
  }
1858
1857
  };
1859
1858
 
@@ -1940,7 +1939,7 @@ var NativeDocument = (function (exports) {
1940
1939
  ObservableItem.prototype.subscribe = function(callback) {
1941
1940
  {
1942
1941
  if (this.$isCleanedUp) {
1943
- DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
1942
+ DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
1944
1943
  return;
1945
1944
  }
1946
1945
  if (typeof callback !== 'function') {
@@ -1952,7 +1951,7 @@ var NativeDocument = (function (exports) {
1952
1951
  this.$listeners.push(callback);
1953
1952
  this.assocTrigger();
1954
1953
  {
1955
- PluginsManager.emit('ObservableSubscribe', this);
1954
+ PluginsManager$1.emit('ObservableSubscribe', this);
1956
1955
  }
1957
1956
  };
1958
1957
 
@@ -2063,7 +2062,7 @@ var NativeDocument = (function (exports) {
2063
2062
  }
2064
2063
  this.assocTrigger();
2065
2064
  {
2066
- PluginsManager.emit('ObservableUnsubscribe', this);
2065
+ PluginsManager$1.emit('ObservableUnsubscribe', this);
2067
2066
  }
2068
2067
  };
2069
2068
 
@@ -2266,20 +2265,20 @@ var NativeDocument = (function (exports) {
2266
2265
  }
2267
2266
 
2268
2267
  const formatter = Formatters[type];
2269
- const localeObservable = Store.follow('locale');
2268
+ const localeObservable = Formatters.locale;
2270
2269
 
2271
- return Observable$1.computed(() => formatter(self.val(), localeObservable.val(), options),
2270
+ return Observable.computed(() => formatter(self.val(), localeObservable.val(), options),
2272
2271
  [self, localeObservable]
2273
2272
  );
2274
2273
  };
2275
2274
 
2276
2275
  ObservableItem.prototype.persist = function(key, options = {}) {
2277
- let value = $getFromStorage$1(key, this.$currentValue);
2276
+ let value = $getFromStorage(key, this.$currentValue);
2278
2277
  if(options.get) {
2279
2278
  value = options.get(value);
2280
2279
  }
2281
2280
  this.set(value);
2282
- const saver = $saveToStorage$1(this.$currentValue);
2281
+ const saver = $saveToStorage(this.$currentValue);
2283
2282
  this.subscribe((newValue) => {
2284
2283
  saver(key, options.set ? options.set(newValue) : newValue);
2285
2284
  });
@@ -2293,18 +2292,18 @@ var NativeDocument = (function (exports) {
2293
2292
  * @returns {ObservableItem}
2294
2293
  * @constructor
2295
2294
  */
2296
- function Observable$1(value, configs = null) {
2295
+ function Observable(value, configs = null) {
2297
2296
  return new ObservableItem(value, configs);
2298
2297
  }
2299
2298
 
2300
- const $ = Observable$1;
2301
- const obs = Observable$1;
2299
+ const $ = Observable;
2300
+ const obs = Observable;
2302
2301
 
2303
2302
  /**
2304
2303
  *
2305
2304
  * @param {string} propertyName
2306
2305
  */
2307
- Observable$1.useValueProperty = function(propertyName = 'value') {
2306
+ Observable.useValueProperty = function(propertyName = 'value') {
2308
2307
  Object.defineProperty(ObservableItem.prototype, propertyName, {
2309
2308
  get() {
2310
2309
  return this.$currentValue;
@@ -2322,7 +2321,7 @@ var NativeDocument = (function (exports) {
2322
2321
  * @param id
2323
2322
  * @returns {ObservableItem|null}
2324
2323
  */
2325
- Observable$1.getById = function(id) {
2324
+ Observable.getById = function(id) {
2326
2325
  const item = MemoryManager.getObservableById(parseInt(id));
2327
2326
  if(!item) {
2328
2327
  throw new NativeDocumentError('Observable.getById : No observable found with id ' + id);
@@ -2334,7 +2333,7 @@ var NativeDocument = (function (exports) {
2334
2333
  *
2335
2334
  * @param {ObservableItem} observable
2336
2335
  */
2337
- Observable$1.cleanup = function(observable) {
2336
+ Observable.cleanup = function(observable) {
2338
2337
  observable.cleanup();
2339
2338
  };
2340
2339
 
@@ -2343,7 +2342,7 @@ var NativeDocument = (function (exports) {
2343
2342
  * @param {Boolean} enable
2344
2343
  * @param {{interval:Boolean, threshold:number}} options
2345
2344
  */
2346
- Observable$1.autoCleanup = function(enable = false, options = {}) {
2345
+ Observable.autoCleanup = function(enable = false, options = {}) {
2347
2346
  if(!enable) {
2348
2347
  return;
2349
2348
  }
@@ -2541,7 +2540,7 @@ var NativeDocument = (function (exports) {
2541
2540
  Function.prototype.toNdElement = function () {
2542
2541
  const child = this;
2543
2542
  {
2544
- PluginsManager.emit('BeforeProcessComponent', child);
2543
+ PluginsManager$1.emit('BeforeProcessComponent', child);
2545
2544
  }
2546
2545
  return ElementCreator.getChild(child());
2547
2546
  };
@@ -2729,14 +2728,14 @@ var NativeDocument = (function (exports) {
2729
2728
  processChildren(children, parent) {
2730
2729
  if(children === null) return;
2731
2730
  {
2732
- PluginsManager.emit('BeforeProcessChildren', parent);
2731
+ PluginsManager$1.emit('BeforeProcessChildren', parent);
2733
2732
  }
2734
2733
  let child = this.getChild(children);
2735
2734
  if(child) {
2736
2735
  parent.appendChild(child);
2737
2736
  }
2738
2737
  {
2739
- PluginsManager.emit('AfterProcessChildren', parent);
2738
+ PluginsManager$1.emit('AfterProcessChildren', parent);
2740
2739
  }
2741
2740
  },
2742
2741
  async safeRemove(element) {
@@ -3497,7 +3496,7 @@ var NativeDocument = (function (exports) {
3497
3496
  String.prototype.use = function(args) {
3498
3497
  const value = this;
3499
3498
 
3500
- return Observable$1.computed(() => {
3499
+ return Observable.computed(() => {
3501
3500
  return value.replace(/\$\{(.*?)}/g, (match, key) => {
3502
3501
  const data = args[key];
3503
3502
  if(Validator.isObservable(data)) {
@@ -3517,7 +3516,7 @@ var NativeDocument = (function (exports) {
3517
3516
  return value;
3518
3517
  }
3519
3518
  const [_, id] = value.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);
3520
- return Observable$1.getById(id);
3519
+ return Observable.getById(id);
3521
3520
  });
3522
3521
  };
3523
3522
 
@@ -3992,7 +3991,7 @@ var NativeDocument = (function (exports) {
3992
3991
 
3993
3992
  ObservableItem.call(this, target, configs);
3994
3993
  {
3995
- PluginsManager.emit('CreateObservableArray', this);
3994
+ PluginsManager$1.emit('CreateObservableArray', this);
3996
3995
  }
3997
3996
  };
3998
3997
 
@@ -4210,7 +4209,7 @@ var NativeDocument = (function (exports) {
4210
4209
  }
4211
4210
  }
4212
4211
 
4213
- const viewArray = Observable$1.array();
4212
+ const viewArray = Observable.array();
4214
4213
 
4215
4214
  const filters = Object.entries(filterCallbacks);
4216
4215
  const updateView = () => {
@@ -4281,6 +4280,68 @@ var NativeDocument = (function (exports) {
4281
4280
  });
4282
4281
  };
4283
4282
 
4283
+ ObservableArray.prototype.deepSubscribe = function(callback) {
4284
+ const updatedValue = nextTick(() => callback(this.val()));
4285
+ const $listeners = new WeakMap();
4286
+
4287
+ const bindItem = (item) => {
4288
+ if ($listeners.has(item)) {
4289
+ return;
4290
+ }
4291
+ if (item?.__$isObservableArray) {
4292
+ $listeners.set(item, item.deepSubscribe(updatedValue));
4293
+ return;
4294
+ }
4295
+ if (item?.__$isObservable) {
4296
+ item.subscribe(updatedValue);
4297
+ $listeners.set(item, () => item.unsubscribe(updatedValue));
4298
+ }
4299
+ };
4300
+
4301
+ const unbindItem = (item) => {
4302
+ const unsub = $listeners.get(item);
4303
+ if (unsub) {
4304
+ unsub();
4305
+ $listeners.delete(item);
4306
+ }
4307
+ };
4308
+
4309
+ this.$currentValue.forEach(bindItem);
4310
+ this.subscribe(updatedValue);
4311
+
4312
+ this.subscribe((items, _, operations) => {
4313
+ switch (operations?.action) {
4314
+ case 'push':
4315
+ case 'unshift':
4316
+ operations.args.forEach(bindItem);
4317
+ break;
4318
+
4319
+ case 'splice': {
4320
+ const [start, deleteCount, ...newItems] = operations.args;
4321
+ operations.result?.forEach(unbindItem);
4322
+ newItems.forEach(bindItem);
4323
+ break;
4324
+ }
4325
+
4326
+ case 'remove':
4327
+ unbindItem(operations.result);
4328
+ break;
4329
+
4330
+ case 'merge':
4331
+ operations.args.forEach(bindItem);
4332
+ break;
4333
+
4334
+ case 'clear':
4335
+ this.$currentValue.forEach(unbindItem);
4336
+ break;
4337
+ }
4338
+ });
4339
+
4340
+ return () => {
4341
+ this.$currentValue.forEach(unbindItem);
4342
+ };
4343
+ };
4344
+
4284
4345
  /**
4285
4346
  * Creates an observable array with reactive array methods.
4286
4347
  * All mutations trigger updates automatically.
@@ -4296,7 +4357,7 @@ var NativeDocument = (function (exports) {
4296
4357
  * items.push(4); // Triggers update
4297
4358
  * items.subscribe((arr) => console.log(arr));
4298
4359
  */
4299
- Observable$1.array = function(target = [], configs = null) {
4360
+ Observable.array = function(target = [], configs = null) {
4300
4361
  return new ObservableArray(target, configs);
4301
4362
  };
4302
4363
 
@@ -4305,8 +4366,8 @@ var NativeDocument = (function (exports) {
4305
4366
  * @param {Function} callback
4306
4367
  * @returns {Function}
4307
4368
  */
4308
- Observable$1.batch = function(callback) {
4309
- const $observer = Observable$1(0);
4369
+ Observable.batch = function(callback) {
4370
+ const $observer = Observable(0);
4310
4371
  const batch = function() {
4311
4372
  if(Validator.isAsyncFunction(callback)) {
4312
4373
  return (callback(...arguments)).then(() => {
@@ -4360,24 +4421,24 @@ var NativeDocument = (function (exports) {
4360
4421
  if(configs?.deep !== false) {
4361
4422
  const mappedItemValue = itemValue.map(item => {
4362
4423
  if(Validator.isJson(item)) {
4363
- return Observable$1.json(item, configs);
4424
+ return Observable.json(item, configs);
4364
4425
  }
4365
4426
  if(Validator.isArray(item)) {
4366
- return Observable$1.array(item, configs);
4427
+ return Observable.array(item, configs);
4367
4428
  }
4368
- return Observable$1(item, configs);
4429
+ return Observable(item, configs);
4369
4430
  });
4370
- this.$observables[key] = Observable$1.array(mappedItemValue, configs);
4431
+ this.$observables[key] = Observable.array(mappedItemValue, configs);
4371
4432
  continue;
4372
4433
  }
4373
- this.$observables[key] = Observable$1.array(itemValue, configs);
4434
+ this.$observables[key] = Observable.array(itemValue, configs);
4374
4435
  continue;
4375
4436
  }
4376
4437
  if(Validator.isObservable(itemValue) || Validator.isProxy(itemValue)) {
4377
4438
  this.$observables[key] = itemValue;
4378
4439
  continue;
4379
4440
  }
4380
- this.$observables[key] = Observable$1(itemValue, configs);
4441
+ this.$observables[key] = (typeof itemValue === 'object') ? Observable.object(itemValue, configs) : Observable(itemValue, configs);
4381
4442
  }
4382
4443
  };
4383
4444
 
@@ -4439,9 +4500,9 @@ var NativeDocument = (function (exports) {
4439
4500
  if(Validator.isObservable(firstElementFromOriginalValue) || Validator.isProxy(firstElementFromOriginalValue)) {
4440
4501
  const newValues = newValue.map(item => {
4441
4502
  if(Validator.isProxy(firstElementFromOriginalValue)) {
4442
- return Observable$1.init(item, configs);
4503
+ return Observable.init(item, configs);
4443
4504
  }
4444
- return Observable$1(item, configs);
4505
+ return Observable(item, configs);
4445
4506
  });
4446
4507
  targetItem.set(newValues);
4447
4508
  continue;
@@ -4469,7 +4530,7 @@ var NativeDocument = (function (exports) {
4469
4530
  };
4470
4531
  ObservableObject.prototype.$keys = ObservableObject.prototype.keys;
4471
4532
  ObservableObject.prototype.clone = function() {
4472
- return Observable$1.init(this.val(), this.configs);
4533
+ return Observable.init(this.val(), this.configs);
4473
4534
  };
4474
4535
  ObservableObject.prototype.$clone = ObservableObject.prototype.clone;
4475
4536
  ObservableObject.prototype.reset = function() {
@@ -4480,15 +4541,16 @@ var NativeDocument = (function (exports) {
4480
4541
  ObservableObject.prototype.originalSubscribe = ObservableObject.prototype.subscribe;
4481
4542
  ObservableObject.prototype.subscribe = function(callback) {
4482
4543
  const observables = this.observables();
4483
- const updatedValue = nextTick(() => {
4484
- this.$currentValue = this.val();
4485
- this.trigger();
4486
- });
4544
+ const updatedValue = nextTick(() => this.trigger());
4487
4545
 
4488
4546
  this.originalSubscribe(callback);
4489
4547
 
4490
- for(let i = 0, length = observables.length; i < length; i++) {
4548
+ for (let i = 0, length = observables.length; i < length; i++) {
4491
4549
  const observable = observables[i];
4550
+ if (observable.__$isObservableArray) {
4551
+ observable.deepSubscribe(updatedValue);
4552
+ continue
4553
+ }
4492
4554
  observable.subscribe(updatedValue);
4493
4555
  }
4494
4556
  };
@@ -4498,7 +4560,7 @@ var NativeDocument = (function (exports) {
4498
4560
 
4499
4561
  ObservableObject.prototype.update = ObservableObject.prototype.set;
4500
4562
 
4501
- Observable$1.init = function(initialValue, configs = null) {
4563
+ Observable.init = function(initialValue, configs = null) {
4502
4564
  return new ObservableObject(initialValue, configs)
4503
4565
  };
4504
4566
 
@@ -4507,8 +4569,8 @@ var NativeDocument = (function (exports) {
4507
4569
  * @param {any[]} data
4508
4570
  * @return Proxy[]
4509
4571
  */
4510
- Observable$1.arrayOfObject = function(data) {
4511
- return data.map(item => Observable$1.object(item));
4572
+ Observable.arrayOfObject = function(data) {
4573
+ return data.map(item => Observable.object(item));
4512
4574
  };
4513
4575
 
4514
4576
  /**
@@ -4516,7 +4578,7 @@ var NativeDocument = (function (exports) {
4516
4578
  * @param {ObservableItem|Object<ObservableItem>} data
4517
4579
  * @returns {{}|*|null}
4518
4580
  */
4519
- Observable$1.value = function(data) {
4581
+ Observable.value = function(data) {
4520
4582
  if(Validator.isObservable(data)) {
4521
4583
  return data.val();
4522
4584
  }
@@ -4527,15 +4589,15 @@ var NativeDocument = (function (exports) {
4527
4589
  const result = [];
4528
4590
  for(let i = 0, length = data.length; i < length; i++) {
4529
4591
  const item = data[i];
4530
- result.push(Observable$1.value(item));
4592
+ result.push(Observable.value(item));
4531
4593
  }
4532
4594
  return result;
4533
4595
  }
4534
4596
  return data;
4535
4597
  };
4536
4598
 
4537
- Observable$1.object = Observable$1.init;
4538
- Observable$1.json = Observable$1.init;
4599
+ Observable.object = Observable.init;
4600
+ Observable.json = Observable.init;
4539
4601
 
4540
4602
  /**
4541
4603
  * Creates a computed observable that automatically updates when its dependencies change.
@@ -4556,12 +4618,12 @@ var NativeDocument = (function (exports) {
4556
4618
  * const batch = Observable.batch(() => { ... });
4557
4619
  * const computed = Observable.computed(() => { ... }, batch);
4558
4620
  */
4559
- Observable$1.computed = function(callback, dependencies = []) {
4621
+ Observable.computed = function(callback, dependencies = []) {
4560
4622
  const initialValue = callback();
4561
4623
  const observable = new ObservableItem(initialValue);
4562
4624
  const updatedValue = nextTick(() => observable.set(callback()));
4563
4625
  {
4564
- PluginsManager.emit('CreateObservableComputed', observable, dependencies);
4626
+ PluginsManager$1.emit('CreateObservableComputed', observable, dependencies);
4565
4627
  }
4566
4628
 
4567
4629
  if(Validator.isFunction(dependencies)) {
@@ -4653,14 +4715,14 @@ var NativeDocument = (function (exports) {
4653
4715
  }
4654
4716
 
4655
4717
  try {
4656
- const indexObserver = callback.length >= 2 ? Observable$1(indexKey) : null;
4718
+ const indexObserver = callback.length >= 2 ? Observable(indexKey) : null;
4657
4719
  let child = ElementCreator.getChild(callback(item, indexObserver));
4658
4720
  if(!child) {
4659
4721
  throw new NativeDocumentError("ForEach child can't be null or undefined!");
4660
4722
  }
4661
4723
  cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
4662
4724
  } catch (e) {
4663
- DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
4725
+ DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
4664
4726
  throw e;
4665
4727
  }
4666
4728
  return keyId;
@@ -4835,7 +4897,7 @@ var NativeDocument = (function (exports) {
4835
4897
  cache.delete(item);
4836
4898
  }
4837
4899
 
4838
- const indexObserver = isIndexRequired ? Observable$1(indexKey) : null;
4900
+ const indexObserver = isIndexRequired ? Observable(indexKey) : null;
4839
4901
  let child = ElementCreator.getChild(callback(item, indexObserver));
4840
4902
  if(child) {
4841
4903
  cache.set(item, {
@@ -5030,7 +5092,7 @@ var NativeDocument = (function (exports) {
5030
5092
  */
5031
5093
  const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
5032
5094
  if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
5033
- return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
5095
+ return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
5034
5096
  }
5035
5097
  const element = Anchor('Show if : '+(comment || ''));
5036
5098
 
@@ -5077,7 +5139,7 @@ var NativeDocument = (function (exports) {
5077
5139
  * HideIf(hasError, Div({}, 'Content'));
5078
5140
  */
5079
5141
  const HideIf = function(condition, child, configs) {
5080
- const hideCondition = Observable$1(!condition.val());
5142
+ const hideCondition = Observable(!condition.val());
5081
5143
  condition.subscribe(value => hideCondition.set(!value));
5082
5144
 
5083
5145
  return ShowIf(hideCondition, child, configs);
@@ -6449,7 +6511,7 @@ var NativeDocument = (function (exports) {
6449
6511
  window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
6450
6512
  this.handleRouteChange(route, params, query, path);
6451
6513
  } catch (e) {
6452
- DebugManager.error('HistoryRouter', 'Error in pushState', e);
6514
+ DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
6453
6515
  }
6454
6516
  };
6455
6517
  /**
@@ -6462,7 +6524,7 @@ var NativeDocument = (function (exports) {
6462
6524
  window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
6463
6525
  this.handleRouteChange(route, params, {}, path);
6464
6526
  } catch(e) {
6465
- DebugManager.error('HistoryRouter', 'Error in replaceState', e);
6527
+ DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
6466
6528
  }
6467
6529
  };
6468
6530
  this.forward = function() {
@@ -6489,7 +6551,7 @@ var NativeDocument = (function (exports) {
6489
6551
  }
6490
6552
  this.handleRouteChange(route, params, query, path);
6491
6553
  } catch(e) {
6492
- DebugManager.error('HistoryRouter', 'Error in popstate event', e);
6554
+ DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
6493
6555
  }
6494
6556
  });
6495
6557
  const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
@@ -6714,7 +6776,7 @@ var NativeDocument = (function (exports) {
6714
6776
  listener(request);
6715
6777
  next && next(request);
6716
6778
  } catch (e) {
6717
- DebugManager.warn('Route Listener', 'Error in listener:', e);
6779
+ DebugManager$1.warn('Route Listener', 'Error in listener:', e);
6718
6780
  }
6719
6781
  }
6720
6782
  };
@@ -6892,7 +6954,7 @@ var NativeDocument = (function (exports) {
6892
6954
  */
6893
6955
  Router.create = function(options, callback) {
6894
6956
  if(!Validator.isFunction(callback)) {
6895
- DebugManager.error('Router', 'Callback must be a function');
6957
+ DebugManager$1.error('Router', 'Callback must be a function');
6896
6958
  throw new RouterError('Callback must be a function');
6897
6959
  }
6898
6960
  const router = new Router(options);
@@ -7084,8 +7146,8 @@ var NativeDocument = (function (exports) {
7084
7146
  exports.ElementCreator = ElementCreator;
7085
7147
  exports.HtmlElementWrapper = HtmlElementWrapper;
7086
7148
  exports.NDElement = NDElement;
7087
- exports.Observable = Observable$1;
7088
- exports.PluginsManager = PluginsManager;
7149
+ exports.Observable = Observable;
7150
+ exports.PluginsManager = PluginsManager$1;
7089
7151
  exports.SingletonView = SingletonView;
7090
7152
  exports.Store = Store;
7091
7153
  exports.StoreFactory = StoreFactory;