atom.io 0.30.6 → 0.31.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 (81) hide show
  1. package/data/dist/index.d.ts +20 -18
  2. package/data/dist/index.js +104 -172
  3. package/data/src/join.ts +138 -210
  4. package/dist/{chunk-LSCRHXLI.js → chunk-42UH5F5Q.js} +385 -773
  5. package/dist/chunk-ICGFFQ3H.js +272 -0
  6. package/dist/index.d.ts +52 -103
  7. package/dist/index.js +3 -11
  8. package/eslint-plugin/dist/index.d.ts +22 -3
  9. package/eslint-plugin/dist/index.js +7 -7
  10. package/immortal/dist/index.d.ts +1 -2
  11. package/immortal/dist/index.js +0 -3
  12. package/immortal/src/seek-state.ts +2 -14
  13. package/internal/dist/index.d.ts +59 -95
  14. package/internal/dist/index.js +2 -2
  15. package/internal/src/atom/dispose-atom.ts +31 -15
  16. package/internal/src/families/dispose-from-store.ts +15 -44
  17. package/internal/src/families/find-in-store.ts +15 -8
  18. package/internal/src/families/init-family-member.ts +1 -1
  19. package/internal/src/families/seek-in-store.ts +2 -14
  20. package/internal/src/get-state/get-from-store.ts +13 -79
  21. package/internal/src/get-trace.ts +7 -0
  22. package/internal/src/index.ts +2 -1
  23. package/internal/src/ingest-updates/ingest-creation-disposal.ts +63 -70
  24. package/internal/src/ingest-updates/ingest-transaction-update.ts +4 -0
  25. package/internal/src/junction.ts +52 -12
  26. package/internal/src/lineage.ts +0 -7
  27. package/internal/src/molecule.ts +7 -0
  28. package/internal/src/mutable/transceiver.ts +5 -5
  29. package/internal/src/pretty-print.ts +0 -4
  30. package/internal/src/selector/dispose-selector.ts +3 -5
  31. package/internal/src/selector/register-selector.ts +2 -26
  32. package/internal/src/set-state/set-into-store.ts +3 -2
  33. package/internal/src/store/counterfeit.ts +11 -25
  34. package/internal/src/store/deposit.ts +5 -39
  35. package/internal/src/store/index.ts +1 -0
  36. package/internal/src/store/store.ts +51 -12
  37. package/internal/src/store/withdraw.ts +3 -26
  38. package/internal/src/timeline/create-timeline.ts +133 -237
  39. package/internal/src/timeline/time-travel.ts +1 -8
  40. package/internal/src/transaction/build-transaction.ts +10 -5
  41. package/internal/src/transaction/index.ts +1 -1
  42. package/internal/src/utility-types.ts +2 -0
  43. package/introspection/dist/index.d.ts +2 -3
  44. package/introspection/dist/index.js +9 -9
  45. package/introspection/src/refinery.ts +1 -3
  46. package/json/dist/index.js +9 -40
  47. package/json/src/index.ts +2 -0
  48. package/json/src/select-json-family.ts +7 -44
  49. package/package.json +34 -29
  50. package/react/dist/index.js +2 -10
  51. package/react/src/parse-state-overloads.ts +3 -11
  52. package/react-devtools/dist/index.js +13 -13
  53. package/react-devtools/src/Updates.tsx +2 -0
  54. package/realtime-client/dist/index.d.ts +20 -12
  55. package/realtime-client/dist/index.js +241 -244
  56. package/realtime-client/src/continuity/index.ts +3 -0
  57. package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +231 -0
  58. package/realtime-client/src/continuity/use-conceal-state.ts +11 -0
  59. package/realtime-client/src/continuity/use-reveal-state.ts +19 -0
  60. package/realtime-client/src/index.ts +1 -0
  61. package/realtime-client/src/sync-continuity.ts +18 -262
  62. package/realtime-react/dist/index.js +2 -2
  63. package/realtime-server/dist/index.d.ts +1 -1
  64. package/realtime-server/dist/index.js +2 -2
  65. package/realtime-server/src/index.ts +1 -1
  66. package/realtime-testing/dist/index.js +2 -3
  67. package/realtime-testing/src/setup-realtime-test.tsx +1 -2
  68. package/src/allocate.ts +311 -145
  69. package/src/dispose-state.ts +5 -21
  70. package/src/get-state.ts +3 -21
  71. package/src/molecule.ts +11 -133
  72. package/src/silo.ts +1 -12
  73. package/src/timeline.ts +2 -3
  74. package/src/transaction.ts +25 -38
  75. package/dist/chunk-ADMEAXYU.js +0 -167
  76. package/internal/src/molecule/create-molecule-family.ts +0 -30
  77. package/internal/src/molecule/dispose-molecule.ts +0 -79
  78. package/internal/src/molecule/grow-molecule-in-store.ts +0 -95
  79. package/internal/src/molecule/index.ts +0 -5
  80. package/internal/src/molecule/make-molecule-in-store.ts +0 -191
  81. package/internal/src/molecule/molecule-internal.ts +0 -52
