atom.io 0.21.1 → 0.22.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 +136 -63
- package/data/dist/index.d.ts +6 -0
- package/data/dist/index.js +3 -3
- package/data/src/join.ts +135 -51
- package/data/src/struct-family.ts +2 -2
- package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
- package/dist/{chunk-HITX3MO4.js → chunk-JA4V7TJY.js} +135 -62
- package/dist/index.cjs +2 -7
- package/dist/index.d.ts +29 -14
- package/dist/index.js +4 -8
- package/ephemeral/dist/index.cjs +11 -0
- package/ephemeral/dist/index.js +9 -0
- package/ephemeral/package.json +16 -0
- package/ephemeral/src/index.ts +1 -0
- package/eslint-plugin/dist/index.cjs +156 -1
- package/eslint-plugin/dist/index.js +156 -1
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/lifespan.ts +204 -0
- package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +1 -65
- package/eslint-plugin/src/walk.ts +73 -0
- package/immortal/dist/index.cjs +100 -0
- package/immortal/dist/index.js +97 -0
- package/immortal/package.json +16 -0
- package/immortal/src/index.ts +2 -0
- package/immortal/src/molecule.ts +134 -0
- package/immortal/src/seek-state.ts +60 -0
- package/internal/dist/index.cjs +186 -146
- package/internal/dist/index.d.ts +29 -13
- package/internal/dist/index.js +185 -146
- package/internal/src/atom/dispose-atom.ts +4 -1
- package/internal/src/families/create-readonly-selector-family.ts +9 -9
- package/internal/src/families/create-regular-atom-family.ts +15 -20
- package/internal/src/families/create-writable-selector-family.ts +6 -7
- package/internal/src/families/find-in-store.ts +11 -5
- package/internal/src/families/index.ts +2 -0
- package/internal/src/families/init-family-member.ts +91 -0
- package/internal/src/families/seek-in-store.ts +106 -0
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/mutable/create-mutable-atom-family.ts +17 -23
- package/internal/src/mutable/create-mutable-atom.ts +3 -1
- package/internal/src/mutable/get-json-family.ts +2 -2
- package/internal/src/mutable/get-json-token.ts +27 -12
- package/internal/src/mutable/tracker-family.ts +14 -12
- package/internal/src/not-found-error.ts +11 -3
- package/internal/src/selector/create-readonly-selector.ts +2 -2
- package/internal/src/selector/create-writable-selector.ts +2 -2
- package/internal/src/selector/dispose-selector.ts +40 -23
- package/internal/src/selector/register-selector.ts +8 -5
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/store/index.ts +0 -1
- package/internal/src/store/store.ts +18 -5
- package/internal/src/subscribe/subscribe-to-state.ts +2 -2
- package/internal/src/transaction/build-transaction.ts +7 -2
- package/introspection/dist/index.cjs +38 -52
- package/introspection/dist/index.js +38 -52
- package/introspection/src/attach-atom-index.ts +38 -48
- package/introspection/src/attach-selector-index.ts +45 -50
- package/json/dist/index.cjs +38 -4
- package/json/dist/index.js +40 -6
- package/json/src/select-json-family.ts +46 -7
- package/package.json +30 -10
- package/react/dist/index.cjs +1 -1
- package/react/dist/index.js +1 -1
- package/react/src/use-json.ts +1 -1
- package/react-devtools/dist/index.cjs +11 -10
- package/react-devtools/dist/index.js +2 -1
- package/react-devtools/src/StateIndex.tsx +2 -1
- package/react-devtools/src/TimelineIndex.tsx +2 -1
- package/react-devtools/src/TransactionIndex.tsx +7 -7
- package/realtime-client/dist/index.cjs +3 -3
- package/realtime-client/dist/index.js +3 -3
- package/realtime-client/src/pull-mutable-atom-family-member.ts +1 -1
- package/realtime-client/src/pull-mutable-atom.ts +1 -1
- package/realtime-client/src/sync-continuity.ts +1 -2
- package/realtime-react/dist/index.cjs +1 -1
- package/realtime-react/dist/index.js +1 -1
- package/realtime-server/dist/index.cjs +18 -17
- package/realtime-server/dist/index.js +7 -6
- package/realtime-server/src/realtime-continuity-synchronizer.ts +5 -3
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -1
- package/realtime-server/src/realtime-mutable-provider.ts +1 -1
- package/realtime-testing/dist/index.cjs +6 -2
- package/realtime-testing/dist/index.js +8 -5
- package/realtime-testing/src/setup-realtime-test.tsx +5 -2
- package/src/atom.ts +10 -4
- package/src/index.ts +1 -2
- package/src/selector.ts +10 -4
- package/src/silo.ts +3 -3
- package/src/transaction.ts +5 -2
- package/internal/src/store/withdraw-new-family-member.ts +0 -69
- /package/{src → ephemeral/src}/find-state.ts +0 -0
- /package/src/{dispose.ts → dispose-state.ts} +0 -0
|
@@ -406,12 +406,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
406
406
|
relations = {
|
|
407
407
|
get [keyAB]() {
|
|
408
408
|
const familyAB = myJoin.states[keyAB];
|
|
409
|
-
const state =
|
|
409
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
410
410
|
return state;
|
|
411
411
|
},
|
|
412
412
|
get [keyBA]() {
|
|
413
413
|
const familyBA = myJoin.states[keyBA];
|
|
414
|
-
const state =
|
|
414
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
415
415
|
return state;
|
|
416
416
|
}
|
|
417
417
|
};
|
|
@@ -421,12 +421,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
421
421
|
Object.assign(relations, {
|
|
422
422
|
get [entryAB]() {
|
|
423
423
|
const familyAB = myJoin.states[entryAB];
|
|
424
|
-
const state =
|
|
424
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
425
425
|
return state;
|
|
426
426
|
},
|
|
427
427
|
get [entryBA]() {
|
|
428
428
|
const familyBA = myJoin.states[entryBA];
|
|
429
|
-
const state =
|
|
429
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
430
430
|
return state;
|
|
431
431
|
}
|
|
432
432
|
});
|
|
@@ -439,12 +439,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
439
439
|
relations = {
|
|
440
440
|
get [keyAB]() {
|
|
441
441
|
const familyAB = myJoin.states[keyAB];
|
|
442
|
-
const state =
|
|
442
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
443
443
|
return state;
|
|
444
444
|
},
|
|
445
445
|
get [keysBA]() {
|
|
446
446
|
const familyBA = myJoin.states[keysBA];
|
|
447
|
-
const state =
|
|
447
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
448
448
|
return state;
|
|
449
449
|
}
|
|
450
450
|
};
|
|
@@ -454,12 +454,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
454
454
|
Object.assign(relations, {
|
|
455
455
|
get [entryAB]() {
|
|
456
456
|
const familyAB = myJoin.states[entryAB];
|
|
457
|
-
const state =
|
|
457
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
458
458
|
return state;
|
|
459
459
|
},
|
|
460
460
|
get [entriesBA]() {
|
|
461
461
|
const familyBA = myJoin.states[entriesBA];
|
|
462
|
-
const state =
|
|
462
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
463
463
|
return state;
|
|
464
464
|
}
|
|
465
465
|
});
|
|
@@ -472,12 +472,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
472
472
|
relations = {
|
|
473
473
|
get [keysAB]() {
|
|
474
474
|
const familyAB = myJoin.states[keysAB];
|
|
475
|
-
const state =
|
|
475
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
476
476
|
return state;
|
|
477
477
|
},
|
|
478
478
|
get [keysBA]() {
|
|
479
479
|
const familyBA = myJoin.states[keysBA];
|
|
480
|
-
const state =
|
|
480
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
481
481
|
return state;
|
|
482
482
|
}
|
|
483
483
|
};
|
|
@@ -487,12 +487,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
487
487
|
Object.assign(relations, {
|
|
488
488
|
get [entriesAB]() {
|
|
489
489
|
const familyAB = myJoin.states[entriesAB];
|
|
490
|
-
const state =
|
|
490
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
491
491
|
return state;
|
|
492
492
|
},
|
|
493
493
|
get [entriesBA]() {
|
|
494
494
|
const familyBA = myJoin.states[entriesBA];
|
|
495
|
-
const state =
|
|
495
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
496
496
|
return state;
|
|
497
497
|
}
|
|
498
498
|
});
|
|
@@ -767,7 +767,7 @@ function realtimeContinuitySynchronizer({
|
|
|
767
767
|
(token) => !newKeys.includes(token.key)
|
|
768
768
|
);
|
|
769
769
|
const revealed = newValue.filter((token) => !oldKeys.includes(token.key)).flatMap((token) => {
|
|
770
|
-
const resourceToken = token.type === `mutable_atom` ? internal.getJsonToken(token) : token;
|
|
770
|
+
const resourceToken = token.type === `mutable_atom` ? internal.getJsonToken(token, store) : token;
|
|
771
771
|
const resource = internal.getFromStore(resourceToken, store);
|
|
772
772
|
return [resourceToken, resource];
|
|
773
773
|
});
|
|
@@ -800,7 +800,7 @@ function realtimeContinuitySynchronizer({
|
|
|
800
800
|
var _a;
|
|
801
801
|
const initialPayload = [];
|
|
802
802
|
for (const atom2 of continuity.globals) {
|
|
803
|
-
const resourceToken = atom2.type === `mutable_atom` ? internal.getJsonToken(atom2) : atom2;
|
|
803
|
+
const resourceToken = atom2.type === `mutable_atom` ? internal.getJsonToken(atom2, store) : atom2;
|
|
804
804
|
initialPayload.push(resourceToken, internal.getFromStore(atom2, store));
|
|
805
805
|
}
|
|
806
806
|
for (const perspective of continuity.perspectives) {
|
|
@@ -813,7 +813,7 @@ function realtimeContinuitySynchronizer({
|
|
|
813
813
|
userView
|
|
814
814
|
});
|
|
815
815
|
for (const visibleToken of userView) {
|
|
816
|
-
const resourceToken = visibleToken.type === `mutable_atom` ? internal.getJsonToken(visibleToken) : visibleToken;
|
|
816
|
+
const resourceToken = visibleToken.type === `mutable_atom` ? internal.getJsonToken(visibleToken, store) : visibleToken;
|
|
817
817
|
const resource = internal.getFromStore(resourceToken, store);
|
|
818
818
|
initialPayload.push(resourceToken, resource);
|
|
819
819
|
}
|
|
@@ -1003,7 +1003,8 @@ function realtimeMutableFamilyProvider({
|
|
|
1003
1003
|
for (const exposedSubKey of exposedSubKeys) {
|
|
1004
1004
|
if (json.stringifyJson(exposedSubKey) === json.stringifyJson(subKey)) {
|
|
1005
1005
|
const token = internal.findInStore(family, subKey, store);
|
|
1006
|
-
|
|
1006
|
+
internal.getFromStore(token, store);
|
|
1007
|
+
const jsonToken = internal.getJsonToken(token, store);
|
|
1007
1008
|
const updateToken = internal.getUpdateToken(token);
|
|
1008
1009
|
socket.emit(`init:${token.key}`, internal.getFromStore(jsonToken, store));
|
|
1009
1010
|
const unsubscribe = internal.subscribeToState(
|
|
@@ -1038,7 +1039,7 @@ function realtimeMutableProvider({
|
|
|
1038
1039
|
}) {
|
|
1039
1040
|
return function mutableProvider(token) {
|
|
1040
1041
|
let unsubscribeFromStateUpdates = null;
|
|
1041
|
-
const jsonToken = internal.getJsonToken(token);
|
|
1042
|
+
const jsonToken = internal.getJsonToken(token, store);
|
|
1042
1043
|
const trackerToken = internal.getUpdateToken(token);
|
|
1043
1044
|
const fillUnsubRequest = () => {
|
|
1044
1045
|
socket.off(`unsub:${token.key}`, fillUnsubRequest);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findRelationsInStore } from '../../dist/chunk-
|
|
1
|
+
import { findRelationsInStore } from '../../dist/chunk-JA4V7TJY.js';
|
|
2
2
|
import '../../dist/chunk-FTONNX2R.js';
|
|
3
3
|
import { __spreadProps, __spreadValues } from '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { parseJson, stringifyJson } from 'atom.io/json';
|
|
@@ -597,7 +597,7 @@ function realtimeContinuitySynchronizer({
|
|
|
597
597
|
(token) => !newKeys.includes(token.key)
|
|
598
598
|
);
|
|
599
599
|
const revealed = newValue.filter((token) => !oldKeys.includes(token.key)).flatMap((token) => {
|
|
600
|
-
const resourceToken = token.type === `mutable_atom` ? getJsonToken(token) : token;
|
|
600
|
+
const resourceToken = token.type === `mutable_atom` ? getJsonToken(token, store) : token;
|
|
601
601
|
const resource = getFromStore(resourceToken, store);
|
|
602
602
|
return [resourceToken, resource];
|
|
603
603
|
});
|
|
@@ -630,7 +630,7 @@ function realtimeContinuitySynchronizer({
|
|
|
630
630
|
var _a;
|
|
631
631
|
const initialPayload = [];
|
|
632
632
|
for (const atom2 of continuity.globals) {
|
|
633
|
-
const resourceToken = atom2.type === `mutable_atom` ? getJsonToken(atom2) : atom2;
|
|
633
|
+
const resourceToken = atom2.type === `mutable_atom` ? getJsonToken(atom2, store) : atom2;
|
|
634
634
|
initialPayload.push(resourceToken, getFromStore(atom2, store));
|
|
635
635
|
}
|
|
636
636
|
for (const perspective of continuity.perspectives) {
|
|
@@ -643,7 +643,7 @@ function realtimeContinuitySynchronizer({
|
|
|
643
643
|
userView
|
|
644
644
|
});
|
|
645
645
|
for (const visibleToken of userView) {
|
|
646
|
-
const resourceToken = visibleToken.type === `mutable_atom` ? getJsonToken(visibleToken) : visibleToken;
|
|
646
|
+
const resourceToken = visibleToken.type === `mutable_atom` ? getJsonToken(visibleToken, store) : visibleToken;
|
|
647
647
|
const resource = getFromStore(resourceToken, store);
|
|
648
648
|
initialPayload.push(resourceToken, resource);
|
|
649
649
|
}
|
|
@@ -833,7 +833,8 @@ function realtimeMutableFamilyProvider({
|
|
|
833
833
|
for (const exposedSubKey of exposedSubKeys) {
|
|
834
834
|
if (stringifyJson(exposedSubKey) === stringifyJson(subKey)) {
|
|
835
835
|
const token = findInStore(family, subKey, store);
|
|
836
|
-
|
|
836
|
+
getFromStore(token, store);
|
|
837
|
+
const jsonToken = getJsonToken(token, store);
|
|
837
838
|
const updateToken = getUpdateToken(token);
|
|
838
839
|
socket.emit(`init:${token.key}`, getFromStore(jsonToken, store));
|
|
839
840
|
const unsubscribe = subscribeToState(
|
|
@@ -868,7 +869,7 @@ function realtimeMutableProvider({
|
|
|
868
869
|
}) {
|
|
869
870
|
return function mutableProvider(token) {
|
|
870
871
|
let unsubscribeFromStateUpdates = null;
|
|
871
|
-
const jsonToken = getJsonToken(token);
|
|
872
|
+
const jsonToken = getJsonToken(token, store);
|
|
872
873
|
const trackerToken = getUpdateToken(token);
|
|
873
874
|
const fillUnsubRequest = () => {
|
|
874
875
|
socket.off(`unsub:${token.key}`, fillUnsubRequest);
|
|
@@ -106,7 +106,9 @@ export function realtimeContinuitySynchronizer({
|
|
|
106
106
|
.filter((token) => !oldKeys.includes(token.key))
|
|
107
107
|
.flatMap((token) => {
|
|
108
108
|
const resourceToken =
|
|
109
|
-
token.type === `mutable_atom`
|
|
109
|
+
token.type === `mutable_atom`
|
|
110
|
+
? getJsonToken(token, store)
|
|
111
|
+
: token
|
|
110
112
|
const resource = getFromStore(resourceToken, store)
|
|
111
113
|
return [resourceToken, resource]
|
|
112
114
|
})
|
|
@@ -139,7 +141,7 @@ export function realtimeContinuitySynchronizer({
|
|
|
139
141
|
const initialPayload: Json.Serializable[] = []
|
|
140
142
|
for (const atom of continuity.globals) {
|
|
141
143
|
const resourceToken =
|
|
142
|
-
atom.type === `mutable_atom` ? getJsonToken(atom) : atom
|
|
144
|
+
atom.type === `mutable_atom` ? getJsonToken(atom, store) : atom
|
|
143
145
|
initialPayload.push(resourceToken, getFromStore(atom, store))
|
|
144
146
|
}
|
|
145
147
|
for (const perspective of continuity.perspectives) {
|
|
@@ -154,7 +156,7 @@ export function realtimeContinuitySynchronizer({
|
|
|
154
156
|
for (const visibleToken of userView) {
|
|
155
157
|
const resourceToken =
|
|
156
158
|
visibleToken.type === `mutable_atom`
|
|
157
|
-
? getJsonToken(visibleToken)
|
|
159
|
+
? getJsonToken(visibleToken, store)
|
|
158
160
|
: visibleToken
|
|
159
161
|
const resource = getFromStore(resourceToken, store)
|
|
160
162
|
|
|
@@ -44,7 +44,8 @@ export function realtimeMutableFamilyProvider({
|
|
|
44
44
|
for (const exposedSubKey of exposedSubKeys) {
|
|
45
45
|
if (stringifyJson(exposedSubKey) === stringifyJson(subKey)) {
|
|
46
46
|
const token = findInStore(family, subKey, store)
|
|
47
|
-
|
|
47
|
+
getFromStore(token, store)
|
|
48
|
+
const jsonToken = getJsonToken(token, store)
|
|
48
49
|
const updateToken = getUpdateToken(token)
|
|
49
50
|
socket.emit(`init:${token.key}`, getFromStore(jsonToken, store))
|
|
50
51
|
const unsubscribe = subscribeToState(
|
|
@@ -22,7 +22,7 @@ export function realtimeMutableProvider({
|
|
|
22
22
|
>(token: AtomIO.MutableAtomToken<Core, SerializableCore>): () => void {
|
|
23
23
|
let unsubscribeFromStateUpdates: (() => void) | null = null
|
|
24
24
|
|
|
25
|
-
const jsonToken = getJsonToken(token)
|
|
25
|
+
const jsonToken = getJsonToken(token, store)
|
|
26
26
|
const trackerToken = getUpdateToken(token)
|
|
27
27
|
|
|
28
28
|
const fillUnsubRequest = () => {
|
|
@@ -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/json');
|
|
14
15
|
require('atom.io/transceivers/set-rtx');
|
|
15
16
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
17
|
|
|
@@ -143,7 +144,10 @@ AtomIO__namespace.atom(
|
|
|
143
144
|
var testNumber = 0;
|
|
144
145
|
var setupRealtimeTestServer = (options) => {
|
|
145
146
|
++testNumber;
|
|
146
|
-
const silo = new AtomIO__namespace.Silo(
|
|
147
|
+
const silo = new AtomIO__namespace.Silo(
|
|
148
|
+
{ name: `SERVER-${testNumber}`, lifespan: `ephemeral` },
|
|
149
|
+
internal.IMPLICIT.STORE
|
|
150
|
+
);
|
|
147
151
|
const httpServer = http__namespace.createServer((_, res) => res.end(`Hello World!`));
|
|
148
152
|
const address = httpServer.listen(options.port).address();
|
|
149
153
|
const port = typeof address === `string` ? null : address === null ? null : address.port;
|
|
@@ -198,7 +202,7 @@ var setupRealtimeTestClient = (options, name, port) => {
|
|
|
198
202
|
const socket = socket_ioClient.io(`http://localhost:${port}/`, {
|
|
199
203
|
auth: { token: `test`, username: `${name}-${testNumber}` }
|
|
200
204
|
});
|
|
201
|
-
const silo = new AtomIO__namespace.Silo(name, internal.IMPLICIT.STORE);
|
|
205
|
+
const silo = new AtomIO__namespace.Silo({ name, lifespan: `ephemeral` }, internal.IMPLICIT.STORE);
|
|
202
206
|
for (const [key, value] of silo.store.valueMap.entries()) {
|
|
203
207
|
if (Array.isArray(value)) {
|
|
204
208
|
silo.store.valueMap.set(key, [...value]);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { myUsernameState } from '../../dist/chunk-O47EQUM6.js';
|
|
2
|
-
import { editRelationsInStore } from '../../dist/chunk-HITX3MO4.js';
|
|
3
|
-
import '../../dist/chunk-FTONNX2R.js';
|
|
4
1
|
import { recordToEntries } from '../../dist/chunk-3V3VWQ7X.js';
|
|
2
|
+
import { myUsernameState } from '../../dist/chunk-O47EQUM6.js';
|
|
5
3
|
import '../../dist/chunk-BWWVY5O5.js';
|
|
4
|
+
import { editRelationsInStore } from '../../dist/chunk-JA4V7TJY.js';
|
|
5
|
+
import '../../dist/chunk-FTONNX2R.js';
|
|
6
6
|
import { __spreadProps, __spreadValues } from '../../dist/chunk-F2X4B4VY.js';
|
|
7
7
|
import * as http from 'http';
|
|
8
8
|
import { render, prettyDOM } from '@testing-library/react';
|
|
@@ -20,7 +20,10 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
20
20
|
var testNumber = 0;
|
|
21
21
|
var setupRealtimeTestServer = (options) => {
|
|
22
22
|
++testNumber;
|
|
23
|
-
const silo = new AtomIO.Silo(
|
|
23
|
+
const silo = new AtomIO.Silo(
|
|
24
|
+
{ name: `SERVER-${testNumber}`, lifespan: `ephemeral` },
|
|
25
|
+
IMPLICIT.STORE
|
|
26
|
+
);
|
|
24
27
|
const httpServer = http.createServer((_, res) => res.end(`Hello World!`));
|
|
25
28
|
const address = httpServer.listen(options.port).address();
|
|
26
29
|
const port = typeof address === `string` ? null : address === null ? null : address.port;
|
|
@@ -75,7 +78,7 @@ var setupRealtimeTestClient = (options, name, port) => {
|
|
|
75
78
|
const socket = io(`http://localhost:${port}/`, {
|
|
76
79
|
auth: { token: `test`, username: `${name}-${testNumber}` }
|
|
77
80
|
});
|
|
78
|
-
const silo = new AtomIO.Silo(name, IMPLICIT.STORE);
|
|
81
|
+
const silo = new AtomIO.Silo({ name, lifespan: `ephemeral` }, IMPLICIT.STORE);
|
|
79
82
|
for (const [key, value] of silo.store.valueMap.entries()) {
|
|
80
83
|
if (Array.isArray(value)) {
|
|
81
84
|
silo.store.valueMap.set(key, [...value]);
|
|
@@ -76,7 +76,10 @@ export const setupRealtimeTestServer = (
|
|
|
76
76
|
options: TestSetupOptions,
|
|
77
77
|
): RealtimeTestServer => {
|
|
78
78
|
++testNumber
|
|
79
|
-
const silo = new AtomIO.Silo(
|
|
79
|
+
const silo = new AtomIO.Silo(
|
|
80
|
+
{ name: `SERVER-${testNumber}`, lifespan: `ephemeral` },
|
|
81
|
+
IMPLICIT.STORE,
|
|
82
|
+
)
|
|
80
83
|
|
|
81
84
|
const httpServer = http.createServer((_, res) => res.end(`Hello World!`))
|
|
82
85
|
const address = httpServer.listen(options.port).address()
|
|
@@ -139,7 +142,7 @@ export const setupRealtimeTestClient = (
|
|
|
139
142
|
const socket: ClientSocket = io(`http://localhost:${port}/`, {
|
|
140
143
|
auth: { token: `test`, username: `${name}-${testNumber}` },
|
|
141
144
|
})
|
|
142
|
-
const silo = new AtomIO.Silo(name, IMPLICIT.STORE)
|
|
145
|
+
const silo = new AtomIO.Silo({ name, lifespan: `ephemeral` }, IMPLICIT.STORE)
|
|
143
146
|
for (const [key, value] of silo.store.valueMap.entries()) {
|
|
144
147
|
if (Array.isArray(value)) {
|
|
145
148
|
silo.store.valueMap.set(key, [...value])
|
package/src/atom.ts
CHANGED
|
@@ -57,8 +57,11 @@ export type RegularAtomFamilyTokenWithCall<
|
|
|
57
57
|
K extends Json.Serializable,
|
|
58
58
|
> =
|
|
59
59
|
& RegularAtomFamilyToken<T, K>
|
|
60
|
-
&
|
|
61
|
-
|
|
60
|
+
& {
|
|
61
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
62
|
+
/* eslint-disable-next-line @typescript-eslint/prefer-function-type */
|
|
63
|
+
(key: K): RegularAtomToken<T>
|
|
64
|
+
}
|
|
62
65
|
// biome-ignore format: intersection
|
|
63
66
|
export type RegularAtomFamily<T, K extends Json.Serializable> =
|
|
64
67
|
& RegularAtomFamilyToken<T, K>
|
|
@@ -100,8 +103,11 @@ export type MutableAtomFamilyTokenWithCall<
|
|
|
100
103
|
K extends Json.Serializable,
|
|
101
104
|
> =
|
|
102
105
|
& MutableAtomFamilyToken<T, J, K>
|
|
103
|
-
&
|
|
104
|
-
|
|
106
|
+
& {
|
|
107
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
108
|
+
/* eslint-disable-next-line @typescript-eslint/prefer-function-type */
|
|
109
|
+
(key: K): MutableAtomToken<T, J>
|
|
110
|
+
}
|
|
105
111
|
// biome-ignore format: intersection
|
|
106
112
|
export type MutableAtomFamily<
|
|
107
113
|
T extends Transceiver<any>,
|
package/src/index.ts
CHANGED
package/src/selector.ts
CHANGED
|
@@ -53,8 +53,11 @@ export type WritableSelectorFamilyTokenWithCall<
|
|
|
53
53
|
K extends Json.Serializable,
|
|
54
54
|
> =
|
|
55
55
|
& WritableSelectorFamilyToken<T, K>
|
|
56
|
-
&
|
|
57
|
-
|
|
56
|
+
& {
|
|
57
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
58
|
+
/* eslint-disable-next-line @typescript-eslint/prefer-function-type */
|
|
59
|
+
(key: K): WritableSelectorToken<T>
|
|
60
|
+
}
|
|
58
61
|
// biome-ignore format: intersection
|
|
59
62
|
export type WritableSelectorFamily<T, K extends Json.Serializable> =
|
|
60
63
|
& WritableSelectorFamilyToken<T, K>
|
|
@@ -76,8 +79,11 @@ export type ReadonlySelectorFamilyTokenWithCall<
|
|
|
76
79
|
K extends Json.Serializable,
|
|
77
80
|
> =
|
|
78
81
|
& ReadonlySelectorFamilyToken<T, K>
|
|
79
|
-
&
|
|
80
|
-
|
|
82
|
+
& {
|
|
83
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
84
|
+
/* eslint-disable-next-line @typescript-eslint/prefer-function-type */
|
|
85
|
+
(key: K): ReadonlySelectorToken<T>
|
|
86
|
+
}
|
|
81
87
|
// biome-ignore format: intersection
|
|
82
88
|
export type ReadonlySelectorFamily<T, K extends Json.Serializable> =
|
|
83
89
|
& ((key: K) => ReadonlySelectorToken<T>)
|
package/src/silo.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { findState } from "atom.io/ephemeral"
|
|
1
2
|
import type { Transceiver } from "atom.io/internal"
|
|
2
3
|
import {
|
|
3
4
|
createAtomFamily,
|
|
@@ -16,7 +17,6 @@ import type { Json } from "atom.io/json"
|
|
|
16
17
|
|
|
17
18
|
import type {
|
|
18
19
|
AtomToken,
|
|
19
|
-
findState,
|
|
20
20
|
getState,
|
|
21
21
|
MutableAtomFamily,
|
|
22
22
|
MutableAtomFamilyOptions,
|
|
@@ -50,8 +50,8 @@ export class Silo {
|
|
|
50
50
|
public subscribe: typeof subscribe
|
|
51
51
|
public undo: typeof undo
|
|
52
52
|
public redo: typeof redo
|
|
53
|
-
public constructor(
|
|
54
|
-
const s = new Store(
|
|
53
|
+
public constructor(config: Store[`config`], fromStore: Store | null = null) {
|
|
54
|
+
const s = new Store(config, fromStore)
|
|
55
55
|
function _atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>
|
|
56
56
|
function _atom<T extends Transceiver<any>, J extends Json.Serializable>(
|
|
57
57
|
options: MutableAtomOptions<T, J>,
|
package/src/transaction.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { findState } from "atom.io/ephemeral"
|
|
1
2
|
import type { EnvironmentData } from "atom.io/internal"
|
|
2
3
|
import {
|
|
3
4
|
actUponStore,
|
|
@@ -6,8 +7,8 @@ import {
|
|
|
6
7
|
IMPLICIT,
|
|
7
8
|
} from "atom.io/internal"
|
|
8
9
|
|
|
10
|
+
import type { seekState } from "../immortal/src/seek-state"
|
|
9
11
|
import type {
|
|
10
|
-
findState,
|
|
11
12
|
Func,
|
|
12
13
|
KeyedStateUpdate,
|
|
13
14
|
ReadonlySelectorToken,
|
|
@@ -40,6 +41,7 @@ export type Transactors = Readonly<{
|
|
|
40
41
|
newValue: New | ((oldValue: S) => New),
|
|
41
42
|
) => void
|
|
42
43
|
find: typeof findState
|
|
44
|
+
seek: typeof seekState
|
|
43
45
|
}>
|
|
44
46
|
export type TransactorsWithRunAndEnv = Readonly<{
|
|
45
47
|
get: <S>(state: ReadonlySelectorToken<S> | WritableToken<S>) => S
|
|
@@ -48,10 +50,11 @@ export type TransactorsWithRunAndEnv = Readonly<{
|
|
|
48
50
|
newValue: New | ((oldValue: S) => New),
|
|
49
51
|
) => void
|
|
50
52
|
find: typeof findState
|
|
53
|
+
seek: typeof seekState
|
|
51
54
|
run: typeof runTransaction
|
|
52
55
|
env: () => EnvironmentData
|
|
53
56
|
}>
|
|
54
|
-
export type ReadonlyTransactors = Pick<Transactors, `find` | `get`>
|
|
57
|
+
export type ReadonlyTransactors = Pick<Transactors, `find` | `get` | `seek`>
|
|
55
58
|
|
|
56
59
|
export type Read<F extends Func> = (
|
|
57
60
|
transactors: ReadonlyTransactors,
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ReadableToken,
|
|
3
|
-
ReadonlySelectorToken,
|
|
4
|
-
RegularAtomToken,
|
|
5
|
-
WritableSelectorToken,
|
|
6
|
-
WritableToken,
|
|
7
|
-
} from "atom.io"
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
Atom,
|
|
11
|
-
ReadableState,
|
|
12
|
-
ReadonlySelector,
|
|
13
|
-
Store,
|
|
14
|
-
WritableSelector,
|
|
15
|
-
WritableState,
|
|
16
|
-
} from ".."
|
|
17
|
-
import { newest, NotFoundError, withdraw } from ".."
|
|
18
|
-
|
|
19
|
-
export function withdrawOrCreate<T>(
|
|
20
|
-
token: RegularAtomToken<T>,
|
|
21
|
-
store: Store,
|
|
22
|
-
): Atom<T>
|
|
23
|
-
export function withdrawOrCreate<T>(
|
|
24
|
-
token: WritableSelectorToken<T>,
|
|
25
|
-
store: Store,
|
|
26
|
-
): WritableSelector<T>
|
|
27
|
-
export function withdrawOrCreate<T>(
|
|
28
|
-
token: ReadonlySelectorToken<T>,
|
|
29
|
-
store: Store,
|
|
30
|
-
): ReadonlySelector<T>
|
|
31
|
-
export function withdrawOrCreate<T>(
|
|
32
|
-
token: WritableToken<T>,
|
|
33
|
-
store: Store,
|
|
34
|
-
): WritableState<T>
|
|
35
|
-
export function withdrawOrCreate<T>(
|
|
36
|
-
token: ReadableToken<T>,
|
|
37
|
-
store: Store,
|
|
38
|
-
): ReadableState<T>
|
|
39
|
-
export function withdrawOrCreate<T>(
|
|
40
|
-
token: ReadableToken<T>,
|
|
41
|
-
store: Store,
|
|
42
|
-
): ReadableState<T> {
|
|
43
|
-
try {
|
|
44
|
-
const state = withdraw(token, store)
|
|
45
|
-
return state
|
|
46
|
-
} catch (notFoundError) {
|
|
47
|
-
if (token.family) {
|
|
48
|
-
store.logger.info(
|
|
49
|
-
`👪`,
|
|
50
|
-
token.type,
|
|
51
|
-
token.key,
|
|
52
|
-
`creating new family member in store "${store.config.name}"`,
|
|
53
|
-
)
|
|
54
|
-
const target = newest(store)
|
|
55
|
-
const family = target.families.get(token.family.key)
|
|
56
|
-
if (family) {
|
|
57
|
-
const jsonSubKey = JSON.parse(token.family.subKey)
|
|
58
|
-
family(jsonSubKey)
|
|
59
|
-
const state = withdraw(token, store)
|
|
60
|
-
return state
|
|
61
|
-
}
|
|
62
|
-
throw new NotFoundError(
|
|
63
|
-
{ key: token.family.key, type: `${token.type}_family` },
|
|
64
|
-
store,
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
throw notFoundError
|
|
68
|
-
}
|
|
69
|
-
}
|
|
File without changes
|
|
File without changes
|