atom.io 0.19.1 → 0.19.2

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 (97) hide show
  1. package/data/dist/index.cjs +99 -79
  2. package/data/dist/index.js +2 -2
  3. package/data/src/join.ts +67 -50
  4. package/dist/{chunk-YDOGCZ53.js → chunk-ATKDGVTV.js} +29 -29
  5. package/dist/{chunk-7VCCW45K.js → chunk-CC7IF7QF.js} +4 -3
  6. package/dist/{chunk-WX2NCOZR.js → chunk-FTONNX2R.js} +8 -8
  7. package/dist/{chunk-7ZR244C2.js → chunk-MSCJWACE.js} +92 -72
  8. package/dist/index.cjs +14 -7
  9. package/dist/index.d.ts +23 -35
  10. package/dist/index.js +14 -7
  11. package/internal/dist/index.cjs +55 -43
  12. package/internal/dist/index.d.ts +20 -20
  13. package/internal/dist/index.js +48 -36
  14. package/internal/src/atom/create-regular-atom.ts +7 -5
  15. package/internal/src/atom/delete-atom.ts +2 -2
  16. package/internal/src/families/create-readonly-selector-family.ts +2 -2
  17. package/internal/src/families/create-regular-atom-family.ts +1 -1
  18. package/internal/src/families/create-writable-selector-family.ts +1 -1
  19. package/internal/src/future.ts +4 -2
  20. package/internal/src/lineage.ts +1 -0
  21. package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
  22. package/internal/src/mutable/create-mutable-atom.ts +7 -5
  23. package/internal/src/mutable/tracker.ts +3 -3
  24. package/internal/src/mutable/transceiver.ts +2 -2
  25. package/internal/src/selector/delete-selector.ts +1 -1
  26. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  27. package/internal/src/store/deposit.ts +5 -5
  28. package/internal/src/store/store.ts +5 -5
  29. package/internal/src/store/withdraw.ts +4 -5
  30. package/internal/src/subject.ts +3 -1
  31. package/internal/src/subscribe/subscribe-to-transaction.ts +4 -4
  32. package/internal/src/timeline/add-atom-to-timeline.ts +13 -8
  33. package/internal/src/timeline/create-timeline.ts +3 -4
  34. package/internal/src/transaction/act-upon-store.ts +5 -5
  35. package/internal/src/transaction/apply-transaction.ts +4 -4
  36. package/internal/src/transaction/build-transaction.ts +9 -6
  37. package/internal/src/transaction/create-transaction.ts +10 -10
  38. package/internal/src/transaction/index.ts +3 -3
  39. package/internal/src/transaction/is-root-store.ts +2 -2
  40. package/introspection/dist/index.d.ts +3 -3
  41. package/introspection/src/attach-introspection-states.ts +3 -3
  42. package/introspection/src/attach-transaction-index.ts +4 -4
  43. package/introspection/src/attach-transaction-logs.ts +8 -4
  44. package/json/dist/index.cjs +6 -2
  45. package/json/dist/index.js +6 -2
  46. package/json/src/select-json-family.ts +3 -2
  47. package/json/src/select-json.ts +3 -1
  48. package/package.json +243 -241
  49. package/react/dist/index.cjs +9 -3
  50. package/react/dist/index.js +9 -3
  51. package/react/src/use-i.ts +3 -1
  52. package/react/src/use-tl.ts +6 -2
  53. package/react-devtools/dist/index.cjs +116 -53
  54. package/react-devtools/dist/index.d.ts +3 -5
  55. package/react-devtools/dist/index.js +113 -51
  56. package/react-devtools/src/AtomIODevtools.tsx +3 -1
  57. package/react-devtools/src/Button.tsx +3 -1
  58. package/react-devtools/src/StateIndex.tsx +6 -2
  59. package/react-devtools/src/TimelineIndex.tsx +6 -2
  60. package/react-devtools/src/TransactionIndex.tsx +3 -3
  61. package/react-devtools/src/Updates.tsx +14 -6
  62. package/realtime/dist/index.cjs +1 -0
  63. package/realtime/dist/index.d.ts +2 -2
  64. package/realtime/dist/index.js +1 -0
  65. package/realtime/src/realtime-continuity.ts +4 -3
  66. package/realtime-client/dist/index.cjs +29 -29
  67. package/realtime-client/dist/index.d.ts +2 -2
  68. package/realtime-client/dist/index.js +1 -1
  69. package/realtime-client/src/server-action.ts +2 -2
  70. package/realtime-client/src/sync-continuity.ts +23 -23
  71. package/realtime-react/dist/index.cjs +29 -29
  72. package/realtime-react/dist/index.d.ts +2 -2
  73. package/realtime-react/dist/index.js +1 -1
  74. package/realtime-react/src/use-server-action.ts +3 -3
  75. package/realtime-server/dist/index.cjs +54 -44
  76. package/realtime-server/dist/index.d.ts +5 -5
  77. package/realtime-server/dist/index.js +34 -24
  78. package/realtime-server/src/ipc-sockets/child-socket.ts +6 -6
  79. package/realtime-server/src/ipc-sockets/custom-socket.ts +4 -8
  80. package/realtime-server/src/ipc-sockets/parent-socket.ts +13 -7
  81. package/realtime-server/src/realtime-action-receiver.ts +7 -5
  82. package/realtime-server/src/realtime-continuity-synchronizer.ts +3 -3
  83. package/realtime-server/src/realtime-state-receiver.ts +3 -1
  84. package/realtime-testing/dist/index.cjs +15 -13
  85. package/realtime-testing/dist/index.js +9 -7
  86. package/realtime-testing/src/setup-realtime-test.tsx +6 -4
  87. package/src/atom.ts +4 -8
  88. package/src/dispose.ts +1 -0
  89. package/src/index.ts +2 -9
  90. package/src/selector.ts +4 -8
  91. package/src/silo.ts +9 -3
  92. package/src/subscribe.ts +6 -6
  93. package/src/timeline.ts +4 -4
  94. package/src/transaction.ts +24 -24
  95. package/transceivers/set-rtx/dist/index.cjs +11 -12
  96. package/transceivers/set-rtx/dist/index.js +11 -12
  97. package/transceivers/set-rtx/src/set-rtx.ts +10 -10
