atom.io 0.40.0 → 0.40.1

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 (82) hide show
  1. package/dist/internal/index.d.ts +67 -62
  2. package/dist/internal/index.d.ts.map +1 -1
  3. package/dist/internal/index.js +81 -93
  4. package/dist/internal/index.js.map +1 -1
  5. package/dist/introspection/index.d.ts +2 -2
  6. package/dist/introspection/index.d.ts.map +1 -1
  7. package/dist/introspection/index.js.map +1 -1
  8. package/dist/main/index.d.ts +14 -11
  9. package/dist/main/index.d.ts.map +1 -1
  10. package/dist/main/index.js +16 -13
  11. package/dist/main/index.js.map +1 -1
  12. package/dist/react/index.d.ts +3 -3
  13. package/dist/react/index.d.ts.map +1 -1
  14. package/dist/react/index.js.map +1 -1
  15. package/dist/react-devtools/index.js +1 -1
  16. package/dist/react-devtools/index.js.map +1 -1
  17. package/dist/realtime-client/index.d.ts +3 -3
  18. package/dist/realtime-client/index.d.ts.map +1 -1
  19. package/dist/realtime-client/index.js +3 -4
  20. package/dist/realtime-client/index.js.map +1 -1
  21. package/dist/realtime-server/index.d.ts +2 -2
  22. package/dist/realtime-server/index.d.ts.map +1 -1
  23. package/package.json +2 -2
  24. package/src/internal/atom/create-regular-atom.ts +3 -2
  25. package/src/internal/atom/dispose-atom.ts +6 -6
  26. package/src/internal/families/create-readonly-held-selector-family.ts +3 -4
  27. package/src/internal/families/create-readonly-pure-selector-family.ts +4 -9
  28. package/src/internal/families/create-regular-atom-family.ts +3 -4
  29. package/src/internal/families/create-selector-family.ts +6 -6
  30. package/src/internal/families/create-writable-held-selector-family.ts +2 -2
  31. package/src/internal/families/create-writable-pure-selector-family.ts +3 -7
  32. package/src/internal/families/dispose-from-store.ts +9 -2
  33. package/src/internal/get-state/get-from-store.ts +10 -3
  34. package/src/internal/index.ts +8 -8
  35. package/src/internal/install-into-store.ts +2 -1
  36. package/src/internal/join/create-join.ts +2 -2
  37. package/src/internal/join/find-relations-in-store.ts +2 -2
  38. package/src/internal/join/get-internal-relations-from-store.ts +2 -2
  39. package/src/internal/join/get-join.ts +5 -2
  40. package/src/internal/join/join-internal.ts +15 -20
  41. package/src/internal/lineage.ts +12 -1
  42. package/src/internal/molecule.ts +64 -36
  43. package/src/internal/mutable/create-mutable-atom-family.ts +4 -4
  44. package/src/internal/mutable/create-mutable-atom.ts +2 -2
  45. package/src/internal/mutable/tracker-family.ts +3 -3
  46. package/src/internal/selector/create-readonly-held-selector.ts +2 -2
  47. package/src/internal/selector/create-readonly-pure-selector.ts +2 -2
  48. package/src/internal/selector/create-writable-held-selector.ts +2 -2
  49. package/src/internal/selector/create-writable-pure-selector.ts +2 -2
  50. package/src/internal/set-state/become.ts +1 -3
  51. package/src/internal/set-state/dispatch-state-update.ts +1 -1
  52. package/src/internal/set-state/reset-in-store.ts +11 -13
  53. package/src/internal/set-state/set-into-store.ts +27 -3
  54. package/src/internal/store/store.ts +14 -12
  55. package/src/internal/timeline/create-timeline.ts +6 -5
  56. package/src/internal/timeline/time-travel.ts +4 -3
  57. package/src/internal/transaction/abort-transaction.ts +3 -15
  58. package/src/internal/transaction/act-upon-store.ts +1 -5
  59. package/src/internal/transaction/apply-transaction.ts +3 -15
  60. package/src/internal/transaction/assign-transaction-to-continuity.ts +2 -7
  61. package/src/internal/transaction/build-transaction.ts +2 -3
  62. package/src/internal/transaction/create-transaction.ts +5 -6
  63. package/src/internal/transaction/get-epoch-number.ts +1 -7
  64. package/src/internal/transaction/set-epoch-number.ts +4 -12
  65. package/src/introspection/attach-introspection-states.ts +4 -2
  66. package/src/introspection/attach-timeline-family.ts +2 -2
  67. package/src/introspection/attach-transaction-logs.ts +2 -2
  68. package/src/introspection/attach-type-selectors.ts +2 -2
  69. package/src/main/dispose-state.ts +1 -5
  70. package/src/main/events.ts +1 -3
  71. package/src/main/get-state.ts +3 -6
  72. package/src/main/realm.ts +36 -12
  73. package/src/main/reset-state.ts +1 -5
  74. package/src/main/set-state.ts +4 -11
  75. package/src/main/silo.ts +4 -3
  76. package/src/react/store-context.tsx +3 -3
  77. package/src/react-devtools/Button.tsx +3 -2
  78. package/src/react-devtools/TimelineIndex.tsx +0 -2
  79. package/src/react-devtools/store.ts +2 -2
  80. package/src/realtime-client/continuity/register-and-attempt-confirmed-update.ts +4 -8
  81. package/src/realtime-client/sync-continuity.ts +2 -2
  82. package/src/realtime-server/index.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["optimisticUpdateQueue","confirmedUpdateQueue","continuityEpoch: number | undefined","k: any","v: any","unsubscribes: Array<() => void>","unsubscribes: Array<() => void>","myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined>","myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined>","myUsernameState: AtomIO.RegularAtomToken<string | null>","optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","optimisticUpdateQueue","confirmedUpdateQueue","k: any","v: any"],"sources":["../../src/realtime-client/continuity/register-and-attempt-confirmed-update.ts","../../src/realtime-client/continuity/use-conceal-state.ts","../../src/realtime-client/continuity/use-reveal-state.ts","../../src/realtime-client/pull-atom.ts","../../src/realtime-client/pull-atom-family-member.ts","../../src/realtime-client/pull-mutable-atom.ts","../../src/realtime-client/pull-mutable-atom-family-member.ts","../../src/realtime-client/pull-selector.ts","../../src/realtime-client/pull-selector-family-member.ts","../../src/realtime-client/push-state.ts","../../src/realtime-client/realtime-client-stores/client-main-store.ts","../../src/realtime-client/realtime-client-stores/client-sync-store.ts","../../src/realtime-client/server-action.ts","../../src/realtime-client/sync-continuity.ts"],"sourcesContent":["import type * as AtomIO from \"atom.io\"\nimport type { Fn, Store } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tgetEpochNumberOfContinuity,\n\tingestTransactionOutcomeEvent,\n\tisRootStore,\n\tsetEpochNumberOfContinuity,\n\tsetIntoStore,\n} from \"atom.io/internal\"\nimport {\n\tconfirmedUpdateQueue,\n\toptimisticUpdateQueue,\n} from \"atom.io/realtime-client\"\nimport type { Socket } from \"atom.io/realtime-server\"\n\nexport const useRegisterAndAttemptConfirmedUpdate =\n\t(\n\t\tstore: Store,\n\t\tcontinuityKey: string,\n\t\tsocket: Socket,\n\t\toptimisticUpdates: AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t\tconfirmedUpdates: AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t) =>\n\t(\n\t\tconfirmed: AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>>,\n\t): void => {\n\t\tfunction reconcileEpoch(\n\t\t\toptimisticUpdate: AtomIO.TransactionOutcomeEvent<\n\t\t\t\tAtomIO.TransactionToken<Fn>\n\t\t\t>,\n\t\t\tconfirmedUpdate: AtomIO.TransactionOutcomeEvent<\n\t\t\t\tAtomIO.TransactionToken<Fn>\n\t\t\t>,\n\t\t): void {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`reconciling updates`,\n\t\t\t)\n\t\t\tsetIntoStore(store, optimisticUpdateQueue, (queue) => {\n\t\t\t\tqueue.shift()\n\t\t\t\treturn queue\n\t\t\t})\n\t\t\tif (optimisticUpdate.id === confirmedUpdate.id) {\n\t\t\t\tconst clientResult = JSON.stringify(optimisticUpdate.subEvents)\n\t\t\t\tconst serverResult = JSON.stringify(confirmedUpdate.subEvents)\n\t\t\t\tif (clientResult === serverResult) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`✅`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`results for ${optimisticUpdate.id} match between client and server`,\n\t\t\t\t\t)\n\t\t\t\t\tsocket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// id mismatch\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`❌`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`thought update #${confirmedUpdate.epoch} was ${optimisticUpdate.token.key}:${optimisticUpdate.id}, but it was actually ${confirmedUpdate.token.key}:${confirmedUpdate.id}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`updates do not match`,\n\t\t\t\toptimisticUpdate,\n\t\t\t\tconfirmedUpdate,\n\t\t\t)\n\t\t\tconst reversedOptimisticUpdates = optimisticUpdates.toReversed()\n\t\t\tfor (const subsequentOptimistic of reversedOptimisticUpdates) {\n\t\t\t\tingestTransactionOutcomeEvent(store, subsequentOptimistic, `oldValue`)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⏪`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`undid optimistic updates:`,\n\t\t\t\treversedOptimisticUpdates,\n\t\t\t)\n\t\t\tingestTransactionOutcomeEvent(store, optimisticUpdate, `oldValue`)\n\t\t\tstore.logger.info(\n\t\t\t\t`⏪`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`undid zeroth optimistic update`,\n\t\t\t\toptimisticUpdate,\n\t\t\t)\n\t\t\tingestTransactionOutcomeEvent(store, confirmedUpdate, `newValue`)\n\t\t\tstore.logger.info(\n\t\t\t\t`⏩`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`applied confirmed update`,\n\t\t\t\tconfirmedUpdate,\n\t\t\t)\n\t\t\tsocket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch)\n\n\t\t\tfor (const subsequentOptimistic of optimisticUpdates) {\n\t\t\t\tconst token = {\n\t\t\t\t\ttype: `transaction`,\n\t\t\t\t\tkey: subsequentOptimistic.token.key,\n\t\t\t\t} as const\n\t\t\t\tconst { id, params } = subsequentOptimistic\n\t\t\t\tactUponStore(store, token, id)(...params)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⏩`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`reapplied subsequent optimistic updates:`,\n\t\t\t\toptimisticUpdates,\n\t\t\t)\n\t\t}\n\n\t\tstore.logger.info(\n\t\t\t`🧑‍⚖️`,\n\t\t\t`continuity`,\n\t\t\tcontinuityKey,\n\t\t\t`integrating confirmed update`,\n\t\t\t{ confirmedUpdate: confirmed, confirmedUpdates, optimisticUpdates },\n\t\t)\n\t\tconst zerothOptimisticUpdate = optimisticUpdates[0]\n\t\tif (zerothOptimisticUpdate) {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`has optimistic updates to reconcile`,\n\t\t\t)\n\t\t\tif (confirmed.epoch === zerothOptimisticUpdate.epoch) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`epoch of confirmed update #${confirmed.epoch} matches zeroth optimistic update`,\n\t\t\t\t)\n\t\t\t\treconcileEpoch(zerothOptimisticUpdate, confirmed)\n\t\t\t\tfor (const nextConfirmed of confirmedUpdates) {\n\t\t\t\t\tconst nextOptimistic = optimisticUpdates[0]\n\t\t\t\t\tif (nextConfirmed.epoch === nextOptimistic?.epoch) {\n\t\t\t\t\t\treconcileEpoch(nextOptimistic, nextConfirmed)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// epoch mismatch\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`,\n\t\t\t\t)\n\t\t\t\tconst confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(\n\t\t\t\t\t(update) => update.epoch === confirmed.epoch,\n\t\t\t\t)\n\t\t\t\tif (!confirmedUpdateIsAlreadyEnqueued) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👈`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`pushing confirmed update to queue`,\n\t\t\t\t\t\tconfirmed,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, confirmedUpdateQueue, (queue) => {\n\t\t\t\t\t\tqueue.push(confirmed)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`has no optimistic updates to deal with`,\n\t\t\t)\n\t\t\tconst isRoot = isRootStore(store)\n\t\t\tlet continuityEpoch: number | undefined\n\t\t\tif (isRoot) {\n\t\t\t\tcontinuityEpoch = getEpochNumberOfContinuity(store, continuityKey)\n\t\t\t}\n\n\t\t\tif (continuityEpoch === confirmed.epoch - 1) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`✅`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`integrating update #${confirmed.epoch} (${confirmed.token.key} ${confirmed.id})`,\n\t\t\t\t)\n\t\t\t\tingestTransactionOutcomeEvent(store, confirmed, `newValue`)\n\t\t\t\tsocket.emit(`ack:${continuityKey}`, confirmed.epoch)\n\t\t\t\tsetEpochNumberOfContinuity(store, continuityKey, confirmed.epoch)\n\t\t\t} else if (isRoot && continuityEpoch !== undefined) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`received update #${confirmed.epoch} but still waiting for update #${\n\t\t\t\t\t\tcontinuityEpoch + 1\n\t\t\t\t\t}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tclientEpoch: continuityEpoch,\n\t\t\t\t\t\tserverEpoch: confirmed.epoch,\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tconst confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(\n\t\t\t\t\t(update) => update.epoch === confirmed.epoch,\n\t\t\t\t)\n\t\t\t\tif (confirmedUpdateIsAlreadyEnqueued) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👍`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`confirmed update #${confirmed.epoch} is already enqueued`,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👈`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`pushing confirmed update #${confirmed.epoch} to queue`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, confirmedUpdateQueue, (queue) => {\n\t\t\t\t\t\tqueue.push(confirmed)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n","import type { AtomToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { disposeAtom } from \"atom.io/internal\"\n\nexport function useConcealState(store: Store) {\n\treturn (concealed: AtomToken<unknown>[]): void => {\n\t\tfor (const token of concealed) {\n\t\t\tdisposeAtom(store, token)\n\t\t}\n\t}\n}\n","import { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nexport function useRevealState(store: Store) {\n\treturn (revealed: Json.Array): void => {\n\t\tlet i = 0\n\t\tlet k: any\n\t\tlet v: any\n\t\tfor (const x of revealed) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\tk = x\n\t\t\t} else {\n\t\t\t\tv = x\n\t\t\t\tsetIntoStore(store, k, v)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullAtom<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.RegularAtomToken<J>,\n): () => void {\n\tconst setServedValue = (data: J) => {\n\t\tsetIntoStore(store, token, data)\n\t}\n\tsocket.on(`serve:${token.key}`, setServedValue)\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`, setServedValue)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { parseJson } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\n/* eslint-disable no-console */\n\nexport function pullAtomFamilyMember<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.RegularAtomToken<J>,\n): () => void {\n\tif (!(`family` in token)) {\n\t\tconsole.error(`Token is not a family member:`, token)\n\t\treturn () => {}\n\t}\n\tconst { key: familyKey, subKey: serializedSubKey } = token.family\n\tconst subKey = parseJson(serializedSubKey)\n\tsocket?.on(`serve:${token.key}`, (data: J) => {\n\t\tsetIntoStore(store, token, data)\n\t})\n\tsocket?.emit(`sub:${familyKey}`, subKey)\n\treturn () => {\n\t\tsocket?.off(`serve:${token.key}`)\n\t\tsocket?.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { AsJSON, SignalFrom, Store, Transceiver } from \"atom.io/internal\"\nimport { getJsonToken, getUpdateToken, setIntoStore } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullMutableAtom<T extends Transceiver<any, any, any>>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.MutableAtomToken<T>,\n): () => void {\n\tconst jsonToken = getJsonToken(store, token)\n\tconst updateToken = getUpdateToken(token)\n\tsocket.on(`init:${token.key}`, (data: AsJSON<T>) => {\n\t\tsetIntoStore(store, jsonToken, data)\n\t})\n\tsocket.on(`next:${token.key}`, (data: SignalFrom<T>) => {\n\t\tsetIntoStore(store, updateToken, data)\n\t})\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`init:${token.key}`)\n\t\tsocket.off(`next:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { AsJSON, SignalFrom, Store, Transceiver } from \"atom.io/internal\"\nimport { getJsonToken, getUpdateToken, setIntoStore } from \"atom.io/internal\"\nimport { parseJson } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\n/* eslint-disable no-console */\n\nexport function pullMutableAtomFamilyMember<\n\tT extends Transceiver<any, any, any>,\n>(store: Store, socket: Socket, token: AtomIO.MutableAtomToken<T>): () => void {\n\tif (!(`family` in token)) {\n\t\tconsole.error(`Token is not a family member:`, token)\n\t\treturn () => {}\n\t}\n\tconst { key: familyKey, subKey: serializedSubKey } = token.family\n\tconst subKey = parseJson(serializedSubKey)\n\tsocket.on(`init:${token.key}`, (data: AsJSON<T>) => {\n\t\tconst jsonToken = getJsonToken(store, token)\n\t\tsetIntoStore(store, jsonToken, data)\n\t})\n\tsocket.on(`next:${token.key}`, (data: SignalFrom<T>) => {\n\t\tconst trackerToken = getUpdateToken(token)\n\t\tsetIntoStore(store, trackerToken, data)\n\t})\n\tsocket.emit(`sub:${familyKey}`, subKey)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { pullAtom } from \"./pull-atom\"\nimport { pullMutableAtom } from \"./pull-mutable-atom\"\n\nexport function pullSelector<T>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.SelectorToken<T>,\n): () => void {\n\tconst atomKeys = store.selectorAtoms.getRelatedKeys(token.key)\n\tconst unsubscribes: Array<() => void> = []\n\tif (atomKeys) {\n\t\tfor (const atomKey of atomKeys) {\n\t\t\tconst atom = store.atoms.get(atomKey)\n\t\t\tif (!atom) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch (atom.type) {\n\t\t\t\tcase `atom`: {\n\t\t\t\t\tunsubscribes.push(pullAtom(store, socket, atom))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase `mutable_atom`: {\n\t\t\t\t\tunsubscribes.push(pullMutableAtom(store, socket, atom))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn () => {\n\t\tfor (const unsubscribe of unsubscribes) {\n\t\t\tunsubscribe()\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { pullAtomFamilyMember } from \"./pull-atom-family-member\"\nimport { pullMutableAtomFamilyMember } from \"./pull-mutable-atom-family-member\"\n\n/* eslint-disable no-console */\n\nexport function pullSelectorFamilyMember<T>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.SelectorToken<T>,\n): () => void {\n\tif (!(`family` in token)) {\n\t\tconsole.error(`Token is not a family member:`, token)\n\t\treturn () => {}\n\t}\n\tconst atomKeys = store.selectorAtoms.getRelatedKeys(token.key)\n\tconst unsubscribes: Array<() => void> = []\n\tif (atomKeys) {\n\t\tfor (const atomKey of atomKeys) {\n\t\t\tconst atom = store.atoms.get(atomKey)\n\t\t\tif (!atom) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch (atom.type) {\n\t\t\t\tcase `atom`: {\n\t\t\t\t\tunsubscribes.push(pullAtomFamilyMember(store, socket, atom))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase `mutable_atom`: {\n\t\t\t\t\tunsubscribes.push(pullMutableAtomFamilyMember(store, socket, atom))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn () => {\n\t\tfor (const unsubscribe of unsubscribes) {\n\t\t\tunsubscribe()\n\t\t}\n\t}\n}\n","import type { WritableToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { subscribeToState } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pushState<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: WritableToken<J>,\n): () => void {\n\tsocket.emit(`claim:${token.key}`)\n\tsubscribeToState(store, token, `push`, ({ newValue }) => {\n\t\tsocket.emit(`pub:${token.key}`, newValue)\n\t})\n\treturn () => {\n\t\tsocket.off(`pub:${token.key}`)\n\t\tsocket.emit(`unclaim:${token.key}`)\n\t}\n}\n","import * as AtomIO from \"atom.io\"\nimport { persistSync } from \"atom.io/web\"\n\nexport const myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined> =\n\tAtomIO.atom<string | undefined>({\n\t\tkey: `mySocketId__INTERNAL`,\n\t\tdefault: undefined,\n\t})\nexport const myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined> =\n\tAtomIO.selector<string | undefined>({\n\t\tkey: `mySocketId`,\n\t\tget: ({ get }) => get(myIdState__INTERNAL),\n\t})\n\nexport const myUsernameState: AtomIO.RegularAtomToken<string | null> =\n\tAtomIO.atom<string | null>({\n\t\tkey: `myName`,\n\t\tdefault: null,\n\t\teffects:\n\t\t\ttypeof window === `undefined`\n\t\t\t\t? []\n\t\t\t\t: [persistSync(window.localStorage, JSON, `myUsername`)],\n\t})\n","import * as AtomIO from \"atom.io\"\n\nexport const optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `updateQueue`,\n\tdefault: () => [],\n})\n\nexport const confirmedUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `serverConfirmedUpdateQueue`,\n\tdefault: () => [],\n})\n","import type * as AtomIO from \"atom.io\"\nimport type { Fn, Store } from \"atom.io/internal\"\nimport { subscribeToTransaction } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function serverAction<F extends Fn>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.TransactionToken<F>,\n): () => void {\n\tconst unsubscribeFromLocalUpdates = subscribeToTransaction(\n\t\tstore,\n\t\ttoken,\n\t\t`tx-run:${token.key}:${socket.id}`,\n\t\t(clientUpdate) => {\n\t\t\tsocket.emit(`tx-run:${token.key}`, clientUpdate)\n\t\t},\n\t)\n\n\treturn () => {\n\t\tunsubscribeFromLocalUpdates()\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tassignTransactionToContinuity,\n\tgetFromStore,\n\tgetJsonToken,\n\tsetEpochNumberOfContinuity,\n\tsetIntoStore,\n\tsubscribeToTransaction,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\nimport {\n\tconfirmedUpdateQueue,\n\toptimisticUpdateQueue,\n} from \"atom.io/realtime-client\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { useRegisterAndAttemptConfirmedUpdate } from \"./continuity/register-and-attempt-confirmed-update\"\nimport { useConcealState } from \"./continuity/use-conceal-state\"\nimport { useRevealState } from \"./continuity/use-reveal-state\"\n\nexport function syncContinuity(\n\tstore: Store,\n\tsocket: Socket,\n\tcontinuity: ContinuityToken,\n): () => void {\n\tconst continuityKey = continuity.key\n\tconst optimisticUpdates = getFromStore(store, optimisticUpdateQueue)\n\tconst confirmedUpdates = getFromStore(store, confirmedUpdateQueue)\n\n\tconst initializeContinuity = (epoch: number, payload: Json.Array) => {\n\t\tsocket.off(`continuity-init:${continuityKey}`, initializeContinuity)\n\t\tlet i = 0\n\t\tlet k: any\n\t\tlet v: any\n\t\tfor (const x of payload) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\tk = x\n\t\t\t} else {\n\t\t\t\tv = x\n\t\t\t\tif (`type` in k && k.type === `mutable_atom`) {\n\t\t\t\t\tk = getJsonToken(store, k)\n\t\t\t\t}\n\t\t\t\tsetIntoStore(store, k, v)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t\tsetEpochNumberOfContinuity(store, continuityKey, epoch)\n\t}\n\tsocket.off(`continuity-init:${continuityKey}`)\n\tsocket.on(`continuity-init:${continuityKey}`, initializeContinuity)\n\n\tconst registerAndAttemptConfirmedUpdate = useRegisterAndAttemptConfirmedUpdate(\n\t\tstore,\n\t\tcontinuityKey,\n\t\tsocket,\n\t\toptimisticUpdates,\n\t\tconfirmedUpdates,\n\t)\n\tsocket.off(`tx-new:${continuityKey}`)\n\tsocket.on(`tx-new:${continuityKey}`, registerAndAttemptConfirmedUpdate)\n\n\tconst unsubscribeFunctions = continuity.actions.map((transaction) => {\n\t\tassignTransactionToContinuity(store, continuityKey, transaction.key)\n\t\tconst unsubscribeFromTransactionUpdates = subscribeToTransaction(\n\t\t\tstore,\n\t\t\ttransaction,\n\t\t\t`tx-run:${continuityKey}`,\n\t\t\t(clientUpdate) => {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🤞`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`enqueuing optimistic update`,\n\t\t\t\t)\n\t\t\t\tconst optimisticUpdateIndex = optimisticUpdates.findIndex(\n\t\t\t\t\t(update) => update.id === clientUpdate.id,\n\t\t\t\t)\n\t\t\t\tif (optimisticUpdateIndex === -1) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🤞`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`enqueuing new optimistic update`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, optimisticUpdateQueue, (queue) => {\n\t\t\t\t\t\tqueue.push(clientUpdate)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🤞`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`replacing existing optimistic update at index ${optimisticUpdateIndex}`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, optimisticUpdateQueue, (queue) => {\n\t\t\t\t\t\tqueue[optimisticUpdateIndex] = clientUpdate\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tsocket.emit(`tx-run:${continuityKey}`, {\n\t\t\t\t\tid: clientUpdate.id,\n\t\t\t\t\ttoken: transaction,\n\t\t\t\t\tparams: clientUpdate.params,\n\t\t\t\t})\n\t\t\t},\n\t\t)\n\t\treturn unsubscribeFromTransactionUpdates\n\t})\n\n\tconst revealState = useRevealState(store)\n\tconst concealState = useConcealState(store)\n\tsocket.on(`reveal:${continuityKey}`, revealState)\n\tsocket.on(`conceal:${continuityKey}`, concealState)\n\n\tsocket.emit(`get:${continuityKey}`)\n\treturn () => {\n\t\tsocket.off(`continuity-init:${continuityKey}`)\n\t\tsocket.off(`tx-new:${continuityKey}`)\n\t\tfor (const unsubscribe of unsubscribeFunctions) unsubscribe()\n\t\t// socket.emit(`unsub:${continuityKey}`)\n\t}\n}\n"],"mappings":";;;;;;;AAgBA,MAAa,wCAEX,OACA,eACA,QACA,mBAGA,sBAKA,cACU;CACV,SAAS,eACR,kBAGA,iBAGO;AACP,QAAM,OAAO,KACZ,SACA,cACA,eACA;AAED,eAAa,OAAOA,0BAAwB,UAAU;AACrD,SAAM;AACN,UAAO;;AAER,MAAI,iBAAiB,OAAO,gBAAgB,IAAI;GAC/C,MAAM,eAAe,KAAK,UAAU,iBAAiB;GACrD,MAAM,eAAe,KAAK,UAAU,gBAAgB;AACpD,OAAI,iBAAiB,cAAc;AAClC,UAAM,OAAO,KACZ,KACA,cACA,eACA,eAAe,iBAAiB,GAAG;AAEpC,WAAO,KAAK,OAAO,iBAAiB,gBAAgB;AACpD;;QAID,OAAM,OAAO,KACZ,KACA,cACA,eACA,mBAAmB,gBAAgB,MAAM,OAAO,iBAAiB,MAAM,IAAI,GAAG,iBAAiB,GAAG,wBAAwB,gBAAgB,MAAM,IAAI,GAAG,gBAAgB;AAGzK,QAAM,OAAO,KACZ,SACA,cACA,eACA,wBACA,kBACA;EAED,MAAM,4BAA4B,kBAAkB;AACpD,OAAK,MAAM,wBAAwB,0BAClC,+BAA8B,OAAO,sBAAsB;AAE5D,QAAM,OAAO,KACZ,KACA,cACA,eACA,6BACA;AAED,gCAA8B,OAAO,kBAAkB;AACvD,QAAM,OAAO,KACZ,KACA,cACA,eACA,kCACA;AAED,gCAA8B,OAAO,iBAAiB;AACtD,QAAM,OAAO,KACZ,KACA,cACA,eACA,4BACA;AAED,SAAO,KAAK,OAAO,iBAAiB,gBAAgB;AAEpD,OAAK,MAAM,wBAAwB,mBAAmB;GACrD,MAAM,QAAQ;IACb,MAAM;IACN,KAAK,qBAAqB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AO,KACZ,MACA,cACA,eACA,iDAAiD;AAElD,iBAAa,OAAOA,0BAAwB,UAAU;AACrD,WAAM,yBAAyB;AAC/B,YAAO;;;AAGT,UAAO,KAAK,UAAU,iBAAiB;IACtC,IAAI,aAAa;IACjB,OAAO;IACP,QAAQ,aAAa;;;AAIxB,SAAO;;CAGR,MAAM,cAAc,eAAe;CACnC,MAAM,eAAe,gBAAgB;AACrC,QAAO,GAAG,UAAU,iBAAiB;AACrC,QAAO,GAAG,WAAW,iBAAiB;AAEtC,QAAO,KAAK,OAAO;AACnB,cAAa;AACZ,SAAO,IAAI,mBAAmB;AAC9B,SAAO,IAAI,UAAU;AACrB,OAAK,MAAM,eAAe,qBAAsB"}
