atom.io 0.12.0 → 0.13.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.
Files changed (81) hide show
  1. package/dist/index.cjs.map +1 -1
  2. package/dist/index.d.cts +6 -3
  3. package/dist/index.d.ts +6 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/metafile-cjs.json +1 -1
  6. package/dist/metafile-esm.json +1 -1
  7. package/internal/dist/index.cjs +1579 -1498
  8. package/internal/dist/index.cjs.map +1 -1
  9. package/internal/dist/index.d.cts +34 -14
  10. package/internal/dist/index.d.ts +34 -14
  11. package/internal/dist/index.js +1577 -1499
  12. package/internal/dist/index.js.map +1 -1
  13. package/internal/dist/metafile-cjs.json +1 -1
  14. package/internal/dist/metafile-esm.json +1 -1
  15. package/internal/src/atom/create-atom.ts +4 -4
  16. package/internal/src/atom/delete-atom.ts +11 -11
  17. package/internal/src/atom/is-default.ts +5 -5
  18. package/internal/src/caching.ts +12 -10
  19. package/internal/src/families/create-atom-family.ts +3 -3
  20. package/internal/src/families/create-readonly-selector-family.ts +3 -3
  21. package/internal/src/families/create-selector-family.ts +4 -4
  22. package/internal/src/index.ts +4 -2
  23. package/internal/src/keys.ts +4 -4
  24. package/internal/src/lazy-map.ts +37 -0
  25. package/internal/src/lineage.ts +18 -0
  26. package/internal/src/mutable/create-mutable-atom.ts +5 -4
  27. package/internal/src/mutable/get-json-family.ts +3 -3
  28. package/internal/src/mutable/tracker.ts +13 -10
  29. package/internal/src/operation.ts +19 -19
  30. package/internal/src/selector/create-read-write-selector.ts +5 -4
  31. package/internal/src/selector/create-readonly-selector.ts +4 -3
  32. package/internal/src/selector/create-selector.ts +6 -6
  33. package/internal/src/selector/delete-selector.ts +10 -10
  34. package/internal/src/selector/get-selector-dependency-keys.ts +2 -2
  35. package/internal/src/selector/register-selector.ts +4 -4
  36. package/internal/src/selector/update-selector-atoms.ts +2 -2
  37. package/internal/src/set-state/copy-mutable-if-needed.ts +4 -3
  38. package/internal/src/set-state/copy-mutable-in-transaction.ts +10 -16
  39. package/internal/src/set-state/copy-mutable-into-new-store.ts +1 -1
  40. package/internal/src/set-state/evict-downstream.ts +5 -5
  41. package/internal/src/set-state/set-atom.ts +6 -1
  42. package/internal/src/set-state/stow-update.ts +7 -2
  43. package/internal/src/store/store.ts +31 -24
  44. package/internal/src/store/withdraw-new-family-member.ts +3 -4
  45. package/internal/src/store/withdraw.ts +58 -59
  46. package/internal/src/subject.ts +14 -0
  47. package/internal/src/subscribe/recall-state.ts +5 -5
  48. package/internal/src/timeline/add-atom-to-timeline.ts +37 -27
  49. package/internal/src/timeline/create-timeline.ts +6 -8
  50. package/internal/src/timeline/time-travel.ts +22 -4
  51. package/internal/src/transaction/abort-transaction.ts +5 -3
  52. package/internal/src/transaction/apply-transaction.ts +80 -58
  53. package/internal/src/transaction/build-transaction.ts +34 -23
  54. package/internal/src/transaction/create-transaction.ts +6 -9
  55. package/internal/src/transaction/index.ts +2 -10
  56. package/internal/src/transaction/redo-transaction.ts +15 -10
  57. package/internal/src/transaction/undo-transaction.ts +15 -16
  58. package/introspection/dist/index.cjs +2 -2
  59. package/introspection/dist/index.cjs.map +1 -1
  60. package/introspection/dist/index.js +3 -3
  61. package/introspection/dist/index.js.map +1 -1
  62. package/introspection/src/attach-atom-index.ts +2 -2
  63. package/introspection/src/attach-selector-index.ts +2 -2
  64. package/package.json +3 -3
  65. package/react-devtools/dist/index.cjs +22 -8
  66. package/react-devtools/dist/index.cjs.map +1 -1
  67. package/react-devtools/dist/index.d.cts +17 -9
  68. package/react-devtools/dist/index.d.ts +17 -9
  69. package/react-devtools/dist/index.js +22 -8
  70. package/react-devtools/dist/index.js.map +1 -1
  71. package/react-devtools/dist/metafile-cjs.json +1 -1
  72. package/react-devtools/dist/metafile-esm.json +1 -1
  73. package/react-devtools/src/Updates.tsx +22 -10
  74. package/src/transaction.ts +7 -2
  75. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  76. package/transceivers/set-rtx/dist/index.d.cts +2 -2
  77. package/transceivers/set-rtx/dist/index.d.ts +2 -2
  78. package/transceivers/set-rtx/dist/index.js.map +1 -1
  79. package/transceivers/set-rtx/dist/metafile-cjs.json +1 -1
  80. package/transceivers/set-rtx/dist/metafile-esm.json +1 -1
  81. package/transceivers/set-rtx/src/set-rtx.ts +3 -3
