atom.io 0.14.4 → 0.14.6

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 (91) hide show
  1. package/data/dist/index.cjs +47 -1416
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +16 -317
  4. package/data/dist/index.d.ts +16 -317
  5. package/data/dist/index.js +4 -6
  6. package/data/dist/index.js.map +1 -1
  7. package/dist/chunk-NYTGCPHB.js +261 -0
  8. package/dist/chunk-NYTGCPHB.js.map +1 -0
  9. package/dist/chunk-PZLG2HP3.js +36 -0
  10. package/dist/chunk-PZLG2HP3.js.map +1 -0
  11. package/dist/chunk-XACXFU3B.js +46 -0
  12. package/dist/chunk-XACXFU3B.js.map +1 -0
  13. package/dist/index.cjs +55 -2330
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +21 -269
  16. package/dist/index.d.ts +21 -269
  17. package/dist/index.js +152 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/metafile-cjs.json +1 -1
  20. package/dist/metafile-esm.json +1 -1
  21. package/internal/dist/index.cjs +30 -159
  22. package/internal/dist/index.cjs.map +1 -1
  23. package/internal/dist/index.d.cts +28 -229
  24. package/internal/dist/index.d.ts +28 -229
  25. package/internal/dist/index.js +2027 -1
  26. package/internal/dist/index.js.map +1 -1
  27. package/introspection/dist/index.cjs +45 -1565
  28. package/introspection/dist/index.cjs.map +1 -1
  29. package/introspection/dist/index.d.cts +4 -376
  30. package/introspection/dist/index.d.ts +4 -376
  31. package/introspection/dist/index.js +298 -2
  32. package/introspection/dist/index.js.map +1 -1
  33. package/json/dist/index.cjs +5 -1502
  34. package/json/dist/index.cjs.map +1 -1
  35. package/json/dist/index.d.cts +7 -373
  36. package/json/dist/index.d.ts +7 -373
  37. package/json/dist/index.js +37 -1
  38. package/json/dist/index.js.map +1 -1
  39. package/package.json +1 -1
  40. package/react/dist/index.cjs +14 -1549
  41. package/react/dist/index.cjs.map +1 -1
  42. package/react/dist/index.d.cts +4 -377
  43. package/react/dist/index.d.ts +4 -377
  44. package/react/dist/index.js +62 -2
  45. package/react/dist/index.js.map +1 -1
  46. package/react-devtools/dist/index.cjs +135 -2153
  47. package/react-devtools/dist/index.cjs.map +1 -1
  48. package/react-devtools/dist/index.d.cts +24 -149
  49. package/react-devtools/dist/index.d.ts +24 -149
  50. package/react-devtools/dist/index.js +5 -3
  51. package/react-devtools/dist/index.js.map +1 -1
  52. package/realtime-client/dist/index.cjs +34 -1529
  53. package/realtime-client/dist/index.cjs.map +1 -1
  54. package/realtime-client/dist/index.d.cts +12 -384
  55. package/realtime-client/dist/index.d.ts +12 -384
  56. package/realtime-client/dist/index.js +165 -2
  57. package/realtime-client/dist/index.js.map +1 -1
  58. package/realtime-react/dist/index.cjs +35 -1727
  59. package/realtime-react/dist/index.cjs.map +1 -1
  60. package/realtime-react/dist/index.d.cts +9 -49
  61. package/realtime-react/dist/index.d.ts +9 -49
  62. package/realtime-react/dist/index.js +66 -4
  63. package/realtime-react/dist/index.js.map +1 -1
  64. package/realtime-server/dist/index.cjs +57 -1548
  65. package/realtime-server/dist/index.cjs.map +1 -1
  66. package/realtime-server/dist/index.d.cts +11 -394
  67. package/realtime-server/dist/index.d.ts +11 -394
  68. package/realtime-server/dist/index.js +21 -27
  69. package/realtime-server/dist/index.js.map +1 -1
  70. package/realtime-testing/dist/index.cjs +15 -2376
  71. package/realtime-testing/dist/index.cjs.map +1 -1
  72. package/realtime-testing/dist/index.d.cts +3 -489
  73. package/realtime-testing/dist/index.d.ts +3 -489
  74. package/realtime-testing/dist/index.js +10 -9
  75. package/realtime-testing/dist/index.js.map +1 -1
  76. package/transceivers/set-rtx/dist/index.cjs +9 -31
  77. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  78. package/transceivers/set-rtx/dist/index.d.cts +3 -29
  79. package/transceivers/set-rtx/dist/index.d.ts +3 -29
  80. package/transceivers/set-rtx/dist/index.js +3 -2
  81. package/transceivers/set-rtx/dist/index.js.map +1 -1
  82. package/dist/chunk-GMN5KH6A.js +0 -309
  83. package/dist/chunk-GMN5KH6A.js.map +0 -1
  84. package/dist/chunk-HQWWV67P.js +0 -62
  85. package/dist/chunk-HQWWV67P.js.map +0 -1
  86. package/dist/chunk-MK4OJD24.js +0 -67
  87. package/dist/chunk-MK4OJD24.js.map +0 -1
  88. package/dist/chunk-N7ADBQJG.js +0 -176
  89. package/dist/chunk-N7ADBQJG.js.map +0 -1
  90. package/dist/chunk-PURABO5G.js +0 -2581
  91. package/dist/chunk-PURABO5G.js.map +0 -1