1
+ {"version":3,"file":"index.js","names":["optimisticUpdateQueue","confirmedUpdateQueue","continuityEpoch: number | undefined","k: any","v: any","unsubscribes: Array<() => void>","unsubscribes: Array<() => void>","myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined>","myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined>","myUsernameState: AtomIO.RegularAtomToken<string | null>","optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","confirmedUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n>","optimisticUpdateQueue","confirmedUpdateQueue","k: any","v: any"],"sources":["../../src/realtime-client/continuity/register-and-attempt-confirmed-update.ts","../../src/realtime-client/continuity/use-conceal-state.ts","../../src/realtime-client/continuity/use-reveal-state.ts","../../src/realtime-client/pull-atom.ts","../../src/realtime-client/pull-atom-family-member.ts","../../src/realtime-client/pull-mutable-atom.ts","../../src/realtime-client/pull-mutable-atom-family-member.ts","../../src/realtime-client/pull-selector.ts","../../src/realtime-client/pull-selector-family-member.ts","../../src/realtime-client/push-state.ts","../../src/realtime-client/realtime-client-stores/client-main-store.ts","../../src/realtime-client/realtime-client-stores/client-sync-store.ts","../../src/realtime-client/server-action.ts","../../src/realtime-client/sync-continuity.ts"],"sourcesContent":["import type * as AtomIO from \"atom.io\"\nimport type { Fn, RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tgetEpochNumberOfContinuity,\n\tingestTransactionOutcomeEvent,\n\tsetEpochNumberOfContinuity,\n\tsetIntoStore,\n} from \"atom.io/internal\"\nimport {\n\tconfirmedUpdateQueue,\n\toptimisticUpdateQueue,\n} from \"atom.io/realtime-client\"\nimport type { Socket } from \"atom.io/realtime-server\"\n\nexport const useRegisterAndAttemptConfirmedUpdate =\n\t(\n\t\tstore: RootStore,\n\t\tcontinuityKey: string,\n\t\tsocket: Socket,\n\t\toptimisticUpdates: AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t\tconfirmedUpdates: AtomIO.TransactionOutcomeEvent<\n\t\t\tAtomIO.TransactionToken<Fn>\n\t\t>[],\n\t) =>\n\t(\n\t\tconfirmed: AtomIO.TransactionOutcomeEvent<AtomIO.TransactionToken<Fn>>,\n\t): void => {\n\t\tfunction reconcileEpoch(\n\t\t\toptimisticUpdate: AtomIO.TransactionOutcomeEvent<\n\t\t\t\tAtomIO.TransactionToken<Fn>\n\t\t\t>,\n\t\t\tconfirmedUpdate: AtomIO.TransactionOutcomeEvent<\n\t\t\t\tAtomIO.TransactionToken<Fn>\n\t\t\t>,\n\t\t): void {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`reconciling updates`,\n\t\t\t)\n\t\t\tsetIntoStore(store, optimisticUpdateQueue, (queue) => {\n\t\t\t\tqueue.shift()\n\t\t\t\treturn queue\n\t\t\t})\n\t\t\tif (optimisticUpdate.id === confirmedUpdate.id) {\n\t\t\t\tconst clientResult = JSON.stringify(optimisticUpdate.subEvents)\n\t\t\t\tconst serverResult = JSON.stringify(confirmedUpdate.subEvents)\n\t\t\t\tif (clientResult === serverResult) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`✅`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`results for ${optimisticUpdate.id} match between client and server`,\n\t\t\t\t\t)\n\t\t\t\t\tsocket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// id mismatch\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`❌`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`thought update #${confirmedUpdate.epoch} was ${optimisticUpdate.token.key}:${optimisticUpdate.id}, but it was actually ${confirmedUpdate.token.key}:${confirmedUpdate.id}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`updates do not match`,\n\t\t\t\toptimisticUpdate,\n\t\t\t\tconfirmedUpdate,\n\t\t\t)\n\t\t\tconst reversedOptimisticUpdates = optimisticUpdates.toReversed()\n\t\t\tfor (const subsequentOptimistic of reversedOptimisticUpdates) {\n\t\t\t\tingestTransactionOutcomeEvent(store, subsequentOptimistic, `oldValue`)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⏪`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`undid optimistic updates:`,\n\t\t\t\treversedOptimisticUpdates,\n\t\t\t)\n\t\t\tingestTransactionOutcomeEvent(store, optimisticUpdate, `oldValue`)\n\t\t\tstore.logger.info(\n\t\t\t\t`⏪`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`undid zeroth optimistic update`,\n\t\t\t\toptimisticUpdate,\n\t\t\t)\n\t\t\tingestTransactionOutcomeEvent(store, confirmedUpdate, `newValue`)\n\t\t\tstore.logger.info(\n\t\t\t\t`⏩`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`applied confirmed update`,\n\t\t\t\tconfirmedUpdate,\n\t\t\t)\n\t\t\tsocket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch)\n\n\t\t\tfor (const subsequentOptimistic of optimisticUpdates) {\n\t\t\t\tconst token = {\n\t\t\t\t\ttype: `transaction`,\n\t\t\t\t\tkey: subsequentOptimistic.token.key,\n\t\t\t\t} as const\n\t\t\t\tconst { id, params } = subsequentOptimistic\n\t\t\t\tactUponStore(store, token, id)(...params)\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⏩`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`reapplied subsequent optimistic updates:`,\n\t\t\t\toptimisticUpdates,\n\t\t\t)\n\t\t}\n\n\t\tstore.logger.info(\n\t\t\t`🧑‍⚖️`,\n\t\t\t`continuity`,\n\t\t\tcontinuityKey,\n\t\t\t`integrating confirmed update`,\n\t\t\t{ confirmedUpdate: confirmed, confirmedUpdates, optimisticUpdates },\n\t\t)\n\t\tconst zerothOptimisticUpdate = optimisticUpdates[0]\n\t\tif (zerothOptimisticUpdate) {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`has optimistic updates to reconcile`,\n\t\t\t)\n\t\t\tif (confirmed.epoch === zerothOptimisticUpdate.epoch) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`epoch of confirmed update #${confirmed.epoch} matches zeroth optimistic update`,\n\t\t\t\t)\n\t\t\t\treconcileEpoch(zerothOptimisticUpdate, confirmed)\n\t\t\t\tfor (const nextConfirmed of confirmedUpdates) {\n\t\t\t\t\tconst nextOptimistic = optimisticUpdates[0]\n\t\t\t\t\tif (nextConfirmed.epoch === nextOptimistic?.epoch) {\n\t\t\t\t\t\treconcileEpoch(nextOptimistic, nextConfirmed)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// epoch mismatch\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`,\n\t\t\t\t)\n\t\t\t\tconst confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(\n\t\t\t\t\t(update) => update.epoch === confirmed.epoch,\n\t\t\t\t)\n\t\t\t\tif (!confirmedUpdateIsAlreadyEnqueued) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👈`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`pushing confirmed update to queue`,\n\t\t\t\t\t\tconfirmed,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, confirmedUpdateQueue, (queue) => {\n\t\t\t\t\t\tqueue.push(confirmed)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tstore.logger.info(\n\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t`continuity`,\n\t\t\t\tcontinuityKey,\n\t\t\t\t`has no optimistic updates to deal with`,\n\t\t\t)\n\t\t\tlet continuityEpoch: number | undefined\n\t\t\tcontinuityEpoch = getEpochNumberOfContinuity(store, continuityKey)\n\n\t\t\tif (continuityEpoch === confirmed.epoch - 1) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`✅`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`integrating update #${confirmed.epoch} (${confirmed.token.key} ${confirmed.id})`,\n\t\t\t\t)\n\t\t\t\tingestTransactionOutcomeEvent(store, confirmed, `newValue`)\n\t\t\t\tsocket.emit(`ack:${continuityKey}`, confirmed.epoch)\n\t\t\t\tsetEpochNumberOfContinuity(store, continuityKey, confirmed.epoch)\n\t\t\t} else if (continuityEpoch !== undefined) {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🧑‍⚖️`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`received update #${confirmed.epoch} but still waiting for update #${\n\t\t\t\t\t\tcontinuityEpoch + 1\n\t\t\t\t\t}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tclientEpoch: continuityEpoch,\n\t\t\t\t\t\tserverEpoch: confirmed.epoch,\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tconst confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(\n\t\t\t\t\t(update) => update.epoch === confirmed.epoch,\n\t\t\t\t)\n\t\t\t\tif (confirmedUpdateIsAlreadyEnqueued) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👍`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`confirmed update #${confirmed.epoch} is already enqueued`,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`👈`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`pushing confirmed update #${confirmed.epoch} to queue`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, confirmedUpdateQueue, (queue) => {\n\t\t\t\t\t\tqueue.push(confirmed)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n","import type { AtomToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { disposeAtom } from \"atom.io/internal\"\n\nexport function useConcealState(store: Store) {\n\treturn (concealed: AtomToken<unknown>[]): void => {\n\t\tfor (const token of concealed) {\n\t\t\tdisposeAtom(store, token)\n\t\t}\n\t}\n}\n","import { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nexport function useRevealState(store: Store) {\n\treturn (revealed: Json.Array): void => {\n\t\tlet i = 0\n\t\tlet k: any\n\t\tlet v: any\n\t\tfor (const x of revealed) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\tk = x\n\t\t\t} else {\n\t\t\t\tv = x\n\t\t\t\tsetIntoStore(store, k, v)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullAtom<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.RegularAtomToken<J>,\n): () => void {\n\tconst setServedValue = (data: J) => {\n\t\tsetIntoStore(store, token, data)\n\t}\n\tsocket.on(`serve:${token.key}`, setServedValue)\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`, setServedValue)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport { setIntoStore, type Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { parseJson } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\n/* eslint-disable no-console */\n\nexport function pullAtomFamilyMember<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.RegularAtomToken<J>,\n): () => void {\n\tif (!(`family` in token)) {\n\t\tconsole.error(`Token is not a family member:`, token)\n\t\treturn () => {}\n\t}\n\tconst { key: familyKey, subKey: serializedSubKey } = token.family\n\tconst subKey = parseJson(serializedSubKey)\n\tsocket?.on(`serve:${token.key}`, (data: J) => {\n\t\tsetIntoStore(store, token, data)\n\t})\n\tsocket?.emit(`sub:${familyKey}`, subKey)\n\treturn () => {\n\t\tsocket?.off(`serve:${token.key}`)\n\t\tsocket?.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { AsJSON, SignalFrom, Store, Transceiver } from \"atom.io/internal\"\nimport { getJsonToken, getUpdateToken, setIntoStore } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullMutableAtom<T extends Transceiver<any, any, any>>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.MutableAtomToken<T>,\n): () => void {\n\tconst jsonToken = getJsonToken(store, token)\n\tconst updateToken = getUpdateToken(token)\n\tsocket.on(`init:${token.key}`, (data: AsJSON<T>) => {\n\t\tsetIntoStore(store, jsonToken, data)\n\t})\n\tsocket.on(`next:${token.key}`, (data: SignalFrom<T>) => {\n\t\tsetIntoStore(store, updateToken, data)\n\t})\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`init:${token.key}`)\n\t\tsocket.off(`next:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { AsJSON, SignalFrom, Store, Transceiver } from \"atom.io/internal\"\nimport { getJsonToken, getUpdateToken, setIntoStore } from \"atom.io/internal\"\nimport { parseJson } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\n/* eslint-disable no-console */\n\nexport function pullMutableAtomFamilyMember<\n\tT extends Transceiver<any, any, any>,\n>(store: Store, socket: Socket, token: AtomIO.MutableAtomToken<T>): () => void {\n\tif (!(`family` in token)) {\n\t\tconsole.error(`Token is not a family member:`, token)\n\t\treturn () => {}\n\t}\n\tconst { key: familyKey, subKey: serializedSubKey } = token.family\n\tconst subKey = parseJson(serializedSubKey)\n\tsocket.on(`init:${token.key}`, (data: AsJSON<T>) => {\n\t\tconst jsonToken = getJsonToken(store, token)\n\t\tsetIntoStore(store, jsonToken, data)\n\t})\n\tsocket.on(`next:${token.key}`, (data: SignalFrom<T>) => {\n\t\tconst trackerToken = getUpdateToken(token)\n\t\tsetIntoStore(store, trackerToken, data)\n\t})\n\tsocket.emit(`sub:${familyKey}`, subKey)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { pullAtom } from \"./pull-atom\"\nimport { pullMutableAtom } from \"./pull-mutable-atom\"\n\nexport function pullSelector<T>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.SelectorToken<T>,\n): () => void {\n\tconst atomKeys = store.selectorAtoms.getRelatedKeys(token.key)\n\tconst unsubscribes: Array<() => void> = []\n\tif (atomKeys) {\n\t\tfor (const atomKey of atomKeys) {\n\t\t\tconst atom = store.atoms.get(atomKey)\n\t\t\tif (!atom) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch (atom.type) {\n\t\t\t\tcase `atom`: {\n\t\t\t\t\tunsubscribes.push(pullAtom(store, socket, atom))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase `mutable_atom`: {\n\t\t\t\t\tunsubscribes.push(pullMutableAtom(store, socket, atom))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn () => {\n\t\tfor (const unsubscribe of unsubscribes) {\n\t\t\tunsubscribe()\n\t\t}\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { pullAtomFamilyMember } from \"./pull-atom-family-member\"\nimport { pullMutableAtomFamilyMember } from \"./pull-mutable-atom-family-member\"\n\n/* eslint-disable no-console */\n\nexport function pullSelectorFamilyMember<T>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.SelectorToken<T>,\n): () => void {\n\tif (!(`family` in token)) {\n\t\tconsole.error(`Token is not a family member:`, token)\n\t\treturn () => {}\n\t}\n\tconst atomKeys = store.selectorAtoms.getRelatedKeys(token.key)\n\tconst unsubscribes: Array<() => void> = []\n\tif (atomKeys) {\n\t\tfor (const atomKey of atomKeys) {\n\t\t\tconst atom = store.atoms.get(atomKey)\n\t\t\tif (!atom) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch (atom.type) {\n\t\t\t\tcase `atom`: {\n\t\t\t\t\tunsubscribes.push(pullAtomFamilyMember(store, socket, atom))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase `mutable_atom`: {\n\t\t\t\t\tunsubscribes.push(pullMutableAtomFamilyMember(store, socket, atom))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn () => {\n\t\tfor (const unsubscribe of unsubscribes) {\n\t\t\tunsubscribe()\n\t\t}\n\t}\n}\n","import type { WritableToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { subscribeToState } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pushState<J extends Json.Serializable>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: WritableToken<J>,\n): () => void {\n\tsocket.emit(`claim:${token.key}`)\n\tsubscribeToState(store, token, `push`, ({ newValue }) => {\n\t\tsocket.emit(`pub:${token.key}`, newValue)\n\t})\n\treturn () => {\n\t\tsocket.off(`pub:${token.key}`)\n\t\tsocket.emit(`unclaim:${token.key}`)\n\t}\n}\n","import * as AtomIO from \"atom.io\"\nimport { persistSync } from \"atom.io/web\"\n\nexport const myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined> =\n\tAtomIO.atom<string | undefined>({\n\t\tkey: `mySocketId__INTERNAL`,\n\t\tdefault: undefined,\n\t})\nexport const myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined> =\n\tAtomIO.selector<string | undefined>({\n\t\tkey: `mySocketId`,\n\t\tget: ({ get }) => get(myIdState__INTERNAL),\n\t})\n\nexport const myUsernameState: AtomIO.RegularAtomToken<string | null> =\n\tAtomIO.atom<string | null>({\n\t\tkey: `myName`,\n\t\tdefault: null,\n\t\teffects:\n\t\t\ttypeof window === `undefined`\n\t\t\t\t? []\n\t\t\t\t: [persistSync(window.localStorage, JSON, `myUsername`)],\n\t})\n","import * as AtomIO from \"atom.io\"\n\nexport const optimisticUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `updateQueue`,\n\tdefault: () => [],\n})\n\nexport const confirmedUpdateQueue: AtomIO.RegularAtomToken<\n\tAtomIO.TransactionOutcomeEvent<any>[]\n> = AtomIO.atom<AtomIO.TransactionOutcomeEvent<any>[]>({\n\tkey: `serverConfirmedUpdateQueue`,\n\tdefault: () => [],\n})\n","import type * as AtomIO from \"atom.io\"\nimport type { Fn, Store } from \"atom.io/internal\"\nimport { subscribeToTransaction } from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function serverAction<F extends Fn>(\n\tstore: Store,\n\tsocket: Socket,\n\ttoken: AtomIO.TransactionToken<F>,\n): () => void {\n\tconst unsubscribeFromLocalUpdates = subscribeToTransaction(\n\t\tstore,\n\t\ttoken,\n\t\t`tx-run:${token.key}:${socket.id}`,\n\t\t(clientUpdate) => {\n\t\t\tsocket.emit(`tx-run:${token.key}`, clientUpdate)\n\t\t},\n\t)\n\n\treturn () => {\n\t\tunsubscribeFromLocalUpdates()\n\t}\n}\n","import type { RootStore } from \"atom.io/internal\"\nimport {\n\tassignTransactionToContinuity,\n\tgetFromStore,\n\tgetJsonToken,\n\tsetEpochNumberOfContinuity,\n\tsetIntoStore,\n\tsubscribeToTransaction,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { ContinuityToken } from \"atom.io/realtime\"\nimport {\n\tconfirmedUpdateQueue,\n\toptimisticUpdateQueue,\n} from \"atom.io/realtime-client\"\nimport type { Socket } from \"socket.io-client\"\n\nimport { useRegisterAndAttemptConfirmedUpdate } from \"./continuity/register-and-attempt-confirmed-update\"\nimport { useConcealState } from \"./continuity/use-conceal-state\"\nimport { useRevealState } from \"./continuity/use-reveal-state\"\n\nexport function syncContinuity(\n\tstore: RootStore,\n\tsocket: Socket,\n\tcontinuity: ContinuityToken,\n): () => void {\n\tconst continuityKey = continuity.key\n\tconst optimisticUpdates = getFromStore(store, optimisticUpdateQueue)\n\tconst confirmedUpdates = getFromStore(store, confirmedUpdateQueue)\n\n\tconst initializeContinuity = (epoch: number, payload: Json.Array) => {\n\t\tsocket.off(`continuity-init:${continuityKey}`, initializeContinuity)\n\t\tlet i = 0\n\t\tlet k: any\n\t\tlet v: any\n\t\tfor (const x of payload) {\n\t\t\tif (i % 2 === 0) {\n\t\t\t\tk = x\n\t\t\t} else {\n\t\t\t\tv = x\n\t\t\t\tif (`type` in k && k.type === `mutable_atom`) {\n\t\t\t\t\tk = getJsonToken(store, k)\n\t\t\t\t}\n\t\t\t\tsetIntoStore(store, k, v)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t\tsetEpochNumberOfContinuity(store, continuityKey, epoch)\n\t}\n\tsocket.off(`continuity-init:${continuityKey}`)\n\tsocket.on(`continuity-init:${continuityKey}`, initializeContinuity)\n\n\tconst registerAndAttemptConfirmedUpdate = useRegisterAndAttemptConfirmedUpdate(\n\t\tstore,\n\t\tcontinuityKey,\n\t\tsocket,\n\t\toptimisticUpdates,\n\t\tconfirmedUpdates,\n\t)\n\tsocket.off(`tx-new:${continuityKey}`)\n\tsocket.on(`tx-new:${continuityKey}`, registerAndAttemptConfirmedUpdate)\n\n\tconst unsubscribeFunctions = continuity.actions.map((transaction) => {\n\t\tassignTransactionToContinuity(store, continuityKey, transaction.key)\n\t\tconst unsubscribeFromTransactionUpdates = subscribeToTransaction(\n\t\t\tstore,\n\t\t\ttransaction,\n\t\t\t`tx-run:${continuityKey}`,\n\t\t\t(clientUpdate) => {\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`🤞`,\n\t\t\t\t\t`continuity`,\n\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t`enqueuing optimistic update`,\n\t\t\t\t)\n\t\t\t\tconst optimisticUpdateIndex = optimisticUpdates.findIndex(\n\t\t\t\t\t(update) => update.id === clientUpdate.id,\n\t\t\t\t)\n\t\t\t\tif (optimisticUpdateIndex === -1) {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🤞`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`enqueuing new optimistic update`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, optimisticUpdateQueue, (queue) => {\n\t\t\t\t\t\tqueue.push(clientUpdate)\n\t\t\t\t\t\tqueue.sort((a, b) => a.epoch - b.epoch)\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🤞`,\n\t\t\t\t\t\t`continuity`,\n\t\t\t\t\t\tcontinuityKey,\n\t\t\t\t\t\t`replacing existing optimistic update at index ${optimisticUpdateIndex}`,\n\t\t\t\t\t)\n\t\t\t\t\tsetIntoStore(store, optimisticUpdateQueue, (queue) => {\n\t\t\t\t\t\tqueue[optimisticUpdateIndex] = clientUpdate\n\t\t\t\t\t\treturn queue\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tsocket.emit(`tx-run:${continuityKey}`, {\n\t\t\t\t\tid: clientUpdate.id,\n\t\t\t\t\ttoken: transaction,\n\t\t\t\t\tparams: clientUpdate.params,\n\t\t\t\t})\n\t\t\t},\n\t\t)\n\t\treturn unsubscribeFromTransactionUpdates\n\t})\n\n\tconst revealState = useRevealState(store)\n\tconst concealState = useConcealState(store)\n\tsocket.on(`reveal:${continuityKey}`, revealState)\n\tsocket.on(`conceal:${continuityKey}`, concealState)\n\n\tsocket.emit(`get:${continuityKey}`)\n\treturn () => {\n\t\tsocket.off(`continuity-init:${continuityKey}`)\n\t\tsocket.off(`tx-new:${continuityKey}`)\n\t\tfor (const unsubscribe of unsubscribeFunctions) unsubscribe()\n\t\t// socket.emit(`unsub:${continuityKey}`)\n\t}\n}\n"],"mappings":";;;;;;;AAeA,MAAa,wCAEX,OACA,eACA,QACA,mBAGA,sBAKA,cACU;CACV,SAAS,eACR,kBAGA,iBAGO;AACP,QAAM,OAAO,KACZ,SACA,cACA,eACA;AAED,eAAa,OAAOA,0BAAwB,UAAU;AACrD,SAAM;AACN,UAAO;;AAER,MAAI,iBAAiB,OAAO,gBAAgB,IAAI;GAC/C,MAAM,eAAe,KAAK,UAAU,iBAAiB;GACrD,MAAM,eAAe,KAAK,UAAU,gBAAgB;AACpD,OAAI,iBAAiB,cAAc;AAClC,UAAM,OAAO,KACZ,KACA,cACA,eACA,eAAe,iBAAiB,GAAG;AAEpC,WAAO,KAAK,OAAO,iBAAiB,gBAAgB;AACpD;;QAID,OAAM,OAAO,KACZ,KACA,cACA,eACA,mBAAmB,gBAAgB,MAAM,OAAO,iBAAiB,MAAM,IAAI,GAAG,iBAAiB,GAAG,wBAAwB,gBAAgB,MAAM,IAAI,GAAG,gBAAgB;AAGzK,QAAM,OAAO,KACZ,SACA,cACA,eACA,wBACA,kBACA;EAED,MAAM,4BAA4B,kBAAkB;AACpD,OAAK,MAAM,wBAAwB,0BAClC,+BAA8B,OAAO,sBAAsB;AAE5D,QAAM,OAAO,KACZ,KACA,cACA,eACA,6BACA;AAED,gCAA8B,OAAO,kBAAkB;AACvD,QAAM,OAAO,KACZ,KACA,cACA,eACA,kCACA;AAED,gCAA8B,OAAO,iBAAiB;AACtD,QAAM,OAAO,KACZ,KACA,cACA,eACA,4BACA;AAED,SAAO,KAA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M,GAAG,MAAM,EAAE,QAAQ,EAAE;AACjC,YAAO;;UAEF;AACN,UAAM,OAAO,KACZ,MACA,cACA,eACA,iDAAiD;AAElD,iBAAa,OAAOA,0BAAwB,UAAU;AACrD,WAAM,yBAAyB;AAC/B,YAAO;;;AAGT,UAAO,KAAK,UAAU,iBAAiB;IACtC,IAAI,aAAa;IACjB,OAAO;IACP,QAAQ,aAAa;;;AAIxB,SAAO;;CAGR,MAAM,cAAc,eAAe;CACnC,MAAM,eAAe,gBAAgB;AACrC,QAAO,GAAG,UAAU,iBAAiB;AACrC,QAAO,GAAG,WAAW,iBAAiB;AAEtC,QAAO,KAAK,OAAO;AACnB,cAAa;AACZ,SAAO,IAAI,mBAAmB;AAC9B,SAAO,IAAI,UAAU;AACrB,OAAK,MAAM,eAAe,qBAAsB"}
@@ -1,4 +1,4 @@
1
- import { Store, Subject, Transceiver } from "atom.io/internal";
1
+ import { RootStore, Subject, Transceiver } from "atom.io/internal";
2
2
  import { Canonical, Json, JsonIO, stringified } from "atom.io/json";
