atom.io 0.31.0 → 0.32.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 (171) hide show
  1. package/data/dist/index.d.ts +867 -101
  2. package/data/dist/index.js +10 -558
  3. package/data/src/index.ts +0 -2
  4. package/data/src/struct-family.ts +1 -1
  5. package/data/src/struct.ts +1 -2
  6. package/dist/chunk-354XQWHH.js +153 -0
  7. package/dist/chunk-4LWKCEW3.js +14 -0
  8. package/dist/chunk-5F2V7S3B.js +83 -0
  9. package/dist/chunk-ECOMOMUN.js +631 -0
  10. package/dist/{chunk-42UH5F5Q.js → chunk-GY2XQYZY.js} +2051 -755
  11. package/dist/chunk-NF7FJKJD.js +107 -0
  12. package/dist/chunk-R3ZUK5EH.js +1024 -0
  13. package/dist/chunk-Z2UJW4NQ.js +523 -0
  14. package/dist/index.d.ts +855 -127
  15. package/dist/index.js +1 -143
  16. package/eslint-plugin/dist/index.d.ts +1 -30
  17. package/eslint-plugin/dist/index.js +0 -146
  18. package/eslint-plugin/src/index.ts +0 -1
  19. package/eslint-plugin/src/rules/index.ts +0 -1
  20. package/internal/dist/index.d.ts +794 -70
  21. package/internal/dist/index.js +1 -2
  22. package/internal/src/atom/create-regular-atom.ts +3 -3
  23. package/internal/src/atom/dispose-atom.ts +4 -13
  24. package/internal/src/atom/is-default.ts +3 -3
  25. package/internal/src/caching.ts +5 -5
  26. package/internal/src/capitalize.ts +3 -0
  27. package/internal/src/families/create-readonly-selector-family.ts +5 -6
  28. package/internal/src/families/create-writable-selector-family.ts +1 -4
  29. package/internal/src/families/dispose-from-store.ts +3 -13
  30. package/internal/src/families/find-in-store.ts +1 -6
  31. package/internal/src/get-state/get-from-store.ts +2 -2
  32. package/internal/src/get-state/read-or-compute-value.ts +1 -1
  33. package/internal/src/index.ts +19 -9
  34. package/internal/src/ingest-updates/ingest-creation-disposal.ts +2 -3
  35. package/internal/src/install-into-store.ts +48 -0
  36. package/internal/src/join/edit-relations-in-store.ts +32 -0
  37. package/internal/src/join/find-relations-in-store.ts +124 -0
  38. package/internal/src/join/get-internal-relations-from-store.ts +14 -0
  39. package/internal/src/join/get-join.ts +31 -0
  40. package/internal/src/join/index.ts +5 -0
  41. package/{data/src/join.ts → internal/src/join/join-internal.ts} +20 -429
  42. package/internal/src/keys.ts +7 -7
  43. package/internal/src/molecule.ts +299 -0
  44. package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
  45. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  46. package/internal/src/mutable/get-json-token.ts +1 -1
  47. package/internal/src/mutable/tracker-family.ts +19 -17
  48. package/internal/src/mutable/tracker.ts +8 -8
  49. package/internal/src/not-found-error.ts +8 -30
  50. package/internal/src/pretty-print.ts +2 -13
  51. package/internal/src/selector/create-readonly-selector.ts +3 -7
  52. package/internal/src/selector/create-writable-selector.ts +4 -4
  53. package/internal/src/selector/dispose-selector.ts +20 -11
  54. package/internal/src/selector/get-selector-dependency-keys.ts +1 -1
  55. package/internal/src/selector/register-selector.ts +7 -17
  56. package/internal/src/selector/trace-selector-atoms.ts +2 -2
  57. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  58. package/internal/src/set-state/emit-update.ts +1 -1
  59. package/internal/src/set-state/evict-downstream.ts +1 -1
  60. package/internal/src/set-state/set-atom-or-selector.ts +1 -1
  61. package/internal/src/set-state/set-atom.ts +10 -10
  62. package/internal/src/set-state/set-into-store.ts +2 -2
  63. package/internal/src/set-state/stow-update.ts +1 -1
  64. package/internal/src/store/deposit.ts +10 -8
  65. package/internal/src/store/store.ts +1 -1
  66. package/internal/src/store/withdraw.ts +34 -53
  67. package/internal/src/subscribe/recall-state.ts +1 -1
  68. package/internal/src/subscribe/subscribe-in-store.ts +3 -3
  69. package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
  70. package/internal/src/subscribe/subscribe-to-state.ts +5 -5
  71. package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
  72. package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
  73. package/internal/src/timeline/create-timeline.ts +17 -37
  74. package/internal/src/transaction/act-upon-store.ts +2 -2
  75. package/internal/src/transaction/apply-transaction.ts +5 -5
  76. package/internal/src/transaction/assign-transaction-to-continuity.ts +1 -1
  77. package/internal/src/transaction/build-transaction.ts +5 -8
  78. package/internal/src/transaction/create-transaction.ts +3 -3
  79. package/internal/src/transaction/get-epoch-number.ts +3 -3
  80. package/internal/src/transaction/set-epoch-number.ts +2 -2
  81. package/introspection/dist/index.d.ts +922 -6
  82. package/introspection/dist/index.js +2 -620
  83. package/json/dist/index.d.ts +899 -5
  84. package/json/dist/index.js +1 -81
  85. package/json/src/select-json-family.ts +3 -14
  86. package/package.json +27 -45
  87. package/react/dist/index.d.ts +921 -3
  88. package/react/dist/index.js +2 -82
  89. package/react/src/use-o.ts +1 -1
  90. package/react/src/use-tl.ts +2 -2
  91. package/react-devtools/dist/index.css +16 -14
  92. package/react-devtools/dist/index.d.ts +26 -1
  93. package/react-devtools/dist/index.js +6 -6
  94. package/react-devtools/src/devtools.scss +16 -14
  95. package/realtime/dist/index.d.ts +202 -8
  96. package/realtime/dist/index.js +2 -107
  97. package/realtime/src/realtime-continuity.ts +2 -2
  98. package/realtime/src/shared-room-store.ts +1 -2
  99. package/realtime-client/dist/index.d.ts +960 -22
  100. package/realtime-client/dist/index.js +3 -509
  101. package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
  102. package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
  103. package/realtime-client/src/pull-atom-family-member.ts +2 -2
  104. package/realtime-client/src/pull-atom.ts +2 -2
  105. package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
  106. package/realtime-client/src/pull-mutable-atom.ts +2 -2
  107. package/realtime-client/src/pull-selector-family-member.ts +4 -4
  108. package/realtime-client/src/pull-selector.ts +4 -4
  109. package/realtime-client/src/push-state.ts +5 -10
  110. package/realtime-client/src/server-action.ts +4 -4
  111. package/realtime-client/src/sync-continuity.ts +6 -6
  112. package/realtime-react/dist/index.d.ts +166 -12
  113. package/realtime-react/dist/index.js +5 -154
  114. package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
  115. package/realtime-react/src/use-pull-atom.ts +1 -1
  116. package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
  117. package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
  118. package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
  119. package/realtime-react/src/use-pull-selector.ts +1 -1
  120. package/realtime-react/src/use-push.ts +1 -1
  121. package/realtime-react/src/use-server-action.ts +2 -2
  122. package/realtime-react/src/use-sync-continuity.ts +1 -1
  123. package/realtime-server/dist/index.d.ts +971 -28
  124. package/realtime-server/dist/index.js +3 -1001
  125. package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
  126. package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
  127. package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
  128. package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
  129. package/realtime-server/src/ipc-sockets/child-socket.ts +0 -1
  130. package/realtime-server/src/realtime-action-receiver.ts +1 -1
  131. package/realtime-server/src/realtime-family-provider.ts +2 -2
  132. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  133. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  134. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
  135. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
  136. package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
  137. package/realtime-server/src/realtime-state-provider.ts +2 -2
  138. package/realtime-testing/dist/index.d.ts +1091 -3
  139. package/realtime-testing/dist/index.js +23 -26
  140. package/realtime-testing/src/setup-realtime-test.tsx +6 -5
  141. package/src/atom.ts +53 -29
  142. package/src/dispose-state.ts +12 -2
  143. package/{ephemeral/src → src}/find-state.ts +35 -25
  144. package/src/get-state.ts +16 -0
  145. package/src/index.ts +77 -3
  146. package/src/join.ts +218 -0
  147. package/src/realm.ts +169 -0
  148. package/src/selector.ts +20 -0
  149. package/src/set-state.ts +16 -8
  150. package/src/silo.ts +13 -7
  151. package/src/timeline.ts +1 -1
  152. package/src/transaction.ts +4 -8
  153. package/transceivers/set-rtx/dist/index.d.ts +37 -2
  154. package/transceivers/set-rtx/dist/index.js +1 -212
  155. package/transceivers/set-rtx/src/set-rtx.ts +4 -1
  156. package/web/dist/index.d.ts +30 -1
  157. package/web/dist/index.js +1 -15
  158. package/data/src/until.ts +0 -15
  159. package/dist/chunk-ICGFFQ3H.js +0 -272
  160. package/ephemeral/dist/index.d.ts +0 -57
  161. package/ephemeral/dist/index.js +0 -9
  162. package/ephemeral/package.json +0 -13
  163. package/ephemeral/src/index.ts +0 -1
  164. package/eslint-plugin/src/rules/lifespan.ts +0 -203
  165. package/immortal/dist/index.d.ts +0 -12
  166. package/immortal/dist/index.js +0 -9
  167. package/immortal/package.json +0 -13
  168. package/immortal/src/index.ts +0 -1
  169. package/immortal/src/seek-state.ts +0 -60
  170. package/src/allocate.ts +0 -443
  171. package/src/molecule.ts +0 -16
