atom.io 0.34.1 → 0.35.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 (53) hide show
  1. package/dist/internal/index.d.ts +32 -41
  2. package/dist/internal/index.d.ts.map +1 -1
  3. package/dist/internal/index.js +106 -128
  4. package/dist/internal/index.js.map +1 -1
  5. package/dist/json/index.d.ts +19 -7
  6. package/dist/json/index.d.ts.map +1 -1
  7. package/dist/json/index.js +4 -0
  8. package/dist/json/index.js.map +1 -1
  9. package/dist/main/index.d.ts +704 -788
  10. package/dist/main/index.d.ts.map +1 -1
  11. package/dist/main/index.js +61 -33
  12. package/dist/main/index.js.map +1 -1
  13. package/dist/react-devtools/index.js +10 -10
  14. package/dist/react-devtools/index.js.map +1 -1
  15. package/dist/realtime/index.d.ts.map +1 -1
  16. package/dist/realtime/index.js +3 -5
  17. package/dist/realtime/index.js.map +1 -1
  18. package/dist/realtime-client/index.js +10 -10
  19. package/dist/realtime-client/index.js.map +1 -1
  20. package/dist/realtime-server/index.d.ts.map +1 -1
  21. package/dist/realtime-server/index.js +8 -10
  22. package/dist/realtime-server/index.js.map +1 -1
  23. package/package.json +12 -12
  24. package/src/internal/atom/create-regular-atom.ts +1 -0
  25. package/src/internal/atom/index.ts +0 -1
  26. package/src/internal/families/index.ts +0 -1
  27. package/src/internal/index.ts +111 -89
  28. package/src/internal/join/join-internal.ts +3 -4
  29. package/src/internal/mutable/create-mutable-atom-family.ts +0 -1
  30. package/src/internal/mutable/create-mutable-atom.ts +1 -1
  31. package/src/internal/selector/register-selector.ts +2 -2
  32. package/src/json/entries.ts +10 -3
  33. package/src/json/index.ts +40 -17
  34. package/src/main/atom.ts +68 -115
  35. package/src/main/dispose-state.ts +0 -2
  36. package/src/main/find-state.ts +3 -9
  37. package/src/main/get-state.ts +0 -2
  38. package/src/main/index.ts +1 -176
  39. package/src/main/join.ts +12 -20
  40. package/src/main/reset-state.ts +0 -2
  41. package/src/main/selector.ts +5 -72
  42. package/src/main/set-state.ts +1 -4
  43. package/src/main/silo.ts +14 -5
  44. package/src/main/subscribe.ts +0 -7
  45. package/src/main/timeline.ts +24 -32
  46. package/src/main/tokens.ts +247 -0
  47. package/src/main/transaction.ts +17 -55
  48. package/src/main/validators.ts +1 -1
  49. package/src/react-devtools/store.ts +61 -45
  50. package/src/realtime/shared-room-store.ts +3 -5
  51. package/src/realtime-server/realtime-server-stores/server-user-store.ts +3 -5
  52. package/src/internal/atom/create-standalone-atom.ts +0 -39
  53. package/src/internal/families/create-atom-family.ts +0 -38
@@ -2,12 +2,20 @@ import { Count, Flat, Store, Transceiver } from "atom.io/internal";
2
2
  import * as AtomIO from "atom.io";
3
3
 
4
4
  //#region src/json/entries.d.ts
5
+ /** Tuples of `[key, value]` pairs, as returned from `Object.entries` */
5
6
  type Entries<K extends PropertyKey = PropertyKey, V = any> = [K, V][];
7
+ /** The collective or "union" type of the keys in a set of entries */
6
8
  type KeyOfEntries<E extends Entries> = E extends [infer K, any][] ? K : never;
9
+ /** The type of the value of entry `K` in a set of entries `E` */
7
10
  type ValueOfEntry<E extends Entries, K extends KeyOfEntries<E>> = { [P in Count<E[`length`]>]: E[P] extends [K, infer V] ? V : never }[Count<E[`length`]>];
11
+ /** The type of a set of entries `E` in object form */
8
12
  type FromEntries<E extends Entries> = Flat<{ [K in KeyOfEntries<E>]: ValueOfEntry<E, K> }>;