3
3
  import * as AtomIO from "atom.io";
4
4
  import { Hierarchy, JoinToken, Loadable, MutableAtomToken, ReadonlyPureSelectorFamilyToken, RegularAtomFamilyToken, TransactionOutcomeEvent, TransactionSubEvent, TransactionToken, WritableToken } from "atom.io";
@@ -163,7 +163,7 @@ type Socket = {
163
163
  };
164
164
  type ServerConfig = {
165
165
  socket: Socket;
166
- store?: Store;
166
+ store?: RootStore;
167
167
  };
168
168
  //#endregion
169
169
  export { ActionReceiver, ChildSocket, ContinuitySyncTransactionUpdate, CreateRoomIO, CustomSocket, EventBuffer, Events, ExposeRealtimeContinuity, FamilyProvider, JoinRoomIO, LeaveRoomIO, MutableFamilyProvider, MutableProvider, ParentSocket, RoomArguments, RoomKey, ServerConfig, Socket, SocketKey, SocketSystemHierarchy, StateProvider, StateReceiver, StringifiedEvent, SubjectSocket, UserKey, createRoomTX, destroyRoomTX, joinRoomTX, leaveRoomTX, prepareToExposeRealtimeContinuity, realtimeActionReceiver, realtimeAtomFamilyProvider, realtimeMutableFamilyProvider, realtimeMutableProvider, realtimeStateProvider, realtimeStateReceiver, redactTransactionUpdateContent, redactorAtoms, roomArgumentsAtoms, roomSelectors, socketAtoms, socketIndex, userIndex, userUnacknowledgedQueues, usersOfSockets };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["socketAtoms: RegularAtomFamilyToken<Socket | null, SocketKey>","socketIndex: MutableAtomToken<SetRTX<SocketKey>>","userIndex: MutableAtomToken<SetRTX<UserKey>>","usersOfSockets: JoinToken<\n\t`user`,\n\tUserKey,\n\t`socket`,\n\tSocketKey,\n\t`1:1`\n>","createRoomTX: AtomIO.TransactionToken<\n\t(\n\t\troomKey: RoomKey,\n\t\tscript: string,\n\t\toptions?: string[],\n\t) => Loadable<ChildSocket<any, any>>\n>","joinRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta\n>","leaveRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string) => void\n>","destroyRoomTX: AtomIO.TransactionToken<(roomKey: RoomKey) => void>","roomArgumentsAtoms: RegularAtomFamilyToken<RoomArguments, string>","roomSelectors: ReadonlyPureSelectorFamilyToken<\n\tLoadable<ChildSocket<any, any>>,\n\tstring\n>","redactorAtoms: RegularAtomFamilyToken<\n\t{\n\t\tocclude: (updates: TransactionSubEvent[]) => TransactionSubEvent[]\n\t},\n\tUserKey\n>","userUnacknowledgedQueues: RegularAtomFamilyToken<\n\tContinuitySyncTransactionUpdate[],\n\tUserKey\n>"],"sources":["../../src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts","../../src/realtime-server/ipc-sockets/custom-socket.ts","../../src/realtime-server/ipc-sockets/child-socket.ts","../../src/realtime-server/ipc-sockets/parent-socket.ts","../../src/realtime-server/realtime-action-receiver.ts","../../src/realtime-server/realtime-family-provider.ts","../../src/realtime-server/realtime-mutable-family-provider.ts","../../src/realtime-server/realtime-mutable-provider.ts","../../src/realtime-server/realtime-server-stores/server-user-store.ts","../../src/realtime-server/realtime-server-stores/server-room-external-actions.ts","../../src/realtime-server/realtime-server-stores/server-room-external-store.ts","../../src/realtime-server/realtime-server-stores/server-sync-store.ts","../../src/realtime-server/realtime-state-provider.ts","../../src/realtime-server/realtime-state-receiver.ts","../../src/realtime-server/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAmBY,wBAAA,gBACC;iBAEG,iCAAA;UACP;;GAEN,eAAe;;;KCrBN,MAAA,GAAS,IAAA,CAAK,eAAe,IAAA,CAAK;KAElC,oDAEI,IAAA,CAAK,kBACjB,aAAa,QAAQ;UAER,gCDQjB,eCNgB,IAAA,CAAK,YDMT,EAAA,CAGZ,SCRU,MDQM,CAAA;EAAA,QAAA,EAAA,ECPH,gBDOG,CCPc,GDOd,ECPmB,MDOnB,CAAA;;AAEf,cCNY,YDMZ,WCNmC,MDOjC,YCPmD,MDOpC,aCPuD;uBACnD,UAAU,GAAG,cAAc,IAAA,CAAK;6BAC1B,6BAA6B,IAAA,CAAK;4CACnB,2BAEhC,EAAE;EAnBb,EAAA,EAAY,MAAA;EAAA,IAAA,EAAA,CAAA,cAAA,MAiCuB,CAjCvB,CAAA,CAAA,KAAA,EAkCH,KAlCG,EAAA,GAAA,IAAA,EAmCD,CAnCC,CAmCC,KAnCD,CAAA,EAAA,GAoCN,YApCM,CAoCO,CApCP,EAoCU,CApCV,CAAA;aAAkC,CAAA,IAAA,EAAA,CAAA,cAAA,MAuCjB,CAvCiB,CAAA,CAAA,KAAA,EAwCpC,KAxCoC,EAAA,GAAA,IAAA,EAyClC,CAzCkC,CAyChC,KAzCgC,CAAA,EAAA,GA0CvC,YA1CuC,CA0C1B,CA1C0B,EA0CvB,CA1CuB,CAAA;mBAApB,MAiDK,CAjDL,CAAA,CAAA,KAAA,EAkDjB,KAlDiB,EAAA,QAAA,EAAA,CAAA,GAAA,IAAA,EAmDJ,CAnDI,CAmDF,KAnDE,CAAA,EAAA,GAAA,IAAA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AA,EAAA,GAAA,IAAA,EAAA,GAAA,IAAA;SACE,CAAA,QAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EcRkC,IAAA,CAAK,YdQvC,EAAA,EAAA,GAAA,IAAA,EAAA,GAAA,IAAA;QAAe,KAAA,EAAA,MAAA,EAAA,QAAA,EAAA,CAAA,GAAA,IAAA,EcNwB,IAAA,CAAK,YdM7B,EAAA,EAAA,GAAA,IAAA,EAAA,GAAA,IAAA;8CcJmB,IAAA,CAAK;iCAEV,IAAA,CAAK;;KAEzB,YAAA;EbrBZ,MAAY,EasBH,MbtBG;EAAA,KAAA,CAAA,EauBH,KbvBG"}
