atom.io 0.31.1 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/data/dist/index.d.ts +3 -154
  2. package/data/dist/index.js +11 -559
  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-3PQTWLQQ.js +83 -0
  7. package/dist/chunk-3ZFTRSNG.js +523 -0
  8. package/dist/chunk-4LWKCEW3.js +14 -0
  9. package/dist/chunk-KVI5OBF2.js +153 -0
  10. package/dist/{chunk-Y5MBNTVU.js → chunk-UQEYZ3OI.js} +1814 -721
  11. package/dist/chunk-UYYKOGZQ.js +1034 -0
  12. package/dist/chunk-VRJP2PCU.js +631 -0
  13. package/dist/chunk-X7SD2NXU.js +108 -0
  14. package/dist/index.d.ts +137 -12
  15. package/dist/index.js +1 -228
  16. package/eslint-plugin/dist/index.d.ts +1 -30
  17. package/eslint-plugin/dist/index.js +3 -149
  18. package/eslint-plugin/src/index.ts +0 -1
  19. package/eslint-plugin/src/rules/explicit-state-types.ts +1 -0
  20. package/eslint-plugin/src/rules/index.ts +0 -1
  21. package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +1 -0
  22. package/eslint-plugin/src/walk.ts +1 -0
  23. package/internal/dist/index.d.ts +129 -58
  24. package/internal/dist/index.js +1 -1
  25. package/internal/src/atom/create-regular-atom.ts +3 -3
  26. package/internal/src/atom/dispose-atom.ts +4 -13
  27. package/internal/src/atom/is-default.ts +3 -3
  28. package/internal/src/caching.ts +5 -5
  29. package/internal/src/capitalize.ts +3 -0
  30. package/internal/src/families/create-readonly-selector-family.ts +5 -6
  31. package/internal/src/families/create-writable-selector-family.ts +1 -4
  32. package/internal/src/families/dispose-from-store.ts +3 -13
  33. package/internal/src/get-state/get-from-store.ts +2 -2
  34. package/internal/src/get-state/read-or-compute-value.ts +1 -1
  35. package/internal/src/index.ts +2 -0
  36. package/internal/src/install-into-store.ts +1 -1
  37. package/internal/src/join/edit-relations-in-store.ts +32 -0
  38. package/internal/src/join/find-relations-in-store.ts +124 -0
  39. package/internal/src/join/get-internal-relations-from-store.ts +14 -0
  40. package/internal/src/join/get-join.ts +31 -0
  41. package/internal/src/join/index.ts +5 -0
  42. package/{data/src/join.ts → internal/src/join/join-internal.ts} +21 -430
  43. package/internal/src/junction.ts +7 -4
  44. package/internal/src/keys.ts +7 -7
  45. package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
  46. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  47. package/internal/src/mutable/get-json-token.ts +1 -1
  48. package/internal/src/mutable/tracker-family.ts +19 -17
  49. package/internal/src/mutable/tracker.ts +8 -8
  50. package/internal/src/pretty-print.ts +1 -1
  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 +6 -9
  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 +4 -2
  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/store.ts +1 -1
  65. package/internal/src/store/withdraw.ts +22 -22
  66. package/internal/src/subscribe/recall-state.ts +1 -1
  67. package/internal/src/subscribe/subscribe-in-store.ts +3 -3
  68. package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
  69. package/internal/src/subscribe/subscribe-to-state.ts +5 -5
  70. package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
  71. package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
  72. package/internal/src/timeline/create-timeline.ts +19 -38
  73. package/internal/src/timeline/time-travel.ts +2 -1
  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.js +2 -620
  82. package/json/dist/index.d.ts +2 -2
  83. package/json/dist/index.js +1 -80
  84. package/json/src/select-json-family.ts +3 -14
  85. package/package.json +31 -49
  86. package/react/dist/index.js +2 -82
  87. package/react/src/use-o.ts +1 -1
  88. package/react/src/use-tl.ts +2 -2
  89. package/react-devtools/dist/index.css +16 -14
  90. package/react-devtools/dist/index.js +31 -18
  91. package/react-devtools/src/Updates.tsx +12 -0
  92. package/react-devtools/src/devtools.scss +16 -14
  93. package/react-devtools/src/json-editor/editors-by-type/utilities/cast-to-json.ts +2 -1
  94. package/realtime/dist/index.d.ts +1 -2
  95. package/realtime/dist/index.js +2 -107
  96. package/realtime/src/realtime-continuity.ts +3 -2
  97. package/realtime/src/shared-room-store.ts +1 -2
  98. package/realtime-client/dist/index.d.ts +9 -9
  99. package/realtime-client/dist/index.js +3 -509
  100. package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
  101. package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
  102. package/realtime-client/src/pull-atom-family-member.ts +2 -2
  103. package/realtime-client/src/pull-atom.ts +2 -2
  104. package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
  105. package/realtime-client/src/pull-mutable-atom.ts +2 -2
  106. package/realtime-client/src/pull-selector-family-member.ts +4 -4
  107. package/realtime-client/src/pull-selector.ts +4 -4
  108. package/realtime-client/src/push-state.ts +5 -10
  109. package/realtime-client/src/server-action.ts +4 -4
  110. package/realtime-client/src/sync-continuity.ts +6 -6
  111. package/realtime-react/dist/index.js +5 -154
  112. package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
  113. package/realtime-react/src/use-pull-atom.ts +1 -1
  114. package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
  115. package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
  116. package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
  117. package/realtime-react/src/use-pull-selector.ts +1 -1
  118. package/realtime-react/src/use-push.ts +1 -1
  119. package/realtime-react/src/use-server-action.ts +2 -2
  120. package/realtime-react/src/use-sync-continuity.ts +1 -1
  121. package/realtime-server/dist/index.d.ts +2 -4
  122. package/realtime-server/dist/index.js +3 -1001
  123. package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
  124. package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
  125. package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
  126. package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
  127. package/realtime-server/src/ipc-sockets/child-socket.ts +2 -0
  128. package/realtime-server/src/realtime-action-receiver.ts +1 -1
  129. package/realtime-server/src/realtime-family-provider.ts +2 -2
  130. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  131. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  132. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
  133. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
  134. package/realtime-server/src/realtime-server-stores/server-sync-store.ts +10 -2
  135. package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
  136. package/realtime-server/src/realtime-state-provider.ts +2 -2
  137. package/realtime-testing/dist/index.js +20 -22
  138. package/realtime-testing/src/setup-realtime-test.tsx +2 -1
  139. package/src/index.ts +4 -0
  140. package/src/join.ts +218 -0
  141. package/src/silo.ts +4 -4
  142. package/src/timeline.ts +1 -1
  143. package/src/transaction.ts +4 -8
  144. package/transceivers/set-rtx/dist/index.d.ts +4 -3
  145. package/transceivers/set-rtx/dist/index.js +1 -215
  146. package/transceivers/set-rtx/src/set-rtx.ts +4 -7
  147. package/web/dist/index.js +1 -15
  148. package/data/src/until.ts +0 -15
  149. package/ephemeral/dist/index.d.ts +0 -67
  150. package/ephemeral/dist/index.js +0 -9
  151. package/ephemeral/package.json +0 -13
  152. package/ephemeral/src/index.ts +0 -1
  153. package/eslint-plugin/src/rules/lifespan.ts +0 -203
  154. package/immortal/dist/index.d.ts +0 -12
  155. package/immortal/dist/index.js +0 -9
  156. package/immortal/package.json +0 -13
  157. package/immortal/src/index.ts +0 -1
  158. package/immortal/src/seek-state.ts +0 -60
  159. package/react-devtools/src/json-editor/assets/Untitled-1.ai +2 -1436
  160. package/react-devtools/src/json-editor/assets/data-vis.ai +1 -1548
  161. package/react-devtools/src/json-editor/comp/json-editor-sketches.ai +5 -1449
  162. /package/{ephemeral/src → src}/find-state.ts +0 -0
