atom.io 0.26.0 → 0.27.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 (60) hide show
  1. package/data/dist/index.d.ts +3 -3
  2. package/data/src/dict.ts +3 -3
  3. package/dist/chunk-AK23DRMD.js +21 -0
  4. package/dist/index.d.ts +32 -54
  5. package/ephemeral/dist/index.d.ts +7 -7
  6. package/ephemeral/src/find-state.ts +7 -7
  7. package/immortal/dist/index.d.ts +7 -7
  8. package/immortal/src/seek-state.ts +8 -8
  9. package/internal/dist/index.d.ts +56 -59
  10. package/internal/dist/index.js +5 -10
  11. package/internal/src/families/create-atom-family.ts +4 -4
  12. package/internal/src/families/create-readonly-selector-family.ts +2 -2
  13. package/internal/src/families/create-regular-atom-family.ts +2 -2
  14. package/internal/src/families/create-selector-family.ts +4 -4
  15. package/internal/src/families/create-writable-selector-family.ts +2 -2
  16. package/internal/src/families/dispose-from-store.ts +3 -7
  17. package/internal/src/families/find-in-store.ts +9 -9
  18. package/internal/src/families/init-family-member.ts +25 -37
  19. package/internal/src/families/seek-in-store.ts +11 -10
  20. package/internal/src/get-state/get-from-store.ts +3 -3
  21. package/internal/src/molecule/grow-molecule-in-store.ts +9 -9
  22. package/internal/src/mutable/index.ts +0 -1
  23. package/internal/src/mutable/tracker-family.ts +2 -2
  24. package/internal/src/set-state/set-into-store.ts +4 -4
  25. package/internal/src/store/deposit.ts +3 -3
  26. package/internal/src/store/withdraw.ts +10 -9
  27. package/json/dist/index.d.ts +10 -27
  28. package/json/dist/index.js +2 -2
  29. package/json/src/index.ts +8 -3
  30. package/json/src/select-json-family.ts +4 -4
  31. package/package.json +20 -17
  32. package/react/dist/index.d.ts +4 -4
  33. package/react/src/parse-state-overloads.ts +4 -4
  34. package/react/src/use-i.ts +3 -3
  35. package/react/src/use-json.ts +3 -3
  36. package/react/src/use-o.ts +3 -3
  37. package/react-devtools/dist/index.d.ts +1 -1
  38. package/react-devtools/dist/index.js +15 -4
  39. package/react-devtools/src/StateIndex.tsx +5 -4
  40. package/realtime/dist/index.d.ts +3 -3
  41. package/realtime/src/realtime-continuity.ts +2 -2
  42. package/realtime-react/dist/index.d.ts +4 -4
  43. package/realtime-react/src/use-pull-atom-family-member.ts +2 -2
  44. package/realtime-react/src/use-pull-mutable-family-member.ts +2 -2
  45. package/realtime-react/src/use-pull-selector-family-member.ts +2 -2
  46. package/realtime-server/dist/index.d.ts +9 -9
  47. package/realtime-server/src/ipc-sockets/custom-socket.ts +2 -2
  48. package/realtime-server/src/realtime-family-provider.ts +3 -2
  49. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  50. package/src/atom.ts +15 -42
  51. package/src/dispose-state.ts +2 -2
  52. package/src/get-state.ts +4 -4
  53. package/src/index.ts +5 -5
  54. package/src/molecule.ts +4 -3
  55. package/src/selector.ts +17 -39
  56. package/src/set-state.ts +3 -2
  57. package/src/silo.ts +4 -4
  58. package/transceivers/set-rtx/src/set-rtx.ts +5 -5
  59. package/dist/chunk-BF4MVQF6.js +0 -44
  60. package/internal/src/mutable/is-mutable.ts +0 -16
@@ -1,6 +1,6 @@
1
1
  import { lazyLocalStorageEffect } from '../../dist/chunk-H6EDLPKH.js';
2
2
  import { pipe, ifDefined, isArray, isRecord, doesExtend, isPlainObject, raiseError, sprawl, fallback, doNothing, become, mapObject, delve } from '../../dist/chunk-IW6WYRS7.js';
