atom.io 0.18.2 → 0.19.0
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 +173 -3
- package/data/dist/index.d.ts +52 -21
- package/data/dist/index.js +13 -334
- package/data/src/join.ts +309 -41
- package/dist/chunk-7ZR244C2.js +489 -0
- package/dist/{chunk-A4ZCNKWQ.js → chunk-BWWVY5O5.js} +0 -2
- package/dist/{chunk-NYCVSXQB.js → chunk-CVBEVTM5.js} +0 -2
- package/dist/{chunk-3J2EGSBE.js → chunk-O47EQUM6.js} +1 -3
- package/dist/{chunk-PZLG2HP3.js → chunk-U2IICNHQ.js} +0 -2
- package/dist/{chunk-XACXFU3B.js → chunk-VAE5OCKN.js} +0 -2
- package/dist/{chunk-NYTGCPHB.js → chunk-WX2NCOZR.js} +0 -2
- package/dist/{chunk-IZHOMSXA.js → chunk-YDOGCZ53.js} +0 -2
- package/dist/index.cjs +0 -2
- package/dist/index.js +1 -3
- package/internal/dist/index.cjs +0 -2
- package/internal/dist/index.js +2 -4
- package/introspection/dist/index.cjs +0 -2
- package/introspection/dist/index.js +1 -3
- package/json/dist/index.cjs +0 -2
- package/json/dist/index.js +3 -5
- package/package.json +3 -3
- package/react/dist/index.cjs +0 -2
- package/react/dist/index.js +1 -3
- package/react-devtools/dist/index.cjs +0 -2
- package/react-devtools/dist/index.css +0 -1
- package/react-devtools/dist/index.js +4 -6
- package/realtime/dist/index.cjs +4 -4
- package/realtime/dist/index.d.ts +1 -96
- package/realtime/dist/index.js +6 -6
- package/realtime/src/shared-room-store.ts +5 -3
- package/realtime-client/dist/index.cjs +0 -2
- package/realtime-client/dist/index.js +4 -6
- package/realtime-react/dist/index.cjs +0 -2
- package/realtime-react/dist/index.js +2 -4
- package/realtime-server/dist/index.cjs +162 -20
- package/realtime-server/dist/index.d.ts +1 -91
- package/realtime-server/dist/index.js +32 -20
- package/realtime-server/src/realtime-continuity-synchronizer.ts +8 -6
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +22 -10
- package/realtime-testing/dist/index.cjs +48 -8
- package/realtime-testing/dist/index.js +13 -8
- package/realtime-testing/src/setup-realtime-test.tsx +8 -2
- package/transceivers/set-rtx/dist/index.cjs +0 -2
- package/transceivers/set-rtx/dist/index.js +1 -3
- package/data/dist/index.cjs.map +0 -1
- package/data/dist/index.js.map +0 -1
- package/dist/chunk-3J2EGSBE.js.map +0 -1
- package/dist/chunk-A4ZCNKWQ.js.map +0 -1
- package/dist/chunk-IZHOMSXA.js.map +0 -1
- package/dist/chunk-NYCVSXQB.js.map +0 -1
- package/dist/chunk-NYTGCPHB.js.map +0 -1
- package/dist/chunk-PZLG2HP3.js.map +0 -1
- package/dist/chunk-XACXFU3B.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/internal/dist/index.cjs.map +0 -1
- package/internal/dist/index.js.map +0 -1
- package/introspection/dist/index.cjs.map +0 -1
- package/introspection/dist/index.js.map +0 -1
- package/json/dist/index.cjs.map +0 -1
- package/json/dist/index.js.map +0 -1
- package/react/dist/index.cjs.map +0 -1
- package/react/dist/index.js.map +0 -1
- package/react-devtools/dist/index.cjs.map +0 -1
- package/react-devtools/dist/index.css.map +0 -1
- package/react-devtools/dist/index.js.map +0 -1
- package/realtime/dist/index.cjs.map +0 -1
- package/realtime/dist/index.js.map +0 -1
- package/realtime-client/dist/index.cjs.map +0 -1
- package/realtime-client/dist/index.js.map +0 -1
- package/realtime-react/dist/index.cjs.map +0 -1
- package/realtime-react/dist/index.js.map +0 -1
- package/realtime-server/dist/index.cjs.map +0 -1
- package/realtime-server/dist/index.js.map +0 -1
- package/realtime-testing/dist/index.cjs.map +0 -1
- package/realtime-testing/dist/index.js.map +0 -1
- package/transceivers/set-rtx/dist/index.cjs.map +0 -1
- package/transceivers/set-rtx/dist/index.js.map +0 -1
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findRelationsInStore } from '../../dist/chunk-7ZR244C2.js';
|
|
2
|
+
import '../../dist/chunk-WX2NCOZR.js';
|
|
3
|
+
import { __spreadProps, __spreadValues } from '../../dist/chunk-U2IICNHQ.js';
|
|
2
4
|
import { parseJson, stringifyJson } from 'atom.io/json';
|
|
3
|
-
import { getUpdateToken, IMPLICIT, Subject,
|
|
5
|
+
import { getUpdateToken, IMPLICIT, Subject, getFromStore, subscribeToState, findInStore, getJsonToken, isRootStore, subscribeToTransaction, actUponStore, setIntoStore } from 'atom.io/internal';
|
|
4
6
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
5
7
|
import * as AtomIO from 'atom.io';
|
|
6
8
|
import { selectorFamily, atomFamily, atom } from 'atom.io';
|
|
7
9
|
import { SyncGroup, roomIndex, usersInRooms } from 'atom.io/realtime';
|
|
10
|
+
import { editRelationsInStore, join } from 'atom.io/data';
|
|
8
11
|
import { spawn } from 'child_process';
|
|
9
|
-
import { join } from 'atom.io/data';
|
|
10
12
|
|
|
11
13
|
// realtime-server/src/ipc-sockets/custom-socket.ts
|
|
12
14
|
var CustomSocket = class {
|
|
@@ -402,26 +404,38 @@ var joinRoomTX = AtomIO.transaction({
|
|
|
402
404
|
key: `joinRoom`,
|
|
403
405
|
do: (transactors, roomId, userId, enteredAtEpoch) => {
|
|
404
406
|
const meta = { enteredAtEpoch };
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
407
|
+
editRelationsInStore(
|
|
408
|
+
usersInRooms,
|
|
409
|
+
(relations) => {
|
|
410
|
+
relations.set({ room: roomId, user: userId }, meta);
|
|
411
|
+
},
|
|
412
|
+
transactors.env().store
|
|
413
|
+
);
|
|
408
414
|
return meta;
|
|
409
415
|
}
|
|
410
416
|
});
|
|
411
417
|
var leaveRoomTX = AtomIO.transaction({
|
|
412
418
|
key: `leaveRoom`,
|
|
413
419
|
do: (transactors, roomId, userId) => {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
420
|
+
editRelationsInStore(
|
|
421
|
+
usersInRooms,
|
|
422
|
+
(relations) => {
|
|
423
|
+
relations.delete({ room: roomId, user: userId });
|
|
424
|
+
},
|
|
425
|
+
transactors.env().store
|
|
426
|
+
);
|
|
417
427
|
}
|
|
418
428
|
});
|
|
419
429
|
var destroyRoomTX = AtomIO.transaction({
|
|
420
430
|
key: `destroyRoom`,
|
|
421
431
|
do: (transactors, roomId) => {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
432
|
+
editRelationsInStore(
|
|
433
|
+
usersInRooms,
|
|
434
|
+
(relations) => {
|
|
435
|
+
relations.delete({ room: roomId });
|
|
436
|
+
},
|
|
437
|
+
transactors.env().store
|
|
438
|
+
);
|
|
425
439
|
transactors.set(roomIndex, (s) => (s.delete(roomId), s));
|
|
426
440
|
}
|
|
427
441
|
});
|
|
@@ -482,11 +496,11 @@ function realtimeContinuitySynchronizer({
|
|
|
482
496
|
return function synchronizer(continuity) {
|
|
483
497
|
let socket = initialSocket;
|
|
484
498
|
const continuityKey = continuity.key;
|
|
485
|
-
const userKeyState =
|
|
486
|
-
usersOfSockets
|
|
499
|
+
const userKeyState = findRelationsInStore(
|
|
500
|
+
usersOfSockets,
|
|
487
501
|
socket.id,
|
|
488
502
|
store
|
|
489
|
-
);
|
|
503
|
+
).userKeyOfSocket;
|
|
490
504
|
const userKey = getFromStore(userKeyState, store);
|
|
491
505
|
if (!userKey) {
|
|
492
506
|
store.logger.error(
|
|
@@ -498,11 +512,11 @@ function realtimeContinuitySynchronizer({
|
|
|
498
512
|
return () => {
|
|
499
513
|
};
|
|
500
514
|
}
|
|
501
|
-
const socketKeyState =
|
|
502
|
-
usersOfSockets
|
|
515
|
+
const socketKeyState = findRelationsInStore(
|
|
516
|
+
usersOfSockets,
|
|
503
517
|
userKey,
|
|
504
518
|
store
|
|
505
|
-
);
|
|
519
|
+
).socketKeyOfUser;
|
|
506
520
|
subscribeToState(
|
|
507
521
|
socketKeyState,
|
|
508
522
|
({ newValue: newSocketKey }) => {
|
|
@@ -944,5 +958,3 @@ function realtimeActionReceiver({
|
|
|
944
958
|
}
|
|
945
959
|
|
|
946
960
|
export { ChildSocket, CustomSocket, ParentSocket, SubjectSocket, actionOcclusionAtoms, createRoomTX, destroyRoomTX, joinRoomTX, leaveRoomTX, realtimeActionReceiver, realtimeAtomFamilyProvider, realtimeContinuitySynchronizer, realtimeMutableFamilyProvider, realtimeMutableProvider, realtimeStateProvider, realtimeStateReceiver, realtimeStateSynchronizer, redactTransactionUpdateContent, roomArgumentsAtoms, roomSelectors, socketAtoms, socketIndex, userIndex, userUnacknowledgedQueues, usersOfSockets };
|
|
947
|
-
//# sourceMappingURL=out.js.map
|
|
948
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -15,6 +15,7 @@ import type { ContinuityToken } from "atom.io/realtime"
|
|
|
15
15
|
import type { ServerConfig, Socket } from "."
|
|
16
16
|
import { socketAtoms, usersOfSockets } from "."
|
|
17
17
|
|
|
18
|
+
import { findRelationsInStore } from "../../data/src/join"
|
|
18
19
|
import {
|
|
19
20
|
redactTransactionUpdateContent,
|
|
20
21
|
userUnacknowledgedQueues,
|
|
@@ -31,11 +32,11 @@ export function realtimeContinuitySynchronizer({
|
|
|
31
32
|
let socket: Socket | null = initialSocket
|
|
32
33
|
|
|
33
34
|
const continuityKey = continuity.key
|
|
34
|
-
const userKeyState =
|
|
35
|
-
usersOfSockets
|
|
35
|
+
const userKeyState = findRelationsInStore(
|
|
36
|
+
usersOfSockets,
|
|
36
37
|
socket.id,
|
|
37
38
|
store,
|
|
38
|
-
)
|
|
39
|
+
).userKeyOfSocket
|
|
39
40
|
const userKey = getFromStore(userKeyState, store)
|
|
40
41
|
if (!userKey) {
|
|
41
42
|
store.logger.error(
|
|
@@ -46,11 +47,12 @@ export function realtimeContinuitySynchronizer({
|
|
|
46
47
|
)
|
|
47
48
|
return () => {}
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
|
|
51
|
+
const socketKeyState = findRelationsInStore(
|
|
52
|
+
usersOfSockets,
|
|
51
53
|
userKey,
|
|
52
54
|
store,
|
|
53
|
-
)
|
|
55
|
+
).socketKeyOfUser
|
|
54
56
|
subscribeToState(
|
|
55
57
|
socketKeyState,
|
|
56
58
|
({ newValue: newSocketKey }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as AtomIO from "atom.io"
|
|
2
|
-
import type
|
|
2
|
+
import { type Loadable, editRelations, editRelationsInStore } from "atom.io/data"
|
|
3
3
|
import type { UserInRoomMeta } from "atom.io/realtime"
|
|
4
4
|
import { roomIndex, usersInRooms } from "atom.io/realtime"
|
|
5
5
|
|
|
@@ -33,9 +33,13 @@ export const joinRoomTX = AtomIO.transaction<
|
|
|
33
33
|
key: `joinRoom`,
|
|
34
34
|
do: (transactors, roomId, userId, enteredAtEpoch) => {
|
|
35
35
|
const meta = { enteredAtEpoch }
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
editRelationsInStore(
|
|
37
|
+
usersInRooms,
|
|
38
|
+
(relations) => {
|
|
39
|
+
relations.set({ room: roomId, user: userId }, meta)
|
|
40
|
+
},
|
|
41
|
+
transactors.env().store,
|
|
42
|
+
)
|
|
39
43
|
return meta
|
|
40
44
|
},
|
|
41
45
|
})
|
|
@@ -46,9 +50,13 @@ export const leaveRoomTX = AtomIO.transaction<
|
|
|
46
50
|
>({
|
|
47
51
|
key: `leaveRoom`,
|
|
48
52
|
do: (transactors, roomId, userId) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
editRelationsInStore(
|
|
54
|
+
usersInRooms,
|
|
55
|
+
(relations) => {
|
|
56
|
+
relations.delete({ room: roomId, user: userId })
|
|
57
|
+
},
|
|
58
|
+
transactors.env().store,
|
|
59
|
+
)
|
|
52
60
|
},
|
|
53
61
|
})
|
|
54
62
|
export type LeaveRoomIO = AtomIO.TransactionIO<typeof leaveRoomTX>
|
|
@@ -56,9 +64,13 @@ export type LeaveRoomIO = AtomIO.TransactionIO<typeof leaveRoomTX>
|
|
|
56
64
|
export const destroyRoomTX = AtomIO.transaction<(roomId: string) => void>({
|
|
57
65
|
key: `destroyRoom`,
|
|
58
66
|
do: (transactors, roomId) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
editRelationsInStore(
|
|
68
|
+
usersInRooms,
|
|
69
|
+
(relations) => {
|
|
70
|
+
relations.delete({ room: roomId })
|
|
71
|
+
},
|
|
72
|
+
transactors.env().store,
|
|
73
|
+
)
|
|
62
74
|
transactors.set(roomIndex, (s) => (s.delete(roomId), s))
|
|
63
75
|
},
|
|
64
76
|
})
|
|
@@ -11,6 +11,7 @@ var RTS = require('atom.io/realtime-server');
|
|
|
11
11
|
var Happy = require('happy-dom');
|
|
12
12
|
var SocketIO = require('socket.io');
|
|
13
13
|
var socket_ioClient = require('socket.io-client');
|
|
14
|
+
require('atom.io/transceivers/set-rtx');
|
|
14
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
16
|
|
|
16
17
|
function _interopNamespace(e) {
|
|
@@ -62,6 +63,42 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
62
63
|
|
|
63
64
|
// ../anvl/src/object/entries.ts
|
|
64
65
|
var recordToEntries = (obj) => Object.entries(obj);
|
|
66
|
+
function getJoinMap(store) {
|
|
67
|
+
if (`joins` in store && store.joins instanceof Map) {
|
|
68
|
+
return store.joins;
|
|
69
|
+
}
|
|
70
|
+
const joins = /* @__PURE__ */ new Map();
|
|
71
|
+
store.joins = joins;
|
|
72
|
+
return joins;
|
|
73
|
+
}
|
|
74
|
+
function getJoin(token, store) {
|
|
75
|
+
var _a;
|
|
76
|
+
const joinMap = getJoinMap(store);
|
|
77
|
+
let join = joinMap.get(token.key);
|
|
78
|
+
if (join === void 0) {
|
|
79
|
+
const rootJoinMap = getJoinMap(internal.IMPLICIT.STORE);
|
|
80
|
+
join = (_a = rootJoinMap.get(token.key)) == null ? void 0 : _a.in(store);
|
|
81
|
+
if (join === void 0) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Join "${token.key}" not found in store "${store.config.name}"`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
joinMap.set(token.key, join);
|
|
87
|
+
}
|
|
88
|
+
return join;
|
|
89
|
+
}
|
|
90
|
+
function editRelationsInStore(token, change, store) {
|
|
91
|
+
const join = getJoin(token, store);
|
|
92
|
+
const target = internal.newest(store);
|
|
93
|
+
if (internal.isChildStore(target)) {
|
|
94
|
+
const { transactors } = target.transactionMeta;
|
|
95
|
+
join.transact(transactors, ({ relations }) => {
|
|
96
|
+
change(relations);
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
change(join.relations);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
65
102
|
|
|
66
103
|
// __unstable__/web-effects/src/storage.ts
|
|
67
104
|
var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, onSet }) => {
|
|
@@ -117,8 +154,13 @@ var setupRealtimeTestServer = (options) => {
|
|
|
117
154
|
if (token === `test` && socket.id) {
|
|
118
155
|
const socketState = internal.findInStore(RTS__namespace.socketAtoms, socket.id, silo.store);
|
|
119
156
|
internal.setIntoStore(socketState, socket, silo.store);
|
|
120
|
-
|
|
121
|
-
|
|
157
|
+
editRelationsInStore(
|
|
158
|
+
RTS__namespace.usersOfSockets,
|
|
159
|
+
(relations) => {
|
|
160
|
+
relations.set(socket.id, username);
|
|
161
|
+
},
|
|
162
|
+
silo.store
|
|
163
|
+
);
|
|
122
164
|
internal.setIntoStore(RTS__namespace.userIndex, (index) => index.add(username), silo.store);
|
|
123
165
|
internal.setIntoStore(RTS__namespace.socketIndex, (index) => index.add(socket.id), silo.store);
|
|
124
166
|
console.log(`${username} connected on ${socket.id}`);
|
|
@@ -130,7 +172,7 @@ var setupRealtimeTestServer = (options) => {
|
|
|
130
172
|
server.on(`connection`, (socket) => {
|
|
131
173
|
options.server({ socket, silo });
|
|
132
174
|
});
|
|
133
|
-
const
|
|
175
|
+
const dispose2 = () => {
|
|
134
176
|
server.close();
|
|
135
177
|
const roomKeys = internal.getFromStore(RT__namespace.roomIndex, silo.store);
|
|
136
178
|
for (const roomKey of roomKeys) {
|
|
@@ -145,7 +187,7 @@ var setupRealtimeTestServer = (options) => {
|
|
|
145
187
|
return {
|
|
146
188
|
name: `SERVER`,
|
|
147
189
|
silo,
|
|
148
|
-
dispose,
|
|
190
|
+
dispose: dispose2,
|
|
149
191
|
port
|
|
150
192
|
};
|
|
151
193
|
};
|
|
@@ -172,12 +214,12 @@ var setupRealtimeTestClient = (options, name, port) => {
|
|
|
172
214
|
}
|
|
173
215
|
);
|
|
174
216
|
const prettyPrint = () => console.log(react.prettyDOM(renderResult.container));
|
|
175
|
-
const
|
|
217
|
+
const dispose2 = () => {
|
|
176
218
|
renderResult.unmount();
|
|
177
219
|
socket.disconnect();
|
|
178
220
|
internal.clearStore(silo.store);
|
|
179
221
|
};
|
|
180
|
-
testClient.dispose =
|
|
222
|
+
testClient.dispose = dispose2;
|
|
181
223
|
return {
|
|
182
224
|
name,
|
|
183
225
|
silo,
|
|
@@ -229,5 +271,3 @@ exports.multiClient = multiClient;
|
|
|
229
271
|
exports.setupRealtimeTestClient = setupRealtimeTestClient;
|
|
230
272
|
exports.setupRealtimeTestServer = setupRealtimeTestServer;
|
|
231
273
|
exports.singleClient = singleClient;
|
|
232
|
-
//# sourceMappingURL=out.js.map
|
|
233
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { myUsernameState } from '../../dist/chunk-
|
|
2
|
-
import {
|
|
3
|
-
import '../../dist/chunk-
|
|
4
|
-
import {
|
|
1
|
+
import { myUsernameState } from '../../dist/chunk-O47EQUM6.js';
|
|
2
|
+
import { editRelationsInStore } from '../../dist/chunk-7ZR244C2.js';
|
|
3
|
+
import '../../dist/chunk-WX2NCOZR.js';
|
|
4
|
+
import { recordToEntries } from '../../dist/chunk-CVBEVTM5.js';
|
|
5
|
+
import '../../dist/chunk-BWWVY5O5.js';
|
|
6
|
+
import { __spreadProps, __spreadValues } from '../../dist/chunk-U2IICNHQ.js';
|
|
5
7
|
import * as http from 'http';
|
|
6
8
|
import { render, prettyDOM } from '@testing-library/react';
|
|
7
9
|
import * as AtomIO from 'atom.io';
|
|
@@ -29,8 +31,13 @@ var setupRealtimeTestServer = (options) => {
|
|
|
29
31
|
if (token === `test` && socket.id) {
|
|
30
32
|
const socketState = findInStore(RTS.socketAtoms, socket.id, silo.store);
|
|
31
33
|
setIntoStore(socketState, socket, silo.store);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
editRelationsInStore(
|
|
35
|
+
RTS.usersOfSockets,
|
|
36
|
+
(relations) => {
|
|
37
|
+
relations.set(socket.id, username);
|
|
38
|
+
},
|
|
39
|
+
silo.store
|
|
40
|
+
);
|
|
34
41
|
setIntoStore(RTS.userIndex, (index) => index.add(username), silo.store);
|
|
35
42
|
setIntoStore(RTS.socketIndex, (index) => index.add(socket.id), silo.store);
|
|
36
43
|
console.log(`${username} connected on ${socket.id}`);
|
|
@@ -138,5 +145,3 @@ var multiClient = (options) => {
|
|
|
138
145
|
};
|
|
139
146
|
|
|
140
147
|
export { multiClient, setupRealtimeTestClient, setupRealtimeTestServer, singleClient };
|
|
141
|
-
//# sourceMappingURL=out.js.map
|
|
142
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -21,6 +21,7 @@ import type { Socket as ClientSocket } from "socket.io-client"
|
|
|
21
21
|
import { io } from "socket.io-client"
|
|
22
22
|
|
|
23
23
|
import { recordToEntries } from "~/packages/anvl/src/object"
|
|
24
|
+
import { editRelationsInStore } from "../../data/src/join"
|
|
24
25
|
import { myUsernameState } from "../../realtime-client/src/realtime-client-stores"
|
|
25
26
|
|
|
26
27
|
let testNumber = 0
|
|
@@ -87,8 +88,13 @@ export const setupRealtimeTestServer = (
|
|
|
87
88
|
if (token === `test` && socket.id) {
|
|
88
89
|
const socketState = findInStore(RTS.socketAtoms, socket.id, silo.store)
|
|
89
90
|
setIntoStore(socketState, socket, silo.store)
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
editRelationsInStore(
|
|
92
|
+
RTS.usersOfSockets,
|
|
93
|
+
(relations) => {
|
|
94
|
+
relations.set(socket.id, username)
|
|
95
|
+
},
|
|
96
|
+
silo.store,
|
|
97
|
+
)
|
|
92
98
|
setIntoStore(RTS.userIndex, (index) => index.add(username), silo.store)
|
|
93
99
|
setIntoStore(RTS.socketIndex, (index) => index.add(socket.id), silo.store)
|
|
94
100
|
console.log(`${username} connected on ${socket.id}`)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '../../../dist/chunk-
|
|
1
|
+
import '../../../dist/chunk-U2IICNHQ.js';
|
|
2
2
|
import { Subject } from 'atom.io/internal';
|
|
3
3
|
import { stringifyJson, parseJson } from 'atom.io/json';
|
|
4
4
|
|
|
@@ -213,5 +213,3 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
213
213
|
};
|
|
214
214
|
|
|
215
215
|
export { SetRTX };
|
|
216
|
-
//# sourceMappingURL=out.js.map
|
|
217
|
-
//# sourceMappingURL=index.js.map
|
package/data/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dict.ts","../src/join.ts","../../../rel8/junction/src/junction.ts","../src/struct.ts","../src/struct-family.ts","../src/until.ts"],"names":["findState","IMPLICIT","findInStore","a","b","join","createStandaloneSelector","capitalize","createRegularAtomFamily","createSelectorFamily"],"mappings":";AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAGA,SAAS,KACfA,YAIA,OAIA,QAAe,SAAS,OAC2C;AACnE,SAAO;AAAA,IACN;AAAA,MACC,KAAK,GAAGA,WAAU,GAAG;AAAA,MACrB,KAAK,CAAC,EAAE,IAAI,MAAM;AACjB,cAAM,OAAO,IAAI,KAAK;AACtB,eAAO,KAAK,OAAO,CAAC,KAAK,QAAQ;AAChC,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AAEP,IAAMF,cAAa,CAAC,QAAgB,IAAI,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AACtE,IAAM,aAAa,CAAC,QAAgB,WACnC,SAASA,YAAW,MAAM,IAAIA,YAAW,MAAM,IAAI;AAE7C,SAAS,aAGd,SAUA;AACD,QAAM,QAIF,OAAO,KAAK,QAAQ,OAAO,EAAE,OAAO,CAAC,KAAK,WAAW;AACxD,UAAM,iBAAiB,WAAW,QAAQ,KAAK,MAAM;AACrD,QAAI,cAAc,IAAIC;AAAA,MACrB;AAAA,QACC,KAAK,GAAG,QAAQ,GAAG,IAAI,MAAM;AAAA,QAC7B,SAAU,QAAQ,QAAgB,MAAM;AAAA,MACzC;AAAA,MACAP,UAAS;AAAA,IACV;AACA,WAAO;AAAA,EACR,GAAG,CAAC,CAAQ;AACZ,QAAM,kBACLQ;AAAA,IACC;AAAA,MACC,KAAK,QAAQ;AAAA,MACb,KACC,CAAC,OACD,CAAC,EAAE,IAAI,MAAM;AACZ,eAAO,OAAO,KAAK,QAAQ,OAAO,EAAE,OAAO,CAAC,KAAK,WAAW;AAC3D,cAAI,MAAM,IAAI;AAAA,YACZ,MAAc,WAAW,QAAQ,KAAK,MAAM,CAAC,EAAE,EAAE;AAAA,UACnD;AACA,iBAAO;AAAA,QACR,GAAG,CAAC,CAAQ;AAAA,MACb;AAAA,IACF;AAAA,IACAR,UAAS;AAAA,EACV;AACD,SAAO,CAAC,OAAO,eAAe;AAC/B;;;ACjDO,SAAS,MAAS,UAAuB,UAAgB;AAC/D,MAAI,oBAAoB,SAAS;AAChC,WAAO;AAAA,EACR;AACA,SAAO;AACR","sourcesContent":["import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateStandaloneSelector,\n\tfindInStore,\n} from \"atom.io/internal\"\nimport type { Json, Stringified } from \"atom.io/json\"\n\nexport function dict<State, Key extends Json.Serializable>(\n\tfindState:\n\t\t| AtomIO.ReadonlySelectorFamilyToken<State, Key>\n\t\t| AtomIO.RegularAtomFamilyToken<State, Key>\n\t\t| AtomIO.WritableSelectorFamily<State, Key>,\n\tindex:\n\t\t| AtomIO.ReadonlySelectorToken<Key[]>\n\t\t| AtomIO.RegularAtomToken<Key[]>\n\t\t| AtomIO.WritableSelectorToken<Key[]>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomIO.ReadonlySelectorToken<{ [K in Stringified<Key>]: State }> {\n\treturn createStandaloneSelector(\n\t\t{\n\t\t\tkey: `${findState.key}Dict`,\n\t\t\tget: ({ get }) => {\n\t\t\t\tconst keys = get(index)\n\t\t\t\treturn keys.reduce((acc, key) => {\n\t\t\t\t\tacc[key] = get(findInStore(findState, key, store))\n\t\t\t\t\treturn acc\n\t\t\t\t}, {} as any)\n\t\t\t},\n\t\t},\n\t\tstore,\n\t)\n}\n","/* eslint-disable @typescript-eslint/ban-types */\nimport type {\n\tMutableAtomFamily,\n\tRead,\n\tReadonlySelectorFamily,\n\tRegularAtomFamily,\n\tTransactors,\n\tWrite,\n} from \"atom.io\"\nimport { dispose, findState, getState, setState } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateMutableAtomFamily,\n\tcreateRegularAtomFamily,\n\tcreateSelectorFamily,\n\tfindInStore,\n\tgetFromStore,\n\tgetJsonFamily,\n\tsetIntoStore,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { SetRTXJson } from \"atom.io/transceivers/set-rtx\"\nimport { SetRTX } from \"atom.io/transceivers/set-rtx\"\n\nimport type {\n\tBaseExternalStoreConfiguration,\n\tExternalStoreConfiguration,\n\tJunctionEntries,\n\tJunctionSchema,\n} from \"~/packages/rel8/junction/src\"\nimport { Junction } from \"~/packages/rel8/junction/src\"\nimport type * as Rel8 from \"~/packages/rel8/types/src\"\n\nconst TRANSACTORS: Transactors = {\n\tget: getState,\n\tset: setState,\n\tfind: findState,\n}\n\nfunction capitalize<S extends string>(string: S): Capitalize<S> {\n\treturn (string[0].toUpperCase() + string.slice(1)) as Capitalize<S>\n}\n\nexport interface JoinOptions<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object | null,\n> extends Json.Object,\n\t\tJunctionSchema<ASide, BSide>,\n\t\tPartial<JunctionEntries<Content>> {\n\treadonly key: string\n\treadonly cardinality: Cardinality\n}\n\nexport type JoinState<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object | null,\n> = Cardinality extends `1:1`\n\t? (Content extends Json.Object\n\t\t\t? {\n\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t? `${AB}EntryOf${Capitalize<BSide>}`\n\t\t\t\t\t\t: `${AB}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\t[string, Content] | null,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>\n\t\t\t }\n\t\t\t: {}) & {\n\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t? `${AB}KeyOf${Capitalize<BSide>}`\n\t\t\t\t: `${AB}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\tstring | null,\n\t\t\t\tstring\n\t\t\t>\n\t }\n\t: Cardinality extends `1:n`\n\t ? (Content extends Json.Object\n\t\t\t\t? {\n\t\t\t\t\t\treadonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\t\t[string, Content] | null,\n\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t>\n\t\t\t\t } & {\n\t\t\t\t\t\treadonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\t\t[string, Content][],\n\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t>\n\t\t\t\t }\n\t\t\t\t: {}) & {\n\t\t\t\treadonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\tstring | null,\n\t\t\t\t\tstring\n\t\t\t\t>\n\t\t } & {\n\t\t\t\treadonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\tstring[],\n\t\t\t\t\tstring\n\t\t\t\t>\n\t\t }\n\t : Cardinality extends `n:n`\n\t\t ? (Content extends Json.Object\n\t\t\t\t\t? {\n\t\t\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t\t\t? `${AB}EntriesOf${Capitalize<BSide>}`\n\t\t\t\t\t\t\t\t: `${AB}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\t\t\t[string, Content][],\n\t\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t\t>\n\t\t\t\t\t }\n\t\t\t\t\t: {}) & {\n\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t? `${AB}KeysOf${Capitalize<BSide>}`\n\t\t\t\t\t\t: `${AB}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\tstring[],\n\t\t\t\t\t\tstring\n\t\t\t\t\t>\n\t\t\t }\n\t\t : never\n\nexport class Join<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n\tconst Content extends Json.Object | null = null,\n> {\n\tprivate options: JoinOptions<ASide, BSide, Cardinality, Content>\n\tprivate defaultContent: Content | undefined\n\tprivate transactors: Transactors\n\tpublic relations: Junction<ASide, BSide, Content>\n\tpublic states: JoinState<ASide, BSide, Cardinality, Content>\n\tpublic core: {\n\t\tfindRelatedKeysState: MutableAtomFamily<\n\t\t\tSetRTX<string>,\n\t\t\tSetRTXJson<string>,\n\t\t\tstring\n\t\t>\n\t}\n\tpublic transact(\n\t\ttransactors: Transactors,\n\t\trun: (join: Join<ASide, BSide, Cardinality, Content>) => void,\n\t): void {\n\t\tconst originalTransactors = this.transactors\n\t\tthis.transactors = transactors\n\t\trun(this)\n\t\tthis.transactors = originalTransactors\n\t}\n\n\tpublic alternates: Map<string, Join<ASide, BSide, Cardinality, Content>>\n\tpublic in(store: Store): Join<ASide, BSide, Cardinality, Content> {\n\t\tconst key = store.config.name\n\t\tconst alternate = this.alternates.get(key)\n\t\tif (alternate) {\n\t\t\treturn alternate\n\t\t}\n\t\tconst join = new Join(this.options, this.defaultContent, store)\n\t\tthis.alternates.set(key, join)\n\t\tjoin.alternates = this.alternates\n\t\treturn join\n\t}\n\n\tpublic constructor(\n\t\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\t\tdefaultContent: Content | undefined,\n\t\tstore: Store = IMPLICIT.STORE,\n\t) {\n\t\tthis.options = options\n\t\tthis.defaultContent = defaultContent\n\t\tthis.alternates = new Map()\n\t\tthis.alternates.set(store.config.name, this)\n\t\tthis.transactors = {\n\t\t\tget: (token) => getFromStore(token, store),\n\t\t\tset: (token, value) => setIntoStore(token, value, store),\n\t\t\tfind: ((token, key) => findInStore(token, key, store)) as typeof findState,\n\t\t}\n\t\tconst a: ASide = options.between[0]\n\t\tconst b: BSide = options.between[1]\n\t\tconst relatedKeysAtoms = createMutableAtomFamily<\n\t\t\tSetRTX<string>,\n\t\t\tSetRTXJson<string>,\n\t\t\tstring\n\t\t>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/relatedKeys`,\n\t\t\t\tdefault: () => new SetRTX(),\n\t\t\t\tmutable: true,\n\t\t\t\tfromJson: (json) => SetRTX.fromJSON(json),\n\t\t\t\ttoJson: (set) => set.toJSON(),\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\t\tthis.core = { findRelatedKeysState: relatedKeysAtoms }\n\t\tconst getRelatedKeys: Read<(key: string) => SetRTX<string>> = (\n\t\t\t{ find, get },\n\t\t\tkey,\n\t\t) => get(find(relatedKeysAtoms, key))\n\t\tconst addRelation: Write<(a: string, b: string) => void> = (\n\t\t\ttransactors,\n\t\t\ta,\n\t\t\tb,\n\t\t) => {\n\t\t\tconst { set, find } = transactors\n\t\t\tconst aKeysState = find(relatedKeysAtoms, a)\n\t\t\tconst bKeysState = find(relatedKeysAtoms, b)\n\t\t\tset(aKeysState, (aKeys) => aKeys.add(b))\n\t\t\tset(bKeysState, (bKeys) => bKeys.add(a))\n\t\t}\n\t\tconst deleteRelation: Write<(a: string, b: string) => void> = (\n\t\t\ttransactors,\n\t\t\ta,\n\t\t\tb,\n\t\t) => {\n\t\t\tconst { find, set } = transactors\n\t\t\tconst aKeysState = find(relatedKeysAtoms, a)\n\t\t\tconst bKeysState = find(relatedKeysAtoms, b)\n\t\t\tset(aKeysState, (aKeys) => (aKeys.delete(b), aKeys))\n\t\t\tset(bKeysState, (bKeys) => (bKeys.delete(a), bKeys))\n\t\t}\n\t\tconst replaceRelationsSafely: Write<\n\t\t\t(a: string, newRelationsOfA: string[]) => void\n\t\t> = (transactors, a, newRelationsOfA) => {\n\t\t\tconst { find, get, set } = transactors\n\t\t\tconst relationsOfAState = find(relatedKeysAtoms, a)\n\t\t\tconst currentRelationsOfA = get(relationsOfAState)\n\t\t\tfor (const currentRelationB of currentRelationsOfA) {\n\t\t\t\tconst remainsRelated = newRelationsOfA.includes(currentRelationB)\n\t\t\t\tif (remainsRelated) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst relationsOfBState = find(relatedKeysAtoms, currentRelationB)\n\t\t\t\tset(relationsOfBState, (relationsOfB) => {\n\t\t\t\t\trelationsOfB.delete(a)\n\t\t\t\t\treturn relationsOfB\n\t\t\t\t})\n\t\t\t}\n\t\t\tset(relationsOfAState, (relationsOfA) => {\n\t\t\t\trelationsOfA.transaction((nextRelationsOfA) => {\n\t\t\t\t\tnextRelationsOfA.clear()\n\t\t\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\t\t\tconst relationsOfB = getRelatedKeys(transactors, newRelationB)\n\t\t\t\t\t\tconst newRelationBIsAlreadyRelated = relationsOfB.has(a)\n\t\t\t\t\t\tif (this.relations.cardinality === `1:n`) {\n\t\t\t\t\t\t\tfor (const previousOwner of relationsOfB) {\n\t\t\t\t\t\t\t\tif (previousOwner === a) {\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst previousOwnerRelations = getRelatedKeys(\n\t\t\t\t\t\t\t\t\ttransactors,\n\t\t\t\t\t\t\t\t\tpreviousOwner,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tpreviousOwnerRelations.delete(newRelationB)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {\n\t\t\t\t\t\t\t\trelationsOfB.clear()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!newRelationBIsAlreadyRelated) {\n\t\t\t\t\t\t\trelationsOfB.add(a)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnextRelationsOfA.add(newRelationB)\n\t\t\t\t\t}\n\t\t\t\t\treturn true\n\t\t\t\t})\n\t\t\t\treturn relationsOfA\n\t\t\t})\n\t\t}\n\t\tconst replaceRelationsUnsafely: Write<\n\t\t\t(a: string, newRelationsOfA: string[]) => void\n\t\t> = (transactors, a, newRelationsOfA) => {\n\t\t\tconst { find, set } = transactors\n\t\t\tconst relationsOfAState = find(relatedKeysAtoms, a)\n\t\t\tset(relationsOfAState, (relationsOfA) => {\n\t\t\t\trelationsOfA.transaction((nextRelationsOfA) => {\n\t\t\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\t\t\tnextRelationsOfA.add(newRelationB)\n\t\t\t\t\t}\n\t\t\t\t\treturn true\n\t\t\t\t})\n\t\t\t\treturn relationsOfA\n\t\t\t})\n\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\tconst newRelationsBState = find(relatedKeysAtoms, newRelationB)\n\t\t\t\tset(newRelationsBState, (newRelationsB) => {\n\t\t\t\t\tnewRelationsB.add(a)\n\t\t\t\t\treturn newRelationsB\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t\tconst has: Read<(a: string, b?: string) => boolean> = (\n\t\t\ttransactors,\n\t\t\ta,\n\t\t\tb,\n\t\t) => {\n\t\t\tconst aKeys = getRelatedKeys(transactors, a)\n\t\t\treturn b ? aKeys.has(b) : aKeys.size > 0\n\t\t}\n\t\tconst baseExternalStoreConfiguration: BaseExternalStoreConfiguration = {\n\t\t\tgetRelatedKeys: (key) => getRelatedKeys(this.transactors, key),\n\t\t\taddRelation: (a, b) => addRelation(this.transactors, a, b),\n\t\t\tdeleteRelation: (a, b) => deleteRelation(this.transactors, a, b),\n\t\t\treplaceRelationsSafely: (a, bs) =>\n\t\t\t\treplaceRelationsSafely(this.transactors, a, bs),\n\t\t\treplaceRelationsUnsafely: (a, bs) =>\n\t\t\t\treplaceRelationsUnsafely(this.transactors, a, bs),\n\t\t\thas: (a, b) => has(this.transactors, a, b),\n\t\t}\n\t\tlet externalStore: ExternalStoreConfiguration<Content>\n\t\tlet contentAtoms: RegularAtomFamily<Content, string>\n\t\tif (defaultContent) {\n\t\t\tcontentAtoms = createRegularAtomFamily<Content, string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/content`,\n\t\t\t\t\tdefault: defaultContent,\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\t\t\tconst getContent: Read<(key: string) => Content | null> = (\n\t\t\t\t{ find, get },\n\t\t\t\tkey,\n\t\t\t) => get(find(contentAtoms, key))\n\t\t\tconst setContent: Write<(key: string, content: Content) => void> = (\n\t\t\t\t{ find, set },\n\t\t\t\tkey,\n\t\t\t\tcontent,\n\t\t\t) => set(find(contentAtoms, key), content)\n\t\t\tconst deleteContent: Write<(key: string) => void> = ({ find }, key) =>\n\t\t\t\tdispose(find(contentAtoms, key))\n\t\t\tconst externalStoreWithContentConfiguration = {\n\t\t\t\tgetContent: (contentKey: string) => {\n\t\t\t\t\tconst content = getContent(this.transactors, contentKey)\n\t\t\t\t\treturn content\n\t\t\t\t},\n\t\t\t\tsetContent: (contentKey: string, content: Content) => {\n\t\t\t\t\tsetContent(this.transactors, contentKey, content)\n\t\t\t\t},\n\t\t\t\tdeleteContent: (contentKey: string) => {\n\t\t\t\t\tdeleteContent(this.transactors, contentKey)\n\t\t\t\t},\n\t\t\t}\n\t\t\texternalStore = Object.assign(\n\t\t\t\tbaseExternalStoreConfiguration,\n\t\t\t\texternalStoreWithContentConfiguration,\n\t\t\t) as ExternalStoreConfiguration<Content>\n\t\t} else {\n\t\t\texternalStore =\n\t\t\t\tbaseExternalStoreConfiguration as ExternalStoreConfiguration<Content>\n\t\t}\n\t\tconst relations = new Junction<ASide, BSide, Content>(options, {\n\t\t\texternalStore,\n\t\t\tmakeContentKey: (...args) => args.sort().join(`:`),\n\t\t})\n\n\t\tconst createSingleKeyStateFamily = () =>\n\t\t\tcreateSelectorFamily<string | null, string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/singleRelatedKey`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ find, get }) => {\n\t\t\t\t\t\t\tconst relatedKeysState = find(relatedKeysAtoms, key)\n\t\t\t\t\t\t\tconst relatedKeys = get(relatedKeysState)\n\t\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\t\treturn relatedKey\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn null\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\t\tconst getMultipleKeyStateFamily = () => {\n\t\t\treturn createSelectorFamily<string[], string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/multipleRelatedKeys`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ find, get }) => {\n\t\t\t\t\t\t\tconst jsonFamily = getJsonFamily(relatedKeysAtoms, store)\n\t\t\t\t\t\t\tconst jsonState = find(jsonFamily, key)\n\t\t\t\t\t\t\tconst json = get(jsonState)\n\t\t\t\t\t\t\treturn json.members\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\t\t}\n\t\tconst createSingleEntryStateFamily = () =>\n\t\t\tcreateSelectorFamily<[string, Content] | null, string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/singleRelatedEntry`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ find, get }) => {\n\t\t\t\t\t\t\tconst relatedKeysState = find(relatedKeysAtoms, key)\n\t\t\t\t\t\t\tconst relatedKeys = get(relatedKeysState)\n\t\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\t\tconst contentKey = relations.makeContentKey(key, relatedKey)\n\t\t\t\t\t\t\t\tconst contentState = find(contentAtoms, contentKey)\n\t\t\t\t\t\t\t\tconst content = get(contentState)\n\t\t\t\t\t\t\t\treturn [relatedKey, content]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn null\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\t\tconst getMultipleEntryStateFamily = () =>\n\t\t\tcreateSelectorFamily<[string, Content][], string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/multipleRelatedEntries`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ find, get }) => {\n\t\t\t\t\t\t\tconst jsonFamily = getJsonFamily(relatedKeysAtoms, store)\n\t\t\t\t\t\t\tconst json = get(jsonFamily(key))\n\t\t\t\t\t\t\treturn json.members.map((relatedKey) => {\n\t\t\t\t\t\t\t\tconst contentKey = relations.makeContentKey(key, relatedKey)\n\t\t\t\t\t\t\t\tconst contentState = find(contentAtoms, contentKey)\n\t\t\t\t\t\t\t\tconst content = get(contentState)\n\t\t\t\t\t\t\t\treturn [relatedKey, content]\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\n\t\tswitch (options.cardinality) {\n\t\t\tcase `1:1`: {\n\t\t\t\tconst findSingleRelatedKeyState = createSingleKeyStateFamily()\n\t\t\t\tconst stateKeyA = `${a}KeyOf${capitalize(b)}` as const\n\t\t\t\tconst stateKeyB = `${b}KeyOf${capitalize(a)}` as const\n\t\t\t\tconst baseStates = {\n\t\t\t\t\t[stateKeyA]: findSingleRelatedKeyState,\n\t\t\t\t\t[stateKeyB]: findSingleRelatedKeyState,\n\t\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tlet states: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tif (defaultContent) {\n\t\t\t\t\tconst findSingleRelatedEntryState = createSingleEntryStateFamily()\n\t\t\t\t\tconst entriesStateKeyA = `${a}EntryOf${capitalize(b)}` as const\n\t\t\t\t\tconst entriesStateKeyB = `${b}EntryOf${capitalize(a)}` as const\n\t\t\t\t\tconst contentStates = {\n\t\t\t\t\t\t[entriesStateKeyA]: findSingleRelatedEntryState,\n\t\t\t\t\t\t[entriesStateKeyB]: findSingleRelatedEntryState,\n\t\t\t\t\t}\n\t\t\t\t\tstates = Object.assign(baseStates, contentStates)\n\t\t\t\t} else {\n\t\t\t\t\tstates = baseStates\n\t\t\t\t}\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = states\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `1:n`: {\n\t\t\t\tconst findSingleRelatedKeyState = createSingleKeyStateFamily()\n\t\t\t\tconst findMultipleRelatedKeysState = getMultipleKeyStateFamily()\n\t\t\t\tconst stateKeyA = `${a}KeyOf${capitalize(b)}` as const\n\t\t\t\tconst stateKeyB = `${b}KeysOf${capitalize(a)}` as const\n\t\t\t\tconst baseStates = {\n\t\t\t\t\t[stateKeyA]: findSingleRelatedKeyState,\n\t\t\t\t\t[stateKeyB]: findMultipleRelatedKeysState,\n\t\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tlet states: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tif (defaultContent) {\n\t\t\t\t\tconst findSingleRelatedEntryState = createSingleEntryStateFamily()\n\t\t\t\t\tconst findMultipleRelatedEntriesState = getMultipleEntryStateFamily()\n\t\t\t\t\tconst entriesStateKeyA = `${a}EntryOf${capitalize(b)}` as const\n\t\t\t\t\tconst entriesStateKeyB = `${b}EntriesOf${capitalize(a)}` as const\n\t\t\t\t\tconst contentStates = {\n\t\t\t\t\t\t[entriesStateKeyA]: findSingleRelatedEntryState,\n\t\t\t\t\t\t[entriesStateKeyB]: findMultipleRelatedEntriesState,\n\t\t\t\t\t}\n\t\t\t\t\tstates = Object.assign(baseStates, contentStates)\n\t\t\t\t} else {\n\t\t\t\t\tstates = baseStates\n\t\t\t\t}\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = states\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconst findMultipleRelatedKeysState = getMultipleKeyStateFamily()\n\t\t\t\tconst stateKeyA = `${a}KeysOf${capitalize(b)}` as const\n\t\t\t\tconst stateKeyB = `${b}KeysOf${capitalize(a)}` as const\n\t\t\t\tconst baseStates = {\n\t\t\t\t\t[stateKeyA]: findMultipleRelatedKeysState,\n\t\t\t\t\t[stateKeyB]: findMultipleRelatedKeysState,\n\t\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tlet states: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tif (defaultContent) {\n\t\t\t\t\tconst findMultipleRelatedEntriesState = getMultipleEntryStateFamily()\n\t\t\t\t\tconst entriesStateKeyA = `${a}EntriesOf${capitalize(b)}` as const\n\t\t\t\t\tconst entriesStateKeyB = `${b}EntriesOf${capitalize(a)}` as const\n\t\t\t\t\tconst contentStates = {\n\t\t\t\t\t\t[entriesStateKeyA]: findMultipleRelatedEntriesState,\n\t\t\t\t\t\t[entriesStateKeyB]: findMultipleRelatedEntriesState,\n\t\t\t\t\t}\n\t\t\t\t\tstates = Object.assign(baseStates, contentStates)\n\t\t\t\t} else {\n\t\t\t\t\tstates = baseStates\n\t\t\t\t}\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = states\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function join<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, null>,\n\tdefaultContent?: undefined,\n\tstore?: Store,\n): {\n\treadonly relations: Junction<ASide, BSide, null>\n\treadonly states: JoinState<ASide, BSide, Cardinality, null>\n\treadonly in: (store: Store) => Join<ASide, BSide, Cardinality>\n\treadonly transact: (\n\t\ttransactors: Transactors,\n\t\trun: (join: Join<ASide, BSide, Cardinality, null>) => void,\n\t) => void\n\treadonly core: {\n\t\treadonly findRelatedKeysState: MutableAtomFamily<\n\t\t\tSetRTX<string>,\n\t\t\tSetRTXJson<string>,\n\t\t\tstring\n\t\t>\n\t}\n}\nexport function join<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n\tconst Content extends Json.Object,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\tdefaultContent: Content,\n\tstore?: Store,\n): {\n\treadonly relations: Junction<ASide, BSide, Content>\n\treadonly states: JoinState<ASide, BSide, Cardinality, Content>\n\treadonly in: (store: Store) => Join<ASide, BSide, Cardinality, Content>\n\treadonly transact: (\n\t\ttransactors: Transactors,\n\t\trun: (join: Join<ASide, BSide, Cardinality, Content>) => void,\n\t) => void\n\treadonly core: {\n\t\treadonly findRelatedKeysState: MutableAtomFamily<\n\t\t\tSetRTX<string>,\n\t\t\tSetRTXJson<string>,\n\t\t\tstring\n\t\t>\n\t}\n}\nexport function join<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n\tContent extends Json.Object,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\tdefaultContent: Content | undefined,\n\tstore: Store = IMPLICIT.STORE,\n): Join<ASide, BSide, Cardinality, Content> {\n\treturn new Join(options, defaultContent, store)\n}\n","import type { Cardinality, Json, Refinement } from \"rel8\"\n\nexport interface JunctionEntries<Content extends Json.Object | null>\n\textends Json.Object {\n\treadonly relations: [string, string[]][]\n\treadonly contents: [string, Content][]\n}\nexport interface JunctionSchema<ASide extends string, BSide extends string>\n\textends Json.Object {\n\treadonly between: [a: ASide, b: BSide]\n\treadonly cardinality: Cardinality\n}\n\nexport type BaseExternalStoreConfiguration = {\n\taddRelation: (a: string, b: string) => void\n\tdeleteRelation: (a: string, b: string) => void\n\treplaceRelationsSafely: (a: string, bs: string[]) => void\n\treplaceRelationsUnsafely: (a: string, bs: string[]) => void\n\tgetRelatedKeys: (key: string) => Set<string> | undefined\n\thas: (a: string, b?: string) => boolean\n}\n\nexport type ExternalStoreWithContentConfiguration<Content extends Json.Object> =\n\t{\n\t\tgetContent: (contentKey: string) => Content | undefined\n\t\tsetContent: (contentKey: string, content: Content) => void\n\t\tdeleteContent: (contentKey: string) => void\n\t}\n\nexport type Empty<Obj extends object> = {\n\t[Key in keyof Obj]?: undefined\n}\n\nexport type ExternalStoreConfiguration<Content extends Json.Object | null> =\n\tContent extends Json.Object\n\t\t? BaseExternalStoreConfiguration &\n\t\t\t\tExternalStoreWithContentConfiguration<Content>\n\t\t: BaseExternalStoreConfiguration &\n\t\t\t\tEmpty<ExternalStoreWithContentConfiguration<Json.Object>>\n\nexport type JunctionAdvancedConfiguration<Content extends Json.Object | null> = {\n\texternalStore?: ExternalStoreConfiguration<Content>\n\tisContent?: Refinement<unknown, Content>\n\tmakeContentKey?: (a: string, b: string) => string\n}\n\nexport type JunctionJSON<\n\tASide extends string,\n\tBSide extends string,\n\tContent extends Json.Object | null,\n> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>\n\nexport class Junction<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Content extends Json.Object | null = null,\n> {\n\tpublic readonly a: ASide\n\tpublic readonly b: BSide\n\tpublic readonly cardinality: Cardinality\n\tpublic readonly relations = new Map<string, Set<string>>()\n\tpublic readonly contents = new Map<string, Content>()\n\n\tpublic isContent: Refinement<unknown, Content> | null\n\tpublic makeContentKey = (a: string, b: string): string => `${a}:${b}`\n\n\tpublic getRelatedKeys(key: string): Set<string> | undefined {\n\t\treturn this.relations.get(key)\n\t}\n\tprotected addRelation(a: string, b: string): void {\n\t\tlet aRelations = this.relations.get(a)\n\t\tlet bRelations = this.relations.get(b)\n\t\tif (aRelations) {\n\t\t\taRelations.add(b)\n\t\t} else {\n\t\t\taRelations = new Set([b])\n\t\t\tthis.relations.set(a, aRelations)\n\t\t}\n\t\tif (bRelations) {\n\t\t\tbRelations.add(a)\n\t\t} else {\n\t\t\tbRelations = new Set([a])\n\t\t\tthis.relations.set(b, bRelations)\n\t\t}\n\t}\n\tprotected deleteRelation(a: string, b: string): void {\n\t\tconst aRelations = this.relations.get(a)\n\t\tif (aRelations) {\n\t\t\taRelations.delete(b)\n\t\t\tif (aRelations.size === 0) {\n\t\t\t\tthis.relations.delete(a)\n\t\t\t}\n\t\t\tconst bRelations = this.relations.get(b)\n\t\t\tif (bRelations) {\n\t\t\t\tbRelations.delete(a)\n\t\t\t\tif (bRelations.size === 0) {\n\t\t\t\t\tthis.relations.delete(b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected replaceRelationsUnsafely(a: string, bs: string[]): void {\n\t\tthis.relations.set(a, new Set(bs))\n\t\tfor (const b of bs) {\n\t\t\tconst bRelations = new Set([a])\n\t\t\tthis.relations.set(b, bRelations)\n\t\t}\n\t}\n\tprotected replaceRelationsSafely(a: string, bs: string[]): void {\n\t\tconst aRelationsPrev = this.relations.get(a)\n\t\tif (aRelationsPrev) {\n\t\t\tfor (const b of aRelationsPrev) {\n\t\t\t\tconst bRelations = this.relations.get(b)\n\t\t\t\tif (bRelations) {\n\t\t\t\t\tif (bRelations.size === 1) {\n\t\t\t\t\t\tthis.relations.delete(b)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbRelations.delete(a)\n\t\t\t\t\t}\n\t\t\t\t\tthis.contents.delete(this.makeContentKey(a, b))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.relations.set(a, new Set(bs))\n\t\tfor (const b of bs) {\n\t\t\tlet bRelations = this.relations.get(b)\n\t\t\tif (bRelations) {\n\t\t\t\tbRelations.add(a)\n\t\t\t} else {\n\t\t\t\tbRelations = new Set([a])\n\t\t\t\tthis.relations.set(b, bRelations)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected getContentInternal(contentKey: string): Content | undefined {\n\t\treturn this.contents.get(contentKey)\n\t}\n\tprotected setContent(contentKey: string, content: Content): void {\n\t\tthis.contents.set(contentKey, content)\n\t}\n\tprotected deleteContent(contentKey: string): void {\n\t\tthis.contents.delete(contentKey)\n\t}\n\n\tpublic constructor(\n\t\tdata: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>,\n\t\tconfig?: JunctionAdvancedConfiguration<Content>,\n\t) {\n\t\tthis.a = data.between[0]\n\t\tthis.b = data.between[1]\n\n\t\tthis.cardinality = data.cardinality\n\t\tif (!config?.externalStore) {\n\t\t\tthis.relations = new Map(data.relations?.map(([a, b]) => [a, new Set(b)]))\n\t\t\tthis.contents = new Map(data.contents)\n\t\t}\n\t\tthis.isContent = config?.isContent ?? null\n\t\tif (config?.makeContentKey) {\n\t\t\tthis.makeContentKey = config.makeContentKey\n\t\t}\n\t\tif (config?.externalStore) {\n\t\t\tconst externalStore = config.externalStore\n\t\t\tthis.has = (a, b) => externalStore.has(a, b)\n\t\t\tthis.addRelation = (a, b) => {\n\t\t\t\texternalStore.addRelation(a, b)\n\t\t\t}\n\t\t\tthis.deleteRelation = (a, b) => {\n\t\t\t\texternalStore.deleteRelation(a, b)\n\t\t\t}\n\t\t\tthis.replaceRelationsSafely = (a, bs) => {\n\t\t\t\texternalStore.replaceRelationsSafely(a, bs)\n\t\t\t}\n\t\t\tthis.replaceRelationsUnsafely = (a, bs) => {\n\t\t\t\texternalStore.replaceRelationsUnsafely(a, bs)\n\t\t\t}\n\t\t\tthis.getRelatedKeys = (key) => externalStore.getRelatedKeys(key)\n\t\t\tif (externalStore.getContent) {\n\t\t\t\tthis.getContentInternal = (contentKey) => {\n\t\t\t\t\treturn externalStore.getContent(contentKey) as any\n\t\t\t\t}\n\t\t\t\tthis.setContent = (contentKey, content) => {\n\t\t\t\t\texternalStore.setContent(contentKey, content as any)\n\t\t\t\t}\n\t\t\t\tthis.deleteContent = (contentKey) => {\n\t\t\t\t\texternalStore.deleteContent(contentKey)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [x, ys] of data.relations ?? []) {\n\t\t\t\tfor (const y of ys) this.addRelation(x, y)\n\t\t\t}\n\t\t\tfor (const [contentKey, content] of data.contents ?? []) {\n\t\t\t\tthis.setContent(contentKey, content)\n\t\t\t}\n\t\t}\n\t}\n\tpublic toJSON(): JunctionJSON<ASide, BSide, Content> {\n\t\treturn {\n\t\t\tbetween: [this.a, this.b],\n\t\t\tcardinality: this.cardinality,\n\t\t\trelations: [...this.relations.entries()].map(([a, b]) => [a, [...b]]),\n\t\t\tcontents: [...this.contents.entries()],\n\t\t}\n\t}\n\n\tpublic set(\n\t\ta: string,\n\t\t...rest: Content extends null ? [b: string] : [b: string, content: Content]\n\t): this\n\tpublic set(\n\t\trelation: { [Key in ASide | BSide]: string },\n\t\t...rest: Content extends null ? [] | [b?: undefined] : [content: Content]\n\t): this\n\tpublic set(\n\t\ta: string | { [Key in ASide | BSide]: string },\n\t\t...rest: Content extends null\n\t\t\t? [] | [b?: string | undefined]\n\t\t\t: [b: string, content: Content] | [content: Content]\n\t): this {\n\t\tconst b: string =\n\t\t\ttypeof rest[0] === `string`\n\t\t\t\t? rest[0]\n\t\t\t\t: (a[this.b as keyof typeof a] as string)\n\t\tconst content: Content | undefined =\n\t\t\trest[1] ?? typeof rest[0] === `string` ? undefined : (rest[0] as Content)\n\t\ta = typeof a === `string` ? a : a[this.a]\n\t\tswitch (this.cardinality) {\n\t\t\t// biome-ignore lint/suspicious/noFallthroughSwitchClause: perfect here\n\t\t\tcase `1:1`: {\n\t\t\t\tconst bPrev = this.getRelatedKey(a)\n\t\t\t\tif (bPrev && bPrev !== b) this.delete(bPrev, a)\n\t\t\t}\n\t\t\tcase `1:n`: {\n\t\t\t\tconst aPrev = this.getRelatedKey(b)\n\t\t\t\tif (aPrev && aPrev !== a) this.delete(aPrev, b)\n\t\t\t}\n\t\t}\n\t\tif (content) {\n\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\tthis.setContent(contentKey, content)\n\t\t}\n\t\tthis.addRelation(a, b)\n\t\treturn this\n\t}\n\n\tpublic delete(a: string, b?: string): this\n\tpublic delete(\n\t\trelation:\n\t\t\t| Record<ASide | BSide, string>\n\t\t\t| Record<ASide, string>\n\t\t\t| Record<BSide, string>,\n\t\tb?: undefined,\n\t): this\n\tpublic delete(\n\t\tx:\n\t\t\t| Record<ASide | BSide, string>\n\t\t\t| Record<ASide, string>\n\t\t\t| Record<BSide, string>\n\t\t\t| string,\n\t\tb?: string | undefined,\n\t): this {\n\t\t// @ts-expect-error we deduce that this.b may index x\n\t\tb = typeof b === `string` ? b : (x[this.b] as string | undefined)\n\t\t// @ts-expect-error we deduce that this.a may index x\n\t\tconst a = typeof x === `string` ? x : (x[this.a] as string | undefined)\n\n\t\tif (a === undefined && typeof b === `string`) {\n\t\t\tconst bRelations = this.getRelatedKeys(b)\n\t\t\tif (bRelations) {\n\t\t\t\tfor (const a of bRelations) {\n\t\t\t\t\tthis.delete(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (typeof a === `string` && b === undefined) {\n\t\t\tconst aRelations = this.getRelatedKeys(a)\n\t\t\tif (aRelations) {\n\t\t\t\tfor (const b of aRelations) {\n\t\t\t\t\tthis.delete(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (typeof a === `string` && typeof b === `string`) {\n\t\t\tthis.deleteRelation(a, b)\n\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\tthis.deleteContent(contentKey)\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getRelatedKey(key: string): string | undefined {\n\t\tconst relations = this.getRelatedKeys(key)\n\t\tif (relations) {\n\t\t\tif (relations.size > 1) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${relations.size} related keys were found for key \"${key}\": (${[\n\t\t\t\t\t\t...relations,\n\t\t\t\t\t]\n\t\t\t\t\t\t.map((k) => `\"${k}\"`)\n\t\t\t\t\t\t.join(`, `)}). Only one related key was expected.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const relation of relations) {\n\t\t\t\treturn relation\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic replaceRelations(\n\t\ta: string,\n\t\trelations: Content extends null ? string[] : Record<string, Content>,\n\t\tconfig?: { reckless: boolean },\n\t): this {\n\t\tconst hasContent = !Array.isArray(relations)\n\t\tconst bs = hasContent ? Object.keys(relations) : relations\n\t\tif (config?.reckless) {\n\t\t\tthis.replaceRelationsUnsafely(a, bs)\n\t\t} else {\n\t\t\tthis.replaceRelationsSafely(a, bs)\n\t\t}\n\t\tif (hasContent) {\n\t\t\tfor (const b of bs) {\n\t\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\t\tconst content = relations[b] as Content\n\t\t\t\tthis.setContent(contentKey, content)\n\t\t\t}\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getContent(a: string, b: string): Content | undefined {\n\t\tconst contentKey = this.makeContentKey(a, b)\n\t\treturn this.getContentInternal(contentKey)\n\t}\n\n\tpublic getRelationEntries(\n\t\tinput: Record<ASide, string> | Record<BSide, string>,\n\t): [string, Content][] {\n\t\tconst a: string | undefined = (input as any)[this.a]\n\t\tconst b: string | undefined = (input as any)[this.b]\n\t\tif (a !== undefined && b === undefined) {\n\t\t\tconst aRelations = this.getRelatedKeys(a)\n\t\t\tif (aRelations) {\n\t\t\t\treturn [...aRelations].map((b) => {\n\t\t\t\t\treturn [b, this.getContent(a, b) ?? (null as Content)]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (a === undefined && b !== undefined) {\n\t\t\tconst bRelations = this.getRelatedKeys(b)\n\t\t\tif (bRelations) {\n\t\t\t\treturn [...bRelations].map((a) => {\n\t\t\t\t\treturn [a, this.getContent(a, b) ?? (null as Content)]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn []\n\t}\n\n\tpublic has(a: string, b?: string): boolean {\n\t\tif (b) {\n\t\t\tconst setA = this.getRelatedKeys(a)\n\t\t\treturn setA?.has(b) ?? false\n\t\t}\n\t\treturn this.relations.has(a)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\n\nimport { createRegularAtom, createStandaloneSelector } from \"atom.io/internal\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\n\nexport function struct<\n\tStruct extends { [key: string]: unknown },\n\tKey extends string,\n>(\n\toptions: {\n\t\tkey: Key\n\t\tdefault: Struct\n\t},\n\tstore: Store = IMPLICIT.STORE,\n): [\n\t{\n\t\t[K in keyof Struct as `${Key}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.RegularAtomToken<Struct[K]>\n\t},\n\tAtomIO.ReadonlySelectorToken<Struct>,\n] {\n\tconst atoms: {\n\t\t[K in keyof Struct as `${Key}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.RegularAtomToken<Struct[K]>\n\t} = Object.keys(options.default).reduce((acc, key) => {\n\t\tconst atomName = options.key + capitalize(key) + `State`\n\t\tacc[atomName] = createRegularAtom(\n\t\t\t{\n\t\t\t\tkey: `${options.key}.${key}`,\n\t\t\t\tdefault: options.default[key],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\t\treturn acc\n\t}, {} as any)\n\tconst structState = createStandaloneSelector(\n\t\t{\n\t\t\tkey: options.key,\n\t\t\tget: ({ get }) => {\n\t\t\t\treturn Object.keys(options.default).reduce((acc, key) => {\n\t\t\t\t\tacc[key] = get(atoms[options.key + capitalize(key) + `State`])\n\t\t\t\t\treturn acc\n\t\t\t\t}, {} as any)\n\t\t\t},\n\t\t},\n\t\tstore,\n\t)\n\treturn [atoms, structState]\n}\n","import type * as AtomIO from \"atom.io\"\nimport {\n\tIMPLICIT,\n\tcreateRegularAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\nconst nameFamily = (topKey: string, subKey: string) =>\n\t`find` + capitalize(topKey) + capitalize(subKey) + `State`\n\nexport function structFamily<\n\tStruct extends object,\n\tKey extends string,\n>(options: {\n\tkey: Key\n\tdefault: Struct\n}): [\n\t{\n\t\t[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.RegularAtomFamily<Struct[K], string>\n\t},\n\tAtomIO.ReadonlySelectorFamilyToken<Struct, string>,\n] {\n\tconst atoms: {\n\t\t[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.RegularAtomFamily<Struct[K], string>\n\t} = Object.keys(options.default).reduce((acc, subKey) => {\n\t\tconst atomFamilyName = nameFamily(options.key, subKey)\n\t\tacc[atomFamilyName] = createRegularAtomFamily(\n\t\t\t{\n\t\t\t\tkey: `${options.key}.${subKey}`,\n\t\t\t\tdefault: (options.default as any)[subKey],\n\t\t\t},\n\t\t\tIMPLICIT.STORE,\n\t\t)\n\t\treturn acc\n\t}, {} as any)\n\tconst findStructState: AtomIO.ReadonlySelectorFamilyToken<Struct, string> =\n\t\tcreateSelectorFamily(\n\t\t\t{\n\t\t\t\tkey: options.key,\n\t\t\t\tget:\n\t\t\t\t\t(id) =>\n\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\treturn Object.keys(options.default).reduce((acc, subKey) => {\n\t\t\t\t\t\t\tacc[subKey] = get(\n\t\t\t\t\t\t\t\t(atoms as any)[nameFamily(options.key, subKey)](id),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t}, {} as any)\n\t\t\t\t\t},\n\t\t\t},\n\t\t\tIMPLICIT.STORE,\n\t\t)\n\treturn [atoms, findStructState]\n}\n","export type Loadable<T> = Promise<T> | T\nexport type Fated<T, E extends Error = Error> = Loadable<E | T>\n\n/**\n * Utility for handling loadable values\n * @param loadable Loadable value\n * @param fallback Fallback value until Loadable is resolved\n * @returns Fallback value if your loadable is a promise, otherwise the loadable's resolved value\n */\nexport function until<T>(loadable: Loadable<T>, fallback: T): T {\n\tif (loadable instanceof Promise) {\n\t\treturn fallback\n\t}\n\treturn loadable\n}\n"]}
|
package/data/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dict.ts","../src/join.ts","../src/struct.ts","../src/struct-family.ts","../src/until.ts"],"names":["findState","IMPLICIT","findInStore","join","a","b","createStandaloneSelector","capitalize","createRegularAtomFamily","createSelectorFamily"],"mappings":";;;;;;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAGA,SAAS,KACfA,YAIA,OAIA,QAAe,SAAS,OAC2C;AACnE,SAAO;AAAA,IACN;AAAA,MACC,KAAK,GAAGA,WAAU,GAAG;AAAA,MACrB,KAAK,CAAC,EAAE,IAAI,MAAM;AACjB,cAAM,OAAO,IAAI,KAAK;AACtB,eAAO,KAAK,OAAO,CAAC,KAAK,QAAQ;AAChC,cAAI,GAAG,IAAI,IAAI,YAAYA,YAAW,KAAK,KAAK,CAAC;AACjD,iBAAO;AAAA,QACR,GAAG,CAAC,CAAQ;AAAA,MACb;AAAA,I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AAA,EACD;AACA,SAAO,CAAC,OAAO,WAAW;AAC3B;;;ACrDA;AAAA,EACC,YAAAN;AAAA,EACA,2BAAAO;AAAA,EACA,wBAAAC;AAAA,OACM;AAEP,IAAMF,cAAa,CAAC,QAAgB,IAAI,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AACtE,IAAM,aAAa,CAAC,QAAgB,WACnC,SAASA,YAAW,MAAM,IAAIA,YAAW,MAAM,IAAI;AAE7C,SAAS,aAGd,SAUA;AACD,QAAM,QAIF,OAAO,KAAK,QAAQ,OAAO,EAAE,OAAO,CAAC,KAAK,WAAW;AACxD,UAAM,iBAAiB,WAAW,QAAQ,KAAK,MAAM;AACrD,QAAI,cAAc,IAAIC;AAAA,MACrB;AAAA,QACC,KAAK,GAAG,QAAQ,GAAG,IAAI,MAAM;AAAA,QAC7B,SAAU,QAAQ,QAAgB,MAAM;AAAA,MACzC;AAAA,MACAP,UAAS;AAAA,IACV;AACA,WAAO;AAAA,EACR,GAAG,CAAC,CAAQ;AACZ,QAAM,kBACLQ;AAAA,IACC;AAAA,MACC,KAAK,QAAQ;AAAA,MACb,KACC,CAAC,OACD,CAAC,EAAE,IAAI,MAAM;AACZ,eAAO,OAAO,KAAK,QAAQ,OAAO,EAAE,OAAO,CAAC,KAAK,WAAW;AAC3D,cAAI,MAAM,IAAI;AAAA,YACZ,MAAc,WAAW,QAAQ,KAAK,MAAM,CAAC,EAAE,EAAE;AAAA,UACnD;AACA,iBAAO;AAAA,QACR,GAAG,CAAC,CAAQ;AAAA,MACb;AAAA,IACF;AAAA,IACAR,UAAS;AAAA,EACV;AACD,SAAO,CAAC,OAAO,eAAe;AAC/B;;;ACjDO,SAAS,MAAS,UAAuB,UAAgB;AAC/D,MAAI,oBAAoB,SAAS;AAChC,WAAO;AAAA,EACR;AACA,SAAO;AACR","sourcesContent":["import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateStandaloneSelector,\n\tfindInStore,\n} from \"atom.io/internal\"\nimport type { Json, Stringified } from \"atom.io/json\"\n\nexport function dict<State, Key extends Json.Serializable>(\n\tfindState:\n\t\t| AtomIO.ReadonlySelectorFamilyToken<State, Key>\n\t\t| AtomIO.RegularAtomFamilyToken<State, Key>\n\t\t| AtomIO.WritableSelectorFamily<State, Key>,\n\tindex:\n\t\t| AtomIO.ReadonlySelectorToken<Key[]>\n\t\t| AtomIO.RegularAtomToken<Key[]>\n\t\t| AtomIO.WritableSelectorToken<Key[]>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomIO.ReadonlySelectorToken<{ [K in Stringified<Key>]: State }> {\n\treturn createStandaloneSelector(\n\t\t{\n\t\t\tkey: `${findState.key}Dict`,\n\t\t\tget: ({ get }) => {\n\t\t\t\tconst keys = get(index)\n\t\t\t\treturn keys.reduce((acc, key) => {\n\t\t\t\t\tacc[key] = get(findInStore(findState, key, store))\n\t\t\t\t\treturn acc\n\t\t\t\t}, {} as any)\n\t\t\t},\n\t\t},\n\t\tstore,\n\t)\n}\n","/* eslint-disable @typescript-eslint/ban-types */\nimport type {\n\tMutableAtomFamily,\n\tRead,\n\tReadonlySelectorFamily,\n\tRegularAtomFamily,\n\tTransactors,\n\tWrite,\n} from \"atom.io\"\nimport { dispose, findState, getState, setState } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateMutableAtomFamily,\n\tcreateRegularAtomFamily,\n\tcreateSelectorFamily,\n\tfindInStore,\n\tgetFromStore,\n\tgetJsonFamily,\n\tsetIntoStore,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport type { SetRTXJson } from \"atom.io/transceivers/set-rtx\"\nimport { SetRTX } from \"atom.io/transceivers/set-rtx\"\n\nimport type {\n\tBaseExternalStoreConfiguration,\n\tExternalStoreConfiguration,\n\tJunctionEntries,\n\tJunctionSchema,\n} from \"~/packages/rel8/junction/src\"\nimport { Junction } from \"~/packages/rel8/junction/src\"\nimport type * as Rel8 from \"~/packages/rel8/types/src\"\n\nconst TRANSACTORS: Transactors = {\n\tget: getState,\n\tset: setState,\n\tfind: findState,\n}\n\nfunction capitalize<S extends string>(string: S): Capitalize<S> {\n\treturn (string[0].toUpperCase() + string.slice(1)) as Capitalize<S>\n}\n\nexport interface JoinOptions<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object | null,\n> extends Json.Object,\n\t\tJunctionSchema<ASide, BSide>,\n\t\tPartial<JunctionEntries<Content>> {\n\treadonly key: string\n\treadonly cardinality: Cardinality\n}\n\nexport type JoinState<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object | null,\n> = Cardinality extends `1:1`\n\t? (Content extends Json.Object\n\t\t\t? {\n\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t? `${AB}EntryOf${Capitalize<BSide>}`\n\t\t\t\t\t\t: `${AB}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\t[string, Content] | null,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>\n\t\t\t }\n\t\t\t: {}) & {\n\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t? `${AB}KeyOf${Capitalize<BSide>}`\n\t\t\t\t: `${AB}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\tstring | null,\n\t\t\t\tstring\n\t\t\t>\n\t }\n\t: Cardinality extends `1:n`\n\t ? (Content extends Json.Object\n\t\t\t\t? {\n\t\t\t\t\t\treadonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\t\t[string, Content] | null,\n\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t>\n\t\t\t\t } & {\n\t\t\t\t\t\treadonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\t\t[string, Content][],\n\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t>\n\t\t\t\t }\n\t\t\t\t: {}) & {\n\t\t\t\treadonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\tstring | null,\n\t\t\t\t\tstring\n\t\t\t\t>\n\t\t } & {\n\t\t\t\treadonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\tstring[],\n\t\t\t\t\tstring\n\t\t\t\t>\n\t\t }\n\t : Cardinality extends `n:n`\n\t\t ? (Content extends Json.Object\n\t\t\t\t\t? {\n\t\t\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t\t\t? `${AB}EntriesOf${Capitalize<BSide>}`\n\t\t\t\t\t\t\t\t: `${AB}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\t\t\t[string, Content][],\n\t\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t\t>\n\t\t\t\t\t }\n\t\t\t\t\t: {}) & {\n\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t? `${AB}KeysOf${Capitalize<BSide>}`\n\t\t\t\t\t\t: `${AB}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamily<\n\t\t\t\t\t\tstring[],\n\t\t\t\t\t\tstring\n\t\t\t\t\t>\n\t\t\t }\n\t\t : never\n\nexport class Join<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n\tconst Content extends Json.Object | null = null,\n> {\n\tprivate options: JoinOptions<ASide, BSide, Cardinality, Content>\n\tprivate defaultContent: Content | undefined\n\tprivate transactors: Transactors\n\tpublic relations: Junction<ASide, BSide, Content>\n\tpublic states: JoinState<ASide, BSide, Cardinality, Content>\n\tpublic core: {\n\t\tfindRelatedKeysState: MutableAtomFamily<\n\t\t\tSetRTX<string>,\n\t\t\tSetRTXJson<string>,\n\t\t\tstring\n\t\t>\n\t}\n\tpublic transact(\n\t\ttransactors: Transactors,\n\t\trun: (join: Join<ASide, BSide, Cardinality, Content>) => void,\n\t): void {\n\t\tconst originalTransactors = this.transactors\n\t\tthis.transactors = transactors\n\t\trun(this)\n\t\tthis.transactors = originalTransactors\n\t}\n\n\tpublic alternates: Map<string, Join<ASide, BSide, Cardinality, Content>>\n\tpublic in(store: Store): Join<ASide, BSide, Cardinality, Content> {\n\t\tconst key = store.config.name\n\t\tconst alternate = this.alternates.get(key)\n\t\tif (alternate) {\n\t\t\treturn alternate\n\t\t}\n\t\tconst join = new Join(this.options, this.defaultContent, store)\n\t\tthis.alternates.set(key, join)\n\t\tjoin.alternates = this.alternates\n\t\treturn join\n\t}\n\n\tpublic constructor(\n\t\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\t\tdefaultContent: Content | undefined,\n\t\tstore: Store = IMPLICIT.STORE,\n\t) {\n\t\tthis.options = options\n\t\tthis.defaultContent = defaultContent\n\t\tthis.alternates = new Map()\n\t\tthis.alternates.set(store.config.name, this)\n\t\tthis.transactors = {\n\t\t\tget: (token) => getFromStore(token, store),\n\t\t\tset: (token, value) => setIntoStore(token, value, store),\n\t\t\tfind: ((token, key) => findInStore(token, key, store)) as typeof findState,\n\t\t}\n\t\tconst a: ASide = options.between[0]\n\t\tconst b: BSide = options.between[1]\n\t\tconst relatedKeysAtoms = createMutableAtomFamily<\n\t\t\tSetRTX<string>,\n\t\t\tSetRTXJson<string>,\n\t\t\tstring\n\t\t>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/relatedKeys`,\n\t\t\t\tdefault: () => new SetRTX(),\n\t\t\t\tmutable: true,\n\t\t\t\tfromJson: (json) => SetRTX.fromJSON(json),\n\t\t\t\ttoJson: (set) => set.toJSON(),\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\t\tthis.core = { findRelatedKeysState: relatedKeysAtoms }\n\t\tconst getRelatedKeys: Read<(key: string) => SetRTX<string>> = (\n\t\t\t{ find, get },\n\t\t\tkey,\n\t\t) => get(find(relatedKeysAtoms, key))\n\t\tconst addRelation: Write<(a: string, b: string) => void> = (\n\t\t\ttransactors,\n\t\t\ta,\n\t\t\tb,\n\t\t) => {\n\t\t\tconst { set, find } = transactors\n\t\t\tconst aKeysState = find(relatedKeysAtoms, a)\n\t\t\tconst bKeysState = find(relatedKeysAtoms, b)\n\t\t\tset(aKeysState, (aKeys) => aKeys.add(b))\n\t\t\tset(bKeysState, (bKeys) => bKeys.add(a))\n\t\t}\n\t\tconst deleteRelation: Write<(a: string, b: string) => void> = (\n\t\t\ttransactors,\n\t\t\ta,\n\t\t\tb,\n\t\t) => {\n\t\t\tconst { find, set } = transactors\n\t\t\tconst aKeysState = find(relatedKeysAtoms, a)\n\t\t\tconst bKeysState = find(relatedKeysAtoms, b)\n\t\t\tset(aKeysState, (aKeys) => (aKeys.delete(b), aKeys))\n\t\t\tset(bKeysState, (bKeys) => (bKeys.delete(a), bKeys))\n\t\t}\n\t\tconst replaceRelationsSafely: Write<\n\t\t\t(a: string, newRelationsOfA: string[]) => void\n\t\t> = (transactors, a, newRelationsOfA) => {\n\t\t\tconst { find, get, set } = transactors\n\t\t\tconst relationsOfAState = find(relatedKeysAtoms, a)\n\t\t\tconst currentRelationsOfA = get(relationsOfAState)\n\t\t\tfor (const currentRelationB of currentRelationsOfA) {\n\t\t\t\tconst remainsRelated = newRelationsOfA.includes(currentRelationB)\n\t\t\t\tif (remainsRelated) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst relationsOfBState = find(relatedKeysAtoms, currentRelationB)\n\t\t\t\tset(relationsOfBState, (relationsOfB) => {\n\t\t\t\t\trelationsOfB.delete(a)\n\t\t\t\t\treturn relationsOfB\n\t\t\t\t})\n\t\t\t}\n\t\t\tset(relationsOfAState, (relationsOfA) => {\n\t\t\t\trelationsOfA.transaction((nextRelationsOfA) => {\n\t\t\t\t\tnextRelationsOfA.clear()\n\t\t\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\t\t\tconst relationsOfB = getRelatedKeys(transactors, newRelationB)\n\t\t\t\t\t\tconst newRelationBIsAlreadyRelated = relationsOfB.has(a)\n\t\t\t\t\t\tif (this.relations.cardinality === `1:n`) {\n\t\t\t\t\t\t\tfor (const previousOwner of relationsOfB) {\n\t\t\t\t\t\t\t\tif (previousOwner === a) {\n\t\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst previousOwnerRelations = getRelatedKeys(\n\t\t\t\t\t\t\t\t\ttransactors,\n\t\t\t\t\t\t\t\t\tpreviousOwner,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tpreviousOwnerRelations.delete(newRelationB)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {\n\t\t\t\t\t\t\t\trelationsOfB.clear()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!newRelationBIsAlreadyRelated) {\n\t\t\t\t\t\t\trelationsOfB.add(a)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnextRelationsOfA.add(newRelationB)\n\t\t\t\t\t}\n\t\t\t\t\treturn true\n\t\t\t\t})\n\t\t\t\treturn relationsOfA\n\t\t\t})\n\t\t}\n\t\tconst replaceRelationsUnsafely: Write<\n\t\t\t(a: string, newRelationsOfA: string[]) => void\n\t\t> = (transactors, a, newRelationsOfA) => {\n\t\t\tconst { find, set } = transactors\n\t\t\tconst relationsOfAState = find(relatedKeysAtoms, a)\n\t\t\tset(relationsOfAState, (relationsOfA) => {\n\t\t\t\trelationsOfA.transaction((nextRelationsOfA) => {\n\t\t\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\t\t\tnextRelationsOfA.add(newRelationB)\n\t\t\t\t\t}\n\t\t\t\t\treturn true\n\t\t\t\t})\n\t\t\t\treturn relationsOfA\n\t\t\t})\n\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\tconst newRelationsBState = find(relatedKeysAtoms, newRelationB)\n\t\t\t\tset(newRelationsBState, (newRelationsB) => {\n\t\t\t\t\tnewRelationsB.add(a)\n\t\t\t\t\treturn newRelationsB\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t\tconst has: Read<(a: string, b?: string) => boolean> = (\n\t\t\ttransactors,\n\t\t\ta,\n\t\t\tb,\n\t\t) => {\n\t\t\tconst aKeys = getRelatedKeys(transactors, a)\n\t\t\treturn b ? aKeys.has(b) : aKeys.size > 0\n\t\t}\n\t\tconst baseExternalStoreConfiguration: BaseExternalStoreConfiguration = {\n\t\t\tgetRelatedKeys: (key) => getRelatedKeys(this.transactors, key),\n\t\t\taddRelation: (a, b) => addRelation(this.transactors, a, b),\n\t\t\tdeleteRelation: (a, b) => deleteRelation(this.transactors, a, b),\n\t\t\treplaceRelationsSafely: (a, bs) =>\n\t\t\t\treplaceRelationsSafely(this.transactors, a, bs),\n\t\t\treplaceRelationsUnsafely: (a, bs) =>\n\t\t\t\treplaceRelationsUnsafely(this.transactors, a, bs),\n\t\t\thas: (a, b) => has(this.transactors, a, b),\n\t\t}\n\t\tlet externalStore: ExternalStoreConfiguration<Content>\n\t\tlet contentAtoms: RegularAtomFamily<Content, string>\n\t\tif (defaultContent) {\n\t\t\tcontentAtoms = createRegularAtomFamily<Content, string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/content`,\n\t\t\t\t\tdefault: defaultContent,\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\t\t\tconst getContent: Read<(key: string) => Content | null> = (\n\t\t\t\t{ find, get },\n\t\t\t\tkey,\n\t\t\t) => get(find(contentAtoms, key))\n\t\t\tconst setContent: Write<(key: string, content: Content) => void> = (\n\t\t\t\t{ find, set },\n\t\t\t\tkey,\n\t\t\t\tcontent,\n\t\t\t) => set(find(contentAtoms, key), content)\n\t\t\tconst deleteContent: Write<(key: string) => void> = ({ find }, key) =>\n\t\t\t\tdispose(find(contentAtoms, key))\n\t\t\tconst externalStoreWithContentConfiguration = {\n\t\t\t\tgetContent: (contentKey: string) => {\n\t\t\t\t\tconst content = getContent(this.transactors, contentKey)\n\t\t\t\t\treturn content\n\t\t\t\t},\n\t\t\t\tsetContent: (contentKey: string, content: Content) => {\n\t\t\t\t\tsetContent(this.transactors, contentKey, content)\n\t\t\t\t},\n\t\t\t\tdeleteContent: (contentKey: string) => {\n\t\t\t\t\tdeleteContent(this.transactors, contentKey)\n\t\t\t\t},\n\t\t\t}\n\t\t\texternalStore = Object.assign(\n\t\t\t\tbaseExternalStoreConfiguration,\n\t\t\t\texternalStoreWithContentConfiguration,\n\t\t\t) as ExternalStoreConfiguration<Content>\n\t\t} else {\n\t\t\texternalStore =\n\t\t\t\tbaseExternalStoreConfiguration as ExternalStoreConfiguration<Content>\n\t\t}\n\t\tconst relations = new Junction<ASide, BSide, Content>(options, {\n\t\t\texternalStore,\n\t\t\tmakeContentKey: (...args) => args.sort().join(`:`),\n\t\t})\n\n\t\tconst createSingleKeyStateFamily = () =>\n\t\t\tcreateSelectorFamily<string | null, string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/singleRelatedKey`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ find, get }) => {\n\t\t\t\t\t\t\tconst relatedKeysState = find(relatedKeysAtoms, key)\n\t\t\t\t\t\t\tconst relatedKeys = get(relatedKeysState)\n\t\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\t\treturn relatedKey\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn null\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\t\tconst getMultipleKeyStateFamily = () => {\n\t\t\treturn createSelectorFamily<string[], string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/multipleRelatedKeys`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ find, get }) => {\n\t\t\t\t\t\t\tconst jsonFamily = getJsonFamily(relatedKeysAtoms, store)\n\t\t\t\t\t\t\tconst jsonState = find(jsonFamily, key)\n\t\t\t\t\t\t\tconst json = get(jsonState)\n\t\t\t\t\t\t\treturn json.members\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\t\t}\n\t\tconst createSingleEntryStateFamily = () =>\n\t\t\tcreateSelectorFamily<[string, Content] | null, string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/singleRelatedEntry`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ find, get }) => {\n\t\t\t\t\t\t\tconst relatedKeysState = find(relatedKeysAtoms, key)\n\t\t\t\t\t\t\tconst relatedKeys = get(relatedKeysState)\n\t\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\t\tconst contentKey = relations.makeContentKey(key, relatedKey)\n\t\t\t\t\t\t\t\tconst contentState = find(contentAtoms, contentKey)\n\t\t\t\t\t\t\t\tconst content = get(contentState)\n\t\t\t\t\t\t\t\treturn [relatedKey, content]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn null\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\t\tconst getMultipleEntryStateFamily = () =>\n\t\t\tcreateSelectorFamily<[string, Content][], string>(\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/multipleRelatedEntries`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ find, get }) => {\n\t\t\t\t\t\t\tconst jsonFamily = getJsonFamily(relatedKeysAtoms, store)\n\t\t\t\t\t\t\tconst json = get(jsonFamily(key))\n\t\t\t\t\t\t\treturn json.members.map((relatedKey) => {\n\t\t\t\t\t\t\t\tconst contentKey = relations.makeContentKey(key, relatedKey)\n\t\t\t\t\t\t\t\tconst contentState = find(contentAtoms, contentKey)\n\t\t\t\t\t\t\t\tconst content = get(contentState)\n\t\t\t\t\t\t\t\treturn [relatedKey, content]\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tstore,\n\t\t\t)\n\n\t\tswitch (options.cardinality) {\n\t\t\tcase `1:1`: {\n\t\t\t\tconst findSingleRelatedKeyState = createSingleKeyStateFamily()\n\t\t\t\tconst stateKeyA = `${a}KeyOf${capitalize(b)}` as const\n\t\t\t\tconst stateKeyB = `${b}KeyOf${capitalize(a)}` as const\n\t\t\t\tconst baseStates = {\n\t\t\t\t\t[stateKeyA]: findSingleRelatedKeyState,\n\t\t\t\t\t[stateKeyB]: findSingleRelatedKeyState,\n\t\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tlet states: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tif (defaultContent) {\n\t\t\t\t\tconst findSingleRelatedEntryState = createSingleEntryStateFamily()\n\t\t\t\t\tconst entriesStateKeyA = `${a}EntryOf${capitalize(b)}` as const\n\t\t\t\t\tconst entriesStateKeyB = `${b}EntryOf${capitalize(a)}` as const\n\t\t\t\t\tconst contentStates = {\n\t\t\t\t\t\t[entriesStateKeyA]: findSingleRelatedEntryState,\n\t\t\t\t\t\t[entriesStateKeyB]: findSingleRelatedEntryState,\n\t\t\t\t\t}\n\t\t\t\t\tstates = Object.assign(baseStates, contentStates)\n\t\t\t\t} else {\n\t\t\t\t\tstates = baseStates\n\t\t\t\t}\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = states\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `1:n`: {\n\t\t\t\tconst findSingleRelatedKeyState = createSingleKeyStateFamily()\n\t\t\t\tconst findMultipleRelatedKeysState = getMultipleKeyStateFamily()\n\t\t\t\tconst stateKeyA = `${a}KeyOf${capitalize(b)}` as const\n\t\t\t\tconst stateKeyB = `${b}KeysOf${capitalize(a)}` as const\n\t\t\t\tconst baseStates = {\n\t\t\t\t\t[stateKeyA]: findSingleRelatedKeyState,\n\t\t\t\t\t[stateKeyB]: findMultipleRelatedKeysState,\n\t\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tlet states: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tif (defaultContent) {\n\t\t\t\t\tconst findSingleRelatedEntryState = createSingleEntryStateFamily()\n\t\t\t\t\tconst findMultipleRelatedEntriesState = getMultipleEntryStateFamily()\n\t\t\t\t\tconst entriesStateKeyA = `${a}EntryOf${capitalize(b)}` as const\n\t\t\t\t\tconst entriesStateKeyB = `${b}EntriesOf${capitalize(a)}` as const\n\t\t\t\t\tconst contentStates = {\n\t\t\t\t\t\t[entriesStateKeyA]: findSingleRelatedEntryState,\n\t\t\t\t\t\t[entriesStateKeyB]: findMultipleRelatedEntriesState,\n\t\t\t\t\t}\n\t\t\t\t\tstates = Object.assign(baseStates, contentStates)\n\t\t\t\t} else {\n\t\t\t\t\tstates = baseStates\n\t\t\t\t}\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = states\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconst findMultipleRelatedKeysState = getMultipleKeyStateFamily()\n\t\t\t\tconst stateKeyA = `${a}KeysOf${capitalize(b)}` as const\n\t\t\t\tconst stateKeyB = `${b}KeysOf${capitalize(a)}` as const\n\t\t\t\tconst baseStates = {\n\t\t\t\t\t[stateKeyA]: findMultipleRelatedKeysState,\n\t\t\t\t\t[stateKeyB]: findMultipleRelatedKeysState,\n\t\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tlet states: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\t\tif (defaultContent) {\n\t\t\t\t\tconst findMultipleRelatedEntriesState = getMultipleEntryStateFamily()\n\t\t\t\t\tconst entriesStateKeyA = `${a}EntriesOf${capitalize(b)}` as const\n\t\t\t\t\tconst entriesStateKeyB = `${b}EntriesOf${capitalize(a)}` as const\n\t\t\t\t\tconst contentStates = {\n\t\t\t\t\t\t[entriesStateKeyA]: findMultipleRelatedEntriesState,\n\t\t\t\t\t\t[entriesStateKeyB]: findMultipleRelatedEntriesState,\n\t\t\t\t\t}\n\t\t\t\t\tstates = Object.assign(baseStates, contentStates)\n\t\t\t\t} else {\n\t\t\t\t\tstates = baseStates\n\t\t\t\t}\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = states\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function join<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, null>,\n\tdefaultContent?: undefined,\n\tstore?: Store,\n): {\n\treadonly relations: Junction<ASide, BSide, null>\n\treadonly states: JoinState<ASide, BSide, Cardinality, null>\n\treadonly in: (store: Store) => Join<ASide, BSide, Cardinality>\n\treadonly transact: (\n\t\ttransactors: Transactors,\n\t\trun: (join: Join<ASide, BSide, Cardinality, null>) => void,\n\t) => void\n\treadonly core: {\n\t\treadonly findRelatedKeysState: MutableAtomFamily<\n\t\t\tSetRTX<string>,\n\t\t\tSetRTXJson<string>,\n\t\t\tstring\n\t\t>\n\t}\n}\nexport function join<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n\tconst Content extends Json.Object,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\tdefaultContent: Content,\n\tstore?: Store,\n): {\n\treadonly relations: Junction<ASide, BSide, Content>\n\treadonly states: JoinState<ASide, BSide, Cardinality, Content>\n\treadonly in: (store: Store) => Join<ASide, BSide, Cardinality, Content>\n\treadonly transact: (\n\t\ttransactors: Transactors,\n\t\trun: (join: Join<ASide, BSide, Cardinality, Content>) => void,\n\t) => void\n\treadonly core: {\n\t\treadonly findRelatedKeysState: MutableAtomFamily<\n\t\t\tSetRTX<string>,\n\t\t\tSetRTXJson<string>,\n\t\t\tstring\n\t\t>\n\t}\n}\nexport function join<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n\tContent extends Json.Object,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\tdefaultContent: Content | undefined,\n\tstore: Store = IMPLICIT.STORE,\n): Join<ASide, BSide, Cardinality, Content> {\n\treturn new Join(options, defaultContent, store)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\n\nimport { createRegularAtom, createStandaloneSelector } from \"atom.io/internal\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\n\nexport function struct<\n\tStruct extends { [key: string]: unknown },\n\tKey extends string,\n>(\n\toptions: {\n\t\tkey: Key\n\t\tdefault: Struct\n\t},\n\tstore: Store = IMPLICIT.STORE,\n): [\n\t{\n\t\t[K in keyof Struct as `${Key}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.RegularAtomToken<Struct[K]>\n\t},\n\tAtomIO.ReadonlySelectorToken<Struct>,\n] {\n\tconst atoms: {\n\t\t[K in keyof Struct as `${Key}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.RegularAtomToken<Struct[K]>\n\t} = Object.keys(options.default).reduce((acc, key) => {\n\t\tconst atomName = options.key + capitalize(key) + `State`\n\t\tacc[atomName] = createRegularAtom(\n\t\t\t{\n\t\t\t\tkey: `${options.key}.${key}`,\n\t\t\t\tdefault: options.default[key],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\t\treturn acc\n\t}, {} as any)\n\tconst structState = createStandaloneSelector(\n\t\t{\n\t\t\tkey: options.key,\n\t\t\tget: ({ get }) => {\n\t\t\t\treturn Object.keys(options.default).reduce((acc, key) => {\n\t\t\t\t\tacc[key] = get(atoms[options.key + capitalize(key) + `State`])\n\t\t\t\t\treturn acc\n\t\t\t\t}, {} as any)\n\t\t\t},\n\t\t},\n\t\tstore,\n\t)\n\treturn [atoms, structState]\n}\n","import type * as AtomIO from \"atom.io\"\nimport {\n\tIMPLICIT,\n\tcreateRegularAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\nconst nameFamily = (topKey: string, subKey: string) =>\n\t`find` + capitalize(topKey) + capitalize(subKey) + `State`\n\nexport function structFamily<\n\tStruct extends object,\n\tKey extends string,\n>(options: {\n\tkey: Key\n\tdefault: Struct\n}): [\n\t{\n\t\t[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.RegularAtomFamily<Struct[K], string>\n\t},\n\tAtomIO.ReadonlySelectorFamilyToken<Struct, string>,\n] {\n\tconst atoms: {\n\t\t[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.RegularAtomFamily<Struct[K], string>\n\t} = Object.keys(options.default).reduce((acc, subKey) => {\n\t\tconst atomFamilyName = nameFamily(options.key, subKey)\n\t\tacc[atomFamilyName] = createRegularAtomFamily(\n\t\t\t{\n\t\t\t\tkey: `${options.key}.${subKey}`,\n\t\t\t\tdefault: (options.default as any)[subKey],\n\t\t\t},\n\t\t\tIMPLICIT.STORE,\n\t\t)\n\t\treturn acc\n\t}, {} as any)\n\tconst findStructState: AtomIO.ReadonlySelectorFamilyToken<Struct, string> =\n\t\tcreateSelectorFamily(\n\t\t\t{\n\t\t\t\tkey: options.key,\n\t\t\t\tget:\n\t\t\t\t\t(id) =>\n\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\treturn Object.keys(options.default).reduce((acc, subKey) => {\n\t\t\t\t\t\t\tacc[subKey] = get(\n\t\t\t\t\t\t\t\t(atoms as any)[nameFamily(options.key, subKey)](id),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t}, {} as any)\n\t\t\t\t\t},\n\t\t\t},\n\t\t\tIMPLICIT.STORE,\n\t\t)\n\treturn [atoms, findStructState]\n}\n","export type Loadable<T> = Promise<T> | T\nexport type Fated<T, E extends Error = Error> = Loadable<E | T>\n\n/**\n * Utility for handling loadable values\n * @param loadable Loadable value\n * @param fallback Fallback value until Loadable is resolved\n * @returns Fallback value if your loadable is a promise, otherwise the loadable's resolved value\n */\nexport function until<T>(loadable: Loadable<T>, fallback: T): T {\n\tif (loadable instanceof Promise) {\n\t\treturn fallback\n\t}\n\treturn loadable\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../realtime-client/src/realtime-client-stores/client-main-store.ts","../realtime-client/src/realtime-client-stores/client-sync-store.ts"],"names":["AtomIO"],"mappings":";;;;;AAAA,YAAY,YAAY;AAIjB,IAAM,sBAA6B,YAAyB;AAAA,EAClE,KAAK;AAAA,EACL,SAAS;AACV,CAAC;AACM,IAAM,YAAmB,gBAA6B;AAAA,EAC5D,KAAK;AAAA,EACL,KAAK,CAAC,EAAE,IAAI,MAAM,IAAI,mBAAmB;AAC1C,CAAC;AAED,IAAM,kBACL,OAAO,WAAW,cAAc,CAAC,IAAI,CAAC,uBAAuB,YAAY,CAAC;AACpE,IAAM,kBAAyB,YAAoB;AAAA,EACzD,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AACV,CAAC;;;ACnBD,YAAYA,aAAY;AAEjB,IAAM,wBAA+B,aAE1C;AAAA,EACD,KAAK;AAAA,EACL,SAAS,CAAC;AACX,CAAC;AAEM,IAAM,uBAA8B;AAAA,EAC1C;AAAA,IACC,KAAK;AAAA,IACL,SAAS,CAAC;AAAA,EACX;AACD","sourcesContent":["import * as AtomIO from \"atom.io\"\n\nimport { lazyLocalStorageEffect } from \"~/packages/atom.io/__unstable__/web-effects/src/storage\"\n\nexport const myIdState__INTERNAL = AtomIO.atom<string | undefined>({\n\tkey: `mySocketId__INTERNAL`,\n\tdefault: undefined,\n})\nexport const myIdState = AtomIO.selector<string | undefined>({\n\tkey: `mySocketId`,\n\tget: ({ get }) => get(myIdState__INTERNAL),\n})\n\nconst usernameEffects =\n\ttypeof window === `undefined` ? [] : [lazyLocalStorageEffect(`myUsername`)]\nexport const myUsernameState = AtomIO.atom<string | null>({\n\tkey: `myUsername`,\n\tdefault: null,\n\teffects: usernameEffects,\n})\n","import * as AtomIO from \"atom.io\"\n\nexport const optimisticUpdateQueue = AtomIO.atom<\n\tAtomIO.TransactionUpdate<any>[]\n>({\n\tkey: `updateQueue`,\n\tdefault: [],\n})\n\nexport const confirmedUpdateQueue = AtomIO.atom<AtomIO.TransactionUpdate<any>[]>(\n\t{\n\t\tkey: `serverConfirmedUpdateQueue`,\n\t\tdefault: [],\n\t},\n)\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../__unstable__/web-effects/src/storage.ts"],"names":[],"mappings":";AAQO,IAAM,cACZ,CAAI,YACJ,CAAC,EAAE,WAAW,MAAM,MACpB,CAAC,QACD,CAAC,EAAE,SAAS,MAAM,MAAM;AACvB,QAAM,aAAa,QAAQ,QAAQ,GAAG;AACtC,MAAI,cAAc;AAAM,YAAQ,MAAM,UAAU,CAAC;AAEjD,QAAM,CAAC,EAAE,SAAS,MAAM;AACvB,QAAI,YAAY,MAAM;AACrB,cAAQ,WAAW,GAAG;AACtB;AAAA,IACD;AACA,YAAQ,QAAQ,KAAK,UAAU,QAAQ,CAAC;AAAA,EACzC,CAAC;AACF;AAEM,IAAM,yBAEQ,YAAY,OAAO,YAAY,EAAE,IAAI","sourcesContent":["import type { AtomEffect } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\n\nexport type StringInterface<T> = {\n\tstringify: (t: T) => string\n\tparse: (s: string) => T\n}\n\nexport const persistAtom =\n\t<T>(storage: Storage) =>\n\t({ stringify, parse }: StringInterface<T>) =>\n\t(key: string): AtomEffect<T> =>\n\t({ setSelf, onSet }) => {\n\t\tconst savedValue = storage.getItem(key)\n\t\tif (savedValue != null) setSelf(parse(savedValue))\n\n\t\tonSet(({ newValue }) => {\n\t\t\tif (newValue == null) {\n\t\t\t\tstorage.removeItem(key)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tstorage.setItem(key, stringify(newValue))\n\t\t})\n\t}\n\nexport const lazyLocalStorageEffect: <J extends Json.Serializable>(\n\tkey: string,\n) => AtomEffect<J> = persistAtom(window.localStorage)(JSON)\n"]}
|