@@ -0,0 +1,108 @@
1
+ import { atom, SetRTX, join, selectorFamily, getInternalRelations, assignTransactionToContinuity, IMPLICIT, setEpochNumberOfContinuity } from './chunk-UQEYZ3OI.js';
2
+
3
+ // realtime/src/realtime-continuity.ts
4
+ var InvariantMap = class extends Map {
5
+ set(key, value) {
6
+ if (this.has(key)) {
7
+ console.warn(`Tried to set a key that already exists in an InvariantMap`, {
8
+ key,
9
+ value
10
+ });
11
+ return this;
12
+ }
13
+ return super.set(key, value);
14
+ }
15
+ clear() {
16
+ throw new Error(`Cannot clear an InvariantMap`);
17
+ }
18
+ };
19
+ var SyncGroup = class _SyncGroup {
20
+ constructor(key) {
21
+ this.key = key;
22
+ }
23
+ type = `continuity`;
24
+ globals = [];
25
+ actions = [];
26
+ perspectives = [];
27
+ static existing = new InvariantMap();
28
+ static create(key, builder) {
29
+ const group = new _SyncGroup(key);
30
+ const { type, globals, actions, perspectives } = builder(group);
31
+ const token = { type, key, globals, actions, perspectives };
32
+ _SyncGroup.existing.set(key, token);
33
+ return token;
34
+ }
35
+ add(...args) {
36
+ const zeroth = args[0];
37
+ switch (zeroth.type) {
38
+ case `atom`:
39
+ case `mutable_atom`:
40
+ this.globals.push(...args);
41
+ break;
42
+ case `transaction`:
43
+ this.actions.push(...args);
44
+ break;
45
+ case `atom_family`:
46
+ case `mutable_atom_family`:
47
+ {
48
+ const [family, index] = args;
49
+ this.perspectives.push({
50
+ type: `realtime_perspective`,
51
+ resourceAtoms: family,
52
+ viewAtoms: index
53
+ });
54
+ }
55
+ break;
56
+ }
57
+ return this;
58
+ }
59
+ };
60
+ function continuity(options) {
61
+ const { key, config } = options;
62
+ const token = SyncGroup.create(key, config);
63
+ const { actions } = token;
64
+ for (const action of actions) {
65
+ assignTransactionToContinuity(IMPLICIT.STORE, key, action.key);
66
+ }
67
+ setEpochNumberOfContinuity(IMPLICIT.STORE, key, -1);
68
+ return token;
69
+ }
70
+
71
+ // realtime/src/shared-room-store.ts
72
+ var usersInThisRoomIndex = atom({
73
+ key: `usersInRoomIndex`,
74
+ mutable: true,
75
+ default: () => new SetRTX(),
76
+ toJson: (set) => set.toJSON(),
77
+ fromJson: (json) => SetRTX.fromJSON(json)
78
+ });
79
+ var roomIndex = atom({
80
+ key: `roomIndex`,
81
+ default: () => new SetRTX(),
82
+ mutable: true,
83
+ toJson: (set) => set.toJSON(),
84
+ fromJson: (json) => SetRTX.fromJSON(json)
85
+ });
86
+ var DEFAULT_USER_IN_ROOM_META = {
87
+ enteredAtEpoch: 0
88
+ };
89
+ var usersInRooms = join(
90
+ {
91
+ key: `usersInRooms`,
92
+ between: [`room`, `user`],
93
+ cardinality: `1:n`,
94
+ isAType: (input) => typeof input === `string`,
95
+ isBType: (input) => typeof input === `string`
96
+ },
97
+ DEFAULT_USER_IN_ROOM_META
98
+ );
99
+ var usersInMyRoomView = selectorFamily({
100
+ key: `usersInMyRoomView`,
101
+ get: (myUsername) => ({ find }) => {
102
+ const usersInRoomsAtoms = getInternalRelations(usersInRooms);
103
+ const myRoomIndex = find(usersInRoomsAtoms, myUsername);
104
+ return [myRoomIndex];
105
+ }
106
+ });
107
+
108
+ export { DEFAULT_USER_IN_ROOM_META, InvariantMap, SyncGroup, continuity, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { Transceiver, Func, EnvironmentData, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate, Store, Each, Flat } from 'atom.io/internal';
2
- import { Json, JsonInterface, Canonical, stringified } from 'atom.io/json';
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
- import { findState } from 'atom.io/ephemeral';
5
- import { seekState } from 'atom.io/immortal';
1
+ import { Transceiver, Func, EnvironmentData, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate, Timeline, JunctionSchemaBase, JunctionEntriesBase, Refinement, Store, Junction, Each, Flat } from 'atom.io/internal';
2
+ import { Canonical, Json, JsonInterface, stringified } from 'atom.io/json';
3
+ import { getState as getState$1, setState as setState$1, findState as findState$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 } from 'atom.io';
4
+ import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
6
5
 
7
6
  /**
8
7
  * @public
@@ -139,19 +138,17 @@ type TransactionUpdate<F extends Func> = {
139
138
  params: Parameters<F>;
140
139
  output: ReturnType<F>;
141
140
  };
142
- type GetterToolkit = Pick<SetterToolkit, `find` | `get` | `json` | `seek`>;
141
+ type GetterToolkit = Pick<SetterToolkit, `find` | `get` | `json`>;
143
142
  type SetterToolkit = Readonly<{
144
143
  get: typeof getState$1;
145
144
  set: typeof setState$1;
146
- find: typeof findState;
147
- seek: typeof seekState;
145
+ find: typeof findState$1;
148
146
  json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
149
147
  }>;
150
148
  type ActorToolkit = Readonly<{
151
149
  get: typeof getState$1;
152
150
  set: typeof setState$1;
153
- find: typeof findState;
154
- seek: typeof seekState;
151
+ find: typeof findState$1;
155
152
  json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
156
153
  dispose: typeof disposeState;
157
154
  run: typeof runTransaction;
@@ -255,6 +252,68 @@ declare function disposeState(token: ReadableToken<any>): void;
255
252
  */
256
253
  declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<any, K>, key: K): void;
