atom.io 0.14.8 → 0.15.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.
Files changed (76) hide show
  1. package/README.md +5 -0
  2. package/data/dist/index.cjs +200 -218
  3. package/data/dist/index.cjs.map +1 -1
  4. package/data/dist/index.d.ts +16 -7
  5. package/data/dist/index.js +202 -221
  6. package/data/dist/index.js.map +1 -1
  7. package/data/src/join.ts +295 -292
  8. package/data/src/struct-family.ts +2 -2
  9. package/data/src/struct.ts +2 -2
  10. package/dist/chunk-S7R5MU6A.js +137 -0
  11. package/dist/chunk-S7R5MU6A.js.map +1 -0
  12. package/dist/index.cjs +3 -20
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +15 -8
  15. package/dist/index.js +1 -151
  16. package/dist/index.js.map +1 -1
  17. package/internal/dist/index.cjs +275 -200
  18. package/internal/dist/index.cjs.map +1 -1
  19. package/internal/dist/index.d.ts +43 -36
  20. package/internal/dist/index.js +221 -193
  21. package/internal/dist/index.js.map +1 -1
  22. package/internal/src/atom/create-atom.ts +5 -86
  23. package/internal/src/atom/create-regular-atom.ts +92 -0
  24. package/internal/src/atom/index.ts +16 -0
  25. package/internal/src/atom/is-default.ts +0 -5
  26. package/internal/src/caching.ts +14 -16
  27. package/internal/src/families/create-atom-family.ts +20 -46
  28. package/internal/src/families/create-readonly-selector-family.ts +1 -0
  29. package/internal/src/families/create-regular-atom-family.ts +72 -0
  30. package/internal/src/families/create-selector-family.ts +2 -0
  31. package/internal/src/families/index.ts +1 -0
  32. package/internal/src/mutable/create-mutable-atom-family.ts +2 -2
  33. package/internal/src/mutable/create-mutable-atom.ts +8 -3
  34. package/internal/src/mutable/get-update-family.ts +1 -1
  35. package/internal/src/mutable/is-mutable.ts +3 -30
  36. package/internal/src/mutable/tracker-family.ts +2 -2
  37. package/internal/src/mutable/tracker.ts +5 -5
  38. package/internal/src/operation.ts +14 -18
  39. package/internal/src/selector/create-read-write-selector.ts +2 -3
  40. package/internal/src/selector/create-selector.ts +1 -1
  41. package/internal/src/selector/register-selector.ts +9 -14
  42. package/internal/src/set-state/evict-downstream.ts +3 -5
  43. package/internal/src/set-state/set-atom.ts +14 -17
  44. package/internal/src/store/store.ts +23 -19
  45. package/internal/src/store/withdraw.ts +32 -70
  46. package/internal/src/subscribe/subscribe-to-root-atoms.ts +5 -3
  47. package/internal/src/subscribe/subscribe-to-state.ts +5 -3
  48. package/internal/src/transaction/apply-transaction.ts +20 -2
  49. package/internal/src/transaction/build-transaction.ts +19 -11
  50. package/internal/src/transaction/create-transaction.ts +6 -11
  51. package/internal/src/transaction/index.ts +2 -3
  52. package/introspection/dist/index.cjs +6 -6
  53. package/introspection/dist/index.cjs.map +1 -1
  54. package/introspection/dist/index.d.ts +3 -3
  55. package/introspection/dist/index.js +7 -7
  56. package/introspection/dist/index.js.map +1 -1
  57. package/introspection/src/attach-atom-index.ts +7 -2
  58. package/introspection/src/attach-selector-index.ts +7 -2
  59. package/introspection/src/attach-timeline-family.ts +5 -2
  60. package/introspection/src/attach-timeline-index.ts +2 -2
  61. package/introspection/src/attach-transaction-index.ts +2 -2
  62. package/introspection/src/attach-transaction-logs.ts +2 -2
  63. package/package.json +10 -8
  64. package/react-devtools/dist/index.d.ts +17 -11
  65. package/src/atom.ts +8 -17
  66. package/src/selector.ts +3 -1
  67. package/src/set-state.ts +1 -3
  68. package/src/silo.ts +2 -14
  69. package/src/transaction.ts +17 -6
  70. package/transceivers/set-rtx/dist/index.cjs +2 -1
  71. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  72. package/transceivers/set-rtx/dist/index.js +2 -1
  73. package/transceivers/set-rtx/dist/index.js.map +1 -1
  74. package/transceivers/set-rtx/src/set-rtx.ts +2 -1
  75. package/internal/src/transaction/redo-transaction.ts +0 -27
  76. package/internal/src/transaction/undo-transaction.ts +0 -27