1
+ {"version":3,"file":"index.d.ts","names":["socketAtoms: RegularAtomFamilyToken<Socket | null, SocketKey>","socketIndex: MutableAtomToken<SetRTX<SocketKey>>","userIndex: MutableAtomToken<SetRTX<UserKey>>","usersOfSockets: JoinToken<\n\t`user`,\n\tUserKey,\n\t`socket`,\n\tSocketKey,\n\t`1:1`\n>","createRoomTX: AtomIO.TransactionToken<\n\t(\n\t\troomKey: RoomKey,\n\t\tscript: string,\n\t\toptions?: string[],\n\t) => Loadable<ChildSocket<any, any>>\n>","joinRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta\n>","leaveRoomTX: AtomIO.TransactionToken<\n\t(roomId: string, userId: string) => void\n>","destroyRoomTX: AtomIO.TransactionToken<(roomKey: RoomKey) => void>","roomArgumentsAtoms: RegularAtomFamilyToken<RoomArguments, string>","roomSelectors: ReadonlyPureSelectorFamilyToken<\n\tLoadable<ChildSocket<any, any>>,\n\tstring\n>","redactorAtoms: RegularAtomFamilyToken<\n\t{\n\t\tocclude: (updates: TransactionSubEvent[]) => TransactionSubEvent[]\n\t},\n\tUserKey\n>","userUnacknowledgedQueues: RegularAtomFamilyToken<\n\tContinuitySyncTransactionUpdate[],\n\tUserKey\n>"],"sources":["../../src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts","../../src/realtime-server/ipc-sockets/custom-socket.ts","../../src/realtime-server/ipc-sockets/child-socket.ts","../../src/realtime-server/ipc-sockets/parent-socket.ts","../../src/realtime-server/realtime-action-receiver.ts","../../src/realtime-server/realtime-family-provider.ts","../../src/realtime-server/realtime-mutable-family-provider.ts","../../src/realtime-server/realtime-mutable-provider.ts","../../src/realtime-server/realtime-server-stores/server-user-store.ts","../../src/realtime-server/realtime-server-stores/server-room-external-actions.ts","../../src/realtime-server/realtime-server-stores/server-room-external-store.ts","../../src/realtime-server/realtime-server-stores/server-sync-store.ts","../../src/realtime-server/realtime-state-provider.ts","../../src/realtime-server/realtime-state-receiver.ts","../../src/realtime-server/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAmBY,wBAAA,gBACC;iBAEG,iCAAA;UACP;;GAEN,eAAe;;;KCrBN,MAAA,GAAS,IAAA,CAAK,eAAe,IAAA,CAAK;KAElC,oDAEI,IAAA,CAAK,kBACjB,aAAa,QAAQ;UAER,gCDQjB,eCNgB,IAAA,CAAK,YDMT,EAAA,CAGZ,SCRU,MDQM,CAAA;EAAA,QAAA,EAAA,ECPH,gBDOG,CCPc,GDOd,ECPmB,MDOnB,CAAA;;AAEf,cCNY,YDMZ,WCNmC,MDOjC,YCPmD,MDOpC,aCPuD;uBACnD,UAAU,GAAG,cAAc,IAAA,CAAK;6BAC1B,6BAA6B,IAAA,CAAK;4CACnB,2BAEhC,EAAE;EAnBb,EAAA,EAAY,MAAA;EAAA,IAAA,EAAA,CAAA,cAAA,MAiCuB,CAjCvB,CAAA,CAAA,KAAA,EAkCH,KAlCG,EAAA,GAAA,IAAA,EAmCD,CAnCC,CAmCC,KAnCD,CAAA,EAAA,GAoCN,YApCM,CAoCO,CApCP,EAoCU,CApCV,CAAA;aAAkC,CAAA,IAAA,EAAA,CAAA,cAAA,MAuCjB,CAvCiB,CAAA,CAAA,KAAA,EAwCpC,KAxCoC,EAAA,GAAA,IAAA,EAyClC,CAzCkC,CAyChC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AO,cAAc;;;KCNlB,aAAA,GAAgB,kBAAkB;iBAC9B,qBAAA;;;GAGb,0BACsC,IAAA,CAAK,qBACrC,cAAc;;;AbUP,KcTJ,MAAA,GdSI;YACP,GAAA,SAAA;YACR,EAAA,MAAA,EAAA,QAAA,EAAA,CAAA,GAAA,IAAA,EcTwC,IAAA,CAAK,YdS7C,EAAA,EAAA,GAAA,IAAA,EAAA,GAAA,IAAA;SACE,CAAA,QAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EcRkC,IAAA,CAAK,YdQvC,EAAA,EAAA,GAAA,IAAA,EAAA,GAAA,IAAA;QAAe,KAAA,EAAA,MAAA,EAAA,QAAA,EAAA,CAAA,GAAA,IAAA,EcNwB,IAAA,CAAK,YdM7B,EAAA,EAAA,GAAA,IAAA,EAAA,GAAA,IAAA;8CcJmB,IAAA,CAAK;iCAEV,IAAA,CAAK;;KAEzB,YAAA;EbrBZ,MAAY,EasBH,MbtBG;EAAA,KAAA,CAAA,EauBH,SbvBG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.40.0",
3
+ "version": "0.40.1",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -70,7 +70,7 @@
70
70
  "@types/estree": "1.0.8",
71
71
  "@types/http-proxy": "1.17.16",
72
72
  "@types/npmlog": "7.0.0",
73
- "@types/react": "19.1.11",
73
+ "@types/react": "19.1.12",
74
74
  "@types/tmp": "0.2.6",
75
75
  "@typescript-eslint/parser": "8.41.0",
76
76
  "@typescript-eslint/rule-tester": "8.41.0",
@@ -5,7 +5,8 @@ import type {
5
5
  UpdateHandler,
6
6
  } from "atom.io"
7
7
 
8
- import { type RegularAtom, resetInStore, setIntoStore } from ".."
8
+ import type { RegularAtom, RootStore } from ".."
9
+ import { resetInStore, setIntoStore } from ".."
9
10
  import { newest } from "../lineage"
10
11
  import type { Store } from "../store"
11
12
  import { deposit } from "../store"
@@ -38,7 +39,7 @@ export function createRegularAtom<T>(
38
39
  const newAtom: RegularAtom<T> = {
39
40
  ...options,
40
41
  type,
41
- install: (s: Store) => {
42
+ install: (s: RootStore) => {
42
43
  s.logger.info(`🛠️`, type, key, `installing in store "${s.config.name}"`)
43
44
  return createRegularAtom(s, options, family)
44
45
  },
@@ -1,7 +1,7 @@
1
1
  import type { AtomDisposalEvent, AtomToken, StateLifecycleEvent } from "atom.io"
2
2
 
3
3
  import type { Store, Subject } from ".."
4
- import { getUpdateToken, isChildStore, newest, withdraw } from ".."
4
+ import { getUpdateToken, hasRole, isChildStore, newest, withdraw } from ".."
5
5
  import { getFamilyOfToken } from "../families/get-family-of-token"
6
6
 
7
7
  export function disposeAtom(store: Store, atomToken: AtomToken<any>): void {
@@ -19,7 +19,7 @@ export function disposeAtom(store: Store, atomToken: AtomToken<any>): void {
19
19
  StateLifecycleEvent<AtomToken<any>>
20
20
  >
21
21
 
22
- const disposal: AtomDisposalEvent<AtomToken<any>> = {
22
+ const disposalEvent: AtomDisposalEvent<AtomToken<any>> = {
23
23
  type: `state_disposal`,
24
24
  subType: `atom`,
25
25
  token: atomToken,
@@ -27,7 +27,7 @@ export function disposeAtom(store: Store, atomToken: AtomToken<any>): void {
27
27
  timestamp: Date.now(),
28
28
  }
29
29
 
30
- subject.next(disposal)
30
+ subject.next(disposalEvent)
31
31
 
32
32
  const isChild = isChildStore(target)
33
33
 
@@ -50,9 +50,9 @@ export function disposeAtom(store: Store, atomToken: AtomToken<any>): void {
50
50
  const updateAlreadyCaptured =
51
51
  wasMoleculeDisposal &&
52
52
  mostRecentUpdate.values.some(([k]) => k === atom.family?.key)
53
-
54
- if (!updateAlreadyCaptured) {
55
- target.transactionMeta.update.subEvents.push(disposal)
53
+ const isTracker = hasRole(atom, `tracker:signal`)
54
+ if (!updateAlreadyCaptured && !isTracker) {
55
+ target.transactionMeta.update.subEvents.push(disposalEvent)
56
56
  }
57
57
  } else {
58
58
  store.on.atomDisposal.next(atomToken)
@@ -9,17 +9,16 @@ import { PRETTY_TOKEN_TYPES } from "atom.io"
9
9
  import type { Canonical } from "atom.io/json"
10
10
  import { stringifyJson } from "atom.io/json"
11
11
 
12
- import type { ReadonlyHeldSelectorFamily } from ".."
12
+ import type { ReadonlyHeldSelectorFamily, RootStore } from ".."
13
13
  import { newest } from "../lineage"
14
14
  import { createReadonlyHeldSelector } from "../selector"
15
- import type { Store } from "../store"
16
15
  import { Subject } from "../subject"
17
16
 
18
17
  export function createReadonlyHeldSelectorFamily<
19
18
  T extends object,
20
19
  K extends Canonical,
21
20
  >(
22
- store: Store,
21
+ store: RootStore,
23
22
  options: ReadonlyHeldSelectorFamilyOptions<T, K>,
24
23
  internalRoles?: string[],
25
24
  ): ReadonlyHeldSelectorFamilyToken<T, K> {
@@ -68,7 +67,7 @@ export function createReadonlyHeldSelectorFamily<
68
67
  const readonlySelectorFamily = Object.assign(familyFunction, familyToken, {
69
68
  internalRoles,
70
69
  subject,
71
- install: (s: Store) => createReadonlyHeldSelectorFamily(s, options),
70
+ install: (s: RootStore) => createReadonlyHeldSelectorFamily(s, options),
72
71
  default: options.const,
73
72
  }) satisfies ReadonlyHeldSelectorFamily<T, K>
74
73
 
@@ -11,19 +11,14 @@ import { PRETTY_TOKEN_TYPES } from "atom.io"
11
11
  import type { Canonical } from "atom.io/json"
12
12
  import { stringifyJson } from "atom.io/json"
13
13
 
14
- import {
15
- findInStore,
16
- getFromStore,
17
- getJsonToken,
18
- type ReadonlyPureSelectorFamily,
19
- } from ".."
14
+ import type { ReadonlyPureSelectorFamily, RootStore } from ".."
15
+ import { findInStore, getFromStore, getJsonToken } from ".."
20
16
  import { newest } from "../lineage"
21
17
  import { createReadonlyPureSelector } from "../selector"
22
- import type { Store } from "../store"
23
18
  import { Subject } from "../subject"
24
19
 
25
20
  export function createReadonlyPureSelectorFamily<T, K extends Canonical>(
26
- store: Store,
21
+ store: RootStore,
27
22
  options: ReadonlyPureSelectorFamilyOptions<T, K>,
28
23
  internalRoles?: string[],
29
24
  ): ReadonlyPureSelectorFamilyToken<T, K> {
@@ -71,7 +66,7 @@ export function createReadonlyPureSelectorFamily<T, K extends Canonical>(
71
66
  const readonlySelectorFamily = Object.assign(familyFunction, familyToken, {
72
67
  internalRoles,
73
68
  subject,
74
- install: (s: Store) => createReadonlyPureSelectorFamily(s, options),
69
+ install: (s: RootStore) => createReadonlyPureSelectorFamily(s, options),
75
70
  default: (key: K) => {
76
71
  const getFn = options.get(key)
77
72
  return getFn({
@@ -10,15 +10,14 @@ import { PRETTY_TOKEN_TYPES } from "atom.io"
10
10
  import type { Canonical } from "atom.io/json"
11
11
  import { stringifyJson } from "atom.io/json"
12
12
 
13
- import type { RegularAtomFamily } from ".."
13
+ import type { RegularAtomFamily, RootStore } from ".."
14
14
  import { createRegularAtom } from "../atom"
15
15
  import { isFn } from "../is-fn"
16
16
  import { newest } from "../lineage"
17
- import type { Store } from "../store"
18
17
  import { Subject } from "../subject"
19
18
 
20
19
  export function createRegularAtomFamily<T, K extends Canonical>(
21
- store: Store,
20
+ store: RootStore,
22
21
  options: RegularAtomFamilyOptions<T, K>,
23
22
  internalRoles?: string[],
24
23
  ): RegularAtomFamilyToken<T, K> {
@@ -63,7 +62,7 @@ export function createRegularAtomFamily<T, K extends Canonical>(
63
62
  const atomFamily = Object.assign(familyFunction, familyToken, {
64
63
  default: options.default,
65
64
  subject,
66
- install: (s: Store) => createRegularAtomFamily(s, options),
65
+ install: (s: RootStore) => createRegularAtomFamily(s, options),
67
66
  internalRoles,
68
67
  }) satisfies RegularAtomFamily<T, K>
69
68
 
@@ -11,30 +11,30 @@ import type {
11
11
  } from "atom.io"
12
12
  import type { Canonical } from "atom.io/json"
13
13
 
14
- import type { Store } from "../store"
14
+ import type { RootStore } from "../transaction"
15
15
  import { createReadonlyHeldSelectorFamily } from "./create-readonly-held-selector-family"
16
16
  import { createReadonlyPureSelectorFamily } from "./create-readonly-pure-selector-family"
17
17
  import { createWritableHeldSelectorFamily } from "./create-writable-held-selector-family"
18
18
  import { createWritablePureSelectorFamily } from "./create-writable-pure-selector-family"
19
19
 
20
20
  export function createSelectorFamily<T extends object, K extends Canonical>(
21
- store: Store,
21
+ store: RootStore,
22
22
  options: WritableHeldSelectorFamilyOptions<T, K>,
23
23
  ): WritableHeldSelectorFamilyToken<T, K>
24
24
  export function createSelectorFamily<T extends object, K extends Canonical>(
25
- store: Store,
25
+ store: RootStore,
26
26
  options: ReadonlyHeldSelectorFamilyOptions<T, K>,
27
27
  ): ReadonlyHeldSelectorFamilyToken<T, K>
28
28
  export function createSelectorFamily<T, K extends Canonical>(
29
- store: Store,
29
+ store: RootStore,
30
30
  options: WritablePureSelectorFamilyOptions<T, K>,
31
31
  ): WritablePureSelectorFamilyToken<T, K>
32
32
  export function createSelectorFamily<T, K extends Canonical>(
33
- store: Store,
33
+ store: RootStore,
34
34
  options: ReadonlyPureSelectorFamilyOptions<T, K>,
35
35
  ): ReadonlyPureSelectorFamilyToken<T, K>
36
36
  export function createSelectorFamily(
37
- store: Store,
37
+ store: RootStore,
38
38
  options:
39
39
  | ReadonlyHeldSelectorFamilyOptions<any, any>
40
40
  | ReadonlyPureSelectorFamilyOptions<any, any>
@@ -9,7 +9,7 @@ import { PRETTY_TOKEN_TYPES } from "atom.io"
9
9
  import type { Canonical } from "atom.io/json"
10
10
  import { stringifyJson } from "atom.io/json"
11
11
 
12
- import type { WritableHeldSelectorFamily } from ".."
12
+ import type { RootStore, WritableHeldSelectorFamily } from ".."
13
13
  import { newest } from "../lineage"
14
14
  import { createWritableHeldSelector } from "../selector"
15
15
  import type { Store } from "../store"
@@ -68,7 +68,7 @@ export function createWritableHeldSelectorFamily<
68
68
  const selectorFamily = Object.assign(familyFunction, familyToken, {
69
69
  internalRoles,
70
70
  subject,
71
- install: (s: Store) => createWritableHeldSelectorFamily(s, options),
71
+ install: (s: RootStore) => createWritableHeldSelectorFamily(s, options),
72
72
  default: options.const,
73
73
  }) satisfies WritableHeldSelectorFamily<T, K>
74
74
 
@@ -11,12 +11,8 @@ import { PRETTY_TOKEN_TYPES } from "atom.io"
11
11
  import type { Canonical } from "atom.io/json"
12
12
  import { stringifyJson } from "atom.io/json"
13
13
 
14
- import {
15
- findInStore,
16
- getFromStore,
17
- getJsonToken,
18
- type WritablePureSelectorFamily,
19
- } from ".."
14
+ import type { RootStore, WritablePureSelectorFamily } from ".."
15
+ import { findInStore, getFromStore, getJsonToken } from ".."
20
16
  import { newest } from "../lineage"
21
17
  import { createWritablePureSelector } from "../selector"
22
18
  import type { Store } from "../store"
@@ -71,7 +67,7 @@ export function createWritablePureSelectorFamily<T, K extends Canonical>(
71
67
  const selectorFamily = Object.assign(familyFunction, familyToken, {
72
68
  internalRoles,
73
69
  subject,
74
- install: (s: Store) => createWritablePureSelectorFamily(s, options),
70
+ install: (s: RootStore) => createWritablePureSelectorFamily(s, options),
75
71
  default: (key: K) => {
76
72
  const getFn = options.get(key)
77
73
  return getFn({
@@ -8,10 +8,17 @@ import { findInStore } from "./find-in-store"
8
8
 
9
9
  export function disposeFromStore(store: Store, token: ReadableToken<any>): void
10
10
 
11
- export function disposeFromStore<K extends Canonical>(
11
+ export function disposeFromStore<K extends Canonical, Key extends K>(
12
12
  store: Store,
13
13
  token: ReadableFamilyToken<any, K>,
14
- key: K,
14
+ key: Key,
15
+ ): void
16
+
17
+ export function disposeFromStore<K extends Canonical, Key extends K>(
18
+ store: Store,
19
+ ...params:
20
+ | [token: ReadableFamilyToken<any, K>, key: Key]
21
+ | [token: ReadableToken<any>]
15
22
  ): void
16
23
 
17
24
  export function disposeFromStore(
@@ -14,11 +14,18 @@ export function getFromStore<T, K extends Canonical>(
14
14
  key: K,
15
15
  ): T
16
16
 
17
- export function getFromStore(
17
+ export function getFromStore<T, K extends Canonical, Key extends K>(
18
18
  store: Store,
19
19
  ...params:
20
- | [token: ReadableFamilyToken<any, any>, key: Canonical]
21
- | [token: ReadableToken<any>]
20
+ | [token: ReadableFamilyToken<T, K>, key: Key]
21
+ | [token: ReadableToken<T>]
22
+ ): T
23
+
24
+ export function getFromStore<T, K extends Canonical, Key extends K>(
25
+ store: Store,
26
+ ...params:
27
+ | [token: ReadableFamilyToken<T, K>, key: Key]
28
+ | [token: ReadableToken<T>]
22
29
  ): any {
23
30
  const { token, family, subKey } = reduceReference(store, ...params)
24
31
 
@@ -22,7 +22,7 @@ import type { ConstructorOf, Transceiver } from "./mutable"
22
22
  import type { Store } from "./store"
23
23
  import type { Subject } from "./subject"
24
24
  import type { Timeline } from "./timeline"
25
- import type { Transaction } from "./transaction"
25
+ import type { RootStore, Transaction } from "./transaction"
26
26
  import type { Flat } from "./utility-types"
27
27
 
28
28
  export * from "./arbitrary"
@@ -58,7 +58,7 @@ export type * from "./utility-types"
58
58
  export type AtomIOState = {
59
59
  key: string
60
60
  family?: FamilyMetadata
61
- install: (store: Store) => void
61
+ install: (store: RootStore) => void
62
62
  subject: Subject<StateUpdate<any>>
63
63
  }
64
64
  export type RegularAtom<T> = Flat<
@@ -131,7 +131,7 @@ export type RegularAtomFamily<T, K extends Canonical> =
131
131
  & RegularAtomFamilyToken<T, K>
132
132
  & {
133
133
  default: T | ((key: K) => T)
134
- install: (store: Store) => void
134
+ install: (store: RootStore) => void
135
135
  internalRoles: string[] | undefined
136
136
  subject: Subject<StateLifecycleEvent<RegularAtomToken<T>>>
137
137
  }
@@ -147,7 +147,7 @@ export type MutableAtomFamily<
147
147
  & MutableAtomFamilyToken<T, K>
148
148
  & {
149
149
  class: ConstructorOf<T>
150
- install: (store: Store) => void
150
+ install: (store: RootStore) => void
151
151
  internalRoles: string[] | undefined
152
152
  subject: Subject<StateLifecycleEvent<MutableAtomToken<T>>>
153
153
  }
@@ -164,7 +164,7 @@ export type WritablePureSelectorFamily<T, K extends Canonical> =
164
164
  & WritablePureSelectorFamilyToken<T, K>
165
165
  & {
166
166
  default: (key: K) => T,
167
- install: (store: Store) => void
167
+ install: (store: RootStore) => void
168
168
  internalRoles: string[] | undefined
169
169
  subject: Subject<StateLifecycleEvent<WritablePureSelectorToken<T>>>
170
170
  }
@@ -177,7 +177,7 @@ export type WritableHeldSelectorFamily<T , K extends Canonical> =
177
177
  & WritableHeldSelectorFamilyToken<T, K>
178
178
  & {
179
179
  default: (key: K) => T,
180
- install: (store: Store) => void
180
+ install: (store: RootStore) => void
181
181
  internalRoles: string[] | undefined
182
182
  subject: Subject<StateLifecycleEvent<WritableHeldSelectorToken<T>>>
183
183
  }
@@ -190,7 +190,7 @@ export type ReadonlyPureSelectorFamily<T, K extends Canonical> =
190
190
  & ReadonlyPureSelectorFamilyToken<T, K>
191
191
  & {
192
192
  default: (key: K) => T,
193
- install: (store: Store) => void
193
+ install: (store: RootStore) => void
194
194
  internalRoles: string[] | undefined
195
195
  subject: Subject<StateLifecycleEvent<ReadonlyPureSelectorToken<T>>>
196
196
  }
@@ -203,7 +203,7 @@ export type ReadonlyHeldSelectorFamily<T , K extends Canonical> =
203
203
  & ReadonlyHeldSelectorFamilyToken<T, K>
204
204
  & {
205
205
  default: (key: K) => T,
206
- install: (store: Store) => void
206
+ install: (store: RootStore) => void
207
207
  internalRoles: string[] | undefined
208
208
  subject: Subject<StateLifecycleEvent<ReadonlyHeldSelectorToken<T>>>
209
209
  }
@@ -2,6 +2,7 @@ import type { AtomIOToken } from "atom.io"
2
2
 
3
3
  import { newest } from "./lineage"
4
4
  import { type Store, withdraw } from "./store"
5
+ import type { RootStore } from "./transaction"
5
6
  import { isChildStore } from "./transaction"
6
7
 
7
8
  /**
@@ -14,7 +15,7 @@ import { isChildStore } from "./transaction"
14
15
  */
15
16
  export function installIntoStore(
16
17
  tokens: AtomIOToken[],
17
- target: Store,
18
+ target: RootStore,
18
19
  source: Store,
19
20
  ): void {
20
21
  const sourceNewest = newest(source)
@@ -1,7 +1,7 @@
1
1
  import type { JoinOptions, JoinToken } from "atom.io"
2
2
  import type { Json } from "atom.io/json"
3
3
 
4
- import type { Store } from "../store"
4
+ import type { RootStore } from "../transaction"
5
5
  import { Join } from "./join-internal"
6
6
 
7
7
  export function createJoin<
@@ -12,7 +12,7 @@ export function createJoin<
12
12
  Cardinality extends `1:1` | `1:n` | `n:n`,
13
13
  Content extends Json.Object,
14
14
  >(
15
- store: Store,
15
+ store: RootStore,
16
16
  options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>,
17
17
  defaultContent: Content | undefined,
18
18
  ): JoinToken<ASide, AType, BSide, BType, Cardinality, Content> {
@@ -3,7 +3,7 @@ import type { Json } from "atom.io/json"
3
3
 
4
4
  import { capitalize } from "../capitalize"
5
5
  import { findInStore } from "../families"
6
- import type { Store } from "../store"
6
+ import type { RootStore } from "../transaction"
7
7
  import { getJoin } from "./get-join"
8
8
 
9
9
  export function findRelationsInStore<
@@ -16,7 +16,7 @@ export function findRelationsInStore<
16
16
  >(
17
17
  token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>,
18
18
  key: AType | BType,
19
- store: Store,
19
+ store: RootStore,
20
20
  ): JoinStates<ASide, AType, BSide, BType, Cardinality, Content> {
21
21
  const myJoin = getJoin(token, store)
22
22
  let relations: JoinStates<ASide, AType, BSide, BType, Cardinality, Content>
@@ -1,12 +1,12 @@
1
1
  import type { JoinToken, MutableAtomFamilyToken } from "atom.io"
2
2
  import type { SetRTX } from "atom.io/transceivers/set-rtx"
3
3
 
4
- import type { Store } from "../store"
4
+ import type { RootStore } from "../transaction"
5
5
  import { getJoin } from "./get-join"
6
6
 
7
7
  export function getInternalRelationsFromStore(
8
8
  token: JoinToken<any, any, any, any, any, any>,
9
- store: Store,
9
+ store: RootStore,
10
10
  ): MutableAtomFamilyToken<SetRTX<string>, string> {
11
11
  const myJoin = getJoin(token, store)
12
12
  const family = myJoin.core.relatedKeysAtoms