13
+ /** Typed form of `Object.fromEntries` */
9
14
  declare function fromEntries<E extends Entries>(entries: E): FromEntries<E>;
10
- declare function toEntries<T extends object>(obj: T): Entries<keyof T, T[keyof T]>;
15
+ /** The type of an object T in {@link Entries} form */
16
+ type ToEntries<T extends object> = Entries<keyof T, T[keyof T]>;
17
+ /** Typed form of `Object.entries` */
18
+ declare function toEntries<T extends object>(obj: T): ToEntries<T>;
11
19
  //#endregion
12
20
  //#region src/json/select-json.d.ts
13
21
  declare const selectJson: <T, J extends Json.Serializable>(atom: AtomIO.AtomToken<T>, transform: JsonInterface<T, J>, store?: Store) => AtomIO.WritablePureSelectorToken<J>;
@@ -32,15 +40,19 @@ declare namespace Json {
32
40
  type Object<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
33
41
  type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
34
42
  }
35
- type stringified<J extends Json.Serializable> = J extends string ? `"${J}"` : J extends number ? `${J}` : J extends true ? `true` : J extends false ? `false` : J extends boolean ? `false` | `true` : J extends null ? `null` : string & {
43
+ /** A generic that retains the type information of a {@link Json.Serializable} value while in string form */
44
+ type stringified<J extends Json.Serializable> = (J extends string ? `"${J}"` : J extends number ? `${J}` : J extends true ? `true` : J extends false ? `false` : J extends boolean ? `false` | `true` : J extends null ? `null` : J extends [] ? `[]` : J extends [infer Element extends Json.Serializable] ? `[${stringified<Element>}]` : J extends [infer Element1 extends Json.Serializable, infer Element2 extends Json.Serializable] ? `[${stringified<Element1>}, ${stringified<Element2>}]` : J extends [infer Element1 extends Json.Serializable, infer Element2 extends Json.Serializable, infer Element3 extends Json.Serializable] ? `[${stringified<Element1>}, ${stringified<Element2>}, ${stringified<Element3>}]` : J extends any[] ? `[${string}]` & {
36
45
  __json?: J;
37
- };
46
+ } : string & {
47
+ __json?: J;
48
+ });
49
+ /** Type-safe wrapper for {@link JSON.parse} */
38
50
  declare const parseJson: <S extends stringified<Json.Serializable>>(str: S | string) => S extends stringified<infer J> ? J : Json.Serializable;
51
+ /** Type-safe wrapper for {@link JSON.stringify} */
39
52
  declare const stringifyJson: <J extends Json.Serializable>(json: J) => stringified<J>;
40
- /**
41
- * Always serializes to the same string.
42
- */
53
+ /** Only Canonical values should be used for keys because they always serialize to the same string */
43
54
  type Canonical = primitive | ReadonlyArray<Canonical>;
55
+ /** A function whose parameters and return value are {@link Json.Serializable} */
44
56
  type JsonIO = (...params: Json.Serializable[]) => Json.Serializable | void;
