atom.io 0.19.3 → 0.20.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 (104) hide show
  1. package/data/dist/index.js +1 -1
  2. package/data/src/dict.ts +1 -1
  3. package/data/src/join.ts +1 -1
  4. package/data/src/struct-family.ts +1 -1
  5. package/data/src/struct.ts +5 -3
  6. package/eslint-plugin/dist/index.cjs +53 -0
  7. package/eslint-plugin/dist/index.js +52 -0
  8. package/eslint-plugin/src/index.ts +1 -0
  9. package/eslint-plugin/src/rules/explicit-state-types.ts +55 -0
  10. package/eslint-plugin/src/rules/index.ts +1 -0
  11. package/internal/dist/index.cjs +127 -92
  12. package/internal/dist/index.d.ts +13 -9
  13. package/internal/dist/index.js +127 -92
  14. package/internal/src/atom/index.ts +1 -1
  15. package/internal/src/caching.ts +13 -9
  16. package/internal/src/families/create-atom-family.ts +1 -1
  17. package/internal/src/families/find-in-store.ts +2 -2
  18. package/internal/src/families/index.ts +1 -1
  19. package/internal/src/future.ts +52 -15
  20. package/internal/src/index.ts +2 -2
  21. package/internal/src/mutable/create-mutable-atom-family.ts +2 -3
  22. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  23. package/internal/src/mutable/get-update-token.ts +1 -0
  24. package/internal/src/selector/delete-selector.ts +1 -1
  25. package/internal/src/selector/register-selector.ts +1 -1
  26. package/internal/src/store/deposit.ts +1 -1
  27. package/internal/src/store/store.ts +2 -2
  28. package/internal/src/store/withdraw-new-family-member.ts +1 -1
  29. package/internal/src/store/withdraw.ts +2 -3
  30. package/internal/src/subscribe/subscribe-to-state.ts +1 -0
  31. package/internal/src/subscribe/subscribe-to-timeline.ts +1 -0
  32. package/internal/src/subscribe/subscribe-to-transaction.ts +2 -1
  33. package/internal/src/timeline/add-atom-to-timeline.ts +2 -2
  34. package/internal/src/timeline/create-timeline.ts +1 -1
  35. package/internal/src/transaction/act-upon-store.ts +1 -1
  36. package/internal/src/transaction/apply-transaction.ts +1 -1
  37. package/internal/src/transaction/build-transaction.ts +2 -2
  38. package/internal/src/transaction/create-transaction.ts +2 -2
  39. package/internal/src/transaction/index.ts +1 -1
  40. package/internal/src/transaction/is-root-store.ts +1 -1
  41. package/introspection/src/attach-atom-index.ts +1 -1
  42. package/introspection/src/attach-introspection-states.ts +2 -2
  43. package/introspection/src/attach-selector-index.ts +1 -1
  44. package/introspection/src/attach-timeline-family.ts +2 -2
  45. package/introspection/src/attach-timeline-index.ts +1 -1
  46. package/introspection/src/attach-transaction-index.ts +2 -2
  47. package/introspection/src/attach-transaction-logs.ts +2 -2
  48. package/json/dist/index.cjs +35 -33
  49. package/json/dist/index.d.ts +5 -5
  50. package/json/dist/index.js +5 -5
  51. package/json/src/index.ts +2 -3
  52. package/json/src/select-json-family.ts +6 -6
  53. package/json/src/select-json.ts +1 -2
  54. package/package.json +18 -15
  55. package/react/src/use-tl.ts +1 -1
  56. package/react-devtools/dist/index.cjs +99 -99
  57. package/react-devtools/dist/index.css +0 -3
  58. package/react-devtools/dist/index.d.ts +2 -2
  59. package/react-devtools/dist/index.js +77 -77
  60. package/react-devtools/src/AtomIODevtools.tsx +2 -2
  61. package/react-devtools/src/TransactionIndex.tsx +2 -2
  62. package/react-devtools/src/Updates.tsx +1 -1
  63. package/react-devtools/src/devtools.scss +0 -3
  64. package/react-devtools/src/index.ts +1 -1
  65. package/realtime/src/realtime-continuity.ts +1 -1
  66. package/realtime/src/shared-room-store.ts +1 -1
  67. package/realtime-client/dist/index.js +1 -1
  68. package/realtime-client/src/pull-atom-family-member.ts +1 -1
  69. package/realtime-client/src/pull-atom.ts +1 -1
  70. package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
  71. package/realtime-client/src/sync-continuity.ts +1 -1
  72. package/realtime-react/dist/index.js +1 -1
  73. package/realtime-react/src/use-realtime-service.ts +1 -0
  74. package/realtime-react/src/use-sync-continuity.ts +2 -1
  75. package/realtime-server/dist/index.cjs +98 -98
  76. package/realtime-server/dist/index.d.ts +17 -18
  77. package/realtime-server/dist/index.js +100 -100
  78. package/realtime-server/src/index.ts +5 -5
  79. package/realtime-server/src/ipc-sockets/parent-socket.ts +3 -3
  80. package/realtime-server/src/realtime-action-receiver.ts +1 -1
  81. package/realtime-server/src/realtime-continuity-synchronizer.ts +2 -3
  82. package/realtime-server/src/realtime-family-provider.ts +1 -1
  83. package/realtime-server/src/realtime-mutable-family-provider.ts +1 -1
  84. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  85. package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +2 -2
  86. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +1 -1
  87. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -0
  88. package/realtime-server/src/realtime-server-stores/server-user-store.ts +3 -2
  89. package/realtime-server/src/realtime-state-provider.ts +1 -1
  90. package/realtime-server/src/realtime-state-synchronizer.ts +1 -1
  91. package/realtime-testing/dist/index.js +2 -2
  92. package/realtime-testing/src/setup-realtime-test.tsx +3 -2
  93. package/src/atom.ts +1 -1
  94. package/src/find-state.ts +1 -1
  95. package/src/index.ts +1 -0
  96. package/src/selector.ts +1 -1
  97. package/src/silo.ts +4 -4
  98. package/src/subscribe.ts +2 -2
  99. package/src/timeline.ts +1 -1
  100. package/src/transaction.ts +3 -3
  101. package/transceivers/set-rtx/src/set-rtx.ts +1 -1
  102. package/dist/{chunk-ATKDGVTV.js → chunk-2AIFLP2B.js} +0 -0
  103. package/dist/{chunk-CC7IF7QF.js → chunk-3V3VWQ7X.js} +6 -6
  104. /package/dist/{chunk-MSCJWACE.js → chunk-SMZRGPN6.js} +0 -0
