atom.io 0.14.1 → 0.14.3

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 (83) hide show
  1. package/data/dist/index.cjs +12 -64
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +2 -0
  4. package/data/dist/index.d.ts +459 -0
  5. package/data/dist/index.js +1 -1
  6. package/dist/{chunk-KW7RA7IM.js → chunk-C4YZZNRH.js} +4 -4
  7. package/dist/{chunk-LFXB7Y6M.js → chunk-CWKKQKVQ.js} +2 -2
  8. package/dist/{chunk-CK7GNCU5.js → chunk-GMN5KH6A.js} +2 -2
  9. package/dist/{chunk-5VJ77LZE.js → chunk-N7ADBQJG.js} +2 -2
  10. package/dist/{chunk-TE3ZSTQ6.js → chunk-PURABO5G.js} +92 -27
  11. package/dist/chunk-PURABO5G.js.map +1 -0
  12. package/dist/index.cjs +106 -20
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +4 -1
  15. package/dist/index.d.ts +493 -0
  16. package/dist/index.js +1 -1
  17. package/dist/metafile-cjs.json +1 -1
  18. package/dist/metafile-esm.json +1 -0
  19. package/internal/dist/index.cjs +93 -29
  20. package/internal/dist/index.cjs.map +1 -1
  21. package/internal/dist/index.d.cts +6 -4
  22. package/internal/dist/index.d.ts +622 -0
  23. package/internal/dist/index.js +1 -1
  24. package/internal/src/atom/create-atom.ts +3 -1
  25. package/internal/src/families/create-atom-family.ts +3 -4
  26. package/internal/src/mutable/get-update-family.ts +23 -0
  27. package/internal/src/mutable/index.ts +1 -4
  28. package/internal/src/mutable/is-mutable.ts +44 -0
  29. package/internal/src/mutable/tracker.ts +9 -2
  30. package/internal/src/subject.ts +2 -1
  31. package/internal/src/timeline/add-atom-to-timeline.ts +10 -1
  32. package/internal/src/timeline/create-timeline.ts +44 -16
  33. package/introspection/dist/index.cjs +12 -64
  34. package/introspection/dist/index.cjs.map +1 -1
  35. package/introspection/dist/index.d.cts +2 -0
  36. package/introspection/dist/index.d.ts +396 -0
  37. package/introspection/dist/index.js +2 -2
  38. package/json/dist/index.cjs +9 -64
  39. package/json/dist/index.cjs.map +1 -1
  40. package/json/dist/index.d.cts +2 -0
  41. package/json/dist/index.d.ts +417 -0
  42. package/json/dist/index.js +1 -1
  43. package/package.json +3 -2
  44. package/react/dist/index.cjs +9 -64
  45. package/react/dist/index.cjs.map +1 -1
  46. package/react/dist/index.d.cts +2 -0
  47. package/react/dist/index.d.ts +396 -0
  48. package/react/dist/index.js +2 -2
  49. package/react-devtools/dist/index.cjs +12 -64
  50. package/react-devtools/dist/index.cjs.map +1 -1
  51. package/react-devtools/dist/index.d.cts +2 -0
  52. package/react-devtools/dist/index.d.ts +467 -0
  53. package/react-devtools/dist/index.js +3 -3
  54. package/realtime-client/dist/index.cjs +9 -64
  55. package/realtime-client/dist/index.cjs.map +1 -1
  56. package/realtime-client/dist/index.d.cts +2 -0
  57. package/realtime-client/dist/index.d.ts +394 -0
  58. package/realtime-client/dist/index.js +2 -2
  59. package/realtime-react/dist/index.cjs +9 -64
  60. package/realtime-react/dist/index.cjs.map +1 -1
  61. package/realtime-react/dist/index.d.ts +67 -0
  62. package/realtime-react/dist/index.js +4 -4
  63. package/realtime-server/dist/index.cjs +9 -64
  64. package/realtime-server/dist/index.cjs.map +1 -1
  65. package/realtime-server/dist/index.d.cts +4 -1
  66. package/realtime-server/dist/index.d.ts +408 -0
  67. package/realtime-server/dist/index.js +1 -1
  68. package/realtime-testing/dist/index.cjs +104 -79
  69. package/realtime-testing/dist/index.cjs.map +1 -1
  70. package/realtime-testing/dist/index.d.cts +4 -1
  71. package/realtime-testing/dist/index.d.ts +535 -0
  72. package/realtime-testing/dist/index.js +4 -4
  73. package/src/atom.ts +3 -1
  74. package/transceivers/set-rtx/dist/index.cjs +2 -1
  75. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  76. package/transceivers/set-rtx/dist/index.d.ts +66 -0
  77. package/transceivers/set-rtx/dist/index.js +1 -1
  78. package/dist/chunk-TE3ZSTQ6.js.map +0 -1
  79. package/internal/src/mutable/is-atom-token-mutable.ts +0 -7
  80. /package/dist/{chunk-KW7RA7IM.js.map → chunk-C4YZZNRH.js.map} +0 -0
  81. /package/dist/{chunk-LFXB7Y6M.js.map → chunk-CWKKQKVQ.js.map} +0 -0
  82. /package/dist/{chunk-CK7GNCU5.js.map → chunk-GMN5KH6A.js.map} +0 -0
  83. /package/dist/{chunk-5VJ77LZE.js.map → chunk-N7ADBQJG.js.map} +0 -0
