aberdeen 1.0.12 → 1.1.0

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.
package/dist/aberdeen.js CHANGED
@@ -194,7 +194,7 @@ class ContentScope extends Scope {
194
194
  getInsertAfterNode() {
195
195
  return this.getLastNode() || this.getPrecedingNode();
196
196
  }
197
- onChange(index, newData, oldData) {
197
+ onChange() {
198
198
  queue(this);
199
199
  }
200
200
  getChildPrevSibling() {
@@ -336,32 +336,6 @@ class SetArgScope extends ChainedScope {
336
336
  currentScope = savedScope;
337
337
  }
338
338
  }
339
- var immediateQueue = new ReverseSortedSet("prio");
340
-
341
- class ImmediateScope extends RegularScope {
342
- onChange(index, newData, oldData) {
343
- immediateQueue.add(this);
344
- }
345
- }
346
- var immediateQueueRunning = false;
347
- function runImmediateQueue() {
348
- for (let count = 0;!immediateQueue.isEmpty() && !immediateQueueRunning; count++) {
349
- if (count > 42) {
350
- immediateQueue.clear();
351
- throw new Error("Too many immediate-mode recursive updates");
352
- }
353
- immediateQueueRunning = true;
354
- const copy = immediateQueue;
355
- immediateQueue = new ReverseSortedSet("prio");
356
- try {
357
- for (const scope of copy) {
358
- scope.queueRun();
359
- }
360
- } finally {
361
- immediateQueueRunning = false;
362
- }
363
- }
364
- }
365
339
 
366
340
  class OnEachScope extends Scope {
367
341
  renderer;
@@ -383,22 +357,18 @@ class OnEachScope extends Scope {
383
357
  currentScope.cleaners.push(this);
384
358
  if (target instanceof Array) {
385
359
  for (let i = 0;i < target.length; i++) {
386
- if (target[i] !== undefined) {
387
- new OnEachItemScope(this, i, false);
388
- }
360
+ new OnEachItemScope(this, i, false);
389
361
  }
390
362
  } else {
391
- for (const [key, value] of getEntries(target)) {
392
- if (value !== undefined) {
393
- new OnEachItemScope(this, key, false);
394
- }
363
+ for (const key of target instanceof Map ? target.keys() : Object.keys(target)) {
364
+ new OnEachItemScope(this, key, false);
395
365
  }
396
366
  }
397
367
  }
398
368
  getPrecedingNode() {
399
369
  return findLastNodeInPrevSiblings(this.prevSibling);
400
370
  }
401
- onChange(index, newData, oldData) {
371
+ onChange(index) {
402
372
  if (!(this.target instanceof Array) || typeof index === "number")
403
373
  this.changedIndexes.add(index);
404
374
  queue(this);
@@ -410,16 +380,10 @@ class OnEachScope extends Scope {
410
380
  const oldScope = this.byIndex.get(index);
411
381
  if (oldScope)
412
382
  oldScope.remove();
413
- let hasValue;
414
- if (this.target instanceof Map) {
415
- hasValue = this.target.has(index);
383
+ if (this.target instanceof Map ? this.target.has(index) : (index in this.target)) {
384
+ new OnEachItemScope(this, index, true);
416
385
  } else {
417
- hasValue = this.target[index] !== undefined;
418
- }
419
- if (!hasValue) {
420
386
  this.byIndex.delete(index);
421
- } else {
422
- new OnEachItemScope(this, index, true);
423
387
  }
424
388
  }
425
389
  topRedrawScope = undefined;
@@ -553,6 +517,15 @@ function addNode(node) {
553
517
  }
554
518
  var ROOT_SCOPE = new RootScope;
555
519
  var currentScope = ROOT_SCOPE;
520
+ function leakScope(func) {
521
+ const savedScope = currentScope;
522
+ currentScope = new RootScope;
523
+ try {
524
+ return func();
525
+ } finally {
526
+ currentScope = savedScope;
527
+ }
528
+ }
556
529
  var ANY_SYMBOL = Symbol("any");
557
530
  var TARGET_SYMBOL = Symbol("target");
558
531
  var MAP_SIZE_SYMBOL = Symbol("mapSize");
@@ -587,10 +560,11 @@ function onEach(target, render, makeKey) {
587
560
  new OnEachScope(target, render, makeKey);
588
561
  }
589
562
  function isObjEmpty(obj) {
590
- for (const k in obj)
563
+ for (const k of Object.keys(obj))
591
564
  return false;
592
565
  return true;
593
566
  }
567
+ var EMPTY = Symbol("empty");
594
568
  function isEmpty(proxied) {
595
569
  const target = proxied[TARGET_SYMBOL] || proxied;
596
570
  const scope = currentScope;
@@ -610,7 +584,7 @@ function isEmpty(proxied) {
610
584
  }
611
585
  const result = isObjEmpty(target);
612
586
  subscribe(target, ANY_SYMBOL, (index, newData, oldData) => {
613
- if (result ? oldData === undefined : newData === undefined)
587
+ if (result ? oldData === EMPTY : newData === EMPTY)
614
588
  queue(scope);
615
589
  });
616
590
  return result;
@@ -622,14 +596,14 @@ function count(proxied) {
622
596
  return ref(proxied, "size");
623
597
  const target = proxied[TARGET_SYMBOL] || proxied;
624
598
  let cnt = 0;
625
- for (const k in target)
599
+ for (const k of Object.keys(target))
626
600
  if (target[k] !== undefined)
627
601
  cnt++;
628
602
  const result = proxy(cnt);
629
603
  subscribe(target, ANY_SYMBOL, (index, newData, oldData) => {
630
- if (oldData === newData) {} else if (oldData === undefined)
604
+ if (oldData === newData) {} else if (oldData === EMPTY)
631
605
  result.value = ++cnt;
632
- else if (newData === undefined)
606
+ else if (newData === EMPTY)
633
607
  result.value = --cnt;
634
608
  });
635
609
  return result;
@@ -647,7 +621,7 @@ function defaultEmitHandler(target, index, newData, oldData) {
647
621
  if (typeof observer === "function")
648
622
  observer(index, newData, oldData);
649
623
  else
650
- observer.onChange(index, newData, oldData);
624
+ observer.onChange(index);
651
625
  }
652
626
  }
653
627
  }
@@ -663,25 +637,22 @@ var objectHandler = {
663
637
  set(target, prop, newData) {
664
638
  if (typeof newData === "object" && newData)
665
639
  newData = newData[TARGET_SYMBOL] || newData;
666
- const oldData = target[prop];
640
+ const oldData = target.hasOwnProperty(prop) ? target[prop] : EMPTY;
667
641
  if (newData !== oldData) {
668
642
  target[prop] = newData;
669
643
  emit(target, prop, newData, oldData);
670
- runImmediateQueue();
671
644
  }
672
645
  return true;
673
646
  },
674
647
  deleteProperty(target, prop) {
675
- const old = target[prop];
648
+ const old = target.hasOwnProperty(prop) ? target[prop] : undefined;
676
649
  delete target[prop];
677
- emit(target, prop, undefined, old);
678
- runImmediateQueue();
650
+ emit(target, prop, EMPTY, old);
679
651
  return true;
680
652
  },
681
653
  has(target, prop) {
682
- const result = prop in target;
683
654
  subscribe(target, prop);
684
- return result;
655
+ return target.hasOwnProperty(prop);
685
656
  },
686
657
  ownKeys(target) {
687
658
  subscribe(target, ANY_SYMBOL);
@@ -689,27 +660,31 @@ var objectHandler = {
689
660
  }
690
661
  };
691
662
  function arraySet(target, prop, newData) {
692
- if (typeof newData === "object" && newData)
663
+ if (typeof newData === "object" && newData) {
693
664
  newData = newData[TARGET_SYMBOL] || newData;
694
- const oldData = target[prop];
665
+ }
666
+ let oldData = target[prop];
667
+ if (oldData === undefined && !target.hasOwnProperty(prop))
668
+ oldData = EMPTY;
695
669
  if (newData !== oldData) {
696
670
  const oldLength = target.length;
697
671
  if (prop === "length") {
698
672
  target.length = newData;
699
673
  for (let i = newData;i < oldLength; i++) {
700
- emit(target, i, undefined, target[i]);
674
+ emit(target, i, EMPTY, target[i]);
701
675
  }
702
676
  } else {
703
- const intProp = Number.parseInt(prop);
704
- if (intProp.toString() === prop)
705
- prop = intProp;
677
+ if (typeof prop === "string") {
678
+ const n = 0 | prop;
679
+ if (String(n) === prop && n >= 0)
680
+ prop = n;
681
+ }
706
682
  target[prop] = newData;
707
683
  emit(target, prop, newData, oldData);
708
684
  }
709
685
  if (target.length !== oldLength) {
710
686
  emit(target, "length", target.length, oldLength);
711
687
  }
712
- runImmediateQueue();
713
688
  }
714
689
  return true;
715
690
  }
@@ -717,47 +692,100 @@ var arrayHandler = {
717
692
  get(target, prop) {
718
693
  if (prop === TARGET_SYMBOL)
719
694
  return target;
720
- let subProp = prop;
721
- if (typeof prop !== "symbol") {
722
- const intProp = Number.parseInt(prop);
723
- if (intProp.toString() === prop)
724
- subProp = intProp;
695
+ if (typeof prop === "string") {
696
+ const n = 0 | prop;
697
+ if (String(n) === prop && n >= 0)
698
+ prop = n;
725
699
  }
726
- subscribe(target, subProp);
700
+ subscribe(target, prop);
727
701
  return optProxy(target[prop]);
728
702
  },
729
703
  set: arraySet,
730
704
  deleteProperty(target, prop) {
731
- return arraySet(target, prop, undefined);
705
+ if (typeof prop === "string") {
706
+ const n = 0 | prop;
707
+ if (String(n) === prop && n >= 0)
708
+ prop = n;
709
+ }
710
+ let oldData = target[prop];
711
+ if (oldData === undefined && !target.hasOwnProperty(prop))
712
+ oldData = EMPTY;
713
+ delete target[prop];
714
+ emit(target, prop, EMPTY, oldData);
715
+ return true;
732
716
  }
733
717
  };
718
+ function wrapIteratorSingle(iterator) {
719
+ return {
720
+ [Symbol.iterator]() {
721
+ return this;
722
+ },
723
+ next() {
724
+ const result = iterator.next();
725
+ if (result.done)
726
+ return result;
727
+ return {
728
+ done: false,
729
+ value: optProxy(result.value)
730
+ };
731
+ }
732
+ };
733
+ }
734
+ function wrapIteratorPair(iterator) {
735
+ return {
736
+ [Symbol.iterator]() {
737
+ return this;
738
+ },
739
+ next() {
740
+ const result = iterator.next();
741
+ if (result.done)
742
+ return result;
743
+ return {
744
+ done: false,
745
+ value: [optProxy(result.value[0]), optProxy(result.value[1])]
746
+ };
747
+ }
748
+ };
749
+ }
734
750
  var mapMethodHandlers = {
735
751
  get(key) {
736
752
  const target = this[TARGET_SYMBOL];
753
+ if (typeof key === "object" && key)
754
+ key = key[TARGET_SYMBOL] || key;
737
755
  subscribe(target, key);
738
756
  return optProxy(target.get(key));
739
757
  },
740
758
  set(key, newData) {
741
759
  const target = this[TARGET_SYMBOL];
742
- if (typeof newData === "object" && newData)
760
+ if (typeof key === "object" && key) {
761
+ key = key[TARGET_SYMBOL] || key;
762
+ }
763
+ if (typeof newData === "object" && newData) {
743
764
  newData = newData[TARGET_SYMBOL] || newData;
744
- const oldData = target.get(key);
765
+ }
766
+ let oldData = target.get(key);
767
+ if (oldData === undefined && !target.has(key))
768
+ oldData = EMPTY;
745
769
  if (newData !== oldData) {
770
+ const oldSize = target.size;
746
771
  target.set(key, newData);
747
772
  emit(target, key, newData, oldData);
748
- emit(target, MAP_SIZE_SYMBOL, target.size, target.size - (oldData === undefined ? 1 : 0));
749
- runImmediateQueue();
773
+ emit(target, MAP_SIZE_SYMBOL, target.size, oldSize);
750
774
  }
751
775
  return this;
752
776
  },
753
777
  delete(key) {
754
778
  const target = this[TARGET_SYMBOL];
755
- const oldData = target.get(key);
779
+ if (typeof key === "object" && key) {
780
+ key = key[TARGET_SYMBOL] || key;
781
+ }
782
+ let oldData = target.get(key);
783
+ if (oldData === undefined && !target.has(key))
784
+ oldData = EMPTY;
756
785
  const result = target.delete(key);
757
786
  if (result) {
758
- emit(target, key, undefined, oldData);
787
+ emit(target, key, EMPTY, oldData);
759
788
  emit(target, MAP_SIZE_SYMBOL, target.size, target.size + 1);
760
- runImmediateQueue();
761
789
  }
762
790
  return result;
763
791
  },
@@ -765,52 +793,52 @@ var mapMethodHandlers = {
765
793
  const target = this[TARGET_SYMBOL];
766
794
  const oldSize = target.size;
767
795
  for (const key of target.keys()) {
768
- const oldData = target.get(key);
769
- emit(target, key, undefined, oldData);
796
+ emit(target, key, undefined, target.get(key));
770
797
  }
771
798
  target.clear();
772
799
  emit(target, MAP_SIZE_SYMBOL, 0, oldSize);
773
- runImmediateQueue();
774
800
  },
775
801
  has(key) {
776
802
  const target = this[TARGET_SYMBOL];
803
+ if (typeof key === "object" && key) {
804
+ key = key[TARGET_SYMBOL] || key;
805
+ }
777
806
  subscribe(target, key);
778
807
  return target.has(key);
779
808
  },
780
809
  keys() {
781
810
  const target = this[TARGET_SYMBOL];
782
811
  subscribe(target, ANY_SYMBOL);
783
- return target.keys();
812
+ return wrapIteratorSingle(target.keys());
784
813
  },
785
814
  values() {
786
815
  const target = this[TARGET_SYMBOL];
787
816
  subscribe(target, ANY_SYMBOL);
788
- return target.values();
817
+ return wrapIteratorSingle(target.values());
789
818
  },
790
819
  entries() {
791
820
  const target = this[TARGET_SYMBOL];
792
821
  subscribe(target, ANY_SYMBOL);
793
- return target.entries();
822
+ return wrapIteratorPair(target.entries());
794
823
  },
795
824
  [Symbol.iterator]() {
796
825
  const target = this[TARGET_SYMBOL];
797
826
  subscribe(target, ANY_SYMBOL);
798
- return target[Symbol.iterator]();
827
+ return wrapIteratorPair(target[Symbol.iterator]());
799
828
  }
800
829
  };
801
830
  var mapHandler = {
802
831
  get(target, prop) {
803
832
  if (prop === TARGET_SYMBOL)
804
833
  return target;
805
- if (prop in mapMethodHandlers) {
834
+ if (mapMethodHandlers.hasOwnProperty(prop)) {
806
835
  return mapMethodHandlers[prop];
807
836
  }
808
837
  if (prop === "size") {
809
838
  subscribe(target, MAP_SIZE_SYMBOL);
810
839
  return target.size;
811
840
  }
812
- subscribe(target, prop);
813
- return optProxy(target[prop]);
841
+ return target[prop];
814
842
  }
815
843
  };
816
844
  var proxyMap = new WeakMap;
@@ -845,31 +873,31 @@ function destroyWithClass(element, cls) {
845
873
  element.classList.add(...classes);
846
874
  setTimeout(() => element.remove(), 2000);
847
875
  }
848
- function copy(dst, src, flags = 0) {
849
- copyRecurse(dst, src, flags);
850
- runImmediateQueue();
876
+ function copy(a, b, c) {
877
+ if (arguments.length > 2)
878
+ return copySet(a, b, c, 0);
879
+ return copyRecursive(a, b, 0);
851
880
  }
852
- var MERGE = 1;
853
- var SHALLOW = 2;
854
- var COPY_SUBSCRIBE = 32;
855
- var COPY_EMIT = 64;
856
- function clone(src, flags = 0) {
857
- let dst;
858
- if (src instanceof Map) {
859
- dst = new Map;
860
- } else {
861
- dst = Object.create(Object.getPrototypeOf(src));
862
- }
863
- copyRecurse(dst, src, flags);
864
- return dst;
865
- }
866
- function getEntries(subject) {
867
- return subject instanceof Map ? subject.entries() : Object.entries(subject);
881
+ function copySet(dst, dstKey, src, flags) {
882
+ let dstVal = peek(dst, dstKey);
883
+ if (src === dstVal)
884
+ return false;
885
+ if (typeof dstVal === "object" && dstVal && typeof src === "object" && src && dstVal.constructor === src.constructor) {
886
+ return copyRecursive(dstVal, src, flags);
887
+ }
888
+ src = clone(src);
889
+ if (dst instanceof Map)
890
+ dst.set(dstKey, src);
891
+ else
892
+ dst[dstKey] = clone(src);
893
+ return true;
868
894
  }
869
- function getKeys(subject) {
870
- return subject instanceof Map ? subject.keys() : Object.keys(subject);
895
+ function merge(a, b, c) {
896
+ if (arguments.length > 2)
897
+ return copySet(a, b, c, MERGE);
898
+ return copyRecursive(a, b, MERGE);
871
899
  }
872
- function copyRecurse(dst, src, flags) {
900
+ function copyRecursive(dst, src, flags) {
873
901
  let unproxied = dst[TARGET_SYMBOL];
874
902
  if (unproxied) {
875
903
  dst = unproxied;
@@ -883,87 +911,122 @@ function copyRecurse(dst, src, flags) {
883
911
  }
884
912
  if (flags & COPY_SUBSCRIBE)
885
913
  subscribe(src, ANY_SYMBOL);
886
- if (src instanceof Array) {
887
- if (!(dst instanceof Array))
888
- throw new Error("Cannot copy array into object");
914
+ let changed = false;
915
+ if (src instanceof Array && dst instanceof Array) {
889
916
  const dstLen = dst.length;
890
917
  const srcLen = src.length;
891
- for (let i = 0;i < srcLen; i++) {
892
- copyValue(dst, i, src[i], flags);
918
+ for (let index = 0;index < srcLen; index++) {
919
+ let dstValue = dst[index];
920
+ if (dstValue === undefined && !dst.hasOwnProperty(index))
921
+ dstValue = EMPTY;
922
+ let srcValue = src[index];
923
+ if (srcValue === undefined && !src.hasOwnProperty(index)) {
924
+ delete dst[index];
925
+ if (flags & COPY_EMIT)
926
+ emit(dst, index, EMPTY, dstValue);
927
+ changed = true;
928
+ } else if (dstValue !== srcValue) {
929
+ if (srcValue && typeof srcValue === "object") {
930
+ if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor) {
931
+ changed = copyRecursive(dstValue, srcValue, flags) || changed;
932
+ continue;
933
+ }
934
+ srcValue = clone(srcValue);
935
+ }
936
+ dst[index] = srcValue;
937
+ if (flags & COPY_EMIT)
938
+ emit(dst, index, srcValue, dstValue);
939
+ changed = true;
940
+ }
893
941
  }
894
942
  if (srcLen !== dstLen) {
895
943
  if (flags & COPY_EMIT) {
896
944
  for (let i = srcLen;i < dstLen; i++) {
897
945
  const old = dst[i];
898
- dst[i] = undefined;
899
- emit(dst, i, undefined, old);
946
+ delete dst[i];
947
+ emit(dst, i, EMPTY, old);
900
948
  }
901
949
  dst.length = srcLen;
902
950
  emit(dst, "length", srcLen, dstLen);
903
951
  } else {
904
952
  dst.length = srcLen;
905
953
  }
954
+ changed = true;
906
955
  }
907
- } else {
908
- for (const [key, value] of getEntries(src)) {
909
- copyValue(dst, key, value, flags);
956
+ } else if (src instanceof Map && dst instanceof Map) {
957
+ for (const key of src.keys()) {
958
+ let srcValue = src.get(key);
959
+ let dstValue = dst.get(key);
960
+ if (dstValue === undefined && !dst.has(key))
961
+ dstValue = EMPTY;
962
+ if (dstValue !== srcValue) {
963
+ if (srcValue && typeof srcValue === "object") {
964
+ if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor) {
965
+ changed = copyRecursive(dstValue, srcValue, flags) || changed;
966
+ continue;
967
+ }
968
+ srcValue = clone(srcValue);
969
+ }
970
+ dst.set(key, srcValue);
971
+ if (flags & COPY_EMIT)
972
+ emit(dst, key, srcValue, dstValue);
973
+ changed = true;
974
+ }
910
975
  }
911
976
  if (!(flags & MERGE)) {
912
- if (src instanceof Map) {
913
- for (const key of getKeys(dst)) {
914
- if (!src.has(key)) {
915
- deleteKey(dst, key, flags);
977
+ for (const k of dst.keys()) {
978
+ if (!src.has(k)) {
979
+ const old = dst.get(k);
980
+ dst.delete(k);
981
+ if (flags & COPY_EMIT) {
982
+ emit(dst, k, undefined, old);
916
983
  }
984
+ changed = true;
917
985
  }
918
- } else {
919
- for (const key of getKeys(dst)) {
920
- if (!(key in src)) {
921
- deleteKey(dst, key, flags);
986
+ }
987
+ }
988
+ } else if (src.constructor === dst.constructor) {
989
+ for (const key of Object.keys(src)) {
990
+ let srcValue = src[key];
991
+ const dstValue = dst.hasOwnProperty(key) ? dst[key] : EMPTY;
992
+ if (dstValue !== srcValue) {
993
+ if (srcValue && typeof srcValue === "object") {
994
+ if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor) {
995
+ changed = copyRecursive(dstValue, srcValue, flags) || changed;
996
+ continue;
922
997
  }
998
+ srcValue = clone(srcValue);
999
+ }
1000
+ dst[key] = srcValue;
1001
+ if (flags & COPY_EMIT)
1002
+ emit(dst, key, srcValue, dstValue);
1003
+ changed = true;
1004
+ }
1005
+ }
1006
+ if (!(flags & MERGE)) {
1007
+ for (const k of Object.keys(dst)) {
1008
+ if (!src.hasOwnProperty(k)) {
1009
+ const old = dst[k];
1010
+ delete dst[k];
1011
+ if (flags & COPY_EMIT && old !== undefined) {
1012
+ emit(dst, k, undefined, old);
1013
+ }
1014
+ changed = true;
923
1015
  }
924
1016
  }
925
1017
  }
926
- }
927
- }
928
- function deleteKey(dst, key, flags) {
929
- let old;
930
- if (dst instanceof Map) {
931
- old = dst.get(key);
932
- dst.delete(key);
933
1018
  } else {
934
- old = dst[key];
935
- delete dst[key];
936
- }
937
- if (flags & COPY_EMIT && old !== undefined) {
938
- emit(dst, key, undefined, old);
1019
+ throw new Error(`Incompatible or non-object types: ${src?.constructor?.name || typeof src} vs ${dst?.constructor?.name || typeof dst}`);
939
1020
  }
1021
+ return changed;
940
1022
  }
941
- function copyValue(dst, index, srcValue, flags) {
942
- const dstValue = dst instanceof Map ? dst.get(index) : dst[index];
943
- if (srcValue !== dstValue) {
944
- if (srcValue && dstValue && typeof srcValue === "object" && typeof dstValue === "object" && (srcValue.constructor === dstValue.constructor || flags & MERGE && dstValue instanceof Array)) {
945
- copyRecurse(dstValue, srcValue, flags);
946
- return;
947
- }
948
- if (!(flags & SHALLOW) && srcValue && typeof srcValue === "object") {
949
- const copy2 = Object.create(Object.getPrototypeOf(srcValue));
950
- copyRecurse(copy2, srcValue, 0);
951
- srcValue = copy2;
952
- }
953
- if (dst instanceof Map) {
954
- if (flags & MERGE && srcValue == null)
955
- dst.delete(index);
956
- else
957
- dst.set(index, srcValue);
958
- } else {
959
- if (flags & MERGE && srcValue == null)
960
- delete dst[index];
961
- else
962
- dst[index] = srcValue;
963
- }
964
- if (flags & COPY_EMIT)
965
- emit(dst, index, srcValue, dstValue);
966
- }
1023
+ var MERGE = 1;
1024
+ var COPY_SUBSCRIBE = 32;
1025
+ var COPY_EMIT = 64;
1026
+ function clone(src) {
1027
+ const copied = Array.isArray(src) ? [] : src instanceof Map ? new Map : Object.create(Object.getPrototypeOf(src));
1028
+ copyRecursive(copied, src, MERGE);
1029
+ return copied;
967
1030
  }
968
1031
  var refHandler = {
969
1032
  get(target, prop) {
@@ -1021,7 +1084,7 @@ function applyBind(el, target) {
1021
1084
  throw new Error(`SELECT has no '${target.value}' OPTION (yet)`);
1022
1085
  };
1023
1086
  }
1024
- observe(onProxyChange);
1087
+ derive(onProxyChange);
1025
1088
  el.addEventListener("input", onInputChange);
1026
1089
  clean(() => {
1027
1090
  el.removeEventListener("input", onInputChange);
@@ -1055,11 +1118,6 @@ var SPECIAL_PROPS = {
1055
1118
  },
1056
1119
  text: (value) => {
1057
1120
  addNode(document.createTextNode(value));
1058
- },
1059
- element: (value) => {
1060
- console.log("Aberdeen: $({element: myElement}) is deprecated, use $(myElement) instead");
1061
- addNode(value);
1062
- SPECIAL_PROPS.element = addNode;
1063
1121
  }
1064
1122
  };
1065
1123
  function $(...args) {
@@ -1134,7 +1192,7 @@ function $(...args) {
1134
1192
  break;
1135
1193
  }
1136
1194
  } else {
1137
- for (const key in arg) {
1195
+ for (const key of Object.keys(arg)) {
1138
1196
  const val = arg[key];
1139
1197
  applyArg(key, val);
1140
1198
  }
@@ -1164,7 +1222,7 @@ function insertCss(style, global = false) {
1164
1222
  function styleToCss(style, prefix) {
1165
1223
  let props = "";
1166
1224
  let rules = "";
1167
- for (const kOr in style) {
1225
+ for (const kOr of Object.keys(style)) {
1168
1226
  const v = style[kOr];
1169
1227
  for (const k of kOr.split(/, ?/g)) {
1170
1228
  if (v && typeof v === "object") {
@@ -1230,12 +1288,9 @@ function getParentElement() {
1230
1288
  function clean(cleaner) {
1231
1289
  currentScope.cleaners.push(cleaner);
1232
1290
  }
1233
- function observe(func) {
1291
+ function derive(func) {
1234
1292
  return new ResultScope(currentScope.parentElement, func).result;
1235
1293
  }
1236
- function immediateObserve(func) {
1237
- new ImmediateScope(currentScope.parentElement, func);
1238
- }
1239
1294
  function mount(parentElement, func) {
1240
1295
  new MountScope(parentElement, func);
1241
1296
  }
@@ -1243,10 +1298,14 @@ function unmountAll() {
1243
1298
  ROOT_SCOPE.remove();
1244
1299
  cssCount = 0;
1245
1300
  }
1246
- function peek(func) {
1301
+ function peek(target, key) {
1247
1302
  peeking++;
1248
1303
  try {
1249
- return func();
1304
+ if (arguments.length === 1) {
1305
+ return target();
1306
+ } else {
1307
+ return target instanceof Map ? target.get(key) : target[key];
1308
+ }
1250
1309
  } finally {
1251
1310
  peeking--;
1252
1311
  }
@@ -1283,10 +1342,10 @@ function multiMap(source, func) {
1283
1342
  onEach(source, (item, key) => {
1284
1343
  const pairs = func(item, key);
1285
1344
  if (pairs) {
1286
- for (const key2 in pairs)
1345
+ for (const key2 of Object.keys(pairs))
1287
1346
  out[key2] = pairs[key2];
1288
1347
  clean(() => {
1289
- for (const key2 in pairs)
1348
+ for (const key2 of Object.keys(pairs))
1290
1349
  delete out[key2];
1291
1350
  });
1292
1351
  }
@@ -1377,25 +1436,24 @@ export {
1377
1436
  peek,
1378
1437
  partition,
1379
1438
  onEach,
1380
- observe,
1381
1439
  multiMap,
1382
1440
  mount,
1441
+ merge,
1383
1442
  map,
1443
+ leakScope,
1384
1444
  isEmpty,
1385
1445
  invertString,
1386
1446
  insertCss,
1387
- immediateObserve,
1388
1447
  getParentElement,
1389
1448
  dump,
1449
+ derive,
1390
1450
  defaultEmitHandler,
1391
1451
  count,
1392
1452
  copy,
1393
1453
  clone,
1394
1454
  clean,
1395
- SHALLOW,
1396
- MERGE,
1397
1455
  $
1398
1456
  };
1399
1457
 
1400
- //# debugId=273356BBA2542BE564756E2164756E21
1458
+ //# debugId=37C620855881B81F64756E2164756E21
1401
1459
  //# sourceMappingURL=aberdeen.js.map