atom.io 0.18.1 → 0.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/data/dist/index.cjs +0 -2
  2. package/data/dist/index.js +2 -4
  3. package/dist/{chunk-JDUNWJFB.js → chunk-BWWVY5O5.js} +1 -3
  4. package/dist/{chunk-NYCVSXQB.js → chunk-CVBEVTM5.js} +0 -2
  5. package/dist/chunk-O47EQUM6.js +29 -0
  6. package/dist/{chunk-PZLG2HP3.js → chunk-U2IICNHQ.js} +0 -2
  7. package/dist/{chunk-XACXFU3B.js → chunk-VAE5OCKN.js} +0 -2
  8. package/dist/{chunk-NYTGCPHB.js → chunk-WX2NCOZR.js} +0 -2
  9. package/dist/{chunk-IZHOMSXA.js → chunk-YDOGCZ53.js} +0 -2
  10. package/dist/index.cjs +0 -2
  11. package/dist/index.js +1 -3
  12. package/internal/dist/index.cjs +46 -102
  13. package/internal/dist/index.d.ts +23 -23
  14. package/internal/dist/index.js +48 -104
  15. package/internal/src/families/create-regular-atom-family.ts +4 -4
  16. package/internal/src/get-state/get-from-store.ts +2 -5
  17. package/internal/src/mutable/create-mutable-atom-family.ts +4 -4
  18. package/internal/src/selector/register-selector.ts +3 -14
  19. package/internal/src/set-state/set-into-store.ts +2 -5
  20. package/internal/src/store/withdraw-new-family-member.ts +38 -28
  21. package/internal/src/store/withdraw.ts +20 -23
  22. package/internal/src/subscribe/subscribe-to-state.ts +2 -3
  23. package/internal/src/subscribe/subscribe-to-timeline.ts +0 -5
  24. package/internal/src/subscribe/subscribe-to-transaction.ts +0 -5
  25. package/internal/src/timeline/add-atom-to-timeline.ts +6 -15
  26. package/internal/src/timeline/create-timeline.ts +0 -27
  27. package/introspection/dist/index.cjs +0 -2
  28. package/introspection/dist/index.js +1 -3
  29. package/json/dist/index.cjs +0 -2
  30. package/json/dist/index.js +3 -5
  31. package/package.json +6 -5
  32. package/react/dist/index.cjs +2 -5
  33. package/react/dist/index.js +3 -6
  34. package/react/src/use-tl.ts +2 -2
  35. package/react-devtools/dist/index.cjs +1 -3
  36. package/react-devtools/dist/index.css +0 -1
  37. package/react-devtools/dist/index.js +4 -6
  38. package/realtime/dist/index.cjs +0 -2
  39. package/realtime/dist/index.js +1 -3
  40. package/realtime-client/dist/index.cjs +1 -3
  41. package/realtime-client/dist/index.js +15 -41
  42. package/realtime-react/dist/index.cjs +0 -2
  43. package/realtime-react/dist/index.js +2 -4
  44. package/realtime-server/dist/index.cjs +3 -5
  45. package/realtime-server/dist/index.js +4 -6
  46. package/realtime-server/src/ipc-sockets/parent-socket.ts +4 -3
  47. package/realtime-testing/dist/index.cjs +43 -7
  48. package/realtime-testing/dist/index.js +6 -9
  49. package/realtime-testing/src/setup-realtime-test.tsx +3 -5
  50. package/transceivers/set-rtx/dist/index.cjs +0 -2
  51. package/transceivers/set-rtx/dist/index.js +1 -3
  52. package/data/dist/index.cjs.map +0 -1
  53. package/data/dist/index.js.map +0 -1
  54. package/dist/chunk-IZHOMSXA.js.map +0 -1
  55. package/dist/chunk-JDUNWJFB.js.map +0 -1
  56. package/dist/chunk-NYCVSXQB.js.map +0 -1
  57. package/dist/chunk-NYTGCPHB.js.map +0 -1
  58. package/dist/chunk-PZLG2HP3.js.map +0 -1
  59. package/dist/chunk-XACXFU3B.js.map +0 -1
  60. package/dist/index.cjs.map +0 -1
  61. package/dist/index.js.map +0 -1
  62. package/internal/dist/index.cjs.map +0 -1
  63. package/internal/dist/index.js.map +0 -1
  64. package/introspection/dist/index.cjs.map +0 -1
  65. package/introspection/dist/index.js.map +0 -1
  66. package/json/dist/index.cjs.map +0 -1
  67. package/json/dist/index.js.map +0 -1
  68. package/react/dist/index.cjs.map +0 -1
  69. package/react/dist/index.js.map +0 -1
  70. package/react-devtools/dist/index.cjs.map +0 -1
  71. package/react-devtools/dist/index.css.map +0 -1
  72. package/react-devtools/dist/index.js.map +0 -1
  73. package/realtime/dist/index.cjs.map +0 -1
  74. package/realtime/dist/index.js.map +0 -1
  75. package/realtime-client/dist/index.cjs.map +0 -1
  76. package/realtime-client/dist/index.js.map +0 -1
  77. package/realtime-react/dist/index.cjs.map +0 -1
  78. package/realtime-react/dist/index.js.map +0 -1
  79. package/realtime-server/dist/index.cjs.map +0 -1
  80. package/realtime-server/dist/index.js.map +0 -1
  81. package/realtime-testing/dist/index.cjs.map +0 -1
  82. package/realtime-testing/dist/index.js.map +0 -1
  83. package/transceivers/set-rtx/dist/index.cjs.map +0 -1
  84. package/transceivers/set-rtx/dist/index.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { AtomToken, TransactionUpdate, ƒn } from "atom.io"
