atom.io 0.34.2 → 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 (51) 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 +7 -7
  6. package/dist/json/index.js +2 -2
  7. package/dist/json/index.js.map +1 -1
  8. package/dist/main/index.d.ts +779 -886
  9. package/dist/main/index.d.ts.map +1 -1
  10. package/dist/main/index.js +46 -14
  11. package/dist/main/index.js.map +1 -1
  12. package/dist/react-devtools/index.js +10 -10
  13. package/dist/react-devtools/index.js.map +1 -1
  14. package/dist/realtime/index.d.ts.map +1 -1
  15. package/dist/realtime/index.js +3 -5
  16. package/dist/realtime/index.js.map +1 -1
  17. package/dist/realtime-client/index.js +10 -10
  18. package/dist/realtime-client/index.js.map +1 -1
  19. package/dist/realtime-server/index.d.ts.map +1 -1
  20. package/dist/realtime-server/index.js +8 -10
  21. package/dist/realtime-server/index.js.map +1 -1
  22. package/package.json +4 -4
  23. package/src/internal/atom/create-regular-atom.ts +1 -0
  24. package/src/internal/atom/index.ts +0 -1
  25. package/src/internal/families/index.ts +0 -1
  26. package/src/internal/index.ts +111 -89
  27. package/src/internal/join/join-internal.ts +3 -4
  28. package/src/internal/mutable/create-mutable-atom-family.ts +0 -1
  29. package/src/internal/mutable/create-mutable-atom.ts +1 -1
  30. package/src/internal/selector/register-selector.ts +2 -2
  31. package/src/json/entries.ts +7 -7
  32. package/src/main/atom.ts +67 -114
  33. package/src/main/dispose-state.ts +0 -2
  34. package/src/main/find-state.ts +3 -9
  35. package/src/main/get-state.ts +0 -2
  36. package/src/main/index.ts +1 -176
  37. package/src/main/join.ts +0 -7
  38. package/src/main/reset-state.ts +0 -2
  39. package/src/main/selector.ts +5 -72
  40. package/src/main/set-state.ts +1 -4
  41. package/src/main/silo.ts +14 -5
  42. package/src/main/subscribe.ts +0 -7
  43. package/src/main/timeline.ts +1 -18
  44. package/src/main/tokens.ts +247 -0
  45. package/src/main/transaction.ts +17 -55
  46. package/src/main/validators.ts +1 -1
  47. package/src/react-devtools/store.ts +61 -45
  48. package/src/realtime/shared-room-store.ts +3 -5
  49. package/src/realtime-server/realtime-server-stores/server-user-store.ts +3 -5
  50. package/src/internal/atom/create-standalone-atom.ts +0 -39
  51. package/src/internal/families/create-atom-family.ts +0 -38
@@ -2,19 +2,19 @@ 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
- /** @public Tuples of `[key, value]` pairs, as returned from `Object.entries` */
5
+ /** Tuples of `[key, value]` pairs, as returned from `Object.entries` */
6
6
  type Entries<K extends PropertyKey = PropertyKey, V = any> = [K, V][];
7
- /** @public The collective or "union" type of the keys in a set of entries */
7
+ /** The collective or "union" type of the keys in a set of entries */
8
8
  type KeyOfEntries<E extends Entries> = E extends [infer K, any][] ? K : never;
9
- /** @public The type of the value of entry `K` in a set of entries `E` */
9
+ /** The type of the value of entry `K` in a set of entries `E` */
10
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
- /** @public The type of a set of entries `E` in object form */
11
+ /** The type of a set of entries `E` in object form */
12
12
  type FromEntries<E extends Entries> = Flat<{ [K in KeyOfEntries<E>]: ValueOfEntry<E, K> }>;
13
- /** @public Typed form of `Object.fromEntries` */
13
+ /** Typed form of `Object.fromEntries` */
14
14
  declare function fromEntries<E extends Entries>(entries: E): FromEntries<E>;
15
- /** @public The type of an object T in {@link Entries} form */
15
+ /** The type of an object T in {@link Entries} form */
16
16
  type ToEntries<T extends object> = Entries<keyof T, T[keyof T]>;
17
- /** @public Typed form of `Object.entries` */
17
+ /** Typed form of `Object.entries` */
18
18
  declare function toEntries<T extends object>(obj: T): ToEntries<T>;
19
19
  //#endregion
20
20
  //#region src/json/select-json.d.ts
@@ -1,11 +1,11 @@
1
1
  import { IMPLICIT, createStandaloneSelector, createWritablePureSelectorFamily } from "atom.io/internal";
2
2
 
3
3
  //#region src/json/entries.ts
4
- /** @public Typed form of `Object.fromEntries` */
4
+ /** Typed form of `Object.fromEntries` */
5
5
  function fromEntries(entries) {
6
6
  return Object.fromEntries(entries);
7
7
  }
8
- /** @public Typed form of `Object.entries` */
8
+ /** Typed form of `Object.entries` */
9
9
  function toEntries(obj) {
10
10
  return Object.entries(obj);
11
11
  }
