atom.io 0.29.5 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/data/dist/index.d.ts +84 -51
  2. package/data/dist/index.js +35 -31
  3. package/data/src/join.ts +240 -134
  4. package/dist/chunk-ADMEAXYU.js +167 -0
  5. package/dist/{chunk-TCINPEYE.js → chunk-SMKF3ZNG.js} +221 -137
  6. package/dist/index.d.ts +75 -10
  7. package/dist/index.js +3 -17
  8. package/internal/dist/index.d.ts +76 -41
  9. package/internal/dist/index.js +2 -1
  10. package/internal/src/atom/dispose-atom.ts +4 -8
  11. package/internal/src/index.ts +1 -1
  12. package/internal/src/ingest-updates/ingest-creation-disposal.ts +71 -27
  13. package/internal/src/junction.ts +152 -84
  14. package/internal/src/molecule/create-molecule-family.ts +2 -2
  15. package/internal/src/molecule/dispose-molecule.ts +4 -2
  16. package/internal/src/molecule/make-molecule-in-store.ts +11 -9
  17. package/internal/src/molecule/molecule-internal.ts +12 -8
  18. package/internal/src/mutable/create-mutable-atom-family.ts +2 -2
  19. package/internal/src/mutable/get-json-family.ts +2 -2
  20. package/internal/src/store/store.ts +10 -2
  21. package/internal/src/timeline/create-timeline.ts +99 -71
  22. package/internal/src/transaction/index.ts +1 -1
  23. package/internal/src/utility-types.ts +9 -2
  24. package/json/dist/index.d.ts +3 -3
  25. package/json/dist/index.js +2 -1
  26. package/json/src/entries.ts +3 -3
  27. package/package.json +15 -15
  28. package/react-devtools/dist/index.js +9 -5
  29. package/react-devtools/src/TimelineIndex.tsx +4 -1
  30. package/react-devtools/src/Updates.tsx +18 -3
  31. package/realtime/dist/index.d.ts +1 -1
  32. package/realtime/dist/index.js +3 -1
  33. package/realtime/src/shared-room-store.ts +2 -0
  34. package/realtime-server/dist/index.d.ts +13 -4
  35. package/realtime-server/dist/index.js +4 -2
  36. package/realtime-server/src/realtime-continuity-synchronizer.ts +2 -2
  37. package/realtime-server/src/realtime-server-stores/server-user-store.ts +17 -1
  38. package/realtime-testing/dist/index.d.ts +3 -0
  39. package/realtime-testing/dist/index.js +11 -4
  40. package/realtime-testing/src/setup-realtime-test.tsx +12 -4
  41. package/src/allocate.ts +277 -0
  42. package/src/index.ts +1 -0
  43. package/src/molecule.ts +9 -5
  44. package/src/transaction.ts +22 -4
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
+ export { $provenance, T$, allocateIntoStore, deallocateFromStore, makeMolecule, makeRootMoleculeInStore, moleculeFamily, realm } from './chunk-ADMEAXYU.js';
1
2
  import './chunk-XWL6SNVU.js';
2
3
  import * as Internal from 'atom.io/internal';
3
- import { createStandaloneAtom, IMPLICIT, createAtomFamily, createMoleculeFamily, makeMoleculeInStore, Molecule, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, findInStore, getFromStore, setIntoStore, disposeFromStore, subscribeInStore, timeTravel, actUponStore, arbitrary } from 'atom.io/internal';
4
- import { stringifyJson } from 'atom.io/json';
4
+ import { createStandaloneAtom, IMPLICIT, createAtomFamily, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, findInStore, getFromStore, setIntoStore, disposeFromStore, subscribeInStore, timeTravel, createMoleculeFamily, makeMoleculeInStore, actUponStore, arbitrary } from 'atom.io/internal';
5
5
 
6
6
  function atom(options) {
7
7
  return createStandaloneAtom(IMPLICIT.STORE, options);
@@ -58,20 +58,6 @@ var AtomIOLogger = class {
58
58
  }
59
59
  };
60
60
  };
