atom.io 0.21.0 → 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 +139 -66
- package/data/dist/index.d.ts +6 -0
- package/data/dist/index.js +3 -3
- package/data/src/join.ts +135 -56
- package/data/src/struct-family.ts +2 -2
- package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
- package/dist/{chunk-KGZGBCYS.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 +211 -194
- package/internal/dist/index.d.ts +30 -14
- package/internal/dist/index.js +210 -194
- 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/future.ts +6 -20
- package/internal/src/get-state/get-from-store.ts +2 -3
- 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/mutable/tracker.ts +2 -24
- package/internal/src/not-found-error.ts +11 -3
- package/internal/src/operation.ts +0 -1
- 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/recall-state.ts +3 -3
- package/internal/src/subscribe/subscribe-to-state.ts +18 -5
- package/internal/src/transaction/build-transaction.ts +7 -2
- package/introspection/dist/index.cjs +39 -65
- package/introspection/dist/index.js +39 -65
- package/introspection/src/attach-atom-index.ts +38 -48
- package/introspection/src/attach-introspection-states.ts +0 -1
- package/introspection/src/attach-selector-index.ts +45 -50
- package/introspection/src/attach-timeline-family.ts +2 -17
- 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 +31 -11
- 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/src/validators.ts +0 -6
- 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
package/data/dist/index.cjs
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var internal = require('atom.io/internal');
|
|
4
4
|
var atom_io = require('atom.io');
|
|
5
|
+
var json = require('atom.io/json');
|
|
5
6
|
var setRtx = require('atom.io/transceivers/set-rtx');
|
|
6
7
|
|
|
7
8
|
// data/src/dict.ts
|
|
8
|
-
function dict(
|
|
9
|
+
function dict(findState, index, store = internal.IMPLICIT.STORE) {
|
|
9
10
|
return internal.createStandaloneSelector(
|
|
10
11
|
{
|
|
11
|
-
key: `${
|
|
12
|
+
key: `${findState.key}Dict`,
|
|
12
13
|
get: ({ get }) => {
|
|
13
14
|
const keys = get(index);
|
|
14
15
|
return keys.reduce((acc, key) => {
|
|
15
|
-
acc[key] = get(internal.findInStore(
|
|
16
|
+
acc[key] = get(internal.findInStore(findState, key, store));
|
|
16
17
|
return acc;
|
|
17
18
|
}, {});
|
|
18
19
|
}
|
|
@@ -284,34 +285,35 @@ function capitalize(string) {
|
|
|
284
285
|
return string[0].toUpperCase() + string.slice(1);
|
|
285
286
|
}
|
|
286
287
|
var Join = class _Join {
|
|
287
|
-
transact(transactors, run) {
|
|
288
|
-
const originalTransactors = this.transactors;
|
|
289
|
-
this.transactors = transactors;
|
|
290
|
-
run(this);
|
|
291
|
-
this.transactors = originalTransactors;
|
|
292
|
-
}
|
|
293
|
-
in(store) {
|
|
294
|
-
const key = store.config.name;
|
|
295
|
-
const alternate = this.alternates.get(key);
|
|
296
|
-
if (alternate) {
|
|
297
|
-
return alternate;
|
|
298
|
-
}
|
|
299
|
-
const join2 = new _Join(this.options, this.defaultContent, store);
|
|
300
|
-
this.alternates.set(key, join2);
|
|
301
|
-
join2.alternates = this.alternates;
|
|
302
|
-
return join2;
|
|
303
|
-
}
|
|
304
288
|
constructor(options, defaultContent, store = internal.IMPLICIT.STORE) {
|
|
289
|
+
this.molecules = /* @__PURE__ */ new Map();
|
|
290
|
+
this.store = store;
|
|
305
291
|
this.options = options;
|
|
306
292
|
this.defaultContent = defaultContent;
|
|
307
293
|
this.alternates = /* @__PURE__ */ new Map();
|
|
308
294
|
this.alternates.set(store.config.name, this);
|
|
295
|
+
this.store.miscResources.set(`join:${options.key}`, this);
|
|
309
296
|
this.transactors = {
|
|
310
297
|
get: (token) => internal.getFromStore(token, store),
|
|
311
298
|
set: (token, value) => {
|
|
312
299
|
internal.setIntoStore(token, value, store);
|
|
313
300
|
},
|
|
314
|
-
find: (token, key) => internal.findInStore(token, key, store)
|
|
301
|
+
find: (token, key) => internal.findInStore(token, key, store),
|
|
302
|
+
seek: (token, key) => internal.seekInStore(token, key, store)
|
|
303
|
+
};
|
|
304
|
+
this.retrieve = (token, key) => {
|
|
305
|
+
const maybeToken = this.transactors.seek(token, key);
|
|
306
|
+
if (maybeToken) {
|
|
307
|
+
return maybeToken;
|
|
308
|
+
}
|
|
309
|
+
const molecule = this.molecules.get(json.stringifyJson(key));
|
|
310
|
+
if (!molecule) {
|
|
311
|
+
if (store.config.lifespan === `immortal`) {
|
|
312
|
+
throw new Error(`No molecule found for key "${json.stringifyJson(key)}"`);
|
|
313
|
+
}
|
|
314
|
+
return internal.initFamilyMember(token, key, store);
|
|
315
|
+
}
|
|
316
|
+
return molecule.bond(token);
|
|
315
317
|
};
|
|
316
318
|
const aSide = options.between[0];
|
|
317
319
|
const bSide = options.between[1];
|
|
@@ -326,31 +328,57 @@ var Join = class _Join {
|
|
|
326
328
|
store
|
|
327
329
|
);
|
|
328
330
|
this.core = { findRelatedKeysState: relatedKeysAtoms };
|
|
329
|
-
const getRelatedKeys = ({
|
|
331
|
+
const getRelatedKeys = ({ get }, key) => get(this.retrieve(relatedKeysAtoms, key));
|
|
330
332
|
const addRelation = (transactors, a, b) => {
|
|
331
|
-
const { set
|
|
332
|
-
const aKeysState =
|
|
333
|
-
const bKeysState =
|
|
333
|
+
const { set } = transactors;
|
|
334
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
335
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
334
336
|
set(aKeysState, (aKeys) => aKeys.add(b));
|
|
335
337
|
set(bKeysState, (bKeys) => bKeys.add(a));
|
|
336
338
|
};
|
|
337
339
|
const deleteRelation = (transactors, a, b) => {
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
var _a, _b;
|
|
341
|
+
const { set } = transactors;
|
|
342
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a);
|
|
343
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b);
|
|
344
|
+
let stringA;
|
|
345
|
+
let stringB;
|
|
346
|
+
set(aKeysState, (aKeys) => {
|
|
347
|
+
aKeys.delete(b);
|
|
348
|
+
if (aKeys.size === 0) {
|
|
349
|
+
stringA = `"${a}"`;
|
|
350
|
+
}
|
|
351
|
+
return aKeys;
|
|
352
|
+
});
|
|
353
|
+
set(bKeysState, (bKeys) => {
|
|
354
|
+
bKeys.delete(a);
|
|
355
|
+
if (bKeys.size === 0) {
|
|
356
|
+
stringB = `"${b}"`;
|
|
357
|
+
}
|
|
358
|
+
return bKeys;
|
|
359
|
+
});
|
|
360
|
+
if (stringA && this.molecules.has(stringA)) {
|
|
361
|
+
(_a = this.molecules.get(stringA)) == null ? void 0 : _a.clear();
|
|
362
|
+
this.molecules.delete(stringA);
|
|
363
|
+
}
|
|
364
|
+
if (stringB && this.molecules.has(stringB)) {
|
|
365
|
+
(_b = this.molecules.get(stringB)) == null ? void 0 : _b.clear();
|
|
366
|
+
this.molecules.delete(stringB);
|
|
367
|
+
}
|
|
343
368
|
};
|
|
344
369
|
const replaceRelationsSafely = (transactors, a, newRelationsOfA) => {
|
|
345
|
-
const {
|
|
346
|
-
const relationsOfAState =
|
|
370
|
+
const { get, set } = transactors;
|
|
371
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
347
372
|
const currentRelationsOfA = get(relationsOfAState);
|
|
348
373
|
for (const currentRelationB of currentRelationsOfA) {
|
|
349
374
|
const remainsRelated = newRelationsOfA.includes(currentRelationB);
|
|
350
375
|
if (remainsRelated) {
|
|
351
376
|
continue;
|
|
352
377
|
}
|
|
353
|
-
const relationsOfBState =
|
|
378
|
+
const relationsOfBState = this.retrieve(
|
|
379
|
+
relatedKeysAtoms,
|
|
380
|
+
currentRelationB
|
|
381
|
+
);
|
|
354
382
|
set(relationsOfBState, (relationsOfB) => {
|
|
355
383
|
relationsOfB.delete(a);
|
|
356
384
|
return relationsOfB;
|
|
@@ -363,6 +391,7 @@ var Join = class _Join {
|
|
|
363
391
|
const relationsOfB = getRelatedKeys(transactors, newRelationB);
|
|
364
392
|
const newRelationBIsAlreadyRelated = relationsOfB.has(a);
|
|
365
393
|
if (this.relations.cardinality === `1:n`) {
|
|
394
|
+
const previousOwnersToDispose = [];
|
|
366
395
|
for (const previousOwner of relationsOfB) {
|
|
367
396
|
if (previousOwner === a) {
|
|
368
397
|
continue;
|
|
@@ -372,10 +401,21 @@ var Join = class _Join {
|
|
|
372
401
|
previousOwner
|
|
373
402
|
);
|
|
374
403
|
previousOwnerRelations.delete(newRelationB);
|
|
404
|
+
if (previousOwnerRelations.size === 0) {
|
|
405
|
+
previousOwnersToDispose.push(previousOwner);
|
|
406
|
+
}
|
|
375
407
|
}
|
|
376
408
|
if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {
|
|
377
409
|
relationsOfB.clear();
|
|
378
410
|
}
|
|
411
|
+
for (const previousOwner of previousOwnersToDispose) {
|
|
412
|
+
const molecule = this.molecules.get(previousOwner);
|
|
413
|
+
molecule == null ? void 0 : molecule.clear();
|
|
414
|
+
this.molecules.delete(previousOwner);
|
|
415
|
+
const sorted = [newRelationB, previousOwner].sort();
|
|
416
|
+
const compositeKey = `"${sorted[0]}:${sorted[1]}"`;
|
|
417
|
+
this.molecules.delete(compositeKey);
|
|
418
|
+
}
|
|
379
419
|
}
|
|
380
420
|
if (!newRelationBIsAlreadyRelated) {
|
|
381
421
|
relationsOfB.add(a);
|
|
@@ -388,8 +428,8 @@ var Join = class _Join {
|
|
|
388
428
|
});
|
|
389
429
|
};
|
|
390
430
|
const replaceRelationsUnsafely = (transactors, a, newRelationsOfA) => {
|
|
391
|
-
const {
|
|
392
|
-
const relationsOfAState =
|
|
431
|
+
const { set } = transactors;
|
|
432
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
|
|
393
433
|
set(relationsOfAState, (relationsOfA) => {
|
|
394
434
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
395
435
|
for (const newRelationB of newRelationsOfA) {
|
|
@@ -400,7 +440,7 @@ var Join = class _Join {
|
|
|
400
440
|
return relationsOfA;
|
|
401
441
|
});
|
|
402
442
|
for (const newRelationB of newRelationsOfA) {
|
|
403
|
-
const newRelationsBState =
|
|
443
|
+
const newRelationsBState = this.retrieve(relatedKeysAtoms, newRelationB);
|
|
404
444
|
set(newRelationsBState, (newRelationsB) => {
|
|
405
445
|
newRelationsB.add(a);
|
|
406
446
|
return newRelationsB;
|
|
@@ -438,12 +478,13 @@ var Join = class _Join {
|
|
|
438
478
|
},
|
|
439
479
|
store
|
|
440
480
|
);
|
|
441
|
-
const getContent = ({
|
|
442
|
-
const setContent = ({
|
|
443
|
-
set(
|
|
481
|
+
const getContent = ({ get }, key) => get(this.retrieve(contentAtoms, key));
|
|
482
|
+
const setContent = ({ set }, key, content) => {
|
|
483
|
+
set(this.retrieve(contentAtoms, key), content);
|
|
444
484
|
};
|
|
445
|
-
const deleteContent = (
|
|
446
|
-
atom_io.disposeState(
|
|
485
|
+
const deleteContent = (_, compositeKey) => {
|
|
486
|
+
atom_io.disposeState(this.retrieve(contentAtoms, compositeKey));
|
|
487
|
+
this.molecules.delete(`"${compositeKey}"`);
|
|
447
488
|
};
|
|
448
489
|
const externalStoreWithContentConfiguration = {
|
|
449
490
|
getContent: (contentKey) => {
|
|
@@ -466,13 +507,24 @@ var Join = class _Join {
|
|
|
466
507
|
}
|
|
467
508
|
const relations = new Junction(options, {
|
|
468
509
|
externalStore,
|
|
469
|
-
makeContentKey: (...args) =>
|
|
510
|
+
makeContentKey: (...args) => {
|
|
511
|
+
const sorted = args.sort();
|
|
512
|
+
const compositeKey = `${sorted[0]}:${sorted[1]}`;
|
|
513
|
+
const [m0, m1] = sorted.map(
|
|
514
|
+
(key) => this.molecules.get(json.stringifyJson(key))
|
|
515
|
+
);
|
|
516
|
+
if (store.config.lifespan === `immortal` && m0 && m1) {
|
|
517
|
+
const composite = m0.with(m1)(compositeKey);
|
|
518
|
+
this.molecules.set(`"${compositeKey}"`, composite);
|
|
519
|
+
}
|
|
520
|
+
return compositeKey;
|
|
521
|
+
}
|
|
470
522
|
});
|
|
471
523
|
const createSingleKeyStateFamily = () => internal.createSelectorFamily(
|
|
472
524
|
{
|
|
473
525
|
key: `${options.key}/singleRelatedKey`,
|
|
474
|
-
get: (key) => ({
|
|
475
|
-
const relatedKeysState =
|
|
526
|
+
get: (key) => ({ get }) => {
|
|
527
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key);
|
|
476
528
|
const relatedKeys = get(relatedKeysState);
|
|
477
529
|
for (const relatedKey of relatedKeys) {
|
|
478
530
|
return relatedKey;
|
|
@@ -486,9 +538,9 @@ var Join = class _Join {
|
|
|
486
538
|
return internal.createSelectorFamily(
|
|
487
539
|
{
|
|
488
540
|
key: `${options.key}/multipleRelatedKeys`,
|
|
489
|
-
get: (key) => ({
|
|
541
|
+
get: (key) => ({ get }) => {
|
|
490
542
|
const jsonFamily = internal.getJsonFamily(relatedKeysAtoms, store);
|
|
491
|
-
const jsonState =
|
|
543
|
+
const jsonState = this.retrieve(jsonFamily, key);
|
|
492
544
|
const json = get(jsonState);
|
|
493
545
|
return json.members;
|
|
494
546
|
}
|
|
@@ -499,12 +551,12 @@ var Join = class _Join {
|
|
|
499
551
|
const createSingleEntryStateFamily = () => internal.createSelectorFamily(
|
|
500
552
|
{
|
|
501
553
|
key: `${options.key}/singleRelatedEntry`,
|
|
502
|
-
get: (key) => ({
|
|
503
|
-
const relatedKeysState =
|
|
554
|
+
get: (key) => ({ get }) => {
|
|
555
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key);
|
|
504
556
|
const relatedKeys = get(relatedKeysState);
|
|
505
557
|
for (const relatedKey of relatedKeys) {
|
|
506
558
|
const contentKey = relations.makeContentKey(key, relatedKey);
|
|
507
|
-
const contentState =
|
|
559
|
+
const contentState = this.retrieve(contentAtoms, contentKey);
|
|
508
560
|
const content = get(contentState);
|
|
509
561
|
return [relatedKey, content];
|
|
510
562
|
}
|
|
@@ -516,12 +568,13 @@ var Join = class _Join {
|
|
|
516
568
|
const getMultipleEntryStateFamily = () => internal.createSelectorFamily(
|
|
517
569
|
{
|
|
518
570
|
key: `${options.key}/multipleRelatedEntries`,
|
|
519
|
-
get: (key) => ({
|
|
571
|
+
get: (key) => ({ get }) => {
|
|
520
572
|
const jsonFamily = internal.getJsonFamily(relatedKeysAtoms, store);
|
|
521
|
-
const
|
|
573
|
+
const jsonState = this.retrieve(jsonFamily, key);
|
|
574
|
+
const json = get(jsonState);
|
|
522
575
|
return json.members.map((relatedKey) => {
|
|
523
576
|
const contentKey = relations.makeContentKey(key, relatedKey);
|
|
524
|
-
const contentState =
|
|
577
|
+
const contentState = this.retrieve(contentAtoms, contentKey);
|
|
525
578
|
const content = get(contentState);
|
|
526
579
|
return [relatedKey, content];
|
|
527
580
|
});
|
|
@@ -614,6 +667,26 @@ var Join = class _Join {
|
|
|
614
667
|
}
|
|
615
668
|
}
|
|
616
669
|
}
|
|
670
|
+
transact(transactors, run) {
|
|
671
|
+
const originalTransactors = this.transactors;
|
|
672
|
+
this.transactors = transactors;
|
|
673
|
+
run(this);
|
|
674
|
+
this.transactors = originalTransactors;
|
|
675
|
+
}
|
|
676
|
+
[Symbol.dispose]() {
|
|
677
|
+
this.alternates.delete(this.store.config.name);
|
|
678
|
+
}
|
|
679
|
+
in(store) {
|
|
680
|
+
const key = store.config.name;
|
|
681
|
+
const alternate = this.alternates.get(key);
|
|
682
|
+
if (alternate) {
|
|
683
|
+
return alternate;
|
|
684
|
+
}
|
|
685
|
+
const join2 = new _Join(this.options, this.defaultContent, store);
|
|
686
|
+
this.alternates.set(key, join2);
|
|
687
|
+
join2.alternates = this.alternates;
|
|
688
|
+
return join2;
|
|
689
|
+
}
|
|
617
690
|
};
|
|
618
691
|
function join(options, defaultContent, store = internal.IMPLICIT.STORE) {
|
|
619
692
|
const joins = getJoinMap(store);
|
|
@@ -661,12 +734,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
661
734
|
relations = {
|
|
662
735
|
get [keyAB]() {
|
|
663
736
|
const familyAB = myJoin.states[keyAB];
|
|
664
|
-
const state =
|
|
737
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
665
738
|
return state;
|
|
666
739
|
},
|
|
667
740
|
get [keyBA]() {
|
|
668
741
|
const familyBA = myJoin.states[keyBA];
|
|
669
|
-
const state =
|
|
742
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
670
743
|
return state;
|
|
671
744
|
}
|
|
672
745
|
};
|
|
@@ -676,12 +749,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
676
749
|
Object.assign(relations, {
|
|
677
750
|
get [entryAB]() {
|
|
678
751
|
const familyAB = myJoin.states[entryAB];
|
|
679
|
-
const state =
|
|
752
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
680
753
|
return state;
|
|
681
754
|
},
|
|
682
755
|
get [entryBA]() {
|
|
683
756
|
const familyBA = myJoin.states[entryBA];
|
|
684
|
-
const state =
|
|
757
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
685
758
|
return state;
|
|
686
759
|
}
|
|
687
760
|
});
|
|
@@ -694,12 +767,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
694
767
|
relations = {
|
|
695
768
|
get [keyAB]() {
|
|
696
769
|
const familyAB = myJoin.states[keyAB];
|
|
697
|
-
const state =
|
|
770
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
698
771
|
return state;
|
|
699
772
|
},
|
|
700
773
|
get [keysBA]() {
|
|
701
774
|
const familyBA = myJoin.states[keysBA];
|
|
702
|
-
const state =
|
|
775
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
703
776
|
return state;
|
|
704
777
|
}
|
|
705
778
|
};
|
|
@@ -709,12 +782,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
709
782
|
Object.assign(relations, {
|
|
710
783
|
get [entryAB]() {
|
|
711
784
|
const familyAB = myJoin.states[entryAB];
|
|
712
|
-
const state =
|
|
785
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
713
786
|
return state;
|
|
714
787
|
},
|
|
715
788
|
get [entriesBA]() {
|
|
716
789
|
const familyBA = myJoin.states[entriesBA];
|
|
717
|
-
const state =
|
|
790
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
718
791
|
return state;
|
|
719
792
|
}
|
|
720
793
|
});
|
|
@@ -727,12 +800,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
727
800
|
relations = {
|
|
728
801
|
get [keysAB]() {
|
|
729
802
|
const familyAB = myJoin.states[keysAB];
|
|
730
|
-
const state =
|
|
803
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
731
804
|
return state;
|
|
732
805
|
},
|
|
733
806
|
get [keysBA]() {
|
|
734
807
|
const familyBA = myJoin.states[keysBA];
|
|
735
|
-
const state =
|
|
808
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
736
809
|
return state;
|
|
737
810
|
}
|
|
738
811
|
};
|
|
@@ -742,12 +815,12 @@ function findRelationsInStore(token, key, store) {
|
|
|
742
815
|
Object.assign(relations, {
|
|
743
816
|
get [entriesAB]() {
|
|
744
817
|
const familyAB = myJoin.states[entriesAB];
|
|
745
|
-
const state =
|
|
818
|
+
const state = myJoin.retrieve(familyAB, key);
|
|
746
819
|
return state;
|
|
747
820
|
},
|
|
748
821
|
get [entriesBA]() {
|
|
749
822
|
const familyBA = myJoin.states[entriesBA];
|
|
750
|
-
const state =
|
|
823
|
+
const state = myJoin.retrieve(familyBA, key);
|
|
751
824
|
return state;
|
|
752
825
|
}
|
|
753
826
|
});
|
|
@@ -827,10 +900,10 @@ function structFamily(options) {
|
|
|
827
900
|
const findStructState = internal.createSelectorFamily(
|
|
828
901
|
{
|
|
829
902
|
key: options.key,
|
|
830
|
-
get: (id) => ({ get }) => {
|
|
903
|
+
get: (id) => ({ find, get }) => {
|
|
831
904
|
return Object.keys(options.default).reduce((acc, subKey) => {
|
|
832
905
|
acc[subKey] = get(
|
|
833
|
-
atoms[nameFamily(options.key, subKey)]
|
|
906
|
+
find(atoms[nameFamily(options.key, subKey)], id)
|
|
834
907
|
);
|
|
835
908
|
return acc;
|
|
836
909
|
}, {});
|
package/data/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import * as AtomIO from 'atom.io';
|
|
|
2
2
|
import { ReadonlySelectorFamily, MutableAtomFamily, Transactors, ReadonlySelectorToken, MutableAtomFamilyToken } from 'atom.io';
|
|
3
3
|
import { Store } from 'atom.io/internal';
|
|
4
4
|
import { Json, Stringified } from 'atom.io/json';
|
|
5
|
+
import { findState } from 'atom.io/ephemeral';
|
|
6
|
+
import { Molecule } from 'atom.io/immortal';
|
|
5
7
|
import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
|
|
6
8
|
|
|
7
9
|
declare function dict<State, Key extends Json.Serializable>(findState: AtomIO.ReadonlySelectorFamilyToken<State, Key> | AtomIO.RegularAtomFamilyToken<State, Key> | AtomIO.WritableSelectorFamily<State, Key>, index: AtomIO.ReadonlySelectorToken<Key[]> | AtomIO.RegularAtomToken<Key[]> | AtomIO.WritableSelectorToken<Key[]>, store?: Store): AtomIO.ReadonlySelectorToken<{
|
|
@@ -119,13 +121,17 @@ declare class Join<const ASide extends string, const BSide extends string, const
|
|
|
119
121
|
private options;
|
|
120
122
|
private defaultContent;
|
|
121
123
|
private transactors;
|
|
124
|
+
retrieve: typeof findState;
|
|
125
|
+
molecules: Map<string, Molecule<any>>;
|
|
122
126
|
relations: Junction<ASide, BSide, Content>;
|
|
123
127
|
states: JoinStateFamilies<ASide, BSide, Cardinality, Content>;
|
|
124
128
|
core: {
|
|
125
129
|
findRelatedKeysState: MutableAtomFamily<SetRTX<string>, SetRTXJson<string>, string>;
|
|
126
130
|
};
|
|
127
131
|
transact(transactors: Transactors, run: (join: Join<ASide, BSide, Cardinality, Content>) => void): void;
|
|
132
|
+
store: Store;
|
|
128
133
|
alternates: Map<string, Join<ASide, BSide, Cardinality, Content>>;
|
|
134
|
+
[Symbol.dispose](): void;
|
|
129
135
|
in(store: Store): Join<ASide, BSide, Cardinality, Content>;
|
|
130
136
|
constructor(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content | undefined, store?: Store);
|
|
131
137
|
}
|
package/data/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-
|
|
1
|
+
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-JA4V7TJY.js';
|
|
2
2
|
import '../../dist/chunk-FTONNX2R.js';
|
|
3
3
|
import '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { createStandaloneSelector, findInStore, IMPLICIT, createRegularAtom, createRegularAtomFamily, createSelectorFamily } from 'atom.io/internal';
|
|
@@ -63,10 +63,10 @@ function structFamily(options) {
|
|
|
63
63
|
const findStructState = createSelectorFamily(
|
|
64
64
|
{
|
|
65
65
|
key: options.key,
|
|
66
|
-
get: (id) => ({ get }) => {
|
|
66
|
+
get: (id) => ({ find, get }) => {
|
|
67
67
|
return Object.keys(options.default).reduce((acc, subKey) => {
|
|
68
68
|
acc[subKey] = get(
|
|
69
|
-
atoms[nameFamily(options.key, subKey)]
|
|
69
|
+
find(atoms[nameFamily(options.key, subKey)], id)
|
|
70
70
|
);
|
|
71
71
|
return acc;
|
|
72
72
|
}, {});
|