atom.io 0.19.1 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/data/dist/index.cjs +99 -79
  2. package/data/dist/index.js +2 -2
  3. package/data/src/join.ts +67 -50
  4. package/dist/{chunk-YDOGCZ53.js → chunk-ATKDGVTV.js} +29 -29
  5. package/dist/{chunk-7VCCW45K.js → chunk-CC7IF7QF.js} +4 -3
  6. package/dist/{chunk-WX2NCOZR.js → chunk-FTONNX2R.js} +8 -8
  7. package/dist/{chunk-7ZR244C2.js → chunk-MSCJWACE.js} +92 -72
  8. package/dist/index.cjs +14 -7
  9. package/dist/index.d.ts +23 -35
  10. package/dist/index.js +14 -7
  11. package/internal/dist/index.cjs +55 -43
  12. package/internal/dist/index.d.ts +20 -20
  13. package/internal/dist/index.js +48 -36
  14. package/internal/src/atom/create-regular-atom.ts +7 -5
  15. package/internal/src/atom/delete-atom.ts +2 -2
  16. package/internal/src/families/create-readonly-selector-family.ts +2 -2
  17. package/internal/src/families/create-regular-atom-family.ts +1 -1
  18. package/internal/src/families/create-writable-selector-family.ts +1 -1
  19. package/internal/src/future.ts +4 -2
  20. package/internal/src/lineage.ts +1 -0
  21. package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
  22. package/internal/src/mutable/create-mutable-atom.ts +7 -5
  23. package/internal/src/mutable/tracker.ts +3 -3
  24. package/internal/src/mutable/transceiver.ts +2 -2
  25. package/internal/src/selector/delete-selector.ts +1 -1
  26. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  27. package/internal/src/store/deposit.ts +5 -5
  28. package/internal/src/store/store.ts +5 -5
  29. package/internal/src/store/withdraw.ts +4 -5
  30. package/internal/src/subject.ts +3 -1
  31. package/internal/src/subscribe/subscribe-to-transaction.ts +4 -4
  32. package/internal/src/timeline/add-atom-to-timeline.ts +13 -8
  33. package/internal/src/timeline/create-timeline.ts +3 -4
  34. package/internal/src/transaction/act-upon-store.ts +5 -5
  35. package/internal/src/transaction/apply-transaction.ts +4 -4
  36. package/internal/src/transaction/build-transaction.ts +9 -6
  37. package/internal/src/transaction/create-transaction.ts +10 -10
  38. package/internal/src/transaction/index.ts +3 -3
  39. package/internal/src/transaction/is-root-store.ts +2 -2
  40. package/introspection/dist/index.d.ts +3 -3
  41. package/introspection/src/attach-introspection-states.ts +3 -3
  42. package/introspection/src/attach-transaction-index.ts +4 -4
  43. package/introspection/src/attach-transaction-logs.ts +8 -4
  44. package/json/dist/index.cjs +6 -2
  45. package/json/dist/index.js +6 -2
  46. package/json/src/select-json-family.ts +3 -2
  47. package/json/src/select-json.ts +3 -1
  48. package/package.json +243 -241
  49. package/react/dist/index.cjs +9 -3
  50. package/react/dist/index.js +9 -3
  51. package/react/src/use-i.ts +3 -1
  52. package/react/src/use-tl.ts +6 -2
  53. package/react-devtools/dist/index.cjs +116 -53
  54. package/react-devtools/dist/index.d.ts +3 -5
  55. package/react-devtools/dist/index.js +113 -51
  56. package/react-devtools/src/AtomIODevtools.tsx +3 -1
  57. package/react-devtools/src/Button.tsx +3 -1
  58. package/react-devtools/src/StateIndex.tsx +6 -2
  59. package/react-devtools/src/TimelineIndex.tsx +6 -2
  60. package/react-devtools/src/TransactionIndex.tsx +3 -3
  61. package/react-devtools/src/Updates.tsx +14 -6
  62. package/realtime/dist/index.cjs +1 -0
  63. package/realtime/dist/index.d.ts +2 -2
  64. package/realtime/dist/index.js +1 -0
  65. package/realtime/src/realtime-continuity.ts +4 -3
  66. package/realtime-client/dist/index.cjs +29 -29
  67. package/realtime-client/dist/index.d.ts +2 -2
  68. package/realtime-client/dist/index.js +1 -1
  69. package/realtime-client/src/server-action.ts +2 -2
  70. package/realtime-client/src/sync-continuity.ts +23 -23
  71. package/realtime-react/dist/index.cjs +29 -29
  72. package/realtime-react/dist/index.d.ts +2 -2
  73. package/realtime-react/dist/index.js +1 -1
  74. package/realtime-react/src/use-server-action.ts +3 -3
  75. package/realtime-server/dist/index.cjs +54 -44
  76. package/realtime-server/dist/index.d.ts +5 -5
  77. package/realtime-server/dist/index.js +34 -24
  78. package/realtime-server/src/ipc-sockets/child-socket.ts +6 -6
  79. package/realtime-server/src/ipc-sockets/custom-socket.ts +4 -8
  80. package/realtime-server/src/ipc-sockets/parent-socket.ts +13 -7
  81. package/realtime-server/src/realtime-action-receiver.ts +7 -5
  82. package/realtime-server/src/realtime-continuity-synchronizer.ts +3 -3
  83. package/realtime-server/src/realtime-state-receiver.ts +3 -1
  84. package/realtime-testing/dist/index.cjs +15 -13
  85. package/realtime-testing/dist/index.js +9 -7
  86. package/realtime-testing/src/setup-realtime-test.tsx +6 -4
  87. package/src/atom.ts +4 -8
  88. package/src/dispose.ts +1 -0
  89. package/src/index.ts +2 -9
  90. package/src/selector.ts +4 -8
  91. package/src/silo.ts +9 -3
  92. package/src/subscribe.ts +6 -6
  93. package/src/timeline.ts +4 -4
  94. package/src/transaction.ts +24 -24
  95. package/transceivers/set-rtx/dist/index.cjs +11 -12
  96. package/transceivers/set-rtx/dist/index.js +11 -12
  97. package/transceivers/set-rtx/src/set-rtx.ts +10 -10