61
- function moleculeFamily(options) {
62
- return createMoleculeFamily(IMPLICIT.STORE, options);
63
- }
64
- function makeMolecule(context, family, key, ...params) {
65
- return makeMoleculeInStore(IMPLICIT.STORE, context, family, key, ...params);
66
- }
67
- function makeRootMolecule(key, store = IMPLICIT.STORE) {
68
- const molecule = new Molecule(void 0, key);
69
- store.molecules.set(stringifyJson(key), molecule);
70
- return {
71
- key,
72
- type: `molecule`
73
- };
74
- }
75
61
  function selector(options) {
76
62
  return createStandaloneSelector(IMPLICIT.STORE, options);
77
63
  }
@@ -163,4 +149,4 @@ function belongsTo(family, unknownToken) {
163
149
  return family.key === unknownToken.family?.key;
164
150
  }
165
151
 
166
- export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, belongsTo, disposeState, getState, isToken, makeMolecule, makeRootMolecule, moleculeFamily, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
152
+ export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, belongsTo, disposeState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
@@ -1,5 +1,5 @@
1
1
  import * as atom_io from 'atom.io';
2
- import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, RegularAtomToken, AtomFamilyToken, AtomToken, WritableSelectorFamilyToken, WritableSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, SelectorFamilyToken, SelectorToken, WritableFamilyToken, WritableToken, ReadableFamilyToken, ReadableToken, MoleculeConstructor, MoleculeFamilyToken, MoleculeKey, TransactionToken, TransactionUpdate, TransactionOptions, ActorToolkit, MoleculeFamily, MoleculeToken, MoleculeFamilyOptions, StateCreation, StateDisposal, MoleculeParams, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, MoleculeCreation, MoleculeDisposal, TimelineUpdate, TimelineOptions, TimelineToken, AtomIOLogger, Logger, MutableAtomOptions, MutableAtomFamilyOptions, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, KeyedStateUpdate, ReadonlySelectorOptions, WritableSelectorOptions, SetterToolkit, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
2
+ import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, RegularAtomToken, AtomFamilyToken, AtomToken, WritableSelectorFamilyToken, WritableSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, SelectorFamilyToken, SelectorToken, WritableFamilyToken, WritableToken, ReadableFamilyToken, ReadableToken, MoleculeConstructor, MoleculeFamilyToken, MoleculeKey, TransactionToken, TransactionUpdate, TransactionOptions, ActorToolkit, MoleculeFamily, MoleculeToken, MoleculeFamilyOptions, StateCreation, StateDisposal, MoleculeParams, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, MoleculeCreation, MoleculeDisposal, TimelineUpdate, TimelineOptions, TimelineToken, MoleculeCreationModern, MoleculeDisposalModern, AtomIOLogger, Logger, MutableAtomOptions, MutableAtomFamilyOptions, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, KeyedStateUpdate, ReadonlySelectorOptions, WritableSelectorOptions, SetterToolkit, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
3
3
  import { Json, Canonical, JsonInterface } from 'atom.io/json';
4
4
  import { Join } from 'atom.io/data';
5
5
  import { Refinement } from 'atom.io/introspection';
@@ -22,20 +22,24 @@ declare function counterfeit<T, K extends Canonical, Key extends K>(token: Writa
22
22
  declare function counterfeit<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T>;
23
23
  declare function counterfeit<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: MoleculeKey<M>): MoleculeKey<M>;
24
24
 
