atom.io 0.6.5 → 0.6.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.
- package/README.md +32 -78
- package/dist/index.d.mts +4 -35
- package/dist/index.d.ts +4 -35
- package/dist/index.js +45 -198
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -195
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.js +312 -0
- package/introspection/dist/index.js.map +1 -0
- package/introspection/dist/index.mjs +289 -0
- package/introspection/dist/index.mjs.map +1 -0
- package/introspection/package.json +15 -0
- package/package.json +16 -6
- package/react-devtools/dist/index.css +22 -5
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +347 -8
- package/react-devtools/dist/index.d.ts +347 -8
- package/react-devtools/dist/index.js +2722 -674
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +2669 -630
- package/react-devtools/dist/index.mjs.map +1 -1
- package/src/internal/index.ts +0 -1
- package/src/internal/operation.ts +1 -0
- package/src/internal/store.ts +3 -2
- package/src/internal/time-travel-internal.ts +2 -0
- package/src/internal/timeline/add-atom-to-timeline.ts +11 -12
- package/src/internal/timeline-internal.ts +5 -1
- package/src/introspection/attach-atom-index.ts +73 -0
- package/src/introspection/attach-introspection-states.ts +42 -0
- package/src/introspection/attach-selector-index.ts +77 -0
- package/src/introspection/attach-timeline-family.ts +49 -0
- package/src/introspection/attach-timeline-index.ts +36 -0
- package/src/introspection/attach-transaction-index.ts +38 -0
- package/src/introspection/attach-transaction-logs.ts +40 -0
- package/src/introspection/index.ts +20 -0
- package/src/react-devtools/AtomIODevtools.tsx +97 -96
- package/src/react-devtools/Button.tsx +24 -0
- package/src/react-devtools/StateEditor.tsx +14 -16
- package/src/react-devtools/StateIndex.tsx +153 -0
- package/src/react-devtools/TimelineIndex.tsx +92 -0
- package/src/react-devtools/TransactionIndex.tsx +70 -0
- package/src/react-devtools/Updates.tsx +145 -0
- package/src/react-devtools/devtools.scss +196 -15
- package/src/react-devtools/index.ts +71 -0
- package/src/react-explorer/AtomIOExplorer.tsx +0 -1
- package/src/react-explorer/explorer-states.ts +1 -1
- package/src/react-explorer/space-states.ts +3 -1
- package/src/react-explorer/view-states.ts +0 -2
- package/realtime-testing/dist/index.d.mts +0 -49
- package/realtime-testing/dist/index.d.ts +0 -49
- package/realtime-testing/dist/index.js +0 -165
- package/realtime-testing/dist/index.js.map +0 -1
- package/realtime-testing/dist/index.mjs +0 -129
- package/realtime-testing/dist/index.mjs.map +0 -1
- package/src/internal/meta/attach-meta.ts +0 -17
- package/src/internal/meta/index.ts +0 -4
- package/src/internal/meta/meta-state.ts +0 -135
- package/src/internal/meta/meta-timelines.ts +0 -1
- package/src/internal/meta/meta-transactions.ts +0 -1
- package/src/react-devtools/TokenList.tsx +0 -61
|
@@ -1,165 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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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,CAAC,EAAE,MAAM,MAAM,OAAO,QAAQ,CAAC;AAC9D,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD;","names":["silo","clients"]}
|
|
@@ -1,129 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,IAAI,MAAM,0CAA0C;AAC7E,QAAM,SAAS,IAAa,gBAAO,UAAU;AAC7C,QAAMA,QAAc,YAAK,UAAiB,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S,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"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { AtomTokenIndex, SelectorTokenIndex } from "./meta-state"
|
|
2
|
-
import { attachMetaAtoms, attachMetaSelectors } from "./meta-state"
|
|
3
|
-
import type { ReadonlySelectorToken } from "../.."
|
|
4
|
-
import type { Store } from "../store"
|
|
5
|
-
import { IMPLICIT } from "../store"
|
|
6
|
-
|
|
7
|
-
export const attachMetaState = (
|
|
8
|
-
store: Store = IMPLICIT.STORE,
|
|
9
|
-
): {
|
|
10
|
-
atomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>
|
|
11
|
-
selectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>
|
|
12
|
-
} => {
|
|
13
|
-
return {
|
|
14
|
-
atomTokenIndexState: attachMetaAtoms(store),
|
|
15
|
-
selectorTokenIndexState: attachMetaSelectors(store),
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "../.."
|
|
2
|
-
import { selector, atom } from "../.."
|
|
3
|
-
import type { Store } from "../store"
|
|
4
|
-
import { IMPLICIT } from "../store"
|
|
5
|
-
|
|
6
|
-
export type StateTokenIndex<
|
|
7
|
-
Token extends
|
|
8
|
-
| AtomToken<unknown>
|
|
9
|
-
| ReadonlySelectorToken<unknown>
|
|
10
|
-
| SelectorToken<unknown>,
|
|
11
|
-
> = Record<
|
|
12
|
-
string,
|
|
13
|
-
| Token
|
|
14
|
-
| {
|
|
15
|
-
key: string
|
|
16
|
-
familyMembers: Record<string, Token>
|
|
17
|
-
}
|
|
18
|
-
>
|
|
19
|
-
|
|
20
|
-
export type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>
|
|
21
|
-
export type SelectorTokenIndex = StateTokenIndex<
|
|
22
|
-
ReadonlySelectorToken<unknown> | SelectorToken<unknown>
|
|
23
|
-
>
|
|
24
|
-
|
|
25
|
-
export const attachMetaAtoms = (
|
|
26
|
-
store: Store = IMPLICIT.STORE,
|
|
27
|
-
): ReadonlySelectorToken<AtomTokenIndex> => {
|
|
28
|
-
const atomTokenIndexState__INTERNAL = atom<AtomTokenIndex>({
|
|
29
|
-
key: `👁🗨_atom_token_index__INTERNAL`,
|
|
30
|
-
default: () =>
|
|
31
|
-
[...store.atoms].reduce<AtomTokenIndex>((acc, [key]) => {
|
|
32
|
-
acc[key] = { key, type: `atom` }
|
|
33
|
-
return acc
|
|
34
|
-
}, {}),
|
|
35
|
-
effects: [
|
|
36
|
-
({ setSelf }) => {
|
|
37
|
-
store.subject.atomCreation.subscribe((atomToken) => {
|
|
38
|
-
if (store.operation.open) {
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
setSelf((state) => {
|
|
42
|
-
const { key, family } = atomToken
|
|
43
|
-
if (family) {
|
|
44
|
-
const { key: familyKey, subKey } = family
|
|
45
|
-
const current = state[familyKey]
|
|
46
|
-
if (current === undefined || `familyMembers` in current) {
|
|
47
|
-
const familyKeyState = current || {
|
|
48
|
-
key: familyKey,
|
|
49
|
-
familyMembers: {},
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
...state,
|
|
53
|
-
[familyKey]: {
|
|
54
|
-
...familyKeyState,
|
|
55
|
-
familyMembers: {
|
|
56
|
-
...familyKeyState.familyMembers,
|
|
57
|
-
[subKey]: atomToken,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
...state,
|
|
65
|
-
[key]: atomToken,
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
})
|
|
72
|
-
return selector({
|
|
73
|
-
key: `👁🗨_atom_token_index`,
|
|
74
|
-
get: ({ get }) => get(atomTokenIndexState__INTERNAL),
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const attachMetaSelectors = (
|
|
79
|
-
store: Store = IMPLICIT.STORE,
|
|
80
|
-
): ReadonlySelectorToken<SelectorTokenIndex> => {
|
|
81
|
-
const readonlySelectorTokenIndexState__INTERNAL = atom<SelectorTokenIndex>({
|
|
82
|
-
key: `👁🗨_selector_token_index__INTERNAL`,
|
|
83
|
-
default: () =>
|
|
84
|
-
Object.assign(
|
|
85
|
-
[...store.readonlySelectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
86
|
-
acc[key] = { key, type: `readonly_selector` }
|
|
87
|
-
return acc
|
|
88
|
-
}, {}),
|
|
89
|
-
[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
90
|
-
acc[key] = { key, type: `selector` }
|
|
91
|
-
return acc
|
|
92
|
-
}, {}),
|
|
93
|
-
),
|
|
94
|
-
effects: [
|
|
95
|
-
({ setSelf }) => {
|
|
96
|
-
store.subject.selectorCreation.subscribe((selectorToken) => {
|
|
97
|
-
if (store.operation.open) {
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
setSelf((state) => {
|
|
101
|
-
const { key, family } = selectorToken
|
|
102
|
-
if (family) {
|
|
103
|
-
const { key: familyKey, subKey } = family
|
|
104
|
-
const current = state[familyKey]
|
|
105
|
-
if (current === undefined || `familyMembers` in current) {
|
|
106
|
-
const familyKeyState = current || {
|
|
107
|
-
key: familyKey,
|
|
108
|
-
familyMembers: {},
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
...state,
|
|
112
|
-
[familyKey]: {
|
|
113
|
-
...familyKeyState,
|
|
114
|
-
familyMembers: {
|
|
115
|
-
...familyKeyState.familyMembers,
|
|
116
|
-
[subKey]: selectorToken,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
...state,
|
|
124
|
-
[key]: selectorToken,
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
})
|
|
131
|
-
return selector({
|
|
132
|
-
key: `👁🗨_selector_token_index`,
|
|
133
|
-
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
|
|
134
|
-
})
|
|
135
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AtomToken,
|
|
3
|
-
ReadonlySelectorToken,
|
|
4
|
-
SelectorToken,
|
|
5
|
-
__INTERNAL__,
|
|
6
|
-
} from "atom.io"
|
|
7
|
-
import { getState } from "atom.io"
|
|
8
|
-
import type { StoreHooks } from "atom.io/react"
|
|
9
|
-
import { Fragment } from "react"
|
|
10
|
-
import type { FC } from "react"
|
|
11
|
-
|
|
12
|
-
import { recordToEntries } from "~/packages/anvl/src/object"
|
|
13
|
-
|
|
14
|
-
import { StoreEditor } from "./StateEditor"
|
|
15
|
-
|
|
16
|
-
export const TokenList: FC<{
|
|
17
|
-
storeHooks: StoreHooks
|
|
18
|
-
tokenIndex: ReadonlySelectorToken<
|
|
19
|
-
__INTERNAL__.META.StateTokenIndex<
|
|
20
|
-
| AtomToken<unknown>
|
|
21
|
-
| ReadonlySelectorToken<unknown>
|
|
22
|
-
| SelectorToken<unknown>
|
|
23
|
-
>
|
|
24
|
-
>
|
|
25
|
-
}> = ({ storeHooks, tokenIndex }) => {
|
|
26
|
-
const tokenIds = storeHooks.useO(tokenIndex)
|
|
27
|
-
return (
|
|
28
|
-
<>
|
|
29
|
-
{Object.entries(tokenIds).map(([key, token]) => {
|
|
30
|
-
let logState: () => void
|
|
31
|
-
return (
|
|
32
|
-
<Fragment key={key}>
|
|
33
|
-
{key.startsWith(`👁🗨_`) ? null : (
|
|
34
|
-
<div className="node">
|
|
35
|
-
{`type` in token
|
|
36
|
-
? ((logState = () => console.log(token, getState(token))),
|
|
37
|
-
(
|
|
38
|
-
<>
|
|
39
|
-
<label onClick={logState} onKeyUp={logState}>
|
|
40
|
-
{key}
|
|
41
|
-
</label>
|
|
42
|
-
<StoreEditor storeHooks={storeHooks} token={token} />
|
|
43
|
-
</>
|
|
44
|
-
))
|
|
45
|
-
: recordToEntries(token.familyMembers).map(([key, token]) => (
|
|
46
|
-
<>
|
|
47
|
-
<label>{key}</label>
|
|
48
|
-
<div key={key} className="node">
|
|
49
|
-
{key}:
|
|
50
|
-
<StoreEditor storeHooks={storeHooks} token={token} />
|
|
51
|
-
</div>
|
|
52
|
-
</>
|
|
53
|
-
))}
|
|
54
|
-
</div>
|
|
55
|
-
)}
|
|
56
|
-
</Fragment>
|
|
57
|
-
)
|
|
58
|
-
})}
|
|
59
|
-
</>
|
|
60
|
-
)
|
|
61
|
-
}
|