atom.io 0.21.1 → 0.23.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 +152 -63
- package/data/dist/index.d.ts +6 -0
- package/data/dist/index.js +3 -3
- package/data/src/join.ts +164 -51
- package/data/src/struct-family.ts +2 -2
- package/dist/chunk-6MLFYN32.js +18 -0
- package/dist/{chunk-HITX3MO4.js → chunk-7DT3PVS3.js} +151 -62
- package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
- package/dist/chunk-OAYGID5B.js +27 -0
- package/dist/index.cjs +4 -18
- package/dist/index.d.ts +71 -28
- package/dist/index.js +6 -19
- 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 +155 -1
- package/eslint-plugin/dist/index.js +155 -1
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/lifespan.ts +203 -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 +260 -0
- package/immortal/dist/index.js +212 -0
- package/immortal/package.json +16 -0
- package/immortal/src/index.ts +3 -0
- package/immortal/src/make-molecule.ts +222 -0
- package/immortal/src/molecule.ts +167 -0
- package/immortal/src/seek-state.ts +73 -0
- package/internal/dist/index.cjs +1242 -837
- package/internal/dist/index.d.ts +135 -22
- package/internal/dist/index.js +1215 -838
- package/internal/src/atom/create-regular-atom.ts +0 -2
- package/internal/src/atom/create-standalone-atom.ts +6 -2
- package/internal/src/atom/dispose-atom.ts +26 -3
- package/internal/src/families/create-readonly-selector-family.ts +15 -10
- package/internal/src/families/create-regular-atom-family.ts +20 -21
- package/internal/src/families/create-writable-selector-family.ts +13 -9
- package/{src/dispose.ts → internal/src/families/dispose-from-store.ts} +7 -4
- package/internal/src/families/find-in-store.ts +11 -6
- package/internal/src/families/index.ts +3 -0
- package/internal/src/families/init-family-member.ts +112 -0
- package/internal/src/families/seek-in-store.ts +123 -0
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/ingest-updates/index.ts +1 -0
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +104 -0
- package/internal/src/ingest-updates/ingest-transaction-update.ts +26 -4
- package/internal/src/mutable/create-mutable-atom-family.ts +22 -24
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-json-family.ts +2 -2
- package/internal/src/mutable/get-json-token.ts +26 -12
- package/internal/src/mutable/tracker-family.ts +21 -19
- package/internal/src/not-found-error.ts +16 -3
- package/internal/src/selector/create-readonly-selector.ts +2 -3
- package/internal/src/selector/create-standalone-selector.ts +6 -2
- package/internal/src/selector/create-writable-selector.ts +2 -3
- package/internal/src/selector/dispose-selector.ts +68 -24
- package/internal/src/selector/register-selector.ts +10 -5
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/set-state/stow-update.ts +5 -1
- package/internal/src/store/deposit.ts +41 -7
- package/internal/src/store/index.ts +0 -1
- package/internal/src/store/store.ts +29 -5
- package/internal/src/store/withdraw.ts +28 -1
- package/internal/src/subscribe/subscribe-to-state.ts +2 -2
- package/internal/src/timeline/add-atom-to-timeline.ts +206 -182
- package/internal/src/timeline/create-timeline.ts +181 -60
- package/internal/src/timeline/time-travel.ts +20 -0
- package/internal/src/transaction/apply-transaction.ts +2 -12
- package/internal/src/transaction/build-transaction.ts +16 -2
- package/introspection/dist/index.cjs +40 -53
- package/introspection/dist/index.js +40 -53
- package/introspection/src/attach-atom-index.ts +38 -48
- package/introspection/src/attach-selector-index.ts +45 -50
- package/introspection/src/attach-timeline-family.ts +1 -0
- package/json/dist/index.cjs +40 -6
- package/json/dist/index.js +44 -9
- package/json/src/select-json-family.ts +47 -9
- 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 +69 -57
- package/react-devtools/dist/index.js +62 -49
- package/react-devtools/src/StateIndex.tsx +2 -1
- package/react-devtools/src/TimelineIndex.tsx +17 -14
- package/react-devtools/src/TransactionIndex.tsx +7 -7
- package/react-devtools/src/Updates.tsx +41 -32
- 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 +39 -27
- package/realtime-server/dist/index.d.ts +1 -1
- package/realtime-server/dist/index.js +27 -16
- 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-server/src/realtime-server-stores/server-sync-store.ts +21 -11
- package/realtime-testing/dist/index.cjs +7 -2
- package/realtime-testing/dist/index.js +8 -5
- package/realtime-testing/src/setup-realtime-test.tsx +5 -2
- package/src/atom.ts +19 -7
- package/src/dispose-state.ts +10 -0
- package/src/index.ts +5 -2
- package/src/selector.ts +13 -7
- package/src/silo.ts +3 -3
- package/src/subscribe.ts +8 -4
- package/src/timeline.ts +18 -1
- package/src/transaction.ts +59 -4
- package/dist/chunk-BF4MVQF6.js +0 -44
- package/internal/src/store/withdraw-new-family-member.ts +0 -69
- /package/{src → ephemeral/src}/find-state.ts +0 -0
|
@@ -1,40 +1,44 @@
|
|
|
1
1
|
import { Junction } from './chunk-FTONNX2R.js';
|
|
2
2
|
import { disposeState } from 'atom.io';
|
|
3
|
-
import {
|
|
3
|
+
import { createMoleculeFamily, Molecule, makeMoleculeInStore } from 'atom.io/immortal';
|
|
4
|
+
import { getFromStore, setIntoStore, findInStore, seekInStore, getJsonToken, initFamilyMember, createMutableAtomFamily, createRegularAtomFamily, newest, IMPLICIT, isChildStore, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
5
|
+
import { stringifyJson } from 'atom.io/json';
|
|
4
6
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
5
7
|
|
|
6
8
|
function capitalize(string) {
|
|
7
9
|
return string[0].toUpperCase() + string.slice(1);
|
|
8
10
|
}
|
|
9
11
|
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
12
|
constructor(options, defaultContent, store = IMPLICIT.STORE) {
|
|
13
|
+
this.molecules = /* @__PURE__ */ new Map();
|
|
14
|
+
this.store = store;
|
|
28
15
|
this.options = options;
|
|
29
16
|
this.defaultContent = defaultContent;
|
|
30
17
|
this.alternates = /* @__PURE__ */ new Map();
|
|
31
18
|
this.alternates.set(store.config.name, this);
|
|
19
|
+
this.store.miscResources.set(`join:${options.key}`, this);
|
|
32
20
|
this.transactors = {
|
|
33
21
|
get: (token) => getFromStore(token, store),
|
|
34
22
|
set: (token, value) => {
|
|
35
23
|
setIntoStore(token, value, store);
|
|
36
24
|
},
|
|
37
|
-
find: (token, key) => findInStore(token, key, store)
|
|
25
|
+
find: (token, key) => findInStore(token, key, store),
|
|
26
|
+
seek: (token, key) => seekInStore(token, key, store),
|
|
27
|
+
json: (token) => getJsonToken(token, store)
|
|
28
|
+
};
|
|
29
|
+
this.retrieve = (token, key) => {
|
|
30
|
+
const maybeToken = this.transactors.seek(token, key);
|
|
31
|
+
if (maybeToken) {
|
|
32
|
+
return maybeToken;
|
|
33
|
+
}
|
|
34
|
+
const molecule = this.molecules.get(stringifyJson(key));
|
|
35
|
+
if (!molecule) {
|
|
36
|
+
if (store.config.lifespan === `immortal`) {
|
|
37
|
+
throw new Error(`No molecule found for key "${stringifyJson(key)}"`);
|
|
38
|
+
}
|
|
39
|
+
return initFamilyMember(token, key, store);
|
|
40
|
+
}
|
|
41
|
+
return molecule.bond(token);
|
|
38
42
|
};
|
|
39
43
|
const aSide = options.between[0];
|
|
40
44
|
const bSide = options.between[1];
|
|
@@ -49,31 +53,57 @@ var Join = class _Join {
|
|
|
49
53
|
store
|
|
50
54
|
);
|
|
51
55
|
this.core = { findRelatedKeysState: relatedKeysAtoms };
|
|
52
|
-
const getRelatedKeys = ({
|
|
56
|
+
const getRelatedKeys = ({ get }, key) => get(this.retrieve(relatedKeysAtoms, key));
|
|
53
57
|
const addRelation = (transactors, a, b) => {
|
|
54
|
-
const { set
|
|
55
|
-
const aKeysState =
|
|
56
|
-
const bKeysState =
|
|
58
|
+
const { set } = transactors;
|
|
59
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
60
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
57
61
|
set(aKeysState, (aKeys) => aKeys.add(b));
|
|
58
62
|
set(bKeysState, (bKeys) => bKeys.add(a));
|
|
59
63
|
};
|
|
60
64
|
const deleteRelation = (transactors, a, b) => {
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
var _a, _b;
|
|
66
|
+
const { set } = transactors;
|
|
67
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
68
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
69
|
+
let stringA;
|
|
70
|
+
let stringB;
|
|
71
|
+
set(aKeysState, (aKeys) => {
|
|
72
|
+
aKeys.delete(b);
|
|
73
|
+
if (aKeys.size === 0) {
|
|
74
|
+
stringA = `"${a}"`;
|
|
75
|
+
}
|
|
76
|
+
return aKeys;
|
|
77
|
+
});
|
|
78
|
+
set(bKeysState, (bKeys) => {
|
|
79
|
+
bKeys.delete(a);
|
|
80
|
+
if (bKeys.size === 0) {
|
|
81
|
+
stringB = `"${b}"`;
|
|
82
|
+
}
|
|
83
|
+
return bKeys;
|
|
84
|
+
});
|
|
85
|
+
if (stringA && this.molecules.has(stringA)) {
|
|
86
|
+
(_a = this.molecules.get(stringA)) == null ? void 0 : _a.clear();
|
|
87
|
+
this.molecules.delete(stringA);
|
|
88
|
+
}
|
|
89
|
+
if (stringB && this.molecules.has(stringB)) {
|
|
90
|
+
(_b = this.molecules.get(stringB)) == null ? void 0 : _b.clear();
|
|
91
|
+
this.molecules.delete(stringB);
|
|
92
|
+
}
|
|
66
93
|
};
|
|
67
94
|
const replaceRelationsSafely = (transactors, a, newRelationsOfA) => {
|
|
68
|
-
const {
|
|
69
|
-
const relationsOfAState =
|
|
95
|
+
const { get, set } = transactors;
|
|
96
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
70
97
|
const currentRelationsOfA = get(relationsOfAState);
|
|
71
98
|
for (const currentRelationB of currentRelationsOfA) {
|
|
72
99
|
const remainsRelated = newRelationsOfA.includes(currentRelationB);
|
|
73
100
|
if (remainsRelated) {
|
|
74
101
|
continue;
|
|
75
102
|
}
|
|
76
|
-
const relationsOfBState =
|
|
103
|
+
const relationsOfBState = this.retrieve(
|
|
104
|
+
relatedKeysAtoms,
|
|
105
|
+
currentRelationB
|
|
106
|
+
);
|
|
77
107
|
set(relationsOfBState, (relationsOfB) => {
|
|
78
108
|
relationsOfB.delete(a);
|
|
79
109
|
return relationsOfB;
|
|
@@ -86,6 +116,7 @@ var Join = class _Join {
|
|
|
86
116
|
const relationsOfB = getRelatedKeys(transactors, newRelationB);
|
|
87
117
|
const newRelationBIsAlreadyRelated = relationsOfB.has(a);
|
|
88
118
|
if (this.relations.cardinality === `1:n`) {
|
|
119
|
+
const previousOwnersToDispose = [];
|
|
89
120
|
for (const previousOwner of relationsOfB) {
|
|
90
121
|
if (previousOwner === a) {
|
|
91
122
|
continue;
|
|
@@ -95,10 +126,21 @@ var Join = class _Join {
|
|
|
95
126
|
previousOwner
|
|
96
127
|
);
|
|
97
128
|
previousOwnerRelations.delete(newRelationB);
|
|
129
|
+
if (previousOwnerRelations.size === 0) {
|
|
130
|
+
previousOwnersToDispose.push(previousOwner);
|
|
131
|
+
}
|
|
98
132
|
}
|
|
99
133
|
if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {
|
|
100
134
|
relationsOfB.clear();
|
|
101
135
|
}
|
|
136
|
+
for (const previousOwner of previousOwnersToDispose) {
|
|
137
|
+
const molecule = this.molecules.get(previousOwner);
|
|
138
|
+
molecule == null ? void 0 : molecule.clear();
|
|
139
|
+
this.molecules.delete(previousOwner);
|
|
140
|
+
const sorted = [newRelationB, previousOwner].sort();
|
|
141
|
+
const compositeKey = `"${sorted[0]}:${sorted[1]}"`;
|
|
142
|
+
this.molecules.delete(compositeKey);
|
|
143
|
+
}
|
|
102
144
|
}
|
|
103
145
|
if (!newRelationBIsAlreadyRelated) {
|
|
104
146
|
relationsOfB.add(a);
|
|
@@ -111,8 +153,8 @@ var Join = class _Join {
|
|
|
111
153
|
});
|
|
112
154
|
};
|
|
113
155
|
const replaceRelationsUnsafely = (transactors, a, newRelationsOfA) => {
|
|
114
|
-
const {
|
|
115
|
-
const relationsOfAState =
|
|
156
|
+
const { set } = transactors;
|
|
157
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
116
158
|
set(relationsOfAState, (relationsOfA) => {
|
|
117
159
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
118
160
|
for (const newRelationB of newRelationsOfA) {
|
|
@@ -123,7 +165,7 @@ var Join = class _Join {
|
|
|
123
165
|
return relationsOfA;
|
|
124
166
|
});
|
|
125
167
|
for (const newRelationB of newRelationsOfA) {
|
|
126
|
-
const newRelationsBState =
|
|
168
|
+
const newRelationsBState = this.retrieve(relatedKeysAtoms, newRelationB);
|
|
127
169
|
set(newRelationsBState, (newRelationsB) => {
|
|
128
170
|
newRelationsB.add(a);
|
|
129
171
|
return newRelationsB;
|
|
@@ -153,6 +195,7 @@ var Join = class _Join {
|
|
|
153
195
|
};
|
|
154
196
|
let externalStore;
|
|
155
197
|
let contentAtoms;
|
|
198
|
+
let contentMolecules;
|
|
156
199
|
if (defaultContent) {
|
|
157
200
|
contentAtoms = createRegularAtomFamily(
|
|
158
201
|
{
|
|
@@ -161,12 +204,24 @@ var Join = class _Join {
|
|
|
161
204
|
},
|
|
162
205
|
store
|
|
163
206
|
);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
207
|
+
contentMolecules = createMoleculeFamily(
|
|
208
|
+
{
|
|
209
|
+
key: `${options.key}/content-molecules`,
|
|
210
|
+
new: (s) => class ContentMolecule extends Molecule {
|
|
211
|
+
constructor(context, token) {
|
|
212
|
+
super(s, context, token);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
store
|
|
217
|
+
);
|
|
218
|
+
const getContent = ({ get }, key) => get(this.retrieve(contentAtoms, key));
|
|
219
|
+
const setContent = ({ set }, key, content) => {
|
|
220
|
+
set(this.retrieve(contentAtoms, key), content);
|
|
167
221
|
};
|
|
168
|
-
const deleteContent = (
|
|
169
|
-
disposeState(
|
|
222
|
+
const deleteContent = (_, compositeKey) => {
|
|
223
|
+
disposeState(this.retrieve(contentAtoms, compositeKey));
|
|
224
|
+
this.molecules.delete(`"${compositeKey}"`);
|
|
170
225
|
};
|
|
171
226
|
const externalStoreWithContentConfiguration = {
|
|
172
227
|
getContent: (contentKey) => {
|
|
@@ -189,13 +244,26 @@ var Join = class _Join {
|
|
|
189
244
|
}
|
|
190
245
|
const relations = new Junction(options, {
|
|
191
246
|
externalStore,
|
|
192
|
-
makeContentKey: (...args) =>
|
|
247
|
+
makeContentKey: (...args) => {
|
|
248
|
+
const sorted = args.sort();
|
|
249
|
+
const compositeKey = `${sorted[0]}:${sorted[1]}`;
|
|
250
|
+
const [m0, m1] = sorted.map(
|
|
251
|
+
(key) => this.molecules.get(stringifyJson(key))
|
|
252
|
+
);
|
|
253
|
+
if (store.config.lifespan === `immortal` && m0 && m1) {
|
|
254
|
+
const composite = m0.with(m1)(compositeKey);
|
|
255
|
+
this.molecules.set(`"${compositeKey}"`, composite);
|
|
256
|
+
const target = newest(store);
|
|
257
|
+
makeMoleculeInStore(target, [m0, m1], contentMolecules, compositeKey);
|
|
258
|
+
}
|
|
259
|
+
return compositeKey;
|
|
260
|
+
}
|
|
193
261
|
});
|
|
194
262
|
const createSingleKeyStateFamily = () => createSelectorFamily(
|
|
195
263
|
{
|
|
196
264
|
key: `${options.key}/singleRelatedKey`,
|
|
197
|
-
get: (key) => ({
|
|
198
|
-
const relatedKeysState =
|
|
265
|
+
get: (key) => ({ get }) => {
|
|
266
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key);
|
|
199
267
|
const relatedKeys = get(relatedKeysState);
|
|
200
268
|
for (const relatedKey of relatedKeys) {
|
|
201
269
|
return relatedKey;
|
|
@@ -209,9 +277,9 @@ var Join = class _Join {
|
|
|
209
277
|
return createSelectorFamily(
|
|
210
278
|
{
|
|
211
279
|
key: `${options.key}/multipleRelatedKeys`,
|
|
212
|
-
get: (key) => ({
|
|
280
|
+
get: (key) => ({ get }) => {
|
|
213
281
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
214
|
-
const jsonState =
|
|
282
|
+
const jsonState = this.retrieve(jsonFamily, key);
|
|
215
283
|
const json = get(jsonState);
|
|
216
284
|
return json.members;
|
|
217
285
|
}
|
|
@@ -222,12 +290,12 @@ var Join = class _Join {
|
|
|
222
290
|
const createSingleEntryStateFamily = () => createSelectorFamily(
|
|
223
291
|
{
|
|
224
292
|
key: `${options.key}/singleRelatedEntry`,
|
|
225
|
-
get: (key) => ({
|
|
226
|
-
const relatedKeysState =
|
|
293
|
+
get: (key) => ({ get }) => {
|
|
294
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key);
|
|
227
295
|
const relatedKeys = get(relatedKeysState);
|
|
228
296
|
for (const relatedKey of relatedKeys) {
|
|
229
297
|
const contentKey = relations.makeContentKey(key, relatedKey);
|
|
230
|
-
const contentState =
|
|
298
|
+
const contentState = this.retrieve(contentAtoms, contentKey);
|
|
231
299
|
const content = get(contentState);
|
|
232
300
|
return [relatedKey, content];
|
|
233
301
|
}
|
|
@@ -239,12 +307,13 @@ var Join = class _Join {
|
|
|
239
307
|
const getMultipleEntryStateFamily = () => createSelectorFamily(
|
|
240
308
|
{
|
|
241
309
|
key: `${options.key}/multipleRelatedEntries`,
|
|
242
|
-
get: (key) => ({
|
|
310
|
+
get: (key) => ({ get }) => {
|
|
243
311
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
244
|
-
const
|
|
312
|
+
const jsonState = this.retrieve(jsonFamily, key);
|
|
313
|
+
const json = get(jsonState);
|
|
245
314
|
return json.members.map((relatedKey) => {
|
|
246
315
|
const contentKey = relations.makeContentKey(key, relatedKey);
|
|
247
|
-
const contentState =
|
|
316
|
+
const contentState = this.retrieve(contentAtoms, contentKey);
|
|
248
317
|
const content = get(contentState);
|
|
249
318
|
return [relatedKey, content];
|
|
250
319
|
});
|
|
@@ -337,6 +406,26 @@ var Join = class _Join {
|
|
|
337
406
|
}
|
|
338
407
|
}
|
|
339
408
|
}
|
|
409
|
+
transact(transactors, run) {
|
|
410
|
+
const originalTransactors = this.transactors;
|
|
411
|
+
this.transactors = transactors;
|
|
412
|
+
run(this);
|
|
413
|
+
this.transactors = originalTransactors;
|
|
414
|
+
}
|
|
415
|
+
[Symbol.dispose]() {
|
|
416
|
+
this.alternates.delete(this.store.config.name);
|
|
417
|
+
}
|
|
418
|
+
in(store) {
|
|
419
|
+
const key = store.config.name;
|
|
420
|
+
const alternate = this.alternates.get(key);
|
|
421
|
+
if (alternate) {
|
|
422
|
+
return alternate;
|
|
423
|
+
}
|
|
424
|
+
const join2 = new _Join(this.options, this.defaultContent, store);
|
|
425
|
+
this.alternates.set(key, join2);
|
|
426
|
+
join2.alternates = this.alternates;
|
|
427
|
+
return join2;
|
|
428
|
+
}
|
|
340
429
|
};
|
|
341
430
|
function join(options, defaultContent, store = IMPLICIT.STORE) {
|
|
342
431
|
const joins = getJoinMap(store);
|
|
@@ -384,12 +473,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
384
473
|
relations = {
|
|
385
474
|
get [keyAB]() {
|
|
386
475
|
const familyAB = myJoin.states[keyAB];
|
|
387
|
-
const state =
|
|
476
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
388
477
|
return state;
|
|
389
478
|
},
|
|
390
479
|
get [keyBA]() {
|
|
391
480
|
const familyBA = myJoin.states[keyBA];
|
|
392
|
-
const state =
|
|
481
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
393
482
|
return state;
|
|
394
483
|
}
|
|
395
484
|
};
|
|
@@ -399,12 +488,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
399
488
|
Object.assign(relations, {
|
|
400
489
|
get [entryAB]() {
|
|
401
490
|
const familyAB = myJoin.states[entryAB];
|
|
402
|
-
const state =
|
|
491
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
403
492
|
return state;
|
|
404
493
|
},
|
|
405
494
|
get [entryBA]() {
|
|
406
495
|
const familyBA = myJoin.states[entryBA];
|
|
407
|
-
const state =
|
|
496
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
408
497
|
return state;
|
|
409
498
|
}
|
|
410
499
|
});
|
|
@@ -417,12 +506,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
417
506
|
relations = {
|
|
418
507
|
get [keyAB]() {
|
|
419
508
|
const familyAB = myJoin.states[keyAB];
|
|
420
|
-
const state =
|
|
509
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
421
510
|
return state;
|
|
422
511
|
},
|
|
423
512
|
get [keysBA]() {
|
|
424
513
|
const familyBA = myJoin.states[keysBA];
|
|
425
|
-
const state =
|
|
514
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
426
515
|
return state;
|
|
427
516
|
}
|
|
428
517
|
};
|
|
@@ -432,12 +521,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
432
521
|
Object.assign(relations, {
|
|
433
522
|
get [entryAB]() {
|
|
434
523
|
const familyAB = myJoin.states[entryAB];
|
|
435
|
-
const state =
|
|
524
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
436
525
|
return state;
|
|
437
526
|
},
|
|
438
527
|
get [entriesBA]() {
|
|
439
528
|
const familyBA = myJoin.states[entriesBA];
|
|
440
|
-
const state =
|
|
529
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
441
530
|
return state;
|
|
442
531
|
}
|
|
443
532
|
});
|
|
@@ -450,12 +539,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
450
539
|
relations = {
|
|
451
540
|
get [keysAB]() {
|
|
452
541
|
const familyAB = myJoin.states[keysAB];
|
|
453
|
-
const state =
|
|
542
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
454
543
|
return state;
|
|
455
544
|
},
|
|
456
545
|
get [keysBA]() {
|
|
457
546
|
const familyBA = myJoin.states[keysBA];
|
|
458
|
-
const state =
|
|
547
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
459
548
|
return state;
|
|
460
549
|
}
|
|
461
550
|
};
|
|
@@ -465,12 +554,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
465
554
|
Object.assign(relations, {
|
|
466
555
|
get [entriesAB]() {
|
|
467
556
|
const familyAB = myJoin.states[entriesAB];
|
|
468
|
-
const state =
|
|
557
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
469
558
|
return state;
|
|
470
559
|
},
|
|
471
560
|
get [entriesBA]() {
|
|
472
561
|
const familyBA = myJoin.states[entriesBA];
|
|
473
|
-
const state =
|
|
562
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
474
563
|
return state;
|
|
475
564
|
}
|
|
476
565
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// ../anvl/src/json/json-interface.ts
|
|
2
|
+
var stringSetJsonInterface = {
|
|
3
|
+
toJson: (stringSet) => Array.from(stringSet),
|
|
4
|
+
fromJson: (json) => new Set(json)
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// ../anvl/src/json/index.ts
|
|
8
|
+
var parseJson = (str) => JSON.parse(str);
|
|
9
|
+
var stringifyJson = (json) => JSON.stringify(json);
|
|
10
|
+
var JSON_TYPE_NAMES = [
|
|
11
|
+
`array`,
|
|
12
|
+
`boolean`,
|
|
13
|
+
`null`,
|
|
14
|
+
`number`,
|
|
15
|
+
`object`,
|
|
16
|
+
`string`
|
|
17
|
+
];
|
|
18
|
+
var JSON_DEFAULTS = {
|
|
19
|
+
array: [],
|
|
20
|
+
boolean: false,
|
|
21
|
+
null: null,
|
|
22
|
+
number: 0,
|
|
23
|
+
object: {},
|
|
24
|
+
string: ``
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { JSON_DEFAULTS, JSON_TYPE_NAMES, parseJson, stringSetJsonInterface, stringifyJson };
|
package/dist/index.cjs
CHANGED
|
@@ -29,21 +29,8 @@ function atom(options) {
|
|
|
29
29
|
function atomFamily(options) {
|
|
30
30
|
return Internal.createAtomFamily(options, Internal.IMPLICIT.STORE);
|
|
31
31
|
}
|
|
32
|
-
function disposeState(token
|
|
33
|
-
|
|
34
|
-
case `atom`:
|
|
35
|
-
case `mutable_atom`:
|
|
36
|
-
Internal__namespace.disposeAtom(token, store);
|
|
37
|
-
break;
|
|
38
|
-
case `selector`:
|
|
39
|
-
case `readonly_selector`:
|
|
40
|
-
Internal__namespace.disposeSelector(token, store);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function findState(token, key) {
|
|
45
|
-
const state = Internal.findInStore(token, key, Internal.IMPLICIT.STORE);
|
|
46
|
-
return state;
|
|
32
|
+
function disposeState(token) {
|
|
33
|
+
Internal__namespace.disposeFromStore(token, Internal__namespace.IMPLICIT.STORE);
|
|
47
34
|
}
|
|
48
35
|
function getState(token) {
|
|
49
36
|
return Internal__namespace.getFromStore(token, Internal__namespace.IMPLICIT.STORE);
|
|
@@ -97,8 +84,8 @@ function setState(token, value) {
|
|
|
97
84
|
Internal__namespace.setIntoStore(token, value, Internal__namespace.IMPLICIT.STORE);
|
|
98
85
|
}
|
|
99
86
|
var Silo = class {
|
|
100
|
-
constructor(
|
|
101
|
-
const s = new Internal.Store(
|
|
87
|
+
constructor(config, fromStore = null) {
|
|
88
|
+
const s = new Internal.Store(config, fromStore);
|
|
102
89
|
function _atom(options) {
|
|
103
90
|
return Internal.createStandaloneAtom(options, s);
|
|
104
91
|
}
|
|
@@ -171,7 +158,6 @@ exports.atom = atom;
|
|
|
171
158
|
exports.atomFamily = atomFamily;
|
|
172
159
|
exports.belongsTo = belongsTo;
|
|
173
160
|
exports.disposeState = disposeState;
|
|
174
|
-
exports.findState = findState;
|
|
175
161
|
exports.getState = getState;
|
|
176
162
|
exports.isToken = isToken;
|
|
177
163
|
exports.redo = redo;
|