atom.io 0.10.2 → 0.10.3

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.
Files changed (49) hide show
  1. package/dist/index.d.mts +53 -8
  2. package/dist/index.d.ts +53 -8
  3. package/dist/index.js +56 -32
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +55 -33
  6. package/dist/index.mjs.map +1 -1
  7. package/internal/dist/index.js +239 -113
  8. package/internal/dist/index.js.map +1 -1
  9. package/internal/dist/index.mjs +239 -113
  10. package/internal/dist/index.mjs.map +1 -1
  11. package/internal/src/atom/create-atom.ts +15 -4
  12. package/internal/src/atom/delete-atom.ts +1 -1
  13. package/internal/src/caching.ts +4 -4
  14. package/internal/src/get-state-internal.ts +3 -5
  15. package/internal/src/mutable/create-mutable-atom.ts +4 -10
  16. package/internal/src/operation.ts +20 -7
  17. package/internal/src/selector/create-read-write-selector.ts +12 -2
  18. package/internal/src/selector/create-readonly-selector.ts +7 -1
  19. package/internal/src/selector/create-selector.ts +4 -5
  20. package/internal/src/selector/register-selector.ts +7 -1
  21. package/internal/src/selector/update-selector-atoms.ts +10 -3
  22. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  23. package/internal/src/set-state/copy-mutable-in-transaction.ts +0 -3
  24. package/internal/src/set-state/emit-update.ts +5 -5
  25. package/internal/src/set-state/evict-downstream.ts +10 -13
  26. package/internal/src/set-state/set-atom.ts +1 -1
  27. package/internal/src/set-state/stow-update.ts +9 -3
  28. package/internal/src/store/store.ts +8 -19
  29. package/internal/src/store/withdraw-new-family-member.ts +4 -1
  30. package/internal/src/store/withdraw.ts +6 -1
  31. package/internal/src/subscribe/recall-state.ts +4 -1
  32. package/internal/src/subscribe/subscribe-to-root-atoms.ts +11 -5
  33. package/internal/src/timeline/add-atom-to-timeline.ts +40 -9
  34. package/internal/src/timeline/time-travel-internal.ts +26 -8
  35. package/internal/src/timeline/timeline-internal.ts +8 -2
  36. package/internal/src/transaction/abort-transaction.ts +7 -2
  37. package/internal/src/transaction/apply-transaction.ts +21 -7
  38. package/internal/src/transaction/build-transaction.ts +5 -1
  39. package/internal/src/transaction/redo-transaction.ts +1 -1
  40. package/internal/src/transaction/transaction-internal.ts +1 -4
  41. package/internal/src/transaction/undo-transaction.ts +7 -1
  42. package/package.json +2 -2
  43. package/realtime-client/dist/index.js +24 -5
  44. package/realtime-client/dist/index.js.map +1 -1
  45. package/realtime-client/dist/index.mjs +24 -5
  46. package/realtime-client/dist/index.mjs.map +1 -1
  47. package/realtime-client/src/use-server-action.ts +24 -5
  48. package/src/logger.ts +82 -14
  49. package/src/subscribe.ts +22 -7
@@ -312,27 +312,20 @@ var Store = class {
312
312
  name: `IMPLICIT_STORE`
313
313
  };
314
314
  this.loggers = [
315
- new AtomIOLogger(
316
- __spreadValues({}, console),
317
- `warn`,
318
- (message) => !message.includes(`\u{1F441}\u200D\u{1F5E8}`)
319
- )
315
+ new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
320
316
  ];
321
317
  this.logger = {
322
318
  error: (...messages) => {
323
- for (const logger of this.loggers) {
319
+ for (const logger of this.loggers)
324
320
  logger.error(...messages);
325
- }
326
321
  },
327
322
  info: (...messages) => {
328
- for (const logger of this.loggers) {
323
+ for (const logger of this.loggers)
329
324
  logger.info(...messages);
330
- }
331
325
  },
332
326
  warn: (...messages) => {
333
- for (const logger of this.loggers) {
327
+ for (const logger of this.loggers)
334
328
  logger.warn(...messages);
335
- }
336
329
  }
337
330
  };
