atom.io 0.25.6 → 0.27.0

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 (108) hide show
  1. package/data/dist/index.d.ts +3 -3
  2. package/data/dist/index.js +33 -25
  3. package/data/package.json +1 -4
  4. package/data/src/dict.ts +3 -3
  5. package/dist/chunk-AK23DRMD.js +21 -0
  6. package/dist/{chunk-HYXKCFVY.js → chunk-IBTHB2PI.js} +59 -60
  7. package/dist/{chunk-MR5NETHW.js → chunk-IW6WYRS7.js} +4 -5
  8. package/dist/chunk-XWL6SNVU.js +7 -0
  9. package/dist/index.d.ts +32 -54
  10. package/dist/index.js +33 -21
  11. package/ephemeral/dist/index.d.ts +7 -7
  12. package/ephemeral/dist/index.js +1 -1
  13. package/ephemeral/package.json +1 -4
  14. package/ephemeral/src/find-state.ts +7 -7
  15. package/eslint-plugin/dist/index.js +7 -8
  16. package/eslint-plugin/package.json +1 -4
  17. package/immortal/dist/index.d.ts +7 -7
  18. package/immortal/dist/index.js +1 -1
  19. package/immortal/package.json +1 -4
  20. package/immortal/src/seek-state.ts +8 -8
  21. package/internal/dist/index.d.ts +56 -59
  22. package/internal/dist/index.js +178 -170
  23. package/internal/package.json +1 -4
  24. package/internal/src/families/create-atom-family.ts +4 -4
  25. package/internal/src/families/create-readonly-selector-family.ts +2 -2
  26. package/internal/src/families/create-regular-atom-family.ts +2 -2
  27. package/internal/src/families/create-selector-family.ts +4 -4
  28. package/internal/src/families/create-writable-selector-family.ts +2 -2
  29. package/internal/src/families/dispose-from-store.ts +3 -7
  30. package/internal/src/families/find-in-store.ts +9 -9
  31. package/internal/src/families/init-family-member.ts +25 -37
  32. package/internal/src/families/seek-in-store.ts +11 -10
  33. package/internal/src/get-state/get-from-store.ts +3 -3
  34. package/internal/src/molecule/grow-molecule-in-store.ts +9 -9
  35. package/internal/src/mutable/index.ts +0 -1
  36. package/internal/src/mutable/tracker-family.ts +2 -2
  37. package/internal/src/set-state/set-into-store.ts +4 -4
  38. package/internal/src/store/deposit.ts +3 -3
  39. package/internal/src/store/withdraw.ts +10 -9
  40. package/introspection/dist/index.js +32 -30
  41. package/introspection/package.json +1 -4
  42. package/json/dist/index.d.ts +10 -27
  43. package/json/dist/index.js +3 -3
  44. package/json/package.json +1 -4
  45. package/json/src/index.ts +8 -3
  46. package/json/src/select-json-family.ts +4 -4
  47. package/package.json +36 -65
  48. package/react/dist/index.d.ts +4 -4
  49. package/react/dist/index.js +2 -2
  50. package/react/package.json +1 -4
  51. package/react/src/parse-state-overloads.ts +4 -4
  52. package/react/src/use-i.ts +3 -3
  53. package/react/src/use-json.ts +3 -3
  54. package/react/src/use-o.ts +3 -3
  55. package/react-devtools/dist/index.d.ts +1 -1
  56. package/react-devtools/dist/index.js +90 -72
  57. package/react-devtools/package.json +1 -4
  58. package/react-devtools/src/StateIndex.tsx +5 -4
  59. package/realtime/dist/index.d.ts +3 -3
  60. package/realtime/dist/index.js +8 -9
  61. package/realtime/package.json +1 -4
  62. package/realtime/src/realtime-continuity.ts +2 -2
  63. package/realtime-client/dist/index.js +6 -6
  64. package/realtime-client/package.json +1 -4
  65. package/realtime-react/dist/index.d.ts +4 -4
  66. package/realtime-react/dist/index.js +9 -11
  67. package/realtime-react/package.json +1 -4
  68. package/realtime-react/src/use-pull-atom-family-member.ts +2 -2
  69. package/realtime-react/src/use-pull-mutable-family-member.ts +2 -2
  70. package/realtime-react/src/use-pull-selector-family-member.ts +2 -2
  71. package/realtime-server/dist/index.d.ts +9 -9
  72. package/realtime-server/dist/index.js +59 -54
  73. package/realtime-server/package.json +1 -4
  74. package/realtime-server/src/ipc-sockets/custom-socket.ts +2 -2
  75. package/realtime-server/src/realtime-family-provider.ts +3 -2
  76. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  77. package/realtime-testing/dist/index.js +3 -3
  78. package/realtime-testing/package.json +1 -4
  79. package/src/atom.ts +15 -42
  80. package/src/dispose-state.ts +2 -2
  81. package/src/get-state.ts +4 -4
  82. package/src/index.ts +5 -5
  83. package/src/molecule.ts +4 -3
  84. package/src/selector.ts +17 -39
  85. package/src/set-state.ts +3 -2
  86. package/src/silo.ts +4 -4
  87. package/transceivers/set-rtx/dist/index.js +11 -11
  88. package/transceivers/set-rtx/package.json +1 -4
  89. package/transceivers/set-rtx/src/set-rtx.ts +5 -5
  90. package/data/dist/index.cjs +0 -953
  91. package/dist/chunk-BF4MVQF6.js +0 -44
  92. package/dist/chunk-S4N6XNPH.js +0 -38
  93. package/dist/index.cjs +0 -215
  94. package/ephemeral/dist/index.cjs +0 -11
  95. package/eslint-plugin/dist/index.cjs +0 -388
  96. package/immortal/dist/index.cjs +0 -14
  97. package/internal/dist/index.cjs +0 -3405
  98. package/internal/src/mutable/is-mutable.ts +0 -16
  99. package/introspection/dist/index.cjs +0 -449
  100. package/json/dist/index.cjs +0 -128
  101. package/react/dist/index.cjs +0 -118
  102. package/react-devtools/dist/index.cjs +0 -2191
  103. package/realtime/dist/index.cjs +0 -120
  104. package/realtime-client/dist/index.cjs +0 -569
  105. package/realtime-react/dist/index.cjs +0 -189
  106. package/realtime-server/dist/index.cjs +0 -965
  107. package/realtime-testing/dist/index.cjs +0 -201
  108. package/transceivers/set-rtx/dist/index.cjs +0 -215