@@ -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\n/** @public Tuples of `[key, value]` pairs, as returned from `Object.entries` */\nexport type Entries<K extends PropertyKey = PropertyKey, V = any> = [K, V][]\n\n/** @public 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/** @public 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/** @public 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/** @public 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/** @public The type of an object T in {@link Entries} form */\nexport type ToEntries<T extends object> = Entries<keyof T, T[keyof T]>\n\n/** @public 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,SAAgB,UAA4BC,KAAsB;AACjE,QAAO,OAAO,QAAQ,IAAI;AAC1B;;;;ACzBD,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,OAAO,IAAI,KAAK,CAAC;EAC7C,KAAK,CAAC,EAAE,KAAK,EAAE,aAAa;GAC3B,IAAI,MAAM,UAAU,SAAS,SAAS,CAAC;EACvC;CACD,EAAC;AACF;;;;ACMD,SAAgB,iBAKfC,OACAC,iBAGAC,WAC+C;CAC/C,MAAM,aAAa,iCAClB,OACA;EACC,KAAK,GAAG,gBAAgB,IAAI,KAAK,CAAC;EAClC,KACC,CAAC,QACD,CAAC,EAAE,KAAK,KAAK;GACZ,MAAM,YAAY,IAAI,iBAAiB,IAAI;AAC3C,UAAO,UAAU,OAAO,UAAU;EAClC;EACF,KACC,CAAC,QACD,CAAC,EAAE,KAAK,EAAE,aAAa;GACtB,IAAI,iBAAiB,KAAK,UAAU,SAAS,SAAS,CAAC;EACvD;CACF,GACD,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,AAAC,EACnB;AACD,QAAO;AACP;;;;;ACcD,MAAa,YAAY,CACxBC,QAC4D,KAAK,MAAM,IAAI;;AAG5E,MAAa,gBAAgB,CAC5BC,SACoB,KAAK,UAAU,KAAK;AAazC,MAAM,kBAAkB;CACvB,MAAM;CACN,QAAQ;CACR,OAAO;CACP,OAAO;CACP,OAAO;AACP;AACD,MAAa,SAAS,CAACC,UAA4C;AAClE,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,UAAU,OAAW,QAAO;CAChC,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QAAO,gBAAgB,SAAS,UAAU;AAC1C;AAED,MAAa,kBAAkB;CAC9B,CAAC,KAAK,CAAC;CACP,CAAC,OAAO,CAAC;CACT,CAAC,IAAI,CAAC;CACN,CAAC,MAAM,CAAC;CACR,CAAC,MAAM,CAAC;CACR,CAAC,MAAM,CAAC;AACR;AAaD,MAAaC,gBAA2B;CACvC,OAAO,CAAE;CACT,SAAS;CACT,MAAM;CACN,QAAQ;CACR,QAAQ,CAAE;CACV,QAAQ,EAAE;AACV"}
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\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,SAAgB,UAA4BC,KAAsB;AACjE,QAAO,OAAO,QAAQ,IAAI;AAC1B;;;;ACzBD,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,OAAO,IAAI,KAAK,CAAC;EAC7C,KAAK,CAAC,EAAE,KAAK,EAAE,aAAa;GAC3B,IAAI,MAAM,UAAU,SAAS,SAAS,CAAC;EACvC;CACD,EAAC;AACF;;;;ACMD,SAAgB,iBAKfC,OACAC,iBAGAC,WAC+C;CAC/C,MAAM,aAAa,iCAClB,OACA;EACC,KAAK,GAAG,gBAAgB,IAAI,KAAK,CAAC;EAClC,KACC,CAAC,QACD,CAAC,EAAE,KAAK,KAAK;GACZ,MAAM,YAAY,IAAI,iBAAiB,IAAI;AAC3C,UAAO,UAAU,OAAO,UAAU;EAClC;EACF,KACC,CAAC,QACD,CAAC,EAAE,KAAK,EAAE,aAAa;GACtB,IAAI,iBAAiB,KAAK,UAAU,SAAS,SAAS,CAAC;EACvD;CACF,GACD,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,AAAC,EACnB;AACD,QAAO;AACP;;;;;ACcD,MAAa,YAAY,CACxBC,QAC4D,KAAK,MAAM,IAAI;;AAG5E,MAAa,gBAAgB,CAC5BC,SACoB,KAAK,UAAU,KAAK;AAazC,MAAM,kBAAkB;CACvB,MAAM;CACN,QAAQ;CACR,OAAO;CACP,OAAO;CACP,OAAO;AACP;AACD,MAAa,SAAS,CAACC,UAA4C;AAClE,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,UAAU,OAAW,QAAO;CAChC,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QAAO,gBAAgB,SAAS,UAAU;AAC1C;AAED,MAAa,kBAAkB;CAC9B,CAAC,KAAK,CAAC;CACP,CAAC,OAAO,CAAC;CACT,CAAC,IAAI,CAAC;CACN,CAAC,MAAM,CAAC;CACR,CAAC,MAAM,CAAC;CACR,CAAC,MAAM,CAAC;AACR;AAaD,MAAaC,gBAA2B;CACvC,OAAO,CAAE;CACT,SAAS;CACT,MAAM;CACN,QAAQ;CACR,QAAQ,CAAE;CACV,QAAQ,EAAE;AACV"}