atom.io 0.11.0 → 0.12.1
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/data/dist/index.cjs +614 -0
- package/data/dist/index.cjs.map +1 -0
- package/data/dist/index.d.cts +158 -0
- package/data/dist/index.d.ts +118 -1
- package/data/dist/index.js +551 -30
- package/data/dist/index.js.map +1 -1
- package/data/dist/metafile-cjs.json +1 -0
- package/data/dist/metafile-esm.json +1 -0
- package/data/package.json +4 -3
- package/data/src/index.ts +1 -0
- package/data/src/join.ts +450 -0
- package/data/src/struct-family.ts +34 -24
- package/data/src/struct.ts +6 -8
- package/dist/index.cjs +257 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +10 -11
- package/dist/index.d.ts +10 -11
- package/dist/index.js +63 -104
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/internal/dist/{index.mjs → index.cjs} +716 -495
- package/internal/dist/index.cjs.map +1 -0
- package/internal/dist/{index.d.mts → index.d.cts} +124 -105
- package/internal/dist/index.d.ts +124 -105
- package/internal/dist/index.js +651 -555
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/metafile-cjs.json +1 -0
- package/internal/dist/metafile-esm.json +1 -0
- package/internal/package.json +4 -3
- package/internal/src/atom/create-atom.ts +29 -16
- package/internal/src/atom/delete-atom.ts +25 -6
- package/internal/src/atom/is-default.ts +4 -17
- package/internal/src/caching.ts +28 -23
- package/internal/src/families/create-atom-family.ts +3 -2
- package/internal/src/families/create-readonly-selector-family.ts +1 -1
- package/internal/src/families/create-selector-family.ts +4 -4
- package/internal/src/index.ts +4 -2
- package/internal/src/lazy-map.ts +33 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +2 -2
- package/internal/src/mutable/create-mutable-atom.ts +1 -2
- package/internal/src/mutable/get-json-family.ts +22 -0
- package/internal/src/mutable/get-json-token.ts +1 -0
- package/internal/src/mutable/index.ts +1 -0
- package/internal/src/mutable/tracker-family.ts +1 -2
- package/internal/src/mutable/tracker.ts +8 -6
- package/internal/src/mutable/transceiver.ts +2 -0
- package/internal/src/not-found-error.ts +27 -0
- package/internal/src/operation.ts +2 -3
- package/internal/src/{get-state-internal.ts → read-or-compute-value.ts} +13 -6
- package/internal/src/selector/create-selector.ts +6 -7
- package/internal/src/selector/delete-selector.ts +37 -0
- package/internal/src/selector/index.ts +2 -1
- package/internal/src/selector/register-selector.ts +7 -7
- package/internal/src/set-state/copy-mutable-in-transaction.ts +3 -2
- package/internal/src/set-state/emit-update.ts +1 -3
- package/internal/src/set-state/evict-downstream.ts +6 -8
- package/internal/src/set-state/index.ts +1 -1
- package/internal/src/set-state/{set-state-internal.ts → set-atom-or-selector.ts} +2 -3
- package/internal/src/set-state/set-atom.ts +5 -6
- package/internal/src/store/store.ts +1 -1
- package/internal/src/store/withdraw-new-family-member.ts +6 -6
- package/internal/src/subscribe/recall-state.ts +1 -2
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +2 -2
- package/internal/src/timeline/add-atom-to-timeline.ts +5 -16
- package/internal/src/timeline/{timeline-internal.ts → create-timeline.ts} +4 -5
- package/internal/src/timeline/index.ts +2 -2
- package/internal/src/timeline/time-travel.ts +89 -0
- package/internal/src/transaction/build-transaction.ts +8 -7
- package/internal/src/transaction/{transaction-internal.ts → create-transaction.ts} +6 -5
- package/internal/src/transaction/index.ts +2 -3
- package/introspection/dist/{index.mjs → index.cjs} +54 -29
- package/introspection/dist/index.cjs.map +1 -0
- package/introspection/dist/{index.d.mts → index.d.cts} +2 -2
- package/introspection/dist/index.d.ts +2 -2
- package/introspection/dist/index.js +32 -49
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/metafile-cjs.json +1 -0
- package/introspection/dist/metafile-esm.json +1 -0
- package/introspection/package.json +4 -3
- package/introspection/src/attach-introspection-states.ts +2 -2
- package/introspection/src/attach-selector-index.ts +8 -4
- package/json/dist/{index.mjs → index.cjs} +20 -7
- package/json/dist/{index.mjs.map → index.cjs.map} +1 -1
- package/json/dist/{index.d.mts → index.d.cts} +1 -1
- package/json/dist/index.d.ts +1 -1
- package/json/dist/index.js +6 -19
- package/json/dist/index.js.map +1 -1
- package/json/dist/metafile-cjs.json +1 -0
- package/json/dist/metafile-esm.json +1 -0
- package/json/package.json +4 -3
- package/package.json +48 -47
- package/react/dist/index.cjs +59 -0
- package/react/dist/index.cjs.map +1 -0
- package/react/dist/index.js +20 -42
- package/react/dist/index.js.map +1 -1
- package/react/dist/metafile-cjs.json +1 -0
- package/react/dist/metafile-esm.json +1 -0
- package/react/package.json +4 -3
- package/react/src/store-hooks.ts +8 -2
- package/react-devtools/dist/{index.mjs → index.cjs} +286 -240
- package/react-devtools/dist/index.cjs.map +1 -0
- package/react-devtools/dist/{index.d.mts → index.d.cts} +29 -17
- package/react-devtools/dist/index.d.ts +29 -17
- package/react-devtools/dist/index.js +251 -273
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/metafile-cjs.json +1 -0
- package/react-devtools/dist/metafile-esm.json +1 -0
- package/react-devtools/package.json +4 -3
- package/react-devtools/src/StateEditor.tsx +8 -8
- package/realtime-client/dist/{index.mjs → index.cjs} +50 -21
- package/realtime-client/dist/index.js +20 -49
- package/realtime-client/dist/metafile-cjs.json +1 -0
- package/realtime-client/dist/metafile-esm.json +1 -0
- package/realtime-client/package.json +4 -3
- package/realtime-react/dist/index.cjs +99 -0
- package/realtime-react/dist/index.js +35 -66
- package/realtime-react/dist/metafile-cjs.json +1 -0
- package/realtime-react/dist/metafile-esm.json +1 -0
- package/realtime-react/package.json +4 -3
- package/realtime-server/dist/{index.mjs → index.cjs} +67 -40
- package/realtime-server/dist/index.js +39 -66
- package/realtime-server/dist/metafile-cjs.json +1 -0
- package/realtime-server/dist/metafile-esm.json +1 -0
- package/realtime-server/package.json +4 -3
- package/realtime-testing/dist/{index.mjs → index.cjs} +54 -23
- package/realtime-testing/dist/index.js +22 -53
- package/realtime-testing/dist/metafile-cjs.json +1 -0
- package/realtime-testing/dist/metafile-esm.json +1 -0
- package/realtime-testing/package.json +4 -3
- package/src/atom.ts +6 -8
- package/src/dispose.ts +18 -0
- package/src/get-state.ts +16 -0
- package/src/index.ts +3 -1
- package/src/logger.ts +1 -1
- package/src/selector.ts +3 -3
- package/src/set-state.ts +22 -0
- package/src/silo.ts +7 -8
- package/src/timeline.ts +6 -11
- package/src/transaction.ts +2 -2
- package/transceivers/set-rtx/dist/{index.mjs → index.cjs} +40 -36
- package/transceivers/set-rtx/dist/index.cjs.map +1 -0
- package/transceivers/set-rtx/dist/{index.d.mts → index.d.cts} +2 -1
- package/transceivers/set-rtx/dist/index.d.ts +2 -1
- package/transceivers/set-rtx/dist/index.js +37 -37
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/transceivers/set-rtx/dist/metafile-cjs.json +1 -0
- package/transceivers/set-rtx/dist/metafile-esm.json +1 -0
- package/transceivers/set-rtx/package.json +4 -3
- package/transceivers/set-rtx/src/set-rtx.ts +29 -26
- package/data/dist/index.d.mts +0 -41
- package/data/dist/index.mjs +0 -82
- package/data/dist/index.mjs.map +0 -1
- package/dist/index.mjs +0 -215
- package/dist/index.mjs.map +0 -1
- package/internal/dist/index.mjs.map +0 -1
- package/internal/src/set-state/set-selector-state.ts +0 -8
- package/internal/src/timeline/time-travel-internal.ts +0 -109
- package/introspection/dist/index.mjs.map +0 -1
- package/react/dist/index.mjs +0 -29
- package/react/dist/index.mjs.map +0 -1
- package/react-devtools/dist/index.mjs.map +0 -1
- package/realtime-react/dist/index.mjs +0 -68
- package/src/get-set.ts +0 -48
- package/transceivers/set-rtx/dist/index.mjs.map +0 -1
- /package/react/dist/{index.d.mts → index.d.cts} +0 -0
- /package/realtime-client/dist/{index.mjs.map → index.cjs.map} +0 -0
- /package/realtime-client/dist/{index.d.mts → index.d.cts} +0 -0
- /package/realtime-react/dist/{index.mjs.map → index.cjs.map} +0 -0
- /package/realtime-react/dist/{index.d.mts → index.d.cts} +0 -0
- /package/realtime-server/dist/{index.mjs.map → index.cjs.map} +0 -0
- /package/realtime-server/dist/{index.d.mts → index.d.cts} +0 -0
- /package/realtime-testing/dist/{index.mjs.map → index.cjs.map} +0 -0
- /package/realtime-testing/dist/{index.d.mts → index.d.cts} +0 -0
|
@@ -1,41 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var socket_ioClient = require('socket.io-client');
|
|
12
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
-
|
|
14
|
-
function _interopNamespace(e) {
|
|
15
|
-
if (e && e.__esModule) return e;
|
|
16
|
-
var n = Object.create(null);
|
|
17
|
-
if (e) {
|
|
18
|
-
Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !== 'default') {
|
|
20
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return e[k]; }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
n.default = e;
|
|
29
|
-
return Object.freeze(n);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var http__namespace = /*#__PURE__*/_interopNamespace(http);
|
|
33
|
-
var AtomIO__namespace = /*#__PURE__*/_interopNamespace(AtomIO);
|
|
34
|
-
var Internal__namespace = /*#__PURE__*/_interopNamespace(Internal);
|
|
35
|
-
var AR__namespace = /*#__PURE__*/_interopNamespace(AR);
|
|
36
|
-
var RTC__namespace = /*#__PURE__*/_interopNamespace(RTC);
|
|
37
|
-
var Happy__namespace = /*#__PURE__*/_interopNamespace(Happy);
|
|
38
|
-
var SocketIO__namespace = /*#__PURE__*/_interopNamespace(SocketIO);
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import { render, prettyDOM } from '@testing-library/react';
|
|
3
|
+
import * as AtomIO from 'atom.io';
|
|
4
|
+
import * as Internal from 'atom.io/internal';
|
|
5
|
+
import * as AR from 'atom.io/react';
|
|
6
|
+
import * as RTC from 'atom.io/realtime-react';
|
|
7
|
+
import * as Happy from 'happy-dom';
|
|
8
|
+
import * as SocketIO from 'socket.io';
|
|
9
|
+
import { io } from 'socket.io-client';
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
39
11
|
|
|
40
12
|
var __defProp = Object.defineProperty;
|
|
41
13
|
var __defProps = Object.defineProperties;
|
|
@@ -60,19 +32,19 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
60
32
|
// ../../anvl/src/object/entries.ts
|
|
61
33
|
var recordToEntries = (obj) => Object.entries(obj);
|
|
62
34
|
var setupRealtimeTestServer = (options) => {
|
|
63
|
-
const httpServer =
|
|
35
|
+
const httpServer = http.createServer((_, res) => res.end(`Hello World!`));
|
|
64
36
|
const address = httpServer.listen().address();
|
|
65
37
|
const port = typeof address === `string` ? 80 : address === null ? null : address.port;
|
|
66
38
|
if (port === null)
|
|
67
39
|
throw new Error(`Could not determine port for test server`);
|
|
68
|
-
const server = new
|
|
69
|
-
const silo = new
|
|
40
|
+
const server = new SocketIO.Server(httpServer);
|
|
41
|
+
const silo = new AtomIO.Silo(`SERVER`, Internal.IMPLICIT.STORE);
|
|
70
42
|
server.on(`connection`, (socket) => {
|
|
71
43
|
options.server({ socket, silo });
|
|
72
44
|
});
|
|
73
45
|
const dispose = () => {
|
|
74
46
|
server.close();
|
|
75
|
-
|
|
47
|
+
Internal.clearStore(silo.store);
|
|
76
48
|
};
|
|
77
49
|
return {
|
|
78
50
|
name: `SERVER`,
|
|
@@ -82,22 +54,22 @@ var setupRealtimeTestServer = (options) => {
|
|
|
82
54
|
};
|
|
83
55
|
};
|
|
84
56
|
var setupRealtimeTestClient = (options, name, port) => {
|
|
85
|
-
const socket =
|
|
86
|
-
const silo = new
|
|
87
|
-
const { document } = new
|
|
57
|
+
const socket = io(`http://localhost:${port}/`);
|
|
58
|
+
const silo = new AtomIO.Silo(name, Internal.IMPLICIT.STORE);
|
|
59
|
+
const { document } = new Happy.Window();
|
|
88
60
|
document.body.innerHTML = `<div id="app"></div>`;
|
|
89
|
-
const renderResult =
|
|
90
|
-
/* @__PURE__ */
|
|
61
|
+
const renderResult = render(
|
|
62
|
+
/* @__PURE__ */ jsx(AR.StoreProvider, { store: silo.store, children: /* @__PURE__ */ jsx(RTC.RealtimeProvider, { socket, children: /* @__PURE__ */ jsx(options.client, {}) }) }),
|
|
91
63
|
{
|
|
92
64
|
container: document.querySelector(`#app`)
|
|
93
65
|
}
|
|
94
66
|
);
|
|
95
|
-
const prettyPrint = () => console.log(
|
|
67
|
+
const prettyPrint = () => console.log(prettyDOM(renderResult.container));
|
|
96
68
|
const disconnect = () => socket.disconnect();
|
|
97
69
|
const reconnect = () => socket.connect();
|
|
98
70
|
const dispose = () => {
|
|
99
71
|
socket.disconnect();
|
|
100
|
-
|
|
72
|
+
Internal.clearStore(silo.store);
|
|
101
73
|
};
|
|
102
74
|
return {
|
|
103
75
|
name,
|
|
@@ -146,9 +118,6 @@ var multiClient = (options) => {
|
|
|
146
118
|
};
|
|
147
119
|
};
|
|
148
120
|
|
|
149
|
-
|
|
150
|
-
exports.setupRealtimeTestClient = setupRealtimeTestClient;
|
|
151
|
-
exports.setupRealtimeTestServer = setupRealtimeTestServer;
|
|
152
|
-
exports.singleClient = singleClient;
|
|
121
|
+
export { multiClient, setupRealtimeTestClient, setupRealtimeTestServer, singleClient };
|
|
153
122
|
//# sourceMappingURL=out.js.map
|
|
154
123
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"../../anvl/src/function/curry.ts":{"bytes":3368,"imports":[],"format":"esm"},"../../anvl/src/function/pipe.ts":{"bytes":6357,"imports":[],"format":"esm"},"../../anvl/src/function/index.ts":{"bytes":1737,"imports":[{"path":"../../anvl/src/function/curry.ts","kind":"import-statement","original":"./curry"},{"path":"../../anvl/src/function/pipe.ts","kind":"import-statement","original":"./pipe"}],"format":"esm"},"../../anvl/src/array/match.ts":{"bytes":696,"imports":[],"format":"esm"},"../../anvl/src/array/venn.ts":{"bytes":1033,"imports":[],"format":"esm"},"../../anvl/src/array/index.ts":{"bytes":2489,"imports":[{"path":"../../anvl/src/array/match.ts","kind":"import-statement","original":"./match"},{"path":"../../anvl/src/array/venn.ts","kind":"import-statement","original":"./venn"}],"format":"esm"},"../../anvl/src/nullish/index.ts":{"bytes":941,"imports":[],"format":"esm"},"../../anvl/src/object/access.ts":{"bytes":381,"imports":[],"format":"esm"},"../../anvl/src/object/entries.ts":{"bytes":348,"imports":[],"format":"esm"},"../../anvl/src/object/mapObject.ts":{"bytes":496,"imports":[{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/array/index.ts","kind":"import-statement","original":"../array"},{"path":"../../anvl/src/object/entries.ts","kind":"import-statement","original":"./entries"}],"format":"esm"},"../../anvl/src/object/refinement.ts":{"bytes":2473,"imports":[{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/array/index.ts","kind":"import-statement","original":"../array"},{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/nullish/index.ts","kind":"import-statement","original":"../nullish"},{"path":"../../anvl/src/object/access.ts","kind":"import-statement","original":"./access"},{"path":"../../anvl/src/object/entries.ts","kind":"import-statement","original":"./entries"},{"path":"../../anvl/src/object/mapObject.ts","kind":"import-statement","original":"./mapObject"}],"format":"esm"},"../../anvl/src/object/sprawl.ts":{"bytes":1069,"imports":[{"path":"../../anvl/src/object/refinement.ts","kind":"import-statement","original":"./refinement"}],"format":"esm"},"../../anvl/src/object/deepMob.ts":{"bytes":1322,"imports":[{"path":"../../anvl/src/array/index.ts","kind":"import-statement","original":"../array"},{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/object/sprawl.ts","kind":"import-statement","original":"./sprawl"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"../../anvl/src/object/modify.ts":{"bytes":745,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"../../anvl/src/object/patch.ts":{"bytes":940,"imports":[{"path":"../../anvl/src/object/access.ts","kind":"import-statement","original":"./access"},{"path":"../../anvl/src/object/refinement.ts","kind":"import-statement","original":"./refinement"},{"path":"../../anvl/src/object/sprawl.ts","kind":"import-statement","original":"./sprawl"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"../../anvl/src/object/index.ts":{"bytes":3846,"imports":[{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/array/index.ts","kind":"import-statement","original":"../array"},{"path":"../../anvl/src/nullish/index.ts","kind":"import-statement","original":"../nullish"},{"path":"../../anvl/src/object/deepMob.ts","kind":"import-statement","original":"./deepMob"},{"path":"../../anvl/src/object/entries.ts","kind":"import-statement","original":"./entries"},{"path":"../../anvl/src/object/refinement.ts","kind":"import-statement","original":"./refinement"},{"path":"../../anvl/src/object/access.ts","kind":"import-statement","original":"./access"},{"path":"../../anvl/src/object/deepMob.ts","kind":"import-statement","original":"./deepMob"},{"path":"../../anvl/src/object/entries.ts","kind":"import-statement","original":"./entries"},{"path":"../../anvl/src/object/mapObject.ts","kind":"import-statement","original":"./mapObject"},{"path":"../../anvl/src/object/modify.ts","kind":"import-statement","original":"./modify"},{"path":"../../anvl/src/object/patch.ts","kind":"import-statement","original":"./patch"},{"path":"../../anvl/src/object/refinement.ts","kind":"import-statement","original":"./refinement"},{"path":"../../anvl/src/object/sprawl.ts","kind":"import-statement","original":"./sprawl"}],"format":"esm"},"src/setup-realtime-test.tsx":{"bytes":4212,"imports":[{"path":"http","kind":"import-statement","external":true},{"path":"@testing-library/react","kind":"import-statement","external":true},{"path":"atom.io","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/react","kind":"import-statement","external":true},{"path":"atom.io/realtime-react","kind":"import-statement","external":true},{"path":"happy-dom","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"socket.io","kind":"import-statement","external":true},{"path":"socket.io-client","kind":"import-statement","external":true},{"path":"../../anvl/src/object/index.ts","kind":"import-statement","original":"~/packages/anvl/src/object"},{"path":"<runtime>","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":38,"imports":[{"path":"src/setup-realtime-test.tsx","kind":"import-statement","original":"./setup-realtime-test"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7159},"dist/index.cjs":{"imports":[{"path":"http","kind":"import-statement","external":true},{"path":"@testing-library/react","kind":"import-statement","external":true},{"path":"atom.io","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/react","kind":"import-statement","external":true},{"path":"atom.io/realtime-react","kind":"import-statement","external":true},{"path":"happy-dom","kind":"import-statement","external":true},{"path":"socket.io","kind":"import-statement","external":true},{"path":"socket.io-client","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["multiClient","setupRealtimeTestClient","setupRealtimeTestServer","singleClient"],"entryPoint":"src/index.ts","inputs":{"src/setup-realtime-test.tsx":{"bytesInOutput":2881},"../../anvl/src/object/entries.ts":{"bytesInOutput":52},"src/index.ts":{"bytesInOutput":0}},"bytes":3983}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"../../anvl/src/function/curry.ts":{"bytes":3368,"imports":[],"format":"esm"},"../../anvl/src/function/pipe.ts":{"bytes":6357,"imports":[],"format":"esm"},"../../anvl/src/function/index.ts":{"bytes":1737,"imports":[{"path":"../../anvl/src/function/curry.ts","kind":"import-statement","original":"./curry"},{"path":"../../anvl/src/function/pipe.ts","kind":"import-statement","original":"./pipe"}],"format":"esm"},"../../anvl/src/array/match.ts":{"bytes":696,"imports":[],"format":"esm"},"../../anvl/src/array/venn.ts":{"bytes":1033,"imports":[],"format":"esm"},"../../anvl/src/array/index.ts":{"bytes":2489,"imports":[{"path":"../../anvl/src/array/match.ts","kind":"import-statement","original":"./match"},{"path":"../../anvl/src/array/venn.ts","kind":"import-statement","original":"./venn"}],"format":"esm"},"../../anvl/src/nullish/index.ts":{"bytes":941,"imports":[],"format":"esm"},"../../anvl/src/object/access.ts":{"bytes":381,"imports":[],"format":"esm"},"../../anvl/src/object/entries.ts":{"bytes":348,"imports":[],"format":"esm"},"../../anvl/src/object/mapObject.ts":{"bytes":496,"imports":[{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/array/index.ts","kind":"import-statement","original":"../array"},{"path":"../../anvl/src/object/entries.ts","kind":"import-statement","original":"./entries"}],"format":"esm"},"../../anvl/src/object/refinement.ts":{"bytes":2473,"imports":[{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/array/index.ts","kind":"import-statement","original":"../array"},{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/nullish/index.ts","kind":"import-statement","original":"../nullish"},{"path":"../../anvl/src/object/access.ts","kind":"import-statement","original":"./access"},{"path":"../../anvl/src/object/entries.ts","kind":"import-statement","original":"./entries"},{"path":"../../anvl/src/object/mapObject.ts","kind":"import-statement","original":"./mapObject"}],"format":"esm"},"../../anvl/src/object/sprawl.ts":{"bytes":1069,"imports":[{"path":"../../anvl/src/object/refinement.ts","kind":"import-statement","original":"./refinement"}],"format":"esm"},"../../anvl/src/object/deepMob.ts":{"bytes":1322,"imports":[{"path":"../../anvl/src/array/index.ts","kind":"import-statement","original":"../array"},{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/object/sprawl.ts","kind":"import-statement","original":"./sprawl"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"../../anvl/src/object/modify.ts":{"bytes":745,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"../../anvl/src/object/patch.ts":{"bytes":940,"imports":[{"path":"../../anvl/src/object/access.ts","kind":"import-statement","original":"./access"},{"path":"../../anvl/src/object/refinement.ts","kind":"import-statement","original":"./refinement"},{"path":"../../anvl/src/object/sprawl.ts","kind":"import-statement","original":"./sprawl"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"../../anvl/src/object/index.ts":{"bytes":3846,"imports":[{"path":"../../anvl/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"../../anvl/src/array/index.ts","kind":"import-statement","original":"../array"},{"path":"../../anvl/src/nullish/index.ts","kind":"import-statement","original":"../nullish"},{"path":"../../anvl/src/object/deepMob.ts","kind":"import-statement","original":"./deepMob"},{"path":"../../anvl/src/object/entries.ts","kind":"import-statement","original":"./entries"},{"path":"../../anvl/src/object/refinement.ts","kind":"import-statement","original":"./refinement"},{"path":"../../anvl/src/object/access.ts","kind":"import-statement","original":"./access"},{"path":"../../anvl/src/object/deepMob.ts","kind":"import-statement","original":"./deepMob"},{"path":"../../anvl/src/object/entries.ts","kind":"import-statement","original":"./entries"},{"path":"../../anvl/src/object/mapObject.ts","kind":"import-statement","original":"./mapObject"},{"path":"../../anvl/src/object/modify.ts","kind":"import-statement","original":"./modify"},{"path":"../../anvl/src/object/patch.ts","kind":"import-statement","original":"./patch"},{"path":"../../anvl/src/object/refinement.ts","kind":"import-statement","original":"./refinement"},{"path":"../../anvl/src/object/sprawl.ts","kind":"import-statement","original":"./sprawl"}],"format":"esm"},"src/setup-realtime-test.tsx":{"bytes":4212,"imports":[{"path":"http","kind":"import-statement","external":true},{"path":"@testing-library/react","kind":"import-statement","external":true},{"path":"atom.io","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/react","kind":"import-statement","external":true},{"path":"atom.io/realtime-react","kind":"import-statement","external":true},{"path":"happy-dom","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"socket.io","kind":"import-statement","external":true},{"path":"socket.io-client","kind":"import-statement","external":true},{"path":"../../anvl/src/object/index.ts","kind":"import-statement","original":"~/packages/anvl/src/object"},{"path":"<runtime>","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":38,"imports":[{"path":"src/setup-realtime-test.tsx","kind":"import-statement","original":"./setup-realtime-test"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":7159},"dist/index.js":{"imports":[{"path":"http","kind":"import-statement","external":true},{"path":"@testing-library/react","kind":"import-statement","external":true},{"path":"atom.io","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/react","kind":"import-statement","external":true},{"path":"atom.io/realtime-react","kind":"import-statement","external":true},{"path":"happy-dom","kind":"import-statement","external":true},{"path":"socket.io","kind":"import-statement","external":true},{"path":"socket.io-client","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["multiClient","setupRealtimeTestClient","setupRealtimeTestServer","singleClient"],"entryPoint":"src/index.ts","inputs":{"src/setup-realtime-test.tsx":{"bytesInOutput":2881},"../../anvl/src/object/entries.ts":{"bytesInOutput":52},"src/index.ts":{"bytesInOutput":0}},"bytes":3983}}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io-realtime-testing",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"private": true,
|
|
4
5
|
"main": "dist/index.js",
|
|
5
6
|
"types": "dist/index.d.ts",
|
|
@@ -7,9 +8,9 @@
|
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"types": "./dist/index.d.ts",
|
|
10
|
-
"browser": "./dist/index.
|
|
11
|
-
"import": "./dist/index.
|
|
12
|
-
"require": "./dist/index.
|
|
11
|
+
"browser": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
}
|
package/src/atom.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import type { Subject, Transceiver } from "atom.io/internal"
|
|
2
2
|
import {
|
|
3
|
+
IMPLICIT,
|
|
3
4
|
createAtom,
|
|
4
5
|
createAtomFamily,
|
|
5
6
|
createMutableAtom,
|
|
6
7
|
createMutableAtomFamily,
|
|
7
|
-
deleteAtom,
|
|
8
8
|
} from "atom.io/internal"
|
|
9
9
|
import type { Json, JsonInterface } from "atom.io/json"
|
|
10
10
|
|
|
11
11
|
import type { AtomToken, MutableAtomToken } from "."
|
|
12
12
|
|
|
13
|
-
export { deleteAtom }
|
|
14
|
-
|
|
15
13
|
export type Effectors<T> = {
|
|
16
14
|
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void
|
|
17
15
|
onSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
export type AtomEffect<T> = (tools: Effectors<T>) => void
|
|
18
|
+
export type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void
|
|
21
19
|
|
|
22
20
|
export type AtomOptions<T> = {
|
|
23
21
|
key: string
|
|
@@ -41,9 +39,9 @@ export function atom<T>(
|
|
|
41
39
|
options: AtomOptions<any> | MutableAtomOptions<any, any>,
|
|
42
40
|
): AtomToken<any> {
|
|
43
41
|
if (`mutable` in options) {
|
|
44
|
-
return createMutableAtom(options)
|
|
42
|
+
return createMutableAtom(options, IMPLICIT.STORE)
|
|
45
43
|
}
|
|
46
|
-
return createAtom<T>(options)
|
|
44
|
+
return createAtom<T>(options, undefined, IMPLICIT.STORE)
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
export type AtomFamilyOptions<T, K extends Json.Serializable> = {
|
|
@@ -95,7 +93,7 @@ export function atomFamily<T, K extends Json.Serializable>(
|
|
|
95
93
|
options: AtomFamilyOptions<T, K> | MutableAtomFamilyOptions<any, any, any>,
|
|
96
94
|
): AtomFamily<T, K> | MutableAtomFamily<any, any, any> {
|
|
97
95
|
if (`mutable` in options) {
|
|
98
|
-
return createMutableAtomFamily(options)
|
|
96
|
+
return createMutableAtomFamily(options, IMPLICIT.STORE)
|
|
99
97
|
}
|
|
100
|
-
return createAtomFamily<T, K>(options)
|
|
98
|
+
return createAtomFamily<T, K>(options, IMPLICIT.STORE)
|
|
101
99
|
}
|
package/src/dispose.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as Internal from "atom.io/internal"
|
|
2
|
+
|
|
3
|
+
import type { ReadonlySelectorToken, StateToken } from "."
|
|
4
|
+
|
|
5
|
+
export function dispose(
|
|
6
|
+
token: ReadonlySelectorToken<any> | StateToken<any>,
|
|
7
|
+
store: Internal.Store = Internal.IMPLICIT.STORE,
|
|
8
|
+
): void {
|
|
9
|
+
switch (token.type) {
|
|
10
|
+
case `atom`:
|
|
11
|
+
Internal.deleteAtom(token, store)
|
|
12
|
+
break
|
|
13
|
+
case `selector`:
|
|
14
|
+
case `readonly_selector`:
|
|
15
|
+
Internal.deleteSelector(token, store)
|
|
16
|
+
break
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/get-state.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as Internal from "atom.io/internal"
|
|
2
|
+
|
|
3
|
+
import type { ReadonlySelectorToken, StateToken } from "."
|
|
4
|
+
|
|
5
|
+
export function getState<T>(
|
|
6
|
+
token: ReadonlySelectorToken<T> | StateToken<T>,
|
|
7
|
+
store: Internal.Store = Internal.IMPLICIT.STORE,
|
|
8
|
+
): T {
|
|
9
|
+
const state =
|
|
10
|
+
Internal.withdraw(token, store) ??
|
|
11
|
+
Internal.withdrawNewFamilyMember(token, store)
|
|
12
|
+
if (state === undefined) {
|
|
13
|
+
throw new Internal.NotFoundError(token, store)
|
|
14
|
+
}
|
|
15
|
+
return Internal.readOrComputeValue(state, store)
|
|
16
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,9 +2,11 @@ import type { Transceiver } from "atom.io/internal"
|
|
|
2
2
|
import type { Json } from "atom.io/json"
|
|
3
3
|
|
|
4
4
|
export * from "./atom"
|
|
5
|
-
export * from "./
|
|
5
|
+
export * from "./dispose"
|
|
6
|
+
export * from "./get-state"
|
|
6
7
|
export * from "./logger"
|
|
7
8
|
export * from "./selector"
|
|
9
|
+
export * from "./set-state"
|
|
8
10
|
export * from "./silo"
|
|
9
11
|
export * from "./subscribe"
|
|
10
12
|
export * from "./timeline"
|
package/src/logger.ts
CHANGED
|
@@ -40,7 +40,7 @@ const LoggerIconDictionary = {
|
|
|
40
40
|
export type LoggerIcon = keyof typeof LoggerIconDictionary
|
|
41
41
|
|
|
42
42
|
export const LOG_LEVELS = [`info`, `warn`, `error`] as const
|
|
43
|
-
export type LogLevel = typeof LOG_LEVELS[number]
|
|
43
|
+
export type LogLevel = (typeof LOG_LEVELS)[number]
|
|
44
44
|
|
|
45
45
|
export type LogFn = (
|
|
46
46
|
icon: LoggerIcon,
|
package/src/selector.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Subject } from "atom.io/internal"
|
|
2
|
-
import { createSelector, createSelectorFamily } from "atom.io/internal"
|
|
2
|
+
import { IMPLICIT, createSelector, createSelectorFamily } from "atom.io/internal"
|
|
3
3
|
import type { Json } from "atom.io/json"
|
|
4
4
|
|
|
5
5
|
import type { ReadonlySelectorToken, SelectorToken } from "."
|
|
@@ -22,7 +22,7 @@ export function selector<T>(
|
|
|
22
22
|
export function selector<T>(
|
|
23
23
|
options: ReadonlySelectorOptions<T> | SelectorOptions<T>,
|
|
24
24
|
): ReadonlySelectorToken<T> | SelectorToken<T> {
|
|
25
|
-
return createSelector(options)
|
|
25
|
+
return createSelector(options, undefined, IMPLICIT.STORE)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export type SelectorFamilyOptions<T, K extends Json.Serializable> = {
|
|
@@ -62,5 +62,5 @@ export function selectorFamily<T, K extends Json.Serializable>(
|
|
|
62
62
|
export function selectorFamily<T, K extends Json.Serializable>(
|
|
63
63
|
options: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,
|
|
64
64
|
): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {
|
|
65
|
-
return createSelectorFamily(options)
|
|
65
|
+
return createSelectorFamily(options, IMPLICIT.STORE)
|
|
66
66
|
}
|
package/src/set-state.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Internal from "atom.io/internal"
|
|
2
|
+
|
|
3
|
+
import type { StateToken } from "."
|
|
4
|
+
|
|
5
|
+
export function setState<T, New extends T>(
|
|
6
|
+
token: StateToken<T>,
|
|
7
|
+
value: New | ((oldValue: T) => New),
|
|
8
|
+
store: Internal.Store = Internal.IMPLICIT.STORE,
|
|
9
|
+
): void {
|
|
10
|
+
const rejection = Internal.openOperation(token, store)
|
|
11
|
+
if (rejection) {
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
const state =
|
|
15
|
+
Internal.withdraw(token, store) ??
|
|
16
|
+
Internal.withdrawNewFamilyMember(token, store)
|
|
17
|
+
if (state === undefined) {
|
|
18
|
+
throw new Internal.NotFoundError(token, store)
|
|
19
|
+
}
|
|
20
|
+
Internal.setAtomOrSelector(state, value, store)
|
|
21
|
+
Internal.closeOperation(store)
|
|
22
|
+
}
|
package/src/silo.ts
CHANGED
|
@@ -6,10 +6,9 @@ import {
|
|
|
6
6
|
createMutableAtomFamily,
|
|
7
7
|
createSelector,
|
|
8
8
|
createSelectorFamily,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
undo__INTERNAL,
|
|
9
|
+
createTimeline,
|
|
10
|
+
createTransaction,
|
|
11
|
+
timeTravel,
|
|
13
12
|
} from "atom.io/internal"
|
|
14
13
|
|
|
15
14
|
import type { redo, timeline, undo } from "."
|
|
@@ -48,12 +47,12 @@ export class Silo {
|
|
|
48
47
|
}
|
|
49
48
|
this.selector = (options) => createSelector(options, undefined, s) as any
|
|
50
49
|
this.selectorFamily = (options) => createSelectorFamily(options, s) as any
|
|
51
|
-
this.transaction = (options) =>
|
|
52
|
-
this.timeline = (options) =>
|
|
50
|
+
this.transaction = (options) => createTransaction(options, s)
|
|
51
|
+
this.timeline = (options) => createTimeline(options, s)
|
|
53
52
|
this.getState = (token) => getState(token, s)
|
|
54
53
|
this.setState = (token, newValue) => setState(token, newValue, s)
|
|
55
54
|
this.subscribe = (token, handler, key) => subscribe(token, handler, key, s)
|
|
56
|
-
this.undo = (token) =>
|
|
57
|
-
this.redo = (token) =>
|
|
55
|
+
this.undo = (token) => timeTravel(`backward`, token, s)
|
|
56
|
+
this.redo = (token) => timeTravel(`forward`, token, s)
|
|
58
57
|
}
|
|
59
58
|
}
|
package/src/timeline.ts
CHANGED
|
@@ -4,12 +4,7 @@ import type {
|
|
|
4
4
|
TimelineSelectorUpdate,
|
|
5
5
|
TimelineTransactionUpdate,
|
|
6
6
|
} from "atom.io/internal"
|
|
7
|
-
import {
|
|
8
|
-
IMPLICIT,
|
|
9
|
-
redo__INTERNAL,
|
|
10
|
-
timeline__INTERNAL,
|
|
11
|
-
undo__INTERNAL,
|
|
12
|
-
} from "atom.io/internal"
|
|
7
|
+
import { IMPLICIT, createTimeline, timeTravel } from "atom.io/internal"
|
|
13
8
|
|
|
14
9
|
import type { AtomFamily, AtomToken } from "."
|
|
15
10
|
|
|
@@ -30,13 +25,13 @@ export type TimelineUpdate =
|
|
|
30
25
|
| TimelineTransactionUpdate
|
|
31
26
|
|
|
32
27
|
export const timeline = (options: TimelineOptions): TimelineToken => {
|
|
33
|
-
return
|
|
28
|
+
return createTimeline(options, IMPLICIT.STORE)
|
|
34
29
|
}
|
|
35
30
|
|
|
36
|
-
export const redo = (
|
|
37
|
-
|
|
31
|
+
export const redo = (timeline: TimelineToken): void => {
|
|
32
|
+
timeTravel(`forward`, timeline, IMPLICIT.STORE)
|
|
38
33
|
}
|
|
39
34
|
|
|
40
|
-
export const undo = (
|
|
41
|
-
|
|
35
|
+
export const undo = (timeline: TimelineToken): void => {
|
|
36
|
+
timeTravel(`backward`, timeline, IMPLICIT.STORE)
|
|
42
37
|
}
|
package/src/transaction.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Store } from "atom.io/internal"
|
|
2
|
-
import { IMPLICIT,
|
|
2
|
+
import { IMPLICIT, createTransaction, withdraw } from "atom.io/internal"
|
|
3
3
|
|
|
4
4
|
import type { KeyedStateUpdate, ReadonlySelectorToken, StateToken, ƒn } from "."
|
|
5
5
|
|
|
@@ -43,7 +43,7 @@ export type TransactionIO<Token extends TransactionToken<any>> =
|
|
|
43
43
|
export function transaction<ƒ extends ƒn>(
|
|
44
44
|
options: TransactionOptions<ƒ>,
|
|
45
45
|
): TransactionToken<ƒ> {
|
|
46
|
-
return
|
|
46
|
+
return createTransaction(options, IMPLICIT.STORE)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export const runTransaction =
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var internal = require('atom.io/internal');
|
|
4
|
+
var json = require('atom.io/json');
|
|
3
5
|
|
|
4
6
|
// src/set-rtx.ts
|
|
5
7
|
var SetRTX = class _SetRTX extends Set {
|
|
6
8
|
constructor(values, cacheLimit = 0) {
|
|
7
9
|
super(values);
|
|
8
10
|
this.mode = `record`;
|
|
9
|
-
this.subject = new Subject();
|
|
11
|
+
this.subject = new internal.Subject();
|
|
10
12
|
this.cacheLimit = 0;
|
|
11
13
|
this.cache = [];
|
|
12
14
|
this.cacheIdx = -1;
|
|
@@ -46,7 +48,7 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
46
48
|
add(value) {
|
|
47
49
|
if (this.mode === `record`) {
|
|
48
50
|
this.cacheUpdateNumber++;
|
|
49
|
-
this.emit(`add:${stringifyJson(value)}`);
|
|
51
|
+
this.emit(`add:${json.stringifyJson(value)}`);
|
|
50
52
|
}
|
|
51
53
|
return super.add(value);
|
|
52
54
|
}
|
|
@@ -60,7 +62,7 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
60
62
|
delete(value) {
|
|
61
63
|
if (this.mode === `record`) {
|
|
62
64
|
this.cacheUpdateNumber++;
|
|
63
|
-
this.emit(`del:${stringifyJson(value)}`);
|
|
65
|
+
this.emit(`del:${json.stringifyJson(value)}`);
|
|
64
66
|
}
|
|
65
67
|
return super.delete(value);
|
|
66
68
|
}
|
|
@@ -108,13 +110,13 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
108
110
|
const value = update.substring(typeValueBreak + 1);
|
|
109
111
|
switch (type) {
|
|
110
112
|
case `add`:
|
|
111
|
-
this.add(parseJson(value));
|
|
113
|
+
this.add(json.parseJson(value));
|
|
112
114
|
break;
|
|
113
115
|
case `clear`:
|
|
114
116
|
this.clear();
|
|
115
117
|
break;
|
|
116
118
|
case `del`:
|
|
117
|
-
this.delete(parseJson(value));
|
|
119
|
+
this.delete(json.parseJson(value));
|
|
118
120
|
break;
|
|
119
121
|
case `tx`:
|
|
120
122
|
for (const update2 of value.split(`;`)) {
|
|
@@ -122,6 +124,10 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
}
|
|
127
|
+
getUpdateNumber(update) {
|
|
128
|
+
const breakpoint = update.indexOf(`=`);
|
|
129
|
+
return Number(update.substring(0, breakpoint));
|
|
130
|
+
}
|
|
125
131
|
do(update) {
|
|
126
132
|
const breakpoint = update.indexOf(`=`);
|
|
127
133
|
const updateNumber = Number(update.substring(0, breakpoint));
|
|
@@ -137,34 +143,32 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
137
143
|
return null;
|
|
138
144
|
}
|
|
139
145
|
return this.cacheUpdateNumber + 1;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
this.mode = `playback`;
|
|
148
|
-
let done = false;
|
|
149
|
-
while (!done) {
|
|
150
|
-
this.cacheIdx %= this.cacheLimit;
|
|
151
|
-
const update2 = this.cache[this.cacheIdx];
|
|
152
|
-
this.cacheIdx--;
|
|
153
|
-
if (!update2) {
|
|
154
|
-
return `OUT_OF_RANGE`;
|
|
155
|
-
}
|
|
156
|
-
this.undo(update2);
|
|
157
|
-
done = this.cacheIdx === eventIdx - 1;
|
|
158
|
-
}
|
|
159
|
-
const innerUpdate = update.substring(breakpoint + 1);
|
|
160
|
-
this.doStep(innerUpdate);
|
|
161
|
-
this.mode = `record`;
|
|
162
|
-
this.cacheUpdateNumber = updateNumber;
|
|
146
|
+
}
|
|
147
|
+
if (Math.abs(eventOffset) < this.cacheLimit) {
|
|
148
|
+
const eventIdx = this.cacheIdx + eventOffset;
|
|
149
|
+
const cachedUpdate = this.cache[eventIdx];
|
|
150
|
+
if (cachedUpdate === update) {
|
|
163
151
|
return null;
|
|
164
|
-
} else {
|
|
165
|
-
return `OUT_OF_RANGE`;
|
|
166
152
|
}
|
|
153
|
+
this.mode = `playback`;
|
|
154
|
+
let done = false;
|
|
155
|
+
while (!done) {
|
|
156
|
+
this.cacheIdx %= this.cacheLimit;
|
|
157
|
+
const update2 = this.cache[this.cacheIdx];
|
|
158
|
+
this.cacheIdx--;
|
|
159
|
+
if (!update2) {
|
|
160
|
+
return `OUT_OF_RANGE`;
|
|
161
|
+
}
|
|
162
|
+
this.undo(update2);
|
|
163
|
+
done = this.cacheIdx === eventIdx - 1;
|
|
164
|
+
}
|
|
165
|
+
const innerUpdate = update.substring(breakpoint + 1);
|
|
166
|
+
this.doStep(innerUpdate);
|
|
167
|
+
this.mode = `record`;
|
|
168
|
+
this.cacheUpdateNumber = updateNumber;
|
|
169
|
+
return null;
|
|
167
170
|
}
|
|
171
|
+
return `OUT_OF_RANGE`;
|
|
168
172
|
}
|
|
169
173
|
undoStep(update) {
|
|
170
174
|
const breakpoint = update.indexOf(`:`);
|
|
@@ -172,10 +176,10 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
172
176
|
const value = update.substring(breakpoint + 1);
|
|
173
177
|
switch (type) {
|
|
174
178
|
case `add`:
|
|
175
|
-
this.delete(parseJson(value));
|
|
179
|
+
this.delete(json.parseJson(value));
|
|
176
180
|
break;
|
|
177
181
|
case `del`:
|
|
178
|
-
this.add(parseJson(value));
|
|
182
|
+
this.add(json.parseJson(value));
|
|
179
183
|
break;
|
|
180
184
|
case `clear`: {
|
|
181
185
|
const values = JSON.parse(value);
|
|
@@ -206,6 +210,6 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
206
210
|
}
|
|
207
211
|
};
|
|
208
212
|
|
|
209
|
-
|
|
213
|
+
exports.SetRTX = SetRTX;
|
|
210
214
|
//# sourceMappingURL=out.js.map
|
|
211
|
-
//# sourceMappingURL=index.
|
|
215
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/set-rtx.ts"],"names":["update","value"],"mappings":"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","sourcesContent":["import type { Transceiver, TransceiverMode } from \"atom.io/internal\"\nimport { Subject } from \"atom.io/internal\"\nimport type { Json, Stringified, primitive } from \"atom.io/json\"\nimport { parseJson, stringifyJson } from \"atom.io/json\"\n\nexport type SetUpdate =\n\t| `add:${string}`\n\t| `clear:${string}`\n\t| `del:${string}`\n\t| `tx:${string}`\nexport type NumberedSetUpdate = `${number}=${SetUpdate}`\n\nexport interface SetRTXJson<P extends primitive> extends Json.Object {\n\tmembers: P[]\n\tcache: (NumberedSetUpdate | null)[]\n\tcacheLimit: number\n\tcacheIdx: number\n\tcacheUpdateNumber: number\n}\nexport class SetRTX<P extends primitive>\n\textends Set<P>\n\timplements Transceiver<NumberedSetUpdate>\n{\n\tpublic mode: TransceiverMode = `record`\n\tpublic readonly subject = new Subject<SetUpdate>()\n\tpublic cacheLimit = 0\n\tpublic cache: (NumberedSetUpdate | null)[] = []\n\tpublic cacheIdx = -1\n\tpublic cacheUpdateNumber = -1\n\n\tpublic constructor(values?: Iterable<P>, cacheLimit = 0) {\n\t\tsuper(values)\n\t\tif (values instanceof SetRTX) {\n\t\t\tthis.parent = values\n\t\t\tthis.cacheUpdateNumber = values.cacheUpdateNumber\n\t\t}\n\t\tif (cacheLimit) {\n\t\t\tthis.cacheLimit = cacheLimit\n\t\t\tthis.cache = new Array(cacheLimit)\n\t\t\tthis.subscribe(`auto cache`, (update) => {\n\t\t\t\tthis.cacheIdx++\n\t\t\t\tthis.cacheIdx %= this.cacheLimit\n\t\t\t\tthis.cache[this.cacheIdx] = update\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic toJSON(): SetRTXJson<P> {\n\t\treturn {\n\t\t\tmembers: [...this],\n\t\t\tcache: this.cache,\n\t\t\tcacheLimit: this.cacheLimit,\n\t\t\tcacheIdx: this.cacheIdx,\n\t\t\tcacheUpdateNumber: this.cacheUpdateNumber,\n\t\t}\n\t}\n\n\tpublic static fromJSON<P extends primitive>(json: SetRTXJson<P>): SetRTX<P> {\n\t\tconst set = new SetRTX<P>(json.members, json.cacheLimit)\n\t\tset.cache = json.cache\n\t\tset.cacheIdx = json.cacheIdx\n\t\tset.cacheUpdateNumber = json.cacheUpdateNumber\n\t\treturn set\n\t}\n\n\tpublic add(value: P): this {\n\t\tif (this.mode === `record`) {\n\t\t\tthis.cacheUpdateNumber++\n\t\t\tthis.emit(`add:${stringifyJson<P>(value)}`)\n\t\t}\n\t\treturn super.add(value)\n\t}\n\n\tpublic clear(): void {\n\t\tif (this.mode === `record`) {\n\t\t\tthis.cacheUpdateNumber++\n\t\t\tthis.emit(`clear:${JSON.stringify([...this])}`)\n\t\t}\n\t\tsuper.clear()\n\t}\n\n\tpublic delete(value: P): boolean {\n\t\tif (this.mode === `record`) {\n\t\t\tthis.cacheUpdateNumber++\n\t\t\tthis.emit(`del:${stringifyJson<P>(value)}`)\n\t\t}\n\t\treturn super.delete(value)\n\t}\n\n\tpublic readonly parent: SetRTX<P> | null\n\tpublic child: SetRTX<P> | null = null\n\tpublic transactionUpdates: SetUpdate[] | null = null\n\tpublic transaction(run: (child: SetRTX<P>) => boolean): void {\n\t\tthis.mode = `transaction`\n\t\tthis.transactionUpdates = []\n\t\tthis.child = new SetRTX(this)\n\t\tconst unsubscribe = this.child._subscribe(`transaction`, (update) => {\n\t\t\tthis.transactionUpdates?.push(update)\n\t\t})\n\t\ttry {\n\t\t\tconst shouldCommit = run(this.child)\n\t\t\tif (shouldCommit) {\n\t\t\t\tthis.cacheUpdateNumber++\n\t\t\t\tthis.emit(`tx:${this.transactionUpdates.join(`;`)}`)\n\t\t\t\tfor (const update of this.transactionUpdates) {\n\t\t\t\t\tthis.doStep(update)\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (thrown) {\n\t\t\tconsole.error(`Failed to apply transaction: ${thrown}`)\n\t\t} finally {\n\t\t\tunsubscribe()\n\t\t\tthis.child = null\n\t\t\tthis.transactionUpdates = null\n\t\t\tthis.mode = `record`\n\t\t}\n\t}\n\n\tprotected _subscribe(\n\t\tkey: string,\n\t\tfn: (update: SetUpdate) => void,\n\t): () => void {\n\t\treturn this.subject.subscribe(key, fn)\n\t}\n\tpublic subscribe(\n\t\tkey: string,\n\t\tfn: (update: NumberedSetUpdate) => void,\n\t): () => void {\n\t\treturn this.subject.subscribe(key, (update) =>\n\t\t\tfn(`${this.cacheUpdateNumber}=${update}`),\n\t\t)\n\t}\n\n\tpublic emit(update: SetUpdate): void {\n\t\tthis.subject.next(update)\n\t}\n\n\tprivate doStep(update: SetUpdate): void {\n\t\tconst typeValueBreak = update.indexOf(`:`)\n\t\tconst type = update.substring(0, typeValueBreak)\n\t\tconst value = update.substring(typeValueBreak + 1)\n\t\tswitch (type) {\n\t\t\tcase `add`:\n\t\t\t\tthis.add(parseJson(value as Stringified<P>))\n\t\t\t\tbreak\n\t\t\tcase `clear`:\n\t\t\t\tthis.clear()\n\t\t\t\tbreak\n\t\t\tcase `del`:\n\t\t\t\tthis.delete(parseJson(value as Stringified<P>))\n\t\t\t\tbreak\n\t\t\tcase `tx`:\n\t\t\t\tfor (const update of value.split(`;`)) {\n\t\t\t\t\tthis.doStep(update as SetUpdate)\n\t\t\t\t}\n\t\t}\n\t}\n\n\tpublic getUpdateNumber(update: NumberedSetUpdate): number {\n\t\tconst breakpoint = update.indexOf(`=`)\n\t\treturn Number(update.substring(0, breakpoint))\n\t}\n\n\tpublic do(update: NumberedSetUpdate): number | `OUT_OF_RANGE` | null {\n\t\tconst breakpoint = update.indexOf(`=`)\n\t\tconst updateNumber = Number(update.substring(0, breakpoint))\n\t\tconst eventOffset = updateNumber - this.cacheUpdateNumber\n\t\tconst isFuture = eventOffset > 0\n\t\tif (isFuture) {\n\t\t\tif (eventOffset === 1) {\n\t\t\t\tthis.mode = `playback`\n\t\t\t\tconst innerUpdate = update.substring(breakpoint + 1) as SetUpdate\n\t\t\t\tthis.doStep(innerUpdate)\n\t\t\t\tthis.mode = `record`\n\t\t\t\tthis.cacheUpdateNumber = updateNumber\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn this.cacheUpdateNumber + 1\n\t\t}\n\t\tif (Math.abs(eventOffset) < this.cacheLimit) {\n\t\t\tconst eventIdx = this.cacheIdx + eventOffset\n\t\t\tconst cachedUpdate = this.cache[eventIdx]\n\t\t\tif (cachedUpdate === update) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tthis.mode = `playback`\n\t\t\tlet done = false\n\t\t\twhile (!done) {\n\t\t\t\tthis.cacheIdx %= this.cacheLimit\n\t\t\t\tconst update = this.cache[this.cacheIdx]\n\t\t\t\tthis.cacheIdx--\n\t\t\t\tif (!update) {\n\t\t\t\t\treturn `OUT_OF_RANGE`\n\t\t\t\t}\n\t\t\t\tconst undoRes = this.undo(update)\n\t\t\t\tdone = this.cacheIdx === eventIdx - 1\n\t\t\t}\n\t\t\tconst innerUpdate = update.substring(breakpoint + 1) as SetUpdate\n\t\t\tthis.doStep(innerUpdate)\n\t\t\tthis.mode = `record`\n\t\t\tthis.cacheUpdateNumber = updateNumber\n\t\t\treturn null\n\t\t}\n\t\treturn `OUT_OF_RANGE`\n\t}\n\n\tpublic undoStep(update: SetUpdate): void {\n\t\tconst breakpoint = update.indexOf(`:`)\n\t\tconst type = update.substring(0, breakpoint)\n\t\tconst value = update.substring(breakpoint + 1)\n\t\tswitch (type) {\n\t\t\tcase `add`:\n\t\t\t\tthis.delete(parseJson(value as Stringified<P>))\n\t\t\t\tbreak\n\t\t\tcase `del`:\n\t\t\t\tthis.add(parseJson(value as Stringified<P>))\n\t\t\t\tbreak\n\t\t\tcase `clear`: {\n\t\t\t\tconst values = JSON.parse(value) as P[]\n\t\t\t\tfor (const value of values) this.add(value)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `tx`: {\n\t\t\t\tconst updates = value.split(`;`) as SetUpdate[]\n\t\t\t\tfor (let i = updates.length - 1; i >= 0; i--) {\n\t\t\t\t\tthis.undoStep(updates[i])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic undo(update: NumberedSetUpdate): number | null {\n\t\tconst breakpoint = update.indexOf(`=`)\n\t\tconst updateNumber = Number(update.substring(0, breakpoint))\n\t\tif (updateNumber === this.cacheUpdateNumber) {\n\t\t\tthis.mode = `playback`\n\t\t\tconst innerUpdate = update.substring(breakpoint + 1) as SetUpdate\n\t\t\tthis.undoStep(innerUpdate)\n\t\t\tthis.mode = `record`\n\t\t\tthis.cacheUpdateNumber--\n\t\t\treturn null\n\t\t}\n\t\treturn this.cacheUpdateNumber\n\t}\n}\n"]}
|
|
@@ -17,7 +17,7 @@ declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<
|
|
|
17
17
|
cache: (NumberedSetUpdate | null)[];
|
|
18
18
|
cacheIdx: number;
|
|
19
19
|
cacheUpdateNumber: number;
|
|
20
|
-
constructor(values?:
|
|
20
|
+
constructor(values?: Iterable<P>, cacheLimit?: number);
|
|
21
21
|
toJSON(): SetRTXJson<P>;
|
|
22
22
|
static fromJSON<P extends primitive>(json: SetRTXJson<P>): SetRTX<P>;
|
|
23
23
|
add(value: P): this;
|
|
@@ -31,6 +31,7 @@ declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<
|
|
|
31
31
|
subscribe(key: string, fn: (update: NumberedSetUpdate) => void): () => void;
|
|
32
32
|
emit(update: SetUpdate): void;
|
|
33
33
|
private doStep;
|
|
34
|
+
getUpdateNumber(update: NumberedSetUpdate): number;
|
|
34
35
|
do(update: NumberedSetUpdate): number | `OUT_OF_RANGE` | null;
|
|
35
36
|
undoStep(update: SetUpdate): void;
|
|
36
37
|
undo(update: NumberedSetUpdate): number | null;
|
|
@@ -17,7 +17,7 @@ declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<
|
|
|
17
17
|
cache: (NumberedSetUpdate | null)[];
|
|
18
18
|
cacheIdx: number;
|
|
19
19
|
cacheUpdateNumber: number;
|
|
20
|
-
constructor(values?:
|
|
20
|
+
constructor(values?: Iterable<P>, cacheLimit?: number);
|
|
21
21
|
toJSON(): SetRTXJson<P>;
|
|
22
22
|
static fromJSON<P extends primitive>(json: SetRTXJson<P>): SetRTX<P>;
|
|
23
23
|
add(value: P): this;
|
|
@@ -31,6 +31,7 @@ declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<
|
|
|
31
31
|
subscribe(key: string, fn: (update: NumberedSetUpdate) => void): () => void;
|
|
32
32
|
emit(update: SetUpdate): void;
|
|
33
33
|
private doStep;
|
|
34
|
+
getUpdateNumber(update: NumberedSetUpdate): number;
|
|
34
35
|
do(update: NumberedSetUpdate): number | `OUT_OF_RANGE` | null;
|
|
35
36
|
undoStep(update: SetUpdate): void;
|
|
36
37
|
undo(update: NumberedSetUpdate): number | null;
|