338
331
  if (store !== null) {
@@ -377,20 +370,28 @@ var clearStore = (store = IMPLICIT.STORE) => {
377
370
  var abortTransaction = (store) => {
378
371
  if (store.transactionStatus.phase === `idle`) {
379
372
  store.logger.warn(
380
- `\u{1F41E} abortTransaction called outside of a transaction. This is probably a bug.`
373
+ `\u{1F41E}`,
374
+ `transaction`,
375
+ `???`,
376
+ `abortTransaction called outside of a transaction. This is probably a bug in AtomIO.`
381
377
  );
382
378
  return;
383
379
  }
384
380
  store.logger.info(
385
381
  `\u{1FA82}`,
386
- `Aborting transaction "${store.transactionStatus.key}"`
382
+ `transaction`,
383
+ store.transactionStatus.key,
384
+ `Aborting transaction`
387
385
  );
388
386
  store.transactionStatus = { phase: `idle` };
389
387
  };
390
388
  var applyTransaction = (output, store) => {
391
389
  if (store.transactionStatus.phase !== `building`) {
392
390
  store.logger.warn(
393
- `\u{1F41E} applyTransaction called outside of a transaction. This is probably a bug.`
391
+ `\u{1F41E}`,
392
+ `transaction`,
393
+ `???`,
394
+ `applyTransaction called outside of a transaction. This is probably a bug in AtomIO.`
394
395
  );
395
396
  return;
396
397
  }
@@ -398,10 +399,10 @@ var applyTransaction = (output, store) => {
398
399
  store.transactionStatus.output = output;
399
400
  const { atomUpdates } = store.transactionStatus;
400
401
  store.logger.info(
401
- `\u{1F6C3} applying transaction "${store.transactionStatus.key}" with ${atomUpdates.length} updates.`
402
- );
403
- store.logger.info(
404
- `\u{1F6C3} the updates from "${store.transactionStatus.key}" are:`,
402
+ `\u{1F6C4}`,
403
+ `transaction`,
404
+ store.transactionStatus.key,
405
+ `Applying transaction with ${atomUpdates.length} updates:`,
405
406
  atomUpdates
406
407
  );
407
408
  for (const { key, newValue } of atomUpdates) {
@@ -421,7 +422,12 @@ var applyTransaction = (output, store) => {
421
422
  }
422
423
  store.atoms.set(newAtom.key, newAtom);
423
424
  store.valueMap.set(newAtom.key, newAtom.default);
424
- store.logger.info(`\u{1F527} Add atom "${newAtom.key}"`);
425
+ store.logger.info(
426
+ `\u{1F528}`,
427
+ `transaction`,
428
+ store.transactionStatus.key,
429
+ `Adding atom "${newAtom.key}"`
430
+ );
425
431
  }
426
432
  }
427
433
  setState(token, newValue, store);
@@ -441,8 +447,13 @@ var applyTransaction = (output, store) => {
441
447
  output,
442
448
  params: store.transactionStatus.params
443
449
  });
450
+ store.logger.info(
451
+ `\u{1F6EC}`,
452
+ `transaction`,
453
+ store.transactionStatus.key,
454
+ `Finished applying transaction.`
455
+ );
444
456
  store.transactionStatus = { phase: `idle` };
445
- store.logger.info(`\u{1F6EC} Successfully applied transaction "${myTransaction.key}"`);
446
457
  };
447
458
 
448
459
  // src/transaction/build-transaction.ts
@@ -473,7 +484,11 @@ var buildTransaction = (key, params, store) => {
473
484
  output: void 0
474
485
  };
475
486
  store.logger.info(
476
- `\u{1F6EB} Building transaction "${key}" in store "${store.config.name}"`
487
+ `\u{1F6EB}`,
488
+ `transaction`,
489
+ key,
490
+ `Building transaction with params:`,
491
+ params
477
492
  );
478
493
  };
479
494
 
@@ -496,10 +511,7 @@ function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
496
511
  return output;
497
512
  } catch (thrown) {
498
513
  abortTransaction(store);
499
- store.logger.error(
500
- `\u2757 Transaction "${options.key}" failed in store "${store.config.name}":`,
501
- thrown
502
- );
514
+ store.logger.warn(`\u{1F4A5}`, `transaction`, options.key, `caught:`, thrown);
503
515
  throw thrown;
504
516
  }
505
517
  },
@@ -514,7 +526,7 @@ function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
514
526
  }
515
527
  var target = (store = IMPLICIT.STORE) => store.transactionStatus.phase === `building` ? store.transactionStatus.core : store;