@@ -1,3 +1,3 @@
1
- export { FamilyTracker, Future, IMPLICIT, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, eldest, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember } from '../../dist/chunk-TE3ZSTQ6.js';
1
+ export { FamilyTracker, Future, IMPLICIT, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, eldest, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, isAtomDefault, isAtomKey, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember } from '../../dist/chunk-PURABO5G.js';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -6,10 +6,11 @@ import type {
6
6
  UpdateHandler,
7
7
  } from "atom.io"
8
8
  import { setState } from "atom.io"
9
+ import { Json } from "atom.io/json"
9
10
 
10
11
  import { cacheValue } from "../caching"
11
12
  import { newest } from "../lineage"
12
- import { createMutableAtom } from "../mutable"
13
+ import { Transceiver, createMutableAtom } from "../mutable"
13
14
  import type { Store } from "../store"
14
15
  import { deposit } from "../store"
15
16
  import { Subject } from "../subject"
@@ -19,6 +20,7 @@ import { markAtomAsDefault } from "./is-default"
19
20
  export type Atom<T> = {
20
21
  key: string
21
22
  type: `atom`
23
+ mutable?: boolean
22
24
  family?: FamilyMetadata
23
25
  install: (store: Store) => void
24
26
  subject: Subject<{ newValue: T; oldValue: T }>
@@ -39,10 +39,6 @@ export function createAtomFamily<T, K extends Json.Serializable>(
39
39
  if (options.effects) {
40
40
  individualOptions.effects = options.effects(key)
41
41
  }
42
- // if (`toJson` in options && `fromJson` in options) {
43
- // individualOptions.toJson = options.toJson
44
- // individualOptions.fromJson
45
- // }
46
42
  token = createAtom<T>(individualOptions, family, store)
47
43
  subject.next(token)
48
44
  }
@@ -54,6 +50,9 @@ export function createAtomFamily<T, K extends Json.Serializable>(
54
50
  subject,
55
51
  } as const,
56
52
  )
53
+ if (`mutable` in options && typeof options.mutable === `boolean`) {
54
+ Object.assign(atomFamily, { mutable: options.mutable })
55
+ }
57
56
  const target = newest(store)
58
57
  target.families.set(options.key, atomFamily)
59
58
  return atomFamily