@@ -1,5 +1,5 @@
1
1
  import { lazyLocalStorageEffect } from '../../dist/chunk-H6EDLPKH.js';
2
- import '../../dist/chunk-S4N6XNPH.js';
2
+ import '../../dist/chunk-XWL6SNVU.js';
3
3
  import * as Internal from 'atom.io/internal';
4
4
  import { setIntoStore, getJsonToken, getUpdateToken, getFromStore, assignTransactionToContinuity, subscribeToTransaction, disposeAtom, setEpochNumberOfContinuity, getEpochNumberOfContinuity, isRootStore, ingestTransactionUpdate, actUponStore } from 'atom.io/internal';
5
5
  import { parseJson } from 'atom.io/json';
@@ -25,13 +25,13 @@ function pullAtomFamilyMember(token, socket, store) {
25
25
  }
26
26
  const { key: familyKey, subKey: serializedSubKey } = token.family;
27
27
  const subKey = parseJson(serializedSubKey);
28
- socket == null ? void 0 : socket.on(`serve:${token.key}`, (data) => {
28
+ socket?.on(`serve:${token.key}`, (data) => {
29
29
  setIntoStore(token, data, store);
30
30
  });
31
- socket == null ? void 0 : socket.emit(`sub:${familyKey}`, subKey);
31
+ socket?.emit(`sub:${familyKey}`, subKey);
32
32
  return () => {
33
- socket == null ? void 0 : socket.off(`serve:${token.key}`);
34
- socket == null ? void 0 : socket.emit(`unsub:${token.key}`);
33
+ socket?.off(`serve:${token.key}`);
34
+ socket?.emit(`unsub:${token.key}`);
35
35
  };
36
36
  }
37
37
  function pullMutableAtom(token, socket, store) {
@@ -332,7 +332,7 @@ function syncContinuity(continuity, socket, store) {
332
332
  reconcileEpoch(zerothOptimisticUpdate, confirmed);
333
333
  for (const nextConfirmed of confirmedUpdates) {
334
334
  const nextOptimistic = optimisticUpdates[0];
335
- if (nextConfirmed.epoch === (nextOptimistic == null ? void 0 : nextOptimistic.epoch)) {
335
+ if (nextConfirmed.epoch === nextOptimistic?.epoch) {
336
336
  reconcileEpoch(nextOptimistic, nextConfirmed);
337
337
  } else {
338
338
  break;
@@ -2,14 +2,11 @@
2
2
  "name": "atom.io-realtime-client",
3
3
  "type": "module",
4
4
  "private": true,
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.js",
5
+ "main": "dist/index.js",
7
6
  "types": "dist/index.d.ts",
8
7
  "exports": {
9
8
  ".": {
10
9
  "import": "./dist/index.js",
11
- "browser": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
10
  "types": "./dist/index.d.ts"
14
11
  }
15
12
  }
@@ -1,7 +1,7 @@
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 { Json } from 'atom.io/json';
4
+ import { Json, Canonical } from 'atom.io/json';
5
5
  import { Transceiver, Func } from 'atom.io/internal';
6
6
  import { ContinuityToken } from 'atom.io/realtime';
7
7
 
@@ -20,15 +20,15 @@ declare const RealtimeProvider: React.FC<{
20
20
 
21
21
  declare function usePullAtom<J extends Json.Serializable>(token: AtomIO.RegularAtomToken<J>): J;
22
22
 
23
- declare function usePullAtomFamilyMember<J extends Json.Serializable, K extends Json.Serializable, Key extends K>(family: AtomIO.RegularAtomFamilyToken<J, K>, subKey: Key): J;
23
+ declare function usePullAtomFamilyMember<J extends Json.Serializable, K extends Canonical, Key extends K>(family: AtomIO.RegularAtomFamilyToken<J, K>, subKey: Key): J;
24
24
 
25
25
  declare function usePullMutable<T extends Transceiver<any>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>): T;
26
26
 
27
- declare function usePullMutableAtomFamilyMember<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(familyToken: AtomIO.MutableAtomFamilyToken<T, J, K>, key: Key): T;
27
+ declare function usePullMutableAtomFamilyMember<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(familyToken: AtomIO.MutableAtomFamilyToken<T, J, K>, key: Key): T;
28
28
 
29
29
  declare function usePullSelector<J extends Json.Serializable>(token: AtomIO.SelectorToken<J>): J;
30
30
 
31
- declare function usePullSelectorFamilyMember<T, K extends Json.Serializable, Key extends K>(familyToken: AtomIO.SelectorFamilyToken<T, K>, key: Key): T;
31
+ declare function usePullSelectorFamilyMember<T, K extends Canonical, Key extends K>(familyToken: AtomIO.SelectorFamilyToken<T, K>, key: Key): T;
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
 
@@ -1,4 +1,4 @@
1
- import '../../dist/chunk-S4N6XNPH.js';
1
+ import '../../dist/chunk-XWL6SNVU.js';
2
2
  import { useI, StoreContext, useO } from 'atom.io/react';
3
3
  import * as RTC from 'atom.io/realtime-client';
4
4
  import { syncContinuity } from 'atom.io/realtime-client';
@@ -14,11 +14,11 @@ var RealtimeProvider = ({ children, socket }) => {
14
14
  const services = React.useRef(/* @__PURE__ */ new Map()).current;
15
15
  const setMyId = useI(RTC.myIdState__INTERNAL);
16
16
  React.useEffect(() => {
17
- setMyId(socket == null ? void 0 : socket.id);
18
- socket == null ? void 0 : socket.on(`connect`, () => {
17
+ setMyId(socket?.id);
18
+ socket?.on(`connect`, () => {
19
19
  setMyId(socket.id);
20
20
  });
21
- socket == null ? void 0 : socket.on(`disconnect`, () => {
21
+ socket?.on(`disconnect`, () => {
22
22
  setMyId(void 0);
23
23
  });
24
24
  }, [socket, setMyId]);
@@ -32,10 +32,9 @@ function useSingleEffect(effect, deps) {
32
32
  if (IN_DEV) {
33
33
  const cleanup = React.useRef(noop);
34
34
  React.useEffect(() => {
35
- var _a;
36
35
  let dispose = cleanup.current;
37
36
  if (dispose === noop) {
38
- dispose = (_a = effect()) != null ? _a : noop;
37
+ dispose = effect() ?? noop;
39
38
  cleanup.current = dispose;
40
39
  } else {
41
40
  return () => {
@@ -58,21 +57,20 @@ function onMount(effect) {
58
57
  function useRealtimeService(key, create) {
59
58
  const { socket, services } = React.useContext(RealtimeContext);
60
59
  onMount(() => {
61
- let service = services == null ? void 0 : services.get(key);
60
+ let service = services?.get(key);
62
61
  if (service) {
63
62
  service[0]++;
64
63
  } else {
65
64
  const dispose = socket ? create(socket) : void 0;
66
65
  service = [1, dispose];
67
- services == null ? void 0 : services.set(key, service);
66
+ services?.set(key, service);
68
67
  }
69
68
  return () => {
70
- var _a;
71
69
  if (service) {
72
70
  service[0]--;
73
71
  if (service[0] === 0) {
74
- (_a = service[1]) == null ? void 0 : _a.call(service);
75
- services == null ? void 0 : services.delete(key);
72
+ service[1]?.();
73
+ services?.delete(key);
76
74
  }
77
75
  }
78
76
  };
@@ -2,14 +2,11 @@
2
2
  "name": "atom.io-realtime-react",
3
3
  "type": "module",
4
4
  "private": true,
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.js",
5
+ "main": "dist/index.js",
7
6
  "types": "dist/index.d.ts",
8
7
  "exports": {
9
8
  ".": {
10
9
  "import": "./dist/index.js",
11
- "browser": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
10
  "types": "./dist/index.d.ts"
14
11
  }
15
12
  }
@@ -1,6 +1,6 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import { findInStore } from "atom.io/internal"
3
- import type { Json } from "atom.io/json"
3
+ import type { Canonical, Json } from "atom.io/json"
4
4
  import { StoreContext, useO } from "atom.io/react"
5
5
  import * as RTC from "atom.io/realtime-client"
6
6
  import * as React from "react"
@@ -9,7 +9,7 @@ import { useRealtimeService } from "./use-realtime-service"
9
9
 
10
10
  export function usePullAtomFamilyMember<
11
11
  J extends Json.Serializable,
12
- K extends Json.Serializable,
12
+ K extends Canonical,
13
13
  Key extends K,
14
14
  >(family: AtomIO.RegularAtomFamilyToken<J, K>, subKey: Key): J {
15
15
  const store = React.useContext(StoreContext)
@@ -1,7 +1,7 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import type { Transceiver } from "atom.io/internal"
3
3
  import { findInStore } from "atom.io/internal"
4
- import type { Json } from "atom.io/json"
4
+ import type { Canonical, Json } from "atom.io/json"
5
5
  import { StoreContext, useO } from "atom.io/react"
6
6
  import * as RTC from "atom.io/realtime-client"
7
7
  import * as React from "react"
@@ -11,7 +11,7 @@ import { useRealtimeService } from "./use-realtime-service"
11
11
  export function usePullMutableAtomFamilyMember<
12
12
  T extends Transceiver<any>,
13
13
  J extends Json.Serializable,
14
- K extends Json.Serializable,
14
+ K extends Canonical,
15
15
  Key extends K,
16
16
  >(familyToken: AtomIO.MutableAtomFamilyToken<T, J, K>, key: Key): T {
17
17
  const store = React.useContext(StoreContext)
@@ -1,6 +1,6 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import { findInStore } from "atom.io/internal"
3
- import type { Json } from "atom.io/json"
3
+ import type { Canonical } from "atom.io/json"
4
4
  import { StoreContext, useO } from "atom.io/react"
5
5
  import * as RTC from "atom.io/realtime-client"
6
6
  import * as React from "react"
@@ -9,7 +9,7 @@ import { useRealtimeService } from "./use-realtime-service"
9
9
 
10
10
  export function usePullSelectorFamilyMember<
11
11
  T,
12
- K extends Json.Serializable,
12
+ K extends Canonical,
13
13
  Key extends K,
14
14
  >(familyToken: AtomIO.SelectorFamilyToken<T, K>, key: Key): T {
15
15
  const store = React.useContext(StoreContext)
@@ -1,5 +1,5 @@
1
1
  import { Subject, Transceiver, Store } from 'atom.io/internal';
2
- import { Json, Stringified, JsonIO } from 'atom.io/json';
2
+ import { Json, stringified, JsonIO, Canonical } from 'atom.io/json';
3
3
  import { ChildProcessWithoutNullStreams } from 'node:child_process';
4
4
  import * as AtomIO from 'atom.io';
5
5
  import { TransactionUpdateContent, TransactionUpdate, WritableToken } from 'atom.io';
@@ -9,7 +9,7 @@ import { Loadable } from 'atom.io/data';
9
9
  import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
10
10
 
11
11
  type Events = Json.Object<string, Json.Serializable[]>;
12
- type StringifiedEvent<Key extends string, Params extends Json.Serializable[]> = Stringified<[Key, ...Params]>;
12
+ type StringifiedEvent<Key extends string, Params extends Json.Serializable[]> = stringified<[Key, ...Params]>;
13
13
  interface EventBuffer<Key extends string, Params extends Json.Serializable[]> extends Buffer {
14
14
  toString(): StringifiedEvent<Key, Params>;
15
15
  }
@@ -88,10 +88,10 @@ type RealtimeContinuitySynchronizer = ReturnType<typeof realtimeContinuitySynchr
88
88
  declare function realtimeContinuitySynchronizer({ socket: initialSocket, store, }: ServerConfig): (continuity: ContinuityToken) => () => void;
89
89
 
90
90
  type FamilyProvider = ReturnType<typeof realtimeAtomFamilyProvider>;
91
- declare function realtimeAtomFamilyProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable, K extends Json.Serializable>(family: AtomIO.RegularAtomFamilyToken<J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
91
+ declare function realtimeAtomFamilyProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable, K extends Canonical>(family: AtomIO.RegularAtomFamilyToken<J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
92
92
 
93
93
  type MutableFamilyProvider = ReturnType<typeof realtimeMutableFamilyProvider>;
94
- declare function realtimeMutableFamilyProvider({ socket, store, }: ServerConfig): <T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(family: AtomIO.MutableAtomFamilyToken<T, J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
94
+ declare function realtimeMutableFamilyProvider({ socket, store, }: ServerConfig): <T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(family: AtomIO.MutableAtomFamilyToken<T, J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
95
95
 
96
96
  type MutableProvider = ReturnType<typeof realtimeMutableProvider>;
97
97
  declare function realtimeMutableProvider({ socket, store, }: ServerConfig): <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
@@ -105,16 +105,16 @@ type LeaveRoomIO = AtomIO.TransactionIO<typeof leaveRoomTX>;
105
105
  declare const destroyRoomTX: AtomIO.TransactionToken<(roomId: string) => void>;
106
106
 
107
107
  type RoomArguments = [script: string, options: string[]] | [script: string];
108
- declare const roomArgumentsAtoms: AtomIO.RegularAtomFamilyTokenWithCall<RoomArguments, string>;
109
- declare const roomSelectors: AtomIO.ReadonlySelectorFamilyTokenWithCall<Loadable<ChildSocket<any, any>>, string>;
108
+ declare const roomArgumentsAtoms: AtomIO.RegularAtomFamilyToken<RoomArguments, string>;
109
+ declare const roomSelectors: AtomIO.ReadonlySelectorFamilyToken<Loadable<ChildSocket<any, any>>, string>;
110
110
 
111
111
  declare function redactTransactionUpdateContent(visibleStateKeys: string[], updates: TransactionUpdateContent[]): TransactionUpdateContent[];
112
- declare const actionOcclusionAtoms: AtomIO.RegularAtomFamilyTokenWithCall<{
112
+ declare const actionOcclusionAtoms: AtomIO.RegularAtomFamilyToken<{
113
113
  occlude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[];
114
114
  }, string>;
115
- declare const userUnacknowledgedQueues: AtomIO.RegularAtomFamilyTokenWithCall<Pick<TransactionUpdate<any>, "key" | "id" | "epoch" | "updates" | "output">[], string>;
115
+ declare const userUnacknowledgedQueues: AtomIO.RegularAtomFamilyToken<Pick<TransactionUpdate<any>, "key" | "id" | "epoch" | "updates" | "output">[], string>;
116
116
 
117
- declare const socketAtoms: AtomIO.RegularAtomFamilyTokenWithCall<Socket | null, string>;
117
+ declare const socketAtoms: AtomIO.RegularAtomFamilyToken<Socket | null, string>;
118
118
  declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
119
119
  declare const userIndex: AtomIO.MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
120
120
  declare const usersOfSockets: atom_io_data.JoinToken<"user", "socket", "1:1", null>;
@@ -1,4 +1,4 @@
1
- import { __spreadProps, __spreadValues } from '../../dist/chunk-S4N6XNPH.js';
1
+ import '../../dist/chunk-XWL6SNVU.js';
2
2
  import { parseJson, stringifyJson } from 'atom.io/json';
3
3
  import { Subject, IMPLICIT, getFromStore, subscribeToState, findInStore, getJsonToken, getUpdateToken, actUponStore, isRootStore, subscribeToTransaction, setIntoStore } from 'atom.io/internal';
4
4
  import { SetRTX } from 'atom.io/transceivers/set-rtx';
@@ -12,10 +12,11 @@ import { spawn } from 'child_process';
12
12
  var CustomSocket = class {
13
13
  constructor(emit) {
14
14
  this.emit = emit;
15
- this.id = `no_id_retrieved`;
16
15
  this.listeners = /* @__PURE__ */ new Map();
17
16
  this.globalListeners = /* @__PURE__ */ new Set();
18
17
  }
18
+ listeners;
19
+ globalListeners;
19
20
  handleEvent(event, ...args) {
20
21
  for (const listener of this.globalListeners) {
21
22
  listener(event, ...args);
@@ -27,6 +28,7 @@ var CustomSocket = class {
27
28
  }
28
29
  }
29
30
  }
31
+ id = `no_id_retrieved`;
30
32
  on(event, listener) {
31
33
  const listeners = this.listeners.get(event);
32
34
  if (listeners) {
@@ -75,11 +77,6 @@ var ChildSocket = class extends CustomSocket {
75
77
  this.process = process2;
76
78
  this.key = key;
77
79
  this.logger = logger;
78
- this.incompleteData = ``;
79
- this.unprocessedEvents = [];
80
- this.incompleteLog = ``;
81
- this.unprocessedLogs = [];
82
- this.id = `#####`;
83
80
  this.process = process2;
84
81
  this.process.stdout.on(
85
82
  `data`,
@@ -90,7 +87,7 @@ var ChildSocket = class extends CustomSocket {
90
87
  }
91
88
  this.unprocessedEvents.push(...chunk.split(``));
92
89
  const newInput = this.unprocessedEvents.shift();
93
- this.incompleteData += newInput != null ? newInput : ``;
90
+ this.incompleteData += newInput ?? ``;
94
91
  try {
95
92
  if (this.incompleteData.startsWith(`error`)) {
96
93
  console.log(`\u2757`, this.incompleteData);
@@ -117,16 +114,15 @@ var ChildSocket = class extends CustomSocket {
117
114
  }
118
115
  );
119
116
  this.process.stderr.on(`data`, (buf) => {
120
- var _a;
121
117
  const chunk = buf.toString();
122
118
  this.unprocessedLogs.push(...chunk.split(``));
123
119
  const newInput = this.unprocessedLogs.shift();
124
- this.incompleteLog += newInput != null ? newInput : ``;
120
+ this.incompleteLog += newInput ?? ``;
125
121
  try {
126
122
  let parsedLog = parseJson(this.incompleteLog);
127
123
  this.handleLog(parsedLog);
128
124
  while (this.unprocessedLogs.length > 0) {
129
- this.incompleteLog = (_a = this.unprocessedLogs.shift()) != null ? _a : ``;
125
+ this.incompleteLog = this.unprocessedLogs.shift() ?? ``;
130
126
  if (this.incompleteLog) {
131
127
  parsedLog = parseJson(this.incompleteLog);
132
128
  this.handleLog(parsedLog);
@@ -143,6 +139,11 @@ var ChildSocket = class extends CustomSocket {
143
139
  this.id = process2.pid.toString();
144
140
  }
145
141
  }
142
+ incompleteData = ``;
143
+ unprocessedEvents = [];
144
+ incompleteLog = ``;
145
+ unprocessedLogs = [];
146
+ id = `#####`;
146
147
  handleLog(arg) {
147
148
  if (Array.isArray(arg)) {
148
149
  const [level, ...rest] = arg;
@@ -161,13 +162,15 @@ var ChildSocket = class extends CustomSocket {
161
162
  }
162
163
  };
163
164
  var SubjectSocket = class extends CustomSocket {
165
+ in;
166
+ out;
167
+ id = `no_id_retrieved`;
168
+ disposalFunctions = [];
164
169
  constructor(id) {
165
170
  super((...args) => {
166
171
  this.out.next(args);
167
172
  return this;
168
173
  });
169
- this.id = `no_id_retrieved`;
170
- this.disposalFunctions = [];
171
174
  this.id = id;
172
175
  this.in = new Subject();
173
176
  this.out = new Subject();
@@ -182,27 +185,38 @@ var SubjectSocket = class extends CustomSocket {
182
185
  }
183
186
  };
184
187
  var ParentSocket = class extends CustomSocket {
188
+ incompleteData = ``;
189
+ unprocessedEvents = [];
190
+ relays;
191
+ relayServices;
192
+ process;
193
+ id = `#####`;
194
+ log(...args) {
195
+ this.process.stderr.write(
196
+ stringifyJson(
197
+ args.map(
198
+ (arg) => arg instanceof SetRTX ? `{ ${arg.toJSON().members.join(` | `)} }` : arg
199
+ )
200
+ ) + ``
201
+ );
202
+ }
203
+ logger = {
204
+ info: (...args) => {
205
+ this.log(`i`, ...args);
206
+ },
207
+ warn: (...args) => {
208
+ this.log(`w`, ...args);
209
+ },
210
+ error: (...args) => {
211
+ this.log(`e`, ...args);
212
+ }
213
+ };
185
214
  constructor() {
186
- var _a;
187
215
  super((event, ...args) => {
188
216
  const stringifiedEvent = JSON.stringify([event, ...args]);
189
217
  this.process.stdout.write(stringifiedEvent + ``);
190
218
  return this;
191
219
  });
192
- this.incompleteData = ``;
193
- this.unprocessedEvents = [];
194
- this.id = `#####`;
195
- this.logger = {
196
- info: (...args) => {
197
- this.log(`i`, ...args);
198
- },
199
- warn: (...args) => {
200
- this.log(`w`, ...args);
201
- },
202
- error: (...args) => {
203
- this.log(`e`, ...args);
204
- }
205
- };
206
220
  this.process = process;
207
221
  this.process.stdin.resume();
208
222
  this.relays = /* @__PURE__ */ new Map();
@@ -213,7 +227,7 @@ var ParentSocket = class extends CustomSocket {
213
227
  const chunk = buffer.toString();
214
228
  this.unprocessedEvents.push(...chunk.split(``));
215
229
  const newInput = this.unprocessedEvents.shift();
216
- this.incompleteData += newInput != null ? newInput : ``;
230
+ this.incompleteData += newInput ?? ``;
217
231
  try {
218
232
  const parsedData = parseJson(this.incompleteData);
219
233
  this.logger.info(`\u{1F3B0}`, `received`, parsedData);
@@ -256,7 +270,7 @@ var ParentSocket = class extends CustomSocket {
256
270
  process.exit(0);
257
271
  });
258
272
  if (process.pid) {
259
- this.id = (_a = process.pid) == null ? void 0 : _a.toString();
273
+ this.id = process.pid?.toString();
260
274
  }
261
275
  this.on(`user-joins`, (username) => {
262
276
  this.logger.info(`\u{1F464}`, `user`, username, `joined`);
@@ -290,15 +304,6 @@ var ParentSocket = class extends CustomSocket {
290
304
  });
291
305
  process.stdout.write(`\u2728`);
292
306
  }
293
- log(...args) {
294
- this.process.stderr.write(
295
- stringifyJson(
296
- args.map(
297
- (arg) => arg instanceof SetRTX ? `{ ${arg.toJSON().members.join(` | `)} }` : arg
298
- )
299
- ) + ``
300
- );
301
- }
302
307
  relay(attachServices) {
303
308
  this.logger.info(`\u{1F517}`, `running relay method`);
304
309
  this.relayServices.push(attachServices);
@@ -321,7 +326,7 @@ function realtimeActionReceiver({
321
326
  performanceKeyStart,
322
327
  performanceKeyEnd
323
328
  );
324
- store == null ? void 0 : store.logger.info(`\u{1F680}`, `transaction`, tx.key, update.id, metric.duration);
329
+ store?.logger.info(`\u{1F680}`, `transaction`, tx.key, update.id, metric.duration);
325
330
  };
326
331
  socket.on(`tx-run:${tx.key}`, fillTransactionRequest);
327
332
  return () => {
@@ -415,7 +420,7 @@ function redactTransactionUpdateContent(visibleStateKeys, updates) {
415
420
  visibleStateKeys,
416
421
  update.updates
417
422
  );
418
- return __spreadProps(__spreadValues({}, update), { updates: redacted });
423
+ return { ...update, updates: redacted };
419
424
  }
420
425
  default:
421
426
  return update;
@@ -556,10 +561,10 @@ function realtimeContinuitySynchronizer({
556
561
  { oldKeys, newKeys, revealed, concealed }
557
562
  );
558
563
  if (revealed.length > 0) {
559
- socket == null ? void 0 : socket.emit(`reveal:${continuityKey}`, revealed);
564
+ socket?.emit(`reveal:${continuityKey}`, revealed);
560
565
  }
561
566
  if (concealed.length > 0) {
562
- socket == null ? void 0 : socket.emit(`conceal:${continuityKey}`, concealed);
567
+ socket?.emit(`conceal:${continuityKey}`, concealed);
563
568
  }
564
569
  },
565
570
  `sync-continuity:${continuityKey}:${userKey}:perspective:${perspective.resourceAtoms.key}`,
@@ -573,7 +578,6 @@ function realtimeContinuitySynchronizer({
573
578
  };
574
579
  const unsubscribeFromPerspectives = revealPerspectives();
575
580
  const sendInitialPayload = () => {
576
- var _a;
577
581
  const initialPayload = [];
578
582
  for (const atom2 of continuity.globals) {
579
583
  const resourceToken = atom2.type === `mutable_atom` ? getJsonToken(atom2, store) : atom2;
@@ -594,8 +598,8 @@ function realtimeContinuitySynchronizer({
594
598
  initialPayload.push(resourceToken, resource);
595
599
  }
596
600
  }
597
- const epoch = isRootStore(store) ? (_a = store.transactionMeta.epoch.get(continuityKey)) != null ? _a : null : null;
598
- socket == null ? void 0 : socket.emit(`continuity-init:${continuityKey}`, epoch, initialPayload);
601
+ const epoch = isRootStore(store) ? store.transactionMeta.epoch.get(continuityKey) ?? null : null;
602
+ socket?.emit(`continuity-init:${continuityKey}`, epoch, initialPayload);
599
603
  for (const transaction2 of continuity.actions) {
600
604
  const unsubscribeFromTransaction = subscribeToTransaction(
601
605
  transaction2,
@@ -623,10 +627,11 @@ function realtimeContinuitySynchronizer({
623
627
  visibleKeys,
624
628
  update.updates
625
629
  );
626
- const redactedUpdate = __spreadProps(__spreadValues({}, update), {
630
+ const redactedUpdate = {
631
+ ...update,
627
632
  updates: redactedUpdates
628
- });
629
- socket == null ? void 0 : socket.emit(
633
+ };
634
+ socket?.emit(
630
635
  `tx-new:${continuityKey}`,
631
636
  redactedUpdate
632
637
  );
@@ -681,7 +686,7 @@ function realtimeContinuitySynchronizer({
681
686
  performanceKeyStart,
682
687
  performanceKeyEnd
683
688
  );
684
- store == null ? void 0 : store.logger.info(
689
+ store?.logger.info(
685
690
  `\u{1F680}`,
686
691
  `transaction`,
687
692
  transactionKey,
@@ -708,8 +713,8 @@ function realtimeContinuitySynchronizer({
708
713
  return () => {
709
714
  for (const unsubscribe of unsubscribeFunctions) unsubscribe();
710
715
  unsubscribeFromPerspectives();
711
- socket == null ? void 0 : socket.off(`get:${continuityKey}`, sendInitialPayload);
712
- socket == null ? void 0 : socket.off(`tx-run:${continuityKey}`, fillTransactionRequest);
716
+ socket?.off(`get:${continuityKey}`, sendInitialPayload);
717
+ socket?.off(`tx-run:${continuityKey}`, fillTransactionRequest);
713
718
  };
714
719
  };
715
720
  }
@@ -818,7 +823,7 @@ function realtimeMutableProvider({
818
823
  const trackerToken = getUpdateToken(token);
819
824
  const fillUnsubRequest = () => {
820
825
  socket.off(`unsub:${token.key}`, fillUnsubRequest);
821
- unsubscribeFromStateUpdates == null ? void 0 : unsubscribeFromStateUpdates();
826
+ unsubscribeFromStateUpdates?.();
822
827
  unsubscribeFromStateUpdates = null;
823
828
  };
824
829
  const fillSubRequest = () => {
@@ -836,7 +841,7 @@ function realtimeMutableProvider({
836
841
  socket.on(`sub:${token.key}`, fillSubRequest);
837
842
  return () => {
838
843
  socket.off(`sub:${token.key}`, fillSubRequest);
839
- unsubscribeFromStateUpdates == null ? void 0 : unsubscribeFromStateUpdates();
844
+ unsubscribeFromStateUpdates?.();
840
845
  };
841
846
  };
842
847
  }
@@ -2,14 +2,11 @@
2
2
  "name": "atom.io-realtime-server",
3
3
  "type": "module",
4
4
  "private": true,
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.js",
5
+ "main": "dist/index.js",
7
6
  "types": "dist/index.d.ts",
8
7
  "exports": {
9
8
  ".": {
10
9
  "import": "./dist/index.js",
11
- "browser": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
10
  "types": "./dist/index.d.ts"
14
11
  }
15
12
  }
@@ -1,4 +1,4 @@
1
- import type { Json, Stringified } from "atom.io/json"
1
+ import type { Json, stringified } from "atom.io/json"
2
2
 
3
3
  import type { Socket } from ".."
4
4
 
@@ -7,7 +7,7 @@ export type Events = Json.Object<string, Json.Serializable[]>
7
7
  export type StringifiedEvent<
8
8
  Key extends string,
9
9
  Params extends Json.Serializable[],
10
- > = Stringified<[Key, ...Params]>
10
+ > = stringified<[Key, ...Params]>
11
11
 
12
12
  export interface EventBuffer<
13
13
  Key extends string,
@@ -5,7 +5,8 @@ import {
5
5
  IMPLICIT,
6
6
  subscribeToState,
7
7
  } from "atom.io/internal"
8
- import { type Json, stringifyJson } from "atom.io/json"
8
+ import type { Canonical, Json } from "atom.io/json"
9
+ import { stringifyJson } from "atom.io/json"
9
10
 
10
11
  import type { ServerConfig } from "."
11
12
 
@@ -16,7 +17,7 @@ export function realtimeAtomFamilyProvider({
16
17
  }: ServerConfig) {
17
18
  return function familyProvider<
18
19
  J extends Json.Serializable,
19
- K extends Json.Serializable,
20
+ K extends Canonical,
20
21
  >(
21
22
  family: AtomIO.RegularAtomFamilyToken<J, K>,
22
23
  index: AtomIO.ReadableToken<Iterable<K>>,
@@ -8,7 +8,7 @@ import {
8
8
  IMPLICIT,
9
9
  subscribeToState,
10
10
  } from "atom.io/internal"
11
- import type { Json } from "atom.io/json"
11
+ import type { Canonical, Json } from "atom.io/json"
12
12
  import { stringifyJson } from "atom.io/json"
13
13
 
14
14
  import type { ServerConfig } from "."
@@ -23,7 +23,7 @@ export function realtimeMutableFamilyProvider({
23
23
  return function mutableFamilyProvider<
24
24
  T extends Transceiver<any>,
25
25
  J extends Json.Serializable,
26
- K extends Json.Serializable,
26
+ K extends Canonical,
27
27
  >(
28
28
  family: AtomIO.MutableAtomFamilyToken<T, J, K>,
29
29
  index: AtomIO.ReadableToken<Iterable<K>>,
@@ -1,5 +1,5 @@
1
- import { recordToEntries } from '../../dist/chunk-MR5NETHW.js';
2
- import { __spreadProps, __spreadValues } from '../../dist/chunk-S4N6XNPH.js';
1
+ import { recordToEntries } from '../../dist/chunk-IW6WYRS7.js';
2
+ import '../../dist/chunk-XWL6SNVU.js';
3
3
  import * as http from 'http';
4
4
  import { render, prettyDOM } from '@testing-library/react';
5
5
  import * as AtomIO from 'atom.io';
@@ -126,7 +126,7 @@ var multiClient = (options) => {
126
126
  const clients = recordToEntries(options.clients).reduce(
127
127
  (clientRecord, [name, client]) => {
128
128
  clientRecord[name] = setupRealtimeTestClient(
129
- __spreadProps(__spreadValues({}, options), { client }),
129
+ { ...options, client },
130
130
  name,
131
131
  server.port
132
132
  );
@@ -2,14 +2,11 @@
2
2
  "name": "atom.io-realtime-testing",
3
3
  "type": "module",
4
4
  "private": true,
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.js",
5
+ "main": "dist/index.js",
7
6
  "types": "dist/index.d.ts",
8
7
  "exports": {
9
8
  ".": {
10
9
  "import": "./dist/index.js",
11
- "browser": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
10
  "types": "./dist/index.d.ts"
14
11
  }
15
12
  }