atom.io 0.30.0 → 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.
@@ -0,0 +1,167 @@
1
+ import { createMoleculeFamily, IMPLICIT, makeMoleculeInStore, Molecule, newest, isChildStore, disposeFromStore } from 'atom.io/internal';
2
+ import { stringifyJson } from 'atom.io/json';
3
+
4
+ // src/molecule.ts
5
+ function moleculeFamily(options) {
6
+ return createMoleculeFamily(IMPLICIT.STORE, options);
7
+ }
8
+ function makeMolecule(context, family, key, ...params) {
9
+ return makeMoleculeInStore(IMPLICIT.STORE, context, family, key, ...params);
10
+ }
11
+ function makeRootMoleculeInStore(key, store = IMPLICIT.STORE) {
12
+ const molecule = new Molecule(void 0, key);
13
+ store.molecules.set(stringifyJson(key), molecule);
14
+ return {
15
+ key,
16
+ type: `molecule`
17
+ };
18
+ }
19
+ var $provenance = Symbol(`provenance`);
20
+ function allocateIntoStore(store, provenance, key) {
21
+ const stringKey = stringifyJson(key);
22
+ try {
23
+ const above = [];
24
+ let allocationAttachmentStyle;
25
+ if (provenance === `root`) {
26
+ above.push(store.molecules.get(`"root"`));
27
+ allocationAttachmentStyle = `all`;
28
+ } else if (typeof provenance === `string` && provenance.startsWith(T$)) {
29
+ allocationAttachmentStyle = `any`;
30
+ const provenanceKey = stringifyJson(provenance);
31
+ const provenanceMolecule = store.molecules.get(provenanceKey);
32
+ if (!provenanceMolecule) {
33
+ throw new Error(
34
+ `Molecule ${provenanceKey} not found in store "${store.config.name}"`
35
+ );
36
+ }
37
+ above.push(provenanceMolecule);
38
+ } else {
39
+ const allocationIsCompound = key.startsWith(`T$--`);
40
+ if (allocationIsCompound) {
41
+ allocationAttachmentStyle = `all`;
42
+ for (const claim of provenance) {
43
+ const provenanceKey = stringifyJson(claim);
44
+ const provenanceMolecule = store.molecules.get(provenanceKey);
45
+ if (!provenanceMolecule) {
46
+ throw new Error(
47
+ `Molecule ${provenanceKey} not found in store "${store.config.name}"`
48
+ );
49
+ }
50
+ above.push(provenanceMolecule);
51
+ }
52
+ } else {
53
+ allocationAttachmentStyle = `any`;
54
+ const provenanceKey = stringifyJson(provenance);
55
+ const provenanceMolecule = store.molecules.get(provenanceKey);
56
+ if (!provenanceMolecule) {
57
+ throw new Error(
58
+ `Molecule ${provenanceKey} not found in store "${store.config.name}"`
59
+ );
60
+ }
61
+ above.push(provenanceMolecule);
62
+ }
63
+ }
64
+ const molecule = new Molecule(above, key);
65
+ molecule._dependsOn = allocationAttachmentStyle;
66
+ store.molecules.set(stringKey, molecule);
67
+ for (const aboveMolecule of above) {
68
+ aboveMolecule.below.set(molecule.stringKey, molecule);
69
+ }
70
+ const creationEvent = {
71
+ type: `molecule_creation`,
72
+ subType: `modern`,
73
+ key: molecule.key,
74
+ provenance
75
+ };
76
+ const target = newest(store);
77
+ const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
78
+ if (isTransaction) {
79
+ target.transactionMeta.update.updates.push(creationEvent);
80
+ } else {
81
+ target.on.moleculeCreationStart.next(creationEvent);
82
+ }
83
+ } catch (thrown) {
84
+ if (thrown instanceof Error) {
85
+ store.logger.error(
86
+ `\u274C`,
87
+ `molecule`,
88
+ stringKey,
89
+ `allocation failed:`,
90
+ thrown.message
91
+ );
92
+ }
93
+ }
94
+ return key;
95
+ }
96
+ function deallocateFromStore(store, claim) {
97
+ const stringKey = stringifyJson(claim);
98
+ const molecule = store.molecules.get(stringKey);
99
+ if (!molecule) {
100
+ throw new Error(
101
+ `Molecule ${stringKey} not found in store "${store.config.name}"`
102
+ );
103
+ }
104
+ for (const join of molecule.joins.values()) {
105
+ join.relations.delete(molecule.key);
106
+ join.molecules.delete(molecule.stringKey);
107
+ }
108
+ let provenance;
109
+ if (molecule.above.size === 1) {
110
+ const above = molecule.above.values().next().value;
111
+ provenance = above.key;
112
+ } else {
113
+ provenance = [...molecule.above.values()].map(({ key }) => key);
114
+ }
115
+ const values = [];
116
+ for (const stateToken of molecule.tokens.values()) {
117
+ const tokenFamily = stateToken.family;
118
+ values.push([tokenFamily.key, store.valueMap.get(stateToken.key)]);
119
+ }
120
+ for (const state of molecule.tokens.values()) {
121
+ disposeFromStore(store, state);
122
+ }
123
+ for (const child of molecule.below.values()) {
124
+ if (child.dependsOn === `all`) {
125
+ deallocateFromStore(store, child.key);
126
+ } else {
127
+ child.above.delete(molecule.stringKey);
128
+ if (child.above.size === 0) {
129
+ deallocateFromStore(store, child.key);
130
+ }
131
+ }
132
+ }
133
+ molecule.below.clear();
134
+ const disposalEvent = {
135
+ type: `molecule_disposal`,
136
+ subType: `modern`,
137
+ key: molecule.key,
138
+ values,
139
+ provenance
140
+ };
141
+ const target = newest(store);
142
+ const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
143
+ if (isTransaction) {
144
+ target.transactionMeta.update.updates.push(disposalEvent);
145
+ } else {
146
+ target.on.moleculeDisposal.next(disposalEvent);
147
+ }
148
+ target.molecules.delete(molecule.stringKey);
149
+ for (const parent of molecule.above.values()) {
150
+ parent.below.delete(molecule.stringKey);
151
+ }
152
+ }
153
+ function realm(store) {
154
+ const root = makeRootMoleculeInStore(`root`, store);
155
+ return {
156
+ root,
157
+ allocate: (provenance, key) => {
158
+ return allocateIntoStore(store, provenance, key);
159
+ },
160
+ deallocate: (claim) => {
161
+ deallocateFromStore(store, claim);
162
+ }
163
+ };
164
+ }
165
+ var T$ = `T$`;
166
+
167
+ export { $provenance, T$, allocateIntoStore, deallocateFromStore, makeMolecule, makeRootMoleculeInStore, moleculeFamily, realm };
@@ -1,7 +1,8 @@
1
+ import { deallocateFromStore, allocateIntoStore } from './chunk-ADMEAXYU.js';
1
2
  import { stringifyJson, parseJson, selectJson, selectJsonFamily } from 'atom.io/json';