@@ -0,0 +1,272 @@
1
+ import { IMPLICIT, newest, isChildStore, findInStore, disposeFromStore, getTrace } from 'atom.io/internal';
2
+ import { stringifyJson, parseJson } from 'atom.io/json';
3
+
4
+ // src/molecule.ts
5
+ function makeRootMoleculeInStore(key, store = IMPLICIT.STORE) {
6
+ const molecule = {
7
+ key,
8
+ stringKey: stringifyJson(key),
9
+ dependsOn: `any`
10
+ };
11
+ store.molecules.set(stringifyJson(key), molecule);
12
+ return key;
13
+ }
14
+ var $claim = Symbol(`claim`);
15
+ function allocateIntoStore(store, provenance, key, dependsOn = `any`) {
16
+ const origin = provenance;
17
+ const stringKey = stringifyJson(key);
18
+ const invalidKeys = [];
19
+ const target = newest(store);
20
+ if (Array.isArray(origin)) {
21
+ for (const formerClaim of origin) {
22
+ const claimString = stringifyJson(formerClaim);
23
+ const claim = target.molecules.get(claimString);
24
+ if (claim) {
25
+ store.moleculeGraph.set(claimString, stringKey, { source: claimString });
26
+ } else {
27
+ invalidKeys.push(claimString);
28
+ }
29
+ }
30
+ } else {
31
+ const claimString = stringifyJson(origin);
32
+ const claim = target.molecules.get(claimString);
33
+ if (claim) {
34
+ store.moleculeGraph.set(claimString, stringKey, { source: claimString });
35
+ } else {
36
+ invalidKeys.push(claimString);
37
+ }
38
+ }
39
+ if (invalidKeys.length === 0) {
40
+ target.molecules.set(stringKey, { key, stringKey, dependsOn });
41
+ }
42
+ const creationEvent = {
43
+ type: `molecule_creation`,
44
+ key,
45
+ provenance: origin
46
+ };
47
+ const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
48
+ if (isTransaction) {
49
+ target.transactionMeta.update.updates.push(creationEvent);
50
+ } else {
51
+ target.on.moleculeCreation.next(creationEvent);
52
+ }
53
+ for (const claim of invalidKeys) {
54
+ const disposal = store.disposalTraces.buffer.find(
55
+ (item) => item?.key === claim
56
+ );
57
+ store.logger.error(
58
+ `\u274C`,
59
+ `molecule`,
60
+ key,
61
+ `allocation failed:`,
62
+ `Could not allocate to ${claim} in store "${store.config.name}".`,
63
+ disposal ? `
64
+ ${claim} was most recently disposed
65
+ ${disposal.trace}` : `No previous disposal trace for ${claim} was found.`
66
+ );
67
+ }
68
+ return key;
69
+ }
70
+ function fuseWithinStore(store, type, sideA, sideB) {
71
+ const compoundKey = `T$--${type}==${sideA}++${sideB}`;
72
+ const above = [sideA, sideB];
73
+ allocateIntoStore(
74
+ store,
75
+ above,
76
+ compoundKey,
77
+ `all`
78
+ );
79
+ return compoundKey;
80
+ }
81
+ function deallocateFromStore(store, claim) {
82
+ const stringKey = stringifyJson(claim);
83
+ const molecule = store.molecules.get(stringKey);
84
+ if (!molecule) {
85
+ const disposal = store.disposalTraces.buffer.find(
86
+ (item) => item?.key === stringKey
87
+ );
88
+ store.logger.error(
89
+ `\u274C`,
90
+ `molecule`,
91
+ claim,
92
+ `deallocation failed:`,
93
+ `Could not find allocation for ${stringKey} in store "${store.config.name}".`,
94
+ disposal ? `
95
+ This state was most recently deallocated
96
+ ${disposal.trace}` : `No previous disposal trace for ${stringKey} was found.`
97
+ );
98
+ return;
99
+ }
100
+ const joinKeys = store.moleculeJoins.getRelatedKeys(
101
+ molecule.key
102
+ );
103
+ if (joinKeys) {
104
+ for (const joinKey of joinKeys) {
105
+ const join = store.joins.get(joinKey);
106
+ if (join) {
107
+ join.relations.delete(molecule.key);
108
+ join.molecules.delete(molecule.stringKey);
109
+ }
110
+ }
111
+ }
112
+ store.moleculeJoins.delete(molecule.stringKey);
113
+ const provenance = [];
114
+ const values = [];
115
+ const disposalEvent = {
116
+ type: `molecule_disposal`,
117
+ key: molecule.key,
118
+ values,
119
+ provenance
120
+ };
121
+ const target = newest(store);
122
+ target.molecules.delete(stringKey);
123
+ const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
124
+ if (isTransaction) {
125
+ target.transactionMeta.update.updates.push(disposalEvent);
126
+ }
127
+ const relatedMolecules = store.moleculeGraph.getRelationEntries({
128
+ downstreamMoleculeKey: molecule.stringKey
129
+ });
130
+ if (relatedMolecules) {
131
+ for (const [relatedStringKey, { source }] of relatedMolecules) {
132
+ if (source === molecule.stringKey) {
133
+ const relatedKey = parseJson(relatedStringKey);
134
+ deallocateFromStore(store, relatedKey);
135
+ } else {
136
+ provenance.push(source);
137
+ }
138
+ }
139
+ }
140
+ const familyKeys = target.moleculeData.getRelatedKeys(molecule.stringKey);
141
+ if (familyKeys) {
142
+ for (const familyKey of familyKeys) {
143
+ const family = target.families.get(familyKey);
144
+ const token = findInStore(store, family, molecule.key);
145
+ values.push([family.key, token]);
146
+ disposeFromStore(store, token);
147
+ }
148
+ }
149
+ target.moleculeGraph.delete(molecule.stringKey);
150
+ target.moleculeJoins.delete(molecule.stringKey);
151
+ target.moleculeData.delete(molecule.stringKey);
152
+ if (!isTransaction) {
153
+ target.on.moleculeDisposal.next(disposalEvent);
154
+ }
155
+ target.molecules.delete(molecule.stringKey);
156
+ const trace = getTrace(new Error());
157
+ store.disposalTraces.add({ key: stringKey, trace });
158
+ }
159
+ function claimWithinStore(store, newProvenance, claim, exclusive) {
160
+ const stringKey = stringifyJson(claim);
161
+ const target = newest(store);
162
+ const molecule = target.molecules.get(stringKey);
163
+ if (!molecule) {
164
+ const disposal = store.disposalTraces.buffer.find(
165
+ (item) => item?.key === stringKey
166
+ );
167
+ store.logger.error(
168
+ `\u274C`,
169
+ `molecule`,
170
+ claim,
171
+ `claim failed:`,
172
+ `Could not allocate to ${stringKey} in store "${store.config.name}".`,
173
+ disposal ? `
174
+ ${stringKey} was most recently disposed
175
+ ${disposal.trace}` : `No previous disposal trace for ${stringKey} was found.`
176
+ );
177
+ return claim;
178
+ }
179
+ const newProvenanceKey = stringifyJson(newProvenance);
180
+ const newProvenanceMolecule = target.molecules.get(newProvenanceKey);
181
+ if (!newProvenanceMolecule) {
182
+ const disposal = store.disposalTraces.buffer.find(
183
+ (item) => item?.key === newProvenanceKey
184
+ );
185
+ store.logger.error(
186
+ `\u274C`,
187
+ `molecule`,
188
+ claim,
189
+ `claim failed:`,
190
+ `Could not allocate to ${newProvenanceKey} in store "${store.config.name}".`,
191
+ disposal ? `
192
+ ${newProvenanceKey} was most recently disposed
193
+ ${disposal.trace}` : `No previous disposal trace for ${newProvenanceKey} was found.`
194
+ );
195
+ return claim;
196
+ }
197
+ const priorProvenance = store.moleculeGraph.getRelationEntries({
198
+ downstreamMoleculeKey: molecule.stringKey
199
+ }).filter(([, { source }]) => source !== stringKey).map(([key]) => parseJson(key));
200
+ if (exclusive) {
201
+ target.moleculeGraph.delete(stringKey);
202
+ }
203
+ target.moleculeGraph.set(
204
+ {
205
+ upstreamMoleculeKey: newProvenanceMolecule.stringKey,
206
+ downstreamMoleculeKey: molecule.stringKey
207
+ },
208
+ {
209
+ source: newProvenanceMolecule.stringKey
210
+ }
211
+ );
212
+ const transferEvent = {
213
+ type: `molecule_transfer`,
214
+ key: molecule.key,
215
+ from: priorProvenance,
216
+ to: [newProvenanceMolecule.key]
217
+ };
218
+ const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
219
+ if (isTransaction) {
220
+ target.transactionMeta.update.updates.push(transferEvent);
221
+ }
222
+ return claim;
223
+ }
224
+ var Realm = class {
225
+ store;
226
+ constructor(store = IMPLICIT.STORE) {
227
+ this.store = store;
228
+ makeRootMoleculeInStore(`root`, store);
229
+ }
230
+ allocate(provenance, key, attachmentStyle) {
231
+ return allocateIntoStore(
232
+ this.store,
233
+ provenance,
234
+ key,
235
+ attachmentStyle
236
+ );
237
+ }
238
+ fuse(type, reagentA, reagentB) {
239
+ return fuseWithinStore(this.store, type, reagentA, reagentB);
240
+ }
241
+ deallocate(claim) {
242
+ deallocateFromStore(this.store, claim);
243
+ }
244
+ claim(newProvenance, claim, exclusive) {
245
+ return claimWithinStore(this.store, newProvenance, claim, exclusive);
246
+ }
247
+ };
248
+ var T$ = `T$`;
249
+ var Anarchy = class {
250
+ store;
251
+ realm;
252
+ constructor(store = IMPLICIT.STORE) {
253
+ this.store = store;
254
+ this.realm = new Realm(store);
255
+ }
256
+ allocate(provenance, key, attachmentStyle) {
257
+ allocateIntoStore(
258
+ this.store,
259
+ provenance,
260
+ key,
261
+ attachmentStyle
262
+ );
263
+ }
264
+ deallocate(key) {
265
+ deallocateFromStore(this.store, key);
266
+ }
267
+ claim(newProvenance, key, exclusive) {
268
+ claimWithinStore(this.store, newProvenance, key, exclusive);
269
+ }
270
+ };
271
+
272
+ export { $claim, Anarchy, Realm, T$, allocateIntoStore, claimWithinStore, deallocateFromStore, fuseWithinStore, makeRootMoleculeInStore };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { Transceiver, Func, EnvironmentData, Flat, Subject, Store, Each, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
1
+ import { Transceiver, Func, EnvironmentData, Store, Each, Flat, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
2
2
  import { Json, JsonInterface, Canonical, stringified } from 'atom.io/json';
3
- import { MoleculeConstructor as MoleculeConstructor$1, MoleculeToken as MoleculeToken$1, MoleculeFamilyToken as MoleculeFamilyToken$1, MoleculeParams as MoleculeParams$1, getState as getState$1, setState as setState$1, makeMolecule as makeMolecule$1, ActorToolkit as ActorToolkit$1, MutableAtomFamilyToken as MutableAtomFamilyToken$1, MutableAtomToken as MutableAtomToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, RegularAtomToken as RegularAtomToken$1, WritableSelectorFamilyToken as WritableSelectorFamilyToken$1, WritableSelectorToken as WritableSelectorToken$1, ReadonlySelectorFamilyToken as ReadonlySelectorFamilyToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, WritableFamilyToken as WritableFamilyToken$1, WritableToken as WritableToken$1, ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1, MoleculeCreationClassic as MoleculeCreationClassic$1, MoleculeDisposalClassic as MoleculeDisposalClassic$1 } from 'atom.io';
3
+ import { getState as getState$1, setState as setState$1, ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1, RegularAtomToken as RegularAtomToken$1, MutableAtomToken as MutableAtomToken$1, WritableSelectorToken as WritableSelectorToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, WritableToken as WritableToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, MutableAtomFamilyToken as MutableAtomFamilyToken$1, WritableSelectorFamilyToken as WritableSelectorFamilyToken$1, ReadonlySelectorFamilyToken as ReadonlySelectorFamilyToken$1, WritableFamilyToken as WritableFamilyToken$1 } from 'atom.io';
4
4
  import { findState } from 'atom.io/ephemeral';
5
5
  import { seekState } from 'atom.io/immortal';
6
- import { JoinToken } from 'atom.io/data';
7
6
 
8
7
  type Effectors<T> = {
9
8
  setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
@@ -77,43 +76,36 @@ type StateCreation<Token extends ReadableToken<any>> = {
77
76
  type: `state_creation`;
78
77
  token: Token;
79
78
  };
80
- type StateDisposal<Token extends ReadableToken<any>> = {
79
+ type AtomDisposal<Token extends ReadableToken<any>> = {
81
80
  type: `state_disposal`;
81
+ subType: `atom`;
82
82
  token: Token;
83
- value?: TokenType<Token>;
83
+ value: TokenType<Token>;
84
84
  };
85
- type MoleculeCreationClassic<M extends MoleculeConstructor$1> = {
86
- type: `molecule_creation`;
87
- subType: `classic`;
88
- token: MoleculeToken$1<M>;
89
- family: MoleculeFamilyToken$1<M>;
90
- context: MoleculeToken$1<any>[];
91
- params: MoleculeParams$1<M>;
85
+ type SelectorDisposal<Token extends ReadableToken<any>> = {
86
+ type: `state_disposal`;
87
+ subType: `selector`;
88
+ token: Token;
92
89
  };
93
- type MoleculeCreationModern = {
90
+ type StateDisposal<Token extends ReadableToken<any>> = AtomDisposal<Token> | SelectorDisposal<Token>;
91
+ type MoleculeCreation = {
94
92
  type: `molecule_creation`;
95
- subType: `modern`;
96
93
  key: Canonical;
97
94
  provenance: Canonical;
98
95
  };
99
- type MoleculeCreation<M extends MoleculeConstructor$1> = MoleculeCreationClassic<M> | MoleculeCreationModern;
100
- type MoleculeDisposalClassic = {
96
+ type MoleculeDisposal = {
101
97
  type: `molecule_disposal`;
102
- subType: `classic`;
103
- token: MoleculeToken$1<any>;
104
- family: MoleculeFamilyToken$1<any>;
105
- context: MoleculeToken$1<any>[];
98
+ key: Canonical;
99
+ provenance: stringified<Canonical>[];
106
100
  values: [key: string, value: any][];
107
101
  };
108
- type MoleculeDisposalModern = {
109
- type: `molecule_disposal`;
110
- subType: `modern`;
102
+ type MoleculeTransfer = {
103
+ type: `molecule_transfer`;
111
104
  key: Canonical;
112
- provenance: Canonical;
113
- values: [key: string, value: any][];
105
+ from: Canonical[];
106
+ to: Canonical[];
114
107
  };
115
- type MoleculeDisposal = MoleculeDisposalClassic | MoleculeDisposalModern;
116
- type TransactionUpdateContent = KeyedStateUpdate<unknown> | MoleculeCreation<any> | MoleculeDisposal | StateCreation<ReadableToken<unknown>> | StateDisposal<ReadableToken<unknown>> | TransactionUpdate<Func>;
108
+ type TransactionUpdateContent = KeyedStateUpdate<unknown> | MoleculeCreation | MoleculeDisposal | MoleculeTransfer | StateCreation<ReadableToken<unknown>> | StateDisposal<ReadableToken<unknown>> | TransactionUpdate<Func>;
117
109
  type TransactionUpdate<F extends Func> = {
118
110
  type: `transaction_update`;
119
111
  key: string;
@@ -137,7 +129,6 @@ type ActorToolkit = Readonly<{
137
129
  find: typeof findState;
138
130
  seek: typeof seekState;
139
131
  json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
140
- make: typeof makeMolecule$1;
141
132
  dispose: typeof disposeState;
142
133
  run: typeof runTransaction;
143
134
  env: () => EnvironmentData;
@@ -189,71 +180,22 @@ type SelectorFamilyToken<T, K extends Canonical> = ReadonlySelectorFamilyToken<T
189
180
  declare function selectorFamily<T, K extends Canonical>(options: WritableSelectorFamilyOptions<T, K>): WritableSelectorFamilyToken<T, K>;
190
181
  declare function selectorFamily<T, K extends Canonical>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamilyToken<T, K>;
191
182
 
192
- type CtorToolkit<K extends Canonical> = Flat<Omit<ActorToolkit$1, `find`> & {
193
- bond<T extends Transceiver<any>, J extends Json.Serializable>(family: MutableAtomFamilyToken$1<T, J, K>): MutableAtomToken$1<T, J>;
194
- bond<T>(family: RegularAtomFamilyToken$1<T, K>): RegularAtomToken$1<T>;
195
- bond<T>(family: WritableSelectorFamilyToken$1<T, K>): WritableSelectorToken$1<T>;
196
- bond<T>(family: ReadonlySelectorFamilyToken$1<T, K>): ReadonlySelectorToken$1<T>;
197
- bond<T>(family: WritableFamilyToken$1<T, K>): WritableToken$1<T>;
198
- bond<T>(family: ReadableFamilyToken$1<T, K>): ReadableToken$1<T>;
199
- bond<J extends JoinToken<any, any, any, any, any, any>>(joinToken: J, role: {
200
- as: J extends JoinToken<infer A, string, infer B, string, any, any> ? A | B : never;
201
- }): J extends JoinToken<any, any, any, any, any, infer Content> ? Content extends null ? {
202
- relatedKeys: ReadonlySelectorToken$1<string[]>;
203
- } : {
204
- relatedKeys: ReadonlySelectorToken$1<string[]>;
205
- relatedEntries: ReadonlySelectorToken$1<[
206
- key: string,
207
- value: Content
208
- ][]>;
209
- } : never;
210
- claim(below: MoleculeToken<any>, options: {
211
- exclusive: boolean;
212
- }): void;
213
- spawn<Key extends Canonical, Ctor extends MoleculeConstructor>(family: MoleculeFamilyToken<Ctor>, key: Key, ...params: MoleculeParams<Ctor>): MoleculeToken<Ctor>;
214
- }>;
215
- type MoleculeConstructor = new (toolkit: CtorToolkit<any>, key: any, ...params: any) => any;
216
- type Tail<T extends any[]> = T extends [any, ...infer Rest] ? Rest : any[];
217
- type MoleculeParams<M extends MoleculeConstructor> = Tail<Tail<ConstructorParameters<M>>>;
218
- type MoleculeFamilyOptions<M extends MoleculeConstructor> = {
219
- key: string;
220
- dependsOn?: `all` | `any`;
221
- new: M;
222
- };
223
- type MoleculeFamilyToken<M extends MoleculeConstructor> = {
224
- key: string;
225
- type: `molecule_family`;
226
- dependsOn: `all` | `any`;
227
- __M?: M;
228
- };
229
- type MoleculeFamily<M extends MoleculeConstructor> = Flat<MoleculeFamilyToken<M> & {
230
- subject: Subject<MoleculeCreationClassic$1<M> | MoleculeDisposalClassic$1>;
231
- dependsOn: `all` | `any`;
232
- new: M;
233
- }>;
234
- type MoleculeToken<M extends MoleculeConstructor> = {
235
- key: MoleculeKey<M>;
236
- type: `molecule`;
237
- family?: MoleculeFamilyToken<M>;
238
- __M?: M;
239
- };
240
- declare function moleculeFamily<M extends MoleculeConstructor>(options: MoleculeFamilyOptions<M>): MoleculeFamilyToken<M>;
241
- declare function makeMolecule<M extends MoleculeConstructor>(context: MoleculeToken<any> | MoleculeToken<any>[], family: MoleculeFamilyToken<M>, key: MoleculeKey<M>, ...params: MoleculeParams<M>): MoleculeToken<M>;
242
- type MoleculeType<T extends MoleculeFamilyToken<any>> = T extends MoleculeFamilyToken<infer M> ? M : T extends MoleculeToken<infer M> ? M : never;
243
- type MoleculeKey<M extends MoleculeConstructor> = InstanceType<M>[`key`];
244
- declare function makeRootMoleculeInStore(key: string, store?: Store): MoleculeToken<ObjectConstructor>;
245
-
246
- declare const $provenance: unique symbol;
247
- type Claim<H extends Hierarchy, V extends Vassal<H>, A extends Above<V, H>> = V & {
248
- [$provenance]?: A;
249
- };
250
- declare function allocateIntoStore<H extends Hierarchy, V extends Vassal<H>, A extends Above<V, H>>(store: Store, provenance: A, key: V): Claim<H, V, A>;
251
- declare function deallocateFromStore<H extends Hierarchy, V extends Vassal<H>, A extends Above<V, H>>(store: Store, claim: Claim<H, V, A>): void;
252
- declare function realm<H extends Hierarchy>(store: Store): {
253
- root: MoleculeToken<ObjectConstructor>;
254
- allocate: <V extends Vassal<H>, A extends Above<V, H>>(provenance: A, key: V) => Claim<H, V, A>;
255
- deallocate: <V extends Vassal<H>, A extends Above<V, H>>(claim: Claim<H, V, A>) => void;
256
- };
183
+ declare const $claim: unique symbol;
184
+ type Claim<K extends Canonical> = K & {
185
+ [$claim]?: true;
186
+ };
187
+ declare function allocateIntoStore<H extends Hierarchy, V extends Vassal<H>, A extends Above<V, H>>(store: Store, provenance: A, key: V, dependsOn?: `all` | `any`): Claim<V>;
188
+ declare function fuseWithinStore<H extends Hierarchy, C extends CompoundFrom<H>, T extends C extends CompoundTypedKey<infer t, any, any> ? t : never, A extends C extends CompoundTypedKey<any, infer a, any> ? a : never, B extends C extends CompoundTypedKey<any, any, infer b> ? b : never>(store: Store, type: T, sideA: SingularTypedKey<A>, sideB: SingularTypedKey<B>): Claim<CompoundTypedKey<T, A, B>>;
189
+ declare function deallocateFromStore<H extends Hierarchy, V extends Vassal<H>>(store: Store, claim: Claim<V>): void;
190
+ declare function claimWithinStore<H extends Hierarchy, V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(store: Store, newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V>;
191
+ declare class Realm<H extends Hierarchy> {
192
+ store: Store;
193
+ constructor(store?: Store);
194
+ allocate<V extends Vassal<H>, A extends Above<V, H>>(provenance: A, key: V, attachmentStyle?: `all` | `any`): Claim<V>;
195
+ fuse<C extends CompoundFrom<H>, T extends C extends CompoundTypedKey<infer t, any, any> ? t : never, A extends C extends CompoundTypedKey<any, infer v, any> ? v : never, B extends C extends CompoundTypedKey<any, any, infer m> ? m : never>(type: T, reagentA: SingularTypedKey<A>, reagentB: SingularTypedKey<B>): Claim<CompoundTypedKey<T, A, B>>;
196
+ deallocate<V extends Vassal<H>>(claim: Claim<V>): void;
197
+ claim<V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V>;
198
+ }
257
199
  declare const T$ = "T$";
258
200
  type T$ = typeof T$;
259
201
  type TypeTag<T extends string> = `${T$}--${T}`;
@@ -264,7 +206,6 @@ type Scope = SingularTypedKey[];
264
206
  type MutualFealty = {
265
207
  above: Scope;
266
208
  below: CompoundTypedKey;
267
- style: `all` | `any`;
268
209
  };
269
210
  type ExclusiveFealty = {
270
211
  above: TypedKey | `root`;
@@ -290,15 +231,23 @@ type Below<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
290
231
  type Mutuals<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
291
232
  [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`above`][number] ? [mutual: Exclude<H[K][`above`][number], TK>, below: H[K][`below`]] : never : never;
292
233
  }[keyof H];
234
+ type CompoundFrom<H extends Hierarchy> = {
235
+ [K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : never;
236
+ }[keyof H];
237
+ declare class Anarchy {
238
+ store: Store;
239
+ realm: Realm<any>;
240
+ constructor(store?: Store);
241
+ allocate(provenance: Canonical, key: Canonical, attachmentStyle?: `all` | `any`): void;
242
+ deallocate(key: Canonical): void;
243
+ claim(newProvenance: Canonical, key: Canonical, exclusive?: `exclusive`): void;
244
+ }
293
245
 
294
- declare function disposeState(token: MoleculeToken<any> | ReadableToken<any>): void;
246
+ declare function disposeState(token: ReadableToken<any>): void;
295
247
  declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<any, K>, key: K): void;
296
- declare function disposeState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: MoleculeKey<M>): void;
297
248
 
298
249
  declare function getState<T>(token: ReadableToken<T>): T;
299
- declare function getState<M extends MoleculeConstructor>(token: MoleculeToken<M>): InstanceType<M>;
300
250
  declare function getState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): T;
301
- declare function getState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: Canonical): InstanceType<M>;
302
251
 
303
252
  declare const LoggerIconDictionary: {
304
253
  readonly "\u231B": "Timeline event fully captured";
@@ -370,6 +319,8 @@ declare class AtomIOLogger implements Logger {
370
319
  warn: LogFn;
371
320
  }
372
321
 
322
+ declare function makeRootMoleculeInStore<S extends string>(key: S, store?: Store): S;
323
+
373
324
  /**
374
325
  * @public
375
326
  * Set the value of a state into the implicit store.
@@ -404,8 +355,6 @@ declare class Silo {
404
355
  subscribe: typeof subscribe;
405
356
  undo: typeof undo;
406
357
  redo: typeof redo;
407
- moleculeFamily: typeof moleculeFamily;
408
- makeMolecule: typeof makeMolecule;
409
358
  runTransaction: typeof runTransaction;
410
359
  constructor(config: Store[`config`], fromStore?: Store | null);
411
360
  }
@@ -434,10 +383,10 @@ type TimelineToken<M> = {
434
383
  };
435
384
  type TimelineOptions<ManagedAtom extends TimelineManageable> = {
436
385
  key: string;
437
- scope: (ManagedAtom | MoleculeFamilyToken$1<any>)[];
386
+ scope: ManagedAtom[];
438
387
  shouldCapture?: (update: TimelineUpdate<ManagedAtom>, timeline: Timeline<TimelineManageable>) => boolean;
439
388
  };
440
- type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineMoleculeCreation<any> | TimelineMoleculeDisposal | TimelineSelectorUpdate<ManagedAtom> | TimelineStateCreation<AtomOnly<ManagedAtom>> | TimelineStateDisposal<AtomOnly<ManagedAtom>> | TimelineTransactionUpdate;
389
+ type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineMoleculeCreation | TimelineMoleculeDisposal | TimelineSelectorUpdate<ManagedAtom> | TimelineStateCreation<AtomOnly<ManagedAtom>> | TimelineStateDisposal<AtomOnly<ManagedAtom>> | TimelineTransactionUpdate;
441
390
  declare const timeline: <ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>) => TimelineToken<ManagedAtom>;
442
391
  declare const redo: (tl: TimelineToken<any>) => void;
443
392
  declare const undo: (tl: TimelineToken<any>) => void;
@@ -492,4 +441,4 @@ type FamilyMetadata<K extends Canonical = any> = {
492
441
  subKey: stringified<K>;
493
442
  };
494
443
 
495
- export { $provenance, type Above, type ActorToolkit, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type Below, type Claim, type CompoundTypedKey, type CtorToolkit, type Effectors, type FamilyMetadata, type GetterToolkit, type Hierarchy, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeConstructor, type MoleculeCreation, type MoleculeCreationClassic, type MoleculeCreationModern, type MoleculeDisposal, type MoleculeDisposalClassic, type MoleculeDisposalModern, type MoleculeFamily, type MoleculeFamilyOptions, type MoleculeFamilyToken, type MoleculeKey, type MoleculeParams, type MoleculeToken, type MoleculeType, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomOptions, type MutableAtomToken, type Mutuals, type Read, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorOptions, type ReadonlySelectorToken, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomOptions, type RegularAtomToken, type SelectorFamilyToken, type SelectorToken, type SetterToolkit, Silo, type SingularTypedKey, type StateCreation, type StateDisposal, type StateUpdate, T$, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type TypeTag, type TypedKey, type UpdateHandler, type Vassal, type WritableFamilyToken, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, allocateIntoStore, atom, atomFamily, belongsTo, deallocateFromStore, disposeState, getState, isToken, makeMolecule, makeRootMoleculeInStore, moleculeFamily, realm, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
444
+ export { $claim, type Above, type ActorToolkit, Anarchy, type AtomDisposal, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type Below, type Claim, type CompoundFrom, type CompoundTypedKey, type Effectors, type FamilyMetadata, type GetterToolkit, type Hierarchy, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeCreation, type MoleculeDisposal, type MoleculeTransfer, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomOptions, type MutableAtomToken, type Mutuals, type Read, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorOptions, type ReadonlySelectorToken, Realm, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomOptions, type RegularAtomToken, type SelectorDisposal, type SelectorFamilyToken, type SelectorToken, type SetterToolkit, Silo, type SingularTypedKey, type StateCreation, type StateDisposal, type StateUpdate, T$, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type TypeTag, type TypedKey, type UpdateHandler, type Vassal, type WritableFamilyToken, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, allocateIntoStore, atom, atomFamily, belongsTo, claimWithinStore, deallocateFromStore, disposeState, fuseWithinStore, getState, isToken, makeRootMoleculeInStore, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { $provenance, T$, allocateIntoStore, deallocateFromStore, makeMolecule, makeRootMoleculeInStore, moleculeFamily, realm } from './chunk-ADMEAXYU.js';
1
+ export { $claim, Anarchy, Realm, T$, allocateIntoStore, claimWithinStore, deallocateFromStore, fuseWithinStore, makeRootMoleculeInStore } from './chunk-ICGFFQ3H.js';
2
2
  import './chunk-XWL6SNVU.js';
3
3
  import * as Internal from 'atom.io/internal';
4
- import { createStandaloneAtom, IMPLICIT, createAtomFamily, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, findInStore, getFromStore, setIntoStore, disposeFromStore, subscribeInStore, timeTravel, createMoleculeFamily, makeMoleculeInStore, actUponStore, arbitrary } from 'atom.io/internal';
4
+ import { createStandaloneAtom, IMPLICIT, createAtomFamily, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, findInStore, getFromStore, setIntoStore, disposeFromStore, subscribeInStore, timeTravel, actUponStore, arbitrary } from 'atom.io/internal';
5
5
 
6
6
  function atom(options) {
7
7
  return createStandaloneAtom(IMPLICIT.STORE, options);
@@ -9,7 +9,7 @@ function atom(options) {
9
9
  function atomFamily(options) {
10
10
  return createAtomFamily(IMPLICIT.STORE, options);
11
11
  }
12
- function disposeState(token, key) {
12
+ function disposeState(...[token, key]) {
13
13
  if (key) {
14
14
  Internal.disposeFromStore(Internal.IMPLICIT.STORE, token, key);
15
15
  } else {
@@ -86,8 +86,6 @@ var Silo = class {
86
86
  subscribe;
87
87
  undo;
88
88
  redo;
89
- moleculeFamily;
90
- makeMolecule;
91
89
  runTransaction;
92
90
  constructor(config, fromStore = null) {
93
91
  const s = new Store(config, fromStore);
@@ -113,12 +111,6 @@ var Silo = class {
113
111
  this.redo = (token) => {
114
112
  timeTravel(s, `redo`, token);
115
113
  };
116
- this.moleculeFamily = (options) => {
117
- return createMoleculeFamily(s, options);
118
- };
119
- this.makeMolecule = (...params) => {
120
- return makeMoleculeInStore(s, ...params);
121
- };
122
114
  this.runTransaction = (token, id = arbitrary()) => actUponStore(token, id, s);
123
115
  }
124
116
  };
@@ -1,3 +1,4 @@
1
+ import * as _eslint_core from '@eslint/core';
1
2
  import * as ESTree from 'estree';
2
3
  import * as eslint from 'eslint';
3
4
  import { Rule } from 'eslint';
@@ -20,7 +21,13 @@ declare const lifespan: {
20
21
  default: string;
21
22
  }[];
22
23
  };
23
- create(context: Rule.RuleContext): {
24
+ create(context: _eslint_core.RuleContext<{
25
+ LangOptions: eslint.Linter.LanguageOptions;
26
+ Code: eslint.SourceCode;
27
+ RuleOptions: any[];
28
+ Node: ESTree.Node;
29
+ MessageIds: string;
30
+ }>): {
24
31
  ImportDeclaration(node: ESTree.ImportDeclaration & Rule.NodeParentExtension): void;
25
32
  CallExpression(node: ESTree.CallExpression & Rule.NodeParentExtension): void;
26
33
  };
@@ -37,7 +44,13 @@ declare const synchronousSelectorDependencies: {
37
44
  };
38
45
  schema: never[];
39
46
  };
40
- create(context: Rule.RuleContext): {
47
+ create(context: _eslint_core.RuleContext<{
48
+ LangOptions: eslint.Linter.LanguageOptions;
49
+ Code: eslint.SourceCode;
50
+ RuleOptions: any[];
51
+ Node: ESTree.Node;
52
+ MessageIds: string;
53
+ }>): {
41
54
  CallExpression(node: ESTree.CallExpression & Rule.NodeParentExtension): void;
42
55
  };
43
56
  };
@@ -64,7 +77,13 @@ declare const _default: {
64
77
  };
65
78
  schema: never[];
66
79
  };
67
- create(context: eslint.Rule.RuleContext): {
80
+ create(context: _eslint_core.RuleContext<{
81
+ LangOptions: eslint.Linter.LanguageOptions;
82
+ Code: eslint.SourceCode;
83
+ RuleOptions: any[];
84
+ Node: ESTree.Node;
85
+ MessageIds: string;
86
+ }>): {
68
87
  CallExpression(node: ESTree.CallExpression & eslint.Rule.NodeParentExtension): void;
69
88
  };
70
89
  };
@@ -172,10 +172,10 @@ var lifespan = {
172
172
  if (storeLifespan === `ephemeral`) {
173
173
  return;
174
174
  }
175
- const functionCallee = node.callee.type === `Identifier` ? node.callee : void 0;
176
- const methodCallee = node.callee.type === `MemberExpression` && node.callee.property.type === `Identifier` ? node.callee.property : void 0;
175
+ const functionCallee = node.callee.type === `Identifier` ? node.callee : undefined;
176
+ const methodCallee = node.callee.type === `MemberExpression` && node.callee.property.type === `Identifier` ? node.callee.property : undefined;
177
177
  const callee = functionCallee ?? methodCallee;
178
- if (callee === void 0) {
178
+ if (callee === undefined) {
179
179
  return;
180
180
  }
181
181
  if (callee.name === `findState`) {
@@ -247,7 +247,7 @@ var lifespan = {
247
247
  }
248
248
  for (const storeProcedure of storeProcedures) {
249
249
  const transactorsParam = storeProcedure.params[0];
250
- const nonDestructuredTransactorsName = transactorsParam && `name` in transactorsParam ? transactorsParam.name : void 0;
250
+ const nonDestructuredTransactorsName = transactorsParam && `name` in transactorsParam ? transactorsParam.name : undefined;
251
251
  walk(storeProcedure.body, (n) => {
252
252
  if (n.type === `CallExpression`) {
253
253
  let willReport = false;
@@ -327,14 +327,14 @@ var synchronousSelectorDependencies = {
327
327
  }
328
328
  }
329
329
  if (selectorComputation?.type === `FunctionExpression` || selectorComputation?.type === `ArrowFunctionExpression`) {
330
- const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name : void 0;
330
+ const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name : undefined;
331
331
  let awaited;
332
332
  let awaitNode;
333
333
  walk(selectorComputation, (n, depth) => {
334
334
  if (typeof awaited === `number`) {
335
335
  if (awaited > depth) {
336
- awaited = void 0;
337
- awaitNode = void 0;
336
+ awaited = undefined;
337
+ awaitNode = undefined;
338
338
  }
339
339
  }
340
340
  switch (n.type) {
@@ -1,4 +1,4 @@
1
- import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, RegularAtomToken, WritableSelectorFamilyToken, WritableSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, WritableFamilyToken, WritableToken, ReadableFamilyToken, ReadableToken, MoleculeConstructor, MoleculeFamilyToken, MoleculeKey, MoleculeToken } from 'atom.io';
1
+ import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, RegularAtomToken, WritableSelectorFamilyToken, WritableSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, WritableFamilyToken, WritableToken, ReadableFamilyToken, ReadableToken } from 'atom.io';
2
2
  import { Transceiver } from 'atom.io/internal';
3
3
  import { Json, Canonical } from 'atom.io/json';
4
4
 
@@ -8,6 +8,5 @@ declare function seekState<T, K extends Canonical, Key extends K>(token: Writabl
8
8
  declare function seekState<T, K extends Canonical, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key): ReadonlySelectorToken<T, K> | undefined;
9
9
  declare function seekState<T, K extends Canonical, Key extends K>(token: WritableFamilyToken<T, K>, key: Key): WritableToken<T, K> | undefined;
10
10
  declare function seekState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T, K> | undefined;
11
- declare function seekState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: MoleculeKey<M>): MoleculeToken<M> | undefined;
12
11
 
13
12
  export { seekState };