25
- interface JunctionEntries<Content extends Json.Object | null> extends Json.Object {
26
- readonly relations: [string, string[]][];
25
+ type JunctionEntriesBase<AType extends string, BType extends string, Content extends Json.Object | null> = {
26
+ readonly relations: ([AType, BType[]] | [BType, AType[]])[];
27
27
  readonly contents: [string, Content][];
28
+ };
29
+ interface JunctionEntries<AType extends string, BType extends string, Content extends Json.Object | null> extends Json.Object, JunctionEntriesBase<AType, BType, Content> {
28
30
  }
29
- interface JunctionSchema<ASide extends string, BSide extends string> extends Json.Object {
31
+ type JunctionSchemaBase<ASide extends string, BSide extends string> = {
30
32
  readonly between: [a: ASide, b: BSide];
31
33
  readonly cardinality: `1:1` | `1:n` | `n:n`;
34
+ };
35
+ interface JunctionSchema<ASide extends string, BSide extends string> extends Json.Object, JunctionSchemaBase<ASide, BSide> {
32
36
  }
33
37
  type BaseExternalStoreConfiguration = {
34
38
  addRelation: (a: string, b: string) => void;
35
39
  deleteRelation: (a: string, b: string) => void;
36
40
  replaceRelationsSafely: (a: string, bs: string[]) => void;
37
41
  replaceRelationsUnsafely: (a: string, bs: string[]) => void;
38
- getRelatedKeys: (key: string) => Set<string> | undefined;
42
+ getRelatedKeys(key: string): Set<string> | undefined;
39
43
  has: (a: string, b?: string) => boolean;
40
44
  };
41
45
  type ExternalStoreWithContentConfiguration<Content extends Json.Object> = {
@@ -47,45 +51,68 @@ type Empty<Obj extends object> = {
47
51
  [Key in keyof Obj]?: undefined;
48
52
  };
49
53
  type ExternalStoreConfiguration<Content extends Json.Object | null> = Content extends Json.Object ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Json.Object>>;
50
- type JunctionAdvancedConfiguration<Content extends Json.Object | null> = {
54
+ type JunctionAdvancedConfiguration<AType extends string, BType extends string, Content extends Json.Object | null> = {
51
55
  warn?: (...args: any[]) => void;
52
56
  externalStore?: ExternalStoreConfiguration<Content>;
57
+ isAType?: Refinement<string, AType>;
58
+ isBType?: Refinement<string, BType>;
53
59
  isContent?: Refinement<unknown, Content>;
54
- makeContentKey?: (a: string, b: string) => string;
60
+ makeContentKey?: (a: AType, b: BType) => string;
55
61
  };
56
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Json.Object | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
57
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Json.Object | null = null> {
62
+ type JunctionJSON<ASide extends string, AType extends string, BSide extends string, BType extends string, Content extends Json.Object | null> = JunctionEntries<AType, BType, Content> & JunctionSchema<ASide, BSide>;
63
+ declare class Junction<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Content extends Json.Object | null = null> {
58
64
  readonly a: ASide;
59
65
  readonly b: BSide;
60
66
  readonly cardinality: `1:1` | `1:n` | `n:n`;
61
- readonly relations: Map<string, Set<string>>;
67
+ readonly relations: Map<AType | BType, Set<AType> | Set<BType>>;
62
68
  readonly contents: Map<string, Content>;
63
69
  isContent: Refinement<unknown, Content> | null;
64
- makeContentKey: (a: string, b: string) => string;
70
+ makeContentKey: (a: AType, b: BType) => string;
65
71
  warn?: (...args: any[]) => void;
66
- getRelatedKeys(key: string): Set<string> | undefined;
67
- protected addRelation(a: string, b: string): void;
68
- protected deleteRelation(a: string, b: string): void;
69
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
70
- protected replaceRelationsSafely(a: string, bs: string[]): void;
72
+ getRelatedKeys(key: AType): Set<BType> | undefined;
73
+ getRelatedKeys(key: BType): Set<AType> | undefined;
74
+ getRelatedKeys(key: AType | BType): Set<AType> | Set<BType> | undefined;
75
+ protected addRelation(a: AType, b: BType): void;
76
+ protected deleteRelation(a: AType, b: BType): void;
77
+ protected replaceRelationsUnsafely(a: AType, bs: BType[]): void;
78
+ protected replaceRelationsUnsafely(b: BType, as: AType[]): void;
79
+ protected replaceRelationsSafely(a: AType, bs: BType[]): void;
80
+ protected replaceRelationsSafely(b: BType, as: AType[]): void;
71
81
  protected getContentInternal(contentKey: string): Content | undefined;
72
82
  protected setContent(contentKey: string, content: Content): void;
73
83
  protected deleteContent(contentKey: string): void;
74
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
75
- toJSON(): JunctionJSON<ASide, BSide, Content>;
76
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
84
+ constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<AType, BType, Content>>, config?: JunctionAdvancedConfiguration<AType, BType, Content>);
85
+ toJSON(): JunctionJSON<ASide, AType, BSide, BType, Content>;
86
+ set(a: AType, ...rest: Content extends null ? [b: BType] : [b: BType, content: Content]): this;
77
87
  set(relation: {
78
- [Key in ASide | BSide]: string;
79
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
80
- delete(a: string, b?: string): this;
81
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
82
- getRelatedKey(key: string): string | undefined;
83
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
88
+ [Key in ASide]: AType;
89
+ } & {
90
+ [Key in BSide]: BType;
91
+ }, ...rest: Content extends null ? [] | [void?: undefined] : [content: Content]): this;
92
+ delete(a: AType, b?: BType): this;
93
+ delete(b: BType, a?: AType): this;
94
+ delete(relation: {
95
+ [Key in ASide]: AType;
96
+ } | {
97
+ [Key in BSide]: BType;
98
+ } | ({
99
+ [Key in ASide]: AType;
100
+ } & {
101
+ [Key in BSide]: BType;
102
+ }), b?: undefined): this;
103
+ getRelatedKey(key: AType): BType | undefined;
104
+ getRelatedKey(key: BType): AType | undefined;
105
+ replaceRelations(a: AType, relations: Content extends null ? BType[] : Record<BType, Content>, config?: {
84
106
  reckless: boolean;
85
107
  }): this;
86
- getContent(a: string, b: string): Content | undefined;
87
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
88
- has(a: string, b?: string): boolean;
108
+ replaceRelations(b: BType, relations: Content extends null ? AType[] : Record<AType, Content>, config?: {
109
+ reckless: boolean;
110
+ }): this;
111
+ getContent(a: AType, b: BType): Content | undefined;
112
+ getRelationEntries(input: Record<ASide, AType>): [BType, Content][];
113
+ getRelationEntries(input: Record<BSide, BType>): [AType, Content][];
114
+ has(a: AType, b?: BType): boolean;
115
+ has(b: BType, a?: AType): boolean;
89
116
  }
90
117
 
91
118
  type Func = (...parameters: any[]) => any;
@@ -94,7 +121,13 @@ type Flat<R extends {
94
121
  }> = {
95
122
  [K in keyof R]: R[K];
96
123
  };
97
- type Range<N extends number, A extends any[] = []> = A[`length`] extends N ? A[`length`] : A[`length`] | Range<N, [...A, any]>;
124
+ type Count<N extends number, A extends any[] = []> = [
125
+ ...A,
126
+ any
127
+ ][`length`] extends N ? A[`length`] : A[`length`] | Count<N, [...A, any]>;
128
+ type Each<E extends any[]> = {
129
+ [P in Count<E[`length`]>]: E[P];
130
+ };
98
131
 
99
132
  declare const abortTransaction: (store: Store) => void;
100
133
 
@@ -157,7 +190,7 @@ type TransactionProgress<F extends Func> = {
157
190
  };
158
191
  type TransactionEpoch = {
159
192
  epoch: Map<string, number>;
160
- actionContinuities: Junction<`continuity`, `action`>;
193
+ actionContinuities: Junction<`continuity`, string, `action`, string>;
161
194
  };
162
195
 
163
196
  declare function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>;
@@ -198,13 +231,15 @@ declare class Molecule<M extends MoleculeConstructor> implements MoleculeToken<M
198
231
  readonly type = "molecule";
199
232
  stringKey: string;
200
233
  family?: MoleculeFamilyToken<M>;
234
+ _dependsOn: `all` | `any`;
235
+ get dependsOn(): `all` | `any`;
201
236
  readonly subject: Subject<StateCreation<any> | StateDisposal<any>>;
202
237
  tokens: Map<string, ReadableToken<any>>;
203
238
  above: Map<string, Molecule<any>>;
204
239
  below: Map<string, Molecule<any>>;
205
- joins: Map<string, Join<any, any, any, any>>;
240
+ joins: Map<string, Join<any, any, any, any, any, any>>;
206
241
  instance: InstanceType<M>;
207
- constructor(ctx: Molecule<any> | Molecule<any>[] | undefined, key: MoleculeKey<M>, family?: MoleculeFamilyToken<M>);
242
+ constructor(ctx: Molecule<any>[] | undefined, key: MoleculeKey<M>, family?: MoleculeFamilyToken<M>);
208
243
  }
209
244
 
210
245
  declare function growMoleculeInStore<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(molecule: Molecule<any>, family: MutableAtomFamilyToken<T, J, K>, store: Store): MutableAtomToken<T, J>;
@@ -298,8 +333,8 @@ declare class Store implements Lineage {
298
333
  selectors: Map<string, WritableSelector<any>>;
299
334
  readonlySelectors: Map<string, ReadonlySelector<any>>;
300
335
  atomsThatAreDefault: Set<string>;
301
- selectorAtoms: Junction<"selectorKey", "atomKey", null>;
302
- selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
336
+ selectorAtoms: Junction<"selectorKey", string, "atomKey", string, null>;
337
+ selectorGraph: Junction<"upstreamSelectorKey", string, "downstreamSelectorKey", string, {
303
338
  source: string;
304
339
  }>;
305
340
  trackers: Map<string, Tracker<Transceiver<any>>>;
@@ -307,7 +342,7 @@ declare class Store implements Lineage {
307
342
  transactions: Map<string, Transaction<Func>>;
308
343
  transactionMeta: TransactionEpoch | TransactionProgress<Func>;
309
344
  timelines: Map<string, Timeline<any>>;
310
- timelineTopics: Junction<"timelineKey", "topicKey", {
345
+ timelineTopics: Junction<"timelineKey", string, "topicKey", string, {
311
346
  topicType: `atom_family` | `atom` | `molecule_family` | `molecule`;
312
347
  }>;
313
348
  disposalTraces: CircularBuffer<{
@@ -316,7 +351,7 @@ declare class Store implements Lineage {
316
351
  }>;
317
352
  molecules: Map<string, Molecule<any>>;
318
353
  moleculeFamilies: Map<string, Flat<atom_io.MoleculeFamilyToken<any> & {
319
- subject: Subject<atom_io.MoleculeCreation<any> | atom_io.MoleculeDisposal>;
354
+ subject: Subject<atom_io.MoleculeCreationClassic<any> | atom_io.MoleculeDisposalClassic>;
320
355
  dependsOn: `all` | `any`;
321
356
  new: any;
322
357
  }>>;
@@ -331,9 +366,9 @@ declare class Store implements Lineage {
331
366
  transactionCreation: Subject<TransactionToken<Func>>;
332
367
  transactionApplying: StatefulSubject<TransactionProgress<Func> | null>;
333
368
  operationClose: Subject<OperationProgress>;
334
- moleculeCreationStart: Subject<MoleculeToken<any>>;
369
+ moleculeCreationStart: Subject<MoleculeToken<any> | MoleculeCreationModern>;
335
370
  moleculeCreationDone: Subject<MoleculeToken<any>>;
336
- moleculeDisposal: Subject<MoleculeToken<any>>;
371
+ moleculeDisposal: Subject<MoleculeToken<any> | MoleculeDisposalModern>;
337
372
  };
338
373
  operation: OperationProgress;
339
374
  config: {
@@ -385,9 +420,9 @@ type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<infer S> ? S
385
420
 
386
421
  declare function createMutableAtom<T extends Transceiver<any>, J extends Json.Serializable>(store: Store, options: MutableAtomOptions<T, J>, family: FamilyMetadata | undefined): MutableAtomToken<T, J>;
387
422
 
388
- declare function createMutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends string>(store: Store, options: MutableAtomFamilyOptions<T, J, K>, internalRoles?: string[]): MutableAtomFamilyToken<T, J, K>;
423
+ declare function createMutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(store: Store, options: MutableAtomFamilyOptions<T, J, K>, internalRoles?: string[]): MutableAtomFamilyToken<T, J, K>;
389
424
 
390
- declare const getJsonFamily: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable, Key extends string>(mutableAtomFamily: MutableAtomFamilyToken<Core, SerializableCore, Key>, store: Store) => WritableSelectorFamily<SerializableCore, Key>;
425
+ declare const getJsonFamily: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable, Key extends Canonical>(mutableAtomFamily: MutableAtomFamilyToken<Core, SerializableCore, Key>, store: Store) => WritableSelectorFamily<SerializableCore, Key>;
391
426
 
392
427
  declare const getJsonToken: <Core extends Transceiver<any>, SerializableCore extends Json.Serializable>(store: Store, mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => WritableSelectorToken<SerializableCore>;
393
428
 
@@ -664,4 +699,4 @@ type SelectorFamily<T, K extends Canonical> = ReadonlySelectorFamily<T, K> | Wri
664
699
  type WritableFamily<T, K extends Canonical> = AtomFamily<T, K> | WritableSelectorFamily<T, K>;
665
700
  type ReadableFamily<T, K extends Canonical> = AtomFamily<T, K> | SelectorFamily<T, K>;
666
701
 
667
- export { type Atom, type AtomFamily, type AtomIOState, type AtomIOToken, type AtomKey, type BaseExternalStoreConfiguration, type ChildStore, type Empty, type EnvironmentData, type ExternalStoreConfiguration, type ExternalStoreWithContentConfiguration, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, type Flat, type Func, Future, IMPLICIT, Junction, type JunctionAdvancedConfiguration, type JunctionEntries, type JunctionJSON, type JunctionSchema, LazyMap, type Lineage, type Modify, Molecule, type MutableAtom, type MutableAtomFamily, NotFoundError, type OperationProgress, type Range, type ReadableFamily, type ReadableState, type ReadonlySelector, type ReadonlySelectorFamily, type ReadonlySelectorKey, type RegularAtom, type RegularAtomFamily, type RootStore, type Selector, type SelectorFamily, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
702
+ export { type Atom, type AtomFamily, type AtomIOState, type AtomIOToken, type AtomKey, type BaseExternalStoreConfiguration, type ChildStore, type Count, type Each, type Empty, type EnvironmentData, type ExternalStoreConfiguration, type ExternalStoreWithContentConfiguration, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, type Flat, type Func, Future, IMPLICIT, Junction, type JunctionAdvancedConfiguration, type JunctionEntries, type JunctionEntriesBase, type JunctionJSON, type JunctionSchema, type JunctionSchemaBase, LazyMap, type Lineage, type Modify, Molecule, type MutableAtom, type MutableAtomFamily, NotFoundError, type OperationProgress, type ReadableFamily, type ReadableState, type ReadonlySelector, type ReadonlySelectorFamily, type ReadonlySelectorKey, type RegularAtom, type RegularAtomFamily, type RootStore, type Selector, type SelectorFamily, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
@@ -1,2 +1,3 @@
1
- export { FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Junction, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-TCINPEYE.js';
1
+ export { FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Junction, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-SMKF3ZNG.js';
2
+ import '../../dist/chunk-ADMEAXYU.js';
2
3
  import '../../dist/chunk-XWL6SNVU.js';
@@ -1,13 +1,7 @@
1
1
  import type { AtomToken } from "atom.io"
2
2
 
3
3
  import type { Store } from ".."
4
- import {
5
- disposeSelector,
6
- getUpdateToken,
7
- isChildStore,
8
- newest,
9
- withdraw,
10
- } from ".."
4
+ import { getUpdateToken, isChildStore, newest, withdraw } from ".."
11
5
 
12
6
  export function disposeAtom(atomToken: AtomToken<unknown>, store: Store): void {
13
7
  const target = newest(store)
@@ -24,6 +18,7 @@ export function disposeAtom(atomToken: AtomToken<unknown>, store: Store): void {
24
18
  token: atomToken,
25
19
  value: lastValue,
26
20
  })
21
+
27
22
  const molecule = target.molecules.get(atom.family.subKey)
28
23
  if (molecule) {
29
24
  molecule.tokens.delete(key)
@@ -32,7 +27,8 @@ export function disposeAtom(atomToken: AtomToken<unknown>, store: Store): void {
32
27
  target.valueMap.delete(key)
33
28
  target.selectorAtoms.delete(key)
34
29
  target.atomsThatAreDefault.delete(key)
35
- target.timelineTopics.delete(key)
30
+ store.timelineTopics.delete(key)
31
+
36
32
  if (atomToken.type === `mutable_atom`) {
37
33
  const updateToken = getUpdateToken(atomToken)
38
34
  disposeAtom(updateToken, store)
@@ -42,7 +42,7 @@ export * from "./subject"
42
42
  export * from "./subscribe"
43
43
  export * from "./timeline"
44
44
  export * from "./transaction"
45
- export * from "./utility-types"
45
+ export type * from "./utility-types"
46
46
 
47
47
  export type AtomIOState = {
48
48
  key: string
@@ -8,10 +8,11 @@ import type {
8
8
  import { parseJson, stringifyJson } from "atom.io/json"
9
9
 
10
10
  import {
11
- disposeFromStore,
12
- findInStore,
13
- initFamilyMemberInStore,
14
- } from "../families"
11
+ allocateIntoStore,
12
+ deallocateFromStore,
13
+ } from "~/packages/atom.io/src/allocate"
14
+
15
+ import { disposeFromStore, findInStore } from "../families"
15
16
  import { growMoleculeInStore, makeMoleculeInStore } from "../molecule"
16
17
  import { type Store, withdraw } from "../store"
17
18
 
@@ -70,16 +71,30 @@ export function ingestMoleculeCreationEvent(
70
71
  ): void {
71
72
  switch (applying) {
72
73
  case `newValue`:
73
- makeMoleculeInStore(
74
- store,
75
- update.context,
76
- update.family,
77
- update.token.key,
78
- ...update.params,
79
- )
74
+ switch (update.subType) {
75
+ case `classic`:
76
+ makeMoleculeInStore(
77
+ store,
78
+ update.context,
79
+ update.family,
80
+ update.token.key,
81
+ ...update.params,
82
+ )
83
+ break
84
+ case `modern`:
85
+ allocateIntoStore<any, any, any>(store, update.provenance, update.key)
86
+ break
87
+ }
80
88
  break
81
89
  case `oldValue`:
82
- disposeFromStore(store, update.token)
90
+ switch (update.subType) {
91
+ case `classic`:
92
+ disposeFromStore(store, update.token)
93
+ break
94
+ case `modern`:
95
+ deallocateFromStore<any, any, any>(store, update.key)
96
+ break
97
+ }
83
98
  break
84
99
  }
85
100
  }
@@ -90,25 +105,54 @@ export function ingestMoleculeDisposalEvent(
90
105
  ): void {
91
106
  switch (applying) {
92
107
  case `newValue`:
93
- disposeFromStore(store, update.token)
108
+ switch (update.subType) {
109
+ case `classic`:
110
+ disposeFromStore(store, update.token)
111
+ break
112
+ case `modern`:
113
+ deallocateFromStore<any, any, any>(store, update.key)
114
+ break
115
+ }
94
116
  break
95
117
  case `oldValue`:
96
118
  {
97
- const moleculeToken = makeMoleculeInStore(
98
- store,
99
- update.context,
100
- update.family,
101
- update.token.key,
102
- )
103
- for (const [familyKey, value] of update.values) {
104
- const memberKey = `${familyKey}(${stringifyJson(moleculeToken.key)})`
105
- const molecule = withdraw(moleculeToken, store)
106
- const alreadyCreated = molecule.tokens.has(memberKey)
107
- const family = store.families.get(familyKey)
108
- if (family && !alreadyCreated) {
109
- growMoleculeInStore(molecule, family, store)
119
+ // TODO: Handle classic vs modern molecules
120
+ switch (update.subType) {
121
+ case `classic`:
122
+ {
123
+ const moleculeToken = makeMoleculeInStore(
124
+ store,
125
+ update.context,
126
+ update.family,
127
+ update.token.key,
128
+ )
129
+ for (const [familyKey, value] of update.values) {
130
+ const memberKey = `${familyKey}(${stringifyJson(moleculeToken.key)})`
131
+ const molecule = withdraw(moleculeToken, store)
132
+ const alreadyCreated = molecule.tokens.has(memberKey)
133
+ const family = store.families.get(familyKey)
134
+ if (family && !alreadyCreated) {
135
+ growMoleculeInStore(molecule, family, store)
136
+ }
137
+ store.valueMap.set(memberKey, value)
138
+ }
139
+ }
140
+ break
141
+ case `modern`: {
142
+ allocateIntoStore<any, any, any>(
143
+ store,
144
+ update.provenance,
145
+ update.key,
146
+ )
147
+ for (const [familyKey, value] of update.values) {
148
+ const family = store.families.get(familyKey)
149
+ if (family) {
150
+ findInStore(store, family, update.key)
151
+ const memberKey = `${familyKey}(${stringifyJson(update.key)})`
152
+ store.valueMap.set(memberKey, value)
153
+ }
154
+ }
110
155
  }
111
- store.valueMap.set(memberKey, value)
112
156
  }
113
157
  }
114
158
  break