@@ -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
- const parsedEvent = json.parseJson(this.incompleteData);
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
- const parsedEvent2 = json.parseJson(event);
147
- this.handleEvent(...parsedEvent2);
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
- const parsedLog = json.parseJson(this.incompleteLog);
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
- const parsedLog2 = json.parseJson(this.incompleteLog);
172
- this.handleLog(parsedLog2);
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) => this.log(`i`, ...args),
237
- warn: (...args) => this.log(`w`, ...args),
238
- error: (...args) => this.log(`e`, ...args)
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 parsedEvent = json.parseJson(this.incompleteData);
253
- this.logger.info(`\u{1F3B0}`, `received`, parsedEvent);
254
- this.handleEvent(...parsedEvent);
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 parsedEvent2 = json.parseJson(event);
262
- this.handleEvent(...parsedEvent2);
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 join2 = joinMap.get(token.key);
356
- if (join2 === void 0) {
361
+ let myJoin = joinMap.get(token.key);
362
+ if (myJoin === void 0) {
357
363
  const rootJoinMap = getJoinMap(internal.IMPLICIT.STORE);
358
- join2 = (_a = rootJoinMap.get(token.key)) == null ? void 0 : _a.in(store);
359
- if (join2 === void 0) {
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, join2);
370
+ joinMap.set(token.key, myJoin);
365
371
  }
366
- return join2;
372
+ return myJoin;
367
373
  }
368
374
  function findRelationsInStore(token, key, store) {
369
- const join2 = getJoin(token, store);
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 = join2.states[keyAB];
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 = join2.states[keyBA];
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 join2.states) {
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 = join2.states[entryAB];
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 = join2.states[entryBA];
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 = join2.states[keyAB];
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 = join2.states[keysBA];
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 join2.states) {
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 = join2.states[entryAB];
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 = join2.states[entriesBA];
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 = join2.states[keysAB];
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 = join2.states[keysBA];
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 join2.states) {
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 = join2.states[entriesAB];
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 = join2.states[entriesBA];
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 unsubscribeFunctions2 = [];
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
- unsubscribeFunctions2.push(unsubscribe);
766
+ unsubFns.push(unsubscribe);
761
767
  }
