atom.io 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +27 -15
- package/dist/index.d.ts +27 -15
- package/dist/index.js +44 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -24
- package/dist/index.mjs.map +1 -1
- package/json/dist/index.d.mts +18 -0
- package/json/dist/index.d.ts +18 -0
- package/json/dist/index.js +51 -0
- package/json/dist/index.js.map +1 -0
- package/json/dist/index.mjs +15 -0
- package/json/dist/index.mjs.map +1 -0
- package/json/package.json +13 -13
- package/package.json +31 -12
- package/react/dist/index.d.mts +24 -0
- package/react/dist/index.d.ts +24 -0
- package/react/dist/index.js +87 -0
- package/react/dist/index.js.map +1 -0
- package/react/dist/index.mjs +45 -0
- package/react/dist/index.mjs.map +1 -0
- package/react/package.json +13 -13
- package/react-devtools/dist/index.css +26 -0
- package/react-devtools/dist/index.css.map +1 -0
- package/react-devtools/dist/index.d.mts +15 -0
- package/react-devtools/dist/index.d.ts +15 -0
- package/react-devtools/dist/index.js +2108 -0
- package/react-devtools/dist/index.js.map +1 -0
- package/react-devtools/dist/index.mjs +2080 -0
- package/react-devtools/dist/index.mjs.map +1 -0
- package/react-devtools/package.json +13 -13
- package/realtime/dist/index.d.mts +27 -0
- package/realtime/dist/index.d.ts +27 -0
- package/realtime/dist/index.js +191 -0
- package/realtime/dist/index.js.map +1 -0
- package/realtime/dist/index.mjs +152 -0
- package/realtime/dist/index.mjs.map +1 -0
- package/realtime/package.json +13 -13
- package/realtime-react/dist/index.d.mts +45 -0
- package/realtime-react/dist/index.d.ts +45 -0
- package/realtime-react/dist/index.js +217 -0
- package/realtime-react/dist/index.js.map +1 -0
- package/realtime-react/dist/index.mjs +172 -0
- package/realtime-react/dist/index.mjs.map +1 -0
- package/realtime-react/package.json +13 -13
- package/realtime-testing/dist/index.d.mts +49 -0
- package/realtime-testing/dist/index.d.ts +49 -0
- package/realtime-testing/dist/index.js +165 -0
- package/realtime-testing/dist/index.js.map +1 -0
- package/realtime-testing/dist/index.mjs +129 -0
- package/realtime-testing/dist/index.mjs.map +1 -0
- package/realtime-testing/package.json +15 -0
- package/src/atom.ts +16 -17
- package/src/index.ts +59 -59
- package/src/internal/atom-internal.ts +37 -37
- package/src/internal/families-internal.ts +115 -116
- package/src/internal/get.ts +83 -83
- package/src/internal/index.ts +1 -0
- package/src/internal/is-default.ts +17 -17
- package/src/internal/meta/attach-meta.ts +7 -7
- package/src/internal/meta/meta-state.ts +115 -115
- package/src/internal/operation.ts +93 -93
- package/src/internal/selector/create-read-write-selector.ts +47 -47
- package/src/internal/selector/create-readonly-selector.ts +38 -38
- package/src/internal/selector/lookup-selector-sources.ts +9 -9
- package/src/internal/selector/register-selector.ts +44 -44
- package/src/internal/selector/trace-selector-atoms.ts +30 -30
- package/src/internal/selector/update-selector-atoms.ts +25 -25
- package/src/internal/selector-internal.ts +38 -39
- package/src/internal/set.ts +78 -78
- package/src/internal/store.ts +119 -119
- package/src/internal/subject.ts +24 -0
- package/src/internal/subscribe-internal.ts +62 -62
- package/src/internal/time-travel-internal.ts +76 -76
- package/src/internal/timeline/add-atom-to-timeline.ts +158 -153
- package/src/internal/timeline-internal.ts +81 -82
- package/src/internal/transaction/abort-transaction.ts +8 -8
- package/src/internal/transaction/apply-transaction.ts +41 -41
- package/src/internal/transaction/build-transaction.ts +28 -28
- package/src/internal/transaction/index.ts +7 -7
- package/src/internal/transaction/redo-transaction.ts +13 -13
- package/src/internal/transaction/undo-transaction.ts +13 -13
- package/src/internal/transaction-internal.ts +49 -49
- package/src/json/select-json.ts +12 -12
- package/src/logger.ts +30 -30
- package/src/react/store-context.tsx +5 -6
- package/src/react/store-hooks.ts +19 -20
- package/src/react-devtools/AtomIODevtools.tsx +85 -85
- package/src/react-devtools/StateEditor.tsx +54 -55
- package/src/react-devtools/TokenList.tsx +49 -45
- package/src/react-explorer/AtomIOExplorer.tsx +198 -187
- package/src/react-explorer/explorer-effects.ts +11 -11
- package/src/react-explorer/explorer-states.ts +186 -193
- package/src/react-explorer/index.ts +11 -11
- package/src/react-explorer/space-states.ts +48 -50
- package/src/react-explorer/view-states.ts +25 -25
- package/src/realtime/hook-composition/expose-family.ts +81 -81
- package/src/realtime/hook-composition/expose-single.ts +26 -26
- package/src/realtime/hook-composition/expose-timeline.ts +60 -0
- package/src/realtime/hook-composition/index.ts +2 -2
- package/src/realtime/hook-composition/receive-state.ts +18 -18
- package/src/realtime/hook-composition/receive-transaction.ts +8 -8
- package/src/realtime-react/realtime-context.tsx +18 -19
- package/src/realtime-react/realtime-hooks.ts +17 -17
- package/src/realtime-react/realtime-state.ts +4 -4
- package/src/realtime-react/use-pull-family-member.ts +16 -17
- package/src/realtime-react/use-pull-family.ts +14 -15
- package/src/realtime-react/use-pull.ts +13 -14
- package/src/realtime-react/use-push.ts +16 -17
- package/src/realtime-react/use-server-action.ts +22 -23
- package/src/realtime-testing/index.ts +1 -0
- package/src/realtime-testing/setup-realtime-test.tsx +159 -0
- package/src/selector.ts +26 -27
- package/src/silo.ts +38 -38
- package/src/subscribe.ts +68 -68
- package/src/timeline.ts +13 -13
- package/src/transaction.ts +28 -28
- package/src/web-effects/storage.ts +17 -17
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// ../src/realtime-react/realtime-context.tsx
|
|
2
|
+
import * as AR from "atom.io/react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { io } from "socket.io-client";
|
|
5
|
+
|
|
6
|
+
// ../src/realtime-react/realtime-state.ts
|
|
7
|
+
import * as AtomIO from "atom.io";
|
|
8
|
+
var myIdState__INTERNAL = AtomIO.atom({
|
|
9
|
+
key: `myId__INTERNAL`,
|
|
10
|
+
default: null
|
|
11
|
+
});
|
|
12
|
+
var myIdState = AtomIO.selector({
|
|
13
|
+
key: `myId`,
|
|
14
|
+
get: ({ get }) => get(myIdState__INTERNAL)
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// ../src/realtime-react/realtime-context.tsx
|
|
18
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
19
|
+
var RealtimeContext = React.createContext({
|
|
20
|
+
socket: io()
|
|
21
|
+
});
|
|
22
|
+
var RealtimeProvider = ({ children, socket }) => {
|
|
23
|
+
const setMyId = AR.useI(myIdState__INTERNAL);
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
socket.on(`connect`, () => {
|
|
26
|
+
setMyId(socket.id);
|
|
27
|
+
});
|
|
28
|
+
socket.on(`disconnect`, () => {
|
|
29
|
+
setMyId(null);
|
|
30
|
+
});
|
|
31
|
+
}, [socket, setMyId]);
|
|
32
|
+
return /* @__PURE__ */ jsxDEV(RealtimeContext.Provider, { value: { socket }, children }, void 0, false, {
|
|
33
|
+
fileName: "../src/realtime-react/realtime-context.tsx",
|
|
34
|
+
lineNumber: 26,
|
|
35
|
+
columnNumber: 3
|
|
36
|
+
}, this);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// ../src/realtime-react/use-pull.ts
|
|
40
|
+
import * as AtomIO3 from "atom.io";
|
|
41
|
+
import * as React3 from "react";
|
|
42
|
+
|
|
43
|
+
// ../src/react/store-context.tsx
|
|
44
|
+
import * as AtomIO2 from "atom.io";
|
|
45
|
+
import * as React2 from "react";
|
|
46
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
47
|
+
var StoreContext = React2.createContext(
|
|
48
|
+
AtomIO2.__INTERNAL__.IMPLICIT.STORE
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// ../src/realtime-react/use-pull.ts
|
|
52
|
+
function usePull(token) {
|
|
53
|
+
const { socket } = React3.useContext(RealtimeContext);
|
|
54
|
+
const store = React3.useContext(StoreContext);
|
|
55
|
+
React3.useEffect(() => {
|
|
56
|
+
socket.on(`serve:${token.key}`, (data) => {
|
|
57
|
+
AtomIO3.setState(token, data, store);
|
|
58
|
+
});
|
|
59
|
+
socket.emit(`sub:${token.key}`);
|
|
60
|
+
return () => {
|
|
61
|
+
socket.off(`serve:${token.key}`);
|
|
62
|
+
socket.emit(`unsub:${token.key}`);
|
|
63
|
+
};
|
|
64
|
+
}, [token.key]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ../src/realtime-react/use-pull-family.ts
|
|
68
|
+
import * as AtomIO4 from "atom.io";
|
|
69
|
+
import * as React4 from "react";
|
|
70
|
+
function usePullFamily(family) {
|
|
71
|
+
const { socket } = React4.useContext(RealtimeContext);
|
|
72
|
+
const store = React4.useContext(StoreContext);
|
|
73
|
+
React4.useEffect(() => {
|
|
74
|
+
socket.on(`serve:${family.key}`, (key, data) => {
|
|
75
|
+
AtomIO4.setState(family(key), data, store);
|
|
76
|
+
});
|
|
77
|
+
socket == null ? void 0 : socket.emit(`sub:${family.key}`);
|
|
78
|
+
return () => {
|
|
79
|
+
socket == null ? void 0 : socket.off(`serve:${family.key}`);
|
|
80
|
+
socket == null ? void 0 : socket.emit(`unsub:${family.key}`);
|
|
81
|
+
};
|
|
82
|
+
}, [family.key]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ../src/realtime-react/use-pull-family-member.ts
|
|
86
|
+
import * as AtomIO5 from "atom.io";
|
|
87
|
+
import * as React5 from "react";
|
|
88
|
+
function usePullFamilyMember(family, subKey) {
|
|
89
|
+
const token = family(subKey);
|
|
90
|
+
const { socket } = React5.useContext(RealtimeContext);
|
|
91
|
+
const store = React5.useContext(StoreContext);
|
|
92
|
+
React5.useEffect(() => {
|
|
93
|
+
socket == null ? void 0 : socket.on(`serve:${token.key}`, (data) => {
|
|
94
|
+
AtomIO5.setState(family(subKey), data, store);
|
|
95
|
+
});
|
|
96
|
+
socket == null ? void 0 : socket.emit(`sub:${family.key}`, subKey);
|
|
97
|
+
return () => {
|
|
98
|
+
socket == null ? void 0 : socket.off(`serve:${token.key}`);
|
|
99
|
+
socket == null ? void 0 : socket.emit(`unsub:${token.key}`);
|
|
100
|
+
};
|
|
101
|
+
}, [family.key]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ../src/realtime-react/use-push.ts
|
|
105
|
+
import * as AtomIO6 from "atom.io";
|
|
106
|
+
import * as React6 from "react";
|
|
107
|
+
function usePush(token) {
|
|
108
|
+
const { socket } = React6.useContext(RealtimeContext);
|
|
109
|
+
const store = React6.useContext(StoreContext);
|
|
110
|
+
React6.useEffect(() => {
|
|
111
|
+
socket.emit(`claim:${token.key}`);
|
|
112
|
+
AtomIO6.subscribe(
|
|
113
|
+
token,
|
|
114
|
+
({ newValue }) => {
|
|
115
|
+
socket.emit(`pub:${token.key}`, newValue);
|
|
116
|
+
},
|
|
117
|
+
store
|
|
118
|
+
);
|
|
119
|
+
return () => {
|
|
120
|
+
socket.emit(`unclaim:${token.key}`);
|
|
121
|
+
};
|
|
122
|
+
}, [token.key]);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ../src/realtime-react/use-server-action.ts
|
|
126
|
+
import * as AtomIO7 from "atom.io";
|
|
127
|
+
import { StoreContext as StoreContext2 } from "atom.io/react";
|
|
128
|
+
import * as React7 from "react";
|
|
129
|
+
var TX_SUBS = /* @__PURE__ */ new Map();
|
|
130
|
+
function useServerAction(token) {
|
|
131
|
+
const store = React7.useContext(StoreContext2);
|
|
132
|
+
const { socket } = React7.useContext(RealtimeContext);
|
|
133
|
+
React7.useEffect(() => {
|
|
134
|
+
var _a;
|
|
135
|
+
const count = (_a = TX_SUBS.get(token.key)) != null ? _a : 0;
|
|
136
|
+
TX_SUBS.set(token.key, count + 1);
|
|
137
|
+
const unsubscribe = count === 0 ? AtomIO7.subscribeToTransaction(
|
|
138
|
+
token,
|
|
139
|
+
(update) => socket.emit(`tx:${token.key}`, update),
|
|
140
|
+
store
|
|
141
|
+
) : () => null;
|
|
142
|
+
return () => {
|
|
143
|
+
var _a2;
|
|
144
|
+
const newCount = (_a2 = TX_SUBS.get(token.key)) != null ? _a2 : 0;
|
|
145
|
+
TX_SUBS.set(token.key, newCount - 1);
|
|
146
|
+
unsubscribe();
|
|
147
|
+
};
|
|
148
|
+
}, [token.key]);
|
|
149
|
+
return AtomIO7.runTransaction(token, store);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ../src/realtime-react/realtime-hooks.ts
|
|
153
|
+
var realtimeHooks = {
|
|
154
|
+
usePull,
|
|
155
|
+
usePullFamily,
|
|
156
|
+
usePullFamilyMember,
|
|
157
|
+
usePush,
|
|
158
|
+
useServerAction
|
|
159
|
+
};
|
|
160
|
+
export {
|
|
161
|
+
RealtimeContext,
|
|
162
|
+
RealtimeProvider,
|
|
163
|
+
myIdState,
|
|
164
|
+
myIdState__INTERNAL,
|
|
165
|
+
realtimeHooks,
|
|
166
|
+
usePull,
|
|
167
|
+
usePullFamily,
|
|
168
|
+
usePullFamilyMember,
|
|
169
|
+
usePush,
|
|
170
|
+
useServerAction
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/realtime-react/realtime-context.tsx","../../src/realtime-react/realtime-state.ts","../../src/realtime-react/use-pull.ts","../../src/react/store-context.tsx","../../src/realtime-react/use-pull-family.ts","../../src/realtime-react/use-pull-family-member.ts","../../src/realtime-react/use-push.ts","../../src/realtime-react/use-server-action.ts","../../src/realtime-react/realtime-hooks.ts"],"sourcesContent":["import * as AR from \"atom.io/react\"\nimport * as React from \"react\"\nimport type { Socket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nimport { myIdState__INTERNAL } from \"./realtime-state\"\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 = AR.useI(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 * 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 * as React from \"react\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { StoreContext } from \"../react\"\n\nexport function usePull<J extends Json>(token: AtomIO.StateToken<J>): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => {\n\t\tsocket.on(`serve:${token.key}`, (data: J) => {\n\t\t\tAtomIO.setState(token, data, store)\n\t\t})\n\t\tsocket.emit(`sub:${token.key}`)\n\t\treturn () => {\n\t\t\tsocket.off(`serve:${token.key}`)\n\t\t\tsocket.emit(`unsub:${token.key}`)\n\t\t}\n\t}, [token.key])\n}\n","import * as AtomIO from \"atom.io\"\nimport * as React from \"react\"\n\nexport const StoreContext = React.createContext<AtomIO.Store>(\n\tAtomIO.__INTERNAL__.IMPLICIT.STORE,\n)\n\nexport const StoreProvider: React.FC<{\n\tchildren: React.ReactNode\n\tstore?: AtomIO.Store\n}> = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => (\n\t<StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n)\n","import * as AtomIO from \"atom.io\"\nimport * as React from \"react\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { StoreContext } from \"../react\"\n\nexport function usePullFamily<J extends Json>(\n\tfamily: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>,\n): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => {\n\t\tsocket.on(`serve:${family.key}`, (key: Json, data: J) => {\n\t\t\tAtomIO.setState(family(key), data, store)\n\t\t})\n\t\tsocket?.emit(`sub:${family.key}`)\n\t\treturn () => {\n\t\t\tsocket?.off(`serve:${family.key}`)\n\t\t\tsocket?.emit(`unsub:${family.key}`)\n\t\t}\n\t}, [family.key])\n}\n","import * as AtomIO from \"atom.io\"\nimport * as React from \"react\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { StoreContext } from \"../react\"\n\nexport function usePullFamilyMember<J extends Json>(\n\tfamily: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>,\n\tsubKey: AtomIO.Serializable,\n): void {\n\tconst token = family(subKey)\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => {\n\t\tsocket?.on(`serve:${token.key}`, (data: J) => {\n\t\t\tAtomIO.setState(family(subKey), data, store)\n\t\t})\n\t\tsocket?.emit(`sub:${family.key}`, subKey)\n\t\treturn () => {\n\t\t\tsocket?.off(`serve:${token.key}`)\n\t\t\tsocket?.emit(`unsub:${token.key}`)\n\t\t}\n\t}, [family.key])\n}\n","import * as AtomIO from \"atom.io\"\nimport * as React from \"react\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { StoreContext } from \"../react\"\n\nexport function usePush<J extends Json>(token: AtomIO.StateToken<J>): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => {\n\t\tsocket.emit(`claim:${token.key}`)\n\t\tAtomIO.subscribe(\n\t\t\ttoken,\n\t\t\t({ newValue }) => {\n\t\t\t\tsocket.emit(`pub:${token.key}`, newValue)\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\t\treturn () => {\n\t\t\tsocket.emit(`unclaim:${token.key}`)\n\t\t}\n\t}, [token.key])\n}\n","import * as AtomIO from \"atom.io\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as React from \"react\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nconst TX_SUBS = new Map<string, number>()\nexport function useServerAction<ƒ extends ƒ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\tconst count = TX_SUBS.get(token.key) ?? 0\n\t\tTX_SUBS.set(token.key, count + 1)\n\t\tconst unsubscribe =\n\t\t\tcount === 0\n\t\t\t\t? AtomIO.subscribeToTransaction(\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t(update) => socket.emit(`tx:${token.key}`, update),\n\t\t\t\t\t\tstore,\n\t\t\t\t )\n\t\t\t\t: () => null\n\t\treturn () => {\n\t\t\tconst newCount = TX_SUBS.get(token.key) ?? 0\n\t\t\tTX_SUBS.set(token.key, newCount - 1)\n\t\t\tunsubscribe()\n\t\t}\n\t}, [token.key])\n\treturn AtomIO.runTransaction(token, store)\n}\n","import type * as AtomIO from \"atom.io\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { usePull } from \"./use-pull\"\nimport { usePullFamily } from \"./use-pull-family\"\nimport { usePullFamilyMember } from \"./use-pull-family-member\"\nimport { usePush } from \"./use-push\"\nimport { useServerAction } from \"./use-server-action\"\n\nexport type RealtimeHooks = {\n\tusePull: <J extends Json>(token: AtomIO.StateToken<J>) => void\n\tusePullFamily: <J extends Json>(\n\t\tfamily: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>,\n\t) => void\n\tusePullFamilyMember: <J extends Json>(\n\t\tfamily: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>,\n\t\tsubKey: string,\n\t) => void\n\tusePush: <J extends Json>(token: AtomIO.StateToken<J>) => void\n\tuseServerAction: <ƒ extends ƒn>(\n\t\ttoken: AtomIO.TransactionToken<ƒ>,\n\t) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>\n}\n\nexport const realtimeHooks: RealtimeHooks = {\n\tusePull,\n\tusePullFamily,\n\tusePullFamilyMember,\n\tusePush,\n\tuseServerAction,\n}\n\nexport * from \"./use-pull\"\nexport * from \"./use-pull-family\"\nexport * from \"./use-pull-family-member\"\nexport * from \"./use-push\"\nexport * from \"./use-server-action\"\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,YAAY,WAAW;AAEvB,SAAS,UAAU;;;ACHnB,YAAY,YAAY;AAEjB,IAAM,sBAA6B,YAAoB;AAAA,EAC7D,KAAK;AAAA,EACL,SAAS;AACV,CAAC;AACM,IAAM,YAAmB,gBAAwB;AAAA,EACvD,KAAK;AAAA,EACL,KAAK,CAAC,EAAE,IAAI,MAAM,IAAI,mBAAmB;AAC1C,CAAC;;;ADgBC;AAlBK,IAAM,kBAAwB,oBAAkC;AAAA,EACtE,QAAQ,GAAG;AACZ,CAAC;AAEM,IAAM,mBAGR,CAAC,EAAE,UAAU,OAAO,MAAM;AAC9B,QAAM,UAAa,QAAK,mBAAmB;AAC3C,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,EACF,GAAG,CAAC,QAAQ,OAAO,CAAC;AACpB,SACC,uBAAC,gBAAgB,UAAhB,EAAyB,OAAO,EAAE,OAAO,GACxC,YADF;AAAA;AAAA;AAAA;AAAA,SAEA;AAEF;;;AE7BA,YAAYA,aAAY;AACxB,YAAYC,YAAW;;;ACDvB,YAAYC,aAAY;AACxB,YA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;AAAA,IACA,IACA,MAAM;AACV,WAAO,MAAM;AAzBf,UAAAC;AA0BG,YAAM,YAAWA,MAAA,QAAQ,IAAI,MAAM,GAAG,MAArB,OAAAA,MAA0B;AAC3C,cAAQ,IAAI,MAAM,KAAK,WAAW,CAAC;AACnC,kBAAY;AAAA,IACb;AAAA,EACD,GAAG,CAAC,MAAM,GAAG,CAAC;AACd,SAAc,uBAAe,OAAO,KAAK;AAC1C;;;ACNO,IAAM,gBAA+B;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;","names":["AtomIO","React","AtomIO","React","jsxDEV","AtomIO","React","AtomIO","React","AtomIO","React","AtomIO","StoreContext","React","StoreContext","_a"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
"name": "atom.io-realtime-react",
|
|
3
|
+
"private": true,
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"browser": "./dist/index.mjs",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
15
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RenderResult } from '@testing-library/react';
|
|
2
|
+
import * as AtomIO from 'atom.io';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SocketIO from 'socket.io';
|
|
5
|
+
|
|
6
|
+
type TestSetupOptions = {
|
|
7
|
+
server: (tools: {
|
|
8
|
+
socket: SocketIO.Socket;
|
|
9
|
+
silo: AtomIO.Silo;
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
12
|
+
type TestSetupOptions__SingleClient = TestSetupOptions & {
|
|
13
|
+
client: React.FC;
|
|
14
|
+
};
|
|
15
|
+
type TestSetupOptions__MultiClient<ClientNames extends string> = TestSetupOptions & {
|
|
16
|
+
clients: {
|
|
17
|
+
[K in ClientNames]: React.FC;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type RealtimeTestTools = {
|
|
21
|
+
name: string;
|
|
22
|
+
silo: AtomIO.Silo;
|
|
23
|
+
dispose: () => void;
|
|
24
|
+
};
|
|
25
|
+
type RealtimeTestClient = RealtimeTestTools & {
|
|
26
|
+
renderResult: RenderResult;
|
|
27
|
+
prettyPrint: () => void;
|
|
28
|
+
reconnect: () => void;
|
|
29
|
+
disconnect: () => void;
|
|
30
|
+
};
|
|
31
|
+
type RealtimeTestServer = RealtimeTestTools & {
|
|
32
|
+
port: number;
|
|
33
|
+
};
|
|
34
|
+
type RealtimeTestAPI = {
|
|
35
|
+
server: RealtimeTestServer;
|
|
36
|
+
teardown: () => void;
|
|
37
|
+
};
|
|
38
|
+
type RealtimeTestAPI__SingleClient = RealtimeTestAPI & {
|
|
39
|
+
client: RealtimeTestClient;
|
|
40
|
+
};
|
|
41
|
+
type RealtimeTestAPI__MultiClient<ClientNames extends string> = RealtimeTestAPI & {
|
|
42
|
+
clients: Record<ClientNames, RealtimeTestClient>;
|
|
43
|
+
};
|
|
44
|
+
declare const setupRealtimeTestServer: (options: TestSetupOptions) => RealtimeTestServer;
|
|
45
|
+
declare const setupRealtimeTestClient: (options: TestSetupOptions__SingleClient, name: string, port: number) => RealtimeTestClient;
|
|
46
|
+
declare const singleClient: (options: TestSetupOptions__SingleClient) => RealtimeTestAPI__SingleClient;
|
|
47
|
+
declare const multiClient: <ClientNames extends string>(options: TestSetupOptions__MultiClient<ClientNames>) => RealtimeTestAPI__MultiClient<ClientNames>;
|
|
48
|
+
|
|
49
|
+
export { RealtimeTestAPI, RealtimeTestAPI__MultiClient, RealtimeTestAPI__SingleClient, RealtimeTestClient, RealtimeTestServer, RealtimeTestTools, TestSetupOptions, TestSetupOptions__MultiClient, TestSetupOptions__SingleClient, multiClient, setupRealtimeTestClient, setupRealtimeTestServer, singleClient };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RenderResult } from '@testing-library/react';
|
|
2
|
+
import * as AtomIO from 'atom.io';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SocketIO from 'socket.io';
|
|
5
|
+
|
|
6
|
+
type TestSetupOptions = {
|
|
7
|
+
server: (tools: {
|
|
8
|
+
socket: SocketIO.Socket;
|
|
9
|
+
silo: AtomIO.Silo;
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
12
|
+
type TestSetupOptions__SingleClient = TestSetupOptions & {
|
|
13
|
+
client: React.FC;
|
|
14
|
+
};
|
|
15
|
+
type TestSetupOptions__MultiClient<ClientNames extends string> = TestSetupOptions & {
|
|
16
|
+
clients: {
|
|
17
|
+
[K in ClientNames]: React.FC;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type RealtimeTestTools = {
|
|
21
|
+
name: string;
|
|
22
|
+
silo: AtomIO.Silo;
|
|
23
|
+
dispose: () => void;
|
|
24
|
+
};
|
|
25
|
+
type RealtimeTestClient = RealtimeTestTools & {
|
|
26
|
+
renderResult: RenderResult;
|
|
27
|
+
prettyPrint: () => void;
|
|
28
|
+
reconnect: () => void;
|
|
29
|
+
disconnect: () => void;
|
|
30
|
+
};
|
|
31
|
+
type RealtimeTestServer = RealtimeTestTools & {
|
|
32
|
+
port: number;
|
|
33
|
+
};
|
|
34
|
+
type RealtimeTestAPI = {
|
|
35
|
+
server: RealtimeTestServer;
|
|
36
|
+
teardown: () => void;
|
|
37
|
+
};
|
|
38
|
+
type RealtimeTestAPI__SingleClient = RealtimeTestAPI & {
|
|
39
|
+
client: RealtimeTestClient;
|
|
40
|
+
};
|
|
41
|
+
type RealtimeTestAPI__MultiClient<ClientNames extends string> = RealtimeTestAPI & {
|
|
42
|
+
clients: Record<ClientNames, RealtimeTestClient>;
|
|
43
|
+
};
|
|
44
|
+
declare const setupRealtimeTestServer: (options: TestSetupOptions) => RealtimeTestServer;
|
|
45
|
+
declare const setupRealtimeTestClient: (options: TestSetupOptions__SingleClient, name: string, port: number) => RealtimeTestClient;
|
|
46
|
+
declare const singleClient: (options: TestSetupOptions__SingleClient) => RealtimeTestAPI__SingleClient;
|
|
47
|
+
declare const multiClient: <ClientNames extends string>(options: TestSetupOptions__MultiClient<ClientNames>) => RealtimeTestAPI__MultiClient<ClientNames>;
|
|
48
|
+
|
|
49
|
+
export { RealtimeTestAPI, RealtimeTestAPI__MultiClient, RealtimeTestAPI__SingleClient, RealtimeTestClient, RealtimeTestServer, RealtimeTestTools, TestSetupOptions, TestSetupOptions__MultiClient, TestSetupOptions__SingleClient, multiClient, setupRealtimeTestClient, setupRealtimeTestServer, singleClient };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
+
mod
|
|
43
|
+
));
|
|
44
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
+
|
|
46
|
+
// ../src/realtime-testing/index.ts
|
|
47
|
+
var realtime_testing_exports = {};
|
|
48
|
+
__export(realtime_testing_exports, {
|
|
49
|
+
multiClient: () => multiClient,
|
|
50
|
+
setupRealtimeTestClient: () => setupRealtimeTestClient,
|
|
51
|
+
setupRealtimeTestServer: () => setupRealtimeTestServer,
|
|
52
|
+
singleClient: () => singleClient
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(realtime_testing_exports);
|
|
55
|
+
|
|
56
|
+
// ../src/realtime-testing/setup-realtime-test.tsx
|
|
57
|
+
var http = __toESM(require("http"));
|
|
58
|
+
var import_react = require("@testing-library/react");
|
|
59
|
+
var AtomIO = __toESM(require("atom.io"));
|
|
60
|
+
var AR = __toESM(require("atom.io/react"));
|
|
61
|
+
var RTC = __toESM(require("atom.io/realtime-react"));
|
|
62
|
+
var RR = __toESM(require("fp-ts/ReadonlyRecord"));
|
|
63
|
+
var Happy = __toESM(require("happy-dom"));
|
|
64
|
+
var SocketIO = __toESM(require("socket.io"));
|
|
65
|
+
var import_socket = require("socket.io-client");
|
|
66
|
+
var import_jsx_dev_runtime = require("react/jsx-dev-runtime");
|
|
67
|
+
var setupRealtimeTestServer = (options) => {
|
|
68
|
+
const httpServer = http.createServer((_, res) => res.end(`Hello World!`));
|
|
69
|
+
const address = httpServer.listen().address();
|
|
70
|
+
const port = typeof address === `string` ? 80 : address === null ? null : address.port;
|
|
71
|
+
if (port === null)
|
|
72
|
+
throw new Error(`Could not determine port for test server`);
|
|
73
|
+
const server = new SocketIO.Server(httpServer);
|
|
74
|
+
const silo2 = AtomIO.silo(`SERVER`, AtomIO.__INTERNAL__.IMPLICIT.STORE);
|
|
75
|
+
server.on(`connection`, (socket) => {
|
|
76
|
+
options.server({ socket, silo: silo2 });
|
|
77
|
+
});
|
|
78
|
+
const dispose = () => {
|
|
79
|
+
server.close();
|
|
80
|
+
AtomIO.__INTERNAL__.clearStore(silo2.store);
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
name: `SERVER`,
|
|
84
|
+
silo: silo2,
|
|
85
|
+
dispose,
|
|
86
|
+
port
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
var setupRealtimeTestClient = (options, name, port) => {
|
|
90
|
+
const socket = (0, import_socket.io)(`http://localhost:${port}/`);
|
|
91
|
+
const silo2 = AtomIO.silo(name, AtomIO.__INTERNAL__.IMPLICIT.STORE);
|
|
92
|
+
const { document } = new Happy.Window();
|
|
93
|
+
document.body.innerHTML = `<div id="app"></div>`;
|
|
94
|
+
const renderResult = (0, import_react.render)(
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(AR.StoreProvider, { store: silo2.store, children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(RTC.RealtimeProvider, { socket, children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(options.client, {}, void 0, false, {
|
|
96
|
+
fileName: "../src/realtime-testing/setup-realtime-test.tsx",
|
|
97
|
+
lineNumber: 94,
|
|
98
|
+
columnNumber: 5
|
|
99
|
+
}, this) }, void 0, false, {
|
|
100
|
+
fileName: "../src/realtime-testing/setup-realtime-test.tsx",
|
|
101
|
+
lineNumber: 93,
|
|
102
|
+
columnNumber: 4
|
|
103
|
+
}, this) }, void 0, false, {
|
|
104
|
+
fileName: "../src/realtime-testing/setup-realtime-test.tsx",
|
|
105
|
+
lineNumber: 92,
|
|
106
|
+
columnNumber: 3
|
|
107
|
+
}, this),
|
|
108
|
+
{
|
|
109
|
+
container: document.querySelector(`#app`)
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
const prettyPrint = () => console.log((0, import_react.prettyDOM)(renderResult.container));
|
|
113
|
+
const disconnect = () => socket.disconnect();
|
|
114
|
+
const reconnect = () => socket.connect();
|
|
115
|
+
const dispose = () => {
|
|
116
|
+
socket.disconnect();
|
|
117
|
+
AtomIO.__INTERNAL__.clearStore(silo2.store);
|
|
118
|
+
};
|
|
119
|
+
return {
|
|
120
|
+
name,
|
|
121
|
+
silo: silo2,
|
|
122
|
+
renderResult,
|
|
123
|
+
prettyPrint,
|
|
124
|
+
disconnect,
|
|
125
|
+
reconnect,
|
|
126
|
+
dispose
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
var singleClient = (options) => {
|
|
130
|
+
const server = setupRealtimeTestServer(options);
|
|
131
|
+
const client = setupRealtimeTestClient(options, `CLIENT`, server.port);
|
|
132
|
+
return {
|
|
133
|
+
client,
|
|
134
|
+
server,
|
|
135
|
+
teardown: () => {
|
|
136
|
+
client.dispose();
|
|
137
|
+
server.dispose();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
var multiClient = (options) => {
|
|
142
|
+
const server = setupRealtimeTestServer(options);
|
|
143
|
+
const clients = RR.toEntries(options.clients).reduce(
|
|
144
|
+
(clients2, [name, client]) => __spreadProps(__spreadValues({}, clients2), {
|
|
145
|
+
[name]: setupRealtimeTestClient(__spreadProps(__spreadValues({}, options), { client }), name, server.port)
|
|
146
|
+
}),
|
|
147
|
+
{}
|
|
148
|
+
);
|
|
149
|
+
return {
|
|
150
|
+
clients,
|
|
151
|
+
server,
|
|
152
|
+
teardown: () => {
|
|
153
|
+
RR.toEntries(clients).forEach(([, client]) => client.dispose());
|
|
154
|
+
server.dispose();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {
|
|
160
|
+
multiClient,
|
|
161
|
+
setupRealtimeTestClient,
|
|
162
|
+
setupRealtimeTestServer,
|
|
163
|
+
singleClient
|
|
164
|
+
});
|
|
165
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/realtime-testing/index.ts","../../src/realtime-testing/setup-realtime-test.tsx"],"sourcesContent":["export * from \"./setup-realtime-test\"\n","import * as http from \"http\"\n\nimport { prettyDOM, render, type RenderResult } from \"@testing-library/react\"\nimport * as AtomIO from \"atom.io\"\nimport * as AR from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-react\"\nimport * as RR from \"fp-ts/ReadonlyRecord\"\nimport * as Happy from \"happy-dom\"\nimport * as React from \"react\"\nimport * as SocketIO from \"socket.io\"\nimport type { Socket as ClientSocket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nexport type TestSetupOptions = {\n\tserver: (tools: { socket: SocketIO.Socket; silo: AtomIO.Silo }) => void\n}\nexport type TestSetupOptions__SingleClient = TestSetupOptions & {\n\tclient: React.FC\n}\nexport type TestSetupOptions__MultiClient<ClientNames extends string> =\n\tTestSetupOptions & {\n\t\tclients: {\n\t\t\t[K in ClientNames]: React.FC\n\t\t}\n\t}\n\nexport type RealtimeTestTools = {\n\tname: string\n\tsilo: AtomIO.Silo\n\tdispose: () => void\n}\nexport type RealtimeTestClient = RealtimeTestTools & {\n\trenderResult: RenderResult\n\tprettyPrint: () => void\n\treconnect: () => void\n\tdisconnect: () => void\n}\nexport type RealtimeTestServer = RealtimeTestTools & {\n\tport: number\n}\n\nexport type RealtimeTestAPI = {\n\tserver: RealtimeTestServer\n\tteardown: () => void\n}\nexport type RealtimeTestAPI__SingleClient = RealtimeTestAPI & {\n\tclient: RealtimeTestClient\n}\nexport type RealtimeTestAPI__MultiClient<ClientNames extends string> =\n\tRealtimeTestAPI & {\n\t\tclients: Record<ClientNames, RealtimeTestClient>\n\t}\n\nexport const setupRealtimeTestServer = (\n\toptions: TestSetupOptions,\n): RealtimeTestServer => {\n\tconst httpServer = http.createServer((_, res) => res.end(`Hello World!`))\n\tconst address = httpServer.listen().address()\n\tconst port =\n\t\ttypeof address === `string` ? 80 : address === null ? null : address.port\n\tif (port === null) throw new Error(`Could not determine port for test server`)\n\tconst server = new SocketIO.Server(httpServer)\n\tconst silo = AtomIO.silo(`SERVER`, AtomIO.__INTERNAL__.IMPLICIT.STORE)\n\n\tserver.on(`connection`, (socket: SocketIO.Socket) => {\n\t\toptions.server({ socket, silo })\n\t})\n\n\tconst dispose = () => {\n\t\tserver.close()\n\t\tAtomIO.__INTERNAL__.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname: `SERVER`,\n\t\tsilo,\n\t\tdispose,\n\t\tport,\n\t}\n}\nexport const setupRealtimeTestClient = (\n\toptions: TestSetupOptions__SingleClient,\n\tname: string,\n\tport: number,\n): RealtimeTestClient => {\n\tconst socket: ClientSocket = io(`http://localhost:${port}/`)\n\tconst silo = AtomIO.silo(name, AtomIO.__INTERNAL__.IMPLICIT.STORE)\n\n\tconst { document } = new Happy.Window()\n\tdocument.body.innerHTML = `<div id=\"app\"></div>`\n\tconst renderResult = render(\n\t\t<AR.StoreProvider store={silo.store}>\n\t\t\t<RTC.RealtimeProvider socket={socket}>\n\t\t\t\t<options.client />\n\t\t\t</RTC.RealtimeProvider>\n\t\t</AR.StoreProvider>,\n\t\t{\n\t\t\tcontainer: document.querySelector(`#app`) as unknown as HTMLElement,\n\t\t},\n\t)\n\n\tconst prettyPrint = () => console.log(prettyDOM(renderResult.container))\n\n\tconst disconnect = () => socket.disconnect()\n\tconst reconnect = () => socket.connect()\n\n\tconst dispose = () => {\n\t\tsocket.disconnect()\n\t\tAtomIO.__INTERNAL__.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname,\n\t\tsilo,\n\t\trenderResult,\n\t\tprettyPrint,\n\t\tdisconnect,\n\t\treconnect,\n\t\tdispose,\n\t}\n}\n\nexport const singleClient = (\n\toptions: TestSetupOptions__SingleClient,\n): RealtimeTestAPI__SingleClient => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst client = setupRealtimeTestClient(options, `CLIENT`, server.port)\n\n\treturn {\n\t\tclient,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tclient.dispose()\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n\nexport const multiClient = <ClientNames extends string>(\n\toptions: TestSetupOptions__MultiClient<ClientNames>,\n): RealtimeTestAPI__MultiClient<ClientNames> => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst clients = RR.toEntries(options.clients).reduce(\n\t\t(clients, [name, client]) => ({\n\t\t\t...clients,\n\t\t\t[name]: setupRealtimeTestClient({ ...options, client }, name, server.port),\n\t\t}),\n\t\t{} as Record<ClientNames, RealtimeTestClient>,\n\t)\n\n\treturn {\n\t\tclients,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tRR.toEntries(clients).forEach(([, client]) => client.dispose())\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,WAAsB;AAEtB,mBAAqD;AACrD,aAAwB;AACxB,SAAoB;AACpB,UAAqB;AACrB,SAAoB;AACpB,YAAuB;AAEvB,eAA0B;AAE1B,oBAAmB;AAkFf;AAxCG,IAAM,0BAA0B,CACtC,YACwB;AACxB,QAAM,aAAkB,kBAAa,CAAC,GAAG,QAAQ,IAAI,IAAI,cAAc,CAAC;AACxE,QAAM,UAAU,WAAW,OAAO,EAAE,QAAQ;AAC5C,QAAM,OACL,OAAO,YAAY,WAAW,KAAK,YAAY,OAAO,OAAO,QAAQ;AACtE,MAAI,SAAS;AAAM,UAAM,IAAI,MAAM,0CAA0C;AAC7E,QAAM,SAAS,IAAa,gBAAO,UAAU;AAC7C,QAAMA,QAAc,YAAK,UAAiB,oBAAa,SAAS,KAAK;AAErE,SAAO,GAAG,cAAc,CAAC,WAA4B;AACpD,YAAQ,OAAO,EAAE,QAAQ,MAAAA,MAAK,CAAC;AAAA,EAChC,CAAC;AAED,QAAM,UAAU,MAAM;AACrB,WAAO,MAAM;AACb,IAAO,oBAAa,WAAWA,MAAK,KAAK;AAAA,EAC1C;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN,MAAAA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AACO,IAAM,0BAA0B,CACtC,SACA,MACA,SACwB;AACxB,QAAM,aAAuB,kBAAG,oBAAoB,IAAI,GAAG;AAC3D,QAAMA,QAAc,YAAK,MAAa,oBAAa,SAAS,KAAK;AAEjE,QAAM,EAAE,SAAS,IAAI,I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AO;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,MAAM;AACf,MAAG,aAAU,OAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,MAAM,OAAO,QAAQ,CAAC;AAC9D,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD;","names":["silo","clients"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// ../src/realtime-testing/setup-realtime-test.tsx
|
|
22
|
+
import * as http from "http";
|
|
23
|
+
import { prettyDOM, render } from "@testing-library/react";
|
|
24
|
+
import * as AtomIO from "atom.io";
|
|
25
|
+
import * as AR from "atom.io/react";
|
|
26
|
+
import * as RTC from "atom.io/realtime-react";
|
|
27
|
+
import * as RR from "fp-ts/ReadonlyRecord";
|
|
28
|
+
import * as Happy from "happy-dom";
|
|
29
|
+
import * as SocketIO from "socket.io";
|
|
30
|
+
import { io } from "socket.io-client";
|
|
31
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
32
|
+
var setupRealtimeTestServer = (options) => {
|
|
33
|
+
const httpServer = http.createServer((_, res) => res.end(`Hello World!`));
|
|
34
|
+
const address = httpServer.listen().address();
|
|
35
|
+
const port = typeof address === `string` ? 80 : address === null ? null : address.port;
|
|
36
|
+
if (port === null)
|
|
37
|
+
throw new Error(`Could not determine port for test server`);
|
|
38
|
+
const server = new SocketIO.Server(httpServer);
|
|
39
|
+
const silo2 = AtomIO.silo(`SERVER`, AtomIO.__INTERNAL__.IMPLICIT.STORE);
|
|
40
|
+
server.on(`connection`, (socket) => {
|
|
41
|
+
options.server({ socket, silo: silo2 });
|
|
42
|
+
});
|
|
43
|
+
const dispose = () => {
|
|
44
|
+
server.close();
|
|
45
|
+
AtomIO.__INTERNAL__.clearStore(silo2.store);
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
name: `SERVER`,
|
|
49
|
+
silo: silo2,
|
|
50
|
+
dispose,
|
|
51
|
+
port
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var setupRealtimeTestClient = (options, name, port) => {
|
|
55
|
+
const socket = io(`http://localhost:${port}/`);
|
|
56
|
+
const silo2 = AtomIO.silo(name, AtomIO.__INTERNAL__.IMPLICIT.STORE);
|
|
57
|
+
const { document } = new Happy.Window();
|
|
58
|
+
document.body.innerHTML = `<div id="app"></div>`;
|
|
59
|
+
const renderResult = render(
|
|
60
|
+
/* @__PURE__ */ jsxDEV(AR.StoreProvider, { store: silo2.store, children: /* @__PURE__ */ jsxDEV(RTC.RealtimeProvider, { socket, children: /* @__PURE__ */ jsxDEV(options.client, {}, void 0, false, {
|
|
61
|
+
fileName: "../src/realtime-testing/setup-realtime-test.tsx",
|
|
62
|
+
lineNumber: 94,
|
|
63
|
+
columnNumber: 5
|
|
64
|
+
}, this) }, void 0, false, {
|
|
65
|
+
fileName: "../src/realtime-testing/setup-realtime-test.tsx",
|
|
66
|
+
lineNumber: 93,
|
|
67
|
+
columnNumber: 4
|
|
68
|
+
}, this) }, void 0, false, {
|
|
69
|
+
fileName: "../src/realtime-testing/setup-realtime-test.tsx",
|
|
70
|
+
lineNumber: 92,
|
|
71
|
+
columnNumber: 3
|
|
72
|
+
}, this),
|
|
73
|
+
{
|
|
74
|
+
container: document.querySelector(`#app`)
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
const prettyPrint = () => console.log(prettyDOM(renderResult.container));
|
|
78
|
+
const disconnect = () => socket.disconnect();
|
|
79
|
+
const reconnect = () => socket.connect();
|
|
80
|
+
const dispose = () => {
|
|
81
|
+
socket.disconnect();
|
|
82
|
+
AtomIO.__INTERNAL__.clearStore(silo2.store);
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
name,
|
|
86
|
+
silo: silo2,
|
|
87
|
+
renderResult,
|
|
88
|
+
prettyPrint,
|
|
89
|
+
disconnect,
|
|
90
|
+
reconnect,
|
|
91
|
+
dispose
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
var singleClient = (options) => {
|
|
95
|
+
const server = setupRealtimeTestServer(options);
|
|
96
|
+
const client = setupRealtimeTestClient(options, `CLIENT`, server.port);
|
|
97
|
+
return {
|
|
98
|
+
client,
|
|
99
|
+
server,
|
|
100
|
+
teardown: () => {
|
|
101
|
+
client.dispose();
|
|
102
|
+
server.dispose();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
var multiClient = (options) => {
|
|
107
|
+
const server = setupRealtimeTestServer(options);
|
|
108
|
+
const clients = RR.toEntries(options.clients).reduce(
|
|
109
|
+
(clients2, [name, client]) => __spreadProps(__spreadValues({}, clients2), {
|
|
110
|
+
[name]: setupRealtimeTestClient(__spreadProps(__spreadValues({}, options), { client }), name, server.port)
|
|
111
|
+
}),
|
|
112
|
+
{}
|
|
113
|
+
);
|
|
114
|
+
return {
|
|
115
|
+
clients,
|
|
116
|
+
server,
|
|
117
|
+
teardown: () => {
|
|
118
|
+
RR.toEntries(clients).forEach(([, client]) => client.dispose());
|
|
119
|
+
server.dispose();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
multiClient,
|
|
125
|
+
setupRealtimeTestClient,
|
|
126
|
+
setupRealtimeTestServer,
|
|
127
|
+
singleClient
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/realtime-testing/setup-realtime-test.tsx"],"sourcesContent":["import * as http from \"http\"\n\nimport { prettyDOM, render, type RenderResult } from \"@testing-library/react\"\nimport * as AtomIO from \"atom.io\"\nimport * as AR from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-react\"\nimport * as RR from \"fp-ts/ReadonlyRecord\"\nimport * as Happy from \"happy-dom\"\nimport * as React from \"react\"\nimport * as SocketIO from \"socket.io\"\nimport type { Socket as ClientSocket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nexport type TestSetupOptions = {\n\tserver: (tools: { socket: SocketIO.Socket; silo: AtomIO.Silo }) => void\n}\nexport type TestSetupOptions__SingleClient = TestSetupOptions & {\n\tclient: React.FC\n}\nexport type TestSetupOptions__MultiClient<ClientNames extends string> =\n\tTestSetupOptions & {\n\t\tclients: {\n\t\t\t[K in ClientNames]: React.FC\n\t\t}\n\t}\n\nexport type RealtimeTestTools = {\n\tname: string\n\tsilo: AtomIO.Silo\n\tdispose: () => void\n}\nexport type RealtimeTestClient = RealtimeTestTools & {\n\trenderResult: RenderResult\n\tprettyPrint: () => void\n\treconnect: () => void\n\tdisconnect: () => void\n}\nexport type RealtimeTestServer = RealtimeTestTools & {\n\tport: number\n}\n\nexport type RealtimeTestAPI = {\n\tserver: RealtimeTestServer\n\tteardown: () => void\n}\nexport type RealtimeTestAPI__SingleClient = RealtimeTestAPI & {\n\tclient: RealtimeTestClient\n}\nexport type RealtimeTestAPI__MultiClient<ClientNames extends string> =\n\tRealtimeTestAPI & {\n\t\tclients: Record<ClientNames, RealtimeTestClient>\n\t}\n\nexport const setupRealtimeTestServer = (\n\toptions: TestSetupOptions,\n): RealtimeTestServer => {\n\tconst httpServer = http.createServer((_, res) => res.end(`Hello World!`))\n\tconst address = httpServer.listen().address()\n\tconst port =\n\t\ttypeof address === `string` ? 80 : address === null ? null : address.port\n\tif (port === null) throw new Error(`Could not determine port for test server`)\n\tconst server = new SocketIO.Server(httpServer)\n\tconst silo = AtomIO.silo(`SERVER`, AtomIO.__INTERNAL__.IMPLICIT.STORE)\n\n\tserver.on(`connection`, (socket: SocketIO.Socket) => {\n\t\toptions.server({ socket, silo })\n\t})\n\n\tconst dispose = () => {\n\t\tserver.close()\n\t\tAtomIO.__INTERNAL__.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname: `SERVER`,\n\t\tsilo,\n\t\tdispose,\n\t\tport,\n\t}\n}\nexport const setupRealtimeTestClient = (\n\toptions: TestSetupOptions__SingleClient,\n\tname: string,\n\tport: number,\n): RealtimeTestClient => {\n\tconst socket: ClientSocket = io(`http://localhost:${port}/`)\n\tconst silo = AtomIO.silo(name, AtomIO.__INTERNAL__.IMPLICIT.STORE)\n\n\tconst { document } = new Happy.Window()\n\tdocument.body.innerHTML = `<div id=\"app\"></div>`\n\tconst renderResult = render(\n\t\t<AR.StoreProvider store={silo.store}>\n\t\t\t<RTC.RealtimeProvider socket={socket}>\n\t\t\t\t<options.client />\n\t\t\t</RTC.RealtimeProvider>\n\t\t</AR.StoreProvider>,\n\t\t{\n\t\t\tcontainer: document.querySelector(`#app`) as unknown as HTMLElement,\n\t\t},\n\t)\n\n\tconst prettyPrint = () => console.log(prettyDOM(renderResult.container))\n\n\tconst disconnect = () => socket.disconnect()\n\tconst reconnect = () => socket.connect()\n\n\tconst dispose = () => {\n\t\tsocket.disconnect()\n\t\tAtomIO.__INTERNAL__.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname,\n\t\tsilo,\n\t\trenderResult,\n\t\tprettyPrint,\n\t\tdisconnect,\n\t\treconnect,\n\t\tdispose,\n\t}\n}\n\nexport const singleClient = (\n\toptions: TestSetupOptions__SingleClient,\n): RealtimeTestAPI__SingleClient => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst client = setupRealtimeTestClient(options, `CLIENT`, server.port)\n\n\treturn {\n\t\tclient,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tclient.dispose()\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n\nexport const multiClient = <ClientNames extends string>(\n\toptions: TestSetupOptions__MultiClient<ClientNames>,\n): RealtimeTestAPI__MultiClient<ClientNames> => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst clients = RR.toEntries(options.clients).reduce(\n\t\t(clients, [name, client]) => ({\n\t\t\t...clients,\n\t\t\t[name]: setupRealtimeTestClient({ ...options, client }, name, server.port),\n\t\t}),\n\t\t{} as Record<ClientNames, RealtimeTestClient>,\n\t)\n\n\treturn {\n\t\tclients,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tRR.toEntries(clients).forEach(([, client]) => client.dispose())\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,UAAU;AAEtB,SAAS,WAAW,cAAiC;AACrD,YAAY,YAAY;AACxB,YAAY,QAAQ;AACpB,YAAY,SAAS;AACrB,YAAY,QAAQ;AACpB,YAAY,WAAW;AAEvB,YAAY,cAAc;AAE1B,SAAS,UAAU;AAkFf;AAxCG,IAAM,0BAA0B,CACtC,YACwB;AACxB,QAAM,aAAkB,kBAAa,CAAC,GAAG,QAAQ,IAAI,IAAI,cAAc,CAAC;AACxE,QAAM,UAAU,WAAW,OAAO,EAAE,QAAQ;AAC5C,QAAM,OACL,OAAO,YAAY,WAAW,KAAK,YAAY,OAAO,OAAO,QAAQ;AACtE,MAAI,SAAS;AAAM,UAAM,IAA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ACD;AACD;AAEO,IAAM,eAAe,CAC3B,YACmC;AACnC,QAAM,SAAS,wBAAwB,OAAO;AAC9C,QAAM,SAAS,wBAAwB,SAAS,UAAU,OAAO,IAAI;AAErE,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,MAAM;AACf,aAAO,QAAQ;AACf,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD;AAEO,IAAM,cAAc,CAC1B,YAC+C;AAC/C,QAAM,SAAS,wBAAwB,OAAO;AAC9C,QAAM,UAAa,aAAU,QAAQ,OAAO,EAAE;AAAA,IAC7C,CAACC,UAAS,CAAC,MAAM,MAAM,MAAO,iCAC1BA,WAD0B;AAAA,MAE7B,CAAC,IAAI,GAAG,wBAAwB,iCAAK,UAAL,EAAc,OAAO,IAAG,MAAM,OAAO,IAAI;AAAA,IAC1E;AAAA,IACA,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,MAAM;AACf,MAAG,aAAU,OAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,MAAM,OAAO,QAAQ,CAAC;AAC9D,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD;","names":["silo","clients"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "atom.io-realtime-testing",
|
|
3
|
+
"private": true,
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"browser": "./dist/index.mjs",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|