516
528
  var redoTransactionUpdate = (update, store) => {
517
- store.logger.info(` \u23ED Redo transaction "${update.key}"`);
529
+ store.logger.info(`\u23ED\uFE0F`, `transaction`, update.key, `Redo`);
518
530
  for (const { key, newValue } of update.atomUpdates) {
519
531
  const token = { key, type: `atom` };
520
532
  const state = withdraw(token, store);
@@ -527,7 +539,13 @@ var redoTransactionUpdate = (update, store) => {
527
539
  }
528
540
  };
529
541
  var undoTransactionUpdate = (update, store) => {
530
- store.logger.info(` \u23EE Undo transaction "${update.key}"`);
542
+ store.logger.info(
543
+ `\u23EE\uFE0F`,
544
+ `transaction`,
545
+ update.key,
546
+ `Undoing transaction update`,
547
+ update
548
+ );
531
549
  for (const { key, oldValue } of update.atomUpdates) {
532
550
  const token = { key, type: `atom` };
533
551
  const state = withdraw(token, store);
@@ -558,11 +576,16 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
558
576
  const currentTransactionKey = store.transactionStatus.phase === `applying` ? store.transactionStatus.key : null;
559
577
  const currentTransactionTime = store.transactionStatus.phase === `applying` ? store.transactionStatus.time : null;
560
578
  store.logger.info(
561
- `\u23F3 timeline "${tl.key}" saw atom "${atomToken.key}" go (`,
579
+ `\u23F3`,
580
+ `timeline`,
581
+ tl.key,
582
+ `atom`,
583
+ atomToken.key,
584
+ `went`,
562
585
  update.oldValue,
563
586
  `->`,
564
587
  update.newValue,
565
- currentTransactionKey ? `) in transaction "${currentTransactionKey}"` : currentSelectorKey ? `) in selector "${currentSelectorKey}"` : `)`
588
+ currentTransactionKey ? `in transaction "${currentTransactionKey}"` : currentSelectorKey ? `in selector "${currentSelectorKey}"` : ``
566
589
  );
567
590
  if (tl.timeTraveling === null) {
568
591
  if (tl.selectorTime && tl.selectorTime !== currentSelectorTime) {
@@ -586,7 +609,10 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
586
609
  if (tl.transactionKey !== currentTransactionKey) {
587
610
  if (tl.transactionKey) {
588
611
  store.logger.error(
589
- `\u{1F41E} Timeline "${tl.key}" was unable to resolve transaction "${tl.transactionKey}. This is probably a bug.`
612
+ `\u{1F41E}`,
613
+ `timeline`,
614
+ tl.key,
615
+ `unable to resolve transaction "${tl.transactionKey}. This is probably a bug in AtomIO.`
590
616
  );
591
617
  }
592
618
  tl.transactionKey = currentTransactionKey;
@@ -626,7 +652,10 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
626
652
  }
627
653
  tl.transactionKey = null;
628
654
  store.logger.info(
629
- `\u231B timeline "${tl.key}" got a transaction_update "${update2.key}"`
655
+ `\u231B`,
656
+ `timeline`,
657
+ tl.key,
658
+ `got a transaction_update "${update2.key}"`
630
659
  );
631
660
  }
632
661
  );
@@ -649,7 +678,10 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
649
678
  }
650
679
  tl.history.push(latestUpdate);
651
680
  store.logger.info(
652
- `\u231B timeline "${tl.key}" got a selector_update "${currentSelectorKey}" with`,
681
+ `\u231B`,
682
+ `timeline`,
683
+ tl.key,
684
+ `got a selector_update "${currentSelectorKey}" with`,
653
685
  latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
654
686
  );
655
687
  tl.at = tl.history.length;
@@ -661,7 +693,10 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
661
693
  type: `atom_update`
662
694
  }, update));
663
695
  store.logger.info(
664
- `\u231B timeline "${tl.key}" set selector_update "${currentSelectorKey}" to`,
696
+ `\u231B`,
697
+ `timeline`,
698
+ tl.key,
699
+ `set selector_update "${currentSelectorKey}" to`,
665
700
  latestUpdate == null ? void 0 : latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
666
701
  );
667
702
  }
@@ -693,7 +728,10 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
693
728
  }
694
729
  const willCapture = (_d = (_c = tl.shouldCapture) == null ? void 0 : _c.call(tl, atomUpdate, tl)) != null ? _d : true;
695
730
  store.logger.info(
696
- `\u231B timeline "${tl.key}" got an atom_update to "${atom.key}"`
731
+ `\u231B`,
732
+ `timeline`,
733
+ tl.key,
734
+ `got an atom_update to "${atom.key}"`
697
735
  );
698
736
  if (willCapture) {
699
737
  tl.history.push(atomUpdate);
@@ -705,17 +743,23 @@ var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
705
743
  });
706
744
  };
707
745
  var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
708
- store.logger.info(`\u23E9 redo "${token.key}"`);
746
+ store.logger.info(`\u23E9`, `timeline`, token.key, `redo`);
709
747
  const timelineData = store.timelines.get(token.key);
710
748
  if (!timelineData) {
711
749
  store.logger.error(
712
- `\u{1F41E} Failed to redo on timeline "${token.key}". This timeline has not been initialized.`
750
+ `\u{1F41E}`,
751
+ `timeline`,
752
+ token.key,
753
+ `Failed to redo. This timeline has not been initialized.`
713
754
  );
714
755
  return;
715
756
  }
716
757
  if (timelineData.at === timelineData.history.length) {
717
758
  store.logger.warn(
718
- `\u261D\uFE0F Failed to redo at the end of timeline "${token.key}". There is nothing to redo.`
759
+ `\u{1F481}`,
760
+ `timeline`,
761
+ token.key,
762
+ `Failed to redo at the end of timeline "${token.key}". There is nothing to redo.`
719
763
  );
720
764
  return;
721
765
  }
@@ -740,21 +784,30 @@ var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
740
784
  timelineData.subject.next(`redo`);
741
785
  timelineData.timeTraveling = null;
742
786
  store.logger.info(
743
- `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
787
+ `\u23F9\uFE0F`,
788
+ `timeline`,
789
+ token.key,
790
+ `"${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
744
791
  );
745
792
  };
746
793
  var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
747
- store.logger.info(`\u23EA undo "${token.key}"`);
794
+ store.logger.info(`\u23EA`, `timeline`, token.key, `undo`);
748
795
  const timelineData = store.timelines.get(token.key);