package/README.md CHANGED
@@ -49,8 +49,13 @@ bun i atom.io
49
49
  <a aria-label="NPM version" href="https://www.npmjs.com/package/atom.io">
50
50
  <img alt="NPM Version" src="https://img.shields.io/npm/v/atom.io?style=for-the-badge&labelColor=333">
51
51
  </a>
52
+ <a aria-label="Coverage" href="https://coveralls.io/github/jeremybanka/wayforge">
53
+ <img alt="Coverage" src="https://img.shields.io/coverallsCoverage/github/jeremybanka/wayforge?style=for-the-badge&labelColor=333">
54
+ </a>
55
+
52
56
  </p>
53
57
 
54
58
 
55
59
 
56
60
 
61
+
@@ -285,263 +285,244 @@ var TRANSACTORS = { get: atom_io.getState, set: atom_io.setState };
285
285
  function capitalize(string) {
286
286
  return string[0].toUpperCase() + string.slice(1);
287
287
  }
288
- function join(options, defaultContent, store = internal.IMPLICIT.STORE) {
289
- const a = options.between[0];
290
- const b = options.between[1];
291
- const findRelatedKeysState = internal.createMutableAtomFamily(
292
- {
293
- key: `${options.key}/relatedKeys`,
294
- default: () => new setRtx.SetRTX(),
295
- mutable: true,
296
- fromJson: (json) => new setRtx.SetRTX(json),
297
- toJson: (set) => [...set]
298
- },
299
- store
300
- );
301
- const getRelatedKeys = ({ get }, key) => get(findRelatedKeysState(key));
302
- const addRelation = (transactors, a2, b2) => {
303
- const aKeys = getRelatedKeys(transactors, a2);
304
- const bKeys = getRelatedKeys(transactors, b2);
305
- if (aKeys) {
288
+ var Join = class {
289
+ constructor(options, defaultContent, store = internal.IMPLICIT.STORE) {
290
+ this.transactors = TRANSACTORS;
291
+ const a = options.between[0];
292
+ const b = options.between[1];
293
+ const findRelatedKeysState = internal.createMutableAtomFamily(
294
+ {
295
+ key: `${options.key}/relatedKeys`,
296
+ default: () => new setRtx.SetRTX(),
297
+ mutable: true,
298
+ fromJson: (json) => new setRtx.SetRTX(json),
299
+ toJson: (set) => [...set]
300
+ },
301
+ store
302
+ );
303
+ const getRelatedKeys = ({ get }, key) => get(findRelatedKeysState(key));
304
+ const addRelation = (transactors, a2, b2) => {
305
+ const aKeys = getRelatedKeys(transactors, a2);
306
+ const bKeys = getRelatedKeys(transactors, b2);
306
307
  transactors.set(findRelatedKeysState(a2), aKeys.add(b2));
307
- } else {
308
- transactors.set(findRelatedKeysState(a2), new setRtx.SetRTX([b2]));
309
- }
310
- if (bKeys) {
311
308
  transactors.set(findRelatedKeysState(b2), bKeys.add(a2));
312
- } else {
313
- transactors.set(findRelatedKeysState(b2), new setRtx.SetRTX([a2]));
314
- }
315
- };
316
- const deleteRelation = (transactors, a2, b2) => {
317
- const aKeys = getRelatedKeys(transactors, a2);
318
- if (aKeys) {
309
+ };
310
+ const deleteRelation = (transactors, a2, b2) => {
311
+ const aKeys = getRelatedKeys(transactors, a2);
319
312
  aKeys.delete(b2);
320
313
  if (aKeys.size === 0) {
321
- transactors.set(findRelatedKeysState(a2), void 0);
314
+ atom_io.dispose(findRelatedKeysState(a2));
322
315
  }
323
316
  const bKeys = getRelatedKeys(transactors, b2);
324
- if (bKeys) {
325
- bKeys.delete(a2);
326
- if (bKeys.size === 0) {
327
- transactors.set(findRelatedKeysState(b2), void 0);
328
- }
317
+ bKeys.delete(a2);
318
+ if (bKeys.size === 0) {
319
+ atom_io.dispose(findRelatedKeysState(b2));
329
320
  }
330
- }
331
- };
332
- const replaceRelationsSafely = (transactors, a2, bs) => {
333
- const aRelations = getRelatedKeys(transactors, a2);
334
- if (aRelations) {
321
+ };
322
+ const replaceRelationsSafely = (transactors, a2, bs) => {
323
+ const aRelations = getRelatedKeys(transactors, a2);
335
324
  for (const b2 of aRelations) {
336
325
  const bKeys = getRelatedKeys(transactors, b2);
337
326
  if (bKeys) {
338
327
  bKeys.delete(a2);
339
328
  if (bKeys.size === 0) {
340
- transactors.set(findRelatedKeysState(b2), void 0);
329
+ atom_io.dispose(findRelatedKeysState(b2));
341
330
  }
342
331
  }
343
332
  }
344
- }
345
- transactors.set(findRelatedKeysState(a2), new setRtx.SetRTX(bs));
346
- for (const b2 of bs) {
347
- const bKeys = getRelatedKeys(transactors, b2);
348
- if (bKeys) {
333
+ transactors.set(findRelatedKeysState(a2), new setRtx.SetRTX(bs));
334
+ for (const b2 of bs) {
335
+ const bKeys = getRelatedKeys(transactors, b2);
349
336
  bKeys.add(a2);
350
- } else {
351
- transactors.set(findRelatedKeysState(b2), new setRtx.SetRTX([a2]));
352
337
  }
353
- }
354
- };
355
- const replaceRelationsUnsafely = (transactors, a2, bs) => {
356
- transactors.set(findRelatedKeysState(a2), new setRtx.SetRTX(bs));
357
- for (const b2 of bs) {
358
- let bKeys = getRelatedKeys(transactors, b2);
359
- if (bKeys) {
338
+ };
339
+ const replaceRelationsUnsafely = (transactors, a2, bs) => {
340
+ transactors.set(findRelatedKeysState(a2), new setRtx.SetRTX(bs));
341
+ for (const b2 of bs) {
342
+ const bKeys = getRelatedKeys(transactors, b2);
360
343
  bKeys.add(a2);
361
- } else {
362
- bKeys = new setRtx.SetRTX([a2]);
363
- transactors.set(findRelatedKeysState(b2), bKeys);
364
344
  }
345
+ };
346
+ const has = (transactors, a2, b2) => {
347
+ const aKeys = getRelatedKeys(transactors, a2);
348
+ return b2 ? aKeys.has(b2) : aKeys.size > 0;
349
+ };
350
+ const baseExternalStoreConfiguration = {
351
+ getRelatedKeys: (key) => getRelatedKeys(this.transactors, key),
352
+ addRelation: (a2, b2) => addRelation(this.transactors, a2, b2),
353
+ deleteRelation: (a2, b2) => deleteRelation(this.transactors, a2, b2),
354
+ replaceRelationsSafely: (a2, bs) => replaceRelationsSafely(this.transactors, a2, bs),
355
+ replaceRelationsUnsafely: (a2, bs) => replaceRelationsUnsafely(this.transactors, a2, bs),
356
+ has: (a2, b2) => has(this.transactors, a2, b2)
357
+ };
358
+ let externalStore;
359
+ let findContentState;
360
+ if (defaultContent) {
361
+ findContentState = internal.createRegularAtomFamily(
362
+ {
363
+ key: `${options.key}/content`,
364
+ default: defaultContent
365
+ },
366
+ store
367
+ );
368
+ const getContent = ({ get }, key) => get(findContentState(key));
369
+ const setContent = (transactors, key, content) => transactors.set(findContentState(key), content);
370
+ const deleteContent = (_, key) => atom_io.dispose(findContentState(key));
371
+ const externalStoreWithContentConfiguration = {
372
+ getContent: (contentKey) => {
373
+ const content = getContent(this.transactors, contentKey);
374
+ return content;
375
+ },
376
+ setContent: (contentKey, content) => {
377
+ setContent(this.transactors, contentKey, content);
378
+ },
379
+ deleteContent: (contentKey) => {
380
+ deleteContent(this.transactors, contentKey);
381
+ }
382
+ };
383
+ externalStore = Object.assign(
384
+ baseExternalStoreConfiguration,
385
+ externalStoreWithContentConfiguration
386
+ );
387
+ } else {
388
+ externalStore = baseExternalStoreConfiguration;
365
389
  }
366
- };
367
- const has = (transactors, a2, b2) => {
368
- var _a, _b;
369
- const aKeys = getRelatedKeys(transactors, a2);
370
- return b2 ? (_a = aKeys == null ? void 0 : aKeys.has(b2)) != null ? _a : false : ((_b = aKeys == null ? void 0 : aKeys.size) != null ? _b : 0) > 0;
371
- };
372
- const baseExternalStoreConfiguration = {
373
- getRelatedKeys: (key) => getRelatedKeys(TRANSACTORS, key),
374
- addRelation: (a2, b2) => addRelation(TRANSACTORS, a2, b2),
375
- deleteRelation: (a2, b2) => deleteRelation(TRANSACTORS, a2, b2),
376
- replaceRelationsSafely: (a2, bs) => replaceRelationsSafely(TRANSACTORS, a2, bs),
377
- replaceRelationsUnsafely: (a2, bs) => replaceRelationsUnsafely(TRANSACTORS, a2, bs),
378
- has: (a2, b2) => has(TRANSACTORS, a2, b2)
379
- };
380
- let externalStore;
381
- let findContentState;
382
- if (defaultContent) {
383
- findContentState = internal.createAtomFamily(
390
+ const relations = new Junction(options, {
391
+ externalStore,
392
+ makeContentKey: (...args) => args.sort().join(`:`)
393
+ });
394
+ const createSingleKeyStateFamily = () => internal.createSelectorFamily(
384
395
  {
385
- key: `${options.key}/content`,
386
- default: defaultContent
396
+ key: `${options.key}/singleRelatedKey`,
397
+ get: (key) => ({ get }) => {
398
+ const relatedKeys = get(findRelatedKeysState(key));
399
+ for (const relatedKey of relatedKeys) {
400
+ return relatedKey;
401
+ }
402
+ }
387
403
  },
388
404
  store
389
405
  );
390
- const getContent = ({ get }, key) => get(findContentState(key));
391
- const setContent = (transactors, key, content) => transactors.set(findContentState(key), content);
392
- const deleteContent = (transactors, key) => transactors.set(findContentState(key), void 0);
393
- const externalStoreWithContentConfiguration = {
394
- getContent: (contentKey) => {
395
- const content = getContent(TRANSACTORS, contentKey);
396
- return content;
397
- },
398
- setContent: (contentKey, content) => {
399
- setContent(TRANSACTORS, contentKey, content);
406
+ const getMultipleKeyStateFamily = () => internal.getJsonFamily(findRelatedKeysState, store);
407
+ const createSingleEntryStateFamily = () => internal.createSelectorFamily(
408
+ {
409
+ key: `${options.key}/singleRelatedEntry`,
410
+ get: (key) => ({ get }) => {
411
+ const relatedKeys = get(findRelatedKeysState(key));
412
+ for (const relatedKey of relatedKeys) {
413
+ const contentKey = relations.makeContentKey(key, relatedKey);
414
+ return [relatedKey, get(findContentState(contentKey))];
415
+ }
416
+ }
400
417
  },
401
- deleteContent: (contentKey) => {
402
- deleteContent(TRANSACTORS, contentKey);
403
- }
404
- };
405
- externalStore = Object.assign(
406
- baseExternalStoreConfiguration,
407
- externalStoreWithContentConfiguration
418
+ store
408
419
  );
409
- } else {
410
- externalStore = baseExternalStoreConfiguration;
411
- }
412
- const relations = new Junction(options, {
413
- externalStore,
414
- makeContentKey: (...args) => args.sort().join(`:`)
415
- });
416
- const createSingleKeyStateFamily = () => internal.createSelectorFamily(
417
- {
418
- key: `${options.key}/singleRelatedKey`,
419
- get: (key) => ({ get }) => {
420
- const relatedKeys = get(findRelatedKeysState(key));
421
- for (const relatedKey of relatedKeys) {
422
- return relatedKey;
423
- }
424
- }
425
- },
426
- store
427
- );
428
- const getMultipleKeyStateFamily = () => internal.getJsonFamily(findRelatedKeysState, store);
429
- const createSingleEntryStateFamily = () => internal.createSelectorFamily(
430
- {
431
- key: `${options.key}/singleRelatedEntry`,
432
- get: (key) => ({ get }) => {
433
- const relatedKeys = get(findRelatedKeysState(key));
434
- for (const relatedKey of relatedKeys) {
435
- const contentKey = relations.makeContentKey(key, relatedKey);
436
- return [relatedKey, get(findContentState(contentKey))];
420
+ const getMultipleEntryStateFamily = () => internal.createSelectorFamily(
421
+ {
422
+ key: `${options.key}/multipleRelatedEntries`,
423
+ get: (key) => ({ get }) => {
424
+ const relatedKeys = get(findRelatedKeysState(key));
425
+ return [...relatedKeys].map((relatedKey) => {
426
+ const contentKey = relations.makeContentKey(key, relatedKey);
427
+ return [relatedKey, get(findContentState(contentKey))];
428
+ });
437
429
  }
438
- }
439
- },
440
- store
441
- );
442
- const getMultipleEntryStateFamily = () => internal.createSelectorFamily(
443
- {
444
- key: `${options.key}/multipleRelatedEntries`,
445
- get: (key) => ({ get }) => {
446
- const relatedKeys = get(findRelatedKeysState(key));
447
- return [...relatedKeys].map((relatedKey) => {
448
- const contentKey = relations.makeContentKey(key, relatedKey);
449
- return [relatedKey, get(findContentState(contentKey))];
450
- });
451
- }
452
- },
453
- store
454
- );
455
- switch (options.cardinality) {
456
- case `1:1`: {
457
- const findSingleRelatedKeyState = createSingleKeyStateFamily();
458
- const stateKeyA = `${a}KeyOf${capitalize(b)}`;
459
- const stateKeyB = `${b}KeyOf${capitalize(a)}`;
460
- const findStateBase = {
461
- [stateKeyA]: findSingleRelatedKeyState,
462
- [stateKeyB]: findSingleRelatedKeyState
463
- };
464
- let findState;
465
- if (defaultContent) {
466
- const findSingleRelatedEntryState = createSingleEntryStateFamily();
467
- const entriesStateKeyA = `${a}EntryOf${capitalize(b)}`;
468
- const entriesStateKeyB = `${b}EntryOf${capitalize(a)}`;
469
- const findStateWithContent = {
470
- [entriesStateKeyA]: findSingleRelatedEntryState,
471
- [entriesStateKeyB]: findSingleRelatedEntryState
430
+ },
431
+ store
432
+ );
433
+ switch (options.cardinality) {
434
+ case `1:1`: {
435
+ const findSingleRelatedKeyState = createSingleKeyStateFamily();
436
+ const stateKeyA = `${a}KeyOf${capitalize(b)}`;
437
+ const stateKeyB = `${b}KeyOf${capitalize(a)}`;
438
+ const findStateBase = {
439
+ [stateKeyA]: findSingleRelatedKeyState,
440
+ [stateKeyB]: findSingleRelatedKeyState
472
441
  };
473
- findState = Object.assign(findStateBase, findStateWithContent);
474
- } else {
475
- findState = findStateBase;
442
+ let findState;
443
+ if (defaultContent) {
444
+ const findSingleRelatedEntryState = createSingleEntryStateFamily();
445
+ const entriesStateKeyA = `${a}EntryOf${capitalize(b)}`;
446
+ const entriesStateKeyB = `${b}EntryOf${capitalize(a)}`;
447
+ const findStateWithContent = {
448
+ [entriesStateKeyA]: findSingleRelatedEntryState,
449
+ [entriesStateKeyB]: findSingleRelatedEntryState
450
+ };
451
+ findState = Object.assign(findStateBase, findStateWithContent);
452
+ } else {
453
+ findState = findStateBase;
454
+ }
455
+ this.relations = relations;
456
+ this.findState = findState;
457
+ break;
476
458
  }
477
- return {
478
- relations,
479
- findState
480
- };
481
- }
482
- case `1:n`: {
483
- const findSingleRelatedKeyState = createSingleKeyStateFamily();
484
- const findMultipleRelatedKeysState = getMultipleKeyStateFamily();
485
- const stateKeyA = `${a}KeyOf${capitalize(b)}`;
486
- const stateKeyB = `${b}KeysOf${capitalize(a)}`;
487
- const findStateBase = {
488
- [stateKeyA]: findSingleRelatedKeyState,
489
- [stateKeyB]: findMultipleRelatedKeysState
490
- };
491
- let findState;
492
- if (defaultContent) {
493
- const findSingleRelatedEntryState = createSingleEntryStateFamily();
494
- const findMultipleRelatedEntriesState = getMultipleEntryStateFamily();
495
- const entriesStateKeyA = `${a}EntryOf${capitalize(b)}`;
496
- const entriesStateKeyB = `${b}EntriesOf${capitalize(a)}`;
497
- const findStateWithContent = {
498
- [entriesStateKeyA]: findSingleRelatedEntryState,
499
- [entriesStateKeyB]: findMultipleRelatedEntriesState
459
+ case `1:n`: {
460
+ const findSingleRelatedKeyState = createSingleKeyStateFamily();
461
+ const findMultipleRelatedKeysState = getMultipleKeyStateFamily();
462
+ const stateKeyA = `${a}KeyOf${capitalize(b)}`;
463
+ const stateKeyB = `${b}KeysOf${capitalize(a)}`;
464
+ const findStateBase = {
465
+ [stateKeyA]: findSingleRelatedKeyState,
466
+ [stateKeyB]: findMultipleRelatedKeysState
500
467
  };
501
- findState = Object.assign(findStateBase, findStateWithContent);
502
- } else {
503
- findState = findStateBase;
468
+ let findState;
469
+ if (defaultContent) {
470
+ const findSingleRelatedEntryState = createSingleEntryStateFamily();
471
+ const findMultipleRelatedEntriesState = getMultipleEntryStateFamily();
472
+ const entriesStateKeyA = `${a}EntryOf${capitalize(b)}`;
473
+ const entriesStateKeyB = `${b}EntriesOf${capitalize(a)}`;
474
+ const findStateWithContent = {
475
+ [entriesStateKeyA]: findSingleRelatedEntryState,
476
+ [entriesStateKeyB]: findMultipleRelatedEntriesState
477
+ };
478
+ findState = Object.assign(findStateBase, findStateWithContent);
479
+ } else {
480
+ findState = findStateBase;
481
+ }
482
+ this.relations = relations;
483
+ this.findState = findState;
484
+ break;
504
485
  }
505
- return {
506
- relations,
507
- findState
508
- };
509
- }
510
- case `n:n`: {
511
- const findMultipleRelatedKeysState = getMultipleKeyStateFamily();
512
- const stateKeyA = `${a}KeysOf${capitalize(b)}`;
513
- const stateKeyB = `${b}KeysOf${capitalize(a)}`;
514
- const findStateBase = {
515
- [stateKeyA]: findMultipleRelatedKeysState,
516
- [stateKeyB]: findMultipleRelatedKeysState
517
- };
518
- let findState;
519
- if (defaultContent) {
520
- const findMultipleRelatedEntriesState = getMultipleEntryStateFamily();
521
- const entriesStateKeyA = `${a}EntriesOf${capitalize(b)}`;
522
- const entriesStateKeyB = `${b}EntriesOf${capitalize(a)}`;
523
- const findStateWithContent = {
524
- [entriesStateKeyA]: findMultipleRelatedEntriesState,
525
- [entriesStateKeyB]: findMultipleRelatedEntriesState
486
+ default: {
487
+ const findMultipleRelatedKeysState = getMultipleKeyStateFamily();
488
+ const stateKeyA = `${a}KeysOf${capitalize(b)}`;
489
+ const stateKeyB = `${b}KeysOf${capitalize(a)}`;
490
+ const findStateBase = {
491
+ [stateKeyA]: findMultipleRelatedKeysState,
492
+ [stateKeyB]: findMultipleRelatedKeysState
526
493
  };
527
- findState = Object.assign(findStateBase, findStateWithContent);
528
- } else {
529
- findState = findStateBase;
494
+ let findState;
495
+ if (defaultContent) {
496
+ const findMultipleRelatedEntriesState = getMultipleEntryStateFamily();
497
+ const entriesStateKeyA = `${a}EntriesOf${capitalize(b)}`;
498
+ const entriesStateKeyB = `${b}EntriesOf${capitalize(a)}`;
499
+ const findStateWithContent = {
500
+ [entriesStateKeyA]: findMultipleRelatedEntriesState,
501
+ [entriesStateKeyB]: findMultipleRelatedEntriesState
502
+ };
503
+ findState = Object.assign(findStateBase, findStateWithContent);
504
+ } else {
505
+ findState = findStateBase;
506
+ }
507
+ this.relations = relations;
508
+ this.findState = findState;
530
509
  }
531
- return {
532
- relations,
533
- findState
534
- };
535
510
  }
536
- default:
537
- throw new Error(`Invalid cardinality: ${options.cardinality}`);
538
511
  }
512
+ transact(transactors, run) {
513
+ this.transactors = transactors;
514
+ run(this);
515
+ this.transactors = TRANSACTORS;
516
+ }
517
+ };
518
+ function join(options, defaultContent, store = internal.IMPLICIT.STORE) {
519
+ return new Join(options, defaultContent, store);
539
520
  }
540
521
  var capitalize2 = (str) => str[0].toUpperCase() + str.slice(1);
541
522
  function struct(options, store = internal.IMPLICIT.STORE) {
542
523
  const atoms = Object.keys(options.default).reduce((acc, key) => {
543
524
  const atomName = options.key + capitalize2(key) + `State`;
544
- acc[atomName] = internal.createAtom(
525
+ acc[atomName] = internal.createRegularAtom(
545
526
  {
546
527
  key: `${options.key}.${key}`,
547
528
  default: options.default[key]
@@ -571,7 +552,7 @@ var nameFamily = (topKey, subKey) => `find` + capitalize3(topKey) + capitalize3(
571
552
  function structFamily(options) {
572
553
  const atoms = Object.keys(options.default).reduce((acc, subKey) => {
573
554
  const atomFamilyName = nameFamily(options.key, subKey);
574
- acc[atomFamilyName] = internal.createAtomFamily(
555
+ acc[atomFamilyName] = internal.createRegularAtomFamily(
575
556
  {
576
557
  key: `${options.key}.${subKey}`,
577
558
  default: options.default[subKey]
@@ -605,6 +586,7 @@ function until(loadable, fallback) {
605
586
  return loadable;
606
587
  }
607
588
 
589
+ exports.Join = Join;
608
590
  exports.dict = dict;
609
591
  exports.join = join;
610
592
  exports.struct = struct;