@@ -1,67 +0,0 @@
1
- import { useI, StoreContext } from './chunk-HQWWV67P.js';
2
- import { myIdState__INTERNAL, pullState, pullFamilyMember, pullMutableState, pullMutableFamilyMember, pushState, synchronizeTransactionResults } from './chunk-N7ADBQJG.js';
3
- import { runTransaction } from './chunk-PURABO5G.js';
4
- import * as React6 from 'react';
5
- import { io } from 'socket.io-client';
6
- import { jsx } from 'react/jsx-runtime';
7
-
8
- var RealtimeContext = React6.createContext({
9
- socket: io()
10
- });
11
- var RealtimeProvider = ({ children, socket }) => {
12
- const setMyId = useI(myIdState__INTERNAL);
13
- React6.useEffect(() => {
14
- socket.on(`connect`, () => {
15
- setMyId(socket.id);
16
- });
17
- socket.on(`disconnect`, () => {
18
- setMyId(null);
19
- });
20
- }, [socket, setMyId]);
21
- return /* @__PURE__ */ jsx(RealtimeContext.Provider, { value: { socket }, children });
22
- };
23
- function usePull(token) {
24
- const { socket } = React6.useContext(RealtimeContext);
25
- const store = React6.useContext(StoreContext);
26
- React6.useEffect(() => pullState(token, socket, store), [token.key]);
27
- }
28
- function usePullFamilyMember(token) {
29
- const { socket } = React6.useContext(RealtimeContext);
30
- const store = React6.useContext(StoreContext);
31
- React6.useEffect(() => pullFamilyMember(token, socket, store), [token.key]);
32
- }
33
- function usePullMutable(token) {
34
- const { socket } = React6.useContext(RealtimeContext);
35
- const store = React6.useContext(StoreContext);
36
- React6.useEffect(() => pullMutableState(token, socket, store), [token.key]);
37
- }
38
- function usePullMutableFamilyMember(token) {
39
- const { socket } = React6.useContext(RealtimeContext);
40
- const store = React6.useContext(StoreContext);
41
- React6.useEffect(
42
- () => pullMutableFamilyMember(token, socket, store),
43
- [token.key]
44
- );
45
- }
46
- function usePush(token) {
47
- const { socket } = React6.useContext(RealtimeContext);
48
- const store = React6.useContext(StoreContext);
49
- const id = React6.useId();
50
- React6.useEffect(
51
- () => pushState(token, socket, `use-push:${id}`, store),
52
- [token.key]
53
- );
54
- }
55
- function useServerAction(token) {
56
- const store = React6.useContext(StoreContext);
57
- const { socket } = React6.useContext(RealtimeContext);
58
- React6.useEffect(
59
- () => synchronizeTransactionResults(token, socket, store),
60
- [token.key]
61
- );
62
- return runTransaction(token, store);
63
- }
64
-
65
- export { RealtimeContext, RealtimeProvider, usePull, usePullFamilyMember, usePullMutable, usePullMutableFamilyMember, usePush, useServerAction };
66
- //# sourceMappingURL=out.js.map
67
- //# sourceMappingURL=chunk-MK4OJD24.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../realtime-react/src/realtime-context.tsx","../realtime-react/src/use-pull.ts","../realtime-react/src/use-pull-family-member.ts","../realtime-react/src/use-pull-mutable.ts","../realtime-react/src/use-pull-mutable-family-member.ts","../realtime-react/src/use-push.ts","../realtime-react/src/use-server-action.ts"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,YAAY,WAAW;AAEvB,SAAS,UAAU;AAoBjB;AAlBK,IAAM,kBAAwB,oBAAkC;AAAA,EACtE,QAAQ,GAAG;AACZ,CAAC;AAEM,IAAM,mBAGR,CAAC,EAAE,UAAU,OAAO,MAAM;AAC9B,QAAM,UAAU,KAAS,mBAAmB;AAC5C,EAAM,gBAAU,MAAM;AACrB,WAAO,GAAG,WAAW,MAAM;AAC1B,cAAQ,OAAO,EAAE;AAAA,IAClB,CAAC;AACD,WAAO,GAAG,cAAc,MAAM;AAC7B,cAAQ,IAAI;AAAA,IACb,CAAC;AAAA,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ACD;;;ACfA,YAAYA,YAAW;AAIhB,SAAS,gBACf,OACkD;AAClD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,EAAE,OAAO,IAAU,kBAAW,eAAe;AACnD,EAAM;AAAA,IACL,MAAU,8BAA8B,OAAO,QAAQ,KAAK;AAAA,IAC5D,CAAC,MAAM,GAAG;AAAA,EACX;AACA,SAAc,eAAe,OAAO,KAAK;AAC1C","sourcesContent":["import { useI } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\nimport type { Socket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nexport const RealtimeContext = React.createContext<{ socket: Socket }>({\n\tsocket: io(),\n})\n\nexport const RealtimeProvider: React.FC<{\n\tchildren: React.ReactNode\n\tsocket: Socket\n}> = ({ children, socket }) => {\n\tconst setMyId = useI(RTC.myIdState__INTERNAL)\n\tReact.useEffect(() => {\n\t\tsocket.on(`connect`, () => {\n\t\t\tsetMyId(socket.id)\n\t\t})\n\t\tsocket.on(`disconnect`, () => {\n\t\t\tsetMyId(null)\n\t\t})\n\t}, [socket, setMyId])\n\treturn (\n\t\t<RealtimeContext.Provider value={{ socket }}>\n\t\t\t{children}\n\t\t</RealtimeContext.Provider>\n\t)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePull<J extends Json.Serializable>(\n\ttoken: AtomIO.StateToken<J>,\n): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => RTC.pullState(token, socket, store), [token.key])\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePullFamilyMember<J extends Json.Serializable>(\n\ttoken: AtomIO.AtomToken<J>,\n): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => RTC.pullFamilyMember(token, socket, store), [token.key])\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePullMutable<\n\tT extends Transceiver<Json.Serializable>,\n\tJ extends Json.Serializable,\n>(token: AtomIO.MutableAtomToken<T, J>): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => RTC.pullMutableState(token, socket, store), [token.key])\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePullMutableFamilyMember<\n\tT extends Transceiver<Json.Serializable>,\n\tJ extends Json.Serializable,\n>(token: AtomIO.MutableAtomToken<T, J>): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(\n\t\t() => RTC.pullMutableFamilyMember(token, socket, store),\n\t\t[token.key],\n\t)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePush<J extends Json.Serializable>(\n\ttoken: AtomIO.StateToken<J>,\n): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\tReact.useEffect(\n\t\t() => RTC.pushState(token, socket, `use-push:${id}`, store),\n\t\t[token.key],\n\t)\n}\n","import * as AtomIO from \"atom.io\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function useServerAction<ƒ extends AtomIO.ƒn>(\n\ttoken: AtomIO.TransactionToken<ƒ>,\n): (...parameters: Parameters<ƒ>) => ReturnType<ƒ> {\n\tconst store = React.useContext(StoreContext)\n\tconst { socket } = React.useContext(RealtimeContext)\n\tReact.useEffect(\n\t\t() => RTC.synchronizeTransactionResults(token, socket, store),\n\t\t[token.key],\n\t)\n\treturn AtomIO.runTransaction(token, store)\n}\n"]}
@@ -1,176 +0,0 @@
1
- import { atom, selector, setState, parseJson, getJsonToken, getUpdateToken, subscribeToState, subscribeToTransaction } from './chunk-PURABO5G.js';
2
-
3
- // realtime-client/src/realtime-state.ts
4
- var myIdState__INTERNAL = atom({
5
- key: `myId__INTERNAL`,
6
- default: null
7
- });
8
- var myIdState = selector({
9
- key: `myId`,
10
- get: ({ get }) => get(myIdState__INTERNAL)
11
- });
12
-
13
- // realtime-client/src/use-pull.ts
14
- function pullState(token, socket, store) {
15
- socket.on(`serve:${token.key}`, (data) => {
16
- setState(token, data, store);
17
- });
18
- socket.emit(`sub:${token.key}`);
19
- return () => {
20
- socket.off(`serve:${token.key}`);
21
- socket.emit(`unsub:${token.key}`);
22
- };
23
- }
24
-
25
- // realtime-client/src/use-pull-family-member.ts
26
- function pullFamilyMember(token, socket, store) {
27
- if (!(`family` in token)) {
28
- console.error(`Token is not a family member:`, token);
29
- return () => {
30
- };
31
- }
32
- const { key: familyKey, subKey: serializedSubKey } = token.family;
33
- const subKey = parseJson(serializedSubKey);
34
- socket == null ? void 0 : socket.on(`serve:${token.key}`, (data) => {
35
- setState(token, data, store);
36
- });
37
- socket == null ? void 0 : socket.emit(`sub:${familyKey}`, subKey);
38
- return () => {
39
- socket == null ? void 0 : socket.off(`serve:${token.key}`);
40
- socket == null ? void 0 : socket.emit(`unsub:${token.key}`);
41
- };
42
- }
43
-
44
- // realtime-client/src/use-pull-mutable.ts
45
- function pullMutableState(token, socket, store) {
46
- const jsonToken = getJsonToken(token);
47
- const updateToken = getUpdateToken(token);
48
- socket.on(`init:${token.key}`, (data) => {
49
- setState(jsonToken, data, store);
50
- });
51
- socket.on(
52
- `next:${token.key}`,
53
- (data) => {
54
- setState(updateToken, data, store);
55
- }
56
- );
57
- socket.emit(`sub:${token.key}`);
58
- return () => {
59
- socket.off(`init:${token.key}`);
60
- socket.off(`next:${token.key}`);
61
- socket.emit(`unsub:${token.key}`);
62
- };
63
- }
64
-
65
- // realtime-client/src/use-pull-mutable-family-member.ts
66
- function pullMutableFamilyMember(token, socket, store) {
67
- if (!(`family` in token)) {
68
- console.error(`Token is not a family member:`, token);
69
- return () => {
70
- };
71
- }
72
- const { key: familyKey, subKey: serializedSubKey } = token.family;
73
- const subKey = parseJson(serializedSubKey);
74
- socket == null ? void 0 : socket.on(`init:${token.key}`, (data) => {
75
- const jsonToken = getJsonToken(token);
76
- setState(jsonToken, data, store);
77
- });
78
- socket == null ? void 0 : socket.on(
79
- `next:${token.key}`,
80
- (data) => {
81
- const trackerToken = getUpdateToken(token);
82
- setState(trackerToken, data, store);
83
- }
84
- );
85
- socket == null ? void 0 : socket.emit(`sub:${familyKey}`, subKey);
86
- return () => {
87
- socket == null ? void 0 : socket.off(`serve:${token.key}`);
88
- socket == null ? void 0 : socket.emit(`unsub:${token.key}`);
89
- };
90
- }
91
-
92
- // realtime-client/src/use-push.ts
93
- function pushState(token, socket, subscriptionKey, store) {
94
- socket.emit(`claim:${token.key}`);
95
- subscribeToState(
96
- token,
97
- ({ newValue }) => {
98
- socket.emit(`pub:${token.key}`, newValue);
99
- },
100
- subscriptionKey,
101
- store
102
- );
103
- return () => {
104
- socket.off(`pub:${token.key}`);
105
- socket.emit(`unclaim:${token.key}`);
106
- };
107
- }
108
-
109
- // realtime-client/src/use-server-action.ts
110
- var TX_SUBS = /* @__PURE__ */ new Map();
111
- function synchronizeTransactionResults(token, socket, store) {
112
- var _a;
113
- const count = (_a = TX_SUBS.get(token.key)) != null ? _a : 0;
114
- TX_SUBS.set(token.key, count + 1);
115
- const unsubscribe = count === 0 ? subscribeToTransaction(
116
- token,
117
- (clientUpdate) => {
118
- const transactionId = Math.random().toString(36).slice(2);
119
- const clientResult = JSON.stringify(clientUpdate);
120
- const topic = `tx:sync:${transactionId}`;
121
- const sync = (serverUpdate) => {
122
- store.logger.info(
123
- `\u{1F504}`,
124
- `transaction`,
125
- token.key,
126
- `syncing client and server`
127
- );
128
- socket.off(topic, sync);
129
- const serverResult = JSON.stringify(serverUpdate);
130
- if (clientResult !== serverResult) {
131
- store.logger.error(
132
- `\u274C`,
133
- `transaction`,
134
- token.key,
135
- `results do not match between client and server`
136
- );
137
- store.logger.error(
138
- `\u274C`,
139
- `transaction`,
140
- token.key,
141
- `client:`,
142
- clientResult
143
- );
144
- store.logger.error(
145
- `\u274C`,
146
- `transaction`,
147
- token.key,
148
- `server:`,
149
- serverResult
150
- );
151
- } else {
152
- store.logger.info(
153
- `\u2705`,
154
- `transaction`,
155
- token.key,
156
- `results match between client and server`
157
- );
158
- }
159
- };
160
- socket.on(topic, sync);
161
- socket.emit(`tx:${token.key}`, clientUpdate, transactionId);
162
- },
163
- `use-server-action`,
164
- store
165
- ) : () => null;
166
- return () => {
167
- var _a2;
168
- const newCount = (_a2 = TX_SUBS.get(token.key)) != null ? _a2 : 0;
169
- TX_SUBS.set(token.key, newCount - 1);
170
- unsubscribe();
171
- };
172
- }
173
-
174
- export { myIdState, myIdState__INTERNAL, pullFamilyMember, pullMutableFamilyMember, pullMutableState, pullState, pushState, synchronizeTransactionResults };
175
- //# sourceMappingURL=out.js.map
176
- //# sourceMappingURL=chunk-N7ADBQJG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../realtime-client/src/realtime-state.ts","../realtime-client/src/use-pull.ts","../realtime-client/src/use-pull-family-member.ts","../realtime-client/src/use-pull-mutable.ts","../realtime-client/src/use-pull-mutable-family-member.ts","../realtime-client/src/use-push.ts","../realtime-client/src/use-server-action.ts"],"names":["_a"],"mappings":";;;;;;;;;;;;AAEO,IAAM,sBAA6B,KAAoB;AAAA,EAC7D,KAAK;AAAA,EACL,SAAS;AACV,CAAC;AACM,IAAM,YAAmB,SAAwB;AAAA,EACvD,KAAK;AAAA,EACL,KAAK,CAAC,EAAE,IAAI,MAAM,IAAI,mBAAmB;AAC1C,CAAC;;;ACJM,SAAS,UACf,OACA,QACA,OACa;AACb,SAAO,GAAG,SAAS,MAAM,GAAG,IAAI,CAAC,SAAS;AACzC,IAAO,SAAS,OAAO,MAAM,KAAK;AAAA,EACnC,CAAC;AACD,SAAO,KAAK,OAAO,MAAM,GAAG,EAAE;AAC9B,SAAO,MAAM;AACZ,WAAO,IAAI,SAAS,MAAM,GAAG,EAAE;AAC/B,WAAO,KAAK,SAAS,MAAM,GAAG,EAAE;AAAA,EACjC;AACD;;;ACZO,SAAS,iBACf,OACA,QACA,OACa;AACb,MAAI,EAAE,YAAY,QAAQ;AACzB,YAAQ,MAAM,iCAAiC,KAAK;AACpD,WAAO,MAAM;AAAA,IAAC;AAAA,EACf;AACA,QAAM,EAAE,KAAK,WAAW,QAAQ,iBAAiB,IAAI,MAAM;AAC3D,QAAM,SAAS,UAAU,gBAAgB;AACzC,mCAAQ,GAAG,SAAS,MAAM,GAAG,IAAI,CAAC,SAAY;AAC7C,IAAO,SAAS,OAAO,MAAM,KAAK;AAAA,EACnC;AACA,mCAAQ,KAAK,OAAO,SAAS,IAAI;AACjC,SAAO,MAAM;AACZ,qCAAQ,IAAI,SAAS,MAAM,GAAG;AAC9B,qCAAQ,KAAK,SAAS,MAAM,GAAG;AAAA,EAChC;AACD;;;ACnBO,SAAS,iBAIf,OACA,QACA,OACa;AACb,QAAM,YA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AAAA,MACD;AACA,aAAO,GAAG,OAAO,IAAI;AACrB,aAAO,KAAK,MAAM,MAAM,GAAG,IAAI,cAAc,aAAa;AAAA,IAC3D;AAAA,IACA;AAAA,IACA;AAAA,EACA,IACA,MAAM;AACV,SAAO,MAAM;AAlEd,QAAAA;AAmEE,UAAM,YAAWA,MAAA,QAAQ,IAAI,MAAM,GAAG,MAArB,OAAAA,MAA0B;AAC3C,YAAQ,IAAI,MAAM,KAAK,WAAW,CAAC;AACnC,gBAAY;AAAA,EACb;AACD","sourcesContent":["import * as AtomIO from \"atom.io\"\n\nexport const myIdState__INTERNAL = AtomIO.atom<string | null>({\n\tkey: `myId__INTERNAL`,\n\tdefault: null,\n})\nexport const myIdState = AtomIO.selector<string | null>({\n\tkey: `myId`,\n\tget: ({ get }) => get(myIdState__INTERNAL),\n})\n","import * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullState<J extends Json.Serializable>(\n\ttoken: AtomIO.StateToken<J>,\n\tsocket: Socket,\n\tstore: Store,\n): () => void {\n\tsocket.on(`serve:${token.key}`, (data) => {\n\t\tAtomIO.setState(token, data, store)\n\t})\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`serve:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { parseJson } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullFamilyMember<J extends Json.Serializable>(\n\ttoken: AtomIO.AtomToken<J>,\n\tsocket: Socket,\n\tstore: Store,\n): () => void {\n\tif (!(`family` in token)) {\n\t\tconsole.error(`Token is not a family member:`, token)\n\t\treturn () => {}\n\t}\n\tconst { key: familyKey, subKey: serializedSubKey } = token.family\n\tconst subKey = parseJson(serializedSubKey)\n\tsocket?.on(`serve:${token.key}`, (data: J) => {\n\t\tAtomIO.setState(token, data, store)\n\t})\n\tsocket?.emit(`sub:${familyKey}`, subKey)\n\treturn () => {\n\t\tsocket?.off(`serve:${token.key}`)\n\t\tsocket?.emit(`unsub:${token.key}`)\n\t}\n}\n","import * as AtomIO from \"atom.io\"\nimport type { Store, Transceiver } from \"atom.io/internal\"\nimport { getJsonToken, getUpdateToken } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullMutableState<\n\tT extends Transceiver<Json.Serializable>,\n\tJ extends Json.Serializable,\n>(\n\ttoken: AtomIO.MutableAtomToken<T, J>,\n\tsocket: Socket,\n\tstore: Store,\n): () => void {\n\tconst jsonToken = getJsonToken(token)\n\tconst updateToken = getUpdateToken(token)\n\tsocket.on(`init:${token.key}`, (data: J) => {\n\t\tAtomIO.setState(jsonToken, data, store)\n\t})\n\tsocket.on(\n\t\t`next:${token.key}`,\n\t\t(data: T extends Transceiver<infer Update> ? Update : never) => {\n\t\t\tAtomIO.setState(updateToken, data, store)\n\t\t},\n\t)\n\tsocket.emit(`sub:${token.key}`)\n\treturn () => {\n\t\tsocket.off(`init:${token.key}`)\n\t\tsocket.off(`next:${token.key}`)\n\t\tsocket.emit(`unsub:${token.key}`)\n\t}\n}\n","import * as AtomIO from \"atom.io\"\nimport { getJsonToken, getUpdateToken } from \"atom.io/internal\"\nimport type { Store, Transceiver } from \"atom.io/internal\"\nimport { parseJson } from \"atom.io/json\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pullMutableFamilyMember<\n\tT extends Transceiver<Json.Serializable>,\n\tJ extends Json.Serializable,\n>(\n\ttoken: AtomIO.MutableAtomToken<T, J>,\n\tsocket: Socket,\n\tstore: Store,\n): () => void {\n\tif (!(`family` in token)) {\n\t\tconsole.error(`Token is not a family member:`, token)\n\t\treturn () => {}\n\t}\n\tconst { key: familyKey, subKey: serializedSubKey } = token.family\n\tconst subKey = parseJson(serializedSubKey)\n\tsocket?.on(`init:${token.key}`, (data: J) => {\n\t\tconst jsonToken = getJsonToken(token)\n\t\tAtomIO.setState(jsonToken, data, store)\n\t})\n\tsocket?.on(\n\t\t`next:${token.key}`,\n\t\t(data: T extends Transceiver<infer Signal> ? Signal : never) => {\n\t\t\tconst trackerToken = getUpdateToken(token)\n\t\t\tAtomIO.setState(trackerToken, data, store)\n\t\t},\n\t)\n\tsocket?.emit(`sub:${familyKey}`, subKey)\n\treturn () => {\n\t\tsocket?.off(`serve:${token.key}`)\n\t\tsocket?.emit(`unsub:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport * as Internal from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { Socket } from \"socket.io-client\"\n\nexport function pushState<J extends Json.Serializable>(\n\ttoken: AtomIO.StateToken<J>,\n\tsocket: Socket,\n\tsubscriptionKey: string,\n\tstore: Internal.Store,\n): () => void {\n\tsocket.emit(`claim:${token.key}`)\n\tInternal.subscribeToState(\n\t\ttoken,\n\t\t({ newValue }) => {\n\t\t\tsocket.emit(`pub:${token.key}`, newValue)\n\t\t},\n\t\tsubscriptionKey,\n\t\tstore,\n\t)\n\treturn () => {\n\t\tsocket.off(`pub:${token.key}`)\n\t\tsocket.emit(`unclaim:${token.key}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport * as Internal from \"atom.io/internal\"\nimport type { Socket } from \"socket.io-client\"\n\nconst TX_SUBS = new Map<string, number>()\nexport function synchronizeTransactionResults(\n\ttoken: AtomIO.TransactionToken<any>,\n\tsocket: Socket,\n\tstore: Internal.Store,\n): () => void {\n\tconst count = TX_SUBS.get(token.key) ?? 0\n\tTX_SUBS.set(token.key, count + 1)\n\tconst unsubscribe =\n\t\tcount === 0\n\t\t\t? Internal.subscribeToTransaction(\n\t\t\t\t\ttoken,\n\t\t\t\t\t(clientUpdate) => {\n\t\t\t\t\t\tconst transactionId = Math.random().toString(36).slice(2)\n\t\t\t\t\t\tconst clientResult = JSON.stringify(clientUpdate)\n\t\t\t\t\t\tconst topic = `tx:sync:${transactionId}`\n\t\t\t\t\t\tconst sync = (serverUpdate: typeof clientUpdate) => {\n\t\t\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t\t\t`🔄`,\n\t\t\t\t\t\t\t\t`transaction`,\n\t\t\t\t\t\t\t\ttoken.key,\n\t\t\t\t\t\t\t\t`syncing client and server`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tsocket.off(topic, sync)\n\t\t\t\t\t\t\tconst serverResult = JSON.stringify(serverUpdate)\n\t\t\t\t\t\t\tif (clientResult !== serverResult) {\n\t\t\t\t\t\t\t\tstore.logger.error(\n\t\t\t\t\t\t\t\t\t`❌`,\n\t\t\t\t\t\t\t\t\t`transaction`,\n\t\t\t\t\t\t\t\t\ttoken.key,\n\t\t\t\t\t\t\t\t\t`results do not match between client and server`,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tstore.logger.error(\n\t\t\t\t\t\t\t\t\t`❌`,\n\t\t\t\t\t\t\t\t\t`transaction`,\n\t\t\t\t\t\t\t\t\ttoken.key,\n\t\t\t\t\t\t\t\t\t`client:`,\n\t\t\t\t\t\t\t\t\tclientResult,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tstore.logger.error(\n\t\t\t\t\t\t\t\t\t`❌`,\n\t\t\t\t\t\t\t\t\t`transaction`,\n\t\t\t\t\t\t\t\t\ttoken.key,\n\t\t\t\t\t\t\t\t\t`server:`,\n\t\t\t\t\t\t\t\t\tserverResult,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t\t\t\t`✅`,\n\t\t\t\t\t\t\t\t\t`transaction`,\n\t\t\t\t\t\t\t\t\ttoken.key,\n\t\t\t\t\t\t\t\t\t`results match between client and server`,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsocket.on(topic, sync)\n\t\t\t\t\t\tsocket.emit(`tx:${token.key}`, clientUpdate, transactionId)\n\t\t\t\t\t},\n\t\t\t\t\t`use-server-action`,\n\t\t\t\t\tstore,\n\t\t\t )\n\t\t\t: () => null\n\treturn () => {\n\t\tconst newCount = TX_SUBS.get(token.key) ?? 0\n\t\tTX_SUBS.set(token.key, newCount - 1)\n\t\tunsubscribe()\n\t}\n}\n"]}