atom.io 0.24.8 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.cjs +40 -62
- package/data/dist/index.d.ts +3 -3
- package/data/dist/index.js +41 -63
- package/data/src/join.ts +47 -64
- package/dist/index.cjs +26 -8
- package/dist/index.d.ts +37 -15
- package/dist/index.js +27 -9
- package/internal/dist/index.cjs +223 -111
- package/internal/dist/index.d.ts +12 -6
- package/internal/dist/index.js +224 -113
- package/internal/src/families/dispose-from-store.ts +56 -3
- package/internal/src/get-state/get-from-store.ts +58 -25
- package/internal/src/lineage.ts +7 -0
- package/internal/src/molecule/make-molecule-in-store.ts +75 -31
- package/internal/src/not-found-error.ts +29 -6
- package/internal/src/selector/create-writable-selector.ts +5 -5
- package/internal/src/selector/register-selector.ts +58 -9
- package/internal/src/set-state/set-into-store.ts +48 -1
- package/internal/src/store/store.ts +4 -4
- package/internal/src/transaction/build-transaction.ts +10 -9
- package/internal/src/transaction/create-transaction.ts +2 -2
- package/internal/src/transaction/index.ts +2 -2
- package/package.json +5 -5
- package/react/dist/index.cjs +4 -1
- package/react/dist/index.js +5 -2
- package/react/src/use-o.ts +11 -3
- package/realtime/dist/index.cjs +0 -1
- package/realtime/dist/index.js +0 -1
- package/realtime/src/realtime-continuity.ts +0 -1
- package/realtime-server/dist/index.cjs +7 -7
- package/realtime-server/dist/index.js +7 -7
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +7 -7
- package/src/dispose-state.ts +32 -3
- package/src/get-state.ts +37 -4
- package/src/molecule.ts +20 -7
- package/src/set-state.ts +19 -2
- package/src/silo.ts +11 -4
- package/src/transaction.ts +9 -17
package/data/dist/index.cjs
CHANGED
|
@@ -289,20 +289,20 @@ var Join = class _Join {
|
|
|
289
289
|
this.alternates = /* @__PURE__ */ new Map();
|
|
290
290
|
this.alternates.set(store.config.name, this);
|
|
291
291
|
this.store.miscResources.set(`join:${options.key}`, this);
|
|
292
|
-
this.
|
|
293
|
-
get: (
|
|
294
|
-
set: (
|
|
295
|
-
internal.setIntoStore(
|
|
292
|
+
this.toolkit = {
|
|
293
|
+
get: (...ps) => internal.getFromStore(...ps, store),
|
|
294
|
+
set: (...ps) => {
|
|
295
|
+
internal.setIntoStore(...ps, store);
|
|
296
296
|
},
|
|
297
297
|
find: (token, key) => internal.findInStore(token, key, store),
|
|
298
298
|
seek: (token, key) => internal.seekInStore(token, key, store),
|
|
299
299
|
json: (token) => internal.getJsonToken(token, store),
|
|
300
|
-
dispose: (
|
|
301
|
-
internal.disposeFromStore(
|
|
300
|
+
dispose: (...ps) => {
|
|
301
|
+
internal.disposeFromStore(...ps, store);
|
|
302
302
|
}
|
|
303
303
|
};
|
|
304
304
|
this.retrieve = (token, key) => {
|
|
305
|
-
const maybeToken = this.
|
|
305
|
+
const maybeToken = this.toolkit.seek(token, key);
|
|
306
306
|
if (maybeToken) {
|
|
307
307
|
return maybeToken;
|
|
308
308
|
}
|
|
@@ -312,7 +312,7 @@ var Join = class _Join {
|
|
|
312
312
|
return internal.growMoleculeInStore(molecule, family, store);
|
|
313
313
|
}
|
|
314
314
|
if (store.config.lifespan === `immortal`) {
|
|
315
|
-
throw new
|
|
315
|
+
throw new internal.NotFoundError(token, key, store);
|
|
316
316
|
}
|
|
317
317
|
return internal.initFamilyMemberInStore(token, key, store);
|
|
318
318
|
};
|
|
@@ -330,48 +330,30 @@ var Join = class _Join {
|
|
|
330
330
|
);
|
|
331
331
|
this.core = { findRelatedKeysState: relatedKeysAtoms };
|
|
332
332
|
const getRelatedKeys = ({ get }, key) => get(this.retrieve(relatedKeysAtoms, key));
|
|
333
|
-
const addRelation = (
|
|
334
|
-
const { set } =
|
|
333
|
+
const addRelation = (toolkit, a, b) => {
|
|
334
|
+
const { set } = toolkit;
|
|
335
335
|
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
336
336
|
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
337
337
|
set(aKeysState, (aKeys) => aKeys.add(b));
|
|
338
338
|
set(bKeysState, (bKeys) => bKeys.add(a));
|
|
339
339
|
};
|
|
340
|
-
const deleteRelation = (
|
|
341
|
-
const { set } =
|
|
340
|
+
const deleteRelation = (toolkit, a, b) => {
|
|
341
|
+
const { set } = toolkit;
|
|
342
342
|
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
343
343
|
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
344
|
-
let stringA;
|
|
345
|
-
let stringB;
|
|
346
344
|
set(aKeysState, (aKeys) => {
|
|
347
345
|
aKeys.delete(b);
|
|
348
|
-
if (aKeys.size === 0)
|
|
349
|
-
stringA = `"${a}"`;
|
|
350
|
-
}
|
|
346
|
+
if (aKeys.size === 0) ;
|
|
351
347
|
return aKeys;
|
|
352
348
|
});
|
|
353
349
|
set(bKeysState, (bKeys) => {
|
|
354
350
|
bKeys.delete(a);
|
|
355
|
-
if (bKeys.size === 0)
|
|
356
|
-
stringB = `"${b}"`;
|
|
357
|
-
}
|
|
351
|
+
if (bKeys.size === 0) ;
|
|
358
352
|
return bKeys;
|
|
359
353
|
});
|
|
360
|
-
if (stringA) {
|
|
361
|
-
const molecule = this.molecules.get(stringA);
|
|
362
|
-
if (molecule) {
|
|
363
|
-
this.transactors.dispose(molecule);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
if (stringB) {
|
|
367
|
-
const molecule = this.molecules.get(stringB);
|
|
368
|
-
if (molecule) {
|
|
369
|
-
this.transactors.dispose(molecule);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
354
|
};
|
|
373
|
-
const replaceRelationsSafely = (
|
|
374
|
-
const { get, set } =
|
|
355
|
+
const replaceRelationsSafely = (toolkit, a, newRelationsOfA) => {
|
|
356
|
+
const { get, set } = toolkit;
|
|
375
357
|
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
376
358
|
const currentRelationsOfA = get(relationsOfAState);
|
|
377
359
|
for (const currentRelationB of currentRelationsOfA) {
|
|
@@ -392,7 +374,7 @@ var Join = class _Join {
|
|
|
392
374
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
393
375
|
nextRelationsOfA.clear();
|
|
394
376
|
for (const newRelationB of newRelationsOfA) {
|
|
395
|
-
const relationsOfB = getRelatedKeys(
|
|
377
|
+
const relationsOfB = getRelatedKeys(toolkit, newRelationB);
|
|
396
378
|
const newRelationBIsAlreadyRelated = relationsOfB.has(a);
|
|
397
379
|
if (this.relations.cardinality === `1:n`) {
|
|
398
380
|
const previousOwnersToDispose = [];
|
|
@@ -401,7 +383,7 @@ var Join = class _Join {
|
|
|
401
383
|
continue;
|
|
402
384
|
}
|
|
403
385
|
const previousOwnerRelations = getRelatedKeys(
|
|
404
|
-
|
|
386
|
+
toolkit,
|
|
405
387
|
previousOwner
|
|
406
388
|
);
|
|
407
389
|
previousOwnerRelations.delete(newRelationB);
|
|
@@ -413,10 +395,6 @@ var Join = class _Join {
|
|
|
413
395
|
relationsOfB.clear();
|
|
414
396
|
}
|
|
415
397
|
for (const previousOwner of previousOwnersToDispose) {
|
|
416
|
-
const molecule = this.molecules.get(previousOwner);
|
|
417
|
-
if (molecule) {
|
|
418
|
-
this.transactors.dispose(molecule);
|
|
419
|
-
}
|
|
420
398
|
const sorted = [newRelationB, previousOwner].sort();
|
|
421
399
|
const compositeKey = `"${sorted[0]}:${sorted[1]}"`;
|
|
422
400
|
this.molecules.delete(compositeKey);
|
|
@@ -432,8 +410,8 @@ var Join = class _Join {
|
|
|
432
410
|
return relationsOfA;
|
|
433
411
|
});
|
|
434
412
|
};
|
|
435
|
-
const replaceRelationsUnsafely = (
|
|
436
|
-
const { set } =
|
|
413
|
+
const replaceRelationsUnsafely = (toolkit, a, newRelationsOfA) => {
|
|
414
|
+
const { set } = toolkit;
|
|
437
415
|
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
438
416
|
set(relationsOfAState, (relationsOfA) => {
|
|
439
417
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
@@ -453,25 +431,25 @@ var Join = class _Join {
|
|
|
453
431
|
}
|
|
454
432
|
return true;
|
|
455
433
|
};
|
|
456
|
-
const has = (
|
|
457
|
-
const aKeys = getRelatedKeys(
|
|
434
|
+
const has = (toolkit, a, b) => {
|
|
435
|
+
const aKeys = getRelatedKeys(toolkit, a);
|
|
458
436
|
return b ? aKeys.has(b) : aKeys.size > 0;
|
|
459
437
|
};
|
|
460
438
|
const baseExternalStoreConfiguration = {
|
|
461
|
-
getRelatedKeys: (key) => getRelatedKeys(this.
|
|
439
|
+
getRelatedKeys: (key) => getRelatedKeys(this.toolkit, key),
|
|
462
440
|
addRelation: (a, b) => {
|
|
463
|
-
addRelation(this.
|
|
441
|
+
addRelation(this.toolkit, a, b);
|
|
464
442
|
},
|
|
465
443
|
deleteRelation: (a, b) => {
|
|
466
|
-
deleteRelation(this.
|
|
444
|
+
deleteRelation(this.toolkit, a, b);
|
|
467
445
|
},
|
|
468
446
|
replaceRelationsSafely: (a, bs) => {
|
|
469
|
-
replaceRelationsSafely(this.
|
|
447
|
+
replaceRelationsSafely(this.toolkit, a, bs);
|
|
470
448
|
},
|
|
471
449
|
replaceRelationsUnsafely: (a, bs) => {
|
|
472
|
-
replaceRelationsUnsafely(this.
|
|
450
|
+
replaceRelationsUnsafely(this.toolkit, a, bs);
|
|
473
451
|
},
|
|
474
|
-
has: (a, b) => has(this.
|
|
452
|
+
has: (a, b) => has(this.toolkit, a, b)
|
|
475
453
|
};
|
|
476
454
|
let externalStore;
|
|
477
455
|
let contentAtoms;
|
|
@@ -495,9 +473,9 @@ var Join = class _Join {
|
|
|
495
473
|
{
|
|
496
474
|
key: `${options.key}/content-molecules`,
|
|
497
475
|
new: class ContentMolecule {
|
|
498
|
-
constructor(
|
|
476
|
+
constructor(toolkit, key) {
|
|
499
477
|
this.key = key;
|
|
500
|
-
|
|
478
|
+
toolkit.bond(joinToken, { as: null });
|
|
501
479
|
}
|
|
502
480
|
}
|
|
503
481
|
},
|
|
@@ -510,20 +488,20 @@ var Join = class _Join {
|
|
|
510
488
|
const deleteContent = (_, compositeKey) => {
|
|
511
489
|
const contentMolecule = store.molecules.get(`"${compositeKey}"`);
|
|
512
490
|
if (contentMolecule) {
|
|
513
|
-
this.
|
|
491
|
+
this.toolkit.dispose(contentMolecule);
|
|
514
492
|
this.molecules.delete(`"${compositeKey}"`);
|
|
515
493
|
}
|
|
516
494
|
};
|
|
517
495
|
const externalStoreWithContentConfiguration = {
|
|
518
496
|
getContent: (contentKey) => {
|
|
519
|
-
const content = getContent(this.
|
|
497
|
+
const content = getContent(this.toolkit, contentKey);
|
|
520
498
|
return content;
|
|
521
499
|
},
|
|
522
500
|
setContent: (contentKey, content) => {
|
|
523
|
-
setContent(this.
|
|
501
|
+
setContent(this.toolkit, contentKey, content);
|
|
524
502
|
},
|
|
525
503
|
deleteContent: (contentKey) => {
|
|
526
|
-
deleteContent(this.
|
|
504
|
+
deleteContent(this.toolkit, contentKey);
|
|
527
505
|
}
|
|
528
506
|
};
|
|
529
507
|
externalStore = Object.assign(
|
|
@@ -704,11 +682,11 @@ var Join = class _Join {
|
|
|
704
682
|
}
|
|
705
683
|
}
|
|
706
684
|
}
|
|
707
|
-
transact(
|
|
708
|
-
const
|
|
709
|
-
this.
|
|
685
|
+
transact(toolkit, run) {
|
|
686
|
+
const originalToolkit = this.toolkit;
|
|
687
|
+
this.toolkit = toolkit;
|
|
710
688
|
run(this);
|
|
711
|
-
this.
|
|
689
|
+
this.toolkit = originalToolkit;
|
|
712
690
|
}
|
|
713
691
|
[Symbol.dispose]() {
|
|
714
692
|
this.alternates.delete(this.store.config.name);
|
|
@@ -873,8 +851,8 @@ function editRelationsInStore(token, change, store) {
|
|
|
873
851
|
const myJoin = getJoin(token, store);
|
|
874
852
|
const target = internal.newest(store);
|
|
875
853
|
if (internal.isChildStore(target)) {
|
|
876
|
-
const {
|
|
877
|
-
myJoin.transact(
|
|
854
|
+
const { toolkit } = target.transactionMeta;
|
|
855
|
+
myJoin.transact(toolkit, ({ relations }) => {
|
|
878
856
|
change(relations);
|
|
879
857
|
});
|
|
880
858
|
} else {
|
package/data/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as AtomIO from 'atom.io';
|
|
2
|
-
import { ReadonlySelectorFamily, MutableAtomFamily,
|
|
2
|
+
import { ReadonlySelectorFamily, MutableAtomFamily, SetterToolkit, disposeState, ReadonlySelectorToken, MutableAtomFamilyToken } from 'atom.io';
|
|
3
3
|
import { Store, Molecule } from 'atom.io/internal';
|
|
4
4
|
import { Json, Stringified } from 'atom.io/json';
|
|
5
5
|
import { findState } from 'atom.io/ephemeral';
|
|
@@ -119,7 +119,7 @@ type JoinStateFamilies<ASide extends string, BSide extends string, Cardinality e
|
|
|
119
119
|
declare class Join<const ASide extends string, const BSide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object | null = null> {
|
|
120
120
|
private options;
|
|
121
121
|
private defaultContent;
|
|
122
|
-
private
|
|
122
|
+
private toolkit;
|
|
123
123
|
retrieve: typeof findState;
|
|
124
124
|
molecules: Map<string, Molecule<any>>;
|
|
125
125
|
relations: Junction<ASide, BSide, Content>;
|
|
@@ -127,7 +127,7 @@ declare class Join<const ASide extends string, const BSide extends string, const
|
|
|
127
127
|
core: {
|
|
128
128
|
findRelatedKeysState: MutableAtomFamily<SetRTX<string>, SetRTXJson<string>, string>;
|
|
129
129
|
};
|
|
130
|
-
transact(
|
|
130
|
+
transact(toolkit: SetterToolkit & {
|
|
131
131
|
dispose: typeof disposeState;
|
|
132
132
|
}, run: (join: Join<ASide, BSide, Cardinality, Content>) => void): void;
|
|
133
133
|
store: Store;
|
package/data/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Junction } from '../../dist/chunk-HYXKCFVY.js';
|
|
2
2
|
import '../../dist/chunk-S4N6XNPH.js';
|
|
3
|
-
import { createStandaloneSelector, findInStore, IMPLICIT, getFromStore, setIntoStore, seekInStore, getJsonToken, disposeFromStore, withdraw, growMoleculeInStore, initFamilyMemberInStore, createMutableAtomFamily, createRegularAtomFamily, createMoleculeFamily, newest, makeMoleculeInStore, isChildStore, createRegularAtom, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
3
|
+
import { createStandaloneSelector, findInStore, IMPLICIT, getFromStore, setIntoStore, seekInStore, getJsonToken, disposeFromStore, withdraw, growMoleculeInStore, NotFoundError, initFamilyMemberInStore, createMutableAtomFamily, createRegularAtomFamily, createMoleculeFamily, newest, makeMoleculeInStore, isChildStore, createRegularAtom, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
4
4
|
import { stringifyJson } from 'atom.io/json';
|
|
5
5
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
6
6
|
|
|
@@ -31,20 +31,20 @@ var Join = class _Join {
|
|
|
31
31
|
this.alternates = /* @__PURE__ */ new Map();
|
|
32
32
|
this.alternates.set(store.config.name, this);
|
|
33
33
|
this.store.miscResources.set(`join:${options.key}`, this);
|
|
34
|
-
this.
|
|
35
|
-
get: (
|
|
36
|
-
set: (
|
|
37
|
-
setIntoStore(
|
|
34
|
+
this.toolkit = {
|
|
35
|
+
get: (...ps) => getFromStore(...ps, store),
|
|
36
|
+
set: (...ps) => {
|
|
37
|
+
setIntoStore(...ps, store);
|
|
38
38
|
},
|
|
39
39
|
find: (token, key) => findInStore(token, key, store),
|
|
40
40
|
seek: (token, key) => seekInStore(token, key, store),
|
|
41
41
|
json: (token) => getJsonToken(token, store),
|
|
42
|
-
dispose: (
|
|
43
|
-
disposeFromStore(
|
|
42
|
+
dispose: (...ps) => {
|
|
43
|
+
disposeFromStore(...ps, store);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
this.retrieve = (token, key) => {
|
|
47
|
-
const maybeToken = this.
|
|
47
|
+
const maybeToken = this.toolkit.seek(token, key);
|
|
48
48
|
if (maybeToken) {
|
|
49
49
|
return maybeToken;
|
|
50
50
|
}
|
|
@@ -54,7 +54,7 @@ var Join = class _Join {
|
|
|
54
54
|
return growMoleculeInStore(molecule, family, store);
|
|
55
55
|
}
|
|
56
56
|
if (store.config.lifespan === `immortal`) {
|
|
57
|
-
throw new
|
|
57
|
+
throw new NotFoundError(token, key, store);
|
|
58
58
|
}
|
|
59
59
|
return initFamilyMemberInStore(token, key, store);
|
|
60
60
|
};
|
|
@@ -72,48 +72,30 @@ var Join = class _Join {
|
|
|
72
72
|
);
|
|
73
73
|
this.core = { findRelatedKeysState: relatedKeysAtoms };
|
|
74
74
|
const getRelatedKeys = ({ get }, key) => get(this.retrieve(relatedKeysAtoms, key));
|
|
75
|
-
const addRelation = (
|
|
76
|
-
const { set } =
|
|
75
|
+
const addRelation = (toolkit, a, b) => {
|
|
76
|
+
const { set } = toolkit;
|
|
77
77
|
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
78
78
|
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
79
79
|
set(aKeysState, (aKeys) => aKeys.add(b));
|
|
80
80
|
set(bKeysState, (bKeys) => bKeys.add(a));
|
|
81
81
|
};
|
|
82
|
-
const deleteRelation = (
|
|
83
|
-
const { set } =
|
|
82
|
+
const deleteRelation = (toolkit, a, b) => {
|
|
83
|
+
const { set } = toolkit;
|
|
84
84
|
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
85
85
|
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
86
|
-
let stringA;
|
|
87
|
-
let stringB;
|
|
88
86
|
set(aKeysState, (aKeys) => {
|
|
89
87
|
aKeys.delete(b);
|
|
90
|
-
if (aKeys.size === 0)
|
|
91
|
-
stringA = `"${a}"`;
|
|
92
|
-
}
|
|
88
|
+
if (aKeys.size === 0) ;
|
|
93
89
|
return aKeys;
|
|
94
90
|
});
|
|
95
91
|
set(bKeysState, (bKeys) => {
|
|
96
92
|
bKeys.delete(a);
|
|
97
|
-
if (bKeys.size === 0)
|
|
98
|
-
stringB = `"${b}"`;
|
|
99
|
-
}
|
|
93
|
+
if (bKeys.size === 0) ;
|
|
100
94
|
return bKeys;
|
|
101
95
|
});
|
|
102
|
-
if (stringA) {
|
|
103
|
-
const molecule = this.molecules.get(stringA);
|
|
104
|
-
if (molecule) {
|
|
105
|
-
this.transactors.dispose(molecule);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (stringB) {
|
|
109
|
-
const molecule = this.molecules.get(stringB);
|
|
110
|
-
if (molecule) {
|
|
111
|
-
this.transactors.dispose(molecule);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
96
|
};
|
|
115
|
-
const replaceRelationsSafely = (
|
|
116
|
-
const { get, set } =
|
|
97
|
+
const replaceRelationsSafely = (toolkit, a, newRelationsOfA) => {
|
|
98
|
+
const { get, set } = toolkit;
|
|
117
99
|
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
118
100
|
const currentRelationsOfA = get(relationsOfAState);
|
|
119
101
|
for (const currentRelationB of currentRelationsOfA) {
|
|
@@ -134,7 +116,7 @@ var Join = class _Join {
|
|
|
134
116
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
135
117
|
nextRelationsOfA.clear();
|
|
136
118
|
for (const newRelationB of newRelationsOfA) {
|
|
137
|
-
const relationsOfB = getRelatedKeys(
|
|
119
|
+
const relationsOfB = getRelatedKeys(toolkit, newRelationB);
|
|
138
120
|
const newRelationBIsAlreadyRelated = relationsOfB.has(a);
|
|
139
121
|
if (this.relations.cardinality === `1:n`) {
|
|
140
122
|
const previousOwnersToDispose = [];
|
|
@@ -143,7 +125,7 @@ var Join = class _Join {
|
|
|
143
125
|
continue;
|
|
144
126
|
}
|
|
145
127
|
const previousOwnerRelations = getRelatedKeys(
|
|
146
|
-
|
|
128
|
+
toolkit,
|
|
147
129
|
previousOwner
|
|
148
130
|
);
|
|
149
131
|
previousOwnerRelations.delete(newRelationB);
|
|
@@ -155,10 +137,6 @@ var Join = class _Join {
|
|
|
155
137
|
relationsOfB.clear();
|
|
156
138
|
}
|
|
157
139
|
for (const previousOwner of previousOwnersToDispose) {
|
|
158
|
-
const molecule = this.molecules.get(previousOwner);
|
|
159
|
-
if (molecule) {
|
|
160
|
-
this.transactors.dispose(molecule);
|
|
161
|
-
}
|
|
162
140
|
const sorted = [newRelationB, previousOwner].sort();
|
|
163
141
|
const compositeKey = `"${sorted[0]}:${sorted[1]}"`;
|
|
164
142
|
this.molecules.delete(compositeKey);
|
|
@@ -174,8 +152,8 @@ var Join = class _Join {
|
|
|
174
152
|
return relationsOfA;
|
|
175
153
|
});
|
|
176
154
|
};
|
|
177
|
-
const replaceRelationsUnsafely = (
|
|
178
|
-
const { set } =
|
|
155
|
+
const replaceRelationsUnsafely = (toolkit, a, newRelationsOfA) => {
|
|
156
|
+
const { set } = toolkit;
|
|
179
157
|
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
180
158
|
set(relationsOfAState, (relationsOfA) => {
|
|
181
159
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
@@ -195,25 +173,25 @@ var Join = class _Join {
|
|
|
195
173
|
}
|
|
196
174
|
return true;
|
|
197
175
|
};
|
|
198
|
-
const has = (
|
|
199
|
-
const aKeys = getRelatedKeys(
|
|
176
|
+
const has = (toolkit, a, b) => {
|
|
177
|
+
const aKeys = getRelatedKeys(toolkit, a);
|
|
200
178
|
return b ? aKeys.has(b) : aKeys.size > 0;
|
|
201
179
|
};
|
|
202
180
|
const baseExternalStoreConfiguration = {
|
|
203
|
-
getRelatedKeys: (key) => getRelatedKeys(this.
|
|
181
|
+
getRelatedKeys: (key) => getRelatedKeys(this.toolkit, key),
|
|
204
182
|
addRelation: (a, b) => {
|
|
205
|
-
addRelation(this.
|
|
183
|
+
addRelation(this.toolkit, a, b);
|
|
206
184
|
},
|
|
207
185
|
deleteRelation: (a, b) => {
|
|
208
|
-
deleteRelation(this.
|
|
186
|
+
deleteRelation(this.toolkit, a, b);
|
|
209
187
|
},
|
|
210
188
|
replaceRelationsSafely: (a, bs) => {
|
|
211
|
-
replaceRelationsSafely(this.
|
|
189
|
+
replaceRelationsSafely(this.toolkit, a, bs);
|
|
212
190
|
},
|
|
213
191
|
replaceRelationsUnsafely: (a, bs) => {
|
|
214
|
-
replaceRelationsUnsafely(this.
|
|
192
|
+
replaceRelationsUnsafely(this.toolkit, a, bs);
|
|
215
193
|
},
|
|
216
|
-
has: (a, b) => has(this.
|
|
194
|
+
has: (a, b) => has(this.toolkit, a, b)
|
|
217
195
|
};
|
|
218
196
|
let externalStore;
|
|
219
197
|
let contentAtoms;
|
|
@@ -237,9 +215,9 @@ var Join = class _Join {
|
|
|
237
215
|
{
|
|
238
216
|
key: `${options.key}/content-molecules`,
|
|
239
217
|
new: class ContentMolecule {
|
|
240
|
-
constructor(
|
|
218
|
+
constructor(toolkit, key) {
|
|
241
219
|
this.key = key;
|
|
242
|
-
|
|
220
|
+
toolkit.bond(joinToken, { as: null });
|
|
243
221
|
}
|
|
244
222
|
}
|
|
245
223
|
},
|
|
@@ -252,20 +230,20 @@ var Join = class _Join {
|
|
|
252
230
|
const deleteContent = (_, compositeKey) => {
|
|
253
231
|
const contentMolecule = store.molecules.get(`"${compositeKey}"`);
|
|
254
232
|
if (contentMolecule) {
|
|
255
|
-
this.
|
|
233
|
+
this.toolkit.dispose(contentMolecule);
|
|
256
234
|
this.molecules.delete(`"${compositeKey}"`);
|
|
257
235
|
}
|
|
258
236
|
};
|
|
259
237
|
const externalStoreWithContentConfiguration = {
|
|
260
238
|
getContent: (contentKey) => {
|
|
261
|
-
const content = getContent(this.
|
|
239
|
+
const content = getContent(this.toolkit, contentKey);
|
|
262
240
|
return content;
|
|
263
241
|
},
|
|
264
242
|
setContent: (contentKey, content) => {
|
|
265
|
-
setContent(this.
|
|
243
|
+
setContent(this.toolkit, contentKey, content);
|
|
266
244
|
},
|
|
267
245
|
deleteContent: (contentKey) => {
|
|
268
|
-
deleteContent(this.
|
|
246
|
+
deleteContent(this.toolkit, contentKey);
|
|
269
247
|
}
|
|
270
248
|
};
|
|
271
249
|
externalStore = Object.assign(
|
|
@@ -446,11 +424,11 @@ var Join = class _Join {
|
|
|
446
424
|
}
|
|
447
425
|
}
|
|
448
426
|
}
|
|
449
|
-
transact(
|
|
450
|
-
const
|
|
451
|
-
this.
|
|
427
|
+
transact(toolkit, run) {
|
|
428
|
+
const originalToolkit = this.toolkit;
|
|
429
|
+
this.toolkit = toolkit;
|
|
452
430
|
run(this);
|
|
453
|
-
this.
|
|
431
|
+
this.toolkit = originalToolkit;
|
|
454
432
|
}
|
|
455
433
|
[Symbol.dispose]() {
|
|
456
434
|
this.alternates.delete(this.store.config.name);
|
|
@@ -615,8 +593,8 @@ function editRelationsInStore(token, change, store) {
|
|
|
615
593
|
const myJoin = getJoin(token, store);
|
|
616
594
|
const target = newest(store);
|
|
617
595
|
if (isChildStore(target)) {
|
|
618
|
-
const {
|
|
619
|
-
myJoin.transact(
|
|
596
|
+
const { toolkit } = target.transactionMeta;
|
|
597
|
+
myJoin.transact(toolkit, ({ relations }) => {
|
|
620
598
|
change(relations);
|
|
621
599
|
});
|
|
622
600
|
} else {
|