atom.io 0.23.5 → 0.24.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.
- package/data/dist/index.cjs +51 -27
- package/data/dist/index.d.ts +5 -4
- package/data/dist/index.js +625 -9
- package/data/src/join.ts +74 -46
- package/dist/chunk-BF4MVQF6.js +44 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.ts +63 -18
- package/dist/index.js +27 -3
- package/immortal/dist/index.cjs +4 -262
- package/immortal/dist/index.d.ts +4 -94
- package/immortal/dist/index.js +3 -215
- package/immortal/src/index.ts +0 -2
- package/immortal/src/seek-state.ts +10 -11
- package/internal/dist/index.cjs +279 -111
- package/internal/dist/index.d.ts +63 -93
- package/internal/dist/index.js +273 -88
- package/internal/src/families/dispose-from-store.ts +11 -7
- package/internal/src/families/find-in-store.ts +2 -2
- package/internal/src/families/init-family-member.ts +37 -25
- package/internal/src/families/seek-in-store.ts +11 -15
- package/internal/src/get-environment-data.ts +0 -4
- package/internal/src/index.ts +1 -0
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +8 -8
- package/internal/src/molecule/create-molecule-family.ts +30 -0
- package/internal/src/molecule/dispose-molecule.ts +76 -0
- package/internal/src/molecule/grow-molecule-in-store.ts +89 -0
- package/internal/src/molecule/index.ts +5 -0
- package/internal/src/molecule/make-molecule-in-store.ts +122 -0
- package/internal/src/molecule/molecule-internal.ts +48 -0
- package/internal/src/not-found-error.ts +4 -3
- package/internal/src/set-state/emit-update.ts +1 -2
- package/internal/src/store/deposit.ts +16 -30
- package/internal/src/store/store.ts +7 -12
- package/internal/src/store/withdraw.ts +30 -19
- package/internal/src/timeline/create-timeline.ts +7 -6
- package/internal/src/transaction/build-transaction.ts +2 -1
- package/introspection/dist/index.cjs +29 -33
- package/introspection/dist/index.js +1 -1
- package/introspection/src/auditor.ts +6 -6
- package/json/dist/index.cjs +4 -4
- package/json/dist/index.js +7 -8
- package/json/src/select-json-family.ts +6 -5
- package/package.json +6 -6
- package/react-devtools/dist/index.js +2 -3
- package/realtime-client/dist/index.js +362 -15
- package/realtime-react/dist/index.cjs +1 -326
- package/realtime-react/dist/index.d.ts +1 -14
- package/realtime-react/dist/index.js +1 -1
- package/realtime-react/src/use-sync-continuity.ts +2 -2
- package/realtime-server/dist/index.cjs +3 -151
- package/realtime-server/dist/index.d.ts +1 -3
- package/realtime-server/dist/index.js +2 -18
- package/realtime-server/src/index.ts +0 -2
- package/realtime-server/src/realtime-continuity-synchronizer.ts +1 -1
- package/realtime-testing/dist/index.cjs +4 -82
- package/realtime-testing/dist/index.js +2 -4
- package/realtime-testing/src/setup-realtime-test.tsx +2 -3
- package/src/dispose-state.ts +2 -2
- package/src/index.ts +1 -0
- package/src/logger.ts +2 -0
- package/src/molecule.ts +133 -0
- package/src/timeline.ts +3 -3
- package/src/transaction.ts +15 -13
- package/dist/chunk-6MLFYN32.js +0 -18
- package/dist/chunk-7DT3PVS3.js +0 -598
- package/dist/chunk-GVHKIJ3G.js +0 -329
- package/dist/chunk-O47EQUM6.js +0 -29
- package/dist/chunk-OAYGID5B.js +0 -27
- package/dist/chunk-PNIHPILQ.js +0 -8
- package/immortal/src/make-molecule.ts +0 -234
- package/immortal/src/molecule.ts +0 -167
- package/realtime-server/src/realtime-state-synchronizer.ts +0 -23
|
@@ -169,335 +169,10 @@ function useServerAction(token) {
|
|
|
169
169
|
);
|
|
170
170
|
return internal.actUponStore(token, internal.arbitrary(), store);
|
|
171
171
|
}
|
|
172
|
-
function syncContinuity(continuity, socket, store) {
|
|
173
|
-
const continuityKey = continuity.key;
|
|
174
|
-
const optimisticUpdates = internal.getFromStore(RTC.optimisticUpdateQueue, store);
|
|
175
|
-
const confirmedUpdates = internal.getFromStore(RTC.confirmedUpdateQueue, store);
|
|
176
|
-
const initializeContinuity = (epoch, payload) => {
|
|
177
|
-
socket.off(`continuity-init:${continuityKey}`, initializeContinuity);
|
|
178
|
-
let i = 0;
|
|
179
|
-
let k = ``;
|
|
180
|
-
let v = null;
|
|
181
|
-
for (const x of payload) {
|
|
182
|
-
if (i % 2 === 0) {
|
|
183
|
-
k = x;
|
|
184
|
-
} else {
|
|
185
|
-
v = x;
|
|
186
|
-
if (`type` in k && k.type === `mutable_atom`) {
|
|
187
|
-
k = internal.getJsonToken(k, store);
|
|
188
|
-
}
|
|
189
|
-
internal.setIntoStore(k, v, store);
|
|
190
|
-
}
|
|
191
|
-
i++;
|
|
192
|
-
}
|
|
193
|
-
internal.setEpochNumberOfContinuity(continuityKey, epoch, store);
|
|
194
|
-
};
|
|
195
|
-
socket.off(`continuity-init:${continuityKey}`);
|
|
196
|
-
socket.on(`continuity-init:${continuityKey}`, initializeContinuity);
|
|
197
|
-
const registerAndAttemptConfirmedUpdate = (confirmed) => {
|
|
198
|
-
function reconcileEpoch(optimisticUpdate, confirmedUpdate) {
|
|
199
|
-
store.logger.info(
|
|
200
|
-
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
201
|
-
`continuity`,
|
|
202
|
-
continuityKey,
|
|
203
|
-
`reconciling updates`
|
|
204
|
-
);
|
|
205
|
-
internal.setIntoStore(
|
|
206
|
-
RTC.optimisticUpdateQueue,
|
|
207
|
-
(queue) => {
|
|
208
|
-
queue.shift();
|
|
209
|
-
return queue;
|
|
210
|
-
},
|
|
211
|
-
store
|
|
212
|
-
);
|
|
213
|
-
if (optimisticUpdate.id === confirmedUpdate.id) {
|
|
214
|
-
const clientResult = JSON.stringify(optimisticUpdate.updates);
|
|
215
|
-
const serverResult = JSON.stringify(confirmedUpdate.updates);
|
|
216
|
-
if (clientResult === serverResult) {
|
|
217
|
-
store.logger.info(
|
|
218
|
-
`\u2705`,
|
|
219
|
-
`continuity`,
|
|
220
|
-
continuityKey,
|
|
221
|
-
`results for ${optimisticUpdate.id} match between client and server`
|
|
222
|
-
);
|
|
223
|
-
socket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch);
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
} else {
|
|
227
|
-
store.logger.info(
|
|
228
|
-
`\u274C`,
|
|
229
|
-
`continuity`,
|
|
230
|
-
continuityKey,
|
|
231
|
-
`thought update #${confirmedUpdate.epoch} was ${optimisticUpdate.key}:${optimisticUpdate.id}, but it was actually ${confirmedUpdate.key}:${confirmedUpdate.id}`
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
store.logger.info(
|
|
235
|
-
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
236
|
-
`continuity`,
|
|
237
|
-
continuityKey,
|
|
238
|
-
`updates do not match`,
|
|
239
|
-
optimisticUpdate,
|
|
240
|
-
confirmedUpdate
|
|
241
|
-
);
|
|
242
|
-
const reversedOptimisticUpdates = optimisticUpdates.toReversed();
|
|
243
|
-
for (const subsequentOptimistic of reversedOptimisticUpdates) {
|
|
244
|
-
internal.ingestTransactionUpdate(`oldValue`, subsequentOptimistic, store);
|
|
245
|
-
}
|
|
246
|
-
store.logger.info(
|
|
247
|
-
`\u23EA`,
|
|
248
|
-
`continuity`,
|
|
249
|
-
continuityKey,
|
|
250
|
-
`undid optimistic updates:`,
|
|
251
|
-
reversedOptimisticUpdates
|
|
252
|
-
);
|
|
253
|
-
internal.ingestTransactionUpdate(`oldValue`, optimisticUpdate, store);
|
|
254
|
-
store.logger.info(
|
|
255
|
-
`\u23EA`,
|
|
256
|
-
`continuity`,
|
|
257
|
-
continuityKey,
|
|
258
|
-
`undid zeroth optimistic update`,
|
|
259
|
-
optimisticUpdate
|
|
260
|
-
);
|
|
261
|
-
internal.ingestTransactionUpdate(`newValue`, confirmedUpdate, store);
|
|
262
|
-
store.logger.info(
|
|
263
|
-
`\u23E9`,
|
|
264
|
-
`continuity`,
|
|
265
|
-
continuityKey,
|
|
266
|
-
`applied confirmed update`,
|
|
267
|
-
confirmedUpdate
|
|
268
|
-
);
|
|
269
|
-
socket.emit(`ack:${continuityKey}`, confirmedUpdate.epoch);
|
|
270
|
-
for (const subsequentOptimistic of optimisticUpdates) {
|
|
271
|
-
const token = {
|
|
272
|
-
type: `transaction`,
|
|
273
|
-
key: subsequentOptimistic.key
|
|
274
|
-
};
|
|
275
|
-
const { id, params } = subsequentOptimistic;
|
|
276
|
-
internal.actUponStore(token, id, store)(...params);
|
|
277
|
-
}
|
|
278
|
-
store.logger.info(
|
|
279
|
-
`\u23E9`,
|
|
280
|
-
`continuity`,
|
|
281
|
-
continuityKey,
|
|
282
|
-
`reapplied subsequent optimistic updates:`,
|
|
283
|
-
optimisticUpdates
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
store.logger.info(
|
|
287
|
-
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
288
|
-
`continuity`,
|
|
289
|
-
continuityKey,
|
|
290
|
-
`integrating confirmed update`,
|
|
291
|
-
{ confirmedUpdate: confirmed, confirmedUpdates, optimisticUpdates }
|
|
292
|
-
);
|
|
293
|
-
const zerothOptimisticUpdate = optimisticUpdates[0];
|
|
294
|
-
if (zerothOptimisticUpdate) {
|
|
295
|
-
store.logger.info(
|
|
296
|
-
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
297
|
-
`continuity`,
|
|
298
|
-
continuityKey,
|
|
299
|
-
`has optimistic updates to reconcile`
|
|
300
|
-
);
|
|
301
|
-
if (confirmed.epoch === zerothOptimisticUpdate.epoch) {
|
|
302
|
-
store.logger.info(
|
|
303
|
-
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
304
|
-
`continuity`,
|
|
305
|
-
continuityKey,
|
|
306
|
-
`epoch of confirmed update #${confirmed.epoch} matches zeroth optimistic update`
|
|
307
|
-
);
|
|
308
|
-
reconcileEpoch(zerothOptimisticUpdate, confirmed);
|
|
309
|
-
for (const nextConfirmed of confirmedUpdates) {
|
|
310
|
-
const nextOptimistic = optimisticUpdates[0];
|
|
311
|
-
if (nextConfirmed.epoch === (nextOptimistic == null ? void 0 : nextOptimistic.epoch)) {
|
|
312
|
-
reconcileEpoch(nextOptimistic, nextConfirmed);
|
|
313
|
-
} else {
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
store.logger.info(
|
|
319
|
-
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
320
|
-
`continuity`,
|
|
321
|
-
continuityKey,
|
|
322
|
-
`epoch of confirmed update #${confirmed.epoch} does not match zeroth optimistic update #${zerothOptimisticUpdate.epoch}`
|
|
323
|
-
);
|
|
324
|
-
const confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(
|
|
325
|
-
(update) => update.epoch === confirmed.epoch
|
|
326
|
-
);
|
|
327
|
-
if (!confirmedUpdateIsAlreadyEnqueued) {
|
|
328
|
-
store.logger.info(
|
|
329
|
-
`\u{1F448}`,
|
|
330
|
-
`continuity`,
|
|
331
|
-
continuityKey,
|
|
332
|
-
`pushing confirmed update to queue`,
|
|
333
|
-
confirmed
|
|
334
|
-
);
|
|
335
|
-
internal.setIntoStore(
|
|
336
|
-
RTC.confirmedUpdateQueue,
|
|
337
|
-
(queue) => {
|
|
338
|
-
queue.push(confirmed);
|
|
339
|
-
queue.sort((a, b) => a.epoch - b.epoch);
|
|
340
|
-
return queue;
|
|
341
|
-
},
|
|
342
|
-
store
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
} else {
|
|
347
|
-
store.logger.info(
|
|
348
|
-
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
349
|
-
`continuity`,
|
|
350
|
-
continuityKey,
|
|
351
|
-
`has no optimistic updates to deal with`
|
|
352
|
-
);
|
|
353
|
-
const continuityEpoch = internal.getEpochNumberOfContinuity(continuityKey, store);
|
|
354
|
-
const isRoot = internal.isRootStore(store);
|
|
355
|
-
if (isRoot && continuityEpoch === confirmed.epoch - 1) {
|
|
356
|
-
store.logger.info(
|
|
357
|
-
`\u2705`,
|
|
358
|
-
`continuity`,
|
|
359
|
-
continuityKey,
|
|
360
|
-
`integrating update #${confirmed.epoch} (${confirmed.key} ${confirmed.id})`
|
|
361
|
-
);
|
|
362
|
-
internal.ingestTransactionUpdate(`newValue`, confirmed, store);
|
|
363
|
-
socket.emit(`ack:${continuityKey}`, confirmed.epoch);
|
|
364
|
-
internal.setEpochNumberOfContinuity(continuityKey, confirmed.epoch, store);
|
|
365
|
-
} else if (isRoot && continuityEpoch !== void 0) {
|
|
366
|
-
store.logger.info(
|
|
367
|
-
`\u{1F9D1}\u200D\u2696\uFE0F`,
|
|
368
|
-
`continuity`,
|
|
369
|
-
continuityKey,
|
|
370
|
-
`received update #${confirmed.epoch} but still waiting for update #${continuityEpoch + 1}`,
|
|
371
|
-
{
|
|
372
|
-
clientEpoch: continuityEpoch,
|
|
373
|
-
serverEpoch: confirmed.epoch
|
|
374
|
-
}
|
|
375
|
-
);
|
|
376
|
-
const confirmedUpdateIsAlreadyEnqueued = confirmedUpdates.some(
|
|
377
|
-
(update) => update.epoch === confirmed.epoch
|
|
378
|
-
);
|
|
379
|
-
if (confirmedUpdateIsAlreadyEnqueued) {
|
|
380
|
-
store.logger.info(
|
|
381
|
-
`\u{1F44D}`,
|
|
382
|
-
`continuity`,
|
|
383
|
-
continuityKey,
|
|
384
|
-
`confirmed update #${confirmed.epoch} is already enqueued`
|
|
385
|
-
);
|
|
386
|
-
} else {
|
|
387
|
-
store.logger.info(
|
|
388
|
-
`\u{1F448}`,
|
|
389
|
-
`continuity`,
|
|
390
|
-
continuityKey,
|
|
391
|
-
`pushing confirmed update #${confirmed.epoch} to queue`
|
|
392
|
-
);
|
|
393
|
-
internal.setIntoStore(
|
|
394
|
-
RTC.confirmedUpdateQueue,
|
|
395
|
-
(queue) => {
|
|
396
|
-
queue.push(confirmed);
|
|
397
|
-
queue.sort((a, b) => a.epoch - b.epoch);
|
|
398
|
-
return queue;
|
|
399
|
-
},
|
|
400
|
-
store
|
|
401
|
-
);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
socket.off(`tx-new:${continuityKey}`);
|
|
407
|
-
socket.on(`tx-new:${continuityKey}`, registerAndAttemptConfirmedUpdate);
|
|
408
|
-
const unsubscribeFunctions = continuity.actions.map((transaction) => {
|
|
409
|
-
internal.assignTransactionToContinuity(continuityKey, transaction.key, store);
|
|
410
|
-
const unsubscribeFromTransactionUpdates = internal.subscribeToTransaction(
|
|
411
|
-
transaction,
|
|
412
|
-
(clientUpdate) => {
|
|
413
|
-
store.logger.info(
|
|
414
|
-
`\u{1F91E}`,
|
|
415
|
-
`continuity`,
|
|
416
|
-
continuityKey,
|
|
417
|
-
`enqueuing optimistic update`
|
|
418
|
-
);
|
|
419
|
-
const optimisticUpdateIndex = optimisticUpdates.findIndex(
|
|
420
|
-
(update) => update.id === clientUpdate.id
|
|
421
|
-
);
|
|
422
|
-
if (optimisticUpdateIndex === -1) {
|
|
423
|
-
store.logger.info(
|
|
424
|
-
`\u{1F91E}`,
|
|
425
|
-
`continuity`,
|
|
426
|
-
continuityKey,
|
|
427
|
-
`enqueuing new optimistic update`
|
|
428
|
-
);
|
|
429
|
-
internal.setIntoStore(
|
|
430
|
-
RTC.optimisticUpdateQueue,
|
|
431
|
-
(queue) => {
|
|
432
|
-
queue.push(clientUpdate);
|
|
433
|
-
queue.sort((a, b) => a.epoch - b.epoch);
|
|
434
|
-
return queue;
|
|
435
|
-
},
|
|
436
|
-
store
|
|
437
|
-
);
|
|
438
|
-
} else {
|
|
439
|
-
store.logger.info(
|
|
440
|
-
`\u{1F91E}`,
|
|
441
|
-
`continuity`,
|
|
442
|
-
continuityKey,
|
|
443
|
-
`replacing existing optimistic update at index ${optimisticUpdateIndex}`
|
|
444
|
-
);
|
|
445
|
-
internal.setIntoStore(
|
|
446
|
-
RTC.optimisticUpdateQueue,
|
|
447
|
-
(queue) => {
|
|
448
|
-
queue[optimisticUpdateIndex] = clientUpdate;
|
|
449
|
-
return queue;
|
|
450
|
-
},
|
|
451
|
-
store
|
|
452
|
-
);
|
|
453
|
-
}
|
|
454
|
-
socket.emit(`tx-run:${continuityKey}`, {
|
|
455
|
-
id: clientUpdate.id,
|
|
456
|
-
key: transaction.key,
|
|
457
|
-
params: clientUpdate.params
|
|
458
|
-
});
|
|
459
|
-
},
|
|
460
|
-
`tx-run:${continuityKey}`,
|
|
461
|
-
store
|
|
462
|
-
);
|
|
463
|
-
return unsubscribeFromTransactionUpdates;
|
|
464
|
-
});
|
|
465
|
-
socket.on(`reveal:${continuityKey}`, (revealed) => {
|
|
466
|
-
let i = 0;
|
|
467
|
-
let k = ``;
|
|
468
|
-
let v = null;
|
|
469
|
-
for (const x of revealed) {
|
|
470
|
-
if (i % 2 === 0) {
|
|
471
|
-
k = x;
|
|
472
|
-
} else {
|
|
473
|
-
v = x;
|
|
474
|
-
internal.setIntoStore(k, v, store);
|
|
475
|
-
}
|
|
476
|
-
i++;
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
socket.on(
|
|
480
|
-
`conceal:${continuityKey}`,
|
|
481
|
-
(concealed) => {
|
|
482
|
-
for (const token of concealed) {
|
|
483
|
-
internal.disposeAtom(token, store);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
);
|
|
487
|
-
socket.emit(`get:${continuityKey}`);
|
|
488
|
-
return () => {
|
|
489
|
-
socket.off(`continuity-init:${continuityKey}`);
|
|
490
|
-
socket.off(`tx-new:${continuityKey}`);
|
|
491
|
-
for (const unsubscribe of unsubscribeFunctions)
|
|
492
|
-
unsubscribe();
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// realtime-react/src/use-sync-continuity.ts
|
|
497
172
|
function useSyncContinuity(token) {
|
|
498
173
|
const store = React__namespace.useContext(react.StoreContext);
|
|
499
174
|
useRealtimeService(`tx-sync:${token.key}`, (socket) => {
|
|
500
|
-
return syncContinuity(token, socket, store);
|
|
175
|
+
return RTC.syncContinuity(token, socket, store);
|
|
501
176
|
});
|
|
502
177
|
}
|
|
503
178
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Socket } from 'socket.io-client';
|
|
3
3
|
import * as AtomIO from 'atom.io';
|
|
4
|
-
import { AtomToken, TransactionToken, AtomFamilyToken, ReadableFamilyToken, ReadableToken } from 'atom.io';
|
|
5
4
|
import { Json } from 'atom.io/json';
|
|
6
5
|
import { Transceiver } from 'atom.io/internal';
|
|
6
|
+
import { ContinuityToken } from 'atom.io/realtime';
|
|
7
7
|
|
|
8
8
|
type RealtimeReactStore = {
|
|
9
9
|
socket: Socket | null;
|
|
@@ -34,19 +34,6 @@ declare function usePush<J extends Json.Serializable>(token: AtomIO.WritableToke
|
|
|
34
34
|
|
|
35
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 U, any> ? U : never> = {
|
|
38
|
-
type: `realtime_perspective`;
|
|
39
|
-
resourceAtoms: F;
|
|
40
|
-
viewAtoms: ReadableFamilyToken<ReadableToken<T>[], string>;
|
|
41
|
-
};
|
|
42
|
-
type ContinuityToken = {
|
|
43
|
-
readonly type: `continuity`;
|
|
44
|
-
readonly key: string;
|
|
45
|
-
readonly globals: AtomToken<any>[];
|
|
46
|
-
readonly actions: TransactionToken<any>[];
|
|
47
|
-
readonly perspectives: PerspectiveToken<AtomFamilyToken<any, Json.Serializable>, Json.Serializable>[];
|
|
48
|
-
};
|
|
49
|
-
|
|
50
37
|
declare function useSyncContinuity(token: ContinuityToken): void;
|
|
51
38
|
|
|
52
39
|
export { RealtimeContext, RealtimeProvider, type RealtimeReactStore, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useServerAction, useSyncContinuity };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { syncContinuity } from '../../dist/chunk-GVHKIJ3G.js';
|
|
2
1
|
import '../../dist/chunk-F2X4B4VY.js';
|
|
3
2
|
import { useI, StoreContext, useO } from 'atom.io/react';
|
|
4
3
|
import * as RTC from 'atom.io/realtime-client';
|
|
4
|
+
import { syncContinuity } from 'atom.io/realtime-client';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
import { findInStore, actUponStore, arbitrary } from 'atom.io/internal';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StoreContext } from "atom.io/react"
|
|
2
|
+
import type { ContinuityToken } from "atom.io/realtime"
|
|
3
|
+
import { syncContinuity } from "atom.io/realtime-client"
|
|
2
4
|
import * as React from "react"
|
|
3
5
|
|
|
4
|
-
import type { ContinuityToken } from "../../realtime/src/realtime-continuity"
|
|
5
|
-
import { syncContinuity } from "../../realtime-client/src/sync-continuity"
|
|
6
6
|
import { useRealtimeService } from "./use-realtime-service"
|
|
7
7
|
|
|
8
8
|
export function useSyncContinuity(token: ContinuityToken): void {
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
var json = require('atom.io/json');
|
|
4
4
|
var internal = require('atom.io/internal');
|
|
5
5
|
var setRtx = require('atom.io/transceivers/set-rtx');
|
|
6
|
+
var data = require('atom.io/data');
|
|
6
7
|
var AtomIO = require('atom.io');
|
|
7
|
-
require('atom.io/immortal');
|
|
8
8
|
var realtime = require('atom.io/realtime');
|
|
9
|
-
var data = require('atom.io/data');
|
|
10
9
|
var child_process = require('child_process');
|
|
11
10
|
|
|
12
11
|
function _interopNamespace(e) {
|
|
@@ -370,138 +369,6 @@ function realtimeActionReceiver({
|
|
|
370
369
|
};
|
|
371
370
|
};
|
|
372
371
|
}
|
|
373
|
-
function capitalize(string) {
|
|
374
|
-
return string[0].toUpperCase() + string.slice(1);
|
|
375
|
-
}
|
|
376
|
-
function getJoinMap(store) {
|
|
377
|
-
if (`joins` in store && store.joins instanceof Map) {
|
|
378
|
-
return store.joins;
|
|
379
|
-
}
|
|
380
|
-
const joins = /* @__PURE__ */ new Map();
|
|
381
|
-
store.joins = joins;
|
|
382
|
-
return joins;
|
|
383
|
-
}
|
|
384
|
-
function getJoin(token, store) {
|
|
385
|
-
var _a;
|
|
386
|
-
const joinMap = getJoinMap(store);
|
|
387
|
-
let myJoin = joinMap.get(token.key);
|
|
388
|
-
if (myJoin === void 0) {
|
|
389
|
-
const rootJoinMap = getJoinMap(internal.IMPLICIT.STORE);
|
|
390
|
-
myJoin = (_a = rootJoinMap.get(token.key)) == null ? void 0 : _a.in(store);
|
|
391
|
-
if (myJoin === void 0) {
|
|
392
|
-
throw new Error(
|
|
393
|
-
`Join "${token.key}" not found in store "${store.config.name}"`
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
joinMap.set(token.key, myJoin);
|
|
397
|
-
}
|
|
398
|
-
return myJoin;
|
|
399
|
-
}
|
|
400
|
-
function findRelationsInStore(token, key, store) {
|
|
401
|
-
const myJoin = getJoin(token, store);
|
|
402
|
-
let relations;
|
|
403
|
-
switch (token.cardinality) {
|
|
404
|
-
case `1:1`: {
|
|
405
|
-
const keyAB = `${token.a}KeyOf${capitalize(token.b)}`;
|
|
406
|
-
const keyBA = `${token.b}KeyOf${capitalize(token.a)}`;
|
|
407
|
-
relations = {
|
|
408
|
-
get [keyAB]() {
|
|
409
|
-
const familyAB = myJoin.states[keyAB];
|
|
410
|
-
const state = myJoin.retrieve(familyAB, key);
|
|
411
|
-
return state;
|
|
412
|
-
},
|
|
413
|
-
get [keyBA]() {
|
|
414
|
-
const familyBA = myJoin.states[keyBA];
|
|
415
|
-
const state = myJoin.retrieve(familyBA, key);
|
|
416
|
-
return state;
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
420
|
-
if (entryAB in myJoin.states) {
|
|
421
|
-
const entryBA = `${token.b}EntryOf${capitalize(token.a)}`;
|
|
422
|
-
Object.assign(relations, {
|
|
423
|
-
get [entryAB]() {
|
|
424
|
-
const familyAB = myJoin.states[entryAB];
|
|
425
|
-
const state = myJoin.retrieve(familyAB, key);
|
|
426
|
-
return state;
|
|
427
|
-
},
|
|
428
|
-
get [entryBA]() {
|
|
429
|
-
const familyBA = myJoin.states[entryBA];
|
|
430
|
-
const state = myJoin.retrieve(familyBA, key);
|
|
431
|
-
return state;
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
break;
|
|
436
|
-
}
|
|
437
|
-
case `1:n`: {
|
|
438
|
-
const keyAB = `${token.a}KeyOf${capitalize(token.b)}`;
|
|
439
|
-
const keysBA = `${token.b}KeysOf${capitalize(token.a)}`;
|
|
440
|
-
relations = {
|
|
441
|
-
get [keyAB]() {
|
|
442
|
-
const familyAB = myJoin.states[keyAB];
|
|
443
|
-
const state = myJoin.retrieve(familyAB, key);
|
|
444
|
-
return state;
|
|
445
|
-
},
|
|
446
|
-
get [keysBA]() {
|
|
447
|
-
const familyBA = myJoin.states[keysBA];
|
|
448
|
-
const state = myJoin.retrieve(familyBA, key);
|
|
449
|
-
return state;
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
453
|
-
if (entryAB in myJoin.states) {
|
|
454
|
-
const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
|
|
455
|
-
Object.assign(relations, {
|
|
456
|
-
get [entryAB]() {
|
|
457
|
-
const familyAB = myJoin.states[entryAB];
|
|
458
|
-
const state = myJoin.retrieve(familyAB, key);
|
|
459
|
-
return state;
|
|
460
|
-
},
|
|
461
|
-
get [entriesBA]() {
|
|
462
|
-
const familyBA = myJoin.states[entriesBA];
|
|
463
|
-
const state = myJoin.retrieve(familyBA, key);
|
|
464
|
-
return state;
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
break;
|
|
469
|
-
}
|
|
470
|
-
case `n:n`: {
|
|
471
|
-
const keysAB = `${token.a}KeysOf${capitalize(token.b)}`;
|
|
472
|
-
const keysBA = `${token.b}KeysOf${capitalize(token.a)}`;
|
|
473
|
-
relations = {
|
|
474
|
-
get [keysAB]() {
|
|
475
|
-
const familyAB = myJoin.states[keysAB];
|
|
476
|
-
const state = myJoin.retrieve(familyAB, key);
|
|
477
|
-
return state;
|
|
478
|
-
},
|
|
479
|
-
get [keysBA]() {
|
|
480
|
-
const familyBA = myJoin.states[keysBA];
|
|
481
|
-
const state = myJoin.retrieve(familyBA, key);
|
|
482
|
-
return state;
|
|
483
|
-
}
|
|
484
|
-
};
|
|
485
|
-
const entriesAB = `${token.a}EntriesOf${capitalize(token.b)}`;
|
|
486
|
-
if (entriesAB in myJoin.states) {
|
|
487
|
-
const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
|
|
488
|
-
Object.assign(relations, {
|
|
489
|
-
get [entriesAB]() {
|
|
490
|
-
const familyAB = myJoin.states[entriesAB];
|
|
491
|
-
const state = myJoin.retrieve(familyAB, key);
|
|
492
|
-
return state;
|
|
493
|
-
},
|
|
494
|
-
get [entriesBA]() {
|
|
495
|
-
const familyBA = myJoin.states[entriesBA];
|
|
496
|
-
const state = myJoin.retrieve(familyBA, key);
|
|
497
|
-
return state;
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
return relations;
|
|
504
|
-
}
|
|
505
372
|
AtomIO.selectorFamily({
|
|
506
373
|
key: `perspectiveRedactor`,
|
|
507
374
|
get: ({ userId, syncGroupKey }) => ({ get, find }) => {
|
|
@@ -708,7 +575,7 @@ function realtimeContinuitySynchronizer({
|
|
|
708
575
|
return function synchronizer(continuity) {
|
|
709
576
|
let socket = initialSocket;
|
|
710
577
|
const continuityKey = continuity.key;
|
|
711
|
-
const userKeyState = findRelationsInStore(
|
|
578
|
+
const userKeyState = data.findRelationsInStore(
|
|
712
579
|
usersOfSockets,
|
|
713
580
|
socket.id,
|
|
714
581
|
store
|
|
@@ -724,7 +591,7 @@ function realtimeContinuitySynchronizer({
|
|
|
724
591
|
return () => {
|
|
725
592
|
};
|
|
726
593
|
}
|
|
727
|
-
const socketKeyState = findRelationsInStore(
|
|
594
|
+
const socketKeyState = data.findRelationsInStore(
|
|
728
595
|
usersOfSockets,
|
|
729
596
|
userKey,
|
|
730
597
|
store
|
|
@@ -1134,20 +1001,6 @@ function realtimeStateReceiver({
|
|
|
1134
1001
|
};
|
|
1135
1002
|
};
|
|
1136
1003
|
}
|
|
1137
|
-
function realtimeStateSynchronizer({
|
|
1138
|
-
socket,
|
|
1139
|
-
store = internal.IMPLICIT.STORE
|
|
1140
|
-
}) {
|
|
1141
|
-
return function stateSynchronizer(token) {
|
|
1142
|
-
const fillGetRequest = () => {
|
|
1143
|
-
socket.emit(`value:${token.key}`, internal.getFromStore(token, store));
|
|
1144
|
-
};
|
|
1145
|
-
socket.on(`get:${token.key}`, fillGetRequest);
|
|
1146
|
-
return () => {
|
|
1147
|
-
socket.off(`get:${token.key}`, fillGetRequest);
|
|
1148
|
-
};
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
1004
|
|
|
1152
1005
|
exports.ChildSocket = ChildSocket;
|
|
1153
1006
|
exports.CustomSocket = CustomSocket;
|
|
@@ -1165,7 +1018,6 @@ exports.realtimeMutableFamilyProvider = realtimeMutableFamilyProvider;
|
|
|
1165
1018
|
exports.realtimeMutableProvider = realtimeMutableProvider;
|
|
1166
1019
|
exports.realtimeStateProvider = realtimeStateProvider;
|
|
1167
1020
|
exports.realtimeStateReceiver = realtimeStateReceiver;
|
|
1168
|
-
exports.realtimeStateSynchronizer = realtimeStateSynchronizer;
|
|
1169
1021
|
exports.redactTransactionUpdateContent = redactTransactionUpdateContent;
|
|
1170
1022
|
exports.roomArgumentsAtoms = roomArgumentsAtoms;
|
|
1171
1023
|
exports.roomSelectors = roomSelectors;
|
|
@@ -125,8 +125,6 @@ declare function realtimeStateProvider({ socket, store, }: ServerConfig): <J ext
|
|
|
125
125
|
type StateReceiver = ReturnType<typeof realtimeStateReceiver>;
|
|
126
126
|
declare function realtimeStateReceiver({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: WritableToken<J>) => () => void;
|
|
127
127
|
|
|
128
|
-
declare function realtimeStateSynchronizer({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: AtomIO.WritableToken<J>) => () => void;
|
|
129
|
-
|
|
130
128
|
type Socket = {
|
|
131
129
|
id: string;
|
|
132
130
|
on: (event: string, listener: (...args: Json.Serializable[]) => void) => void;
|
|
@@ -140,4 +138,4 @@ type ServerConfig = {
|
|
|
140
138
|
store?: Store;
|
|
141
139
|
};
|
|
142
140
|
|
|
143
|
-
export { type ActionReceiver, ChildSocket, type CreateRoomIO, CustomSocket, type EventBuffer, type Events, type FamilyProvider, type JoinRoomIO, type LeaveRoomIO, type MutableFamilyProvider, type MutableProvider, ParentSocket, type RealtimeContinuitySynchronizer, type RoomArguments, type ServerConfig, type Socket, type StateProvider, type StateReceiver, type StringifiedEvent, SubjectSocket, actionOcclusionAtoms, createRoomTX, destroyRoomTX, joinRoomTX, leaveRoomTX, realtimeActionReceiver, realtimeAtomFamilyProvider, realtimeContinuitySynchronizer, realtimeMutableFamilyProvider, realtimeMutableProvider, realtimeStateProvider, realtimeStateReceiver,
|
|
141
|
+
export { type ActionReceiver, ChildSocket, type CreateRoomIO, CustomSocket, type EventBuffer, type Events, type FamilyProvider, type JoinRoomIO, type LeaveRoomIO, type MutableFamilyProvider, type MutableProvider, ParentSocket, type RealtimeContinuitySynchronizer, type RoomArguments, type ServerConfig, type Socket, type StateProvider, type StateReceiver, type StringifiedEvent, SubjectSocket, actionOcclusionAtoms, createRoomTX, destroyRoomTX, joinRoomTX, leaveRoomTX, realtimeActionReceiver, realtimeAtomFamilyProvider, realtimeContinuitySynchronizer, realtimeMutableFamilyProvider, realtimeMutableProvider, realtimeStateProvider, realtimeStateReceiver, redactTransactionUpdateContent, roomArgumentsAtoms, roomSelectors, socketAtoms, socketIndex, userIndex, userUnacknowledgedQueues, usersOfSockets };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { findRelationsInStore } from '../../dist/chunk-7DT3PVS3.js';
|
|
2
|
-
import '../../dist/chunk-FTONNX2R.js';
|
|
3
1
|
import { __spreadProps, __spreadValues } from '../../dist/chunk-F2X4B4VY.js';
|
|
4
2
|
import { parseJson, stringifyJson } from 'atom.io/json';
|
|
5
3
|
import { getUpdateToken, IMPLICIT, Subject, getFromStore, subscribeToState, findInStore, getJsonToken, actUponStore, isRootStore, subscribeToTransaction, setIntoStore } from 'atom.io/internal';
|
|
6
4
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
5
|
+
import { editRelationsInStore, join, findRelationsInStore } from 'atom.io/data';
|
|
7
6
|
import * as AtomIO from 'atom.io';
|
|
8
7
|
import { selectorFamily, atomFamily, atom } from 'atom.io';
|
|
9
8
|
import { SyncGroup, roomIndex, usersInRooms } from 'atom.io/realtime';
|
|
10
|
-
import { editRelationsInStore, join } from 'atom.io/data';
|
|
11
9
|
import { spawn } from 'child_process';
|
|
12
10
|
|
|
13
11
|
// realtime-server/src/ipc-sockets/custom-socket.ts
|
|
@@ -963,19 +961,5 @@ function realtimeStateReceiver({
|
|
|
963
961
|
};
|
|
964
962
|
};
|
|
965
963
|
}
|
|
966
|
-
function realtimeStateSynchronizer({
|
|
967
|
-
socket,
|
|
968
|
-
store = IMPLICIT.STORE
|
|
969
|
-
}) {
|
|
970
|
-
return function stateSynchronizer(token) {
|
|
971
|
-
const fillGetRequest = () => {
|
|
972
|
-
socket.emit(`value:${token.key}`, getFromStore(token, store));
|
|
973
|
-
};
|
|
974
|
-
socket.on(`get:${token.key}`, fillGetRequest);
|
|
975
|
-
return () => {
|
|
976
|
-
socket.off(`get:${token.key}`, fillGetRequest);
|
|
977
|
-
};
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
964
|
|
|
981
|
-
export { ChildSocket, CustomSocket, ParentSocket, SubjectSocket, actionOcclusionAtoms, createRoomTX, destroyRoomTX, joinRoomTX, leaveRoomTX, realtimeActionReceiver, realtimeAtomFamilyProvider, realtimeContinuitySynchronizer, realtimeMutableFamilyProvider, realtimeMutableProvider, realtimeStateProvider, realtimeStateReceiver,
|
|
965
|
+
export { ChildSocket, CustomSocket, ParentSocket, SubjectSocket, actionOcclusionAtoms, createRoomTX, destroyRoomTX, joinRoomTX, leaveRoomTX, realtimeActionReceiver, realtimeAtomFamilyProvider, realtimeContinuitySynchronizer, realtimeMutableFamilyProvider, realtimeMutableProvider, realtimeStateProvider, realtimeStateReceiver, redactTransactionUpdateContent, roomArgumentsAtoms, roomSelectors, socketAtoms, socketIndex, userIndex, userUnacknowledgedQueues, usersOfSockets };
|
|
@@ -10,8 +10,6 @@ export * from "./realtime-mutable-provider"
|
|
|
10
10
|
export * from "./realtime-server-stores"
|
|
11
11
|
export * from "./realtime-state-provider"
|
|
12
12
|
export * from "./realtime-state-receiver"
|
|
13
|
-
export * from "./realtime-state-synchronizer"
|
|
14
|
-
// export * from "./realtime-action-synchronizer.txt"
|
|
15
13
|
|
|
16
14
|
export type Socket = {
|
|
17
15
|
id: string
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as AtomIO from "atom.io"
|
|
2
|
+
import { findRelationsInStore } from "atom.io/data"
|
|
2
3
|
import {
|
|
3
4
|
actUponStore,
|
|
4
5
|
findInStore,
|
|
@@ -12,7 +13,6 @@ import {
|
|
|
12
13
|
import type { Json, JsonIO } from "atom.io/json"
|
|
13
14
|
import type { ContinuityToken } from "atom.io/realtime"
|
|
14
15
|
|
|
15
|
-
import { findRelationsInStore } from "../../data/src/join"
|
|
16
16
|
import type { ServerConfig, Socket } from "."
|
|
17
17
|
import { socketAtoms, usersOfSockets } from "."
|
|
18
18
|
import {
|