45
57
  type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {
46
58
  toJson: (t: T) => J;
@@ -59,5 +71,5 @@ interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {
59
71
  }
60
72
  declare const JSON_DEFAULTS: JsonTypes;
61
73
  //#endregion
62
- export { Canonical, Entries, FromEntries, JSON_DEFAULTS, JSON_TYPE_NAMES, Json, JsonIO, JsonInterface, JsonTypeName, JsonTypes, KeyOfEntries, ValueOfEntry, fromEntries, isJson, parseJson, primitive, selectJson, selectJsonFamily, stringified, stringifyJson, toEntries };
74
+ export { Canonical, Entries, FromEntries, JSON_DEFAULTS, JSON_TYPE_NAMES, Json, JsonIO, JsonInterface, JsonTypeName, JsonTypes, KeyOfEntries, ToEntries, ValueOfEntry, fromEntries, isJson, parseJson, primitive, selectJson, selectJsonFamily, stringified, stringifyJson, toEntries };
63
75
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["entries: E","obj: T","atom: AtomIO.AtomToken<T>","transform: JsonInterface<T, J>","store: Store","store: Store","atomFamilyToken: AtomIO.MutableAtomFamilyToken<T, J, K>","transform: JsonInterface<T, J>","atomFamilyToken: AtomIO.RegularAtomFamilyToken<T, K>","str: S | string","json: J","t: T","input: unknown","JSON_DEFAULTS: JsonTypes"],"sources":["../../src/json/entries.ts","../../src/json/select-json.ts","../../src/json/select-json-family.ts","../../src/json/index.ts"],"sourcesContent":[],"mappings":";;;;KAEY,kBAAkB,cAAc,qBAA5C,GAAY,CAAyD,CAAzD,EAA4D,CAA5D,CAAA,EAAA;AAAA,KAEA,YAFA,CAAA,UAEuB,OAFvB,CAAA,GAEkC,CAFlC,SAAA,CAAA,KAAA,EAAA,EAAA,GAAA,CAAA,EAAA,GAGT,CAHS,GAAA,KAAA;AAAkB,KAMlB,YANkB,CAAA,UAMK,OANS,EAAA,UAMU,YANe,CAMF,CANE,CAAA,CAAA,GAAA,QAO9D,KAPiE,CAO3D,CAP2D,CAAA,QAAA,CAAA,CAAA,GAO5C,CAP4C,CAO1C,CAP0C,CAAA,SAAA,CAO9B,CAP8B,EAAA,KA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QAAA,EAAA,QAAA,EAAA,QAAA,CAAA;AAAsB,KGwE1B,YAAA,GHxE0B,CAAA,OGwEH,eHxEG,CAAA,CAAA,MAAA,CAAA;AAAkB,UG0EvC,SAAA,SAAkB,MH1EqB,CG0Ed,YH1Ec,EG0EA,IAAA,CAAK,YH1EL,CAAA,CAAA;EAAA,KAAA,EG2EhD,IAAA,CAAK,KH3E2D;EAAA,OAAZ,EAAA,OAAA;EAAA,IAAA,EAAA,IAAA;EAI5D,MAAgB,EAAA,MAAA;EAAA,MAAA,EG2EP,IAAA,CAAK,MH3EE;EAAA,MACV,EAAA,MAAA;;AACc,cG6EPa,aH7EO,EG6EQ,SH7ER"}
1
+ {"version":3,"file":"index.d.ts","names":["entries: E","obj: T","atom: AtomIO.AtomToken<T>","transform: JsonInterface<T, J>","store: Store","store: Store","atomFamilyToken: AtomIO.MutableAtomFamilyToken<T, J, K>","transform: JsonInterface<T, J>","atomFamilyToken: AtomIO.RegularAtomFamilyToken<T, K>","str: S | string","json: J","t: T","input: unknown","JSON_DEFAULTS: JsonTypes"],"sources":["../../src/json/entries.ts","../../src/json/select-json.ts","../../src/json/select-json-family.ts","../../src/json/index.ts"],"sourcesContent":[],"mappings":";;;;;KAGY,kBAAkB,cAAc,aAA5C,IAAY,GAAA,CAAA,GAAA,CAAyD,CAAzD,EAA4D,CAA5D,CAAA,EAAA;;AAAgC,KAGhC,YAHgC,CAAA,UAGT,OAHS,CAAA,GAGE,CAHF,SAAA,CAAA,KAAA,EAAA,EAAA,GAAA,CAAA,EAAA,GAIzC,CAJyC,GAAA,KAAA;;AAA4B,KAQ5D,YAR4D,CAAA,UAQrC,OARqC,EAGxE,UAKsD,YAL1C,CAKuD,CALvD,CAAA,CAAA,GAAA,QAML,KANK,CAMC,CAND,CAAA,QAAA,CAAA,CAAA,GAMgB,CANhB,CAMkB,CANlB,CAAA,SAAA,CAM8B,CAN9B,EAAA,KAAA,EAAA,CAAA,GAM4C,CAN5C,GAAA,KAAA,EAAA,C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loneSelector, createWritablePureSelectorFamily } from "atom.io/internal";
2
2
 
3
3
  //#region src/json/entries.ts
4
+ /** Typed form of `Object.fromEntries` */
4
5
  function fromEntries(entries) {
5
6
  return Object.fromEntries(entries);
6
7
  }
8
+ /** Typed form of `Object.entries` */
7
9
  function toEntries(obj) {
8
10
  return Object.entries(obj);
9
11
  }
@@ -38,7 +40,9 @@ function selectJsonFamily(store, atomFamilyToken, transform) {
38
40
 
39
41
  //#endregion
40
42
  //#region src/json/index.ts
43
+ /** Type-safe wrapper for {@link JSON.parse} */
41
44
  const parseJson = (str) => JSON.parse(str);
45
+ /** Type-safe wrapper for {@link JSON.stringify} */
42
46
  const stringifyJson = (json) => JSON.stringify(json);
43
47
  const JSON_PROTOTYPES = [
44
48
  Array.prototype,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["entries: E","obj: T","atom: AtomIO.AtomToken<T>","transform: JsonInterface<T, J>","store: Store","store: Store","atomFamilyToken:\n\t\t| AtomIO.MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, J, K>\n\t\t| AtomIO.RegularAtomFamilyToken<T, K>","transform: JsonInterface<T, J>","str: S | string","json: J","input: unknown","JSON_DEFAULTS: JsonTypes"],"sources":["../../src/json/entries.ts","../../src/json/select-json.ts","../../src/json/select-json-family.ts","../../src/json/index.ts"],"sourcesContent":["import type { Count, Flat } from \"atom.io/internal\"\n\nexport type Entries<K extends PropertyKey = PropertyKey, V = any> = [K, V][]\n\nexport type KeyOfEntries<E extends Entries> = E extends [infer K, any][]\n\t? K\n\t: never\n\nexport type ValueOfEntry<E extends Entries, K extends KeyOfEntries<E>> = {\n\t[P in Count<E[`length`]>]: E[P] extends [K, infer V] ? V : never\n}[Count<E[`length`]>]\n\nexport type FromEntries<E extends Entries> = Flat<{\n\t[K in KeyOfEntries<E>]: ValueOfEntry<E, K>\n}>\n\nexport function fromEntries<E extends Entries>(entries: E): FromEntries<E> {\n\treturn Object.fromEntries(entries) as FromEntries<E>\n}\n\nexport function toEntries<T extends object>(\n\tobj: T,\n): Entries<keyof T, T[keyof T]> {\n\treturn Object.entries(obj) as Entries<keyof T, T[keyof T]>\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { createStandaloneSelector, IMPLICIT } from \"atom.io/internal\"\n\nimport type { Json, JsonInterface } from \".\"\n\nexport const selectJson = <T, J extends Json.Serializable>(\n\tatom: AtomIO.AtomToken<T>,\n\ttransform: JsonInterface<T, J>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomIO.WritablePureSelectorToken<J> => {\n\treturn createStandaloneSelector(store, {\n\t\tkey: `${atom.key}:JSON`,\n\t\tget: ({ get }) => transform.toJson(get(atom)),\n\t\tset: ({ set }, newValue) => {\n\t\t\tset(atom, transform.fromJson(newValue))\n\t\t},\n\t})\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store, Transceiver } from \"atom.io/internal\"\nimport { createWritablePureSelectorFamily } from \"atom.io/internal\"\n\nimport type { Canonical, Json, JsonInterface } from \".\"\n\nexport function selectJsonFamily<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tatomFamilyToken: AtomIO.MutableAtomFamilyToken<T, J, K>,\n\ttransform: JsonInterface<T, J>,\n): AtomIO.WritablePureSelectorFamilyToken<J, K>\nexport function selectJsonFamily<\n\tT,\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tatomFamilyToken: AtomIO.RegularAtomFamilyToken<T, K>,\n\ttransform: JsonInterface<T, J>,\n): AtomIO.WritablePureSelectorFamilyToken<J, K>\nexport function selectJsonFamily<\n\tT,\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tatomFamilyToken:\n\t\t| AtomIO.MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, J, K>\n\t\t| AtomIO.RegularAtomFamilyToken<T, K>,\n\ttransform: JsonInterface<T, J>,\n): AtomIO.WritablePureSelectorFamilyToken<J, K> {\n\tconst jsonFamily = createWritablePureSelectorFamily<J, K>(\n\t\tstore,\n\t\t{\n\t\t\tkey: `${atomFamilyToken.key}:JSON`,\n\t\t\tget:\n\t\t\t\t(key) =>\n\t\t\t\t({ get }) => {\n\t\t\t\t\tconst baseState = get(atomFamilyToken, key)\n\t\t\t\t\treturn transform.toJson(baseState)\n\t\t\t\t},\n\t\t\tset:\n\t\t\t\t(key) =>\n\t\t\t\t({ set }, newValue) => {\n\t\t\t\t\tset(atomFamilyToken, key, transform.fromJson(newValue))\n\t\t\t\t},\n\t\t},\n\t\t[`mutable`, `json`],\n\t)\n\treturn jsonFamily\n}\n","export * from \"./entries\"\nexport * from \"./select-json\"\nexport * from \"./select-json-family\"\n\nexport type primitive = boolean | number | string | null\n\nexport namespace Json {\n\texport namespace Tree {\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\texport type Array<Element = unknown> = ReadonlyArray<Element>\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\texport type Object<K extends string = string, V = unknown> = Record<K, V>\n\t\texport type Fork = Array | Object\n\t\texport type Leaf = primitive\n\t\texport type Node = Fork | Leaf\n\t}\n\n\texport type Serializable =\n\t\t| primitive\n\t\t| Readonly<{ [key: string]: Serializable }>\n\t\t| ReadonlyArray<Serializable>\n\n\texport type Object<\n\t\tKey extends string = string,\n\t\tValue extends Serializable = Serializable,\n\t> = Record<Key, Value>\n\n\texport type Array<Element extends Serializable = Serializable> =\n\t\tReadonlyArray<Element>\n}\n\nexport type stringified<J extends Json.Serializable> = J extends string\n\t? `\"${J}\"`\n\t: J extends number\n\t\t? `${J}`\n\t\t: J extends true\n\t\t\t? `true`\n\t\t\t: J extends false\n\t\t\t\t? `false`\n\t\t\t\t: J extends boolean\n\t\t\t\t\t? `false` | `true`\n\t\t\t\t\t: J extends null\n\t\t\t\t\t\t? `null`\n\t\t\t\t\t\t: string & { __json?: J }\n\nexport const parseJson = <S extends stringified<Json.Serializable>>(\n\tstr: S | string,\n): S extends stringified<infer J> ? J : Json.Serializable => JSON.parse(str)\n\nexport const stringifyJson = <J extends Json.Serializable>(\n\tjson: J,\n): stringified<J> => JSON.stringify(json) as stringified<J>\n\n/**\n * Always serializes to the same string.\n */\nexport type Canonical = primitive | ReadonlyArray<Canonical>\n\nexport type JsonIO = (...params: Json.Serializable[]) => Json.Serializable | void\n\nexport type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {\n\ttoJson: (t: T) => J\n\tfromJson: (json: J) => T\n}\n\nconst JSON_PROTOTYPES = [\n\tArray.prototype,\n\tBoolean.prototype,\n\tNumber.prototype,\n\tObject.prototype,\n\tString.prototype,\n] as const\nexport const isJson = (input: unknown): input is Json.Tree.Node => {\n\tif (input === null) return true\n\tif (input === undefined) return false\n\tconst prototype = Object.getPrototypeOf(input)\n\treturn JSON_PROTOTYPES.includes(prototype)\n}\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {\n\tarray: Json.Array\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: Json.Object\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n"],"mappings":";;;AAgBA,SAAgB,YAA+BA,SAA4B;AAC1E,QAAO,OAAO,YAAY,QAAQ;AAClC;AAED,SAAgB,UACfC,KAC+B;AAC/B,QAAO,OAAO,QAAQ,IAAI;AAC1B;;;;AClBD,MAAa,aAAa,CACzBC,MACAC,WACAC,QAAe,SAAS,UACiB;AACzC,QAAO,yBAAyB,OAAO;EACtC,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC;EACvB,KAAK,CAAC,EAAE,KAAK,KAAK,UAAU,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entries: E","obj: T","atom: AtomIO.AtomToken<T>","transform: JsonInterface<T, J>","store: Store","store: Store","atomFamilyToken:\n\t\t| AtomIO.MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, J, K>\n\t\t| AtomIO.RegularAtomFamilyToken<T, K>","transform: JsonInterface<T, J>","str: S | string","json: J","input: unknown","JSON_DEFAULTS: JsonTypes"],"sources":["../../src/json/entries.ts","../../src/json/select-json.ts","../../src/json/select-json-family.ts","../../src/json/index.ts"],"sourcesContent":["import type { Count, Flat } from \"atom.io/internal\"\n\n/** Tuples of `[key, value]` pairs, as returned from `Object.entries` */\nexport type Entries<K extends PropertyKey = PropertyKey, V = any> = [K, V][]\n\n/** The collective or \"union\" type of the keys in a set of entries */\nexport type KeyOfEntries<E extends Entries> = E extends [infer K, any][]\n\t? K\n\t: never\n\n/** The type of the value of entry `K` in a set of entries `E` */\nexport type ValueOfEntry<E extends Entries, K extends KeyOfEntries<E>> = {\n\t[P in Count<E[`length`]>]: E[P] extends [K, infer V] ? V : never\n}[Count<E[`length`]>]\n\n/** The type of a set of entries `E` in object form */\nexport type FromEntries<E extends Entries> = Flat<{\n\t[K in KeyOfEntries<E>]: ValueOfEntry<E, K>\n}>\n\n/** Typed form of `Object.fromEntries` */\nexport function fromEntries<E extends Entries>(entries: E): FromEntries<E> {\n\treturn Object.fromEntries(entries) as FromEntries<E>\n}\n\n/** The type of an object T in {@link Entries} form */\nexport type ToEntries<T extends object> = Entries<keyof T, T[keyof T]>\n\n/** Typed form of `Object.entries` */\nexport function toEntries<T extends object>(obj: T): ToEntries<T> {\n\treturn Object.entries(obj) as Entries<keyof T, T[keyof T]>\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { createStandaloneSelector, IMPLICIT } from \"atom.io/internal\"\n\nimport type { Json, JsonInterface } from \".\"\n\nexport const selectJson = <T, J extends Json.Serializable>(\n\tatom: AtomIO.AtomToken<T>,\n\ttransform: JsonInterface<T, J>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomIO.WritablePureSelectorToken<J> => {\n\treturn createStandaloneSelector(store, {\n\t\tkey: `${atom.key}:JSON`,\n\t\tget: ({ get }) => transform.toJson(get(atom)),\n\t\tset: ({ set }, newValue) => {\n\t\t\tset(atom, transform.fromJson(newValue))\n\t\t},\n\t})\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store, Transceiver } from \"atom.io/internal\"\nimport { createWritablePureSelectorFamily } from \"atom.io/internal\"\n\nimport type { Canonical, Json, JsonInterface } from \".\"\n\nexport function selectJsonFamily<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tatomFamilyToken: AtomIO.MutableAtomFamilyToken<T, J, K>,\n\ttransform: JsonInterface<T, J>,\n): AtomIO.WritablePureSelectorFamilyToken<J, K>\nexport function selectJsonFamily<\n\tT,\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tatomFamilyToken: AtomIO.RegularAtomFamilyToken<T, K>,\n\ttransform: JsonInterface<T, J>,\n): AtomIO.WritablePureSelectorFamilyToken<J, K>\nexport function selectJsonFamily<\n\tT,\n\tJ extends Json.Serializable,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\tatomFamilyToken:\n\t\t| AtomIO.MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, J, K>\n\t\t| AtomIO.RegularAtomFamilyToken<T, K>,\n\ttransform: JsonInterface<T, J>,\n): AtomIO.WritablePureSelectorFamilyToken<J, K> {\n\tconst jsonFamily = createWritablePureSelectorFamily<J, K>(\n\t\tstore,\n\t\t{\n\t\t\tkey: `${atomFamilyToken.key}:JSON`,\n\t\t\tget:\n\t\t\t\t(key) =>\n\t\t\t\t({ get }) => {\n\t\t\t\t\tconst baseState = get(atomFamilyToken, key)\n\t\t\t\t\treturn transform.toJson(baseState)\n\t\t\t\t},\n\t\t\tset:\n\t\t\t\t(key) =>\n\t\t\t\t({ set }, newValue) => {\n\t\t\t\t\tset(atomFamilyToken, key, transform.fromJson(newValue))\n\t\t\t\t},\n\t\t},\n\t\t[`mutable`, `json`],\n\t)\n\treturn jsonFamily\n}\n","export * from \"./entries\"\nexport * from \"./select-json\"\nexport * from \"./select-json-family\"\n\nexport type primitive = boolean | number | string | null\n\nexport namespace Json {\n\texport namespace Tree {\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\texport type Array<Element = unknown> = ReadonlyArray<Element>\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\texport type Object<K extends string = string, V = unknown> = Record<K, V>\n\t\texport type Fork = Array | Object\n\t\texport type Leaf = primitive\n\t\texport type Node = Fork | Leaf\n\t}\n\n\t/** A value can survive being {@link JSON.stringify}-ed and {@link JSON.parse}-d fully intact */\n\texport type Serializable =\n\t\t| primitive\n\t\t| Readonly<{ [key: string]: Serializable }>\n\t\t| ReadonlyArray<Serializable>\n\n\texport type Object<\n\t\tKey extends string = string,\n\t\tValue extends Serializable = Serializable,\n\t> = Record<Key, Value>\n\n\texport type Array<Element extends Serializable = Serializable> =\n\t\tReadonlyArray<Element>\n}\n\n/** A generic that retains the type information of a {@link Json.Serializable} value while in string form */\n// biome-ignore format: long silly ternary\nexport type stringified<J extends Json.Serializable> = (\n J extends string\n ? `\"${J}\"`\n : J extends number\n ? `${J}`\n : J extends true\n ? `true`\n : J extends false\n ? `false`\n : J extends boolean\n ? `false` | `true`\n : J extends null\n ? `null`\n : J extends []\n ? `[]`\n : J extends [infer Element extends Json.Serializable]\n ? `[${stringified<Element>}]`\n : J extends [\n\t\t\t\t\tinfer Element1 extends Json.Serializable,\n\t\t\t\t\tinfer Element2 extends Json.Serializable,\n\t\t\t\t]\n ? `[${stringified<Element1>}, ${stringified<Element2>}]`\n : J extends [\n\t\t\t\t\tinfer Element1 extends Json.Serializable,\n\t\t\t\t\tinfer Element2 extends Json.Serializable,\n\t\t\t\t\tinfer Element3 extends Json.Serializable,\n\t\t\t\t]\n ? `[${stringified<Element1>}, ${stringified<Element2>}, ${stringified<Element3>}]`\n : J extends any[]\n ? `[${string}]` & { __json?: J }\n : string & { __json?: J }\n )\n\n/** Type-safe wrapper for {@link JSON.parse} */\nexport const parseJson = <S extends stringified<Json.Serializable>>(\n\tstr: S | string,\n): S extends stringified<infer J> ? J : Json.Serializable => JSON.parse(str)\n\n/** Type-safe wrapper for {@link JSON.stringify} */\nexport const stringifyJson = <J extends Json.Serializable>(\n\tjson: J,\n): stringified<J> => JSON.stringify(json) as stringified<J>\n\n/** Only Canonical values should be used for keys because they always serialize to the same string */\nexport type Canonical = primitive | ReadonlyArray<Canonical>\n\n/** A function whose parameters and return value are {@link Json.Serializable} */\nexport type JsonIO = (...params: Json.Serializable[]) => Json.Serializable | void\n\nexport type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {\n\ttoJson: (t: T) => J\n\tfromJson: (json: J) => T\n}\n\nconst JSON_PROTOTYPES = [\n\tArray.prototype,\n\tBoolean.prototype,\n\tNumber.prototype,\n\tObject.prototype,\n\tString.prototype,\n] as const\nexport const isJson = (input: unknown): input is Json.Tree.Node => {\n\tif (input === null) return true\n\tif (input === undefined) return false\n\tconst prototype = Object.getPrototypeOf(input)\n\treturn JSON_PROTOTYPES.includes(prototype)\n}\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {\n\tarray: Json.Array\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: Json.Object\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n"],"mappings":";;;;AAqBA,SAAgB,YAA+BA,SAA4B;AAC1E,QAAO,OAAO,YAAY,QAAQ;AAClC;;AAMD,S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