257
254
 
255
+ /**
256
+ * @public
257
+ * Finds a {@link MutableAtomToken} in the store
258
+ * @param token - A {@link MutableAtomFamilyToken}
259
+ * @param key - The key of the state
260
+ * @returns
261
+ * The current value of the state
262
+ * @overload Mutable Atom
263
+ */
264
+ declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(token: MutableAtomFamilyToken$1<T, J, K>, key: Key): MutableAtomToken$1<T, J, K>;
265
+ /**
266
+ * @public
267
+ * Finds a state in the store
268
+ * @param token - The token of the state family
269
+ * @param key - The key of the state
270
+ * @returns
271
+ * The current value of the state
272
+ * @overload Regular Atom
273
+ */
274
+ declare function findState<T, K extends Canonical, Key extends K>(token: RegularAtomFamilyToken$1<T, K>, key: Key): RegularAtomToken$1<T, K>;
275
+ /**
276
+ * @public
277
+ * Finds a state in the store
278
+ * @param token - The token of the state family
279
+ * @param key - The key of the state
280
+ * @returns
281
+ * The current value of the state
282
+ * @overload Writable Selector
283
+ */
284
+ declare function findState<T, K extends Canonical, Key extends K>(token: WritableSelectorFamilyToken$1<T, K>, key: Key): WritableSelectorToken$1<T, K>;
285
+ /**
286
+ * @public
287
+ * Finds a state in the store
288
+ * @param token - The token of the state family
289
+ * @param key - The key of the state
290
+ * @returns
291
+ * The current value of the state
292
+ * @overload Readonly Selector
293
+ */
294
+ declare function findState<T, K extends Canonical, Key extends K>(token: ReadonlySelectorFamilyToken$1<T, K>, key: Key): ReadonlySelectorToken$1<T, K>;
295
+ /**
296
+ * @public
297
+ * Finds a state in the store
298
+ * @param token - The token of the state family
299
+ * @param key - The key of the state
300
+ * @returns
301
+ * The current value of the state
302
+ * @overload Writable State
303
+ */
304
+ declare function findState<T, K extends Canonical, Key extends K>(token: WritableFamilyToken$1<T, K>, key: Key): WritableToken$1<T, K>;
305
+ /**
306
+ * @public
307
+ * Finds a {@link ReadableToken} in the store
308
+ * @param token - A {@link ReadableFamilyToken}
309
+ * @param key - The key of the state
310
+ * @returns
311
+ * The current value of the state
312
+ * @overload Unknown
313
+ * @default
314
+ */
315
+ declare function findState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken$1<T, K>, key: Key): ReadableToken$1<T, K>;
316
+
258
317
  /**
259
318
  * @public
260
319
  * Get the current value of a state
@@ -274,6 +333,71 @@ declare function getState<T>(token: ReadableToken<T>): T;
274
333
  */