@@ -0,0 +1,23 @@
1
+ import type { AtomFamily, MutableAtomFamily, SelectorFamily } from "atom.io"
2
+ import type { Json } from "atom.io/json"
3
+
4
+ import { newest } from "../lineage"
5
+ import type { Store } from "../store"
6
+ import type { Signal, Transceiver } from "./transceiver"
7
+
8
+ export const getUpdateFamily = <
9
+ Core extends Transceiver<Json.Serializable>,
10
+ SerializableCore extends Json.Serializable,
11
+ Key extends string,
12
+ >(
13
+ mutableAtomFamily: MutableAtomFamily<Core, SerializableCore, Key>,
14
+ store: Store,
15
+ ): AtomFamily<Signal<Core> | null, Key> => {
16
+ const target = newest(store)
17
+ const key = `*${mutableAtomFamily.key}`
18
+ const updateFamily = target.families.get(key) as AtomFamily<
19
+ Signal<Core> | null,
20
+ Key
21
+ >
22
+ return updateFamily
23
+ }
@@ -5,7 +5,7 @@ export * from "./create-mutable-atom-family"
5
5
  export * from "./get-json-family"
6
6
  export * from "./get-json-token"
7
7
  export * from "./get-update-token"
8
- export * from "./is-atom-token-mutable"
8
+ export * from "./get-update-family"
9
9
  export * from "./tracker"
10
10
  export * from "./tracker-family"
11
11
  export * from "./transceiver"
@@ -13,6 +13,3 @@ export * from "./transceiver"
13
13
  export interface MutableAtom<T> extends Atom<T> {
14
14
  mutable: true
15
15
  }