@@ -1,5 +1,4 @@
1
1
  import type {
2
- AtomFamily,
3
2
  AtomFamilyToken,
4
3
  FamilyMetadata,
5
4
  StateUpdate,
@@ -9,7 +8,7 @@ import type {
9
8
  TimelineUpdate,
10
9
  TokenType,
11
10
  TransactionUpdate,
12
- ƒn,
11
+ Func,
13
12
  } from "atom.io"
14
13
 
15
14
  import { newest } from "../lineage"
@@ -31,7 +30,7 @@ export type TimelineSelectorUpdate<ManagedAtom extends TimelineManageable> = {
31
30
  timestamp: number
32
31
  atomUpdates: Omit<TimelineAtomUpdate<ManagedAtom>, `timestamp`>[]
33
32
  }
34
- export type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
33
+ export type TimelineTransactionUpdate = TransactionUpdate<Func> & {
35
34
  key: string
36
35
  type: `transaction_update`
37
36
  timestamp: number
@@ -73,7 +72,7 @@ export function createTimeline<ManagedAtom extends TimelineManageable>(
73
72
  transactionKey: null,
74
73
  ...data,
75
74
  history: data?.history.map((update) => ({ ...update })) ?? [],
76
- install: (store) => createTimeline(options, store, tl),
75
+ install: (s) => createTimeline(options, s, tl),
77
76
  subject: new Subject(),
78
77
  }
79
78
  if (options.shouldCapture) {
@@ -1,15 +1,15 @@
1
- import type { TransactionToken, ƒn } from "atom.io"
1
+ import type { TransactionToken, Func } from "atom.io"
2
2
 
3
3
  import { NotFoundError } from "../not-found-error"
4
4
  import type { Store } from "../store"
5
5
  import { withdraw } from "../store"
6
6
 
7
- export function actUponStore extends ƒn>(
8
- token: TransactionToken<ƒ>,
7
+ export function actUponStore<F extends Func>(
8
+ token: TransactionToken<F>,
9
9
  id: string,
10
10
  store: Store,
11
- ): (...parameters: Parameters<ƒ>) => ReturnType<ƒ> {
12
- return (...parameters: Parameters<ƒ>): ReturnType<ƒ> => {
11
+ ): (...parameters: Parameters<F>) => ReturnType<F> {
12
+ return (...parameters: Parameters<F>): ReturnType<F> => {
13
13
  const tx = withdraw(token, store)
14
14
  if (tx) {
15
15
  return tx.run(parameters, id)
@@ -1,4 +1,4 @@
1
- import type { ƒn } from "atom.io"
1
+ import type { Func } from "atom.io"
2
2
 
3
3
  import { ingestTransactionUpdate } from "../ingest-updates"
4
4
  import { newest } from "../lineage"
@@ -7,8 +7,8 @@ import type { Store } from "../store"
7
7
  import { isChildStore, isRootStore } from "./is-root-store"
8
8
  import { setEpochNumberOfAction } from "./set-epoch-number"
9
9
 
10
- export const applyTransaction = extends ƒn>(
11
- output: ReturnType<ƒ>,
10
+ export const applyTransaction = <F extends Func>(
11
+ output: ReturnType<F>,
12
12
  store: Store,
13
13
  ): void => {
14
14
  const child = newest(store)
@@ -65,7 +65,7 @@ export const applyTransaction = <ƒ extends ƒn>(
65
65
  child.transactionMeta.update.epoch,
66
66
  parent,
67
67
  )
68
- const myTransaction = withdraw<ƒ>(
68
+ const myTransaction = withdraw<F>(
69
69
  { key: child.transactionMeta.update.key, type: `transaction` },
70
70
  store,
71
71
  )
@@ -1,4 +1,4 @@
1
- import type { findState, ƒn } from "atom.io"
1
+ import type { findState, Func } from "atom.io"
2
2
 
3
3
  import { Junction } from "~/packages/rel8/junction/src"
4
4
 
@@ -45,8 +45,8 @@ export const buildTransaction = (
45
45
  valueMap: new LazyMap(parent.valueMap),
46
46
  }
47
47
  const epoch = getEpochNumberOfAction(key, store)
48
- const transactionMeta: TransactionProgress<ƒn> = {
49
- phase: `building` as const,
48
+ const transactionMeta: TransactionProgress<Func> = {
49
+ phase: `building`,
50
50
  update: {
51
51
  key,
52
52
  id,
@@ -57,9 +57,12 @@ export const buildTransaction = (
57
57
  },
58
58
  transactors: {
59
59
  get: (token) => getFromStore(token, child),
60
- set: (token, value) => setIntoStore(token, value, child),
61
- run: (token, id = arbitrary()) => actUponStore(token, id, child),
62
- find: ((token, key) => findInStore(token, key, child)) as typeof findState,
60
+ set: (token, value) => {
61
+ setIntoStore(token, value, child)
62
+ },
63
+ run: (token, identifier = arbitrary()) =>
64
+ actUponStore(token, identifier, child),
65
+ find: ((token, k) => findInStore(token, k, child)) as typeof findState,
63
66
  env: () => getEnvironmentData(child),
64
67
  },
65
68
  }
@@ -2,7 +2,7 @@ import type {
2
2
  TransactionOptions,
3
3
  TransactionToken,
4
4
  TransactionUpdate,
5
- ƒn,
5
+ Func,
6
6
  } from "atom.io"
7
7
 
8
8
  import { newest } from "../lineage"
@@ -13,22 +13,22 @@ import { abortTransaction } from "./abort-transaction"
13
13
  import { applyTransaction } from "./apply-transaction"
14
14
  import { buildTransaction } from "./build-transaction"
15
15
 
16
- export type Transaction extends ƒn> = {
16
+ export type Transaction<F extends Func> = {
17
17
  key: string
18
18
  type: `transaction`
19
19
  install: (store: Store) => void
20
- subject: Subject<TransactionUpdate<ƒ>>
21
- run: (parameters: Parameters<ƒ>, id?: string) => ReturnType<ƒ>
20
+ subject: Subject<TransactionUpdate<F>>
21
+ run: (parameters: Parameters<F>, id?: string) => ReturnType<F>
22
22
  }
23
23
 
24
- export function createTransaction extends ƒn>(
25
- options: TransactionOptions<ƒ>,
24
+ export function createTransaction<F extends Func>(
25
+ options: TransactionOptions<F>,
26
26
  store: Store,
27
- ): TransactionToken<ƒ> {
28
- const newTransaction: Transaction<ƒ> = {
27
+ ): TransactionToken<F> {
28
+ const newTransaction: Transaction<F> = {
29
29
  key: options.key,
30
30
  type: `transaction`,
31
- run: (params: Parameters<ƒ>, id: string) => {
31
+ run: (params: Parameters<F>, id: string) => {
32
32
  const childStore = buildTransaction(options.key, params, store, id)
33
33
  try {
34
34
  const target = newest(store)
@@ -42,7 +42,7 @@ export function createTransaction<ƒ extends ƒn>(
42
42
  throw thrown
43
43
  }
44
44
  },
45
- install: (store) => createTransaction(options, store),
45
+ install: (s) => createTransaction(options, s),
46
46
  subject: new Subject(),
47
47
  }
48
48
  const target = newest(store)
@@ -1,4 +1,4 @@
1
- import type { TransactionUpdate, TransactorsWithRunAndEnv, ƒn } from "atom.io"
1
+ import type { TransactionUpdate, TransactorsWithRunAndEnv, Func } from "atom.io"
2
2
  import type { Junction } from "rel8/junction"
3
3
 
4
4
  export * from "./abort-transaction"
@@ -14,9 +14,9 @@ export * from "./set-epoch-number"
14
14
  export const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const
15
15
  export type TransactionPhase = (typeof TRANSACTION_PHASES)[number]
16
16
 
17
- export type TransactionProgress extends ƒn> = {
17
+ export type TransactionProgress<F extends Func> = {
18
18
  phase: `applying` | `building`
19
- update: TransactionUpdate<ƒ>
19
+ update: TransactionUpdate<F>
20
20
  transactors: TransactorsWithRunAndEnv
21
21
  }
22
22
 
@@ -1,4 +1,4 @@
1
- import type { ƒn } from "atom.io"
1
+ import type { Func } from "atom.io"
2
2
 
3
3
  import type { TransactionEpoch, TransactionProgress } from "."
4
4
  import type { Store } from "../store"
@@ -9,7 +9,7 @@ export interface RootStore extends Store {
9
9
  child: ChildStore | null
10
10
  }
11
11
  export interface ChildStore extends Store {
12
- transactionMeta: TransactionProgress<ƒn>
12
+ transactionMeta: TransactionProgress<Func>
13
13
  parent: ChildStore | RootStore
14
14
  child: ChildStore | null
15
15
  }
@@ -1,4 +1,4 @@
1
- import { AtomToken, ReadonlySelectorToken, WritableSelectorToken, TransactionToken, ƒn as _n, ReadonlySelectorFamilyToken, TransactionUpdate, TimelineToken } from 'atom.io';
1
+ import { AtomToken, ReadonlySelectorToken, WritableSelectorToken, TransactionToken, Func, ReadonlySelectorFamilyToken, TransactionUpdate, TimelineToken } from 'atom.io';
2
2
  import * as Internal from 'atom.io/internal';
3
3
  import { Timeline } from 'atom.io/internal';
4
4
 
@@ -9,8 +9,8 @@ type SelectorTokenIndex = WritableTokenIndex<ReadonlySelectorToken<unknown> | Wr
9
9
  declare const attachIntrospectionStates: (store?: Internal.Store) => {
10
10
  atomIndex: ReadonlySelectorToken<AtomTokenIndex>;
11
11
  selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>;
12
- transactionIndex: ReadonlySelectorToken<TransactionToken<_n>[]>;
13
- findTransactionLogState: ReadonlySelectorFamilyToken<TransactionUpdate<_n>[], string>;
12
+ transactionIndex: ReadonlySelectorToken<TransactionToken<Func>[]>;
13
+ findTransactionLogState: ReadonlySelectorFamilyToken<TransactionUpdate<Func>[], string>;
14
14
  timelineIndex: ReadonlySelectorToken<TimelineToken<any>[]>;
15
15
  findTimelineState: ReadonlySelectorFamilyToken<Timeline<any>, string>;
16
16
  };
@@ -5,7 +5,7 @@ import type {
5
5
  TimelineToken,
6
6
  TransactionToken,
7
7
  TransactionUpdate,
8
- ƒn,
8
+ Func,
9
9
  } from "atom.io"
10
10
  import * as Internal from "atom.io/internal"
11
11
  import type { Timeline } from "atom.io/internal"
@@ -23,9 +23,9 @@ export const attachIntrospectionStates = (
23
23
  ): {
24
24
  atomIndex: ReadonlySelectorToken<AtomTokenIndex>
25
25
  selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>
26
- transactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>
26
+ transactionIndex: ReadonlySelectorToken<TransactionToken<Func>[]>
27
27
  findTransactionLogState: ReadonlySelectorFamilyToken<
28
- TransactionUpdate<ƒn>[],
28
+ TransactionUpdate<Func>[],
29
29
  string
30
30
  >
31
31
  timelineIndex: ReadonlySelectorToken<TimelineToken<any>[]>
@@ -1,4 +1,4 @@
1
- import type { ReadonlySelectorToken, TransactionToken, ƒn } from "atom.io"
1
+ import type { ReadonlySelectorToken, TransactionToken, Func } from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
3
  import {
4
4
  IMPLICIT,
@@ -8,14 +8,14 @@ import {
8
8
 
9
9
  export const attachTransactionIndex = (
10
10
  store: Store = IMPLICIT.STORE,
11
- ): ReadonlySelectorToken<TransactionToken<ƒn>[]> => {
11
+ ): ReadonlySelectorToken<TransactionToken<Func>[]> => {
12
12
  const transactionTokenIndexState__INTERNAL = createRegularAtom<
13
- TransactionToken<ƒn>[]
13
+ TransactionToken<Func>[]
14
14
  >(
15
15
  {
16
16
  key: `👁‍🗨 Transaction Token Index (Internal)`,
17
17
  default: () =>
18
- [...store.transactions].map(([key]): TransactionToken<ƒn> => {
18
+ [...store.transactions].map(([key]): TransactionToken<Func> => {
19
19
  return { key, type: `transaction` }
20
20
  }),
21
21
  effects: [
@@ -1,4 +1,8 @@
1
- import type { ReadonlySelectorFamilyToken, TransactionUpdate, ƒn } from "atom.io"
1
+ import type {
2
+ ReadonlySelectorFamilyToken,
3
+ TransactionUpdate,
4
+ Func,
5
+ } from "atom.io"
2
6
  import type { Store } from "atom.io/internal"
3
7
  import {
4
8
  IMPLICIT,
@@ -8,9 +12,9 @@ import {
8
12
 
9
13
  export const attachTransactionLogs = (
10
14
  store: Store = IMPLICIT.STORE,
11
- ): ReadonlySelectorFamilyToken<TransactionUpdate<ƒn>[], string> => {
15
+ ): ReadonlySelectorFamilyToken<TransactionUpdate<Func>[], string> => {
12
16
  const findTransactionUpdateLog = createRegularAtomFamily<
13
- TransactionUpdate<ƒn>[],
17
+ TransactionUpdate<Func>[],
14
18
  string
15
19
  >(
16
20
  {
@@ -30,7 +34,7 @@ export const attachTransactionLogs = (
30
34
  store,
31
35
  )
32
36
  const findTransactionUpdateLogState = createSelectorFamily<
33
- TransactionUpdate<ƒn>[],
37
+ TransactionUpdate<Func>[],
34
38
  string
35
39
  >(
36
40
  {
@@ -49,7 +49,9 @@ var selectJson = (atom, transform, store = internal.IMPLICIT.STORE) => {
49
49
  {
50
50
  key: `${atom.key}:JSON`,
51
51
  get: ({ get }) => transform.toJson(get(atom)),
52
- set: ({ set }, newValue) => set(atom, transform.fromJson(newValue))
52
+ set: ({ set }, newValue) => {
53
+ set(atom, transform.fromJson(newValue));
54
+ }
53
55
  },
54
56
  store
55
57
  );
@@ -59,7 +61,9 @@ function selectJsonFamily(atomFamily, transform, store = internal.IMPLICIT.STORE
59
61
  {
60
62
  key: `${atomFamily.key}:JSON`,
61
63
  get: (key) => ({ get }) => transform.toJson(get(atomFamily(key))),
62
- set: (key) => ({ set }, newValue) => set(atomFamily(key), transform.fromJson(newValue))
64
+ set: (key) => ({ set }, newValue) => {
65
+ set(atomFamily(key), transform.fromJson(newValue));
66
+ }
63
67
  },
64
68
  store
65
69
  );
@@ -8,7 +8,9 @@ var selectJson = (atom, transform, store = IMPLICIT.STORE) => {
8
8
  {
9
9
  key: `${atom.key}:JSON`,
10
10
  get: ({ get }) => transform.toJson(get(atom)),
11
- set: ({ set }, newValue) => set(atom, transform.fromJson(newValue))
11
+ set: ({ set }, newValue) => {
12
+ set(atom, transform.fromJson(newValue));
13
+ }
12
14
  },
13
15
  store
14
16
  );
@@ -18,7 +20,9 @@ function selectJsonFamily(atomFamily, transform, store = IMPLICIT.STORE) {
18
20
  {
19
21
  key: `${atomFamily.key}:JSON`,
20
22
  get: (key) => ({ get }) => transform.toJson(get(atomFamily(key))),
21
- set: (key) => ({ set }, newValue) => set(atomFamily(key), transform.fromJson(newValue))
23
+ set: (key) => ({ set }, newValue) => {
24
+ set(atomFamily(key), transform.fromJson(newValue));
25
+ }
22
26
  },
23
27
  store
24
28
  );
@@ -43,8 +43,9 @@ export function selectJsonFamily<
43
43
  transform.toJson(get(atomFamily(key))),
44
44
  set:
45
45
  (key) =>
46
- ({ set }, newValue) =>
47
- set(atomFamily(key), transform.fromJson(newValue)),
46
+ ({ set }, newValue) => {
47
+ set(atomFamily(key), transform.fromJson(newValue))
48
+ },
48
49
  },
49
50
  store,
50
51
  )
@@ -14,7 +14,9 @@ export const selectJson = <T, J extends Json.Serializable>(
14
14
  {
15
15
  key: `${atom.key}:JSON`,
16
16
  get: ({ get }) => transform.toJson(get(atom)),
17
- set: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),
17
+ set: ({ set }, newValue) => {
18
+ set(atom, transform.fromJson(newValue))
19
+ },
18
20
  },
19
21
  store,
20
22
  )