2
3
  import { AtomIOLogger } from 'atom.io';
3
4
  import { getJoin, findRelations } from 'atom.io/data';
4
- import { subscribeToTimeline, subscribeToTransaction, subscribeToState, arbitrary as arbitrary$1, Molecule as Molecule$1, newest as newest$1, isChildStore as isChildStore$1, disposeFromStore as disposeFromStore$1 } from 'atom.io/internal';
5
+ import { subscribeToTimeline, subscribeToTransaction, subscribeToState, arbitrary as arbitrary$1 } from 'atom.io/internal';
5
6
 
6
7
  // internal/src/arbitrary.ts
7
8
  function arbitrary(random = Math.random) {
@@ -158,36 +159,36 @@ var Junction = class {
158
159
  }
159
160
  }
160
161
  }
161
- replaceRelationsUnsafely(a, bs) {
162
- this.relations.set(a, new Set(bs));
163
- for (const b of bs) {
164
- const bRelations = /* @__PURE__ */ new Set([a]);
165
- this.relations.set(b, bRelations);
162
+ replaceRelationsUnsafely(x, ys) {
163
+ this.relations.set(x, new Set(ys));
164
+ for (const y of ys) {
165
+ const yRelations = (/* @__PURE__ */ new Set()).add(x);
166
+ this.relations.set(y, yRelations);
166
167
  }
167
168
  }
168
- replaceRelationsSafely(a, bs) {
169
- const aRelationsPrev = this.relations.get(a);
170
- if (aRelationsPrev) {
171
- for (const b of aRelationsPrev) {
172
- const bRelations = this.relations.get(b);
173
- if (bRelations) {
174
- if (bRelations.size === 1) {
175
- this.relations.delete(b);
169
+ replaceRelationsSafely(x, ys) {
170
+ const xRelationsPrev = this.relations.get(x);
171
+ if (xRelationsPrev) {
172
+ for (const y of xRelationsPrev) {
173
+ const yRelations = this.relations.get(y);
174
+ if (yRelations) {
175
+ if (yRelations.size === 1) {
176
+ this.relations.delete(y);
176
177
  } else {
177
- bRelations.delete(a);
178
+ yRelations.delete(x);
178
179
  }
179
- this.contents.delete(this.makeContentKey(a, b));
180
+ this.contents.delete(this.makeContentKey(x, y));
180
181
  }
181
182
  }
182
183
  }
183
- this.relations.set(a, new Set(bs));
184
- for (const b of bs) {
185
- let bRelations = this.relations.get(b);
186
- if (bRelations) {
187
- bRelations.add(a);
184
+ this.relations.set(x, new Set(ys));
185
+ for (const y of ys) {
186
+ let yRelations = this.relations.get(y);
187
+ if (yRelations) {
188
+ yRelations.add(x);
188
189
  } else {
189
- bRelations = /* @__PURE__ */ new Set([a]);
190
- this.relations.set(b, bRelations);
190
+ yRelations = (/* @__PURE__ */ new Set()).add(x);
191
+ this.relations.set(y, yRelations);
191
192
  }
192
193
  }
193
194
  }
@@ -205,7 +206,9 @@ var Junction = class {
205
206
  this.b = data.between[1];
206
207
  this.cardinality = data.cardinality;
207
208
  if (!config?.externalStore) {
208
- this.relations = new Map(data.relations?.map(([a, b]) => [a, new Set(b)]));
209
+ this.relations = new Map(
210
+ data.relations?.map(([x, ys]) => [x, new Set(ys)])
211
+ );
209
212
  this.contents = new Map(data.contents);
210
213
  }
211
214
  this.isContent = config?.isContent ?? null;
@@ -227,7 +230,9 @@ var Junction = class {
227
230
  this.replaceRelationsUnsafely = (a, bs) => {
228
231
  externalStore.replaceRelationsUnsafely(a, bs);
229
232
  };
230
- this.getRelatedKeys = (key) => externalStore.getRelatedKeys(key);
233
+ this.getRelatedKeys = (key) => externalStore.getRelatedKeys(
234
+ key
235
+ );
231
236
  if (externalStore.getContent) {
232
237
  this.getContentInternal = (contentKey) => {
233
238
  return externalStore.getContent(contentKey);
@@ -254,7 +259,9 @@ var Junction = class {
254
259
  return {
255
260
  between: [this.a, this.b],
256
261
  cardinality: this.cardinality,
257
- relations: [...this.relations.entries()].map(([a, b]) => [a, [...b]]),
262
+ relations: [...this.relations.entries()].map(
263
+ ([a, b]) => [a, [...b]]
264
+ ),
258
265
  contents: [...this.contents.entries()]
259
266
  };
260
267
  }
@@ -266,7 +273,7 @@ var Junction = class {
266
273
  // biome-ignore lint/suspicious/noFallthroughSwitchClause: perfect here
267
274
  case `1:1`: {
268
275
  const bPrev = this.getRelatedKey(a);
269
- if (bPrev && bPrev !== b) this.delete(bPrev, a);
276
+ if (bPrev && bPrev !== b) this.delete(a, bPrev);
270
277
  }
271
278
  case `1:n`: {
272
279
  const aPrev = this.getRelatedKey(b);
@@ -282,7 +289,10 @@ var Junction = class {
282
289
  }
283
290
  delete(x, b) {
284
291
  b = typeof b === `string` ? b : x[this.b];
285
- const a = typeof x === `string` ? x : x[this.a];
292
+ const a = (
293
+ // @ts-expect-error we deduce that this.a may index x
294
+ typeof x === `string` ? x : x[this.a]
295
+ );
286
296
  if (a === void 0 && typeof b === `string`) {
287
297
  const bRelations = this.getRelatedKeys(b);
288
298
  if (bRelations) {
@@ -321,18 +331,18 @@ var Junction = class {
321
331
  }
322
332
  }
323
333
  }
324
- replaceRelations(a, relations, config) {
334
+ replaceRelations(x, relations, config) {
325
335
  const hasContent = !Array.isArray(relations);
326
- const bs = hasContent ? Object.keys(relations) : relations;
336
+ const ys = hasContent ? Object.keys(relations) : relations;
327
337
  if (config?.reckless) {
328
- this.replaceRelationsUnsafely(a, bs);
338
+ this.replaceRelationsUnsafely(x, ys);
329
339
  } else {
330
- this.replaceRelationsSafely(a, bs);
340
+ this.replaceRelationsSafely(x, ys);
331
341
  }
332
342
  if (hasContent) {
333
- for (const b of bs) {
334
- const contentKey = this.makeContentKey(a, b);
335
- const content = relations[b];
343
+ for (const y of ys) {
344
+ const contentKey = this.makeContentKey(x, y);
345
+ const content = relations[y];
336
346
  this.setContent(contentKey, content);
337
347
  }
338
348
  }
@@ -1729,142 +1739,6 @@ function ingestAtomUpdate(applying, atomUpdate, store) {
1729
1739
  }
1730
1740
  setIntoStore(store, token, value);
1731
1741
  }
1732
- function allocateIntoStore(store, provenance, key) {
1733
- const stringKey = stringifyJson(key);
1734
- try {
1735
- const above = [];
1736
- let allocationAttachmentStyle;
1737
- if (provenance === `root`) {
1738
- above.push(store.molecules.get(`"root"`));
1739
- allocationAttachmentStyle = `all`;
1740
- } else if (provenance[0][0] === T$) {
1741
- allocationAttachmentStyle = `any`;
1742
- const provenanceKey = stringifyJson(provenance);
1743
- const provenanceMolecule = store.molecules.get(provenanceKey);
1744
- if (!provenanceMolecule) {
1745
- throw new Error(
1746
- `Molecule ${provenanceKey} not found in store "${store.config.name}"`
1747
- );
1748
- }
1749
- above.push(provenanceMolecule);
1750
- } else {
1751
- const allocationIsCompound = key[0][0] === T$;
1752
- if (allocationIsCompound) {
1753
- allocationAttachmentStyle = `all`;
1754
- for (const claim of provenance) {
1755
- const provenanceKey = stringifyJson(claim);
1756
- const provenanceMolecule = store.molecules.get(provenanceKey);
1757
- if (!provenanceMolecule) {
1758
- throw new Error(
1759
- `Molecule ${provenanceKey} not found in store "${store.config.name}"`
1760
- );
1761
- }
1762
- above.push(provenanceMolecule);
1763
- }
1764
- } else {
1765
- allocationAttachmentStyle = `any`;
1766
- const provenanceKey = stringifyJson(provenance);
1767
- const provenanceMolecule = store.molecules.get(provenanceKey);
1768
- if (!provenanceMolecule) {
1769
- throw new Error(
1770
- `Molecule ${provenanceKey} not found in store "${store.config.name}"`
1771
- );
1772
- }
1773
- above.push(provenanceMolecule);
1774
- }
1775
- }
1776
- const molecule = new Molecule$1(above, key);
1777
- molecule._dependsOn = allocationAttachmentStyle;
1778
- store.molecules.set(stringKey, molecule);
1779
- for (const aboveMolecule of above) {
1780
- aboveMolecule.below.set(molecule.stringKey, molecule);
1781
- }
1782
- const creationEvent = {
1783
- type: `molecule_creation`,
1784
- subType: `modern`,
1785
- key: molecule.key,
1786
- provenance
1787
- };
1788
- const target = newest$1(store);
1789
- const isTransaction = isChildStore$1(target) && target.transactionMeta.phase === `building`;
1790
- if (isTransaction) {
1791
- target.transactionMeta.update.updates.push(creationEvent);
1792
- } else {
1793
- target.on.moleculeCreationStart.next(creationEvent);
1794
- }
1795
- } catch (thrown) {
1796
- if (thrown instanceof Error) {
1797
- store.logger.error(
1798
- `\u274C`,
1799
- `molecule`,
1800
- stringKey,
1801
- `allocation failed:`,
1802
- thrown.message
1803
- );
1804
- }
1805
- }
1806
- return key;
1807
- }
1808
- function deallocateFromStore(store, claim) {
1809
- const stringKey = stringifyJson(claim);
1810
- const molecule = store.molecules.get(stringKey);
1811
- if (!molecule) {
1812
- throw new Error(
1813
- `Molecule ${stringKey} not found in store "${store.config.name}"`
1814
- );
1815
- }
1816
- for (const join of molecule.joins.values()) {
1817
- join.relations.delete(molecule.key);
1818
- join.molecules.delete(molecule.stringKey);
1819
- }
1820
- let provenance;
1821
- if (molecule.above.size === 1) {
1822
- const above = molecule.above.values().next().value;
1823
- provenance = above.key;
1824
- } else {
1825
- provenance = [...molecule.above.values()].map(({ key }) => key);
1826
- }
1827
- const values = [];
1828
- for (const stateToken of molecule.tokens.values()) {
1829
- const tokenFamily = stateToken.family;
1830
- values.push([tokenFamily.key, store.valueMap.get(stateToken.key)]);
1831
- }
1832
- for (const state of molecule.tokens.values()) {
1833
- disposeFromStore$1(store, state);
1834
- }
1835
- for (const child of molecule.below.values()) {
1836
- if (child.dependsOn === `all`) {
1837
- deallocateFromStore(store, child.key);
1838
- } else {
1839
- child.above.delete(molecule.stringKey);
1840
- if (child.above.size === 0) {
1841
- deallocateFromStore(store, child.key);
1842
- }
1843
- }
1844
- }
1845
- molecule.below.clear();
1846
- const disposalEvent = {
1847
- type: `molecule_disposal`,
1848
- subType: `modern`,
1849
- key: molecule.key,
1850
- values,
1851
- provenance
1852
- };
1853
- const target = newest$1(store);
1854
- const isTransaction = isChildStore$1(target) && target.transactionMeta.phase === `building`;
1855
- if (isTransaction) {
1856
- target.transactionMeta.update.updates.push(disposalEvent);
1857
- } else {
1858
- target.on.moleculeDisposal.next(disposalEvent);
1859
- }
1860
- target.molecules.delete(molecule.stringKey);
1861
- for (const parent of molecule.above.values()) {
1862
- parent.below.delete(molecule.stringKey);
1863
- }
1864
- }
1865
- var T$ = `T$`;
1866
-
1867
- // internal/src/ingest-updates/ingest-creation-disposal.ts
1868
1742
  function ingestCreationEvent(update, applying, store) {
1869
1743
  switch (applying) {
1870
1744
  case `newValue`: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Transceiver, Func, EnvironmentData, Flat, Subject, Store, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
1
+ import { Transceiver, Func, EnvironmentData, Flat, Subject, Store, Each, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
2
2
  import { Json, JsonInterface, Canonical, stringified } from 'atom.io/json';
3
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';
4
4
  import { findState } from 'atom.io/ephemeral';
@@ -196,9 +196,9 @@ type CtorToolkit<K extends Canonical> = Flat<Omit<ActorToolkit$1, `find`> & {
196
196
  bond<T>(family: ReadonlySelectorFamilyToken$1<T, K>): ReadonlySelectorToken$1<T>;
197
197
  bond<T>(family: WritableFamilyToken$1<T, K>): WritableToken$1<T>;
198
198
  bond<T>(family: ReadableFamilyToken$1<T, K>): ReadableToken$1<T>;
199
- bond<J extends JoinToken<any, any, any, any>>(joinToken: J, role: {
200
- as: J extends JoinToken<infer A, infer B, any, any> ? A | B : never;
201
- }): J extends JoinToken<any, any, any, infer Content> ? Content extends null ? {
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
202
  relatedKeys: ReadonlySelectorToken$1<string[]>;
203
203
  } : {
204
204
  relatedKeys: ReadonlySelectorToken$1<string[]>;
@@ -243,6 +243,54 @@ type MoleculeType<T extends MoleculeFamilyToken<any>> = T extends MoleculeFamily
243
243
  type MoleculeKey<M extends MoleculeConstructor> = InstanceType<M>[`key`];
244
244
  declare function makeRootMoleculeInStore(key: string, store?: Store): MoleculeToken<ObjectConstructor>;
245
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
+ };
257
+ declare const T$ = "T$";
258
+ type T$ = typeof T$;
259
+ type TypeTag<T extends string> = `${T$}--${T}`;
260
+ type SingularTypedKey<T extends string = string> = `${T}::${string}`;
261
+ type CompoundTypedKey<A extends string = string, B extends string = string, C extends string = string> = `${TypeTag<A>}==${SingularTypedKey<B>}++${SingularTypedKey<C>}`;
262
+ type TypedKey<A extends string = string, B extends string = string, C extends string = string> = CompoundTypedKey<A, B, C> | SingularTypedKey<A>;
263
+ type Scope = SingularTypedKey[];
264
+ type MutualFealty = {
265
+ above: Scope;
266
+ below: CompoundTypedKey;
267
+ style: `all` | `any`;
268
+ };
269
+ type ExclusiveFealty = {
270
+ above: TypedKey | `root`;
271
+ below: Scope;
272
+ };
273
+ type Fealty = ExclusiveFealty | MutualFealty;
274
+ type Hierarchy<F extends Fealty[] = Fealty[]> = Each<F>;
275
+ type Vassal<H extends Hierarchy> = {
276
+ [K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : H[K] extends {
277
+ below: Array<infer V>;
278
+ } ? V extends TypedKey ? V : never : never;
279
+ }[keyof H];
280
+ type Above<TK extends TypedKey, H extends Hierarchy> = {
281
+ [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`below`] ? H[K][`above`] : never : H[K] extends {
282
+ below: Array<infer V>;
283
+ } ? TK extends V ? H[K] extends ExclusiveFealty ? H[K][`above`] : never : never : never;
284
+ }[keyof H];
285
+ type Below<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
286
+ [K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`above`] ? H[K][`below`] : TK extends H[K][`above`][number] ? H[K][`below`] : never : H[K] extends {
287
+ above: infer V;
288
+ } ? TK extends V ? H[K] extends ExclusiveFealty ? H[K][`below`][number] : never : never : never;
289
+ }[keyof H];
290
+ type Mutuals<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
291
+ [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
+ }[keyof H];
293
+
246
294
  declare function disposeState(token: MoleculeToken<any> | ReadableToken<any>): void;
247
295
  declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<any, K>, key: K): void;
248
296
  declare function disposeState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: MoleculeKey<M>): void;
@@ -444,4 +492,4 @@ type FamilyMetadata<K extends Canonical = any> = {
444
492
  subKey: stringified<K>;
445
493
  };
446
494
 
447
- export { type ActorToolkit, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type CtorToolkit, type Effectors, type FamilyMetadata, type GetterToolkit, 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 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 StateCreation, type StateDisposal, type StateUpdate, 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 UpdateHandler, type WritableFamilyToken, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState, getState, isToken, makeMolecule, makeRootMoleculeInStore, moleculeFamily, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
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 };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { makeMolecule, makeRootMoleculeInStore, moleculeFamily } from './chunk-ZKG6ZA4I.js';
1
+ export { $provenance, T$, allocateIntoStore, deallocateFromStore, makeMolecule, makeRootMoleculeInStore, moleculeFamily, realm } from './chunk-ADMEAXYU.js';
2
2
  import './chunk-XWL6SNVU.js';
3
3
  import * as Internal from 'atom.io/internal';
4
4
  import { createStandaloneAtom, IMPLICIT, createAtomFamily, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, findInStore, getFromStore, setIntoStore, disposeFromStore, subscribeInStore, timeTravel, createMoleculeFamily, makeMoleculeInStore, actUponStore, arbitrary } from 'atom.io/internal';