275
334
  declare function getState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): T;
276
335
 
336
+ interface JoinOptions<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> extends JunctionSchemaBase<ASide, BSide>, Partial<JunctionEntriesBase<AType, BType, Content>> {
337
+ readonly key: string;
338
+ readonly cardinality: Cardinality;
339
+ readonly isAType: Refinement<string, AType>;
340
+ readonly isBType: Refinement<string, BType>;
341
+ }
342
+ type JoinToken<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null = null> = {
343
+ key: string;
344
+ type: `join`;
345
+ cardinality: Cardinality;
346
+ a: ASide;
347
+ b: BSide;
348
+ __aType?: AType;
349
+ __bType?: BType;
350
+ __content?: Content;
351
+ };
352
+ declare function join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`>(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, null>, defaultContent?: undefined, store?: Store): JoinToken<ASide, AType, BSide, BType, Cardinality, null>;
353
+ declare function join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object>(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>, defaultContent: Content, store?: Store): JoinToken<ASide, AType, BSide, BType, Cardinality, Content>;
354
+ type JoinStates<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
355
+ readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorToken$1<[
356
+ AType,
357
+ Content
358
+ ] | null, BType>;
359
+ } & {
360
+ readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorToken$1<[
361
+ BType,
362
+ Content
363
+ ] | null, AType>;
364
+ } : {}) & {
365
+ readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorToken$1<AType | null, BType>;
366
+ } & {
367
+ readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorToken$1<BType | null, AType>;
368
+ } : Cardinality extends `1:n` ? (Content extends Json.Object ? {
369
+ readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorToken$1<[
370
+ AType,
371
+ Content
372
+ ] | null, BType>;
373
+ } & {
374
+ readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorToken$1<[
375
+ BType,
376
+ Content
377
+ ][], AType>;
378
+ } : {}) & {
379
+ readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorToken$1<AType | null, BType>;
380
+ } & {
381
+ readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorToken$1<BType[], AType>;
382
+ } : Cardinality extends `n:n` ? (Content extends Json.Object ? {
383
+ readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlySelectorToken$1<[
384
+ AType,
385
+ Content
386
+ ][], BType>;
387
+ } & {
388
+ readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorToken$1<[
389
+ BType,
390
+ Content
391
+ ][], AType>;
392
+ } : {}) & {
393
+ readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlySelectorToken$1<AType[], BType>;
394
+ } & {
395
+ readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorToken$1<BType[], AType>;
396
+ } : never;
397
+ declare function findRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, key: AType | BType): JoinStates<ASide, AType, BSide, BType, Cardinality, Content>;
398
+ declare function editRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, change: (relations: Junction<ASide, AType, BSide, BType, Content>) => void): void;
399
+ declare function getInternalRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>): MutableAtomFamilyToken$1<SetRTX<string>, SetRTXJson<string>, string>;
400
+
277
401
  declare const LoggerIconDictionary: {
278
402
  readonly "\u231B": "Timeline event fully captured";
279
403
  readonly "\u23E9": "Timeline redo";
@@ -438,7 +562,7 @@ declare class Silo {
438
562
  selectorFamily: typeof selectorFamily;
439
563
  transaction: typeof transaction;
440
564
  timeline: typeof timeline;
441
- findState: typeof findState;
565
+ findState: typeof findState$1;
442
566
  getState: typeof getState;
443
567
  setState: typeof setState;
444
568
  disposeState: typeof disposeState;
@@ -572,5 +696,6 @@ type FamilyMetadata<K extends Canonical = any> = {
572
696
  /** The family member's unique identifier, in the form of a string. */
573
697
  subKey: stringified<K>;
574
698
  };
699
+ type Loadable<T> = Promise<T> | T;
575
700
 
576
- export { $claim, type Above, type ActorToolkit, Anarchy, type AtomDisposal, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomIOToken, 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 Setter, 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, atom, atomFamily, belongsTo, disposeState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
701
+ export { $claim, type Above, type ActorToolkit, Anarchy, type AtomDisposal, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomIOToken, type AtomOnly, type AtomToken, type Below, type Claim, type CompoundFrom, type CompoundTypedKey, type Effectors, type FamilyMetadata, type GetterToolkit, type Hierarchy, type JoinOptions, type JoinStates, type JoinToken, type KeyedStateUpdate, LOG_LEVELS, type Loadable, 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 Setter, 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, atom, atomFamily, belongsTo, disposeState, editRelations, findRelations, findState, getInternalRelations, getState, isToken, join, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
package/dist/index.js CHANGED
@@ -1,229 +1,2 @@
1
- import { newest, isChildStore, withdraw } from './chunk-Y5MBNTVU.js';
1
+ export { $claim, Anarchy, AtomIOLogger, LOG_LEVELS, Realm, Silo, T$, atom, atomFamily, belongsTo, disposeState, editRelations, findRelations, findState, getInternalRelations, getState, isToken, join, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo } from './chunk-UQEYZ3OI.js';
2
2
  import './chunk-XWL6SNVU.js';
3
- import * as Internal from 'atom.io/internal';
4
- import { createStandaloneAtom, IMPLICIT, createAtomFamily, makeRootMoleculeInStore, allocateIntoStore, fuseWithinStore, deallocateFromStore, claimWithinStore, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, findInStore, getFromStore, setIntoStore, disposeFromStore, subscribeInStore, timeTravel, actUponStore, arbitrary } from 'atom.io/internal';
5
-
6
- function atom(options) {
7
- return createStandaloneAtom(IMPLICIT.STORE, options);
8
- }
9
- function atomFamily(options) {
10
- return createAtomFamily(IMPLICIT.STORE, options);
11
- }
12
- function disposeState(...[token, key]) {
13
- if (key) {
14
- Internal.disposeFromStore(Internal.IMPLICIT.STORE, token, key);
15
- } else {
16
- Internal.disposeFromStore(Internal.IMPLICIT.STORE, token);
17
- }
18
- }
19
- function getState(...params) {
20
- if (params.length === 2) {
21
- return Internal.getFromStore(Internal.IMPLICIT.STORE, ...params);
22
- }
23
- return Internal.getFromStore(Internal.IMPLICIT.STORE, ...params);
24
- }
25
-
26
- // src/logger.ts
27
- var LOG_LEVELS = [`info`, `warn`, `error`];
28
- var simpleLog = (logLevel) => (icon, denomination, tokenKey, message, ...rest) => {
29
- console[logLevel](
30
- `${icon} ${denomination} "${tokenKey}" ${message}`,
31
- ...rest
32
- );
33
- };
34
- var simpleLogger = {
35
- error: simpleLog(`error`),
36
- info: simpleLog(`info`),
37
- warn: simpleLog(`warn`)
38
- };
39
- var AtomIOLogger = class {
40
- constructor(logLevel, filter, logger = simpleLogger) {
41
- this.logLevel = logLevel;
42
- this.filter = filter;
43
- this.logger = logger;
44
- }
45
- error = (...args) => {
46
- if ((this.filter?.(...args) ?? true) && this.logLevel !== null) {
47
- this.logger.error(...args);
48
- }
49
- };
50
- info = (...args) => {
51
- if ((this.filter?.(...args) ?? true) && this.logLevel === `info`) {
52
- this.logger.info(...args);
53
- }
54
- };
55
- warn = (...args) => {
56
- if ((this.filter?.(...args) ?? true) && this.logLevel !== `error` && this.logLevel !== null) {
57
- this.logger.warn(...args);
58
- }
59
- };
60
- };
61
- var $claim = Symbol(`claim`);
62
- var Realm = class {
63
- store;
64
- constructor(store = IMPLICIT.STORE) {
65
- this.store = store;
66
- makeRootMoleculeInStore(`root`, store);
67
- }
68
- allocate(provenance, key, attachmentStyle) {
69
- return allocateIntoStore(
70
- this.store,
71
- provenance,
72
- key,
73
- attachmentStyle
74
- );
75
- }
76
- fuse(type, reagentA, reagentB) {
77
- return fuseWithinStore(this.store, type, reagentA, reagentB);
78
- }
79
- deallocate(claim) {
80
- deallocateFromStore(this.store, claim);
81
- }
82
- claim(newProvenance, claim, exclusive) {
83
- return claimWithinStore(this.store, newProvenance, claim, exclusive);
84
- }
85
- };
86
- var Anarchy = class {
87
- store;
88
- realm;
89
- constructor(store = IMPLICIT.STORE) {
90
- this.store = store;
91
- this.realm = new Realm(store);
92
- }
93
- allocate(provenance, key, attachmentStyle) {
94
- allocateIntoStore(
95
- this.store,
96
- provenance,
97
- key,
98
- attachmentStyle
99
- );
100
- }
101
- deallocate(key) {
102
- deallocateFromStore(this.store, key);
103
- }
104
- claim(newProvenance, key, exclusive) {
105
- claimWithinStore(this.store, newProvenance, key, exclusive);
106
- }
107
- };
108
- var T$ = `T$`;
109
- function selector(options) {
110
- return createStandaloneSelector(IMPLICIT.STORE, options);
111
- }
112
- function selectorFamily(options) {
113
- return createSelectorFamily(IMPLICIT.STORE, options);
114
- }
115
- function setState(...params) {
116
- if (params.length === 2) {
117
- Internal.setIntoStore(Internal.IMPLICIT.STORE, ...params);
118
- } else {
119
- Internal.setIntoStore(Internal.IMPLICIT.STORE, ...params);
120
- }
121
- }
122
-
123
- // internal/src/install-into-store.ts
124
- function installIntoStore(tokens, target, source) {
125
- const sourceNewest = newest(source);
126
- if (isChildStore(sourceNewest)) {
127
- source.logger.error(
128
- `\u274C`,
129
- `transaction`,
130
- sourceNewest.transactionMeta.update.key,
131
- `could not install the following tokens into store "${target.config.name} from "${source.config.name}":`,
132
- tokens,
133
- `${sourceNewest.config.name} is undergoing a transaction.`
134
- );
135
- return;
136
- }
137
- const targetNewest = newest(target);
138
- if (isChildStore(targetNewest)) {
139
- target.logger.error(
140
- `\u274C`,
141
- `transaction`,
142
- targetNewest.transactionMeta.update.key,
143
- `could not install the following tokens into store "${target.config.name} from "${source.config.name}":`,
144
- tokens,
145
- `${targetNewest.config.name} is undergoing a transaction.`
146
- );
147
- return;
148
- }
149
- for (const token of tokens) {
150
- const resource = withdraw(token, source);
151
- resource.install(target);
152
- }
153
- }
154
-
155
- // src/silo.ts
156
- var Silo = class {
157
- store;
158
- atom;
159
- atomFamily;
160
- selector;
161
- selectorFamily;
162
- transaction;
163
- timeline;
164
- findState;
165
- getState;
166
- setState;
167
- disposeState;
168
- subscribe;
169
- undo;
170
- redo;
171
- runTransaction;
172
- install;
173
- constructor(config, fromStore = null) {
174
- const s = this.store = new Store(config, fromStore);
175
- this.atom = (options) => createStandaloneAtom(s, options);
176
- this.atomFamily = (options) => createAtomFamily(s, options);
177
- this.selector = (options) => createStandaloneSelector(s, options);
178
- this.selectorFamily = (options) => createSelectorFamily(s, options);
179
- this.transaction = (options) => createTransaction(options, s);
180
- this.timeline = (options) => createTimeline(options, s);
181
- this.findState = (...params) => findInStore(s, ...params);
182
- this.getState = (...params) => getFromStore(s, ...params);
183
- this.setState = (...params) => {
184
- setIntoStore(s, ...params);
185
- };
186
- this.disposeState = (...params) => {
187
- disposeFromStore(s, ...params);
188
- };
189
- this.subscribe = (...params) => subscribeInStore(s, ...params);
190
- this.undo = (token) => {
191
- timeTravel(s, `undo`, token);
192
- };
193
- this.redo = (token) => {
194
- timeTravel(s, `redo`, token);
195
- };
196
- this.runTransaction = (token, id = arbitrary()) => actUponStore(token, id, s);
197
- this.install = (tokens, source = IMPLICIT.STORE) => {
198
- installIntoStore(tokens, s, source);
199
- };
200
- }
201
- };
202
- function subscribe(token, handleUpdate, key = arbitrary()) {
203
- return subscribeInStore(IMPLICIT.STORE, token, handleUpdate, key);
204
- }
205
- var timeline = (options) => {
206
- return createTimeline(options, IMPLICIT.STORE);
207
- };
208
- var redo = (tl) => {
209
- timeTravel(IMPLICIT.STORE, `redo`, tl);
210
- };
211
- var undo = (tl) => {
212
- timeTravel(IMPLICIT.STORE, `undo`, tl);
213
- };
214
- function transaction(options) {
215
- return createTransaction(options, IMPLICIT.STORE);
216
- }
217
- function runTransaction(token, id = arbitrary()) {
218
- return actUponStore(token, id, IMPLICIT.STORE);
219
- }
220
-
221
- // src/validators.ts
222
- function isToken(knownToken, unknownToken) {
223
- return knownToken.key === unknownToken.key;
224
- }
225
- function belongsTo(family, unknownToken) {
226
- return family.key === unknownToken.family?.key;
227
- }
228
-
229
- export { $claim, Anarchy, AtomIOLogger, LOG_LEVELS, Realm, Silo, T$, atom, atomFamily, belongsTo, disposeState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
@@ -6,33 +6,6 @@ import { ESLintUtils } from '@typescript-eslint/utils';
6
6
 
7
7
  declare const explicitStateTypes: ESLintUtils.RuleModule<"noTypeArgument", [], unknown, ESLintUtils.RuleListener>;
8
8
 
9
- declare const lifespan: {
10
- meta: {
11
- type: "problem";
12
- docs: {
13
- description: string;
14
- category: string;
15
- recommended: false;
16
- url: string;
17
- };
18
- schema: {
19
- type: "string";
20
- enum: string[];
21
- default: string;
22
- }[];
23
- };
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
- }>): {
31
- ImportDeclaration(node: ESTree.ImportDeclaration & Rule.NodeParentExtension): void;
32
- CallExpression(node: ESTree.CallExpression & Rule.NodeParentExtension): void;
33
- };
34
- };
35
-
36
9
  declare const synchronousSelectorDependencies: {
37
10
  meta: {
38
11
  type: "problem";
@@ -56,16 +29,14 @@ declare const synchronousSelectorDependencies: {
56
29
  };
57
30
 
58
31
  declare const index_explicitStateTypes: typeof explicitStateTypes;
59
- declare const index_lifespan: typeof lifespan;
60
32
  declare const index_synchronousSelectorDependencies: typeof synchronousSelectorDependencies;
61
33
  declare namespace index {
62
- export { index_explicitStateTypes as explicitStateTypes, index_lifespan as lifespan, index_synchronousSelectorDependencies as synchronousSelectorDependencies };
34
+ export { index_explicitStateTypes as explicitStateTypes, index_synchronousSelectorDependencies as synchronousSelectorDependencies };
63
35
  }
64
36
 
65
37
  declare const _default: {
66
38
  rules: {
67
39
  "explicit-state-types": any;
68
- lifespan: any;
69
40
  "synchronous-selector-dependencies": {
70
41
  meta: {
71
42
  type: "problem";