762
768
  return () => {
763
- for (const unsubscribe of unsubscribeFunctions2)
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) => internal.setIntoStore(token, newValue, store);
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 () => socket.off(`tx-run:${tx.key}`, fillTransactionRequest);
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): CustomSocket<I, O>;
25
- onAny(listener: (event: string, ...args: Json.Array) => void): CustomSocket<I, O>;
26
- off<Event extends keyof I>(event: Event, listener?: (...args: I[Event]) => void): CustomSocket<I, O>;
27
- offAny(listener: (event: string, ...args: Json.Array) => void): CustomSocket<I, O>;
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): extends JsonIO>(tx: AtomIO.TransactionToken<ƒ>) => () => void;
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,5 +1,5 @@
1
- import { findRelationsInStore } from '../../dist/chunk-7ZR244C2.js';
2
- import '../../dist/chunk-WX2NCOZR.js';
1
+ import { findRelationsInStore } from '../../dist/chunk-MSCJWACE.js';
2
+ import '../../dist/chunk-FTONNX2R.js';
3
3
  import { __spreadProps, __spreadValues } from '../../dist/chunk-U2IICNHQ.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';
@@ -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
- const parsedEvent = parseJson(this.incompleteData);
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
- const parsedEvent2 = parseJson(event);
109
- this.handleEvent(...parsedEvent2);
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
- const parsedLog = parseJson(this.incompleteLog);
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
- const parsedLog2 = parseJson(this.incompleteLog);
134
- this.handleLog(parsedLog2);
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) => this.log(`i`, ...args),
199
- warn: (...args) => this.log(`w`, ...args),
200
- error: (...args) => this.log(`e`, ...args)
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 parsedEvent = parseJson(this.incompleteData);
215
- this.logger.info(`\u{1F3B0}`, `received`, parsedEvent);
216
- this.handleEvent(...parsedEvent);
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 parsedEvent2 = parseJson(event);
224
- this.handleEvent(...parsedEvent2);
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 unsubscribeFunctions2 = [];
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
- unsubscribeFunctions2.push(unsubscribe);
596
+ unsubFns.push(unsubscribe);
591
597
  }
592
598
  return () => {
593
- for (const unsubscribe of unsubscribeFunctions2)
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) => setIntoStore(token, newValue, store);
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 () => socket.off(`tx-run:${tx.key}`, fillTransactionRequest);
964
+ return () => {
965
+ socket.off(`tx-run:${tx.key}`, fillTransactionRequest);
966
+ };
957
967
  };
958
968
  }
959
969
 
@@ -76,12 +76,12 @@ export class ChildSocket<
76
76
  // console.log(`🤓`, this.unprocessedEvents.length)
77
77
  // console.log(`🤓`, ...this.unprocessedEvents.map((x) => x.length))
78
78
  const newInput = this.unprocessedEvents.shift()
79
- this.incompleteData += newInput || ``
79
+ this.incompleteData += newInput ?? ``
80
80
  try {
81
81
  if (this.incompleteData.startsWith(`error`)) {
82
82
  console.log(`❗`, this.incompleteData)
83
83
  }
84
- const parsedEvent = parseJson(this.incompleteData)
84
+ let parsedEvent = parseJson(this.incompleteData)
85
85
  this.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))
86
86
  while (this.unprocessedEvents.length > 0) {
87
87
  const event = this.unprocessedEvents.shift()
@@ -89,7 +89,7 @@ export class ChildSocket<
89
89
  if (this.unprocessedEvents.length === 0) {
90
90
  this.incompleteData = event
91
91
  }
92
- const parsedEvent = parseJson(event)
92
+ parsedEvent = parseJson(event)
93
93
  this.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))