package/src/allocate.ts DELETED
@@ -1,443 +0,0 @@
1
- import type { Each, Store } from "atom.io/internal"
2
- import {
3
- disposeFromStore,
4
- findInStore,
5
- getTrace,
6
- IMPLICIT,
7
- isChildStore,
8
- newest,
9
- } from "atom.io/internal"
10
- import type { Canonical, stringified } from "atom.io/json"
11
- import { parseJson, stringifyJson } from "atom.io/json"
12
-
13
- import { makeRootMoleculeInStore } from "./molecule"
14
- import type {
15
- MoleculeCreation,
16
- MoleculeDisposal,
17
- MoleculeTransfer,
18
- } from "./transaction"
19
-
20
- export const $claim = Symbol(`claim`)
21
- export type Claim<K extends Canonical> = K & { [$claim]?: true }
22
-
23
- export function allocateIntoStore<
24
- H extends Hierarchy,
25
- V extends Vassal<H>,
26
- A extends Above<V, H>,
27
- >(
28
- store: Store,
29
- provenance: A,
30
- key: V,
31
- dependsOn: `all` | `any` = `any`,
32
- ): Claim<V> {
33
- const origin = provenance as Canonical | [Canonical, Canonical]
34
- const stringKey = stringifyJson(key)
35
- const invalidKeys: stringified<Canonical>[] = []
36
- const target = newest(store)
37
-
38
- if (Array.isArray(origin)) {
39
- for (const formerClaim of origin) {
40
- const claimString = stringifyJson(formerClaim)
41
- const claim = target.molecules.get(claimString)
42
- if (claim) {
43
- store.moleculeGraph.set(claimString, stringKey, { source: claimString })
44
- } else {
45
- invalidKeys.push(claimString)
46
- }
47
- }
48
- } else {
49
- const claimString = stringifyJson(origin)
50
- const claim = target.molecules.get(claimString)
51
- if (claim) {
52
- store.moleculeGraph.set(claimString, stringKey, { source: claimString })
53
- } else {
54
- invalidKeys.push(claimString)
55
- }
56
- }
57
- if (invalidKeys.length === 0) {
58
- target.molecules.set(stringKey, { key, stringKey, dependsOn })
59
- }
60
-
61
- const creationEvent: MoleculeCreation = {
62
- type: `molecule_creation`,
63
- key,
64
- provenance: origin,
65
- }
66
- const isTransaction =
67
- isChildStore(target) && target.transactionMeta.phase === `building`
68
- if (isTransaction) {
69
- target.transactionMeta.update.updates.push(creationEvent)
70
- } else {
71
- target.on.moleculeCreation.next(creationEvent)
72
- }
73
-
74
- for (const claim of invalidKeys) {
75
- const disposal = store.disposalTraces.buffer.find(
76
- (item) => item?.key === claim,
77
- )
78
- store.logger.error(
79
- `❌`,
80
- `molecule`,
81
- key,
82
- `allocation failed:`,
83
- `Could not allocate to ${claim} in store "${store.config.name}".`,
84
- disposal
85
- ? `\n ${claim} was most recently disposed\n${disposal.trace}`
86
- : `No previous disposal trace for ${claim} was found.`,
87
- )
88
- }
89
-
90
- return key as Claim<V>
91
- }
92
-
93
- export function fuseWithinStore<
94
- H extends Hierarchy,
95
- C extends CompoundFrom<H>,
96
- T extends C extends CompoundTypedKey<infer t, any, any> ? t : never,
97
- A extends C extends CompoundTypedKey<any, infer a, any> ? a : never,
98
- B extends C extends CompoundTypedKey<any, any, infer b> ? b : never,
99
- >(
100
- store: Store,
101
- type: T,
102
- sideA: SingularTypedKey<A>,
103
- sideB: SingularTypedKey<B>,
104
- ): Claim<CompoundTypedKey<T, A, B>> {
105
- const compoundKey: CompoundTypedKey<T, A, B> =
106
- `T$--${type}==${sideA}++${sideB}`
107
- const above = [sideA, sideB] as Above<Vassal<H>, H>
108
- allocateIntoStore<H, Vassal<H>, Above<Vassal<H>, H>>(
109
- store,
110
- above,
111
- compoundKey as Vassal<H>,
112
- `all`,
113
- )
114
- return compoundKey
115
- }
116
-
117
- export function deallocateFromStore<H extends Hierarchy, V extends Vassal<H>>(
118
- store: Store,
119
- claim: Claim<V>,
120
- ): void {
121
- const stringKey = stringifyJson(claim)
122
-
123
- const molecule = store.molecules.get(stringKey)
124
- if (!molecule) {
125
- const disposal = store.disposalTraces.buffer.find(
126
- (item) => item?.key === stringKey,
127
- )
128
- store.logger.error(
129
- `❌`,
130
- `molecule`,
131
- claim,
132
- `deallocation failed:`,
133
- `Could not find allocation for ${stringKey} in store "${store.config.name}".`,
134
- disposal
135
- ? `\n This state was most recently deallocated\n${disposal.trace}`
136
- : `No previous disposal trace for ${stringKey} was found.`,
137
- )
138
- return
139
- }
140
-
141
- const joinKeys = store.moleculeJoins.getRelatedKeys(
142
- molecule.key as string /* 💥 RECONCILE */,
143
- )
144
- if (joinKeys) {
145
- for (const joinKey of joinKeys) {
146
- const join = store.joins.get(joinKey)
147
- if (join) {
148
- join.relations.delete(molecule.key)
149
- join.molecules.delete(molecule.stringKey) // get rid of
150
- }
151
- }
152
- }
153
- store.moleculeJoins.delete(molecule.stringKey)
154
-
155
- const provenance: stringified<Canonical>[] = []
156
-
157
- const values: [string, any][] = []
158
- const disposalEvent: MoleculeDisposal = {
159
- type: `molecule_disposal`,
160
- key: molecule.key,
161
- values,
162
- provenance,
163
- }
164
- const target = newest(store)
165
- target.molecules.delete(stringKey)
166
- const isTransaction =
167
- isChildStore(target) && target.transactionMeta.phase === `building`
168
- if (isTransaction) {
169
- target.transactionMeta.update.updates.push(disposalEvent)
170
- }
171
- const relatedMolecules = store.moleculeGraph.getRelationEntries({
172
- downstreamMoleculeKey: molecule.stringKey,
173
- })
174
- if (relatedMolecules) {
175
- for (const [relatedStringKey, { source }] of relatedMolecules) {
176
- if (source === molecule.stringKey) {
177
- const relatedKey = parseJson(relatedStringKey)
178
- deallocateFromStore<any, any>(store, relatedKey)
179
- } else {
180
- provenance.push(source)
181
- }
182
- }
183
- }
184
- const familyKeys = target.moleculeData.getRelatedKeys(molecule.stringKey)
185
- if (familyKeys) {
186
- for (const familyKey of familyKeys) {
187
- // biome-ignore lint/style/noNonNullAssertion: tokens of molecules must have a family
188
- const family = target.families.get(familyKey)!
189
- const token = findInStore(store, family, molecule.key)
190
- values.push([family.key, token])
191
- disposeFromStore(store, token)
192
- }
193
- }
194
-
195
- target.moleculeGraph.delete(molecule.stringKey)
196
- target.moleculeJoins.delete(molecule.stringKey)
197
- target.moleculeData.delete(molecule.stringKey)
198
-
199
- if (!isTransaction) {
200
- target.on.moleculeDisposal.next(disposalEvent)
201
- }
202
- target.molecules.delete(molecule.stringKey)
203
-
204
- const trace = getTrace(new Error())
205
- store.disposalTraces.add({ key: stringKey, trace })
206
- }
207
- export function claimWithinStore<
208
- H extends Hierarchy,
209
- V extends Exclude<Vassal<H>, CompoundTypedKey>,
210
- A extends Above<V, H>,
211
- >(
212
- store: Store,
213
- newProvenance: A,
214
- claim: Claim<V>,
215
- exclusive?: `exclusive`,
216
- ): Claim<V> {
217
- const stringKey = stringifyJson(claim)
218
- const target = newest(store)
219
- const molecule = target.molecules.get(stringKey)
220
- if (!molecule) {
221
- const disposal = store.disposalTraces.buffer.find(
222
- (item) => item?.key === stringKey,
223
- )
224
- store.logger.error(
225
- `❌`,
226
- `molecule`,
227
- claim,
228
- `claim failed:`,
229
- `Could not allocate to ${stringKey} in store "${store.config.name}".`,
230
- disposal
231
- ? `\n ${stringKey} was most recently disposed\n${disposal.trace}`
232
- : `No previous disposal trace for ${stringKey} was found.`,
233
- )
234
- return claim
235
- }
236
-
237
- const newProvenanceKey = stringifyJson(newProvenance as Canonical)
238
- const newProvenanceMolecule = target.molecules.get(newProvenanceKey)
239
- if (!newProvenanceMolecule) {
240
- const disposal = store.disposalTraces.buffer.find(
241
- (item) => item?.key === newProvenanceKey,
242
- )
243
- store.logger.error(
244
- `❌`,
245
- `molecule`,
246
- claim,
247
- `claim failed:`,
248
- `Could not allocate to ${newProvenanceKey} in store "${store.config.name}".`,
249
- disposal
250
- ? `\n ${newProvenanceKey} was most recently disposed\n${disposal.trace}`
251
- : `No previous disposal trace for ${newProvenanceKey} was found.`,
252
- )
253
- return claim
254
- }
255
-
256
- const priorProvenance = store.moleculeGraph
257
- .getRelationEntries({
258
- downstreamMoleculeKey: molecule.stringKey,
259
- })
260
- .filter(([, { source }]) => source !== stringKey)
261
- .map(([key]) => parseJson(key))
262
- if (exclusive) {
263
- target.moleculeGraph.delete(stringKey)
264
- }
265
- target.moleculeGraph.set(
266
- {
267
- upstreamMoleculeKey: newProvenanceMolecule.stringKey,
268
- downstreamMoleculeKey: molecule.stringKey,
269
- },
270
- {
271
- source: newProvenanceMolecule.stringKey,
272
- },
273
- )
274
- const transferEvent: MoleculeTransfer = {
275
- type: `molecule_transfer`,
276
- key: molecule.key,
277
- from: priorProvenance,
278
- to: [newProvenanceMolecule.key],
279
- }
280
- const isTransaction =
281
- isChildStore(target) && target.transactionMeta.phase === `building`
282
- if (isTransaction) {
283
- target.transactionMeta.update.updates.push(transferEvent)
284
- }
285
-
286
- return claim
287
- }
288
-
289
- export class Realm<H extends Hierarchy> {
290
- public store: Store
291
- public constructor(store: Store = IMPLICIT.STORE) {
292
- this.store = store
293
- makeRootMoleculeInStore(`root`, store)
294
- }
295
- public allocate<V extends Vassal<H>, A extends Above<V, H>>(
296
- provenance: A,
297
- key: V,
298
- attachmentStyle?: `all` | `any`,
299
- ): Claim<V> {
300
- return allocateIntoStore<H, V, A>(
301
- this.store,
302
- provenance,
303
- key,
304
- attachmentStyle,
305
- )
306
- }
307
- public fuse<
308
- C extends CompoundFrom<H>,
309
- T extends C extends CompoundTypedKey<infer t, any, any> ? t : never,
310
- A extends C extends CompoundTypedKey<any, infer v, any> ? v : never,
311
- B extends C extends CompoundTypedKey<any, any, infer m> ? m : never,
312
- >(
313
- type: T,
314
- reagentA: SingularTypedKey<A>,
315
- reagentB: SingularTypedKey<B>,
316
- ): Claim<CompoundTypedKey<T, A, B>> {
317
- return fuseWithinStore<H, C, T, A, B>(this.store, type, reagentA, reagentB)
318
- }
319
-
320
- public deallocate<V extends Vassal<H>>(claim: Claim<V>): void {
321
- deallocateFromStore<H, V>(this.store, claim)
322
- }
323
- public claim<
324
- V extends Exclude<Vassal<H>, CompoundTypedKey>,
325
- A extends Above<V, H>,
326
- >(newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V> {
327
- return claimWithinStore<H, V, A>(this.store, newProvenance, claim, exclusive)
328
- }
329
- }
330
-
331
- export const T$ = `T$`
332
- export type T$ = typeof T$
333
- export type TypeTag<T extends string> = `${T$}--${T}`
334
- export type SingularTypedKey<T extends string = string> = `${T}::${string}`
335
- export type CompoundTypedKey<
336
- A extends string = string,
337
- B extends string = string,
338
- C extends string = string,
339
- > = `${TypeTag<A>}==${SingularTypedKey<B>}++${SingularTypedKey<C>}`
340
- export type TypedKey<
341
- A extends string = string,
342
- B extends string = string,
343
- C extends string = string,
344
- > = CompoundTypedKey<A, B, C> | SingularTypedKey<A>
345
- type Scope = SingularTypedKey[]
346
- type MutualFealty = {
347
- above: Scope
348
- below: CompoundTypedKey
349
- }
350
- type ExclusiveFealty = {
351
- above: TypedKey | `root`
352
- below: Scope
353
- }
354
- type Fealty = ExclusiveFealty | MutualFealty
355
-
356
- export type Hierarchy<F extends Fealty[] = Fealty[]> = Each<F>
357
-
358
- export type Vassal<H extends Hierarchy> = {
359
- [K in keyof H]: H[K] extends MutualFealty
360
- ? H[K][`below`]
361
- : H[K] extends { below: Array<infer V> }
362
- ? V extends TypedKey
363
- ? V
364
- : never
365
- : never
366
- }[keyof H]
367
-
368
- export type Above<TK extends TypedKey, H extends Hierarchy> = {
369
- [K in keyof H]: H[K] extends MutualFealty
370
- ? TK extends H[K][`below`]
371
- ? H[K][`above`]
372
- : never
373
- : H[K] extends { below: Array<infer V> }
374
- ? TK extends V
375
- ? H[K] extends ExclusiveFealty
376
- ? H[K][`above`]
377
- : never
378
- : never
379
- : never
380
- }[keyof H]
381
-
382
- export type Below<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
383
- [K in keyof H]: H[K] extends MutualFealty
384
- ? TK extends H[K][`above`]
385
- ? H[K][`below`]
386
- : TK extends H[K][`above`][number]
387
- ? H[K][`below`]
388
- : never
389
- : H[K] extends { above: infer V }
390
- ? TK extends V
391
- ? H[K] extends ExclusiveFealty
392
- ? H[K][`below`][number]
393
- : never
394
- : never
395
- : never
396
- }[keyof H]
397
-
398
- export type Mutuals<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {
399
- [K in keyof H]: H[K] extends MutualFealty
400
- ? TK extends H[K][`above`][number]
401
- ? [mutual: Exclude<H[K][`above`][number], TK>, below: H[K][`below`]]
402
- : never
403
- : never
404
- }[keyof H]
405
-
406
- export type CompoundFrom<H extends Hierarchy> = {
407
- [K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : never
408
- }[keyof H]
409
-
410
- export class Anarchy {
411
- public store: Store
412
- public realm: Realm<any>
413
-
414
- public constructor(store: Store = IMPLICIT.STORE) {
415
- this.store = store
416
- this.realm = new Realm(store)
417
- }
418
-
419
- public allocate(
420
- provenance: Canonical,
421
- key: Canonical,
422
- attachmentStyle?: `all` | `any`,
423
- ): void {
424
- allocateIntoStore<any, any, any>(
425
- this.store,
426
- provenance,
427
- key,
428
- attachmentStyle,
429
- )
430
- }
431
-
432
- public deallocate(key: Canonical): void {
433
- deallocateFromStore<any, any>(this.store, key)
434
- }
435
-
436
- public claim(
437
- newProvenance: Canonical,
438
- key: Canonical,
439
- exclusive?: `exclusive`,
440
- ): void {
441
- claimWithinStore<any, any, any>(this.store, newProvenance, key, exclusive)
442
- }
443
- }
package/src/molecule.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { Molecule, Store } from "atom.io/internal"
2
- import { IMPLICIT } from "atom.io/internal"
3
- import { stringifyJson } from "atom.io/json"
4
-
5
- export function makeRootMoleculeInStore<S extends string>(
6
- key: S,
7
- store: Store = IMPLICIT.STORE,
8
- ): S {
9
- const molecule = {
10
- key,
11
- stringKey: stringifyJson(key),
12
- dependsOn: `any`,
13
- } satisfies Molecule<S>
14
- store.molecules.set(stringifyJson(key), molecule)
15
- return key
16
- }