flightdeck 0.2.19 → 0.2.20

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.
@@ -486,19 +486,30 @@ var readOrComputeValue = (target, state) => {
486
486
  target.logger.info(`\u{1F4D6}`, state.type, state.key, `reading cached value`);
487
487
  return readCachedValue(state, target);
488
488
  }
489
- if (state.type === `selector` || state.type === `readonly_selector`) {
490
- target.logger.info(`\u{1F9EE}`, state.type, state.key, `computing value`);
491
- return state.get();
489
+ switch (state.type) {
490
+ case `selector`:
491
+ case `readonly_selector`:
492
+ target.logger.info(`\u{1F9EE}`, state.type, state.key, `computing value`);
493
+ return state.get();
494
+ case `atom`:
495
+ case `mutable_atom`: {
496
+ const def = state.default;
497
+ let fallback;
498
+ if (def instanceof Function) {
499
+ fallback = def();
500
+ } else {
501
+ fallback = def;
502
+ }
503
+ target.logger.info(
504
+ `\u{1F481}`,
505
+ `atom`,
506
+ state.key,
507
+ `could not find cached value; using default`,
508
+ fallback
509
+ );
510
+ return fallback;
511
+ }
492
512
  }
493
- const fallback = state.default instanceof Function ? state.default() : state.default;
494
- target.logger.info(
495
- `\u{1F481}`,
496
- `atom`,
497
- state.key,
498
- `could not find cached value; using default`,
499
- fallback
500
- );
501
- return state.default instanceof Function ? state.default() : state.default;
502
513
  };
503
514
 
504
515
  // ../atom.io/internal/src/operation.ts
@@ -626,55 +637,8 @@ var evictDownStream = (store, atom2) => {
626
637
  }
627
638
  };
628
639
 
629
- // ../atom.io/internal/src/set-state/stow-update.ts
630
- function shouldUpdateBeStowed(key, update) {
631
- if (isTransceiver(update.newValue)) {
632
- return false;
633
- }
634
- if (key.includes(`\u{1F50D}`)) {
635
- return false;
636
- }
637
- return true;
638
- }
639
- var stowUpdate = (store, state, update) => {
640
- const { key } = state;
641
- const target = newest(store);
642
- if (!isChildStore(target) || target.transactionMeta.phase !== `building`) {
643
- store.logger.error(
644
- `\u{1F41E}`,
645
- `atom`,
646
- key,
647
- `stowUpdate called outside of a transaction. This is probably a bug.`
648
- );
649
- return;
650
- }
651
- const shouldStow = shouldUpdateBeStowed(key, update);
652
- if (!shouldStow) {
653
- return;
654
- }
655
- const atomUpdate = {
656
- type: `atom_update`,
657
- key,
658
- ...update
659
- };
660
- if (state.family) {
661
- atomUpdate.family = state.family;
662
- }
663
- target.transactionMeta.update.updates.push(atomUpdate);
664
- store.logger.info(
665
- `\u{1F4C1}`,
666
- `atom`,
667
- key,
668
- `stowed (`,
669
- update.oldValue,
670
- `->`,
671
- update.newValue,
672
- `)`
673
- );
674
- };
675
-
676
640
  // ../atom.io/internal/src/set-state/set-atom.ts