94
94
  }
95
95
  }
@@ -109,15 +109,15 @@ export class ChildSocket<
109
109
  // console.log(`🤫`, this.unprocessedLogs.length)
110
110
  // console.log(`🤫`, ...this.unprocessedLogs.map((x) => x.length))
111
111
  const newInput = this.unprocessedLogs.shift()
112
- this.incompleteLog += newInput || ``
112
+ this.incompleteLog += newInput ?? ``
113
113
  try {
114
- const parsedLog = parseJson(this.incompleteLog)
114
+ let parsedLog = parseJson(this.incompleteLog)
115
115
  // console.log(`🤫`, parsedLog)
116
116
  this.handleLog(parsedLog)
117
117
  while (this.unprocessedLogs.length > 0) {
118
118
  this.incompleteLog = this.unprocessedLogs.shift() ?? ``
119
119
  if (this.incompleteLog) {
120
- const parsedLog = parseJson(this.incompleteLog)
120
+ parsedLog = parseJson(this.incompleteLog)
121
121
  this.handleLog(parsedLog)
122
122
  }
123
123
  }
@@ -49,7 +49,7 @@ export class CustomSocket<I extends Events, O extends Events> implements Socket
49
49
  public on<Event extends keyof I>(
50
50
  event: Event,
51
51
  listener: (...args: I[Event]) => void,
52
- ): CustomSocket<I, O> {
52
+ ): this {
53
53
  const listeners = this.listeners.get(event)
54
54
  if (listeners) {
55
55
  listeners.add(listener)
@@ -59,9 +59,7 @@ export class CustomSocket<I extends Events, O extends Events> implements Socket
59
59
  return this
60
60
  }
61
61
 
62
- public onAny(
63
- listener: (event: string, ...args: Json.Array) => void,
64
- ): CustomSocket<I, O> {
62
+ public onAny(listener: (event: string, ...args: Json.Array) => void): this {
65
63
  this.globalListeners.add(listener)
66
64
  return this
67
65
  }
@@ -69,7 +67,7 @@ export class CustomSocket<I extends Events, O extends Events> implements Socket
69
67
  public off<Event extends keyof I>(
70
68
  event: Event,
71
69
  listener?: (...args: I[Event]) => void,
72
- ): CustomSocket<I, O> {
70
+ ): this {
73
71
  const listeners = this.listeners.get(event)
74
72
  if (listeners) {
75
73
  if (listener) {
@@ -81,9 +79,7 @@ export class CustomSocket<I extends Events, O extends Events> implements Socket
81
79
  return this
82
80
  }
83
81
 
84
- public offAny(
85
- listener: (event: string, ...args: Json.Array) => void,
86
- ): CustomSocket<I, O> {
82
+ public offAny(listener: (event: string, ...args: Json.Array) => void): this {
87
83
  this.globalListeners.delete(listener)
88
84
  return this
89
85
  }
@@ -70,9 +70,15 @@ export class ParentSocket<
70
70
  )
71
71
  }
72
72
  public logger = {
73
- info: (...args: any[]): void => this.log(`i`, ...args),
74
- warn: (...args: any[]): void => this.log(`w`, ...args),
75
- error: (...args: any[]): void => this.log(`e`, ...args),
73
+ info: (...args: any[]): void => {
74
+ this.log(`i`, ...args)
75
+ },
76
+ warn: (...args: any[]): void => {
77
+ this.log(`w`, ...args)
78
+ },
79
+ error: (...args: any[]): void => {
80
+ this.log(`e`, ...args)
81
+ },
76
82
  }
77
83
 
78
84
  public constructor() {
@@ -93,12 +99,12 @@ export class ParentSocket<
93
99
  const chunk = buffer.toString()
94
100
  this.unprocessedEvents.push(...chunk.split(`\x03`))
95
101
  const newInput = this.unprocessedEvents.shift()
96
- this.incompleteData += newInput || ``
102
+ this.incompleteData += newInput ?? ``
97
103
 
98
104
  try {
99
- const parsedEvent = parseJson(this.incompleteData)
100
- this.logger.info(`🎰`, `received`, parsedEvent)
101
- this.handleEvent(...(parsedEvent as [string, ...I[keyof I]]))
105
+ const parsedData = parseJson(this.incompleteData)
106
+ this.logger.info(`🎰`, `received`, parsedData)
107
+ this.handleEvent(...(parsedData as [string, ...I[keyof I]]))
102
108
  while (this.unprocessedEvents.length > 0) {
103
109
  const event = this.unprocessedEvents.shift()
104
110
  if (event) {
@@ -9,17 +9,17 @@ export function realtimeActionReceiver({
9
9
  socket,
10
10
  store = IMPLICIT.STORE,
11
11
  }: ServerConfig) {
12
- return function actionReceiver extends JsonIO>(
13
- tx: AtomIO.TransactionToken<ƒ>,
12
+ return function actionReceiver<F extends JsonIO>(
13
+ tx: AtomIO.TransactionToken<F>,
14
14
  ): () => void {
15
15
  const fillTransactionRequest = (
16
- update: Pick<AtomIO.TransactionUpdate<ƒ>, `id` | `params`>,
16
+ update: Pick<AtomIO.TransactionUpdate<F>, `id` | `params`>,
17
17
  ) => {
18
18
  const performanceKey = `tx-run:${tx.key}:${update.id}`
19
19
  const performanceKeyStart = `${performanceKey}:start`
20
20
  const performanceKeyEnd = `${performanceKey}:end`
21
21
  performance.mark(performanceKeyStart)
22
- actUponStore<ƒ>(tx, update.id, store)(...update.params)
22
+ actUponStore<F>(tx, update.id, store)(...update.params)
23
23
  performance.mark(performanceKeyEnd)
24
24
  const metric = performance.measure(
25
25
  performanceKey,
@@ -30,6 +30,8 @@ export function realtimeActionReceiver({
30
30
  }
31
31
  socket.on(`tx-run:${tx.key}`, fillTransactionRequest)
32
32
 
33
- return () => socket.off(`tx-run:${tx.key}`, fillTransactionRequest)
33
+ return () => {
34
+ socket.off(`tx-run:${tx.key}`, fillTransactionRequest)
35
+ }
34
36
  }
35
37
  }
@@ -91,7 +91,7 @@ export function realtimeContinuitySynchronizer({
91
91
  const unsubscribeFunctions: (() => void)[] = []
92
92
 
93
93
  const revealPerspectives = (): (() => void) => {
94
- const unsubscribeFunctions: (() => void)[] = []
94
+ const unsubFns: (() => void)[] = []
95
95
  for (const perspective of continuity.perspectives) {
96
96
  const { viewAtoms } = perspective
97
97
  const userViewState = findInStore(viewAtoms, userKey, store)
@@ -128,10 +128,10 @@ export function realtimeContinuitySynchronizer({
128
128
  `sync-continuity:${continuityKey}:${userKey}:perspective:${perspective.resourceAtoms.key}`,
129
129
  store,
130
130
  )
131
- unsubscribeFunctions.push(unsubscribe)
131
+ unsubFns.push(unsubscribe)
132
132
  }
133
133
  return () => {
134
- for (const unsubscribe of unsubscribeFunctions) unsubscribe()
134
+ for (const unsubscribe of unsubFns) unsubscribe()
135
135
  }
136
136
  }
137
137
  const unsubscribeFromPerspectives = revealPerspectives()
@@ -12,7 +12,9 @@ export function realtimeStateReceiver({
12
12
  return function stateReceiver<J extends Json.Serializable>(
13
13
  token: WritableToken<J>,
14
14
  ): () => void {
15
- const publish = (newValue: J) => setIntoStore(token, newValue, store)
15
+ const publish = (newValue: J) => {
16
+ setIntoStore(token, newValue, store)
17
+ }
16
18
 
17
19
  const fillPubUnclaim = () => {
18
20
  socket.off(`pub:${token.key}`, publish)