atom.io 0.40.7 → 0.40.8
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/dist/data/index.js +1 -2
- package/dist/data/index.js.map +1 -1
- package/dist/employ-socket-D6wgByWh.js.map +1 -1
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/{has-role-hv4-hJMw.js → has-role-CMlaUlaf.js} +30 -46
- package/dist/has-role-CMlaUlaf.js.map +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +103 -174
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.d.ts.map +1 -1
- package/dist/introspection/index.js +13 -32
- package/dist/introspection/index.js.map +1 -1
- package/dist/is-fn-DY1wZ-md.js.map +1 -1
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +1 -2
- package/dist/main/index.js.map +1 -1
- package/dist/mutex-store-CSvxY9i3.js.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-devtools/index.d.ts.map +1 -1
- package/dist/react-devtools/index.js +2 -4
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +2 -3
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +1 -4
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js +5 -20
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts +2 -5
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js +4 -15
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +36 -44
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js +125 -171
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/realtime-testing/index.d.ts +4 -2
- package/dist/realtime-testing/index.d.ts.map +1 -1
- package/dist/realtime-testing/index.js +13 -7
- package/dist/realtime-testing/index.js.map +1 -1
- package/dist/{shared-room-store-COGGKqes.js → shared-room-store-BfW3nWif.js} +2 -3
- package/dist/{shared-room-store-COGGKqes.js.map → shared-room-store-BfW3nWif.js.map} +1 -1
- package/dist/shared-room-store-D2o4ZLjC.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.js +4 -8
- package/dist/transceivers/set-rtx/index.js.map +1 -1
- package/dist/web/index.js.map +1 -1
- package/package.json +11 -11
- package/src/internal/mutable/tracker.ts +66 -51
- package/src/internal/subscribe/subscribe-to-state.ts +9 -0
- package/src/realtime-client/index.ts +0 -1
- package/src/realtime-react/index.ts +0 -1
- package/src/realtime-server/continuity/continuity-store.ts +1 -26
- package/src/realtime-server/continuity/provide-continuity.ts +50 -0
- package/src/realtime-server/continuity/{subscribe-to-continuity-actions.ts → provide-outcomes.ts} +14 -12
- package/src/realtime-server/continuity/{subscribe-to-continuity-perpectives.ts → provide-perspectives.ts} +10 -8
- package/src/realtime-server/continuity/{prepare-to-send-initial-payload.ts → provide-startup-payloads.ts} +6 -4
- package/src/realtime-server/continuity/receive-action-requests.ts +68 -0
- package/src/realtime-server/continuity/{prepare-to-track-client-acknowledgement.ts → track-acknowledgements.ts} +15 -8
- package/src/realtime-server/index.ts +1 -2
- package/src/realtime-server/ipc-sockets/custom-socket.ts +3 -3
- package/src/realtime-server/ipc-sockets/parent-socket.ts +19 -13
- package/src/realtime-server/server-config.ts +0 -1
- package/src/realtime-testing/setup-realtime-test.tsx +20 -14
- package/dist/has-role-hv4-hJMw.js.map +0 -1
- package/src/realtime-client/server-action.ts +0 -23
- package/src/realtime-react/use-server-action.ts +0 -19
- package/src/realtime-server/continuity/prepare-to-serve-transaction-request.ts +0 -59
- package/src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts +0 -145
- package/src/realtime-server/realtime-action-receiver.ts +0 -40
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
findInStore,
|
|
3
|
-
findRelationsInStore,
|
|
4
|
-
getFromStore,
|
|
5
|
-
IMPLICIT,
|
|
6
|
-
subscribeToState,
|
|
7
|
-
} from "atom.io/internal"
|
|
8
|
-
import type { Json } from "atom.io/json"
|
|
9
|
-
import type { ContinuityToken } from "atom.io/realtime"
|
|
10
|
-
|
|
11
|
-
import type { ServerConfig, Socket } from ".."
|
|
12
|
-
import { socketAtoms, usersOfSockets } from ".."
|
|
13
|
-
import { userUnacknowledgedQueues } from "./continuity-store"
|
|
14
|
-
import { prepareToSendInitialPayload } from "./prepare-to-send-initial-payload"
|
|
15
|
-
import { prepareToServeTransactionRequest } from "./prepare-to-serve-transaction-request"
|
|
16
|
-
import { prepareToTrackClientAcknowledgement } from "./prepare-to-track-client-acknowledgement"
|
|
17
|
-
import { subscribeToContinuityActions } from "./subscribe-to-continuity-actions"
|
|
18
|
-
import { subscribeToContinuityPerspectives } from "./subscribe-to-continuity-perpectives"
|
|
19
|
-
|
|
20
|
-
export type ExposeRealtimeContinuity = (
|
|
21
|
-
continuity: ContinuityToken,
|
|
22
|
-
) => () => void
|
|
23
|
-
export function prepareToExposeRealtimeContinuity({
|
|
24
|
-
socket: initialSocket,
|
|
25
|
-
store = IMPLICIT.STORE,
|
|
26
|
-
}: ServerConfig): ExposeRealtimeContinuity {
|
|
27
|
-
return function syncRealtimeContinuity(continuity) {
|
|
28
|
-
let socket: Socket | null = initialSocket
|
|
29
|
-
|
|
30
|
-
const continuityKey = continuity.key
|
|
31
|
-
const userKeyState = findRelationsInStore(
|
|
32
|
-
usersOfSockets,
|
|
33
|
-
`socket::${socket.id}`,
|
|
34
|
-
store,
|
|
35
|
-
).userKeyOfSocket
|
|
36
|
-
const userKey = getFromStore(store, userKeyState)
|
|
37
|
-
if (!userKey) {
|
|
38
|
-
store.logger.error(
|
|
39
|
-
`❌`,
|
|
40
|
-
`continuity`,
|
|
41
|
-
continuityKey,
|
|
42
|
-
`Tried to create a synchronizer for a socket (${socket.id}) that is not connected to a user.`,
|
|
43
|
-
)
|
|
44
|
-
return () => {}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const socketKeyState = findRelationsInStore(
|
|
48
|
-
usersOfSockets,
|
|
49
|
-
userKey,
|
|
50
|
-
store,
|
|
51
|
-
).socketKeyOfUser
|
|
52
|
-
const _unsubscribeFromSocketTracking = subscribeToState(
|
|
53
|
-
store,
|
|
54
|
-
socketKeyState,
|
|
55
|
-
`sync-continuity:${continuityKey}:${userKey}`,
|
|
56
|
-
({ newValue: newSocketKey }) => {
|
|
57
|
-
store.logger.info(
|
|
58
|
-
`👋`,
|
|
59
|
-
`continuity`,
|
|
60
|
-
continuityKey,
|
|
61
|
-
`seeing ${userKey} on new socket ${newSocketKey}`,
|
|
62
|
-
)
|
|
63
|
-
if (newSocketKey === null) {
|
|
64
|
-
store.logger.warn(
|
|
65
|
-
`❌`,
|
|
66
|
-
`continuity`,
|
|
67
|
-
continuityKey,
|
|
68
|
-
`User (${userKey}) is not connected to a socket, waiting for them to reappear.`,
|
|
69
|
-
)
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
const newSocketState = findInStore(store, socketAtoms, newSocketKey)
|
|
73
|
-
const newSocket = getFromStore(store, newSocketState)
|
|
74
|
-
socket = newSocket
|
|
75
|
-
for (const unacknowledgedUpdate of userUnacknowledgedUpdates) {
|
|
76
|
-
socket?.emit(
|
|
77
|
-
`tx-new:${continuityKey}`,
|
|
78
|
-
unacknowledgedUpdate as Json.Serializable,
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
const userUnacknowledgedUpdates = getFromStore(
|
|
85
|
-
store,
|
|
86
|
-
userUnacknowledgedQueues,
|
|
87
|
-
userKey,
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
const unsubscribeFunctions: (() => void)[] = []
|
|
91
|
-
|
|
92
|
-
const unsubscribeFromPerspectives = subscribeToContinuityPerspectives(
|
|
93
|
-
store,
|
|
94
|
-
continuity,
|
|
95
|
-
userKey,
|
|
96
|
-
socket,
|
|
97
|
-
)
|
|
98
|
-
const unsubscribeFromTransactions = subscribeToContinuityActions(
|
|
99
|
-
store,
|
|
100
|
-
continuity,
|
|
101
|
-
userKey,
|
|
102
|
-
socket,
|
|
103
|
-
)
|
|
104
|
-
unsubscribeFunctions.push(
|
|
105
|
-
...unsubscribeFromPerspectives,
|
|
106
|
-
...unsubscribeFromTransactions,
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
const sendInitialPayload = prepareToSendInitialPayload(
|
|
110
|
-
store,
|
|
111
|
-
continuity,
|
|
112
|
-
userKey,
|
|
113
|
-
initialSocket,
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
socket.off(`get:${continuityKey}`, sendInitialPayload)
|
|
117
|
-
socket.on(`get:${continuityKey}`, sendInitialPayload)
|
|
118
|
-
|
|
119
|
-
const fillTransactionRequest = prepareToServeTransactionRequest(
|
|
120
|
-
store,
|
|
121
|
-
continuity,
|
|
122
|
-
userKey,
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
socket.off(`tx-run:${continuityKey}`, fillTransactionRequest)
|
|
126
|
-
socket.on(`tx-run:${continuityKey}`, fillTransactionRequest)
|
|
127
|
-
|
|
128
|
-
const trackClientAcknowledgement = prepareToTrackClientAcknowledgement(
|
|
129
|
-
store,
|
|
130
|
-
continuity,
|
|
131
|
-
userKey,
|
|
132
|
-
userUnacknowledgedUpdates,
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
socket?.on(`ack:${continuityKey}`, trackClientAcknowledgement)
|
|
136
|
-
|
|
137
|
-
return () => {
|
|
138
|
-
// clearInterval(retryTimeout)
|
|
139
|
-
for (const unsubscribe of unsubscribeFunctions) unsubscribe()
|
|
140
|
-
socket?.off(`ack:${continuityKey}`, trackClientAcknowledgement)
|
|
141
|
-
socket?.off(`get:${continuityKey}`, sendInitialPayload)
|
|
142
|
-
socket?.off(`tx-run:${continuityKey}`, fillTransactionRequest)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { TransactionOutcomeEvent, TransactionToken } from "atom.io"
|
|
2
|
-
import { actUponStore, IMPLICIT } from "atom.io/internal"
|
|
3
|
-
import type { JsonIO } from "atom.io/json"
|
|
4
|
-
|
|
5
|
-
import type { ServerConfig } from "."
|
|
6
|
-
|
|
7
|
-
export type ActionReceiver = ReturnType<typeof realtimeActionReceiver>
|
|
8
|
-
export function realtimeActionReceiver({
|
|
9
|
-
socket,
|
|
10
|
-
store = IMPLICIT.STORE,
|
|
11
|
-
}: ServerConfig) {
|
|
12
|
-
return function actionReceiver<F extends JsonIO>(
|
|
13
|
-
tx: TransactionToken<F>,
|
|
14
|
-
): () => void {
|
|
15
|
-
const fillTransactionRequest = (
|
|
16
|
-
update: Pick<
|
|
17
|
-
TransactionOutcomeEvent<TransactionToken<F>>,
|
|
18
|
-
`id` | `params`
|
|
19
|
-
>,
|
|
20
|
-
) => {
|
|
21
|
-
const performanceKey = `tx-run:${tx.key}:${update.id}`
|
|
22
|
-
const performanceKeyStart = `${performanceKey}:start`
|
|
23
|
-
const performanceKeyEnd = `${performanceKey}:end`
|
|
24
|
-
performance.mark(performanceKeyStart)
|
|
25
|
-
actUponStore<F>(store, tx, update.id)(...update.params)
|
|
26
|
-
performance.mark(performanceKeyEnd)
|
|
27
|
-
const metric = performance.measure(
|
|
28
|
-
performanceKey,
|
|
29
|
-
performanceKeyStart,
|
|
30
|
-
performanceKeyEnd,
|
|
31
|
-
)
|
|
32
|
-
store?.logger.info(`🚀`, `transaction`, tx.key, update.id, metric.duration)
|
|
33
|
-
}
|
|
34
|
-
socket.on(`tx-run:${tx.key}`, fillTransactionRequest)
|
|
35
|
-
|
|
36
|
-
return () => {
|
|
37
|
-
socket.off(`tx-run:${tx.key}`, fillTransactionRequest)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|