749
796
  if (!timelineData) {
750
797
  store.logger.error(
751
- `\u{1F41E} Failed to undo on timeline "${token.key}". This timeline has not been initialized.`
798
+ `\u{1F41E}`,
799
+ `timeline`,
800
+ token.key,
801
+ `Failed to undo. This timeline has not been initialized.`
752
802
  );
753
803
  return;
754
804
  }
755
805
  if (timelineData.at === 0) {
756
806
  store.logger.warn(
757
- `\u261D\uFE0F Failed to undo at the beginning of timeline "${token.key}". There is nothing to undo.`
807
+ `\u{1F481}`,
808
+ `timeline`,
809
+ token.key,
810
+ `Failed to undo at the beginning of timeline "${token.key}". There is nothing to undo.`
758
811
  );
759
812
  return;
760
813
  }
@@ -779,7 +832,10 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
779
832
  timelineData.subject.next(`undo`);
780
833
  timelineData.timeTraveling = null;
781
834
  store.logger.info(
782
- `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
835
+ `\u23F9\uFE0F`,
836
+ `timeline`,
837
+ token.key,
838
+ `"${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
783
839
  );
784
840
  };
785
841
 
@@ -806,7 +862,10 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
806
862
  const timelineKey = core.timelineAtoms.getRelatedKey(tokenOrFamily.key);
807
863
  if (timelineKey) {
808
864
  store.logger.error(
809
- `\u274C Failed to add atom "${tokenOrFamily.key}" to timeline "${options.key}" because it belongs to timeline "${timelineKey}"`
865
+ `\u274C`,
866
+ `timeline`,
867
+ options.key,
868
+ `Failed to add atom "${tokenOrFamily.key}" because it already belongs to timeline "${timelineKey}"`
810
869
  );
811
870
  continue;
812
871
  }
@@ -828,7 +887,10 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
828
887
  );
829
888
  if (familyTimelineKey) {
830
889
  store.logger.error(
831
- `\u274C Failed to add atom "${token2.key}" to timeline "${options.key}" because its family "${token2.family.key}" belongs to timeline "${familyTimelineKey}"`
890
+ `\u274C`,
891
+ `timeline`,
892
+ options.key,
893
+ `Failed to add atom "${token2.key}" because its family "${token2.family.key}" already belongs to timeline "${familyTimelineKey}"`
832
894
  );
833
895
  continue;
834
896
  }