@@ -1,4 +1,4 @@
1
- export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-MSCJWACE.js';
1
+ export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-SMZRGPN6.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';
package/data/src/dict.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
3
  import {
4
- IMPLICIT,
5
4
  createStandaloneSelector,
6
5
  findInStore,
6
+ IMPLICIT,
7
7
  } from "atom.io/internal"
8
8
  import type { Json, Stringified } from "atom.io/json"
9
9
 
package/data/src/join.ts CHANGED
@@ -13,13 +13,13 @@ import type {
13
13
  import { dispose, findState, getState, setState } from "atom.io"
14
14
  import type { Store } from "atom.io/internal"
15
15
  import {
16
- IMPLICIT,
17
16
  createMutableAtomFamily,
18
17
  createRegularAtomFamily,
19
18
  createSelectorFamily,
20
19
  findInStore,
21
20
  getFromStore,
22
21
  getJsonFamily,
22
+ IMPLICIT,
23
23
  isChildStore,
24
24
  newest,
25
25
  setIntoStore,
@@ -1,8 +1,8 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import {
3
- IMPLICIT,
4
3
  createRegularAtomFamily,
5
4
  createSelectorFamily,
5
+ IMPLICIT,
6
6
  } from "atom.io/internal"
7
7
 
8
8
  const capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)
@@ -1,8 +1,10 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
- import { IMPLICIT } from "atom.io/internal"
4
-
5
- import { createRegularAtom, createStandaloneSelector } from "atom.io/internal"
3
+ import {
4
+ createRegularAtom,
5
+ createStandaloneSelector,
6
+ IMPLICIT,
7
+ } from "atom.io/internal"
6
8
 
7
9
  const capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)
