atom.io 0.9.7 → 0.9.9

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.
@@ -551,7 +551,7 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
551
551
  );
552
552
  }
553
553
  atom.subject.subscribe(`timeline`, (update) => {
554
- var _a, _b, _c, _d, _e;
554
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
555
555
  const currentSelectorKey = store.operation.open && store.operation.token.type === `selector` ? store.operation.token.key : null;
556
556
  const currentSelectorTime = store.operation.open && store.operation.token.type === `selector` ? store.operation.time : null;
557
557
  const currentTransactionKey = store.transactionStatus.phase === `applying` ? store.transactionStatus.key : null;
@@ -592,7 +592,7 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
592
592
  const unsubscribe = currentTransaction.subject.subscribe(
593
593
  `timeline:${tl.key}`,
594
594
  (update2) => {
595
- var _a2;
595
+ var _a2, _b2, _c2;
596
596
  unsubscribe();
597
597
  if (tl.timeTraveling === null && currentTransactionTime) {
598
598
  if (tl.at !== tl.history.length) {
@@ -616,12 +616,15 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
616
616
  }, update2), {
617
617
  atomUpdates
618
618
  });
619
- tl.history.push(timelineTransactionUpdate);
620
- tl.at = tl.history.length;
621
- tl.subject.next(timelineTransactionUpdate);
619
+ const willCapture = (_b2 = (_a2 = tl.shouldCapture) == null ? void 0 : _a2.call(tl, timelineTransactionUpdate, tl)) != null ? _b2 : true;
620
+ if (willCapture) {
621
+ tl.history.push(timelineTransactionUpdate);
622
+ tl.at = tl.history.length;
623
+ tl.subject.next(timelineTransactionUpdate);
624
+ }
622
625
  }
623
626
  tl.transactionKey = null;
624
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(
627
+ (_c2 = store.config.logger) == null ? void 0 : _c2.info(
625
628
  `\u231B timeline "${tl.key}" got a transaction_update "${update2.key}"`
626
629
  );
627
630
  }
@@ -662,8 +665,15 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
662
665
  );
663
666
  }
664
667
  }
665
- if (latestUpdate)
666
- tl.subject.next(latestUpdate);
668
+ if (latestUpdate) {
669
+ const willCaptureSelectorUpdate = (_f = (_e = tl.shouldCapture) == null ? void 0 : _e.call(tl, latestUpdate, tl)) != null ? _f : true;
670
+ if (willCaptureSelectorUpdate) {
671
+ tl.subject.next(latestUpdate);
672
+ } else {
673
+ tl.history.pop();
674
+ tl.at = tl.history.length;
675
+ }
676
+ }
667
677
  } else {
668
678
  const timestamp = Date.now();
669
679
  tl.selectorTime = null;
@@ -680,12 +690,15 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
680
690
  if (atom.family) {
681
691
  atomUpdate.family = atom.family;
682
692
  }
683
- tl.history.push(atomUpdate);
684
- tl.subject.next(atomUpdate);
685
- (_e = store.config.logger) == null ? void 0 : _e.info(
693
+ const willCapture = (_h = (_g = tl.shouldCapture) == null ? void 0 : _g.call(tl, atomUpdate, tl)) != null ? _h : true;
694
+ (_i = store.config.logger) == null ? void 0 : _i.info(
686
695
  `\u231B timeline "${tl.key}" got an atom_update to "${atom.key}"`
687
696
  );
688
- tl.at = tl.history.length;
697
+ if (willCapture) {
698
+ tl.history.push(atomUpdate);
699
+ tl.at = tl.history.length;
700
+ tl.subject.next(atomUpdate);
701
+ }
689
702
  }
690
703
  }
691
704
  });
@@ -786,6 +799,9 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
786
799
  install: (store2) => timeline__INTERNAL(options, store2, tl),
787
800
  subject: new Subject()
788
801
  });
802
+ if (options.shouldCapture) {
803
+ tl.shouldCapture = options.shouldCapture;
804
+ }
789
805
  const core = target(store);
790
806
  for (const tokenOrFamily of options.atoms) {
791
807
  const timelineKey = core.timelineAtoms.getRelatedKey(tokenOrFamily.key);
@@ -798,9 +814,7 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
798
814
  if (tokenOrFamily.type === `atom_family`) {
799
815
  const family = tokenOrFamily;
800
816
  family.subject.subscribe(`timeline:${options.key}`, (token2) => {
801
- if (!core.atoms.has(token2.key)) {
802
- addAtomToTimeline(token2, tl, store);
803
- }
817
+ addAtomToTimeline(token2, tl, store);
804
818
  });
805
819
  for (const atom of core.atoms.values()) {
806
820
  if (((_c = atom.family) == null ? void 0 : _c.key) === family.key) {
@@ -1366,6 +1380,7 @@ var setState__INTERNAL = (state, value, store = IMPLICIT.STORE) => {
1366
1380
 
1367
1381
  // src/selector/trace-selector-atoms.ts
1368
1382
  var traceSelectorAtoms = (selectorKey, dependency, store) => {
1383
+ var _a;
1369
1384
  const roots = [];
1370
1385
  const sources = lookupSelectorSources(dependency.key, store);
1371
1386
  let depth = 0;
@@ -1373,6 +1388,11 @@ var traceSelectorAtoms = (selectorKey, dependency, store) => {
1373
1388
  const source = sources.shift();
1374
1389
  ++depth;
1375
1390
  if (depth > 999) {
1391
+ (_a = store.config.logger) == null ? void 0 : _a.warn(
1392
+ `Maximum selector dependency depth exceeded 999 in selector "${selectorKey}".`
1393
+ );
1394
+ }
1395
+ if (depth > 99999) {
1376
1396
  throw new Error(
1377
1397
  `Maximum selector dependency depth exceeded in selector "${selectorKey}".`
1378
1398
  );