3
- import { JSON_TYPE_NAMES, isString, isNumber, isBoolean, stringifyJson, JSON_DEFAULTS } from '../../dist/chunk-BF4MVQF6.js';
3
+ import { JSON_TYPE_NAMES, stringifyJson, JSON_DEFAULTS } from '../../dist/chunk-AK23DRMD.js';
4
4
  import '../../dist/chunk-XWL6SNVU.js';
5
5
  import { selectorFamily, atom, atomFamily, undo, redo, getState } from 'atom.io';
6
6
  import { attachIntrospectionStates } from 'atom.io/introspection';
@@ -61,6 +61,17 @@ var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isT
61
61
  };
62
62
  var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
63
63
 
64
+ // ../anvl/src/primitive/index.ts
65
+ var isString = (input) => {
66
+ return typeof input === `string`;
67
+ };
68
+ var isNumber = (input) => {
69
+ return typeof input === `number`;
70
+ };
71
+ var isBoolean = (input) => {
72
+ return typeof input === `boolean`;
73
+ };
74
+
64
75
  // ../anvl/src/refinement/refine-json.ts
65
76
  var JSON_PROTOTYPES = [
66
77
  `Array`,
@@ -1496,7 +1507,7 @@ var StateIndexTreeNode = ({ node, isOpenState }) => {
1496
1507
  const isOpen = useO(isOpenState);
1497
1508
  for (const [key, childNode] of node.familyMembers) {
1498
1509
  findState(findViewIsOpenState, key);
1499
- findState(findStateTypeState, childNode);
1510
+ findState(findStateTypeState, childNode.key);
1500
1511
  }
1501
1512
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1502
1513
  /* @__PURE__ */ jsxs("header", { children: [
@@ -1518,7 +1529,7 @@ var StateIndexTreeNode = ({ node, isOpenState }) => {
1518
1529
  {
1519
1530
  node: childNode,
1520
1531
  isOpenState: findState(findViewIsOpenState, childNode.key),
1521
- typeState: findState(findStateTypeState, childNode)
1532
+ typeState: findState(findStateTypeState, childNode.key)
1522
1533
  },
1523
1534
  key
1524
1535
  )) : null
@@ -1542,7 +1553,7 @@ var StateIndex = ({ tokenIndex }) => {
1542
1553
  {
1543
1554
  node,
1544
1555
  isOpenState: findState(findViewIsOpenState, node.key),
1545
- typeState: findState(findStateTypeState, node)
1556
+ typeState: findState(findStateTypeState, node.key)
1546
1557
  },
1547
1558
  key
1548
1559
  );
@@ -6,6 +6,7 @@ import type {
6
6
  import { getState, selectorFamily } from "atom.io"
7
7
  import { findState } from "atom.io/ephemeral"
8
8
  import type { FamilyNode, WritableTokenIndex } from "atom.io/introspection"
9
+ import type { Canonical } from "atom.io/json"
9
10
  import { useI, useO } from "atom.io/react"
10
11
  import type { FC } from "react"
11
12
 
@@ -15,7 +16,7 @@ import { findViewIsOpenState, primitiveRefinery } from "."
15
16
  import { button } from "./Button"
16
17
  import { StoreEditor } from "./StateEditor"
17
18
 
18
- const findStateTypeState = selectorFamily<string, { key: string }>({
19
+ const findStateTypeState = selectorFamily<string, Canonical>({
19
20
  key: `👁‍🗨 State Type`,
20
21
  get:
21
22
  (token) =>
@@ -83,7 +84,7 @@ export const StateIndexTreeNode: FC<{
83
84
  const isOpen = useO(isOpenState)
84
85
  for (const [key, childNode] of node.familyMembers) {
85
86
  findState(findViewIsOpenState, key)
86
- findState(findStateTypeState, childNode)
87
+ findState(findStateTypeState, childNode.key)
87
88
  }
88
89
  return (
89
90
  <>
@@ -104,7 +105,7 @@ export const StateIndexTreeNode: FC<{
104
105
  key={key}
105
106
  node={childNode}
106
107
  isOpenState={findState(findViewIsOpenState, childNode.key)}
107
- typeState={findState(findStateTypeState, childNode)}
108
+ typeState={findState(findStateTypeState, childNode.key)}
108
109
  />
109
110
  ))
110
111
  : null}
@@ -147,7 +148,7 @@ export const StateIndex: FC<{
147
148
  key={key}
148
149
  node={node}
149
150
  isOpenState={findState(findViewIsOpenState, node.key)}
150
- typeState={findState(findStateTypeState, node)}
151
+ typeState={findState(findStateTypeState, node.key)}
151
152
  />
152
153
  )
153
154
  })}
@@ -1,6 +1,6 @@
1
1
  import * as atom_io from 'atom.io';
2
2
  import { AtomFamilyToken, ReadableFamilyToken, ReadableToken, AtomToken, TransactionToken, MutableAtomToken } from 'atom.io';
3
- import { Json } from 'atom.io/json';
3
+ import { Canonical, Json } from 'atom.io/json';
4
4
  import * as atom_io_data from 'atom.io/data';
5
5
  import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
6
6
 
@@ -18,7 +18,7 @@ type ContinuityToken = {
18
18
  readonly key: string;
19
19
  readonly globals: AtomToken<any>[];
20
20
  readonly actions: TransactionToken<any>[];
21
- readonly perspectives: PerspectiveToken<AtomFamilyToken<any, Json.Serializable>, Json.Serializable>[];
21
+ readonly perspectives: PerspectiveToken<AtomFamilyToken<any, Canonical>, Json.Serializable>[];
22
22
  };
23
23
  declare class SyncGroup {
24
24
  protected readonly key: string;
@@ -46,6 +46,6 @@ type UserInRoomMeta = {
46
46
  };
47
47
  declare const DEFAULT_USER_IN_ROOM_META: UserInRoomMeta;
48
48
  declare const usersInRooms: atom_io_data.JoinToken<"room", "user", "1:n", UserInRoomMeta>;
49
- declare const usersInMyRoomView: atom_io.ReadonlySelectorFamilyTokenWithCall<MutableAtomToken<SetRTX<string>, SetRTXJson<string>>[], string>;
49
+ declare const usersInMyRoomView: atom_io.ReadonlySelectorFamilyToken<MutableAtomToken<SetRTX<string>, SetRTXJson<string>>[], string>;
50
50
 
51
51
  export { type ContinuityOptions, type ContinuityToken, DEFAULT_USER_IN_ROOM_META, InvariantMap, type PerspectiveToken, SyncGroup, type UserInRoomMeta, continuity, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex };
@@ -11,7 +11,7 @@ import {
11
11
  IMPLICIT,
12
12
  setEpochNumberOfContinuity,
13
13
  } from "atom.io/internal"
14
- import type { Json } from "atom.io/json"
14
+ import type { Canonical, Json } from "atom.io/json"
15
15
 
16
16
  export class InvariantMap<K, V> extends Map<K, V> {
17
17
  public set(key: K, value: V): this {
@@ -45,7 +45,7 @@ export type ContinuityToken = {
45
45
  readonly globals: AtomToken<any>[]
46
46
  readonly actions: TransactionToken<any>[]
47
47
  readonly perspectives: PerspectiveToken<
48
- AtomFamilyToken<any, Json.Serializable>,
48
+ AtomFamilyToken<any, Canonical>,
49
49
  Json.Serializable
50
50
  >[]
51
51
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { Socket } from 'socket.io-client';
3
3
  import * as AtomIO from 'atom.io';
4
- import { Json } from 'atom.io/json';
4
+ import { Json, Canonical } from 'atom.io/json';
5
5
  import { Transceiver, Func } from 'atom.io/internal';
6
6
  import { ContinuityToken } from 'atom.io/realtime';
7
7
 
@@ -20,15 +20,15 @@ declare const RealtimeProvider: React.FC<{
20
20
 
21
21
  declare function usePullAtom<J extends Json.Serializable>(token: AtomIO.RegularAtomToken<J>): J;
22
22
 
23
- declare function usePullAtomFamilyMember<J extends Json.Serializable, K extends Json.Serializable, Key extends K>(family: AtomIO.RegularAtomFamilyToken<J, K>, subKey: Key): J;
23
+ declare function usePullAtomFamilyMember<J extends Json.Serializable, K extends Canonical, Key extends K>(family: AtomIO.RegularAtomFamilyToken<J, K>, subKey: Key): J;
24
24
 
25
25
  declare function usePullMutable<T extends Transceiver<any>, J extends Json.Serializable>(token: AtomIO.MutableAtomToken<T, J>): T;
26
26
 
27
- declare function usePullMutableAtomFamilyMember<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(familyToken: AtomIO.MutableAtomFamilyToken<T, J, K>, key: Key): T;
27
+ declare function usePullMutableAtomFamilyMember<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(familyToken: AtomIO.MutableAtomFamilyToken<T, J, K>, key: Key): T;
28
28
 
29
29
  declare function usePullSelector<J extends Json.Serializable>(token: AtomIO.SelectorToken<J>): J;
30
30
 
31
- declare function usePullSelectorFamilyMember<T, K extends Json.Serializable, Key extends K>(familyToken: AtomIO.SelectorFamilyToken<T, K>, key: Key): T;
31
+ declare function usePullSelectorFamilyMember<T, K extends Canonical, Key extends K>(familyToken: AtomIO.SelectorFamilyToken<T, K>, key: Key): T;
32
32
 
33
33
  declare function usePush<J extends Json.Serializable>(token: AtomIO.WritableToken<J>): <New extends J>(next: New | ((old: J) => New)) => void;
34
34
 
@@ -1,6 +1,6 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import { findInStore } from "atom.io/internal"
3
- import type { Json } from "atom.io/json"
3
+ import type { Canonical, Json } from "atom.io/json"
4
4
  import { StoreContext, useO } from "atom.io/react"
5
5
  import * as RTC from "atom.io/realtime-client"
6
6
  import * as React from "react"
@@ -9,7 +9,7 @@ import { useRealtimeService } from "./use-realtime-service"
9
9
 
10
10
  export function usePullAtomFamilyMember<
11
11
  J extends Json.Serializable,
12
- K extends Json.Serializable,
12
+ K extends Canonical,
13
13
  Key extends K,
14
14
  >(family: AtomIO.RegularAtomFamilyToken<J, K>, subKey: Key): J {
15
15
  const store = React.useContext(StoreContext)
@@ -1,7 +1,7 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import type { Transceiver } from "atom.io/internal"
3
3
  import { findInStore } from "atom.io/internal"
4
- import type { Json } from "atom.io/json"
4
+ import type { Canonical, Json } from "atom.io/json"
5
5
  import { StoreContext, useO } from "atom.io/react"
6
6
  import * as RTC from "atom.io/realtime-client"
7
7
  import * as React from "react"
@@ -11,7 +11,7 @@ import { useRealtimeService } from "./use-realtime-service"
11
11
  export function usePullMutableAtomFamilyMember<
12
12
  T extends Transceiver<any>,
13
13
  J extends Json.Serializable,
14
- K extends Json.Serializable,
14
+ K extends Canonical,
15
15
  Key extends K,
16
16
  >(familyToken: AtomIO.MutableAtomFamilyToken<T, J, K>, key: Key): T {
17
17
  const store = React.useContext(StoreContext)
@@ -1,6 +1,6 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import { findInStore } from "atom.io/internal"
3
- import type { Json } from "atom.io/json"
3
+ import type { Canonical } from "atom.io/json"
4
4
  import { StoreContext, useO } from "atom.io/react"
5
5
  import * as RTC from "atom.io/realtime-client"
6
6
  import * as React from "react"
@@ -9,7 +9,7 @@ import { useRealtimeService } from "./use-realtime-service"
9
9
 
10
10
  export function usePullSelectorFamilyMember<
11
11
  T,
12
- K extends Json.Serializable,
12
+ K extends Canonical,
13
13
  Key extends K,
14
14
  >(familyToken: AtomIO.SelectorFamilyToken<T, K>, key: Key): T {
15
15
  const store = React.useContext(StoreContext)
@@ -1,5 +1,5 @@
1
1
  import { Subject, Transceiver, Store } from 'atom.io/internal';
2
- import { Json, Stringified, JsonIO } from 'atom.io/json';
2
+ import { Json, stringified, JsonIO, Canonical } from 'atom.io/json';
3
3
  import { ChildProcessWithoutNullStreams } from 'node:child_process';
4
4
  import * as AtomIO from 'atom.io';
5
5
  import { TransactionUpdateContent, TransactionUpdate, WritableToken } from 'atom.io';
@@ -9,7 +9,7 @@ import { Loadable } from 'atom.io/data';
9
9
  import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
10
10
 
11
11
  type Events = Json.Object<string, Json.Serializable[]>;
12
- type StringifiedEvent<Key extends string, Params extends Json.Serializable[]> = Stringified<[Key, ...Params]>;
12
+ type StringifiedEvent<Key extends string, Params extends Json.Serializable[]> = stringified<[Key, ...Params]>;
13
13
  interface EventBuffer<Key extends string, Params extends Json.Serializable[]> extends Buffer {
14
14
  toString(): StringifiedEvent<Key, Params>;
15
15
  }
@@ -88,10 +88,10 @@ type RealtimeContinuitySynchronizer = ReturnType<typeof realtimeContinuitySynchr
88
88
  declare function realtimeContinuitySynchronizer({ socket: initialSocket, store, }: ServerConfig): (continuity: ContinuityToken) => () => void;
89
89
 
90
90
  type FamilyProvider = ReturnType<typeof realtimeAtomFamilyProvider>;
91
- declare function realtimeAtomFamilyProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable, K extends Json.Serializable>(family: AtomIO.RegularAtomFamilyToken<J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
91
+ declare function realtimeAtomFamilyProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable, K extends Canonical>(family: AtomIO.RegularAtomFamilyToken<J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
92
92
 
93
93
  type MutableFamilyProvider = ReturnType<typeof realtimeMutableFamilyProvider>;
94
- declare function realtimeMutableFamilyProvider({ socket, store, }: ServerConfig): <T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(family: AtomIO.MutableAtomFamilyToken<T, J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
94
+ declare function realtimeMutableFamilyProvider({ socket, store, }: ServerConfig): <T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(family: AtomIO.MutableAtomFamilyToken<T, J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
95
95
 
96
96
  type MutableProvider = ReturnType<typeof realtimeMutableProvider>;
97
97
  declare function realtimeMutableProvider({ socket, store, }: ServerConfig): <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
@@ -105,16 +105,16 @@ type LeaveRoomIO = AtomIO.TransactionIO<typeof leaveRoomTX>;
105
105
  declare const destroyRoomTX: AtomIO.TransactionToken<(roomId: string) => void>;
106
106
 
107
107
  type RoomArguments = [script: string, options: string[]] | [script: string];
108
- declare const roomArgumentsAtoms: AtomIO.RegularAtomFamilyTokenWithCall<RoomArguments, string>;
109
- declare const roomSelectors: AtomIO.ReadonlySelectorFamilyTokenWithCall<Loadable<ChildSocket<any, any>>, string>;
108
+ declare const roomArgumentsAtoms: AtomIO.RegularAtomFamilyToken<RoomArguments, string>;
109
+ declare const roomSelectors: AtomIO.ReadonlySelectorFamilyToken<Loadable<ChildSocket<any, any>>, string>;
110
110
 
111
111
  declare function redactTransactionUpdateContent(visibleStateKeys: string[], updates: TransactionUpdateContent[]): TransactionUpdateContent[];
112
- declare const actionOcclusionAtoms: AtomIO.RegularAtomFamilyTokenWithCall<{
112
+ declare const actionOcclusionAtoms: AtomIO.RegularAtomFamilyToken<{
113
113
  occlude: (updates: TransactionUpdateContent[]) => TransactionUpdateContent[];
114
114
  }, string>;
115
- declare const userUnacknowledgedQueues: AtomIO.RegularAtomFamilyTokenWithCall<Pick<TransactionUpdate<any>, "key" | "id" | "epoch" | "updates" | "output">[], string>;
115
+ declare const userUnacknowledgedQueues: AtomIO.RegularAtomFamilyToken<Pick<TransactionUpdate<any>, "key" | "id" | "epoch" | "updates" | "output">[], string>;
116
116
 
117
- declare const socketAtoms: AtomIO.RegularAtomFamilyTokenWithCall<Socket | null, string>;
117
+ declare const socketAtoms: AtomIO.RegularAtomFamilyToken<Socket | null, string>;
118
118
  declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
119
119
  declare const userIndex: AtomIO.MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
120
120
  declare const usersOfSockets: atom_io_data.JoinToken<"user", "socket", "1:1", null>;
@@ -1,4 +1,4 @@
1
- import type { Json, Stringified } from "atom.io/json"
1
+ import type { Json, stringified } from "atom.io/json"
2
2
 
3
3
  import type { Socket } from ".."
4
4
 
@@ -7,7 +7,7 @@ export type Events = Json.Object<string, Json.Serializable[]>
7
7
  export type StringifiedEvent<
8
8
  Key extends string,
9
9
  Params extends Json.Serializable[],
10
- > = Stringified<[Key, ...Params]>
10
+ > = stringified<[Key, ...Params]>
11
11
 
12
12
  export interface EventBuffer<
13
13
  Key extends string,
@@ -5,7 +5,8 @@ import {
5
5
  IMPLICIT,
6
6
  subscribeToState,
7
7
  } from "atom.io/internal"
8
- import { type Json, stringifyJson } from "atom.io/json"
8
+ import type { Canonical, Json } from "atom.io/json"
9
+ import { stringifyJson } from "atom.io/json"
9
10
 
10
11
  import type { ServerConfig } from "."
11
12
 
@@ -16,7 +17,7 @@ export function realtimeAtomFamilyProvider({
16
17
  }: ServerConfig) {
17
18
  return function familyProvider<
18
19
  J extends Json.Serializable,
19
- K extends Json.Serializable,
20
+ K extends Canonical,
20
21
  >(
21
22
  family: AtomIO.RegularAtomFamilyToken<J, K>,
22
23
  index: AtomIO.ReadableToken<Iterable<K>>,
@@ -8,7 +8,7 @@ import {
8
8
  IMPLICIT,
9
9
  subscribeToState,
10
10
  } from "atom.io/internal"
11
- import type { Json } from "atom.io/json"
11
+ import type { Canonical, Json } from "atom.io/json"
12
12
  import { stringifyJson } from "atom.io/json"
13
13
 
14
14
  import type { ServerConfig } from "."
@@ -23,7 +23,7 @@ export function realtimeMutableFamilyProvider({
23
23
  return function mutableFamilyProvider<
24
24
  T extends Transceiver<any>,
25
25
  J extends Json.Serializable,
26
- K extends Json.Serializable,
26
+ K extends Canonical,
27
27
  >(
28
28
  family: AtomIO.MutableAtomFamilyToken<T, J, K>,
29
29
  index: AtomIO.ReadableToken<Iterable<K>>,
package/src/atom.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createStandaloneAtom,
5
5
  IMPLICIT,
6
6
  } from "atom.io/internal"
7
- import type { Json, JsonInterface } from "atom.io/json"
7
+ import type { Canonical, Json, JsonInterface } from "atom.io/json"
8
8
 
9
9
  import type {
10
10
  AtomToken,
@@ -62,31 +62,20 @@ export function atom(
62
62
  return createStandaloneAtom(options, IMPLICIT.STORE)
63
63
  }
64
64
 
65
- export type RegularAtomFamilyOptions<T, K extends Json.Serializable> = {
65
+ export type RegularAtomFamilyOptions<T, K extends Canonical> = {
66
66
  key: string
67
67
  default: T | ((key: K) => T)
68
68
  effects?: (key: K) => AtomEffect<T>[]
69
69
  }
70
70
 
71
- export type RegularAtomFamilyToken<T, K extends Json.Serializable> = {
71
+ export type RegularAtomFamilyToken<T, K extends Canonical> = {
72
72
  key: string
73
73
  type: `atom_family`
74
74
  __T?: T
75
75
  __K?: K
76
76
  }
77
77
  // biome-ignore format: intersection
78
- export type RegularAtomFamilyTokenWithCall<
79
- T,
80
- K extends Json.Serializable,
81
- > =
82
- & RegularAtomFamilyToken<T, K>
83
- & {
84
- /** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
85
- /* eslint-disable-next-line @typescript-eslint/prefer-function-type */
86
- (key: K): RegularAtomToken<T>
87
- }
88
- // biome-ignore format: intersection
89
- export type RegularAtomFamily<T, K extends Json.Serializable> =
78
+ export type RegularAtomFamily<T, K extends Canonical> =
90
79
  & RegularAtomFamilyToken<T, K>
91
80
  & {
92
81
  (key: K): RegularAtomToken<T>
@@ -98,7 +87,7 @@ export type RegularAtomFamily<T, K extends Json.Serializable> =
98
87
  export type MutableAtomFamilyOptions<
99
88
  T extends Transceiver<any>,
100
89
  J extends Json.Serializable,
101
- K extends Json.Serializable,
90
+ K extends Canonical,
102
91
  > =
103
92
  & JsonInterface<T, J>
104
93
  & {
@@ -111,7 +100,7 @@ export type MutableAtomFamilyOptions<
111
100
  export type MutableAtomFamilyToken<
112
101
  T extends Transceiver<any>,
113
102
  J extends Json.Serializable,
114
- K extends Json.Serializable,
103
+ K extends Canonical,
115
104
  > = {
116
105
  key: string
117
106
  type: `mutable_atom_family`
@@ -120,22 +109,10 @@ export type MutableAtomFamilyToken<
120
109
  __K?: K
121
110
  }
122
111
  // biome-ignore format: intersection
123
- export type MutableAtomFamilyTokenWithCall<
124
- T extends Transceiver<any>,
125
- J extends Json.Serializable,
126
- K extends Json.Serializable,
127
- > =
128
- & MutableAtomFamilyToken<T, J, K>
129
- & {
130
- /** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
131
- /* eslint-disable-next-line @typescript-eslint/prefer-function-type */
132
- (key: K): MutableAtomToken<T, J>
133
- }
134
- // biome-ignore format: intersection
135
112
  export type MutableAtomFamily<
136
113
  T extends Transceiver<any>,
137
114
  J extends Json.Serializable,
138
- K extends Json.Serializable,
115
+ K extends Canonical,
139
116
  > =
140
117
  & JsonInterface<T, J>
141
118
  & MutableAtomFamilyToken<T, J, K>
@@ -145,29 +122,25 @@ export type MutableAtomFamily<
145
122
  install: (store: Store) => void
146
123
  }
147
124
 
148
- export type AtomFamily<T, K extends Json.Serializable = Json.Serializable> =
125
+ export type AtomFamily<T, K extends Canonical = Canonical> =
149
126
  | MutableAtomFamily<T extends Transceiver<any> ? T : never, any, K>
150
127
  | RegularAtomFamily<T, K>
151
- export type AtomFamilyToken<T, K extends Json.Serializable = Json.Serializable> =
128
+ export type AtomFamilyToken<T, K extends Canonical = Canonical> =
152
129
  | MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, any, K>
153
130
  | RegularAtomFamilyToken<T, K>
154
131
 
155
132
  export function atomFamily<
156
133
  T extends Transceiver<any>,
157
134
  J extends Json.Serializable,
158
- K extends Json.Serializable,
159
- >(
160
- options: MutableAtomFamilyOptions<T, J, K>,
161
- ): MutableAtomFamilyTokenWithCall<T, J, K>
162
- export function atomFamily<T, K extends Json.Serializable>(
135
+ K extends Canonical,
136
+ >(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyToken<T, J, K>
137
+ export function atomFamily<T, K extends Canonical>(
163
138
  options: RegularAtomFamilyOptions<T, K>,
164
- ): RegularAtomFamilyTokenWithCall<T, K>
165
- export function atomFamily<T, K extends Json.Serializable>(
139
+ ): RegularAtomFamilyToken<T, K>
140
+ export function atomFamily<T, K extends Canonical>(
166
141
  options:
167
142
  | MutableAtomFamilyOptions<any, any, any>
168
143
  | RegularAtomFamilyOptions<T, K>,
169
- ):
170
- | MutableAtomFamilyTokenWithCall<any, any, any>
171
- | RegularAtomFamilyTokenWithCall<T, K> {
144
+ ): MutableAtomFamilyToken<any, any, any> | RegularAtomFamilyToken<T, K> {
172
145
  return createAtomFamily(options, IMPLICIT.STORE)
173
146
  }
@@ -1,5 +1,5 @@
1
1
  import * as Internal from "atom.io/internal"
2
- import type { Json } from "atom.io/json"
2
+ import type { Canonical, Json } from "atom.io/json"
3
3
 
4
4
  import type { ReadableFamilyToken, ReadableToken } from "."
5
5
  import type {
@@ -13,7 +13,7 @@ export function disposeState(
13
13
  token: MoleculeToken<any> | ReadableToken<any>,
14
14
  ): void
15
15
 
16
- export function disposeState<K extends Json.Serializable>(
16
+ export function disposeState<K extends Canonical>(
17
17
  token: ReadableFamilyToken<any, K>,
18
18
  key: K,
19
19
  ): void
package/src/get-state.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as Internal from "atom.io/internal"
2
- import type { Json } from "atom.io/json"
2
+ import type { Canonical } from "atom.io/json"
3
3
 
4
4
  import type {
5
5
  MoleculeConstructor,
@@ -15,14 +15,14 @@ export function getState<M extends MoleculeConstructor>(
15
15
  token: MoleculeToken<M>,
16
16
  ): InstanceType<M>
17
17
 
18
- export function getState<T, K extends Json.Serializable>(
18
+ export function getState<T, K extends Canonical>(
19
19
  token: ReadableFamilyToken<T, K>,
20
20
  key: K,
21
21
  ): T
22
22
 
23
23
  export function getState<M extends MoleculeConstructor>(
24
24
  token: MoleculeFamilyToken<M>,
25
- key: Json.Serializable,
25
+ key: Canonical,
26
26
  ): InstanceType<M>
27
27
 
28
28
  export function getState(
@@ -31,7 +31,7 @@ export function getState(
31
31
  | MoleculeToken<any>
32
32
  | ReadableFamilyToken<any, any>
33
33
  | ReadableToken<any>,
34
- key?: Json.Serializable,
34
+ key?: Canonical,
35
35
  ): any {
36
36
  if (key) {
37
37
  return Internal.getFromStore(
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Transceiver } from "atom.io/internal"
2
- import type { Json } from "atom.io/json"
2
+ import type { Canonical, Json } from "atom.io/json"
3
3
 
4
4
  import type { AtomFamily, AtomFamilyToken } from "./atom"
5
5
  import type {
@@ -61,17 +61,17 @@ export type SelectorToken<T> =
61
61
  export type WritableToken<T> = AtomToken<T> | WritableSelectorToken<T>
62
62
  export type ReadableToken<T> = AtomToken<T> | SelectorToken<T>
63
63
 
64
- export type WritableFamily<T, K extends Json.Serializable> =
64
+ export type WritableFamily<T, K extends Canonical> =
65
65
  | AtomFamily<T, K>
66
66
  | WritableSelectorFamily<T, K>
67
- export type ReadableFamily<T, K extends Json.Serializable> =
67
+ export type ReadableFamily<T, K extends Canonical> =
68
68
  | AtomFamily<T, K>
69
69
  | SelectorFamily<T, K>
70
70
 
71
- export type WritableFamilyToken<T, K extends Json.Serializable> =
71
+ export type WritableFamilyToken<T, K extends Canonical> =
72
72
  | AtomFamilyToken<T, K>
73
73
  | WritableSelectorFamilyToken<T, K>
74
- export type ReadableFamilyToken<T, K extends Json.Serializable> =
74
+ export type ReadableFamilyToken<T, K extends Canonical> =
75
75
  | AtomFamilyToken<T, K>
76
76
  | SelectorFamilyToken<T, K>
77
77
 
package/src/molecule.ts CHANGED
@@ -23,9 +23,10 @@ import {
23
23
  makeMoleculeInStore,
24
24
  Molecule,
25
25
  } from "atom.io/internal"
26
- import { type Json, stringifyJson } from "atom.io/json"
26
+ import type { Canonical, Json } from "atom.io/json"
27
+ import { stringifyJson } from "atom.io/json"
27
28
 
28
- export type CtorToolkit<K extends Json.Serializable> = Flat<
29
+ export type CtorToolkit<K extends Canonical> = Flat<
29
30
  Omit<ActorToolkit, `find`> & {
30
31
  bond<T extends Transceiver<any>, J extends Json.Serializable>(
31
32
  family: MutableAtomFamilyToken<T, J, K>,
@@ -53,7 +54,7 @@ export type CtorToolkit<K extends Json.Serializable> = Flat<
53
54
 
54
55
  claim(below: MoleculeToken<any>, options: { exclusive: boolean }): void
55
56
 
56
- spawn<Key extends Json.Serializable, Ctor extends MoleculeConstructor>(
57
+ spawn<Key extends Canonical, Ctor extends MoleculeConstructor>(
57
58
  family: MoleculeFamilyToken<Ctor>,
58
59
  key: Key,
59
60
  ...params: MoleculeParams<Ctor>