677
- var setAtom = (atom2, next, target) => {
641
+ var setAtom = (target, atom2, next) => {
678
642
  const oldValue = readOrComputeValue(target, atom2);
679
643
  let newValue = oldValue;
680
644
  if (atom2.type === `mutable_atom` && isChildStore(target)) {
@@ -691,23 +655,45 @@ var setAtom = (atom2, next, target) => {
691
655
  markDone(target, atom2.key);
692
656
  evictDownStream(target, atom2);
693
657
  const update = { oldValue, newValue };
694
- if (isRootStore(target)) {
658
+ if (!isChildStore(target)) {
695
659
  emitUpdate(target, atom2, update);
696
- } else if (target.parent) {
697
- if (target.on.transactionApplying.state === null) {
698
- stowUpdate(target, atom2, update);
699
- } else if (atom2.key.startsWith(`*`)) {
700
- const mutableKey = atom2.key.slice(1);
701
- const mutableAtom = target.atoms.get(mutableKey);
702
- let transceiver = target.valueMap.get(mutableKey);
703
- if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
704
- const { parent } = target;
705
- const copiedValue = copyMutableIfNeeded(target, mutableAtom, parent);
706
- transceiver = copiedValue;
707
- }
708
- const accepted = transceiver.do(update.newValue) === null;
709
- if (accepted) evictDownStream(target, mutableAtom);
660
+ return;
661
+ }
662
+ if (target.on.transactionApplying.state === null) {
663
+ const { key } = atom2;
664
+ if (isTransceiver(update.newValue)) {
665
+ return;
666
+ }
667
+ const atomUpdate = {
668
+ type: `atom_update`,
669
+ key,
670
+ ...update
671
+ };
672
+ if (atom2.family) {
673
+ atomUpdate.family = atom2.family;
710
674
  }
675
+ target.transactionMeta.update.updates.push(atomUpdate);
676
+ target.logger.info(
677
+ `\u{1F4C1}`,
678
+ `atom`,
679
+ key,
680
+ `stowed (`,
681
+ update.oldValue,
682
+ `->`,
683
+ update.newValue,
684
+ `)`
685
+ );
686
+ } else if (atom2.key.startsWith(`*`)) {
687
+ const mutableKey = atom2.key.slice(1);
688
+ const mutableAtom = target.atoms.get(mutableKey);
689
+ let transceiver = target.valueMap.get(mutableKey);
690
+ if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
691
+ const { parent } = target;
692
+ const copiedValue = copyMutableIfNeeded(target, mutableAtom, parent);
693
+ transceiver = copiedValue;
694
+ }
695
+ const accepted = transceiver.do(update.newValue) === null;
696
+ if (accepted) evictDownStream(target, mutableAtom);
711
697
  }
712
698
  };
713
699
 
@@ -716,7 +702,7 @@ var setAtomOrSelector = (store, state, value) => {
716
702
  switch (state.type) {
717
703
  case `atom`:
718
704
  case `mutable_atom`:
719
- setAtom(state, value, store);
705
+ setAtom(store, state, value);
720
706
  break;
721
707
  case `selector`:
722
708
  state.set(value);
@@ -1160,13 +1146,34 @@ function ingestTransactionUpdate(applying, transactionUpdate, store) {
1160
1146
  }
1161
1147
  }
1162
1148
 
1149
+ // ../atom.io/internal/src/transaction/get-epoch-number.ts
1150
+ function getContinuityKey(store, transactionKey) {
1151
+ const continuity = store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
1152
+ return continuity;
1153
+ }
1154
+ function getEpochNumberOfContinuity(store, continuityKey) {
1155
+ const epoch = store.transactionMeta.epoch.get(continuityKey);
1156
+ return epoch;
1157
+ }
1158
+ function getEpochNumberOfAction(store, transactionKey) {
1159
+ const isRoot = isRootStore(store);
1160
+ if (!isRoot) {
1161
+ return void 0;
1162
+ }
1163
+ const continuityKey = getContinuityKey(store, transactionKey);
1164
+ if (continuityKey === void 0) {
1165
+ return void 0;
1166
+ }
1167
+ return getEpochNumberOfContinuity(store, continuityKey);
1168
+ }
1169
+
1163
1170
  // ../atom.io/internal/src/transaction/set-epoch-number.ts
1164
1171
  function setEpochNumberOfAction(store, transactionKey, newEpoch) {
1165
1172
  const isRoot = isRootStore(store);
1166
1173
  if (!isRoot) {
1167
1174
  return;
1168
1175
  }
1169
- const continuityKey = store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
1176
+ const continuityKey = getContinuityKey(store, transactionKey);
1170
1177
  if (continuityKey !== void 0) {
1171
1178
  store.transactionMeta.epoch.set(continuityKey, newEpoch);
1172
1179
  }
@@ -1729,14 +1736,6 @@ function createTransaction(store, options) {
1729
1736
  return token;
1730
1737
  }
1731
1738
 
1732
- // ../atom.io/internal/src/transaction/get-epoch-number.ts
1733
- function getEpochNumberOfAction(store, transactionKey) {
1734
- const isRoot = isRootStore(store);
1735
- const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : void 0;
1736
- const epoch = isRoot && continuity !== void 0 ? store.transactionMeta.epoch.get(continuity) : void 0;
1737
- return epoch;
1738
- }
1739
-
1740
1739
  // ../atom.io/src/transaction.ts
1741
1740
  function transaction(options) {
1742
1741
  return createTransaction(IMPLICIT.STORE, options);
@@ -1831,7 +1830,7 @@ var Store = class {
1831
1830
  lifespan: `ephemeral`
1832
1831
  };
1833
1832
  loggers = [
1834
- new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F50D}`))
1833
+ new AtomIOLogger(`warn`, (_, __, key) => !isReservedIntrospectionKey(key))
1835
1834
  ];
1836
1835
  logger = {
1837
1836
  error: (...messages) => {
@@ -2899,18 +2898,18 @@ function isTransceiver(value) {
2899
2898
  function copyMutableIfNeeded(target, atom2, origin) {
2900
2899
  const originValue = origin.valueMap.get(atom2.key);
2901
2900
  const targetValue = target.valueMap.get(atom2.key);
2902
- if (originValue === targetValue) {
2903
- if (originValue === void 0) {
2904
- return typeof atom2.default === `function` ? atom2.default() : atom2.default;
2905
- }
2906
- origin.logger.info(`\u{1F4C3}`, `atom`, atom2.key, `copying`);
2907
- const jsonValue = atom2.toJson(originValue);
2908
- const copiedValue = atom2.fromJson(jsonValue);
2909
- target.valueMap.set(atom2.key, copiedValue);
2910
- new Tracker(atom2, origin);
2911
- return copiedValue;
2912
- }
2913
- return targetValue;
2901
+ if (originValue !== targetValue) {
2902
+ return targetValue;
2903
+ }
2904
+ if (originValue === void 0) {
2905
+ return atom2.default();
2906
+ }
2907
+ origin.logger.info(`\u{1F4C3}`, `atom`, atom2.key, `copying`);
2908
+ const jsonValue = atom2.toJson(originValue);
2909
+ const copiedValue = atom2.fromJson(jsonValue);
2910
+ target.valueMap.set(atom2.key, copiedValue);
2911
+ new Tracker(atom2, origin);
2912
+ return copiedValue;
2914
2913
  }
2915
2914
 
2916
2915
  // ../atom.io/internal/src/caching.ts
@@ -3731,6 +3730,11 @@ function getInternalRelationsFromStore(token, store) {
3731
3730
  return family;
3732
3731
  }
3733
3732
 
3733
+ // ../atom.io/internal/src/reserved-keys.ts
3734
+ function isReservedIntrospectionKey(value) {
3735
+ return value.startsWith(`\u{1F50D} `);
3736
+ }
3737
+
3734
3738
  // ../atom.io/introspection/src/refinery.ts
3735
3739
  var Refinery = class {
3736
3740
  supported;
@@ -4774,5 +4778,5 @@ var FlightDeckLogger = class {
4774
4778
  };
4775
4779
 
4776
4780
  export { FLIGHTDECK_ERROR, FLIGHTDECK_INFO, FLIGHTDECK_LNAV_FORMAT, FLIGHTDECK_SETUP_PHASES, FLIGHTDECK_UPDATE_PHASES, FLIGHTDECK_WARN, FlightDeck, FlightDeckLogger, flightDeckLogSchema, isVersionNumber };
4777
- //# sourceMappingURL=chunk-D4EVARJP.js.map
4778
- //# sourceMappingURL=chunk-D4EVARJP.js.map
4781
+ //# sourceMappingURL=chunk-JHE6N7DO.js.map
4782
+ //# sourceMappingURL=chunk-JHE6N7DO.js.map