8
10
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var utils = require('@typescript-eslint/utils');
6
+
5
7
  var __defProp = Object.defineProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -11,8 +13,58 @@ var __export = (target, all) => {
11
13
  // eslint-plugin/src/rules/index.ts
12
14
  var rules_exports = {};
13
15
  __export(rules_exports, {
16
+ explicitStateTypes: () => explicitStateTypes,
14
17
  synchronousSelectorDependencies: () => synchronousSelectorDependencies
15
18
  });
19
+ var createRule = utils.ESLintUtils.RuleCreator(
20
+ (name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
21
+ );
22
+ var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
23
+ var explicitStateTypes = createRule({
24
+ name: `explicit-state-types`,
25
+ meta: {
26
+ type: `problem`,
27
+ docs: {
28
+ description: `State declarations must have generic type arguments directly passed to them`
29
+ },
30
+ messages: {
31
+ noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
32
+ },
33
+ schema: []
34
+ // no options
35
+ },
36
+ defaultOptions: [],
37
+ create(context) {
38
+ return {
39
+ CallExpression(node) {
40
+ const { callee } = node;
41
+ switch (callee.type) {
42
+ case `Identifier`: {
43
+ if (STATE_FUNCTIONS.includes(callee.name)) {
44
+ if (!node.typeArguments) {
45
+ context.report({
46
+ node,
47
+ messageId: `noTypeArgument`
48
+ });
49
+ }
50
+ }
51
+ break;
52
+ }
53
+ case `MemberExpression`: {
54
+ if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
55
+ if (!node.typeArguments) {
56
+ context.report({
57
+ node,
58
+ messageId: `noTypeArgument`
59
+ });
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ };
66
+ }
67
+ });
16
68
 
17
69
  // eslint-plugin/src/rules/synchronous-selector-dependencies.ts
18
70
  function walk(node, callback, depth = 0) {
@@ -172,6 +224,7 @@ var synchronousSelectorDependencies = {
172
224
  // eslint-plugin/src/index.ts
173
225
  var src_default = {
174
226
  rules: {
227
+ "explicit-state-types": explicitStateTypes,
175
228
  "synchronous-selector-dependencies": synchronousSelectorDependencies
176
229
  }
177
230
  };
@@ -1,10 +1,61 @@
1
1
  import { __export } from '../../dist/chunk-F2X4B4VY.js';
2
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
3
 
3
4
  // eslint-plugin/src/rules/index.ts
4
5
  var rules_exports = {};
5
6
  __export(rules_exports, {
7
+ explicitStateTypes: () => explicitStateTypes,
6
8
  synchronousSelectorDependencies: () => synchronousSelectorDependencies
7
9
  });
10
+ var createRule = ESLintUtils.RuleCreator(
11
+ (name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
12
+ );
13
+ var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
14
+ var explicitStateTypes = createRule({
15
+ name: `explicit-state-types`,
16
+ meta: {
17
+ type: `problem`,
18
+ docs: {
19
+ description: `State declarations must have generic type arguments directly passed to them`
20
+ },
21
+ messages: {
22
+ noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
23
+ },
24
+ schema: []
25
+ // no options
26
+ },
27
+ defaultOptions: [],
28
+ create(context) {
29
+ return {
30
+ CallExpression(node) {
31
+ const { callee } = node;
32
+ switch (callee.type) {
33
+ case `Identifier`: {
34
+ if (STATE_FUNCTIONS.includes(callee.name)) {
35
+ if (!node.typeArguments) {
36
+ context.report({
37
+ node,
38
+ messageId: `noTypeArgument`
39
+ });
40
+ }
41
+ }
42
+ break;
43
+ }
44
+ case `MemberExpression`: {
45
+ if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
46
+ if (!node.typeArguments) {
47
+ context.report({
48
+ node,
49
+ messageId: `noTypeArgument`
50
+ });
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ };
57
+ }
58
+ });
8
59
 
9
60
  // eslint-plugin/src/rules/synchronous-selector-dependencies.ts
10
61
  function walk(node, callback, depth = 0) {
@@ -164,6 +215,7 @@ var synchronousSelectorDependencies = {
164
215
  // eslint-plugin/src/index.ts
165
216
  var src_default = {
166
217
  rules: {
218
+ "explicit-state-types": explicitStateTypes,
167
219
  "synchronous-selector-dependencies": synchronousSelectorDependencies
168
220
  }
169
221
  };
@@ -6,6 +6,7 @@ export { Rules }
6
6
 
7
7
  export default {
8
8
  rules: {
9
+ "explicit-state-types": Rules.explicitStateTypes as any,
9
10
  "synchronous-selector-dependencies": Rules.synchronousSelectorDependencies,
10
11
  },
11
12
  } satisfies ESLint.Plugin
@@ -0,0 +1,55 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils"
2
+
3
+ const createRule = ESLintUtils.RuleCreator(
4
+ (name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`,
5
+ )
6
+
7
+ const STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`]
8
+
9
+ export const explicitStateTypes = createRule({
10
+ name: `explicit-state-types`,
11
+ meta: {
12
+ type: `problem`,
13
+ docs: {
14
+ description: `State declarations must have generic type arguments directly passed to them`,
15
+ },
16
+ messages: {
17
+ noTypeArgument: `State declarations must have generic type arguments directly passed to them.`,
18
+ },
19
+ schema: [], // no options
20
+ },
21
+ defaultOptions: [],
22
+ create(context) {
23
+ return {
24
+ CallExpression(node) {
25
+ const { callee } = node
26
+ switch (callee.type) {
27
+ case `Identifier`: {
28
+ if (STATE_FUNCTIONS.includes(callee.name)) {
29
+ if (!node.typeArguments) {
30
+ context.report({
31
+ node,
32
+ messageId: `noTypeArgument`,
33
+ })
34
+ }
35
+ }
36
+ break
37
+ }
38
+ case `MemberExpression`: {
39
+ if (
40
+ callee.property.type === `Identifier` &&
41
+ STATE_FUNCTIONS.includes(callee.property.name)
42
+ ) {
43
+ if (!node.typeArguments) {
44
+ context.report({
45
+ node,
46
+ messageId: `noTypeArgument`,
47
+ })
48
+ }
49
+ }
50
+ }
51
+ }
52
+ },
53
+ }
54
+ },
55
+ })
@@ -1 +1,2 @@
1
+ export * from "./explicit-state-types"
1
2
  export * from "./synchronous-selector-dependencies"
@@ -23,6 +23,67 @@ var __spreadValues = (a, b) => {
23
23
  };
24
24
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
25
 
26
+ // internal/src/arbitrary.ts
27
+ function arbitrary(random = Math.random) {
28
+ return random().toString(36).slice(2);
29
+ }
30
+
31
+ // internal/src/future.ts
32
+ var Future = class extends Promise {
33
+ constructor(executor) {
34
+ let promise;
35
+ let superResolve;
36
+ let superReject;
37
+ super((resolve, reject) => {
38
+ superResolve = resolve;
39
+ superReject = reject;
40
+ promise = executor instanceof Promise ? executor : new Promise(executor);
41
+ promise.then(
42
+ (value) => {
43
+ if (promise) {
44
+ this.pass(promise, value);
45
+ }
46
+ },
47
+ (reason) => {
48
+ if (promise) {
49
+ this.fail(promise, reason);
50
+ }
51
+ }
52
+ );
53
+ });
54
+ this.destiny = promise;
55
+ this.resolve = superResolve;
56
+ this.reject = superReject;
57
+ }
58
+ pass(promise, value) {
59
+ if (promise === this.destiny) {
60
+ this.resolve(value);
61
+ }
62
+ }
63
+ fail(promise, reason) {
64
+ if (promise === this.destiny) {
65
+ this.reject(reason);
66
+ }
67
+ }
68
+ use(value) {
69
+ if (value instanceof Promise) {
70
+ const promise = value;
71
+ this.destiny = promise;
72
+ promise.then(
73
+ (resolved) => {
74
+ this.pass(promise, resolved);
75
+ },
76
+ (reason) => {
77
+ this.fail(promise, reason);
78
+ }
79
+ );
80
+ } else {
81
+ this.resolve(value);
82
+ this.destiny = void 0;
83
+ }
84
+ }
85
+ };
86
+
26
87
  // internal/src/lineage.ts
27
88
  function newest(scion) {
28
89
  while (scion.child !== null) {
@@ -539,93 +600,6 @@ function withdrawOrCreate(token, store) {
539
600
  }
540
601
  }
541
602
 
542
- // internal/src/future.ts
543
- var Future = class extends Promise {
544
- constructor(executor) {
545
- super((resolve, reject) => {
546
- const pass = (value) => {
547
- this.isCanceled ? reject(`canceled`) : resolve(value);
548
- };
549
- const fail = (reason) => {
550
- this.isCanceled ? reject(`canceled`) : reject(reason);
551
- };
552
- if (typeof executor === `function`) {
553
- executor(pass, fail);
554
- } else {
555
- executor.then(pass, fail);
556
- }
557
- });
558
- this.isCanceled = false;
559
- }
560
- cancel() {
561
- this.isCanceled = true;
562
- }
563
- };
564
-
565
- // internal/src/set-state/copy-mutable-if-needed.ts
566
- function copyMutableIfNeeded(atom, origin, target) {
567
- const originValue = origin.valueMap.get(atom.key);
568
- const targetValue = target.valueMap.get(atom.key);
569
- if (originValue === targetValue) {
570
- if (originValue === void 0) {
571
- return typeof atom.default === `function` ? atom.default() : atom.default;
572
- }
573
- origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
574
- const jsonValue = atom.toJson(originValue);
575
- const copiedValue = atom.fromJson(jsonValue);
576
- target.valueMap.set(atom.key, copiedValue);
577
- new Tracker(atom, origin);
578
- return copiedValue;
579
- }
580
- return targetValue;
581
- }
582
-
583
- // internal/src/caching.ts
584
- function cacheValue(key, value, subject, target) {
585
- const currentValue = target.valueMap.get(key);
586
- if (currentValue instanceof Future) {
587
- currentValue.cancel();
588
- }
589
- if (value instanceof Promise) {
590
- const future = new Future(value);
591
- target.valueMap.set(key, future);
592
- future.then((resolved) => {
593
- if (future.isCanceled) {
594
- return;
595
- }
596
- cacheValue(key, resolved, subject, target);
597
- subject.next({ newValue: resolved, oldValue: future });
598
- }).catch((thrown) => {
599
- if (thrown !== `canceled`) {
600
- target.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
601
- }
602
- });
603
- return future;
604
- }
605
- target.valueMap.set(key, value);
606
- return value;
607
- }
608
- var readCachedValue = (token, target) => {
609
- let value = target.valueMap.get(token.key);
610
- if (token.type === `mutable_atom` && isChildStore(target)) {
611
- const { parent } = target;
612
- const copiedValue = copyMutableIfNeeded(token, parent, target);
613
- value = copiedValue;
614
- }
615
- return value;
616
- };
617
- var evictCachedValue = (key, target) => {
618
- const currentValue = target.valueMap.get(key);
619
- if (currentValue instanceof Future) {
620
- currentValue.cancel();
621
- }
622
- if (target.operation.open) {
623
- target.operation.prev.set(key, currentValue);
624
- }
625
- target.valueMap.delete(key);
626
- target.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
627
- };
628
-
629
603
  // internal/src/get-state/read-or-compute-value.ts
630
604
  var readOrComputeValue = (state, target) => {
631
605
  if (target.valueMap.has(state.key)) {
@@ -1727,6 +1701,72 @@ function isTransceiver(value) {
1727
1701
  return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
1728
1702
  }
1729
1703
 
1704
+ // internal/src/set-state/copy-mutable-if-needed.ts
1705
+ function copyMutableIfNeeded(atom, origin, target) {
1706
+ const originValue = origin.valueMap.get(atom.key);
1707
+ const targetValue = target.valueMap.get(atom.key);
1708
+ if (originValue === targetValue) {
1709
+ if (originValue === void 0) {
1710
+ return typeof atom.default === `function` ? atom.default() : atom.default;
1711
+ }
1712
+ origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
1713
+ const jsonValue = atom.toJson(originValue);
1714
+ const copiedValue = atom.fromJson(jsonValue);
1715
+ target.valueMap.set(atom.key, copiedValue);
1716
+ new Tracker(atom, origin);
1717
+ return copiedValue;
1718
+ }
1719
+ return targetValue;
1720
+ }
1721
+
1722
+ // internal/src/caching.ts
1723
+ function cacheValue(key, value, subject, target) {
1724
+ const currentValue = target.valueMap.get(key);
1725
+ if (currentValue instanceof Future) {
1726
+ const future = currentValue;
1727
+ future.use(value);
1728
+ }
1729
+ if (value instanceof Promise) {
1730
+ const future = new Future(value);
1731
+ target.valueMap.set(key, future);
1732
+ future.then((resolved) => {
1733
+ cacheValue(key, resolved, subject, target);
1734
+ subject.next({ newValue: resolved, oldValue: future });
1735
+ }).catch((thrown) => {
1736
+ target.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
1737
+ });
1738
+ return future;
1739
+ }
1740
+ target.valueMap.set(key, value);
1741
+ return value;
1742
+ }
1743
+ var readCachedValue = (token, target) => {
1744
+ let value = target.valueMap.get(token.key);
1745
+ if (token.type === `mutable_atom` && isChildStore(target)) {
1746
+ const { parent } = target;
1747
+ const copiedValue = copyMutableIfNeeded(token, parent, target);
1748
+ value = copiedValue;
1749
+ }
1750
+ return value;
1751
+ };
1752
+ var evictCachedValue = (key, target) => {
1753
+ var _a;
1754
+ const currentValue = target.valueMap.get(key);
1755
+ if (currentValue instanceof Future) {
1756
+ const future = currentValue;
1757
+ const selector = (_a = target.selectors.get(key)) != null ? _a : target.readonlySelectors.get(key);
1758
+ if (selector) {
1759
+ future.use(selector.get());
1760
+ }
1761
+ return;
1762
+ }
1763
+ if (target.operation.open) {
1764
+ target.operation.prev.set(key, currentValue);
1765
+ }
1766
+ target.valueMap.delete(key);
1767
+ target.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
1768
+ };
1769
+
1730
1770
  // internal/src/atom/is-default.ts
1731
1771
  var isAtomDefault = (key, store) => {
1732
1772
  const core = newest(store);
@@ -1856,11 +1896,6 @@ function deleteAtom(atomToken, store) {
1856
1896
  store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
1857
1897
  }
1858
1898
 
1859
- // internal/src/arbitrary.ts
1860
- function arbitrary(random = Math.random) {
1861
- return random().toString(36).slice(2);
1862
- }
1863
-
1864
1899
  // internal/src/get-environment-data.ts
1865
1900
  function getEnvironmentData(store) {
1866
1901
  return {
@@ -315,21 +315,21 @@ declare class FamilyTracker<Core extends Transceiver<any>, FamilyMemberKey exten
315
315
  constructor(findMutableState: MutableAtomFamily<Core, any, FamilyMemberKey>, store: Store);
316
316
  }
317
317
 
318
- declare function createStandaloneAtom<T>(options: RegularAtomOptions<T>, store: Store): RegularAtomToken<T>;
319
- declare function createStandaloneAtom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>, store: Store): MutableAtomToken<T, J>;
318
+ declare function arbitrary(random?: () => number): string;
320
319
 
321
320
  declare function createRegularAtom<T>(options: MutableAtomOptions<any, any> | RegularAtomOptions<T>, family: FamilyMetadata | undefined, store: Store): RegularAtomToken<T>;
322
321
 
322
+ declare function createStandaloneAtom<T>(options: RegularAtomOptions<T>, store: Store): RegularAtomToken<T>;
323
+ declare function createStandaloneAtom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>, store: Store): MutableAtomToken<T, J>;
324
+
323
325
  declare function deleteAtom(atomToken: AtomToken<unknown>, store: Store): void;
324
326
 
325
327
  declare const isAtomDefault: (key: string, store: Store) => boolean;
326
328
  declare const markAtomAsDefault: (key: string, store: Store) => void;
327
329
  declare const markAtomAsNotDefault: (key: string, store: Store) => void;
328
330
 
329
- declare function arbitrary(random?: () => number): string;
330
-
331
331
  /**
332
- * A Promise that can be canceled.
332
+ * A Promise whose incoming value can be hot swapped.
333
333
  * @internal
334
334
  * @private
335
335
  * @typeParam T The type of the value that the promise will resolve to.
@@ -338,9 +338,13 @@ declare function arbitrary(random?: () => number): string;
338
338
  * Can be constructed like a Promise, or from an existing Promise.
339
339
  */
340
340
  declare class Future<T> extends Promise<T> {
341
- isCanceled: boolean;
341
+ private destiny;
342
+ private resolve;
343
+ private reject;
342
344
  constructor(executor: Promise<T> | ((resolve: (value: T) => void, reject: (reason?: any) => void) => void));
343
- cancel(): void;
345
+ private pass;
346
+ private fail;
347
+ use(value: Promise<T> | T): void;
344
348
  }
345
349
 
346
350
  declare function cacheValue<T>(key: string, value: T, subject: Subject<StateUpdate<unknown>>, store: Store): T;
@@ -351,10 +355,10 @@ declare const evictCachedValue: (key: string, target: Store) => void;
351
355
  declare function createAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>, store: Store): MutableAtomFamily<T, J, K>;
352
356
  declare function createAtomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>, store: Store): RegularAtomFamily<T, K>;
353
357
 
354
- declare function createRegularAtomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>, store: Store): RegularAtomFamily<T, K>;
355
-
356
358
  declare function createReadonlySelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
357
359
 
360
+ declare function createRegularAtomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>, store: Store): RegularAtomFamily<T, K>;
361
+
358
362
  declare function createSelectorFamily<T, K extends Json.Serializable>(options: WritableSelectorFamilyOptions<T, K>, store: Store): WritableSelectorFamily<T, K>;
359
363
  declare function createSelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
360
364