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
|
@@ -194,8 +194,8 @@ function syncContinuity(continuity, socket, store) {
|
|
|
194
194
|
};
|
|
195
195
|
socket.off(`continuity-init:${continuityKey}`);
|
|
196
196
|
socket.on(`continuity-init:${continuityKey}`, initializeContinuity);
|
|
197
|
-
const registerAndAttemptConfirmedUpdate = (
|
|
198
|
-
function reconcileEpoch(optimisticUpdate,
|
|
197
|
+
const registerAndAttemptConfirmedUpdate = (confirmed) => {
|
|
198
|
+
function reconcileEpoch(optimisticUpdate, confirmedUpdate) {
|
|
199
199
|
store.logger.info(
|
|
200
200
|
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
201
201
|
`continuity`,
|
|
@@ -210,9 +210,9 @@ function syncContinuity(continuity, socket, store) {
|
|
|
210
210
|
},
|
|
211
211
|
store
|
|
212
212
|
);
|
|
213
|
-
if (optimisticUpdate.id ===
|
|
213
|
+
if (optimisticUpdate.id === confirmedUpdate.id) {
|
|
214
214
|
const clientResult = JSON.stringify(optimisticUpdate.updates);
|
|
215
|
-
const serverResult = JSON.stringify(
|
|
215
|
+
const serverResult = JSON.stringify(confirmedUpdate.updates);
|
|
216
216
|
if (clientResult === serverResult) {
|
|
217
217
|
store.logger.info(
|
|
218
218
|
`\u2705`,
|
|
@@ -220,7 +220,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
220
220
|
continuityKey,
|
|
221
221
|
`results for ${optimisticUpdate.id} match between client and server`
|
|
222
222
|
);
|
|
223
|
-
socket.emit(`ack:${continuityKey}`,
|
|
223
|
+
socket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch);
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
226
|
} else {
|
|
@@ -228,7 +228,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
228
228
|
`\u274C`,
|
|
229
229
|
`continuity`,
|
|
230
230
|
continuityKey,
|
|
231
|
-
`thought update #${
|
|
231
|
+
`thought update #${confirmedUpdate.epoch} was ${optimisticUpdate.key}:${optimisticUpdate.id}, but it was actually ${confirmedUpdate.key}:${confirmedUpdate.id}`
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
234
|
store.logger.info(
|
|
@@ -237,7 +237,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
237
237
|
continuityKey,
|
|
238
238
|
`updates do not match`,
|
|
239
239
|
optimisticUpdate,
|
|
240
|
-
|
|
240
|
+
confirmedUpdate
|
|
241
241
|
);
|
|
242
242
|
const reversedOptimisticUpdates = optimisticUpdates.toReversed();
|
|
243
243
|
for (const subsequentOptimistic of reversedOptimisticUpdates) {
|
|
@@ -258,15 +258,15 @@ function syncContinuity(continuity, socket, store) {
|
|
|
258
258
|
`undid zeroth optimistic update`,
|
|
259
259
|
optimisticUpdate
|
|
260
260
|
);
|
|
261
|
-
internal.ingestTransactionUpdate(`newValue`,
|
|
261
|
+
internal.ingestTransactionUpdate(`newValue`, confirmedUpdate, store);
|
|
262
262
|
store.logger.info(
|
|
263
263
|
`\u23E9`,
|
|
264
264
|
`continuity`,
|
|
265
265
|
continuityKey,
|
|
266
266
|
`applied confirmed update`,
|
|
267
|
-
|
|
267
|
+
confirmedUpdate
|
|
268
268
|
);
|
|
269
|
-
socket.emit(`ack:${continuityKey}`,
|
|
269
|
+
socket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch);
|
|
270
270
|
for (const subsequentOptimistic of optimisticUpdates) {
|
|
271
271
|
const token = {
|
|
272
272
|
type: `transaction`,
|
|
@@ -288,7 +288,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
288
288
|
`continuity`,
|
|
289
289
|
continuityKey,
|
|
290
290
|
`integrating confirmed update`,
|
|
291
|
-
{ confirmedUpdate, confirmedUpdates, optimisticUpdates }
|
|
291
|
+
{ confirmedUpdate: confirmed, confirmedUpdates, optimisticUpdates }
|
|
292
292
|
);
|
|
293
293
|
const zerothOptimisticUpdate = optimisticUpdates[0];
|
|
294
294
|
if (zerothOptimisticUpdate) {
|
|
@@ -298,14 +298,14 @@ function syncContinuity(continuity, socket, store) {
|
|
|
298
298
|
continuityKey,
|
|
299
299
|
`has optimistic updates to reconcile`
|
|
300
300
|
);
|
|
301
|
-
if (
|
|
301
|
+
if (confirmed.epoch === zerothOptimisticUpdate.epoch) {
|
|
302
302
|
store.logger.info(
|
|
303
303
|
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
304
304
|
`continuity`,
|
|
305
305
|
continuityKey,
|
|
306
|
-
`epoch of confirmed update #${
|
|
306
|
+
`epoch of confirmed update #${confirmed.epoch} matches zeroth optimistic update`
|
|
307
307
|
);
|
|
308
|
-
reconcileEpoch(zerothOptimisticUpdate,
|
|
308
|
+
reconcileEpoch(zerothOptimisticUpdate, confirmed);
|
|
309
309
|
for (const nextConfirmed of confirmedUpdates) {
|
|
310
310
|
const nextOptimistic = optimisticUpdates[0];
|
|
311
311
|
if (nextConfirmed.epoch === (nextOptimistic == null ? void 0 : nextOptimistic.epoch)) {
|
|
@@ -319,10 +319,10 @@ function syncContinuity(continuity, socket, store) {
|
|
|
319
319
|
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
320
320
|
`continuity`,
|
|
321
321
|
continuityKey,
|
|
322
|
-
`epoch of confirmed update #${
|
|
322
|
+
`epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`
|
|
323
323
|
);
|
|
324
324
|
const confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(
|
|
325
|
-
(update) => update.epoch ===
|
|
325
|
+
(update) => update.epoch === confirmed.epoch
|
|
326
326
|
);
|
|
327
327
|
if (!confirmedUpdateIsAlreadyEnqueued) {
|
|
328
328
|
store.logger.info(
|
|
@@ -330,12 +330,12 @@ function syncContinuity(continuity, socket, store) {
|
|
|
330
330
|
`continuity`,
|
|
331
331
|
continuityKey,
|
|
332
332
|
`pushing confirmed update to queue`,
|
|
333
|
-
|
|
333
|
+
confirmed
|
|
334
334
|
);
|
|
335
335
|
internal.setIntoStore(
|
|
336
336
|
RTC.confirmedUpdateQueue,
|
|
337
337
|
(queue) => {
|
|
338
|
-
queue.push(
|
|
338
|
+
queue.push(confirmed);
|
|
339
339
|
queue.sort((a, b) => a.epoch - b.epoch);
|
|
340
340
|
return queue;
|
|
341
341
|
},
|
|
@@ -352,48 +352,48 @@ function syncContinuity(continuity, socket, store) {
|
|
|
352
352
|
);
|
|
353
353
|
const continuityEpoch = internal.getEpochNumberOfContinuity(continuityKey, store);
|
|
354
354
|
const isRoot = internal.isRootStore(store);
|
|
355
|
-
if (isRoot && continuityEpoch ===
|
|
355
|
+
if (isRoot && continuityEpoch === confirmed.epoch - 1) {
|
|
356
356
|
store.logger.info(
|
|
357
357
|
`\u2705`,
|
|
358
358
|
`continuity`,
|
|
359
359
|
continuityKey,
|
|
360
|
-
`integrating update #${
|
|
360
|
+
`integrating update #${confirmed.epoch} (${confirmed.key} ${confirmed.id})`
|
|
361
361
|
);
|
|
362
|
-
internal.ingestTransactionUpdate(`newValue`,
|
|
363
|
-
socket.emit(`ack:${continuityKey}`,
|
|
364
|
-
internal.setEpochNumberOfContinuity(continuityKey,
|
|
362
|
+
internal.ingestTransactionUpdate(`newValue`, confirmed, store);
|
|
363
|
+
socket.emit(`ack:${continuityKey}`, confirmed.epoch);
|
|
364
|
+
internal.setEpochNumberOfContinuity(continuityKey, confirmed.epoch, store);
|
|
365
365
|
} else if (isRoot && continuityEpoch !== void 0) {
|
|
366
366
|
store.logger.info(
|
|
367
367
|
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
368
368
|
`continuity`,
|
|
369
369
|
continuityKey,
|
|
370
|
-
`received update #${
|
|
370
|
+
`received update #${confirmed.epoch} but still waiting for update #${continuityEpoch + 1}`,
|
|
371
371
|
{
|
|
372
372
|
clientEpoch: continuityEpoch,
|
|
373
|
-
serverEpoch:
|
|
373
|
+
serverEpoch: confirmed.epoch
|
|
374
374
|
}
|
|
375
375
|
);
|
|
376
376
|
const confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(
|
|
377
|
-
(update) => update.epoch ===
|
|
377
|
+
(update) => update.epoch === confirmed.epoch
|
|
378
378
|
);
|
|
379
379
|
if (confirmedUpdateIsAlreadyEnqueued) {
|
|
380
380
|
store.logger.info(
|
|
381
381
|
`\u{1F44D}`,
|
|
382
382
|
`continuity`,
|
|
383
383
|
continuityKey,
|
|
384
|
-
`confirmed update #${
|
|
384
|
+
`confirmed update #${confirmed.epoch} is already enqueued`
|
|
385
385
|
);
|
|
386
386
|
} else {
|
|
387
387
|
store.logger.info(
|
|
388
388
|
`\u{1F448}`,
|
|
389
389
|
`continuity`,
|
|
390
390
|
continuityKey,
|
|
391
|
-
`pushing confirmed update #${
|
|
391
|
+
`pushing confirmed update #${confirmed.epoch} to queue`
|
|
392
392
|
);
|
|
393
393
|
internal.setIntoStore(
|
|
394
394
|
RTC.confirmedUpdateQueue,
|
|
395
395
|
(queue) => {
|
|
396
|
-
queue.push(
|
|
396
|
+
queue.push(confirmed);
|
|
397
397
|
queue.sort((a, b) => a.epoch - b.epoch);
|
|
398
398
|
return queue;
|
|
399
399
|
},
|
|
@@ -32,9 +32,9 @@ declare function usePullSelectorFamilyMember<T, K extends Json.Serializable, Key
|
|
|
32
32
|
|
|
33
33
|
declare function usePush<J extends Json.Serializable>(token: AtomIO.WritableToken<J>): <New extends J>(next: New | ((old: J) => New)) => void;
|
|
34
34
|
|
|
35
|
-
declare function useServerAction
|
|
35
|
+
declare function useServerAction<F extends AtomIO.Func>(token: AtomIO.TransactionToken<F>): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
36
36
|
|
|
37
|
-
type PerspectiveToken<F extends AtomFamilyToken<any>, T extends F extends AtomFamilyToken<infer
|
|
37
|
+
type PerspectiveToken<F extends AtomFamilyToken<any>, T extends F extends AtomFamilyToken<infer U, any> ? U : never> = {
|
|
38
38
|
type: `realtime_perspective`;
|
|
39
39
|
resourceAtoms: F;
|
|
40
40
|
viewAtoms: ReadableFamilyToken<ReadableToken<T>[], string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { syncContinuity } from '../../dist/chunk-
|
|
2
|
-
import '../../dist/chunk-
|
|
1
|
+
import { syncContinuity } from '../../dist/chunk-ATKDGVTV.js';
|
|
2
|
+
import '../../dist/chunk-F2X4B4VY.js';
|
|
3
3
|
import { useI, StoreContext, useO } from 'atom.io/react';
|
|
4
4
|
import * as RTC from 'atom.io/realtime-client';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -6,9 +6,9 @@ import * as React from "react"
|
|
|
6
6
|
|
|
7
7
|
import { useRealtimeService } from "./use-realtime-service"
|
|
8
8
|
|
|
9
|
-
export function useServerAction
|
|
10
|
-
token: AtomIO.TransactionToken
|
|
11
|
-
): (...parameters: Parameters
|
|
9
|
+
export function useServerAction<F extends AtomIO.Func>(
|
|
10
|
+
token: AtomIO.TransactionToken<F>,
|
|
11
|
+
): (...parameters: Parameters<F>) => ReturnType<F> {
|
|
12
12
|
const store = React.useContext(StoreContext)
|
|
13
13
|
|
|
14
14
|
useRealtimeService(`tx:${token.key}`, (socket) =>
|
|
@@ -130,12 +130,12 @@ var ChildSocket = class extends CustomSocket {
|
|
|
130
130
|
}
|
|
131
131
|
this.unprocessedEvents.push(...chunk.split(``));
|
|
132
132
|
const newInput = this.unprocessedEvents.shift();
|
|
133
|
-
this.incompleteData += newInput
|
|
133
|
+
this.incompleteData += newInput != null ? newInput : ``;
|
|
134
134
|
try {
|
|
135
135
|
if (this.incompleteData.startsWith(`error`)) {
|
|
136
136
|
console.log(`\u2757`, this.incompleteData);
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
let parsedEvent = json.parseJson(this.incompleteData);
|
|
139
139
|
this.handleEvent(...parsedEvent);
|
|
140
140
|
while (this.unprocessedEvents.length > 0) {
|
|
141
141
|
const event = this.unprocessedEvents.shift();
|
|
@@ -143,8 +143,8 @@ var ChildSocket = class extends CustomSocket {
|
|
|
143
143
|
if (this.unprocessedEvents.length === 0) {
|
|
144
144
|
this.incompleteData = event;
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
this.handleEvent(...
|
|
146
|
+
parsedEvent = json.parseJson(event);
|
|
147
|
+
this.handleEvent(...parsedEvent);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
this.incompleteData = ``;
|
|
@@ -161,15 +161,15 @@ var ChildSocket = class extends CustomSocket {
|
|
|
161
161
|
const chunk = buf.toString();
|
|
162
162
|
this.unprocessedLogs.push(...chunk.split(``));
|
|
163
163
|
const newInput = this.unprocessedLogs.shift();
|
|
164
|
-
this.incompleteLog += newInput
|
|
164
|
+
this.incompleteLog += newInput != null ? newInput : ``;
|
|
165
165
|
try {
|
|
166
|
-
|
|
166
|
+
let parsedLog = json.parseJson(this.incompleteLog);
|
|
167
167
|
this.handleLog(parsedLog);
|
|
168
168
|
while (this.unprocessedLogs.length > 0) {
|
|
169
169
|
this.incompleteLog = (_a = this.unprocessedLogs.shift()) != null ? _a : ``;
|
|
170
170
|
if (this.incompleteLog) {
|
|
171
|
-
|
|
172
|
-
this.handleLog(
|
|
171
|
+
parsedLog = json.parseJson(this.incompleteLog);
|
|
172
|
+
this.handleLog(parsedLog);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
} catch (error) {
|
|
@@ -233,9 +233,15 @@ var ParentSocket = class extends CustomSocket {
|
|
|
233
233
|
this.unprocessedEvents = [];
|
|
234
234
|
this.id = `#####`;
|
|
235
235
|
this.logger = {
|
|
236
|
-
info: (...args) =>
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
info: (...args) => {
|
|
237
|
+
this.log(`i`, ...args);
|
|
238
|
+
},
|
|
239
|
+
warn: (...args) => {
|
|
240
|
+
this.log(`w`, ...args);
|
|
241
|
+
},
|
|
242
|
+
error: (...args) => {
|
|
243
|
+
this.log(`e`, ...args);
|
|
244
|
+
}
|
|
239
245
|
};
|
|
240
246
|
this.process = process;
|
|
241
247
|
this.process.stdin.resume();
|
|
@@ -247,19 +253,19 @@ var ParentSocket = class extends CustomSocket {
|
|
|
247
253
|
const chunk = buffer.toString();
|
|
248
254
|
this.unprocessedEvents.push(...chunk.split(``));
|
|
249
255
|
const newInput = this.unprocessedEvents.shift();
|
|
250
|
-
this.incompleteData += newInput
|
|
256
|
+
this.incompleteData += newInput != null ? newInput : ``;
|
|
251
257
|
try {
|
|
252
|
-
const
|
|
253
|
-
this.logger.info(`\u{1F3B0}`, `received`,
|
|
254
|
-
this.handleEvent(...
|
|
258
|
+
const parsedData = json.parseJson(this.incompleteData);
|
|
259
|
+
this.logger.info(`\u{1F3B0}`, `received`, parsedData);
|
|
260
|
+
this.handleEvent(...parsedData);
|
|
255
261
|
while (this.unprocessedEvents.length > 0) {
|
|
256
262
|
const event = this.unprocessedEvents.shift();
|
|
257
263
|
if (event) {
|
|
258
264
|
if (this.unprocessedEvents.length === 0) {
|
|
259
265
|
this.incompleteData = event;
|
|
260
266
|
}
|
|
261
|
-
const
|
|
262
|
-
this.handleEvent(...
|
|
267
|
+
const parsedEvent = json.parseJson(event);
|
|
268
|
+
this.handleEvent(...parsedEvent);
|
|
263
269
|
}
|
|
264
270
|
}
|
|
265
271
|
this.incompleteData = ``;
|
|
@@ -352,21 +358,21 @@ function getJoinMap(store) {
|
|
|
352
358
|
function getJoin(token, store) {
|
|
353
359
|
var _a;
|
|
354
360
|
const joinMap = getJoinMap(store);
|
|
355
|
-
let
|
|
356
|
-
if (
|
|
361
|
+
let myJoin = joinMap.get(token.key);
|
|
362
|
+
if (myJoin === void 0) {
|
|
357
363
|
const rootJoinMap = getJoinMap(internal.IMPLICIT.STORE);
|
|
358
|
-
|
|
359
|
-
if (
|
|
364
|
+
myJoin = (_a = rootJoinMap.get(token.key)) == null ? void 0 : _a.in(store);
|
|
365
|
+
if (myJoin === void 0) {
|
|
360
366
|
throw new Error(
|
|
361
367
|
`Join "${token.key}" not found in store "${store.config.name}"`
|
|
362
368
|
);
|
|
363
369
|
}
|
|
364
|
-
joinMap.set(token.key,
|
|
370
|
+
joinMap.set(token.key, myJoin);
|
|
365
371
|
}
|
|
366
|
-
return
|
|
372
|
+
return myJoin;
|
|
367
373
|
}
|
|
368
374
|
function findRelationsInStore(token, key, store) {
|
|
369
|
-
const
|
|
375
|
+
const myJoin = getJoin(token, store);
|
|
370
376
|
let relations;
|
|
371
377
|
switch (token.cardinality) {
|
|
372
378
|
case `1:1`: {
|
|
@@ -374,27 +380,27 @@ function findRelationsInStore(token, key, store) {
|
|
|
374
380
|
const keyBA = `${token.b}KeyOf${capitalize(token.a)}`;
|
|
375
381
|
relations = {
|
|
376
382
|
get [keyAB]() {
|
|
377
|
-
const familyAB =
|
|
383
|
+
const familyAB = myJoin.states[keyAB];
|
|
378
384
|
const state = internal.findInStore(familyAB, key, store);
|
|
379
385
|
return state;
|
|
380
386
|
},
|
|
381
387
|
get [keyBA]() {
|
|
382
|
-
const familyBA =
|
|
388
|
+
const familyBA = myJoin.states[keyBA];
|
|
383
389
|
const state = internal.findInStore(familyBA, key, store);
|
|
384
390
|
return state;
|
|
385
391
|
}
|
|
386
392
|
};
|
|
387
393
|
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
388
|
-
if (entryAB in
|
|
394
|
+
if (entryAB in myJoin.states) {
|
|
389
395
|
const entryBA = `${token.b}EntryOf${capitalize(token.a)}`;
|
|
390
396
|
Object.assign(relations, {
|
|
391
397
|
get [entryAB]() {
|
|
392
|
-
const familyAB =
|
|
398
|
+
const familyAB = myJoin.states[entryAB];
|
|
393
399
|
const state = internal.findInStore(familyAB, key, store);
|
|
394
400
|
return state;
|
|
395
401
|
},
|
|
396
402
|
get [entryBA]() {
|
|
397
|
-
const familyBA =
|
|
403
|
+
const familyBA = myJoin.states[entryBA];
|
|
398
404
|
const state = internal.findInStore(familyBA, key, store);
|
|
399
405
|
return state;
|
|
400
406
|
}
|
|
@@ -407,27 +413,27 @@ function findRelationsInStore(token, key, store) {
|
|
|
407
413
|
const keysBA = `${token.b}KeysOf${capitalize(token.a)}`;
|
|
408
414
|
relations = {
|
|
409
415
|
get [keyAB]() {
|
|
410
|
-
const familyAB =
|
|
416
|
+
const familyAB = myJoin.states[keyAB];
|
|
411
417
|
const state = internal.findInStore(familyAB, key, store);
|
|
412
418
|
return state;
|
|
413
419
|
},
|
|
414
420
|
get [keysBA]() {
|
|
415
|
-
const familyBA =
|
|
421
|
+
const familyBA = myJoin.states[keysBA];
|
|
416
422
|
const state = internal.findInStore(familyBA, key, store);
|
|
417
423
|
return state;
|
|
418
424
|
}
|
|
419
425
|
};
|
|
420
426
|
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
421
|
-
if (entryAB in
|
|
427
|
+
if (entryAB in myJoin.states) {
|
|
422
428
|
const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
|
|
423
429
|
Object.assign(relations, {
|
|
424
430
|
get [entryAB]() {
|
|
425
|
-
const familyAB =
|
|
431
|
+
const familyAB = myJoin.states[entryAB];
|
|
426
432
|
const state = internal.findInStore(familyAB, key, store);
|
|
427
433
|
return state;
|
|
428
434
|
},
|
|
429
435
|
get [entriesBA]() {
|
|
430
|
-
const familyBA =
|
|
436
|
+
const familyBA = myJoin.states[entriesBA];
|
|
431
437
|
const state = internal.findInStore(familyBA, key, store);
|
|
432
438
|
return state;
|
|
433
439
|
}
|
|
@@ -440,27 +446,27 @@ function findRelationsInStore(token, key, store) {
|
|
|
440
446
|
const keysBA = `${token.b}KeysOf${capitalize(token.a)}`;
|
|
441
447
|
relations = {
|
|
442
448
|
get [keysAB]() {
|
|
443
|
-
const familyAB =
|
|
449
|
+
const familyAB = myJoin.states[keysAB];
|
|
444
450
|
const state = internal.findInStore(familyAB, key, store);
|
|
445
451
|
return state;
|
|
446
452
|
},
|
|
447
453
|
get [keysBA]() {
|
|
448
|
-
const familyBA =
|
|
454
|
+
const familyBA = myJoin.states[keysBA];
|
|
449
455
|
const state = internal.findInStore(familyBA, key, store);
|
|
450
456
|
return state;
|
|
451
457
|
}
|
|
452
458
|
};
|
|
453
459
|
const entriesAB = `${token.a}EntriesOf${capitalize(token.b)}`;
|
|
454
|
-
if (entriesAB in
|
|
460
|
+
if (entriesAB in myJoin.states) {
|
|
455
461
|
const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
|
|
456
462
|
Object.assign(relations, {
|
|
457
463
|
get [entriesAB]() {
|
|
458
|
-
const familyAB =
|
|
464
|
+
const familyAB = myJoin.states[entriesAB];
|
|
459
465
|
const state = internal.findInStore(familyAB, key, store);
|
|
460
466
|
return state;
|
|
461
467
|
},
|
|
462
468
|
get [entriesBA]() {
|
|
463
|
-
const familyBA =
|
|
469
|
+
const familyBA = myJoin.states[entriesBA];
|
|
464
470
|
const state = internal.findInStore(familyBA, key, store);
|
|
465
471
|
return state;
|
|
466
472
|
}
|
|
@@ -723,7 +729,7 @@ function realtimeContinuitySynchronizer({
|
|
|
723
729
|
);
|
|
724
730
|
const unsubscribeFunctions = [];
|
|
725
731
|
const revealPerspectives = () => {
|
|
726
|
-
const
|
|
732
|
+
const unsubFns = [];
|
|
727
733
|
for (const perspective of continuity.perspectives) {
|
|
728
734
|
const { viewAtoms } = perspective;
|
|
729
735
|
const userViewState = internal.findInStore(viewAtoms, userKey, store);
|
|
@@ -757,10 +763,10 @@ function realtimeContinuitySynchronizer({
|
|
|
757
763
|
`sync-continuity:${continuityKey}:${userKey}:perspective:${perspective.resourceAtoms.key}`,
|
|
758
764
|
store
|
|
759
765
|
);
|
|
760
|
-
|
|
766
|
+
unsubFns.push(unsubscribe);
|
|
761
767
|
}
|
|
762
768
|
return () => {
|
|
763
|
-
for (const unsubscribe of
|
|
769
|
+
for (const unsubscribe of unsubFns)
|
|
764
770
|
unsubscribe();
|
|
765
771
|
};
|
|
766
772
|
};
|
|
@@ -1087,7 +1093,9 @@ function realtimeStateReceiver({
|
|
|
1087
1093
|
store = internal.IMPLICIT.STORE
|
|
1088
1094
|
}) {
|
|
1089
1095
|
return function stateReceiver(token) {
|
|
1090
|
-
const publish = (newValue) =>
|
|
1096
|
+
const publish = (newValue) => {
|
|
1097
|
+
internal.setIntoStore(token, newValue, store);
|
|
1098
|
+
};
|
|
1091
1099
|
const fillPubUnclaim = () => {
|
|
1092
1100
|
socket.off(`pub:${token.key}`, publish);
|
|
1093
1101
|
socket.off(`unclaim:${token.key}`, fillPubUnclaim);
|
|
@@ -1123,7 +1131,9 @@ function realtimeActionReceiver({
|
|
|
1123
1131
|
store == null ? void 0 : store.logger.info(`\u{1F680}`, `transaction`, tx.key, update.id, metric.duration);
|
|
1124
1132
|
};
|
|
1125
1133
|
socket.on(`tx-run:${tx.key}`, fillTransactionRequest);
|
|
1126
|
-
return () =>
|
|
1134
|
+
return () => {
|
|
1135
|
+
socket.off(`tx-run:${tx.key}`, fillTransactionRequest);
|
|
1136
|
+
};
|
|
1127
1137
|
};
|
|
1128
1138
|
}
|
|
1129
1139
|
|
|
@@ -21,10 +21,10 @@ declare class CustomSocket<I extends Events, O extends Events> implements Socket
|
|
|
21
21
|
protected handleEvent<Event extends keyof I>(event: string, ...args: I[Event]): void;
|
|
22
22
|
id: string;
|
|
23
23
|
constructor(emit: <Event extends keyof O>(event: Event, ...args: O[Event]) => CustomSocket<I, O>);
|
|
24
|
-
on<Event extends keyof I>(event: Event, listener: (...args: I[Event]) => void):
|
|
25
|
-
onAny(listener: (event: string, ...args: Json.Array) => void):
|
|
26
|
-
off<Event extends keyof I>(event: Event, listener?: (...args: I[Event]) => void):
|
|
27
|
-
offAny(listener: (event: string, ...args: Json.Array) => void):
|
|
24
|
+
on<Event extends keyof I>(event: Event, listener: (...args: I[Event]) => void): this;
|
|
25
|
+
onAny(listener: (event: string, ...args: Json.Array) => void): this;
|
|
26
|
+
off<Event extends keyof I>(event: Event, listener?: (...args: I[Event]) => void): this;
|
|
27
|
+
offAny(listener: (event: string, ...args: Json.Array) => void): this;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
declare class ChildSocket<I extends Events, O extends Events & {
|
|
@@ -126,7 +126,7 @@ type StateReceiver = ReturnType<typeof realtimeStateReceiver>;
|
|
|
126
126
|
declare function realtimeStateReceiver({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: WritableToken<J>) => () => void;
|
|
127
127
|
|
|
128
128
|
type ActionReceiver = ReturnType<typeof realtimeActionReceiver>;
|
|
129
|
-
declare function realtimeActionReceiver({ socket, store, }: ServerConfig):
|
|
129
|
+
declare function realtimeActionReceiver({ socket, store, }: ServerConfig): <F extends JsonIO>(tx: AtomIO.TransactionToken<F>) => () => void;
|
|
130
130
|
|
|
131
131
|
type Socket = {
|
|
132
132
|
id: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { findRelationsInStore } from '../../dist/chunk-
|
|
2
|
-
import '../../dist/chunk-
|
|
3
|
-
import { __spreadProps, __spreadValues } from '../../dist/chunk-
|
|
1
|
+
import { findRelationsInStore } from '../../dist/chunk-MSCJWACE.js';
|
|
2
|
+
import '../../dist/chunk-FTONNX2R.js';
|
|
3
|
+
import { __spreadProps, __spreadValues } from '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { parseJson, stringifyJson } from 'atom.io/json';
|
|
5
5
|
import { getUpdateToken, IMPLICIT, Subject, getFromStore, subscribeToState, findInStore, getJsonToken, isRootStore, subscribeToTransaction, actUponStore, setIntoStore } from 'atom.io/internal';
|
|
6
6
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
@@ -92,12 +92,12 @@ var ChildSocket = class extends CustomSocket {
|
|
|
92
92
|
}
|
|
93
93
|
this.unprocessedEvents.push(...chunk.split(``));
|
|
94
94
|
const newInput = this.unprocessedEvents.shift();
|
|
95
|
-
this.incompleteData += newInput
|
|
95
|
+
this.incompleteData += newInput != null ? newInput : ``;
|
|
96
96
|
try {
|
|
97
97
|
if (this.incompleteData.startsWith(`error`)) {
|
|
98
98
|
console.log(`\u2757`, this.incompleteData);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
let parsedEvent = parseJson(this.incompleteData);
|
|
101
101
|
this.handleEvent(...parsedEvent);
|
|
102
102
|
while (this.unprocessedEvents.length > 0) {
|
|
103
103
|
const event = this.unprocessedEvents.shift();
|
|
@@ -105,8 +105,8 @@ var ChildSocket = class extends CustomSocket {
|
|
|
105
105
|
if (this.unprocessedEvents.length === 0) {
|
|
106
106
|
this.incompleteData = event;
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
this.handleEvent(...
|
|
108
|
+
parsedEvent = parseJson(event);
|
|
109
|
+
this.handleEvent(...parsedEvent);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
this.incompleteData = ``;
|
|
@@ -123,15 +123,15 @@ var ChildSocket = class extends CustomSocket {
|
|
|
123
123
|
const chunk = buf.toString();
|
|
124
124
|
this.unprocessedLogs.push(...chunk.split(``));
|
|
125
125
|
const newInput = this.unprocessedLogs.shift();
|
|
126
|
-
this.incompleteLog += newInput
|
|
126
|
+
this.incompleteLog += newInput != null ? newInput : ``;
|
|
127
127
|
try {
|
|
128
|
-
|
|
128
|
+
let parsedLog = parseJson(this.incompleteLog);
|
|
129
129
|
this.handleLog(parsedLog);
|
|
130
130
|
while (this.unprocessedLogs.length > 0) {
|
|
131
131
|
this.incompleteLog = (_a = this.unprocessedLogs.shift()) != null ? _a : ``;
|
|
132
132
|
if (this.incompleteLog) {
|
|
133
|
-
|
|
134
|
-
this.handleLog(
|
|
133
|
+
parsedLog = parseJson(this.incompleteLog);
|
|
134
|
+
this.handleLog(parsedLog);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
} catch (error) {
|
|
@@ -195,9 +195,15 @@ var ParentSocket = class extends CustomSocket {
|
|
|
195
195
|
this.unprocessedEvents = [];
|
|
196
196
|
this.id = `#####`;
|
|
197
197
|
this.logger = {
|
|
198
|
-
info: (...args) =>
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
info: (...args) => {
|
|
199
|
+
this.log(`i`, ...args);
|
|
200
|
+
},
|
|
201
|
+
warn: (...args) => {
|
|
202
|
+
this.log(`w`, ...args);
|
|
203
|
+
},
|
|
204
|
+
error: (...args) => {
|
|
205
|
+
this.log(`e`, ...args);
|
|
206
|
+
}
|
|
201
207
|
};
|
|
202
208
|
this.process = process;
|
|
203
209
|
this.process.stdin.resume();
|
|
@@ -209,19 +215,19 @@ var ParentSocket = class extends CustomSocket {
|
|
|
209
215
|
const chunk = buffer.toString();
|
|
210
216
|
this.unprocessedEvents.push(...chunk.split(``));
|
|
211
217
|
const newInput = this.unprocessedEvents.shift();
|
|
212
|
-
this.incompleteData += newInput
|
|
218
|
+
this.incompleteData += newInput != null ? newInput : ``;
|
|
213
219
|
try {
|
|
214
|
-
const
|
|
215
|
-
this.logger.info(`\u{1F3B0}`, `received`,
|
|
216
|
-
this.handleEvent(...
|
|
220
|
+
const parsedData = parseJson(this.incompleteData);
|
|
221
|
+
this.logger.info(`\u{1F3B0}`, `received`, parsedData);
|
|
222
|
+
this.handleEvent(...parsedData);
|
|
217
223
|
while (this.unprocessedEvents.length > 0) {
|
|
218
224
|
const event = this.unprocessedEvents.shift();
|
|
219
225
|
if (event) {
|
|
220
226
|
if (this.unprocessedEvents.length === 0) {
|
|
221
227
|
this.incompleteData = event;
|
|
222
228
|
}
|
|
223
|
-
const
|
|
224
|
-
this.handleEvent(...
|
|
229
|
+
const parsedEvent = parseJson(event);
|
|
230
|
+
this.handleEvent(...parsedEvent);
|
|
225
231
|
}
|
|
226
232
|
}
|
|
227
233
|
this.incompleteData = ``;
|
|
@@ -553,7 +559,7 @@ function realtimeContinuitySynchronizer({
|
|
|
553
559
|
);
|
|
554
560
|
const unsubscribeFunctions = [];
|
|
555
561
|
const revealPerspectives = () => {
|
|
556
|
-
const
|
|
562
|
+
const unsubFns = [];
|
|
557
563
|
for (const perspective of continuity.perspectives) {
|
|
558
564
|
const { viewAtoms } = perspective;
|
|
559
565
|
const userViewState = findInStore(viewAtoms, userKey, store);
|
|
@@ -587,10 +593,10 @@ function realtimeContinuitySynchronizer({
|
|
|
587
593
|
`sync-continuity:${continuityKey}:${userKey}:perspective:${perspective.resourceAtoms.key}`,
|
|
588
594
|
store
|
|
589
595
|
);
|
|
590
|
-
|
|
596
|
+
unsubFns.push(unsubscribe);
|
|
591
597
|
}
|
|
592
598
|
return () => {
|
|
593
|
-
for (const unsubscribe of
|
|
599
|
+
for (const unsubscribe of unsubFns)
|
|
594
600
|
unsubscribe();
|
|
595
601
|
};
|
|
596
602
|
};
|
|
@@ -917,7 +923,9 @@ function realtimeStateReceiver({
|
|
|
917
923
|
store = IMPLICIT.STORE
|
|
918
924
|
}) {
|
|
919
925
|
return function stateReceiver(token) {
|
|
920
|
-
const publish = (newValue) =>
|
|
926
|
+
const publish = (newValue) => {
|
|
927
|
+
setIntoStore(token, newValue, store);
|
|
928
|
+
};
|
|
921
929
|
const fillPubUnclaim = () => {
|
|
922
930
|
socket.off(`pub:${token.key}`, publish);
|
|
923
931
|
socket.off(`unclaim:${token.key}`, fillPubUnclaim);
|
|
@@ -953,7 +961,9 @@ function realtimeActionReceiver({
|
|
|
953
961
|
store == null ? void 0 : store.logger.info(`\u{1F680}`, `transaction`, tx.key, update.id, metric.duration);
|
|
954
962
|
};
|
|
955
963
|
socket.on(`tx-run:${tx.key}`, fillTransactionRequest);
|
|
956
|
-
return () =>
|
|
964
|
+
return () => {
|
|
965
|
+
socket.off(`tx-run:${tx.key}`, fillTransactionRequest);
|
|
966
|
+
};
|
|
957
967
|
};
|
|
958
968
|
}
|
|
959
969
|
|