1
+ import type { AtomToken, TransactionToken, TransactionUpdate, ƒn } from "atom.io"
2
2
  import type { TimelineUpdate } from "atom.io"
3
3
 
4
4
  import { newest } from "../lineage"
@@ -17,16 +17,11 @@ export const addAtomToTimeline = (
17
17
  store: Store,
18
18
  ): void => {
19
19
  let maybeAtom = withdraw(atomToken, store)
20
- if (maybeAtom?.type === `mutable_atom`) {
20
+ if (maybeAtom.type === `mutable_atom`) {
21
21
  const updateToken = getUpdateToken(maybeAtom)
22
22
  maybeAtom = withdraw(updateToken, store)
23
23
  }
24
24
  const atom = maybeAtom
25
- if (atom === undefined) {
26
- throw new Error(
27
- `Cannot subscribe to atom "${atomToken.key}" because it has not been initialized in store "${store.config.name}"`,
28
- )
29
- }
30
25
  store.timelineAtoms.set({ atomKey: atom.key, timelineKey: tl.key })
31
26
 
32
27
  atom.subject.subscribe(`timeline`, (update) => {
@@ -70,15 +65,11 @@ export const addAtomToTimeline = (
70
65
  }
71
66
  }
72
67
  if (currentTransactionKey) {
73
- const currentTransaction = withdraw(
74
- { key: currentTransactionKey, type: `transaction` },
75
- store,
76
- )
77
- if (currentTransaction === undefined) {
78
- throw new Error(
79
- `Transaction "${currentTransactionKey}" not found in store "${store.config.name}". This is surprising, because we are in the application phase of "${currentTransactionKey}".`,
80
- )
68
+ const txToken: TransactionToken<any> = {
69
+ key: currentTransactionKey,
70
+ type: `transaction`,
81
71
  }
72
+ const currentTransaction = withdraw(txToken, store)
82
73
  if (tl.transactionKey !== currentTransactionKey) {
83
74
  if (tl.transactionKey) {
84
75
  store.logger.error(
@@ -89,15 +89,6 @@ export function createTimeline<ManagedAtom extends TimelineManageable>(
89
89
  ) {
90
90
  const familyToken: AtomFamilyToken<any> = tokenOrFamily
91
91
  const family = withdraw(familyToken, store)
92
- if (family === undefined) {
93
- store.logger.error(
94
- `❌`,
95
- `timeline`,
96
- options.key,
97
- `Failed to add family "${familyToken.key}" because it does not exist in the store`,
98
- )
99
- continue
100
- }
101
92
  const familyKey = family.key
102
93
  target.timelineAtoms.set({ atomKey: familyKey, timelineKey })
103
94
  family.subject.subscribe(`timeline:${options.key}`, (token) => {
@@ -110,26 +101,8 @@ export function createTimeline<ManagedAtom extends TimelineManageable>(
110
101
  }
111
102
  } else {
112
103
  let atom = withdraw(tokenOrFamily, store)
113
- if (atom === undefined) {
114
- store.logger.error(
115
- `❌`,
116
- `timeline`,
117
- options.key,
118
- `Failed to add atom "${atomKey}" because it does not exist in the store`,
119
- )
120
- continue
121
- }
122
104
  if (isMutable(atom)) {
123
105
  const updateAtom = withdraw(getUpdateToken(atom), store)
124
- if (updateAtom === undefined) {
125
- store.logger.error(
126
- `❌`,
127
- `timeline`,
128
- options.key,
129
- `Failed to add update atom "${atomKey}" because it does not exist in the store`,
130
- )
131
- continue
132
- }
133
106
  atom = updateAtom
134
107
  atomKey = atom.key
135
108
  }
@@ -331,5 +331,3 @@ var attachIntrospectionStates = (store = Internal__namespace.IMPLICIT.STORE) =>
331
331
  };
332
332
 
333
333
  exports.attachIntrospectionStates = attachIntrospectionStates;
334
- //# sourceMappingURL=out.js.map
335
- //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { __spreadValues, __spreadProps } from '../../dist/chunk-PZLG2HP3.js';
1
+ import { __spreadValues, __spreadProps } from '../../dist/chunk-U2IICNHQ.js';
2
2
  import * as Internal from 'atom.io/internal';
3
3
  import { createRegularAtom, newest, createStandaloneSelector, IMPLICIT, createRegularAtomFamily, Subject, createSelectorFamily } from 'atom.io/internal';
4
4
 
@@ -292,5 +292,3 @@ var attachIntrospectionStates = (store = Internal.IMPLICIT.STORE) => {
292
292
  };
293
293
 
294
294
  export { attachIntrospectionStates };
295
- //# sourceMappingURL=out.js.map
296
- //# sourceMappingURL=index.js.map
@@ -86,5 +86,3 @@ exports.selectJson = selectJson;
86
86
  exports.selectJsonFamily = selectJsonFamily;
87
87
  exports.stringSetJsonInterface = stringSetJsonInterface;
88
88
  exports.stringifyJson = stringifyJson;
89
- //# sourceMappingURL=out.js.map
90
- //# sourceMappingURL=index.cjs.map
@@ -1,6 +1,6 @@
1
- import { parseJson } from '../../dist/chunk-XACXFU3B.js';
2
- export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, stringSetJsonInterface, stringifyJson } from '../../dist/chunk-XACXFU3B.js';
3
- import '../../dist/chunk-PZLG2HP3.js';
1
+ import { parseJson } from '../../dist/chunk-VAE5OCKN.js';
2
+ export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, stringSetJsonInterface, stringifyJson } from '../../dist/chunk-VAE5OCKN.js';
3
+ import '../../dist/chunk-U2IICNHQ.js';
4
4
  import { createStandaloneSelector, IMPLICIT, createSelectorFamily } from 'atom.io/internal';
5
5
 
6
6
  var selectJson = (atom, transform, store = IMPLICIT.STORE) => {
@@ -34,5 +34,3 @@ function selectJsonFamily(atomFamily, transform, store = IMPLICIT.STORE) {
34
34
  }
35
35
 
36
36
  export { selectJson, selectJsonFamily };
37
- //# sourceMappingURL=out.js.map
38
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -39,6 +39,7 @@
39
39
  "test": "vitest",
40
40
  "test:coverage": "vitest run --coverage",
41
41
  "test:once": "bun run test:manifest && cross-env IMPORT=dist vitest run",
42
+ "test:once:public": "cross-env IMPORT=dist vitest run public",
42
43
  "test:manifest": "tsx __scripts__/manifest-test.node"
43
44
  },
44
45
  "peerDependencies": {
@@ -77,7 +78,7 @@
77
78
  "@testing-library/react": "14.2.1",
78
79
  "@types/http-proxy": "1.17.14",
79
80
  "@types/npmlog": "7.0.0",
80
- "@types/react": "18.2.60",
81
+ "@types/react": "18.2.61",
81
82
  "@types/tmp": "0.2.6",
82
83
  "@vitest/coverage-v8": "1.3.1",
83
84
  "@vitest/ui": "1.3.1",
@@ -85,7 +86,7 @@
85
86
  "drizzle-kit": "0.20.14",
86
87
  "drizzle-orm": "0.29.4",
87
88
  "eslint": "8.57.0",
88
- "framer-motion": "11.0.6",
89
+ "framer-motion": "11.0.8",
89
90
  "happy-dom": "13.6.2",
90
91
  "http-proxy": "1.18.1",
91
92
  "npmlog": "7.0.1",
@@ -93,10 +94,10 @@
93
94
  "preact": "10.19.6",
94
95
  "react": "18.2.0",
95
96
  "react-dom": "18.2.0",
96
- "react-router-dom": "6.22.1",
97
+ "react-router-dom": "6.22.2",
97
98
  "socket.io": "4.7.4",
98
99
  "socket.io-client": "4.7.4",
99
- "tmp": "0.2.1",
100
+ "tmp": "0.2.3",
100
101
  "tsup": "8.0.2",
101
102
  "typescript": "5.3.3",
102
103
  "vite": "5.1.4",
@@ -61,10 +61,9 @@ function useTL(token) {
61
61
  const timeline = internal.withdraw(token, store);
62
62
  const tokenRef = React5__namespace.useRef(token);
63
63
  const rebuildMeta = () => {
64
- var _a, _b;
65
64
  return {
66
- at: (_a = timeline == null ? void 0 : timeline.at) != null ? _a : NaN,
67
- length: (_b = timeline == null ? void 0 : timeline.history.length) != null ? _b : NaN,
65
+ at: timeline.at,
66
+ length: timeline.history.length,
68
67
  undo: () => atom_io.undo(token),
69
68
  redo: () => atom_io.redo(token)
70
69
  };
@@ -90,5 +89,3 @@ exports.useI = useI;
90
89
  exports.useJSON = useJSON;
91
90
  exports.useO = useO;
92
91
  exports.useTL = useTL;
93
- //# sourceMappingURL=out.js.map
94
- //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import '../../dist/chunk-PZLG2HP3.js';
1
+ import '../../dist/chunk-U2IICNHQ.js';
2
2
  import { IMPLICIT, findInStore, setIntoStore, subscribeToState, getFromStore, getJsonToken, withdraw, subscribeToTimeline } from 'atom.io/internal';
3
3
  import * as React5 from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
@@ -39,10 +39,9 @@ function useTL(token) {
39
39
  const timeline = withdraw(token, store);
40
40
  const tokenRef = React5.useRef(token);
41
41
  const rebuildMeta = () => {
42
- var _a, _b;
43
42
  return {
44
- at: (_a = timeline == null ? void 0 : timeline.at) != null ? _a : NaN,
45
- length: (_b = timeline == null ? void 0 : timeline.history.length) != null ? _b : NaN,
43
+ at: timeline.at,
44
+ length: timeline.history.length,
46
45
  undo: () => undo(token),
47
46
  redo: () => redo(token)
48
47
  };
@@ -63,5 +62,3 @@ function useTL(token) {
63
62
  }
64
63
 
65
64
  export { StoreContext, StoreProvider, useI, useJSON, useO, useTL };
66
- //# sourceMappingURL=out.js.map
67
- //# sourceMappingURL=index.js.map
@@ -19,8 +19,8 @@ export function useTL(token: TimelineToken<any>): TimelineMeta {
19
19
  const tokenRef = React.useRef(token)
20
20
  const rebuildMeta = () => {
21
21
  return {
22
- at: timeline?.at ?? NaN,
23
- length: timeline?.history.length ?? NaN,
22
+ at: timeline.at,
23
+ length: timeline.history.length,
24
24
  undo: () => undo(token),
25
25
  redo: () => redo(token),
26
26
  }
@@ -525,7 +525,7 @@ var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, on
525
525
  storage.setItem(key, stringify(newValue));
526
526
  });
527
527
  };
528
- var lazyLocalStorageEffect = persistAtom(localStorage)(JSON);
528
+ var lazyLocalStorageEffect = persistAtom(window.localStorage)(JSON);
529
529
  var OpenClose = ({ isOpen, setIsOpen, disabled }) => {
530
530
  return /* @__PURE__ */ jsxRuntime.jsx(
531
531
  "button",
@@ -2852,5 +2852,3 @@ exports.primitiveRefinery = primitiveRefinery;
2852
2852
  exports.selectorIndex = selectorIndex;
2853
2853
  exports.timelineIndex = timelineIndex;
2854
2854
  exports.transactionIndex = transactionIndex;
2855
- //# sourceMappingURL=out.js.map
2856
- //# sourceMappingURL=index.cjs.map
@@ -326,4 +326,3 @@ main.atom_io_devtools {
326
326
  }
327
327
  }
328
328
  }
329
- /*# sourceMappingURL=index.css.map */
@@ -1,7 +1,7 @@
1
- import { lazyLocalStorageEffect } from '../../dist/chunk-JDUNWJFB.js';
2
- import { treeShake, isEmptyArray, pipe, ifDefined, isArray, isRecord, doesExtend, isModifier, isPlainObject, raiseError, sprawl, recordToEntries, fallback, hasExactProperties, isEmptyObject, doNothing, isOneOf, map, entriesToRecord, comprises, addTo, become, mapObject, delve } from '../../dist/chunk-NYCVSXQB.js';
3
- import { JSON_TYPE_NAMES, isString, isNumber, isBoolean, stringifyJson, JSON_DEFAULTS } from '../../dist/chunk-XACXFU3B.js';
4
- import { __spreadProps, __spreadValues, __objRest, __restKey } from '../../dist/chunk-PZLG2HP3.js';
1
+ import { treeShake, isEmptyArray, pipe, ifDefined, isArray, isRecord, doesExtend, isModifier, isPlainObject, raiseError, sprawl, recordToEntries, fallback, hasExactProperties, isEmptyObject, doNothing, isOneOf, map, entriesToRecord, comprises, addTo, become, mapObject, delve } from '../../dist/chunk-CVBEVTM5.js';
2
+ import { lazyLocalStorageEffect } from '../../dist/chunk-BWWVY5O5.js';
3
+ import { JSON_TYPE_NAMES, isString, isNumber, isBoolean, stringifyJson, JSON_DEFAULTS } from '../../dist/chunk-VAE5OCKN.js';
4
+ import { __spreadProps, __spreadValues, __objRest, __restKey } from '../../dist/chunk-U2IICNHQ.js';
5
5
  import { selectorFamily, atom, atomFamily, findState, undo, redo, getState } from 'atom.io';
6
6
  import { attachIntrospectionStates } from 'atom.io/introspection';
7
7
  import { useI, useO } from 'atom.io/react';
@@ -2566,5 +2566,3 @@ var prettyJson = new Differ(primitiveRefinery, jsonTreeRefinery, {
2566
2566
  });
2567
2567
 
2568
2568
  export { AtomIODevtools, atomIndex, devtoolsAreOpenState, devtoolsViewOptionsState, devtoolsViewSelectionState, findTimelineState, findTransactionLogState, findViewIsOpenState, jsonTreeRefinery, prettyJson, primitiveRefinery, selectorIndex, timelineIndex, transactionIndex };
2569
- //# sourceMappingURL=out.js.map
2570
- //# sourceMappingURL=index.js.map
@@ -116,5 +116,3 @@ exports.roomIndex = roomIndex;
116
116
  exports.usersInMyRoomView = usersInMyRoomView;
117
117
  exports.usersInRooms = usersInRooms;
118
118
  exports.usersInThisRoomIndex = usersInThisRoomIndex;
119
- //# sourceMappingURL=out.js.map
120
- //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import '../../dist/chunk-PZLG2HP3.js';
1
+ import '../../dist/chunk-U2IICNHQ.js';
2
2
  import { assignTransactionToContinuity, IMPLICIT, setEpochNumberOfContinuity, getUpdateToken } from 'atom.io/internal';
3
3
  import { atom, selectorFamily } from 'atom.io';
4
4
  import { join } from 'atom.io/data';
@@ -107,5 +107,3 @@ var usersInMyRoomView = selectorFamily({
107
107
  });
108
108
 
109
109
  export { DEFAULT_USER_IN_ROOM_META, InvariantMap, SyncGroup, continuity, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex };
110
- //# sourceMappingURL=out.js.map
111
- //# sourceMappingURL=index.js.map
@@ -191,7 +191,7 @@ var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, on
191
191
  storage.setItem(key, stringify(newValue));
192
192
  });
193
193
  };
194
- var lazyLocalStorageEffect = persistAtom(localStorage)(JSON);
194
+ var lazyLocalStorageEffect = persistAtom(window.localStorage)(JSON);
195
195
 
196
196
  // realtime-client/src/realtime-client-stores/client-main-store.ts
197
197
  var myIdState__INTERNAL = AtomIO__namespace.atom({
@@ -569,5 +569,3 @@ exports.pullSelectorFamilyMember = pullSelectorFamilyMember;
569
569
  exports.pushState = pushState;
570
570
  exports.serverAction = serverAction;
571
571
  exports.syncContinuity = syncContinuity;
572
- //# sourceMappingURL=out.js.map
573
- //# sourceMappingURL=index.cjs.map
@@ -1,10 +1,10 @@
1
- export { syncContinuity } from '../../dist/chunk-IZHOMSXA.js';
2
- import { lazyLocalStorageEffect } from '../../dist/chunk-JDUNWJFB.js';
3
- import '../../dist/chunk-PZLG2HP3.js';
1
+ export { syncContinuity } from '../../dist/chunk-YDOGCZ53.js';
2
+ export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue } from '../../dist/chunk-O47EQUM6.js';
3
+ import '../../dist/chunk-BWWVY5O5.js';
4
+ import '../../dist/chunk-U2IICNHQ.js';
4
5
  import * as Internal from 'atom.io/internal';
5
6
  import { setIntoStore, getJsonToken, getUpdateToken } from 'atom.io/internal';
6
7
  import { parseJson } from 'atom.io/json';
7
- import * as AtomIO from 'atom.io';
8
8
 
9
9
  function pullAtom(token, socket, store) {
10
10
  const setServedValue = (data) => {
@@ -85,17 +85,17 @@ function pullSelector(token, socket, store) {
85
85
  const unsubscribes = [];
86
86
  if (atomKeys) {
87
87
  for (const atomKey of atomKeys) {
88
- const atom3 = store.atoms.get(atomKey);
89
- if (!atom3) {
88
+ const atom = store.atoms.get(atomKey);
89
+ if (!atom) {
90
90
  continue;
91
91
  }
92
- switch (atom3.type) {
92
+ switch (atom.type) {
93
93
  case `atom`: {
94
- unsubscribes.push(pullAtom(atom3, socket, store));
94
+ unsubscribes.push(pullAtom(atom, socket, store));
95
95
  break;
96
96
  }
97
97
  case `mutable_atom`: {
98
- unsubscribes.push(pullMutableAtom(atom3, socket, store));
98
+ unsubscribes.push(pullMutableAtom(atom, socket, store));
99
99
  break;
100
100
  }
101
101
  }
@@ -119,17 +119,17 @@ function pullSelectorFamilyMember(token, socket, store) {
119
119
  const unsubscribes = [];
120
120
  if (atomKeys) {
121
121
  for (const atomKey of atomKeys) {
122
- const atom3 = store.atoms.get(atomKey);
123
- if (!atom3) {
122
+ const atom = store.atoms.get(atomKey);
123
+ if (!atom) {
124
124
  continue;
125
125
  }
126
- switch (atom3.type) {
126
+ switch (atom.type) {
127
127
  case `atom`: {
128
- unsubscribes.push(pullAtomFamilyMember(atom3, socket, store));
128
+ unsubscribes.push(pullAtomFamilyMember(atom, socket, store));
129
129
  break;
130
130
  }
131
131
  case `mutable_atom`: {
132
- unsubscribes.push(pullMutableAtomFamilyMember(atom3, socket, store));
132
+ unsubscribes.push(pullMutableAtomFamilyMember(atom, socket, store));
133
133
  break;
134
134
  }
135
135
  }
@@ -156,30 +156,6 @@ function pushState(token, socket, store) {
156
156
  socket.emit(`unclaim:${token.key}`);
157
157
  };
158
158
  }
159
- var myIdState__INTERNAL = AtomIO.atom({
160
- key: `mySocketId__INTERNAL`,
161
- default: void 0
162
- });
163
- var myIdState = AtomIO.selector({
164
- key: `mySocketId`,
165
- get: ({ get }) => get(myIdState__INTERNAL)
166
- });
167
- var usernameEffects = typeof window === `undefined` ? [] : [lazyLocalStorageEffect(`myUsername`)];
168
- var myUsernameState = AtomIO.atom({
169
- key: `myUsername`,
170
- default: null,
171
- effects: usernameEffects
172
- });
173
- var optimisticUpdateQueue = AtomIO.atom({
174
- key: `updateQueue`,
175
- default: []
176
- });
177
- var confirmedUpdateQueue = AtomIO.atom(
178
- {
179
- key: `serverConfirmedUpdateQueue`,
180
- default: []
181
- }
182
- );
183
159
  function serverAction(token, socket, store) {
184
160
  const unsubscribeFromLocalUpdates = Internal.subscribeToTransaction(
185
161
  token,
@@ -194,6 +170,4 @@ function serverAction(token, socket, store) {
194
170
  };
195
171
  }
196
172
 
197
- export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue, pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, serverAction };
198
- //# sourceMappingURL=out.js.map
199
- //# sourceMappingURL=index.js.map
173
+ export { pullAtom, pullAtomFamilyMember, pullMutableAtom, pullMutableAtomFamilyMember, pullSelector, pullSelectorFamilyMember, pushState, serverAction };
@@ -512,5 +512,3 @@ exports.usePullSelectorFamilyMember = usePullSelectorFamilyMember;
512
512
  exports.usePush = usePush;
513
513
  exports.useServerAction = useServerAction;
514
514
  exports.useSyncContinuity = useSyncContinuity;
515
- //# sourceMappingURL=out.js.map
516
- //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,5 @@
1
- import { syncContinuity } from '../../dist/chunk-IZHOMSXA.js';
2
- import '../../dist/chunk-PZLG2HP3.js';
1
+ import { syncContinuity } from '../../dist/chunk-YDOGCZ53.js';
2
+ import '../../dist/chunk-U2IICNHQ.js';
3
3
  import { useI, StoreContext, useO } from 'atom.io/react';
4
4
  import * as RTC from 'atom.io/realtime-client';
5
5
  import * as React from 'react';
@@ -155,5 +155,3 @@ function useSyncContinuity(token) {
155
155
  }
156
156
 
157
157
  export { RealtimeContext, RealtimeProvider, usePullAtom, usePullAtomFamilyMember, usePullMutable, usePullMutableAtomFamilyMember, usePullSelector, usePullSelectorFamilyMember, usePush, useServerAction, useSyncContinuity };
158
- //# sourceMappingURL=out.js.map
159
- //# sourceMappingURL=index.js.map
@@ -271,11 +271,11 @@ var ParentSocket = class extends CustomSocket {
271
271
  }
272
272
  );
273
273
  this.on(`exit`, () => {
274
+ this.logger.info(`\u{1F525}`, this.id, `received "exit"`);
274
275
  process.exit(0);
275
276
  });
276
- process.on(`exit`, () => {
277
- this.logger.info(`\u{1F525}`, this.id, `exited`);
278
- process.exit(0);
277
+ process.on(`exit`, (code) => {
278
+ this.logger.info(`\u{1F525}`, this.id, `exited with code ${code}`);
279
279
  });
280
280
  process.on(`end`, () => {
281
281
  this.logger.info(`\u{1F525}`, this.id, `ended`);
@@ -1008,5 +1008,3 @@ exports.socketIndex = socketIndex;
1008
1008
  exports.userIndex = userIndex;
1009
1009
  exports.userUnacknowledgedQueues = userUnacknowledgedQueues;
1010
1010
  exports.usersOfSockets = usersOfSockets;
1011
- //# sourceMappingURL=out.js.map
1012
- //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { __spreadProps, __spreadValues } from '../../dist/chunk-PZLG2HP3.js';
1
+ import { __spreadProps, __spreadValues } from '../../dist/chunk-U2IICNHQ.js';
2
2
  import { parseJson, stringifyJson } from 'atom.io/json';
3
3
  import { getUpdateToken, IMPLICIT, Subject, findInStore, getFromStore, subscribeToState, getJsonToken, isRootStore, subscribeToTransaction, actUponStore, setIntoStore } from 'atom.io/internal';
4
4
  import { SetRTX } from 'atom.io/transceivers/set-rtx';
@@ -231,11 +231,11 @@ var ParentSocket = class extends CustomSocket {
231
231
  }
232
232
  );
233
233
  this.on(`exit`, () => {
234
+ this.logger.info(`\u{1F525}`, this.id, `received "exit"`);
234
235
  process.exit(0);
235
236
  });
236
- process.on(`exit`, () => {
237
- this.logger.info(`\u{1F525}`, this.id, `exited`);
238
- process.exit(0);
237
+ process.on(`exit`, (code) => {
238
+ this.logger.info(`\u{1F525}`, this.id, `exited with code ${code}`);
239
239
  });
240
240
  process.on(`end`, () => {
241
241
  this.logger.info(`\u{1F525}`, this.id, `ended`);
@@ -944,5 +944,3 @@ function realtimeActionReceiver({
944
944
  }
945
945
 
946
946
  export { ChildSocket, CustomSocket, ParentSocket, SubjectSocket, actionOcclusionAtoms, createRoomTX, destroyRoomTX, joinRoomTX, leaveRoomTX, realtimeActionReceiver, realtimeAtomFamilyProvider, realtimeContinuitySynchronizer, realtimeMutableFamilyProvider, realtimeMutableProvider, realtimeStateProvider, realtimeStateReceiver, realtimeStateSynchronizer, redactTransactionUpdateContent, roomArgumentsAtoms, roomSelectors, socketAtoms, socketIndex, userIndex, userUnacknowledgedQueues, usersOfSockets };
947
- //# sourceMappingURL=out.js.map
948
- //# sourceMappingURL=index.js.map
@@ -85,6 +85,7 @@ export class ParentSocket<
85
85
  this.process.stdin.resume()
86
86
  this.relays = new Map()
87
87
  this.relayServices = []
88
+ // this.logger.info(`🔗`, `uplink`, process.pid)
88
89
 
89
90
  this.process.stdin.on(
90
91
  `data`,
@@ -118,11 +119,11 @@ export class ParentSocket<
118
119
  )
119
120
 
120
121
  this.on(`exit`, () => {
122
+ this.logger.info(`🔥`, this.id, `received "exit"`)
121
123
  process.exit(0)
122
124
  })
123
- process.on(`exit`, () => {
124
- this.logger.info(`🔥`, this.id, `exited`)
125
- process.exit(0)
125
+ process.on(`exit`, (code) => {
126
+ this.logger.info(`🔥`, this.id, `exited with code ${code}`)
126
127
  })
127
128
  process.on(`end`, () => {
128
129
  this.logger.info(`🔥`, this.id, `ended`)
@@ -62,6 +62,47 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
62
62
 
63
63
  // ../anvl/src/object/entries.ts
64
64
  var recordToEntries = (obj) => Object.entries(obj);
65
+
66
+ // __unstable__/web-effects/src/storage.ts
67
+ var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, onSet }) => {
68
+ const savedValue = storage.getItem(key);
69
+ if (savedValue != null)
70
+ setSelf(parse(savedValue));
71
+ onSet(({ newValue }) => {
72
+ if (newValue == null) {
73
+ storage.removeItem(key);
74
+ return;
75
+ }
76
+ storage.setItem(key, stringify(newValue));
77
+ });
78
+ };
79
+ var lazyLocalStorageEffect = persistAtom(window.localStorage)(JSON);
80
+
81
+ // realtime-client/src/realtime-client-stores/client-main-store.ts
82
+ var myIdState__INTERNAL = AtomIO__namespace.atom({
83
+ key: `mySocketId__INTERNAL`,
84
+ default: void 0
85
+ });
86
+ AtomIO__namespace.selector({
87
+ key: `mySocketId`,
88
+ get: ({ get }) => get(myIdState__INTERNAL)
89
+ });
90
+ var usernameEffects = typeof window === `undefined` ? [] : [lazyLocalStorageEffect(`myUsername`)];
91
+ var myUsernameState = AtomIO__namespace.atom({
92
+ key: `myUsername`,
93
+ default: null,
94
+ effects: usernameEffects
95
+ });
96
+ AtomIO__namespace.atom({
97
+ key: `updateQueue`,
98
+ default: []
99
+ });
100
+ AtomIO__namespace.atom(
101
+ {
102
+ key: `serverConfirmedUpdateQueue`,
103
+ default: []
104
+ }
105
+ );
65
106
  var testNumber = 0;
66
107
  var setupRealtimeTestServer = (options) => {
67
108
  ++testNumber;
@@ -121,6 +162,7 @@ var setupRealtimeTestClient = (options, name, port) => {
121
162
  silo.store.valueMap.set(key, [...value]);
122
163
  }
123
164
  }
165
+ silo.setState(myUsernameState, `${name}-${testNumber}`);
124
166
  const { document } = new Happy__namespace.Window();
125
167
  document.body.innerHTML = `<div id="app"></div>`;
126
168
  const renderResult = react.render(
@@ -148,11 +190,7 @@ var setupRealtimeTestClient = (options, name, port) => {
148
190
  };
149
191
  var singleClient = (options) => {
150
192
  const server = setupRealtimeTestServer(options);
151
- const client = setupRealtimeTestClient(
152
- options,
153
- `CLIENT-${testNumber}`,
154
- server.port
155
- );
193
+ const client = setupRealtimeTestClient(options, `CLIENT`, server.port);
156
194
  return {
157
195
  client,
158
196
  server,
@@ -191,5 +229,3 @@ exports.multiClient = multiClient;
191
229
  exports.setupRealtimeTestClient = setupRealtimeTestClient;
192
230
  exports.setupRealtimeTestServer = setupRealtimeTestServer;
193
231
  exports.singleClient = singleClient;
194
- //# sourceMappingURL=out.js.map
195
- //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,7 @@
1
- import { recordToEntries } from '../../dist/chunk-NYCVSXQB.js';
2
- import { __spreadProps, __spreadValues } from '../../dist/chunk-PZLG2HP3.js';
1
+ import { myUsernameState } from '../../dist/chunk-O47EQUM6.js';
2
+ import { recordToEntries } from '../../dist/chunk-CVBEVTM5.js';
3
+ import '../../dist/chunk-BWWVY5O5.js';
4
+ import { __spreadProps, __spreadValues } from '../../dist/chunk-U2IICNHQ.js';
3
5
  import * as http from 'http';
4
6
  import { render, prettyDOM } from '@testing-library/react';
5
7
  import * as AtomIO from 'atom.io';
@@ -72,6 +74,7 @@ var setupRealtimeTestClient = (options, name, port) => {
72
74
  silo.store.valueMap.set(key, [...value]);
73
75
  }
74
76
  }
77
+ silo.setState(myUsernameState, `${name}-${testNumber}`);
75
78
  const { document } = new Happy.Window();
76
79
  document.body.innerHTML = `<div id="app"></div>`;
77
80
  const renderResult = render(
@@ -99,11 +102,7 @@ var setupRealtimeTestClient = (options, name, port) => {
99
102
  };
100
103
  var singleClient = (options) => {
101
104
  const server = setupRealtimeTestServer(options);
102
- const client = setupRealtimeTestClient(
103
- options,
104
- `CLIENT-${testNumber}`,
105
- server.port
106
- );
105
+ const client = setupRealtimeTestClient(options, `CLIENT`, server.port);
107
106
  return {
108
107
  client,
109
108
  server,
@@ -139,5 +138,3 @@ var multiClient = (options) => {
139
138
  };
140
139
 
141
140
  export { multiClient, setupRealtimeTestClient, setupRealtimeTestServer, singleClient };
142
- //# sourceMappingURL=out.js.map
143
- //# sourceMappingURL=index.js.map
@@ -21,6 +21,7 @@ import type { Socket as ClientSocket } from "socket.io-client"
21
21
  import { io } from "socket.io-client"
22
22
 
23
23
  import { recordToEntries } from "~/packages/anvl/src/object"
24
+ import { myUsernameState } from "../../realtime-client/src/realtime-client-stores"
24
25
 
25
26
  let testNumber = 0
26
27
 
@@ -137,6 +138,7 @@ export const setupRealtimeTestClient = (
137
138
  silo.store.valueMap.set(key, [...value])
138
139
  }
139
140
  }
141
+ silo.setState(myUsernameState, `${name}-${testNumber}`)
140
142
 
141
143
  const { document } = new Happy.Window()
142
144
  document.body.innerHTML = `<div id="app"></div>`
@@ -175,11 +177,7 @@ export const singleClient = (
175
177
  options: TestSetupOptions__SingleClient,
176
178
  ): RealtimeTestAPI__SingleClient => {
177
179
  const server = setupRealtimeTestServer(options)
178
- const client = setupRealtimeTestClient(
179
- options,
180
- `CLIENT-${testNumber}`,
181
- server.port,
182
- )
180
+ const client = setupRealtimeTestClient(options, `CLIENT`, server.port)
183
181
 
184
182
  return {
185
183
  client,
@@ -215,5 +215,3 @@ var SetRTX = class _SetRTX extends Set {
215
215
  };
216
216
 
217
217
  exports.SetRTX = SetRTX;
218
- //# sourceMappingURL=out.js.map
219
- //# sourceMappingURL=index.cjs.map