@@ -31,6 +31,11 @@ declare class Subject<T> {
31
31
  private unsubscribe;
32
32
  next(value: T): void;
33
33
  }
34
+ declare class StatefulSubject<T> extends Subject<T> {
35
+ state: T;
36
+ constructor(initialState: T);
37
+ next(value: T): void;
38
+ }
34
39
 
35
40
  type Selector<T> = {
36
41
  key: string;
@@ -64,15 +69,11 @@ type Transaction<ƒ extends ƒn> = {
64
69
  run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
65
70
  };
66
71
 
67
- type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
72
+ type TransactionMeta<ƒ extends ƒn> = {
68
73
  phase: `applying` | `building`;
69
74
  time: number;
70
- core: StoreCore;
71
- };
72
- type TransactionIdle = {
73
- phase: `idle`;
75
+ update: TransactionUpdate<ƒ>;
74
76
  };
75
- type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
76
77
 
77
78
  type primitive = boolean | number | string | null;
78
79
 
@@ -148,6 +149,11 @@ declare class Junction<const ASide extends string, const BSide extends string, c
148
149
  has(a: string, b?: string): boolean;
149
150
  }
150
151
 
152
+ interface Lineage {
153
+ parent: typeof this | null;
154
+ child: typeof this | null;
155
+ }
156
+
151
157
  interface Transceiver<Signal extends Json.Serializable> {
152
158
  do: (update: Signal) => void;
153
159
  undo: (update: Signal) => void;
@@ -216,8 +222,9 @@ type Timeline = {
216
222
  subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
217
223
  };
218
224
 
219
- type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `families` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `trackers` | `transactions` | `valueMap`>;
220
- declare class Store {
225
+ declare class Store implements Lineage {
226
+ parent: Store | null;
227
+ child: Store | null;
221
228
  valueMap: Map<string, any>;
222
229
  atoms: Map<string, Atom<any> | MutableAtom<any>>;
223
230
  selectors: Map<string, Selector<any>>;
@@ -237,10 +244,11 @@ declare class Store {
237
244
  selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
238
245
  transactionCreation: Subject<TransactionToken<ƒn>>;
239
246
  timelineCreation: Subject<TimelineToken>;
247
+ transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
240
248
  operationStatus: Subject<OperationProgress>;
241
249
  };
242
250
  operation: OperationProgress;
243
- transactionStatus: TransactionStatus<ƒn>;
251
+ transactionMeta: TransactionMeta<ƒn> | null;
244
252
  config: {
245
253
  name: string;
246
254
  };
@@ -31,6 +31,11 @@ declare class Subject<T> {
31
31
  private unsubscribe;
32
32
  next(value: T): void;
33
33
  }
34
+ declare class StatefulSubject<T> extends Subject<T> {
35
+ state: T;
36
+ constructor(initialState: T);
37
+ next(value: T): void;
38
+ }
34
39
 
35
40
  type Selector<T> = {
36
41
  key: string;
@@ -64,15 +69,11 @@ type Transaction<ƒ extends ƒn> = {
64
69
  run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
65
70
  };
66
71
 
67
- type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
72
+ type TransactionMeta<ƒ extends ƒn> = {
68
73
  phase: `applying` | `building`;
69
74
  time: number;
70
- core: StoreCore;
71
- };
72
- type TransactionIdle = {
73
- phase: `idle`;
75
+ update: TransactionUpdate<ƒ>;
74
76
  };
75
- type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
76
77
 
77
78
  type primitive = boolean | number | string | null;
78
79
 
@@ -148,6 +149,11 @@ declare class Junction<const ASide extends string, const BSide extends string, c
148
149
  has(a: string, b?: string): boolean;
149
150
  }
150
151
 
152
+ interface Lineage {
153
+ parent: typeof this | null;
154
+ child: typeof this | null;
155
+ }
156
+
151
157
  interface Transceiver<Signal extends Json.Serializable> {
152
158
  do: (update: Signal) => void;
153
159
  undo: (update: Signal) => void;
@@ -216,8 +222,9 @@ type Timeline = {
216
222
  subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
217
223
  };
218
224
 
219
- type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `families` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `trackers` | `transactions` | `valueMap`>;
220
- declare class Store {
225
+ declare class Store implements Lineage {
226
+ parent: Store | null;
227
+ child: Store | null;
221
228
  valueMap: Map<string, any>;
222
229
  atoms: Map<string, Atom<any> | MutableAtom<any>>;
223
230
  selectors: Map<string, Selector<any>>;
@@ -237,10 +244,11 @@ declare class Store {
237
244
  selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
238
245
  transactionCreation: Subject<TransactionToken<ƒn>>;
239
246
  timelineCreation: Subject<TimelineToken>;
247
+ transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
240
248
  operationStatus: Subject<OperationProgress>;
241
249
  };
242
250
  operation: OperationProgress;
243
- transactionStatus: TransactionStatus<ƒn>;
251
+ transactionMeta: TransactionMeta<ƒn> | null;
244
252
  config: {
245
253
  name: string;
246
254
  };
@@ -2528,14 +2528,21 @@ var TransactionUpdateFC = ({ serialNumber, transactionUpdate }) => {
2528
2528
  ] }),
2529
2529
  /* @__PURE__ */ jsxs("section", { className: "transaction_impact", children: [
2530
2530
  /* @__PURE__ */ jsx("span", { className: "detail", children: "impact: " }),
2531
- transactionUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
2532
- return /* @__PURE__ */ jsx(
2531
+ transactionUpdate.updates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((update, index) => {
2532
+ return `newValue` in update ? /* @__PURE__ */ jsx(
2533
2533
  article.AtomUpdate,
2534
2534
  {
2535
2535
  serialNumber: index,
2536
- atomUpdate
2536
+ atomUpdate: update
2537
2537
  },
2538
- `${transactionUpdate.key}:${index}:${atomUpdate.key}`
2538
+ `${transactionUpdate.key}:${index}:${update.key}`
2539
+ ) : /* @__PURE__ */ jsx(
2540
+ TransactionUpdateFC,
2541
+ {
2542
+ serialNumber: index,
2543
+ transactionUpdate: update
2544
+ },
2545
+ `${transactionUpdate.key}:${index}:${update.key}`
2539
2546
  );
2540
2547
  })
2541
2548
  ] })
@@ -2552,14 +2559,21 @@ var TimelineUpdateFC = ({ timelineUpdate }) => {
2552
2559
  timelineUpdate.key,
2553
2560
  ")"
2554
2561
  ] }) }),
2555
- /* @__PURE__ */ jsx("main", { children: timelineUpdate.type === `transaction_update` ? timelineUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
2556
- return /* @__PURE__ */ jsx(
2562
+ /* @__PURE__ */ jsx("main", { children: timelineUpdate.type === `transaction_update` ? timelineUpdate.updates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((update, index) => {
2563
+ return `newValue` in update ? /* @__PURE__ */ jsx(
2557
2564
  article.AtomUpdate,
2558
2565
  {
2559
2566
  serialNumber: index,
2560
- atomUpdate
2567
+ atomUpdate: update
2561
2568
  },
2562
- `${timelineUpdate.key}:${index}:${atomUpdate.key}`
2569
+ `${timelineUpdate.key}:${index}:${update.key}`
2570
+ ) : /* @__PURE__ */ jsx(
2571
+ TransactionUpdateFC,
2572
+ {
2573
+ serialNumber: index,
2574
+ transactionUpdate: update
2575
+ },
2576
+ `${timelineUpdate.key}:${index}:${update.key}`
2563
2577
  );
2564
2578
  }) : timelineUpdate.type === `selector_update` ? timelineUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
2565
2579
  return /* @__PURE__ */ jsx(