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
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
import { Junction } from './chunk-FTONNX2R.js';
|
|
2
2
|
import { disposeState } from 'atom.io';
|
|
3
|
-
import { getFromStore, setIntoStore, findInStore, createMutableAtomFamily, createRegularAtomFamily, IMPLICIT, newest, isChildStore, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
3
|
+
import { getFromStore, setIntoStore, findInStore, seekInStore, initFamilyMember, createMutableAtomFamily, createRegularAtomFamily, IMPLICIT, newest, isChildStore, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
4
|
+
import { stringifyJson } from 'atom.io/json';
|
|
4
5
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
5
6
|
|
|
6
7
|
function capitalize(string) {
|
|
7
8
|
return string[0].toUpperCase() + string.slice(1);
|
|
8
9
|
}
|
|
9
10
|
var Join = class _Join {
|
|
10
|
-
transact(transactors, run) {
|
|
11
|
-
const originalTransactors = this.transactors;
|
|
12
|
-
this.transactors = transactors;
|
|
13
|
-
run(this);
|
|
14
|
-
this.transactors = originalTransactors;
|
|
15
|
-
}
|
|
16
|
-
in(store) {
|
|
17
|
-
const key = store.config.name;
|
|
18
|
-
const alternate = this.alternates.get(key);
|
|
19
|
-
if (alternate) {
|
|
20
|
-
return alternate;
|
|
21
|
-
}
|
|
22
|
-
const join2 = new _Join(this.options, this.defaultContent, store);
|
|
23
|
-
this.alternates.set(key, join2);
|
|
24
|
-
join2.alternates = this.alternates;
|
|
25
|
-
return join2;
|
|
26
|
-
}
|
|
27
11
|
constructor(options, defaultContent, store = IMPLICIT.STORE) {
|
|
12
|
+
this.molecules = /* @__PURE__ */ new Map();
|
|
13
|
+
this.store = store;
|
|
28
14
|
this.options = options;
|
|
29
15
|
this.defaultContent = defaultContent;
|
|
30
16
|
this.alternates = /* @__PURE__ */ new Map();
|
|
31
17
|
this.alternates.set(store.config.name, this);
|
|
18
|
+
this.store.miscResources.set(`join:${options.key}`, this);
|
|
32
19
|
this.transactors = {
|
|
33
20
|
get: (token) => getFromStore(token, store),
|
|
34
21
|
set: (token, value) => {
|
|
35
22
|
setIntoStore(token, value, store);
|
|
36
23
|
},
|
|
37
|
-
find: (token, key) => findInStore(token, key, store)
|
|
24
|
+
find: (token, key) => findInStore(token, key, store),
|
|
25
|
+
seek: (token, key) => seekInStore(token, key, store)
|
|
26
|
+
};
|
|
27
|
+
this.retrieve = (token, key) => {
|
|
28
|
+
const maybeToken = this.transactors.seek(token, key);
|
|
29
|
+
if (maybeToken) {
|
|
30
|
+
return maybeToken;
|
|
31
|
+
}
|
|
32
|
+
const molecule = this.molecules.get(stringifyJson(key));
|
|
33
|
+
if (!molecule) {
|
|
34
|
+
if (store.config.lifespan === `immortal`) {
|
|
35
|
+
throw new Error(`No molecule found for key "${stringifyJson(key)}"`);
|
|
36
|
+
}
|
|
37
|
+
return initFamilyMember(token, key, store);
|
|
38
|
+
}
|
|
39
|
+
return molecule.bond(token);
|
|
38
40
|
};
|
|
39
41
|
const aSide = options.between[0];
|
|
40
42
|
const bSide = options.between[1];
|
|
@@ -49,31 +51,57 @@ var Join = class _Join {
|
|
|
49
51
|
store
|
|
50
52
|
);
|
|
51
53
|
this.core = { findRelatedKeysState: relatedKeysAtoms };
|
|
52
|
-
const getRelatedKeys = ({
|
|
54
|
+
const getRelatedKeys = ({ get }, key) => get(this.retrieve(relatedKeysAtoms, key));
|
|
53
55
|
const addRelation = (transactors, a, b) => {
|
|
54
|
-
const { set
|
|
55
|
-
const aKeysState =
|
|
56
|
-
const bKeysState =
|
|
56
|
+
const { set } = transactors;
|
|
57
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
58
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
57
59
|
set(aKeysState, (aKeys) => aKeys.add(b));
|
|
58
60
|
set(bKeysState, (bKeys) => bKeys.add(a));
|
|
59
61
|
};
|
|
60
62
|
const deleteRelation = (transactors, a, b) => {
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const { set } = transactors;
|
|
65
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
66
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
67
|
+
let stringA;
|
|
68
|
+
let stringB;
|
|
69
|
+
set(aKeysState, (aKeys) => {
|
|
70
|
+
aKeys.delete(b);
|
|
71
|
+
if (aKeys.size === 0) {
|
|
72
|
+
stringA = `"${a}"`;
|
|
73
|
+
}
|
|
74
|
+
return aKeys;
|
|
75
|
+
});
|
|
76
|
+
set(bKeysState, (bKeys) => {
|
|
77
|
+
bKeys.delete(a);
|
|
78
|
+
if (bKeys.size === 0) {
|
|
79
|
+
stringB = `"${b}"`;
|
|
80
|
+
}
|
|
81
|
+
return bKeys;
|
|
82
|
+
});
|
|
83
|
+
if (stringA && this.molecules.has(stringA)) {
|
|
84
|
+
(_a = this.molecules.get(stringA)) == null ? void 0 : _a.clear();
|
|
85
|
+
this.molecules.delete(stringA);
|
|
86
|
+
}
|
|
87
|
+
if (stringB && this.molecules.has(stringB)) {
|
|
88
|
+
(_b = this.molecules.get(stringB)) == null ? void 0 : _b.clear();
|
|
89
|
+
this.molecules.delete(stringB);
|
|
90
|
+
}
|
|
66
91
|
};
|
|
67
92
|
const replaceRelationsSafely = (transactors, a, newRelationsOfA) => {
|
|
68
|
-
const {
|
|
69
|
-
const relationsOfAState =
|
|
93
|
+
const { get, set } = transactors;
|
|
94
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
70
95
|
const currentRelationsOfA = get(relationsOfAState);
|
|
71
96
|
for (const currentRelationB of currentRelationsOfA) {
|
|
72
97
|
const remainsRelated = newRelationsOfA.includes(currentRelationB);
|
|
73
98
|
if (remainsRelated) {
|
|
74
99
|
continue;
|
|
75
100
|
}
|
|
76
|
-
const relationsOfBState =
|
|
101
|
+
const relationsOfBState = this.retrieve(
|
|
102
|
+
relatedKeysAtoms,
|
|
103
|
+
currentRelationB
|
|
104
|
+
);
|
|
77
105
|
set(relationsOfBState, (relationsOfB) => {
|
|
78
106
|
relationsOfB.delete(a);
|
|
79
107
|
return relationsOfB;
|
|
@@ -86,6 +114,7 @@ var Join = class _Join {
|
|
|
86
114
|
const relationsOfB = getRelatedKeys(transactors, newRelationB);
|
|
87
115
|
const newRelationBIsAlreadyRelated = relationsOfB.has(a);
|
|
88
116
|
if (this.relations.cardinality === `1:n`) {
|
|
117
|
+
const previousOwnersToDispose = [];
|
|
89
118
|
for (const previousOwner of relationsOfB) {
|
|
90
119
|
if (previousOwner === a) {
|
|
91
120
|
continue;
|
|
@@ -95,10 +124,21 @@ var Join = class _Join {
|
|
|
95
124
|
previousOwner
|
|
96
125
|
);
|
|
97
126
|
previousOwnerRelations.delete(newRelationB);
|
|
127
|
+
if (previousOwnerRelations.size === 0) {
|
|
128
|
+
previousOwnersToDispose.push(previousOwner);
|
|
129
|
+
}
|
|
98
130
|
}
|
|
99
131
|
if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {
|
|
100
132
|
relationsOfB.clear();
|
|
101
133
|
}
|
|
134
|
+
for (const previousOwner of previousOwnersToDispose) {
|
|
135
|
+
const molecule = this.molecules.get(previousOwner);
|
|
136
|
+
molecule == null ? void 0 : molecule.clear();
|
|
137
|
+
this.molecules.delete(previousOwner);
|
|
138
|
+
const sorted = [newRelationB, previousOwner].sort();
|
|
139
|
+
const compositeKey = `"${sorted[0]}:${sorted[1]}"`;
|
|
140
|
+
this.molecules.delete(compositeKey);
|
|
141
|
+
}
|
|
102
142
|
}
|
|
103
143
|
if (!newRelationBIsAlreadyRelated) {
|
|
104
144
|
relationsOfB.add(a);
|
|
@@ -111,8 +151,8 @@ var Join = class _Join {
|
|
|
111
151
|
});
|
|
112
152
|
};
|
|
113
153
|
const replaceRelationsUnsafely = (transactors, a, newRelationsOfA) => {
|
|
114
|
-
const {
|
|
115
|
-
const relationsOfAState =
|
|
154
|
+
const { set } = transactors;
|
|
155
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
116
156
|
set(relationsOfAState, (relationsOfA) => {
|
|
117
157
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
118
158
|
for (const newRelationB of newRelationsOfA) {
|
|
@@ -123,7 +163,7 @@ var Join = class _Join {
|
|
|
123
163
|
return relationsOfA;
|
|
124
164
|
});
|
|
125
165
|
for (const newRelationB of newRelationsOfA) {
|
|
126
|
-
const newRelationsBState =
|
|
166
|
+
const newRelationsBState = this.retrieve(relatedKeysAtoms, newRelationB);
|
|
127
167
|
set(newRelationsBState, (newRelationsB) => {
|
|
128
168
|
newRelationsB.add(a);
|
|
129
169
|
return newRelationsB;
|
|
@@ -161,12 +201,13 @@ var Join = class _Join {
|
|
|
161
201
|
},
|
|
162
202
|
store
|
|
163
203
|
);
|
|
164
|
-
const getContent = ({
|
|
165
|
-
const setContent = ({
|
|
166
|
-
set(
|
|
204
|
+
const getContent = ({ get }, key) => get(this.retrieve(contentAtoms, key));
|
|
205
|
+
const setContent = ({ set }, key, content) => {
|
|
206
|
+
set(this.retrieve(contentAtoms, key), content);
|
|
167
207
|
};
|
|
168
|
-
const deleteContent = (
|
|
169
|
-
disposeState(
|
|
208
|
+
const deleteContent = (_, compositeKey) => {
|
|
209
|
+
disposeState(this.retrieve(contentAtoms, compositeKey));
|
|
210
|
+
this.molecules.delete(`"${compositeKey}"`);
|
|
170
211
|
};
|
|
171
212
|
const externalStoreWithContentConfiguration = {
|
|
172
213
|
getContent: (contentKey) => {
|
|
@@ -189,13 +230,24 @@ var Join = class _Join {
|
|
|
189
230
|
}
|
|
190
231
|
const relations = new Junction(options, {
|
|
191
232
|
externalStore,
|
|
192
|
-
makeContentKey: (...args) =>
|
|
233
|
+
makeContentKey: (...args) => {
|
|
234
|
+
const sorted = args.sort();
|
|
235
|
+
const compositeKey = `${sorted[0]}:${sorted[1]}`;
|
|
236
|
+
const [m0, m1] = sorted.map(
|
|
237
|
+
(key) => this.molecules.get(stringifyJson(key))
|
|
238
|
+
);
|
|
239
|
+
if (store.config.lifespan === `immortal` && m0 && m1) {
|
|
240
|
+
const composite = m0.with(m1)(compositeKey);
|
|
241
|
+
this.molecules.set(`"${compositeKey}"`, composite);
|
|
242
|
+
}
|
|
243
|
+
return compositeKey;
|
|
244
|
+
}
|
|
193
245
|
});
|
|
194
246
|
const createSingleKeyStateFamily = () => createSelectorFamily(
|
|
195
247
|
{
|
|
196
248
|
key: `${options.key}/singleRelatedKey`,
|
|
197
|
-
get: (key) => ({
|
|
198
|
-
const relatedKeysState =
|
|
249
|
+
get: (key) => ({ get }) => {
|
|
250
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key);
|
|
199
251
|
const relatedKeys = get(relatedKeysState);
|
|
200
252
|
for (const relatedKey of relatedKeys) {
|
|
201
253
|
return relatedKey;
|
|
@@ -209,9 +261,9 @@ var Join = class _Join {
|
|
|
209
261
|
return createSelectorFamily(
|
|
210
262
|
{
|
|
211
263
|
key: `${options.key}/multipleRelatedKeys`,
|
|
212
|
-
get: (key) => ({
|
|
264
|
+
get: (key) => ({ get }) => {
|
|
213
265
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
214
|
-
const jsonState =
|
|
266
|
+
const jsonState = this.retrieve(jsonFamily, key);
|
|
215
267
|
const json = get(jsonState);
|
|
216
268
|
return json.members;
|
|
217
269
|
}
|
|
@@ -222,12 +274,12 @@ var Join = class _Join {
|
|
|
222
274
|
const createSingleEntryStateFamily = () => createSelectorFamily(
|
|
223
275
|
{
|
|
224
276
|
key: `${options.key}/singleRelatedEntry`,
|
|
225
|
-
get: (key) => ({
|
|
226
|
-
const relatedKeysState =
|
|
277
|
+
get: (key) => ({ get }) => {
|
|
278
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key);
|
|
227
279
|
const relatedKeys = get(relatedKeysState);
|
|
228
280
|
for (const relatedKey of relatedKeys) {
|
|
229
281
|
const contentKey = relations.makeContentKey(key, relatedKey);
|
|
230
|
-
const contentState =
|
|
282
|
+
const contentState = this.retrieve(contentAtoms, contentKey);
|
|
231
283
|
const content = get(contentState);
|
|
232
284
|
return [relatedKey, content];
|
|
233
285
|
}
|
|
@@ -239,12 +291,13 @@ var Join = class _Join {
|
|
|
239
291
|
const getMultipleEntryStateFamily = () => createSelectorFamily(
|
|
240
292
|
{
|
|
241
293
|
key: `${options.key}/multipleRelatedEntries`,
|
|
242
|
-
get: (key) => ({
|
|
294
|
+
get: (key) => ({ get }) => {
|
|
243
295
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
244
|
-
const
|
|
296
|
+
const jsonState = this.retrieve(jsonFamily, key);
|
|
297
|
+
const json = get(jsonState);
|
|
245
298
|
return json.members.map((relatedKey) => {
|
|
246
299
|
const contentKey = relations.makeContentKey(key, relatedKey);
|
|
247
|
-
const contentState =
|
|
300
|
+
const contentState = this.retrieve(contentAtoms, contentKey);
|
|
248
301
|
const content = get(contentState);
|
|
249
302
|
return [relatedKey, content];
|
|
250
303
|
});
|
|
@@ -337,6 +390,26 @@ var Join = class _Join {
|
|
|
337
390
|
}
|
|
338
391
|
}
|
|
339
392
|
}
|
|
393
|
+
transact(transactors, run) {
|
|
394
|
+
const originalTransactors = this.transactors;
|
|
395
|
+
this.transactors = transactors;
|
|
396
|
+
run(this);
|
|
397
|
+
this.transactors = originalTransactors;
|
|
398
|
+
}
|
|
399
|
+
[Symbol.dispose]() {
|
|
400
|
+
this.alternates.delete(this.store.config.name);
|
|
401
|
+
}
|
|
402
|
+
in(store) {
|
|
403
|
+
const key = store.config.name;
|
|
404
|
+
const alternate = this.alternates.get(key);
|
|
405
|
+
if (alternate) {
|
|
406
|
+
return alternate;
|
|
407
|
+
}
|
|
408
|
+
const join2 = new _Join(this.options, this.defaultContent, store);
|
|
409
|
+
this.alternates.set(key, join2);
|
|
410
|
+
join2.alternates = this.alternates;
|
|
411
|
+
return join2;
|
|
412
|
+
}
|
|
340
413
|
};
|
|
341
414
|
function join(options, defaultContent, store = IMPLICIT.STORE) {
|
|
342
415
|
const joins = getJoinMap(store);
|
|
@@ -384,12 +457,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
384
457
|
relations = {
|
|
385
458
|
get [keyAB]() {
|
|
386
459
|
const familyAB = myJoin.states[keyAB];
|
|
387
|
-
const state =
|
|
460
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
388
461
|
return state;
|
|
389
462
|
},
|
|
390
463
|
get [keyBA]() {
|
|
391
464
|
const familyBA = myJoin.states[keyBA];
|
|
392
|
-
const state =
|
|
465
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
393
466
|
return state;
|
|
394
467
|
}
|
|
395
468
|
};
|
|
@@ -399,12 +472,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
399
472
|
Object.assign(relations, {
|
|
400
473
|
get [entryAB]() {
|
|
401
474
|
const familyAB = myJoin.states[entryAB];
|
|
402
|
-
const state =
|
|
475
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
403
476
|
return state;
|
|
404
477
|
},
|
|
405
478
|
get [entryBA]() {
|
|
406
479
|
const familyBA = myJoin.states[entryBA];
|
|
407
|
-
const state =
|
|
480
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
408
481
|
return state;
|
|
409
482
|
}
|
|
410
483
|
});
|
|
@@ -417,12 +490,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
417
490
|
relations = {
|
|
418
491
|
get [keyAB]() {
|
|
419
492
|
const familyAB = myJoin.states[keyAB];
|
|
420
|
-
const state =
|
|
493
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
421
494
|
return state;
|
|
422
495
|
},
|
|
423
496
|
get [keysBA]() {
|
|
424
497
|
const familyBA = myJoin.states[keysBA];
|
|
425
|
-
const state =
|
|
498
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
426
499
|
return state;
|
|
427
500
|
}
|
|
428
501
|
};
|
|
@@ -432,12 +505,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
432
505
|
Object.assign(relations, {
|
|
433
506
|
get [entryAB]() {
|
|
434
507
|
const familyAB = myJoin.states[entryAB];
|
|
435
|
-
const state =
|
|
508
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
436
509
|
return state;
|
|
437
510
|
},
|
|
438
511
|
get [entriesBA]() {
|
|
439
512
|
const familyBA = myJoin.states[entriesBA];
|
|
440
|
-
const state =
|
|
513
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
441
514
|
return state;
|
|
442
515
|
}
|
|
443
516
|
});
|
|
@@ -450,12 +523,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
450
523
|
relations = {
|
|
451
524
|
get [keysAB]() {
|
|
452
525
|
const familyAB = myJoin.states[keysAB];
|
|
453
|
-
const state =
|
|
526
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
454
527
|
return state;
|
|
455
528
|
},
|
|
456
529
|
get [keysBA]() {
|
|
457
530
|
const familyBA = myJoin.states[keysBA];
|
|
458
|
-
const state =
|
|
531
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
459
532
|
return state;
|
|
460
533
|
}
|
|
461
534
|
};
|
|
@@ -465,12 +538,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
465
538
|
Object.assign(relations, {
|
|
466
539
|
get [entriesAB]() {
|
|
467
540
|
const familyAB = myJoin.states[entriesAB];
|
|
468
|
-
const state =
|
|
541
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
469
542
|
return state;
|
|
470
543
|
},
|
|
471
544
|
get [entriesBA]() {
|
|
472
545
|
const familyBA = myJoin.states[entriesBA];
|
|
473
|
-
const state =
|
|
546
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
474
547
|
return state;
|
|
475
548
|
}
|
|
476
549
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -41,10 +41,6 @@ function disposeState(token, store = Internal__namespace.IMPLICIT.STORE) {
|
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
function findState(token, key) {
|
|
45
|
-
const state = Internal.findInStore(token, key, Internal.IMPLICIT.STORE);
|
|
46
|
-
return state;
|
|
47
|
-
}
|
|
48
44
|
function getState(token) {
|
|
49
45
|
return Internal__namespace.getFromStore(token, Internal__namespace.IMPLICIT.STORE);
|
|
50
46
|
}
|
|
@@ -97,8 +93,8 @@ function setState(token, value) {
|
|
|
97
93
|
Internal__namespace.setIntoStore(token, value, Internal__namespace.IMPLICIT.STORE);
|
|
98
94
|
}
|
|
99
95
|
var Silo = class {
|
|
100
|
-
constructor(
|
|
101
|
-
const s = new Internal.Store(
|
|
96
|
+
constructor(config, fromStore = null) {
|
|
97
|
+
const s = new Internal.Store(config, fromStore);
|
|
102
98
|
function _atom(options) {
|
|
103
99
|
return Internal.createStandaloneAtom(options, s);
|
|
104
100
|
}
|
|
@@ -171,7 +167,6 @@ exports.atom = atom;
|
|
|
171
167
|
exports.atomFamily = atomFamily;
|
|
172
168
|
exports.belongsTo = belongsTo;
|
|
173
169
|
exports.disposeState = disposeState;
|
|
174
|
-
exports.findState = findState;
|
|
175
170
|
exports.getState = getState;
|
|
176
171
|
exports.isToken = isToken;
|
|
177
172
|
exports.redo = redo;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Internal from 'atom.io/internal';
|
|
2
2
|
import { Transceiver, Subject, Store, EnvironmentData, Timeline, TimelineAtomUpdate, TimelineSelectorUpdate, TimelineTransactionUpdate } from 'atom.io/internal';
|
|
3
3
|
import { Json, JsonInterface } from 'atom.io/json';
|
|
4
|
+
import { findState } from 'atom.io/ephemeral';
|
|
4
5
|
import { MutableAtomFamilyToken as MutableAtomFamilyToken$1, MutableAtomToken as MutableAtomToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, RegularAtomToken as RegularAtomToken$1, WritableSelectorFamilyToken as WritableSelectorFamilyToken$1, WritableSelectorToken as WritableSelectorToken$1, ReadonlySelectorFamilyToken as ReadonlySelectorFamilyToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, WritableFamilyToken as WritableFamilyToken$1, WritableToken as WritableToken$1, ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1 } from 'atom.io';
|
|
5
6
|
|
|
6
7
|
type Effectors<T> = {
|
|
@@ -33,7 +34,10 @@ type RegularAtomFamilyToken<T, K extends Json.Serializable> = {
|
|
|
33
34
|
__T?: T;
|
|
34
35
|
__K?: K;
|
|
35
36
|
};
|
|
36
|
-
type RegularAtomFamilyTokenWithCall<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> &
|
|
37
|
+
type RegularAtomFamilyTokenWithCall<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> & {
|
|
38
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
39
|
+
(key: K): RegularAtomToken<T>;
|
|
40
|
+
};
|
|
37
41
|
type RegularAtomFamily<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> & {
|
|
38
42
|
(key: K): RegularAtomToken<T>;
|
|
39
43
|
subject: Subject<RegularAtomToken<T>>;
|
|
@@ -52,7 +56,10 @@ type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializa
|
|
|
52
56
|
__J?: J;
|
|
53
57
|
__K?: K;
|
|
54
58
|
};
|
|
55
|
-
type MutableAtomFamilyTokenWithCall<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = MutableAtomFamilyToken<T, J, K> &
|
|
59
|
+
type MutableAtomFamilyTokenWithCall<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = MutableAtomFamilyToken<T, J, K> & {
|
|
60
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
61
|
+
(key: K): MutableAtomToken<T, J>;
|
|
62
|
+
};
|
|
56
63
|
type MutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = JsonInterface<T, J> & MutableAtomFamilyToken<T, J, K> & {
|
|
57
64
|
(key: K): MutableAtomToken<T, J>;
|
|
58
65
|
subject: Subject<MutableAtomToken<T, J>>;
|
|
@@ -63,6 +70,13 @@ type AtomFamilyToken<T, K extends Json.Serializable = Json.Serializable> = Mutab
|
|
|
63
70
|
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyTokenWithCall<T, J, K>;
|
|
64
71
|
declare function atomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>): RegularAtomFamilyTokenWithCall<T, K>;
|
|
65
72
|
|
|
73
|
+
declare function seekState<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(token: MutableAtomFamilyToken$1<T, J, K>, key: Key): MutableAtomToken$1<T, J> | undefined;
|
|
74
|
+
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: RegularAtomFamilyToken$1<T, K>, key: Key): RegularAtomToken$1<T> | undefined;
|
|
75
|
+
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: WritableSelectorFamilyToken$1<T, K>, key: Key): WritableSelectorToken$1<T> | undefined;
|
|
76
|
+
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: ReadonlySelectorFamilyToken$1<T, K>, key: Key): ReadonlySelectorToken$1<T> | undefined;
|
|
77
|
+
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: WritableFamilyToken$1<T, K>, key: Key): WritableToken$1<T> | undefined;
|
|
78
|
+
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: ReadableFamilyToken$1<T, K>, key: Key): ReadableToken$1<T> | undefined;
|
|
79
|
+
|
|
66
80
|
type TransactionToken<F extends Func> = {
|
|
67
81
|
key: string;
|
|
68
82
|
type: `transaction`;
|
|
@@ -81,15 +95,17 @@ type Transactors = Readonly<{
|
|
|
81
95
|
get: <S>(state: ReadonlySelectorToken<S> | WritableToken<S>) => S;
|
|
82
96
|
set: <S, New extends S>(state: WritableToken<S>, newValue: New | ((oldValue: S) => New)) => void;
|
|
83
97
|
find: typeof findState;
|
|
98
|
+
seek: typeof seekState;
|
|
84
99
|
}>;
|
|
85
100
|
type TransactorsWithRunAndEnv = Readonly<{
|
|
86
101
|
get: <S>(state: ReadonlySelectorToken<S> | WritableToken<S>) => S;
|
|
87
102
|
set: <S, New extends S>(state: WritableToken<S>, newValue: New | ((oldValue: S) => New)) => void;
|
|
88
103
|
find: typeof findState;
|
|
104
|
+
seek: typeof seekState;
|
|
89
105
|
run: typeof runTransaction;
|
|
90
106
|
env: () => EnvironmentData;
|
|
91
107
|
}>;
|
|
92
|
-
type ReadonlyTransactors = Pick<Transactors, `find` | `get`>;
|
|
108
|
+
type ReadonlyTransactors = Pick<Transactors, `find` | `get` | `seek`>;
|
|
93
109
|
type Read<F extends Func> = (transactors: ReadonlyTransactors, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
94
110
|
type Write<F extends Func> = (transactors: Transactors, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
95
111
|
type Transact<F extends Func> = (transactors: TransactorsWithRunAndEnv, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
@@ -127,7 +143,10 @@ type WritableSelectorFamilyToken<T, K extends Json.Serializable> = {
|
|
|
127
143
|
__T?: T;
|
|
128
144
|
__K?: K;
|
|
129
145
|
};
|
|
130
|
-
type WritableSelectorFamilyTokenWithCall<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> &
|
|
146
|
+
type WritableSelectorFamilyTokenWithCall<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> & {
|
|
147
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
148
|
+
(key: K): WritableSelectorToken<T>;
|
|
149
|
+
};
|
|
131
150
|
type WritableSelectorFamily<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> & {
|
|
132
151
|
(key: K): WritableSelectorToken<T>;
|
|
133
152
|
subject: Subject<WritableSelectorToken<T>>;
|
|
@@ -139,7 +158,10 @@ type ReadonlySelectorFamilyToken<T, K extends Json.Serializable> = {
|
|
|
139
158
|
__T?: T;
|
|
140
159
|
__K?: K;
|
|
141
160
|
};
|
|
142
|
-
type ReadonlySelectorFamilyTokenWithCall<T, K extends Json.Serializable> = ReadonlySelectorFamilyToken<T, K> &
|
|
161
|
+
type ReadonlySelectorFamilyTokenWithCall<T, K extends Json.Serializable> = ReadonlySelectorFamilyToken<T, K> & {
|
|
162
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
163
|
+
(key: K): ReadonlySelectorToken<T>;
|
|
164
|
+
};
|
|
143
165
|
type ReadonlySelectorFamily<T, K extends Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
144
166
|
key: string;
|
|
145
167
|
type: `readonly_selector_family`;
|
|
@@ -155,13 +177,6 @@ declare function selectorFamily<T, K extends Json.Serializable>(options: Readonl
|
|
|
155
177
|
|
|
156
178
|
declare function disposeState(token: ReadableToken<any>, store?: Internal.Store): void;
|
|
157
179
|
|
|
158
|
-
declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(token: MutableAtomFamilyToken$1<T, J, K>, key: Key): MutableAtomToken$1<T, J>;
|
|
159
|
-
declare function findState<T, K extends Json.Serializable, Key extends K>(token: RegularAtomFamilyToken$1<T, K>, key: Key): RegularAtomToken$1<T>;
|
|
160
|
-
declare function findState<T, K extends Json.Serializable, Key extends K>(token: WritableSelectorFamilyToken$1<T, K>, key: Key): WritableSelectorToken$1<T>;
|
|
161
|
-
declare function findState<T, K extends Json.Serializable, Key extends K>(token: ReadonlySelectorFamilyToken$1<T, K>, key: Key): ReadonlySelectorToken$1<T>;
|
|
162
|
-
declare function findState<T, K extends Json.Serializable, Key extends K>(token: WritableFamilyToken$1<T, K>, key: Key): WritableToken$1<T>;
|
|
163
|
-
declare function findState<T, K extends Json.Serializable, Key extends K>(token: ReadableFamilyToken$1<T, K>, key: Key): ReadableToken$1<T>;
|
|
164
|
-
|
|
165
180
|
declare function getState<T>(token: ReadableToken<T>): T;
|
|
166
181
|
|
|
167
182
|
declare const LoggerIconDictionary: {
|
|
@@ -250,7 +265,7 @@ declare class Silo {
|
|
|
250
265
|
subscribe: typeof subscribe;
|
|
251
266
|
undo: typeof undo;
|
|
252
267
|
redo: typeof redo;
|
|
253
|
-
constructor(
|
|
268
|
+
constructor(config: Store[`config`], fromStore?: Store | null);
|
|
254
269
|
}
|
|
255
270
|
|
|
256
271
|
type StateUpdate<T> = {
|
|
@@ -336,4 +351,4 @@ type FamilyMetadata = {
|
|
|
336
351
|
subKey: string;
|
|
337
352
|
};
|
|
338
353
|
|
|
339
|
-
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomToken, type Effectors, type FamilyMetadata, type Func, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, Silo, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type Transactors, type TransactorsWithRunAndEnv, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState,
|
|
354
|
+
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomToken, type Effectors, type FamilyMetadata, type Func, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, Silo, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type Transactors, type TransactorsWithRunAndEnv, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getState } from './chunk-PNIHPILQ.js';
|
|
2
2
|
import './chunk-F2X4B4VY.js';
|
|
3
3
|
import * as Internal from 'atom.io/internal';
|
|
4
|
-
import { createStandaloneAtom, IMPLICIT, createAtomFamily,
|
|
4
|
+
import { createStandaloneAtom, IMPLICIT, createAtomFamily, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, findInStore, getFromStore, setIntoStore, timeTravel, subscribeToTimeline, subscribeToTransaction, subscribeToState, arbitrary, actUponStore } from 'atom.io/internal';
|
|
5
5
|
|
|
6
6
|
function atom(options) {
|
|
7
7
|
return createStandaloneAtom(options, IMPLICIT.STORE);
|
|
@@ -21,10 +21,6 @@ function disposeState(token, store = Internal.IMPLICIT.STORE) {
|
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
function findState(token, key) {
|
|
25
|
-
const state = findInStore(token, key, IMPLICIT.STORE);
|
|
26
|
-
return state;
|
|
27
|
-
}
|
|
28
24
|
|
|
29
25
|
// src/logger.ts
|
|
30
26
|
var LOG_LEVELS = [`info`, `warn`, `error`];
|
|
@@ -74,8 +70,8 @@ function setState(token, value) {
|
|
|
74
70
|
Internal.setIntoStore(token, value, Internal.IMPLICIT.STORE);
|
|
75
71
|
}
|
|
76
72
|
var Silo = class {
|
|
77
|
-
constructor(
|
|
78
|
-
const s = new Store(
|
|
73
|
+
constructor(config, fromStore = null) {
|
|
74
|
+
const s = new Store(config, fromStore);
|
|
79
75
|
function _atom(options) {
|
|
80
76
|
return createStandaloneAtom(options, s);
|
|
81
77
|
}
|
|
@@ -141,4 +137,4 @@ function belongsTo(family, unknownToken) {
|
|
|
141
137
|
return family.key === ((_a = unknownToken.family) == null ? void 0 : _a.key);
|
|
142
138
|
}
|
|
143
139
|
|
|
144
|
-
export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, belongsTo, disposeState,
|
|
140
|
+
export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, belongsTo, disposeState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var internal = require('atom.io/internal');
|
|
4
|
+
|
|
5
|
+
// ephemeral/src/find-state.ts
|
|
6
|
+
function findState(token, key) {
|
|
7
|
+
const state = internal.findInStore(token, key, internal.IMPLICIT.STORE);
|
|
8
|
+
return state;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.findState = findState;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "atom.io-ephemeral",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"private": true,
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"browser": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./find-state"
|