atom.io 0.19.1 → 0.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.cjs +99 -79
- package/data/dist/index.js +3 -3
- package/data/package.json +1 -1
- package/data/src/join.ts +67 -50
- package/dist/{chunk-YDOGCZ53.js → chunk-ATKDGVTV.js} +29 -29
- package/dist/{chunk-7VCCW45K.js → chunk-CC7IF7QF.js} +4 -3
- package/dist/{chunk-U2IICNHQ.js → chunk-F2X4B4VY.js} +5 -1
- package/dist/{chunk-WX2NCOZR.js → chunk-FTONNX2R.js} +8 -8
- package/dist/{chunk-7ZR244C2.js → chunk-MSCJWACE.js} +92 -72
- package/dist/index.cjs +14 -7
- package/dist/index.d.ts +23 -35
- package/dist/index.js +15 -8
- package/eslint-plugin/dist/index.cjs +180 -0
- package/eslint-plugin/dist/index.js +171 -0
- package/eslint-plugin/package.json +16 -0
- package/eslint-plugin/src/index.ts +11 -0
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +190 -0
- package/internal/dist/index.cjs +55 -43
- package/internal/dist/index.d.ts +20 -20
- package/internal/dist/index.js +49 -37
- package/internal/package.json +1 -1
- package/internal/src/atom/create-regular-atom.ts +7 -5
- package/internal/src/atom/delete-atom.ts +2 -2
- package/internal/src/families/create-readonly-selector-family.ts +2 -2
- package/internal/src/families/create-regular-atom-family.ts +1 -1
- package/internal/src/families/create-writable-selector-family.ts +1 -1
- package/internal/src/future.ts +4 -2
- package/internal/src/lineage.ts +1 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
- package/internal/src/mutable/create-mutable-atom.ts +7 -5
- package/internal/src/mutable/tracker.ts +3 -3
- package/internal/src/mutable/transceiver.ts +2 -2
- package/internal/src/selector/delete-selector.ts +1 -1
- package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
- package/internal/src/store/deposit.ts +5 -5
- package/internal/src/store/store.ts +5 -5
- package/internal/src/store/withdraw.ts +4 -5
- package/internal/src/subject.ts +3 -1
- package/internal/src/subscribe/subscribe-to-transaction.ts +4 -4
- package/internal/src/timeline/add-atom-to-timeline.ts +13 -8
- package/internal/src/timeline/create-timeline.ts +3 -4
- package/internal/src/transaction/act-upon-store.ts +5 -5
- package/internal/src/transaction/apply-transaction.ts +4 -4
- package/internal/src/transaction/build-transaction.ts +9 -6
- package/internal/src/transaction/create-transaction.ts +10 -10
- package/internal/src/transaction/index.ts +3 -3
- package/internal/src/transaction/is-root-store.ts +2 -2
- package/introspection/dist/index.d.ts +3 -3
- package/introspection/dist/index.js +1 -1
- package/introspection/package.json +1 -1
- package/introspection/src/attach-introspection-states.ts +3 -3
- package/introspection/src/attach-transaction-index.ts +4 -4
- package/introspection/src/attach-transaction-logs.ts +8 -4
- package/json/dist/index.cjs +6 -2
- package/json/dist/index.js +7 -3
- package/json/package.json +1 -1
- package/json/src/select-json-family.ts +3 -2
- package/json/src/select-json.ts +3 -1
- package/package.json +258 -241
- package/react/dist/index.cjs +9 -3
- package/react/dist/index.js +10 -4
- package/react/package.json +1 -1
- package/react/src/use-i.ts +3 -1
- package/react/src/use-tl.ts +6 -2
- package/react-devtools/dist/index.cjs +205 -155
- package/react-devtools/dist/index.d.ts +3 -5
- package/react-devtools/dist/index.js +182 -133
- package/react-devtools/package.json +1 -1
- package/react-devtools/src/AtomIODevtools.tsx +3 -1
- package/react-devtools/src/Button.tsx +3 -1
- package/react-devtools/src/StateIndex.tsx +6 -2
- package/react-devtools/src/TimelineIndex.tsx +6 -2
- package/react-devtools/src/TransactionIndex.tsx +3 -3
- package/react-devtools/src/Updates.tsx +24 -13
- package/realtime/dist/index.cjs +1 -0
- package/realtime/dist/index.d.ts +2 -2
- package/realtime/dist/index.js +2 -1
- package/realtime/package.json +1 -1
- package/realtime/src/realtime-continuity.ts +4 -3
- package/realtime-client/dist/index.cjs +29 -29
- package/realtime-client/dist/index.d.ts +2 -2
- package/realtime-client/dist/index.js +2 -2
- package/realtime-client/package.json +1 -1
- package/realtime-client/src/server-action.ts +2 -2
- package/realtime-client/src/sync-continuity.ts +23 -23
- package/realtime-react/dist/index.cjs +29 -29
- package/realtime-react/dist/index.d.ts +2 -2
- package/realtime-react/dist/index.js +2 -2
- package/realtime-react/package.json +1 -1
- package/realtime-react/src/use-server-action.ts +3 -3
- package/realtime-server/dist/index.cjs +54 -44
- package/realtime-server/dist/index.d.ts +5 -5
- package/realtime-server/dist/index.js +35 -25
- package/realtime-server/package.json +1 -1
- package/realtime-server/src/ipc-sockets/child-socket.ts +6 -6
- package/realtime-server/src/ipc-sockets/custom-socket.ts +4 -8
- package/realtime-server/src/ipc-sockets/parent-socket.ts +13 -7
- package/realtime-server/src/realtime-action-receiver.ts +7 -5
- package/realtime-server/src/realtime-continuity-synchronizer.ts +3 -3
- package/realtime-server/src/realtime-state-receiver.ts +3 -1
- package/realtime-testing/dist/index.cjs +15 -13
- package/realtime-testing/dist/index.js +10 -8
- package/realtime-testing/package.json +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +6 -4
- package/src/atom.ts +4 -8
- package/src/dispose.ts +1 -0
- package/src/index.ts +2 -9
- package/src/selector.ts +4 -8
- package/src/silo.ts +9 -3
- package/src/subscribe.ts +6 -6
- package/src/timeline.ts +4 -4
- package/src/transaction.ts +24 -24
- package/transceivers/set-rtx/dist/index.cjs +11 -12
- package/transceivers/set-rtx/dist/index.js +12 -13
- package/transceivers/set-rtx/package.json +1 -1
- package/transceivers/set-rtx/src/set-rtx.ts +10 -10
|
@@ -67,7 +67,9 @@ export const AtomIODevtools = (): JSX.Element => {
|
|
|
67
67
|
type="button"
|
|
68
68
|
data-testid={`view-${viewOption}`}
|
|
69
69
|
className={viewOption === devtoolsView ? `active` : ``}
|
|
70
|
-
onClick={() =>
|
|
70
|
+
onClick={() => {
|
|
71
|
+
setDevtoolsView(viewOption)
|
|
72
|
+
}}
|
|
71
73
|
disabled={viewOption === devtoolsView}
|
|
72
74
|
>
|
|
73
75
|
{viewOption}
|
|
@@ -12,7 +12,9 @@ export const OpenClose: FC<{
|
|
|
12
12
|
type="button"
|
|
13
13
|
data-testid={testid}
|
|
14
14
|
className={`carat ${isOpen ? `open` : `closed`}`}
|
|
15
|
-
onClick={() =>
|
|
15
|
+
onClick={() => {
|
|
16
|
+
setIsOpen((prev) => !prev)
|
|
17
|
+
}}
|
|
16
18
|
disabled={disabled}
|
|
17
19
|
>
|
|
18
20
|
▶
|
|
@@ -59,8 +59,12 @@ export const StateIndexLeafNode: FC<{
|
|
|
59
59
|
disabled={isPrimitive}
|
|
60
60
|
/>
|
|
61
61
|
<label
|
|
62
|
-
onClick={() =>
|
|
63
|
-
|
|
62
|
+
onClick={() => {
|
|
63
|
+
console.log(node, getState(node))
|
|
64
|
+
}}
|
|
65
|
+
onKeyUp={() => {
|
|
66
|
+
console.log(node, getState(node))
|
|
67
|
+
}}
|
|
64
68
|
>
|
|
65
69
|
<h2>{node.family?.subKey ?? node.key}</h2>
|
|
66
70
|
<span className="type detail">({stateType})</span>
|
|
@@ -42,14 +42,18 @@ export const TimelineLog: FC<{
|
|
|
42
42
|
<nav>
|
|
43
43
|
<button
|
|
44
44
|
type="button"
|
|
45
|
-
onClick={() =>
|
|
45
|
+
onClick={() => {
|
|
46
|
+
undo(token)
|
|
47
|
+
}}
|
|
46
48
|
disabled={timeline.at === 0}
|
|
47
49
|
>
|
|
48
50
|
undo
|
|
49
51
|
</button>
|
|
50
52
|
<button
|
|
51
53
|
type="button"
|
|
52
|
-
onClick={() =>
|
|
54
|
+
onClick={() => {
|
|
55
|
+
redo(token)
|
|
56
|
+
}}
|
|
53
57
|
disabled={timeline.at === timeline.history.length}
|
|
54
58
|
>
|
|
55
59
|
redo
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type TransactionToken,
|
|
5
5
|
type TransactionUpdate,
|
|
6
6
|
findState,
|
|
7
|
-
type
|
|
7
|
+
type Func,
|
|
8
8
|
} from "atom.io"
|
|
9
9
|
import { useI, useO } from "atom.io/react"
|
|
10
10
|
import type { FC } from "react"
|
|
@@ -18,9 +18,9 @@ import { button } from "./Button"
|
|
|
18
18
|
import { article } from "./Updates"
|
|
19
19
|
|
|
20
20
|
export const TransactionLog: FC<{
|
|
21
|
-
token: TransactionToken
|
|
21
|
+
token: TransactionToken<Func>
|
|
22
22
|
isOpenState: RegularAtomToken<boolean>
|
|
23
|
-
logState: ReadonlySelectorToken<TransactionUpdate
|
|
23
|
+
logState: ReadonlySelectorToken<TransactionUpdate<Func>[]>
|
|
24
24
|
}> = ({ token, isOpenState, logState }) => {
|
|
25
25
|
const log = useO(logState)
|
|
26
26
|
const isOpen = useO(isOpenState)
|
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
KeyedStateUpdate,
|
|
3
3
|
TimelineUpdate,
|
|
4
4
|
TransactionUpdate,
|
|
5
|
-
|
|
5
|
+
Func,
|
|
6
6
|
} from "atom.io"
|
|
7
7
|
import * as React from "react"
|
|
8
8
|
|
|
@@ -18,8 +18,12 @@ const AtomUpdateFC: React.FC<{
|
|
|
18
18
|
<article
|
|
19
19
|
key={atomUpdate.key}
|
|
20
20
|
className="node atom_update"
|
|
21
|
-
onClick={() =>
|
|
22
|
-
|
|
21
|
+
onClick={() => {
|
|
22
|
+
console.log(atomUpdate)
|
|
23
|
+
}}
|
|
24
|
+
onKeyUp={() => {
|
|
25
|
+
console.log(atomUpdate)
|
|
26
|
+
}}
|
|
23
27
|
>
|
|
24
28
|
<span className="detail">{atomUpdate.key}: </span>
|
|
25
29
|
<span>
|
|
@@ -33,7 +37,7 @@ const AtomUpdateFC: React.FC<{
|
|
|
33
37
|
|
|
34
38
|
const TransactionUpdateFC: React.FC<{
|
|
35
39
|
serialNumber: number
|
|
36
|
-
transactionUpdate: TransactionUpdate
|
|
40
|
+
transactionUpdate: TransactionUpdate<Func>
|
|
37
41
|
}> = ({ serialNumber, transactionUpdate }) => {
|
|
38
42
|
return (
|
|
39
43
|
<article
|
|
@@ -51,8 +55,12 @@ const TransactionUpdateFC: React.FC<{
|
|
|
51
55
|
<article
|
|
52
56
|
key={`param` + index}
|
|
53
57
|
className="node transaction_param"
|
|
54
|
-
onClick={() =>
|
|
55
|
-
|
|
58
|
+
onClick={() => {
|
|
59
|
+
console.log(transactionUpdate)
|
|
60
|
+
}}
|
|
61
|
+
onKeyUp={() => {
|
|
62
|
+
console.log(transactionUpdate)
|
|
63
|
+
}}
|
|
56
64
|
>
|
|
57
65
|
<span className="detail">{discoverType(param)}: </span>
|
|
58
66
|
<span className="summary">
|
|
@@ -85,13 +93,16 @@ const TransactionUpdateFC: React.FC<{
|
|
|
85
93
|
{transactionUpdate.updates
|
|
86
94
|
.filter((token) => !token.key.startsWith(`👁🗨`))
|
|
87
95
|
.map((update, index) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
if (`newValue` in update) {
|
|
97
|
+
return (
|
|
98
|
+
<article.AtomUpdate
|
|
99
|
+
key={`${transactionUpdate.key}:${index}:${update.key}`}
|
|
100
|
+
serialNumber={index}
|
|
101
|
+
atomUpdate={update}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
return (
|
|
95
106
|
<TransactionUpdateFC
|
|
96
107
|
key={`${transactionUpdate.key}:${index}:${update.key}`}
|
|
97
108
|
serialNumber={index}
|
package/realtime/dist/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ var InvariantMap = class extends Map {
|
|
|
24
24
|
var _SyncGroup = class _SyncGroup {
|
|
25
25
|
constructor(key) {
|
|
26
26
|
this.key = key;
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
27
28
|
this.type = `continuity`;
|
|
28
29
|
this.globals = [];
|
|
29
30
|
this.actions = [];
|
package/realtime/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare class InvariantMap<K, V> extends Map<K, V> {
|
|
|
8
8
|
set(key: K, value: V): this;
|
|
9
9
|
clear(): void;
|
|
10
10
|
}
|
|
11
|
-
type PerspectiveToken<F extends AtomFamilyToken<any>, T extends F extends AtomFamilyToken<infer
|
|
11
|
+
type PerspectiveToken<F extends AtomFamilyToken<any>, T extends F extends AtomFamilyToken<infer U, any> ? U : never> = {
|
|
12
12
|
type: `realtime_perspective`;
|
|
13
13
|
resourceAtoms: F;
|
|
14
14
|
viewAtoms: ReadableFamilyToken<ReadableToken<T>[], string>;
|
|
@@ -31,7 +31,7 @@ declare class SyncGroup {
|
|
|
31
31
|
static create(key: string, builder: (group: SyncGroup) => SyncGroup): ContinuityToken;
|
|
32
32
|
add(...atoms: AtomToken<any>[]): SyncGroup;
|
|
33
33
|
add(...args: TransactionToken<any>[]): SyncGroup;
|
|
34
|
-
add<F extends AtomFamilyToken<any>, T extends F extends AtomFamilyToken<infer
|
|
34
|
+
add<F extends AtomFamilyToken<any>, T extends F extends AtomFamilyToken<infer U> ? U : never>(family: AtomFamilyToken<T, any>, index: ReadableFamilyToken<Iterable<AtomToken<T>>, string>): SyncGroup;
|
|
35
35
|
}
|
|
36
36
|
type ContinuityOptions = {
|
|
37
37
|
key: string;
|
package/realtime/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '../../dist/chunk-
|
|
1
|
+
import '../../dist/chunk-F2X4B4VY.js';
|
|
2
2
|
import { assignTransactionToContinuity, IMPLICIT, setEpochNumberOfContinuity, getUpdateToken } from 'atom.io/internal';
|
|
3
3
|
import { atom, selectorFamily } from 'atom.io';
|
|
4
4
|
import { join, getInternalRelations } from 'atom.io/data';
|
|
@@ -22,6 +22,7 @@ var InvariantMap = class extends Map {
|
|
|
22
22
|
var _SyncGroup = class _SyncGroup {
|
|
23
23
|
constructor(key) {
|
|
24
24
|
this.key = key;
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
25
26
|
this.type = `continuity`;
|
|
26
27
|
this.globals = [];
|
|
27
28
|
this.actions = [];
|
package/realtime/package.json
CHANGED
|
@@ -32,7 +32,7 @@ export class InvariantMap<K, V> extends Map<K, V> {
|
|
|
32
32
|
|
|
33
33
|
export type PerspectiveToken<
|
|
34
34
|
F extends AtomFamilyToken<any>,
|
|
35
|
-
T extends F extends AtomFamilyToken<infer
|
|
35
|
+
T extends F extends AtomFamilyToken<infer U, any> ? U : never,
|
|
36
36
|
> = {
|
|
37
37
|
type: `realtime_perspective`
|
|
38
38
|
resourceAtoms: F
|
|
@@ -51,6 +51,7 @@ export type ContinuityToken = {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export class SyncGroup {
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
54
55
|
protected type = `continuity` as const
|
|
55
56
|
|
|
56
57
|
protected globals: AtomToken<any>[] = []
|
|
@@ -76,7 +77,7 @@ export class SyncGroup {
|
|
|
76
77
|
public add(...args: TransactionToken<any>[]): SyncGroup
|
|
77
78
|
public add<
|
|
78
79
|
F extends AtomFamilyToken<any>,
|
|
79
|
-
T extends F extends AtomFamilyToken<infer
|
|
80
|
+
T extends F extends AtomFamilyToken<infer U> ? U : never,
|
|
80
81
|
>(
|
|
81
82
|
family: AtomFamilyToken<T, any>,
|
|
82
83
|
index: ReadableFamilyToken<Iterable<AtomToken<T>>, string>,
|
|
@@ -86,7 +87,7 @@ export class SyncGroup {
|
|
|
86
87
|
| readonly AtomToken<any>[]
|
|
87
88
|
| readonly TransactionToken<any>[]
|
|
88
89
|
| [AtomFamilyToken<any, any>, ReadableFamilyToken<Iterable<any>, string>]
|
|
89
|
-
):
|
|
90
|
+
): this {
|
|
90
91
|
const zeroth = args[0]
|
|
91
92
|
if (zeroth.type === `atom` || zeroth.type === `mutable_atom`) {
|
|
92
93
|
const globals = args as AtomToken<any>[]
|
|
@@ -256,8 +256,8 @@ function syncContinuity(continuity, socket, store) {
|
|
|
256
256
|
};
|
|
257
257
|
socket.off(`continuity-init:${continuityKey}`);
|
|
258
258
|
socket.on(`continuity-init:${continuityKey}`, initializeContinuity);
|
|
259
|
-
const registerAndAttemptConfirmedUpdate = (
|
|
260
|
-
function reconcileEpoch(optimisticUpdate,
|
|
259
|
+
const registerAndAttemptConfirmedUpdate = (confirmed) => {
|
|
260
|
+
function reconcileEpoch(optimisticUpdate, confirmedUpdate) {
|
|
261
261
|
store.logger.info(
|
|
262
262
|
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
263
263
|
`continuity`,
|
|
@@ -272,9 +272,9 @@ function syncContinuity(continuity, socket, store) {
|
|
|
272
272
|
},
|
|
273
273
|
store
|
|
274
274
|
);
|
|
275
|
-
if (optimisticUpdate.id ===
|
|
275
|
+
if (optimisticUpdate.id === confirmedUpdate.id) {
|
|
276
276
|
const clientResult = JSON.stringify(optimisticUpdate.updates);
|
|
277
|
-
const serverResult = JSON.stringify(
|
|
277
|
+
const serverResult = JSON.stringify(confirmedUpdate.updates);
|
|
278
278
|
if (clientResult === serverResult) {
|
|
279
279
|
store.logger.info(
|
|
280
280
|
`\u2705`,
|
|
@@ -282,7 +282,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
282
282
|
continuityKey,
|
|
283
283
|
`results for ${optimisticUpdate.id} match between client and server`
|
|
284
284
|
);
|
|
285
|
-
socket.emit(`ack:${continuityKey}`,
|
|
285
|
+
socket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch);
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
288
|
} else {
|
|
@@ -290,7 +290,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
290
290
|
`\u274C`,
|
|
291
291
|
`continuity`,
|
|
292
292
|
continuityKey,
|
|
293
|
-
`thought update #${
|
|
293
|
+
`thought update #${confirmedUpdate.epoch} was ${optimisticUpdate.key}:${optimisticUpdate.id}, but it was actually ${confirmedUpdate.key}:${confirmedUpdate.id}`
|
|
294
294
|
);
|
|
295
295
|
}
|
|
296
296
|
store.logger.info(
|
|
@@ -299,7 +299,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
299
299
|
continuityKey,
|
|
300
300
|
`updates do not match`,
|
|
301
301
|
optimisticUpdate,
|
|
302
|
-
|
|
302
|
+
confirmedUpdate
|
|
303
303
|
);
|
|
304
304
|
const reversedOptimisticUpdates = optimisticUpdates.toReversed();
|
|
305
305
|
for (const subsequentOptimistic of reversedOptimisticUpdates) {
|
|
@@ -320,15 +320,15 @@ function syncContinuity(continuity, socket, store) {
|
|
|
320
320
|
`undid zeroth optimistic update`,
|
|
321
321
|
optimisticUpdate
|
|
322
322
|
);
|
|
323
|
-
Internal.ingestTransactionUpdate(`newValue`,
|
|
323
|
+
Internal.ingestTransactionUpdate(`newValue`, confirmedUpdate, store);
|
|
324
324
|
store.logger.info(
|
|
325
325
|
`\u23E9`,
|
|
326
326
|
`continuity`,
|
|
327
327
|
continuityKey,
|
|
328
328
|
`applied confirmed update`,
|
|
329
|
-
|
|
329
|
+
confirmedUpdate
|
|
330
330
|
);
|
|
331
|
-
socket.emit(`ack:${continuityKey}`,
|
|
331
|
+
socket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch);
|
|
332
332
|
for (const subsequentOptimistic of optimisticUpdates) {
|
|
333
333
|
const token = {
|
|
334
334
|
type: `transaction`,
|
|
@@ -350,7 +350,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
350
350
|
`continuity`,
|
|
351
351
|
continuityKey,
|
|
352
352
|
`integrating confirmed update`,
|
|
353
|
-
{ confirmedUpdate, confirmedUpdates, optimisticUpdates }
|
|
353
|
+
{ confirmedUpdate: confirmed, confirmedUpdates, optimisticUpdates }
|
|
354
354
|
);
|
|
355
355
|
const zerothOptimisticUpdate = optimisticUpdates[0];
|
|
356
356
|
if (zerothOptimisticUpdate) {
|
|
@@ -360,14 +360,14 @@ function syncContinuity(continuity, socket, store) {
|
|
|
360
360
|
continuityKey,
|
|
361
361
|
`has optimistic updates to reconcile`
|
|
362
362
|
);
|
|
363
|
-
if (
|
|
363
|
+
if (confirmed.epoch === zerothOptimisticUpdate.epoch) {
|
|
364
364
|
store.logger.info(
|
|
365
365
|
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
366
366
|
`continuity`,
|
|
367
367
|
continuityKey,
|
|
368
|
-
`epoch of confirmed update #${
|
|
368
|
+
`epoch of confirmed update #${confirmed.epoch} matches zeroth optimistic update`
|
|
369
369
|
);
|
|
370
|
-
reconcileEpoch(zerothOptimisticUpdate,
|
|
370
|
+
reconcileEpoch(zerothOptimisticUpdate, confirmed);
|
|
371
371
|
for (const nextConfirmed of confirmedUpdates) {
|
|
372
372
|
const nextOptimistic = optimisticUpdates[0];
|
|
373
373
|
if (nextConfirmed.epoch === (nextOptimistic == null ? void 0 : nextOptimistic.epoch)) {
|
|
@@ -381,10 +381,10 @@ function syncContinuity(continuity, socket, store) {
|
|
|
381
381
|
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
382
382
|
`continuity`,
|
|
383
383
|
continuityKey,
|
|
384
|
-
`epoch of confirmed update #${
|
|
384
|
+
`epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`
|
|
385
385
|
);
|
|
386
386
|
const confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(
|
|
387
|
-
(update) => update.epoch ===
|
|
387
|
+
(update) => update.epoch === confirmed.epoch
|
|
388
388
|
);
|
|
389
389
|
if (!confirmedUpdateIsAlreadyEnqueued) {
|
|
390
390
|
store.logger.info(
|
|
@@ -392,12 +392,12 @@ function syncContinuity(continuity, socket, store) {
|
|
|
392
392
|
`continuity`,
|
|
393
393
|
continuityKey,
|
|
394
394
|
`pushing confirmed update to queue`,
|
|
395
|
-
|
|
395
|
+
confirmed
|
|
396
396
|
);
|
|
397
397
|
Internal.setIntoStore(
|
|
398
398
|
realtimeClient.confirmedUpdateQueue,
|
|
399
399
|
(queue) => {
|
|
400
|
-
queue.push(
|
|
400
|
+
queue.push(confirmed);
|
|
401
401
|
queue.sort((a, b) => a.epoch - b.epoch);
|
|
402
402
|
return queue;
|
|
403
403
|
},
|
|
@@ -414,48 +414,48 @@ function syncContinuity(continuity, socket, store) {
|
|
|
414
414
|
);
|
|
415
415
|
const continuityEpoch = Internal.getEpochNumberOfContinuity(continuityKey, store);
|
|
416
416
|
const isRoot = Internal.isRootStore(store);
|
|
417
|
-
if (isRoot && continuityEpoch ===
|
|
417
|
+
if (isRoot && continuityEpoch === confirmed.epoch - 1) {
|
|
418
418
|
store.logger.info(
|
|
419
419
|
`\u2705`,
|
|
420
420
|
`continuity`,
|
|
421
421
|
continuityKey,
|
|
422
|
-
`integrating update #${
|
|
422
|
+
`integrating update #${confirmed.epoch} (${confirmed.key} ${confirmed.id})`
|
|
423
423
|
);
|
|
424
|
-
Internal.ingestTransactionUpdate(`newValue`,
|
|
425
|
-
socket.emit(`ack:${continuityKey}`,
|
|
426
|
-
Internal.setEpochNumberOfContinuity(continuityKey,
|
|
424
|
+
Internal.ingestTransactionUpdate(`newValue`, confirmed, store);
|
|
425
|
+
socket.emit(`ack:${continuityKey}`, confirmed.epoch);
|
|
426
|
+
Internal.setEpochNumberOfContinuity(continuityKey, confirmed.epoch, store);
|
|
427
427
|
} else if (isRoot && continuityEpoch !== void 0) {
|
|
428
428
|
store.logger.info(
|
|
429
429
|
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
430
430
|
`continuity`,
|
|
431
431
|
continuityKey,
|
|
432
|
-
`received update #${
|
|
432
|
+
`received update #${confirmed.epoch} but still waiting for update #${continuityEpoch + 1}`,
|
|
433
433
|
{
|
|
434
434
|
clientEpoch: continuityEpoch,
|
|
435
|
-
serverEpoch:
|
|
435
|
+
serverEpoch: confirmed.epoch
|
|
436
436
|
}
|
|
437
437
|
);
|
|
438
438
|
const confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(
|
|
439
|
-
(update) => update.epoch ===
|
|
439
|
+
(update) => update.epoch === confirmed.epoch
|
|
440
440
|
);
|
|
441
441
|
if (confirmedUpdateIsAlreadyEnqueued) {
|
|
442
442
|
store.logger.info(
|
|
443
443
|
`\u{1F44D}`,
|
|
444
444
|
`continuity`,
|
|
445
445
|
continuityKey,
|
|
446
|
-
`confirmed update #${
|
|
446
|
+
`confirmed update #${confirmed.epoch} is already enqueued`
|
|
447
447
|
);
|
|
448
448
|
} else {
|
|
449
449
|
store.logger.info(
|
|
450
450
|
`\u{1F448}`,
|
|
451
451
|
`continuity`,
|
|
452
452
|
continuityKey,
|
|
453
|
-
`pushing confirmed update #${
|
|
453
|
+
`pushing confirmed update #${confirmed.epoch} to queue`
|
|
454
454
|
);
|
|
455
455
|
Internal.setIntoStore(
|
|
456
456
|
realtimeClient.confirmedUpdateQueue,
|
|
457
457
|
(queue) => {
|
|
458
|
-
queue.push(
|
|
458
|
+
queue.push(confirmed);
|
|
459
459
|
queue.sort((a, b) => a.epoch - b.epoch);
|
|
460
460
|
return queue;
|
|
461
461
|
},
|
|
@@ -26,8 +26,8 @@ declare const myUsernameState: AtomIO.RegularAtomToken<string | null>;
|
|
|
26
26
|
declare const optimisticUpdateQueue: AtomIO.RegularAtomToken<AtomIO.TransactionUpdate<any>[]>;
|
|
27
27
|
declare const confirmedUpdateQueue: AtomIO.RegularAtomToken<AtomIO.TransactionUpdate<any>[]>;
|
|
28
28
|
|
|
29
|
-
declare function serverAction
|
|
29
|
+
declare function serverAction<F extends AtomIO.Func>(token: AtomIO.TransactionToken<F>, socket: Socket, store: Internal.Store): () => void;
|
|
30
30
|
|
|
31
|
-
declare function syncContinuity
|
|
31
|
+
declare function syncContinuity<F extends AtomIO.Func>(continuity: ContinuityToken, socket: Socket, store: Store): () => void;
|
|
32
32
|
|
|
33
33
|
export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, serverAction, syncContinuity };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { syncContinuity } from '../../dist/chunk-
|
|
1
|
+
export { syncContinuity } from '../../dist/chunk-ATKDGVTV.js';
|
|
2
2
|
export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue } from '../../dist/chunk-O47EQUM6.js';
|
|
3
3
|
import '../../dist/chunk-BWWVY5O5.js';
|
|
4
|
-
import '../../dist/chunk-
|
|
4
|
+
import '../../dist/chunk-F2X4B4VY.js';
|
|
5
5
|
import * as Internal from 'atom.io/internal';
|
|
6
6
|
import { setIntoStore, getJsonToken, getUpdateToken } from 'atom.io/internal';
|
|
7
7
|
import { parseJson } from 'atom.io/json';
|
|
@@ -2,8 +2,8 @@ import type * as AtomIO from "atom.io"
|
|
|
2
2
|
import * as Internal from "atom.io/internal"
|
|
3
3
|
import type { Socket } from "socket.io-client"
|
|
4
4
|
|
|
5
|
-
export function serverAction
|
|
6
|
-
token: AtomIO.TransactionToken
|
|
5
|
+
export function serverAction<F extends AtomIO.Func>(
|
|
6
|
+
token: AtomIO.TransactionToken<F>,
|
|
7
7
|
socket: Socket,
|
|
8
8
|
store: Internal.Store,
|
|
9
9
|
): () => void {
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "atom.io/realtime-client"
|
|
22
22
|
import type { Socket } from "socket.io-client"
|
|
23
23
|
|
|
24
|
-
export function syncContinuity
|
|
24
|
+
export function syncContinuity<F extends AtomIO.Func>(
|
|
25
25
|
continuity: ContinuityToken,
|
|
26
26
|
socket: Socket,
|
|
27
27
|
store: Store,
|
|
@@ -54,7 +54,7 @@ export function syncContinuity<ƒ extends AtomIO.ƒn>(
|
|
|
54
54
|
socket.on(`continuity-init:${continuityKey}`, initializeContinuity)
|
|
55
55
|
|
|
56
56
|
const registerAndAttemptConfirmedUpdate = (
|
|
57
|
-
|
|
57
|
+
confirmed: AtomIO.TransactionUpdate<F>,
|
|
58
58
|
) => {
|
|
59
59
|
function reconcileEpoch(
|
|
60
60
|
optimisticUpdate: AtomIO.TransactionUpdate<any>,
|
|
@@ -155,7 +155,7 @@ export function syncContinuity<ƒ extends AtomIO.ƒn>(
|
|
|
155
155
|
`continuity`,
|
|
156
156
|
continuityKey,
|
|
157
157
|
`integrating confirmed update`,
|
|
158
|
-
{ confirmedUpdate, confirmedUpdates, optimisticUpdates },
|
|
158
|
+
{ confirmedUpdate: confirmed, confirmedUpdates, optimisticUpdates },
|
|
159
159
|
)
|
|
160
160
|
const zerothOptimisticUpdate = optimisticUpdates[0]
|
|
161
161
|
if (zerothOptimisticUpdate) {
|
|
@@ -165,14 +165,14 @@ export function syncContinuity<ƒ extends AtomIO.ƒn>(
|
|
|
165
165
|
continuityKey,
|
|
166
166
|
`has optimistic updates to reconcile`,
|
|
167
167
|
)
|
|
168
|
-
if (
|
|
168
|
+
if (confirmed.epoch === zerothOptimisticUpdate.epoch) {
|
|
169
169
|
store.logger.info(
|
|
170
170
|
`🧑⚖️`,
|
|
171
171
|
`continuity`,
|
|
172
172
|
continuityKey,
|
|
173
|
-
`epoch of confirmed update #${
|
|
173
|
+
`epoch of confirmed update #${confirmed.epoch} matches zeroth optimistic update`,
|
|
174
174
|
)
|
|
175
|
-
reconcileEpoch(zerothOptimisticUpdate,
|
|
175
|
+
reconcileEpoch(zerothOptimisticUpdate, confirmed)
|
|
176
176
|
for (const nextConfirmed of confirmedUpdates) {
|
|
177
177
|
const nextOptimistic = optimisticUpdates[0]
|
|
178
178
|
if (nextConfirmed.epoch === nextOptimistic?.epoch) {
|
|
@@ -187,10 +187,10 @@ export function syncContinuity<ƒ extends AtomIO.ƒn>(
|
|
|
187
187
|
`🧑⚖️`,
|
|
188
188
|
`continuity`,
|
|
189
189
|
continuityKey,
|
|
190
|
-
`epoch of confirmed update #${
|
|
190
|
+
`epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`,
|
|
191
191
|
)
|
|
192
192
|
const confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(
|
|
193
|
-
(update) => update.epoch ===
|
|
193
|
+
(update) => update.epoch === confirmed.epoch,
|
|
194
194
|
)
|
|
195
195
|
if (!confirmedUpdateIsAlreadyEnqueued) {
|
|
196
196
|
store.logger.info(
|
|
@@ -198,12 +198,12 @@ export function syncContinuity<ƒ extends AtomIO.ƒn>(
|
|
|
198
198
|
`continuity`,
|
|
199
199
|
continuityKey,
|
|
200
200
|
`pushing confirmed update to queue`,
|
|
201
|
-
|
|
201
|
+
confirmed,
|
|
202
202
|
)
|
|
203
203
|
setIntoStore(
|
|
204
204
|
confirmedUpdateQueue,
|
|
205
205
|
(queue) => {
|
|
206
|
-
queue.push(
|
|
206
|
+
queue.push(confirmed)
|
|
207
207
|
queue.sort((a, b) => a.epoch - b.epoch)
|
|
208
208
|
return queue
|
|
209
209
|
},
|
|
@@ -221,50 +221,50 @@ export function syncContinuity<ƒ extends AtomIO.ƒn>(
|
|
|
221
221
|
const continuityEpoch = getEpochNumberOfContinuity(continuityKey, store)
|
|
222
222
|
const isRoot = isRootStore(store)
|
|
223
223
|
|
|
224
|
-
if (isRoot && continuityEpoch ===
|
|
224
|
+
if (isRoot && continuityEpoch === confirmed.epoch - 1) {
|
|
225
225
|
store.logger.info(
|
|
226
226
|
`✅`,
|
|
227
227
|
`continuity`,
|
|
228
228
|
continuityKey,
|
|
229
|
-
`integrating update #${
|
|
229
|
+
`integrating update #${confirmed.epoch} (${confirmed.key} ${confirmed.id})`,
|
|
230
230
|
)
|
|
231
|
-
ingestTransactionUpdate(`newValue`,
|
|
232
|
-
socket.emit(`ack:${continuityKey}`,
|
|
233
|
-
setEpochNumberOfContinuity(continuityKey,
|
|
231
|
+
ingestTransactionUpdate(`newValue`, confirmed, store)
|
|
232
|
+
socket.emit(`ack:${continuityKey}`, confirmed.epoch)
|
|
233
|
+
setEpochNumberOfContinuity(continuityKey, confirmed.epoch, store)
|
|
234
234
|
} else if (isRoot && continuityEpoch !== undefined) {
|
|
235
235
|
store.logger.info(
|
|
236
236
|
`🧑⚖️`,
|
|
237
237
|
`continuity`,
|
|
238
238
|
continuityKey,
|
|
239
|
-
`received update #${
|
|
240
|
-
|
|
241
|
-
}
|
|
239
|
+
`received update #${confirmed.epoch} but still waiting for update #${
|
|
240
|
+
continuityEpoch + 1
|
|
241
|
+
}`,
|
|
242
242
|
{
|
|
243
243
|
clientEpoch: continuityEpoch,
|
|
244
|
-
serverEpoch:
|
|
244
|
+
serverEpoch: confirmed.epoch,
|
|
245
245
|
},
|
|
246
246
|
)
|
|
247
247
|
const confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(
|
|
248
|
-
(update) => update.epoch ===
|
|
248
|
+
(update) => update.epoch === confirmed.epoch,
|
|
249
249
|
)
|
|
250
250
|
if (confirmedUpdateIsAlreadyEnqueued) {
|
|
251
251
|
store.logger.info(
|
|
252
252
|
`👍`,
|
|
253
253
|
`continuity`,
|
|
254
254
|
continuityKey,
|
|
255
|
-
`confirmed update #${
|
|
255
|
+
`confirmed update #${confirmed.epoch} is already enqueued`,
|
|
256
256
|
)
|
|
257
257
|
} else {
|
|
258
258
|
store.logger.info(
|
|
259
259
|
`👈`,
|
|
260
260
|
`continuity`,
|
|
261
261
|
continuityKey,
|
|
262
|
-
`pushing confirmed update #${
|
|
262
|
+
`pushing confirmed update #${confirmed.epoch} to queue`,
|
|
263
263
|
)
|
|
264
264
|
setIntoStore(
|
|
265
265
|
confirmedUpdateQueue,
|
|
266
266
|
(queue) => {
|
|
267
|
-
queue.push(
|
|
267
|
+
queue.push(confirmed)
|
|
268
268
|
queue.sort((a, b) => a.epoch - b.epoch)
|
|
269
269
|
return queue
|
|
270
270
|
},
|