16
-
17
- export const isAtomMutable = <T>(atom: Atom<T>): atom is MutableAtom<T> =>
18
- `isMutable` in atom
@@ -0,0 +1,44 @@
1
+ import type {
2
+ AtomFamily,
3
+ AtomToken,
4
+ MutableAtomFamily,
5
+ MutableAtomToken,
6
+ } from "~/packages/atom.io/src"
7
+ import type { MutableAtom } from "."
8
+ import type { Atom } from "../atom"
9
+ import type { Store } from "../store"
10
+ import { withdraw } from "../store"
11
+
12
+ export function isMutable(
13
+ token: AtomToken<any>,
14
+ store: Store,
15
+ ): token is MutableAtomToken<any, any>
16
+ export function isMutable(atom: Atom<any>): atom is MutableAtom<any>
17
+ export function isMutable(
18
+ family: AtomFamily<any, any>,
19
+ ): family is MutableAtomFamily<any, any, any>
20
+ export function isMutable(
21
+ atomOrTokenOrFamily: Atom<any> | AtomFamily<any, any> | AtomToken<any>,
22
+ store?: Store,
23
+ ): boolean {
24
+ if (`mutable` in atomOrTokenOrFamily) {
25
+ return atomOrTokenOrFamily.mutable
26
+ }
27
+ if (atomOrTokenOrFamily.type === `atom_family`) {
28
+ return false
29
+ }
30
+ if (`default` in atomOrTokenOrFamily) {
31
+ return false
32
+ }
33
+ if (!store) {
34
+ throw new Error(`Cannot check mutability without a store`)
35
+ }
36
+ const atom = withdraw(atomOrTokenOrFamily, store)
37
+ if (!atom) {
38
+ throw new Error(`Cannot check mutability without an atom`)
39
+ }
40
+ if (`mutable` in atom) {
41
+ return atom.mutable
42
+ }
43
+ return false
44
+ }
@@ -20,7 +20,8 @@ export class Tracker<Mutable extends Transceiver<any>> {
20
20
  store: Store,
21
21
  ): AtomToken<typeof this.Update | null> {
22
22
  const latestUpdateStateKey = `*${mutableState.key}`
23
- deleteAtom({ type: `atom`, key: latestUpdateStateKey }, store)
23
+ store.atoms.delete(latestUpdateStateKey)
24
+ store.valueMap.delete(latestUpdateStateKey)
24
25
  const familyMetaData: FamilyMetadata | undefined = mutableState.family
25
26
  ? {
26
27
  key: `*${mutableState.family.key}`,
@@ -37,6 +38,10 @@ export class Tracker<Mutable extends Transceiver<any>> {
37
38
  familyMetaData,
38
39
  store,
39
40
  )
41
+ if (store.parent) {
42
+ const parentValue = store.parent.valueMap.get(latestUpdateStateKey)
43
+ store.valueMap.set(latestUpdateStateKey, parentValue)
44
+ }
40
45
 
41
46
  return latestUpdateState
42
47
  }
@@ -137,7 +142,9 @@ export class Tracker<Mutable extends Transceiver<any>> {
137
142
  () => {
138
143
  unsubscribe()
139
144
  const mutable = getState(mutableState, store)
140
- const updateNumber = mutable.getUpdateNumber(newValue)
145
+ // debugger
146
+ const updateNumber =
147
+ newValue === null ? -1 : mutable.getUpdateNumber(newValue)
141
148
  const eventOffset = updateNumber - mutable.cacheUpdateNumber
142
149
  if (newValue && eventOffset === 1) {
143
150
  // ❗ new:"0=add:\"myHand\"",old:"0=add:\"deckId\""
@@ -14,7 +14,8 @@ export class Subject<T> {
14
14
  }
15
15
 
16
16
  public next(value: T): void {
17
- for (const subscriber of this.subscribers.values()) {
17
+ const subscribers = this.subscribers.values()
18
+ for (const subscriber of subscribers) {
18
19
  subscriber(value)
19
20
  }
20
21
  }
@@ -2,6 +2,7 @@ import type { TransactionUpdate, ƒn } from "atom.io"
2
2
  import type { AtomToken, TimelineUpdate } from "atom.io"
3
3
 
4
4
  import { newest } from "../lineage"
5
+ import { getUpdateToken } from "../mutable"
5
6
  import type { Store } from "../store"
6
7
  import { withdraw } from "../store"
7
8
  import type {
@@ -15,13 +16,21 @@ export const addAtomToTimeline = (
15
16
  tl: Timeline,
16
17
  store: Store,
17
18
  ): void => {
18
- const atom = withdraw(atomToken, store)
19
+ let maybeAtom = withdraw(atomToken, store)
20
+ if (maybeAtom?.mutable) {
21
+ console.log(`adding transceiver to timeline`, atomToken.key)
22
+ const updateToken = getUpdateToken(atomToken)
23
+ maybeAtom = withdraw(updateToken, store)
24
+ }
25
+ const atom = maybeAtom
19
26
  if (atom === undefined) {
20
27
  throw new Error(
21
28
  `Cannot subscribe to atom "${atomToken.key}" because it has not been initialized in store "${store.config.name}"`,
22
29
  )
23
30
  }
31
+
24
32
  atom.subject.subscribe(`timeline`, (update) => {
33
+ // debugger
25
34
  const target = newest(store)
26
35
  const currentSelectorKey =
27
36
  store.operation.open && store.operation.token.type === `selector`
@@ -9,7 +9,10 @@ import type {
9
9
  } from "atom.io"
10
10
 
11
11
  import { newest } from "../lineage"
12
- import type { Store } from "../store"
12
+ import { getUpdateToken } from "../mutable"
13
+ import { getUpdateFamily } from "../mutable/get-update-family"
14
+ import { isMutable } from "../mutable/is-mutable"
15
+ import { type Store, withdraw } from "../store"
13
16
  import { Subject } from "../subject"
14
17
  import { addAtomToTimeline } from "./add-atom-to-timeline"
15
18
 
@@ -70,21 +73,26 @@ export function createTimeline(
70
73
  if (options.shouldCapture) {
71
74
  tl.shouldCapture = options.shouldCapture
72
75
  }
73
-
76
+ const timelineKey = options.key
74
77
  const target = newest(store)
75
78
  for (const tokenOrFamily of options.atoms) {
76
- const timelineKey = target.timelineAtoms.getRelatedKey(tokenOrFamily.key)
77
- if (timelineKey) {
79
+ let atomKey = tokenOrFamily.key
80
+ const existingTimelineKey = target.timelineAtoms.getRelatedKey(atomKey)
81
+ if (existingTimelineKey) {
78
82
  store.logger.error(
79
83
  `❌`,
80
84
  `timeline`,
81
85
  options.key,
82
- `Failed to add atom "${tokenOrFamily.key}" because it already belongs to timeline "${timelineKey}"`,
86
+ `Failed to add atom "${atomKey}" because it already belongs to timeline "${existingTimelineKey}"`,
83
87
  )
84
88
  continue
85
89
  }
86
90
  if (tokenOrFamily.type === `atom_family`) {
87
- const family = tokenOrFamily
91
+ let family = tokenOrFamily
92
+ if (isMutable(family)) {
93
+ family = getUpdateFamily(family, store)
94
+ atomKey = family.key
95
+ }
88
96
  family.subject.subscribe(`timeline:${options.key}`, (token) => {
89
97
  addAtomToTimeline(token, tl, store)
90
98
  })
@@ -94,32 +102,52 @@ export function createTimeline(
94
102
  }
95
103
  }
96
104
  } else {
97
- const token = tokenOrFamily
98
- if (`family` in token && token.family) {
105
+ let atom = withdraw(tokenOrFamily, store)
106
+ if (atom === undefined) {
107
+ store.logger.error(
108
+ `❌`,
109
+ `timeline`,
110
+ options.key,
111
+ `Failed to add atom "${atomKey}" because it does not exist in the store`,
112
+ )
113
+ continue
114
+ }
115
+ if (isMutable(atom)) {
116
+ const updateAtom = withdraw(getUpdateToken(atom), store)
117
+ if (updateAtom === undefined) {
118
+ store.logger.error(
119
+ `❌`,
120
+ `timeline`,
121
+ options.key,
122
+ `Failed to add update atom "${atomKey}" because it does not exist in the store`,
123
+ )
124
+ continue
125
+ }
126
+ atom = updateAtom
127
+ atomKey = atom.key
128
+ }
129
+ if (`family` in atom) {
99
130
  const familyTimelineKey = target.timelineAtoms.getRelatedKey(
100
- token.family.key,
131
+ atom.family.key,
101
132
  )
102
133
  if (familyTimelineKey) {
103
134
  store.logger.error(
104
135
  `❌`,
105
136
  `timeline`,
106
137
  options.key,
107
- `Failed to add atom "${token.key}" because its family "${token.family.key}" already belongs to timeline "${familyTimelineKey}"`,
138
+ `Failed to add atom "${atom.key}" because its family "${atom.family.key}" already belongs to timeline "${familyTimelineKey}"`,
108
139
  )
109
140
  continue
110
141
  }
111
142
  }
112
- addAtomToTimeline(token, tl, store)
143
+ addAtomToTimeline(atom, tl, store)
113
144
  }
114
- target.timelineAtoms = target.timelineAtoms.set({
115
- atomKey: tokenOrFamily.key,
116
- timelineKey: options.key,
117
- })
145
+ target.timelineAtoms.set({ atomKey, timelineKey })
118
146
  }
119
147
 
120
148
  store.timelines.set(options.key, tl)
121
149
  const token: TimelineToken = {
122
- key: options.key,
150
+ key: timelineKey,
123
151
  type: `timeline`,
124
152
  }
125
153
  store.subject.timelineCreation.next(token)
@@ -274,7 +274,8 @@ var Subject = class {
274
274
  this.subscribers.delete(key);
275
275
  }
276
276
  next(value) {
277
- for (const subscriber of this.subscribers.values()) {
277
+ const subscribers = this.subscribers.values();
278
+ for (const subscriber of subscribers) {
278
279
  subscriber(value);
279
280
  }
280
281
  }
@@ -1081,35 +1082,6 @@ function createSelector(options, family, store) {
1081
1082
  return createReadonlySelector(options, family, store);
1082
1083
  }
1083
1084
 
1084
- // internal/src/selector/delete-selector.ts
1085
- function deleteSelector(selectorToken, store) {
1086
- const target = newest(store);
1087
- const { key } = selectorToken;
1088
- switch (selectorToken.type) {
1089
- case `selector`:
1090
- target.selectors.delete(key);
1091
- break;
1092
- case `readonly_selector`:
1093
- target.readonlySelectors.delete(key);
1094
- break;
1095
- }
1096
- target.valueMap.delete(key);
1097
- target.selectorAtoms.delete(key);
1098
- const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
1099
- ([downstreamSelectorKey]) => {
1100
- var _a;
1101
- return (_a = target.selectors.get(downstreamSelectorKey)) != null ? _a : target.readonlySelectors.get(downstreamSelectorKey);
1102
- }
1103
- );
1104
- for (const downstreamToken of downstreamTokens) {
1105
- if (downstreamToken) {
1106
- deleteSelector(downstreamToken, store);
1107
- }
1108
- }
1109
- target.selectorGraph.delete(key);
1110
- store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
1111
- }
1112
-
1113
1085
  // internal/src/subscribe/recall-state.ts
1114
1086
  var recallState = (state, store) => {
1115
1087
  const target = newest(store);
@@ -1228,7 +1200,8 @@ var Tracker = class {
1228
1200
  }
1229
1201
  initializeState(mutableState, store) {
1230
1202
  const latestUpdateStateKey = `*${mutableState.key}`;
1231
- deleteAtom({ type: `atom`, key: latestUpdateStateKey }, store);
1203
+ store.atoms.delete(latestUpdateStateKey);
1204
+ store.valueMap.delete(latestUpdateStateKey);
1232
1205
  const familyMetaData = mutableState.family ? {
1233
1206
  key: `*${mutableState.family.key}`,
1234
1207
  subKey: mutableState.family.subKey
@@ -1241,6 +1214,10 @@ var Tracker = class {
1241
1214
  familyMetaData,
1242
1215
  store
1243
1216
  );
1217
+ if (store.parent) {
1218
+ const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
1219
+ store.valueMap.set(latestUpdateStateKey, parentValue);
1220
+ }
1244
1221
  return latestUpdateState;
1245
1222
  }
1246
1223
  observeCore(mutableState, latestUpdateState, store) {
@@ -1321,7 +1298,7 @@ var Tracker = class {
1321
1298
  () => {
1322
1299
  unsubscribe();
1323
1300
  const mutable = getState(mutableState, store);
1324
- const updateNumber = mutable.getUpdateNumber(newValue);
1301
+ const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
1325
1302
  const eventOffset = updateNumber - mutable.cacheUpdateNumber;
1326
1303
  if (newValue && eventOffset === 1) {
1327
1304
  setState(
@@ -1396,6 +1373,9 @@ function createAtomFamily(options, store) {
1396
1373
  subject
1397
1374
  }
1398
1375
  );
1376
+ if (`mutable` in options && typeof options.mutable === `boolean`) {
1377
+ Object.assign(atomFamily, { mutable: options.mutable });
1378
+ }
1399
1379
  const target = newest(store);
1400
1380
  target.families.set(options.key, atomFamily);
1401
1381
  return atomFamily;
@@ -1554,38 +1534,6 @@ function createAtom(options, family, store) {
1554
1534
  return token;
1555
1535
  }
1556
1536
 
1557
- // internal/src/atom/delete-atom.ts
1558
- function deleteAtom(atomToken, store) {
1559
- var _a, _b;
1560
- const target = newest(store);
1561
- const { key } = atomToken;
1562
- const atom = target.atoms.get(key);
1563
- if (!atom) {
1564
- store.logger.error(
1565
- `\u274C`,
1566
- `atom`,
1567
- `${key}`,
1568
- `Tried to delete atom, but it does not exist in the store.`
1569
- );
1570
- }
1571
- (_a = atom == null ? void 0 : atom.cleanup) == null ? void 0 : _a.call(atom);
1572
- target.atoms.delete(key);
1573
- target.valueMap.delete(key);
1574
- const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
1575
- if (selectorKeys) {
1576
- for (const selectorKey of selectorKeys) {
1577
- const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
1578
- if (token) {
1579
- deleteSelector(token, store);
1580
- }
1581
- }
1582
- }
1583
- target.selectorAtoms.delete(key);
1584
- target.atomsThatAreDefault.delete(key);
1585
- target.timelineAtoms.delete(key);
1586
- store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
1587
- }
1588
-
1589
1537
  // internal/src/not-found-error.ts
1590
1538
  var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
1591
1539
  function prettyPrintTokenType(token) {