@@ -861,7 +923,12 @@ function withdraw(token, store) {
861
923
  core = store.transactionStatus.core;
862
924
  state = (_h = (_g = (_f = (_e = core.atoms.get(token.key)) != null ? _e : core.selectors.get(token.key)) != null ? _f : core.readonlySelectors.get(token.key)) != null ? _g : core.transactions.get(token.key)) != null ? _h : core.timelines.get(token.key);
863
925
  if (state) {
864
- store.logger.info(`\u{1F6E0}\uFE0F add ${token.type} "${token.key}"`);
926
+ store.logger.info(
927
+ `\u{1F6E0}\uFE0F`,
928
+ token.type,
929
+ token.key,
930
+ `add ${token.type} "${token.key}"`
931
+ );
865
932
  switch (state.type) {
866
933
  case `atom`: {
867
934
  store.atoms.set(token.key, state);
@@ -900,7 +967,10 @@ function withdraw(token, store) {
900
967
  // src/store/withdraw-new-family-member.ts
901
968
  function withdrawNewFamilyMember(token, store) {
902
969
  store.logger.info(
903
- `\u{1F46A} creating new family member "${token.key}" in store "${store.config.name}"`
970
+ `\u{1F46A}`,
971
+ token.type,
972
+ token.key,
973
+ `creating new family member in store "${store.config.name}"`
904
974
  );
905
975
  if (token.family) {
906
976
  const core = target(store);
@@ -930,9 +1000,9 @@ var cacheValue = (key, value, subject, store = IMPLICIT.STORE) => {
930
1000
  }
931
1001
  cacheValue(key, value2, subject, store);
932
1002
  subject.next({ newValue: value2, oldValue: value2 });
933
- }).catch((error) => {
934
- if (error !== `canceled`) {
935
- store.logger.error(`\u{1F645}\u200D\u2642\uFE0F Promised value for "${key}" rejected:`, error);
1003
+ }).catch((thrown) => {
1004
+ if (thrown !== `canceled`) {
1005
+ store.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
936
1006
  }
937
1007
  });
938
1008
  } else {
@@ -951,7 +1021,7 @@ var evictCachedValue = (key, store = IMPLICIT.STORE) => {
951
1021
  core.operation.prev.set(key, currentValue);
952
1022
  }
953
1023
  core.valueMap.delete(key);
954
- store.logger.info(`\u{1F5D1} evicted "${key}"`);
1024
+ store.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
955
1025
  };
956
1026
  var Tracker = class {
957
1027
  constructor(mutableState, store = IMPLICIT.STORE) {
@@ -1072,7 +1142,10 @@ var Tracker = class {
1072
1142
  // src/mutable/create-mutable-atom.ts
1073
1143
  function createMutableAtom(options, store = IMPLICIT.STORE) {
1074
1144
  store.logger.info(
1075
- `\u{1F527} creating mutable atom "${options.key}" in store "${store.config.name}"`
1145
+ `\u{1F527}`,
1146
+ `atom`,
1147
+ options.key,
1148
+ `creating in store "${store.config.name}"`
1076
1149
  );
1077
1150
  const coreState = createAtom(options, void 0, store);
1078
1151
  new Tracker(coreState, store);
@@ -1080,10 +1153,6 @@ function createMutableAtom(options, store = IMPLICIT.STORE) {
1080
1153
  subscribe(
1081
1154
  jsonState,
1082
1155
  () => {
1083
- store.logger.info(
1084
- `\u{1F50D} tracker-initializer:${store == null ? void 0 : store.config.name}:${store.transactionStatus.phase === `idle` ? `main` : store.transactionStatus.key}`,
1085
- `Initializing tracker for ${coreState.key}`
1086
- );
1087
1156
  const trackerHasBeenInitialized = target(store).trackers.has(coreState.key);
1088
1157
  if (!trackerHasBeenInitialized) {
1089
1158
  new Tracker(coreState, store);
@@ -1143,16 +1212,14 @@ var getSelectorDependencyKeys = (key, store) => {
1143
1212
  // src/get-state-internal.ts
1144
1213
  var getState__INTERNAL = (state, store = IMPLICIT.STORE) => {
1145
1214
  if (isValueCached(state.key, store)) {
1146
- store.logger.info(`\u{1F4D6} reading "${state.key}"`);
1215
+ store.logger.info(`\u{1F4D6}`, state.type, state.key, `reading cached value`);
1147
1216
  return readCachedValue(state.key, store);
1148
1217
  }
1149
1218
  if (state.type !== `atom`) {
1150
- store.logger.info(`\u{1F9EE} calculating "${state.key}"`);
1219
+ store.logger.info(`\u{1F9EE}`, state.type, state.key, `calculating value`);
1151
1220
  return state.get();
1152
1221
  }
1153
- store.logger.error(
1154
- `\u{1F41E} Attempted to get atom "${state.key}", which was never initialized in store "${store.config.name}".`
1155
- );
1222
+ store.logger.error(`\u{1F41E}`, `atom`, state.key, `could not find cached value`);
1156
1223
  return state.default;
1157
1224
  };
1158
1225
 
@@ -1166,7 +1233,10 @@ var openOperation = (token, store) => {
1166
1233
  const core = target(store);
1167
1234
  if (core.operation.open) {
1168
1235
  store.logger.error(
1169
- `\u274C failed to setState to "${token.key}" during a setState for "${core.operation.token.key}"`
1236
+ `\u274C`,
1237
+ token.type,
1238
+ token.key,
1239
+ `failed to setState during a setState for "${core.operation.token.key}"`
1170
1240
  );
1171
1241
  return `rejection`;
1172
1242
  }
@@ -1178,14 +1248,20 @@ var openOperation = (token, store) => {
1178
1248
  token
1179
1249
  };
1180
1250
  store.logger.info(
1181
- `\u2B55 Operation start from ${token.type} "${token.key}" in store "${store.config.name}"${store.transactionStatus.phase === `idle` ? `` : ` ${store.transactionStatus.phase} "${store.transactionStatus.key}"`}`
1251
+ `\u2B55`,
1252
+ token.type,
1253
+ token.key,
1254
+ `operation start in store "${store.config.name}"${store.transactionStatus.phase === `idle` ? `` : ` ${store.transactionStatus.phase} "${store.transactionStatus.key}"`}`
1182
1255
  );
1183
1256
  };
1184
1257
  var closeOperation = (store) => {
1185
1258
  const core = target(store);
1186
1259
  if (core.operation.open) {
1187
1260
  store.logger.info(
1188
- `\u{1F534} Operation done for ${core.operation.token.type} "${core.operation.token.key}" in store ${store.config.name}`
1261
+ `\u{1F534}`,
1262
+ core.operation.token.type,
1263
+ core.operation.token.key,
1264
+ `operation done in store "${store.config.name}"`
1189
1265
  );
1190
1266
  }
1191
1267
  core.operation = { open: false };
@@ -1195,7 +1271,10 @@ var isDone = (key, store = IMPLICIT.STORE) => {
1195
1271
  const core = target(store);
1196
1272
  if (!core.operation.open) {
1197
1273
  store.logger.warn(
1198
- `\u{1F41E} isDone called outside of an operation. This is probably a bug.`
1274
+ `\u{1F41E}`,
1275
+ `unknown`,
1276
+ key,
1277
+ `isDone called outside of an operation. This is probably a bug.`
1199
1278
  );
1200
1279
  return true;
1201
1280
  }
@@ -1205,7 +1284,10 @@ var markDone = (key, store = IMPLICIT.STORE) => {
1205
1284
  const core = target(store);
1206
1285
  if (!core.operation.open) {
1207
1286
  store.logger.warn(
1208
- `\u{1F41E} markDone called outside of an operation. This is probably a bug.`
1287
+ `\u{1F41E}`,
1288
+ `unknown`,
1289
+ key,
1290
+ `markDone called outside of an operation. This is probably a bug.`
1209
1291
  );
1210
1292
  return;
1211
1293
  }
@@ -1217,7 +1299,7 @@ function copyMutableIfNeeded(atom, transform, origin, target2) {
1217
1299
  const originValue = origin.valueMap.get(atom.key);
1218
1300
  const targetValue = target2.valueMap.get(atom.key);
1219
1301
  if (originValue === targetValue) {
1220
- origin.logger.info(`\u{1F4C3} copying`, `${atom.key}`);
1302
+ origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
1221
1303
  const copiedValue = transform.fromJson(transform.toJson(originValue));
1222
1304
  target2.valueMap.set(atom.key, copiedValue);
1223
1305
  new Tracker(atom, origin);
@@ -1230,9 +1312,6 @@ function copyMutableIfNeeded(atom, transform, origin, target2) {
1230
1312
  function copyMutableIfWithinTransaction(atom, store) {
1231
1313
  if (store.transactionStatus.phase === `building` || store.transactionStatus.phase === `applying`) {
1232
1314
  if (`toJson` in atom && `fromJson` in atom) {
1233
- store.logger.info(
1234
- `\u{1F4C4} copyMutableIfWithinTransaction: ${atom.key} is mutable`
1235
- );
1236
1315
  const copiedValue = copyMutableIfNeeded(
1237
1316
  atom,
1238
1317
  atom,
@@ -1268,48 +1347,46 @@ function copyMutableFamilyMemberWithinTransaction(atom, family, origin, target2)
1268
1347
 
1269
1348
  // src/set-state/emit-update.ts
1270
1349
  var emitUpdate = (state, update, store) => {
1271
- const { key } = state;
1272
1350
  const { logger } = store;
1273
1351
  logger.info(
1274
- `\u{1F4E2} ${state.type} "${key}" went (`,
1352
+ `\u{1F4E2}`,
1353
+ state.type,
1354
+ state.key,
1355
+ `went (`,
1275
1356
  update.oldValue,
1276
1357
  `->`,
1277
1358
  update.newValue,
1278
- `)`
1279
- );
1280
- logger.info(
1281
- `\u{1F4E2} notifying subscribers to "${state.key}"`,
1359
+ `) subscribers:`,
1282
1360
  state.subject.subscribers
1283
1361
  );
1284
1362
  state.subject.next(update);
1285
1363
  };
1286
1364
 
1287
1365
  // src/set-state/evict-downstream.ts
1288
- var evictDownStream = (state, store = IMPLICIT.STORE) => {
1289
- var _a, _b;
1366
+ var evictDownStream = (atom, store = IMPLICIT.STORE) => {
1367
+ var _a;
1290
1368
  const core = target(store);
1291
- const downstreamKeys = core.selectorAtoms.getRelatedKeys(state.key);
1369
+ const downstreamKeys = core.selectorAtoms.getRelatedKeys(atom.key);
1292
1370
  store.logger.info(
1293
- `\u{1F9F9} evicting ${(_a = downstreamKeys == null ? void 0 : downstreamKeys.size) != null ? _a : 0} states downstream from ${state.type} "${state.key}":`,
1371
+ `\u{1F9F9}`,
1372
+ atom.type,
1373
+ atom.key,
1374
+ `evicting ${(_a = downstreamKeys == null ? void 0 : downstreamKeys.size) != null ? _a : 0} states downstream:`,
1294
1375
  downstreamKeys
1295
1376
  );
1296
1377
  if (downstreamKeys !== void 0) {
1297
1378
  if (core.operation.open) {
1298
1379
  store.logger.info(
1299
- `\u{1F9F9} [ ${[...core.operation.done].join(`, `)} ] already done`
1380
+ `\u{1F9F9}`,
1381
+ atom.type,
1382
+ atom.key,
1383
+ `[ ${[...core.operation.done].join(`, `)} ] already done`
1300
1384
  );
1301
1385
  }
1302
1386
  for (const key of downstreamKeys) {
1303
1387
  if (isDone(key, store)) {
1304
1388
  continue;
1305
1389
  }
1306
- const state2 = (_b = core.selectors.get(key)) != null ? _b : core.readonlySelectors.get(key);
1307
- if (!state2) {
1308
- store.logger.error(
1309
- `\u{1F41E} "${key}" was not found in selectors or readonlySelectors`
1310
- );
1311
- return;
1312
- }
1313
1390
  evictCachedValue(key, store);
1314
1391
  markDone(key, store);
1315
1392
  }
@@ -1329,8 +1406,11 @@ function shouldUpdateBeStowed(key, update) {
1329
1406
  var stowUpdate = (state, update, store) => {
1330
1407
  const { key } = state;
1331
1408
  if (store.transactionStatus.phase !== `building`) {
1332
- store.logger.warn(
1333
- `\u{1F41E} stowUpdate called outside of a transaction. This is probably a bug.`
1409
+ store.logger.error(
1410
+ `\u{1F41E}`,
1411
+ `atom`,
1412
+ key,
1413
+ `stowUpdate called outside of a transaction. This is probably a bug.`
1334
1414
  );
1335
1415
  return;
1336
1416
  }
@@ -1344,7 +1424,10 @@ var stowUpdate = (state, update, store) => {
1344
1424
  }
1345
1425
  store.transactionStatus.atomUpdates.push(atomUpdate);
1346
1426
  store.logger.info(
1347
- `\u{1F4C1} ${key} stowed (`,
1427
+ `\u{1F4C1}`,
1428
+ `atom`,
1429
+ key,
1430
+ `stowed (`,
1348
1431
  update.oldValue,
1349
1432
  `->`,
1350
1433
  update.newValue,
@@ -1357,7 +1440,7 @@ var setAtom = (atom, next, store = IMPLICIT.STORE) => {
1357
1440
  const oldValue = getState__INTERNAL(atom, store);
1358
1441
  let newValue = copyMutableIfWithinTransaction(atom, store);
1359
1442
  newValue = become(next)(newValue);
1360
- store.logger.info(`\u{1F4DD} setting atom "${atom.key}" to`, newValue);
1443
+ store.logger.info(`\u{1F4DD}`, `atom`, atom.key, `set to`, newValue);
1361
1444
  cacheValue(atom.key, newValue, atom.subject, store);
1362
1445
  if (isAtomDefault(atom.key, store)) {
1363
1446
  markAtomAsNotDefault(atom.key, store);
@@ -1423,13 +1506,18 @@ var updateSelectorAtoms = (selectorKey, dependency, store) => {
1423
1506
  atomKey: dependency.key
1424
1507
  });
1425
1508
  store.logger.info(
1426
- `\u{1F50D} selector "${selectorKey}" discovers root atom "${dependency.key}"`
1509
+ `\u{1F50D}`,
1510
+ `selector`,
1511
+ selectorKey,
1512
+ `discovers root atom "${dependency.key}"`
1427
1513
  );
1428
1514
  } else {
1429
1515
  const rootKeys = traceSelectorAtoms(selectorKey, dependency.key, store);
1430
1516
  store.logger.info(
1431
- `\u{1F50D} selector "${selectorKey}" discovers root atoms:`,
1432
- rootKeys.map((r) => r)
1517
+ `\u{1F50D}`,
1518
+ `selector`,
1519
+ selectorKey,
1520
+ `discovers root atoms: [ ${rootKeys.map((key) => `"${key}"`).join(`, `)} ]`
1433
1521
  );
1434
1522
  for (const atomKey of rootKeys) {
1435
1523
  core.selectorAtoms = core.selectorAtoms.set({
@@ -1453,7 +1541,12 @@ var registerSelector = (selectorKey, store = IMPLICIT.STORE) => ({
1453
1541
  }
1454
1542
  const dependencyValue = getState__INTERNAL(dependencyState, store);
1455
1543
  store.logger.info(
1456
- `\u{1F50C} selector "${selectorKey}" registers dependency ( "${dependency.key}" = ${dependencyValue} )`
1544
+ `\u{1F50C}`,
1545
+ `selector`,
1546
+ selectorKey,
1547
+ `registers dependency ( "${dependency.key}" =`,
1548
+ dependencyValue,
1549
+ `)`
1457
1550
  );
1458
1551
  if (!alreadyRegistered) {
1459
1552
  core.selectorGraph = core.selectorGraph.set(
@@ -1492,7 +1585,16 @@ var createReadWriteSelector = (options, family, store, core) => {
1492
1585
  const setSelf = (next) => {
1493
1586
  const oldValue = getSelf();
1494
1587
  const newValue = become(next)(oldValue);
1495
- store.logger.info(`\u{1F4DD} set "${options.key}" (`, oldValue, `->`, newValue, `)`);
1588
+ store.logger.info(
1589
+ `\u{1F4DD}`,
1590
+ `selector`,
1591
+ options.key,
1592
+ `set (`,
1593
+ oldValue,
1594
+ `->`,
1595
+ newValue,
1596
+ `)`
1597
+ );
1496
1598
  cacheValue(options.key, newValue, subject, store);
1497
1599
  markDone(options.key, store);
1498
1600
  if (store.transactionStatus.phase === `idle`) {
@@ -1509,7 +1611,7 @@ var createReadWriteSelector = (options, family, store, core) => {
1509
1611
  }), family && { family });
1510
1612
  core.selectors.set(options.key, mySelector);
1511
1613
  const initialValue = getSelf();
1512
- store.logger.info(`\u2728 "${options.key}" =`, initialValue);
1614
+ store.logger.info(`\u2728`, mySelector.type, mySelector.key, `=`, initialValue);
1513
1615
  const token = {
1514
1616
  key: options.key,
1515
1617
  type: `selector`
@@ -1538,7 +1640,13 @@ var createReadonlySelector = (options, family, store, core) => {
1538
1640
  }), family && { family });
1539
1641
  core.readonlySelectors.set(options.key, readonlySelector);
1540
1642
  const initialValue = getSelf();
1541
- store.logger.info(`\u2728 "${options.key}" =`, initialValue);
1643
+ store.logger.info(
1644
+ `\u2728`,
1645
+ readonlySelector.type,
1646
+ readonlySelector.key,
1647
+ `=`,
1648
+ initialValue
1649
+ );
1542
1650
  const token = {
1543
1651
  key: options.key,
1544
1652
  type: `readonly_selector`
@@ -1557,9 +1665,10 @@ function createSelector(options, family, store = IMPLICIT.STORE) {
1557
1665
  const existingReadonly = core.readonlySelectors.get(options.key);
1558
1666
  if (existingWritable || existingReadonly) {
1559
1667
  store.logger.error(
1560
- `\u2753 Tried to create ${existingReadonly ? `readonly selector` : `selector`}`,
1561
- `"${options.key}", but it already exists in the store.`,
1562
- `(Ignore if you are in development using hot module replacement.)`
1668
+ `\u274C`,
1669
+ existingReadonly ? `readonly_selector` : `selector`,
1670
+ options.key,
1671
+ `Tried to create selector, but it already exists in the store. (Ignore if you are in development using hot module replacement.)`
1563
1672
  );
1564
1673
  }
1565
1674
  if (`set` in options) {
@@ -1741,14 +1850,19 @@ var isSelectorDefault = (key, store = IMPLICIT.STORE) => {
1741
1850
  function createAtom(options, family, store = IMPLICIT.STORE) {
1742
1851
  var _a;
1743
1852
  store.logger.info(
1744
- `\u{1F528} creating atom "${options.key}" in store "${store.config.name}"`
1853
+ `\u{1F528}`,
1854
+ `atom`,
1855
+ options.key,
1856
+ `creating in store "${store.config.name}"`
1745
1857
  );
1746
1858
  const core = target(store);
1747
1859
  const existing = core.atoms.get(options.key);
1748
1860
  if (existing) {
1749
1861
  store.logger.error(
1750
- `\u2753 Tried to create atom "${options.key}",`,
1751
- `but it already exists in the store.`,
1862
+ `\u274C`,
1863
+ `atom`,
1864
+ options.key,
1865
+ `Tried to create atom, but it already exists in the store.`,
1752
1866
  `(Ignore if you are in development using hot module replacement.)`
1753
1867
  );
1754
1868
  return deposit(existing);
@@ -1758,7 +1872,10 @@ function createAtom(options, family, store = IMPLICIT.STORE) {
1758
1872
  type: `atom`,
1759
1873
  install: (store2) => {
1760
1874
  store2.logger.info(
1761
- `\u{1F6E0}\uFE0F installing atom "${options.key}" in store "${store2.config.name}"`
1875
+ `\u{1F6E0}\uFE0F`,
1876
+ `atom`,
1877
+ options.key,
1878
+ `installing in store "${store2.config.name}"`
1762
1879
  );
1763
1880
  return `mutable` in options ? createMutableAtom(options, store2) : createAtom(options, void 0, store2);
1764
1881
  },
@@ -1788,7 +1905,7 @@ function deleteAtom(atomToken, store = IMPLICIT.STORE) {
1788
1905
  core.selectorAtoms.delete(key);
1789
1906
  core.atomsThatAreDefault.delete(key);
1790
1907
  core.timelineAtoms.delete(key);
1791
- store.logger.info(`\u{1F525} Atom "${key}" deleted`);
1908
+ store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
1792
1909
  }
1793
1910
 
1794
1911
  // src/subscribe/recall-state.ts
@@ -1796,7 +1913,10 @@ var recallState = (state, store = IMPLICIT.STORE) => {
1796
1913
  const core = target(store);
1797
1914
  if (!core.operation.open) {
1798
1915
  store.logger.warn(
1799
- `\u{1F41E} recall called outside of an operation. This is probably a bug.`
1916
+ `\u{1F41E}`,
1917
+ state.type,
1918
+ state.key,
1919
+ `recall called outside of an operation. This is probably a bug.`
1800
1920
  );
1801
1921
  return core.valueMap.get(state.key);
1802
1922
  }
@@ -1816,20 +1936,26 @@ var subscribeToRootAtoms = (state, store) => {
1816
1936
  `${state.type}:${state.key}`,
1817
1937
  (atomChange) => {
1818
1938
  store.logger.info(
1819
- `\u{1F4E2} selector "${state.key}" saw root "${atomKey}" go (`,
1939
+ `\u{1F4E2}`,
1940
+ state.type,
1941
+ state.key,
1942
+ `root`,
1943
+ atomKey,
1944
+ `went`,
1820
1945
  atomChange.oldValue,
1821
1946
  `->`,
1822
- atomChange.newValue,
1823
- `)`
1947
+ atomChange.newValue
1824
1948
  );
1825
1949
  const oldValue = recallState(state, store);
1826
1950
  const newValue = getState__INTERNAL(state, store);
1827
1951
  store.logger.info(
1828
- `\u2728 "${state.key}" went (`,
1952
+ `\u2728`,
1953
+ state.type,
1954
+ state.key,
1955
+ `went`,
1829
1956
  oldValue,
1830
1957
  `->`,
1831
- newValue,
1832
- `)`
1958
+ newValue
1833
1959
  );
1834
1960
  state.subject.next({ newValue, oldValue });
1835
1961
  }