atom.io 0.19.4 → 0.20.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 (94) hide show
  1. package/data/dist/index.js +1 -1
  2. package/data/src/dict.ts +1 -1
  3. package/data/src/join.ts +1 -1
  4. package/data/src/struct-family.ts +1 -1
  5. package/data/src/struct.ts +5 -3
  6. package/internal/dist/index.cjs +127 -92
  7. package/internal/dist/index.d.ts +13 -9
  8. package/internal/dist/index.js +127 -92
  9. package/internal/src/atom/index.ts +1 -1
  10. package/internal/src/caching.ts +13 -9
  11. package/internal/src/families/create-atom-family.ts +1 -1
  12. package/internal/src/families/find-in-store.ts +2 -2
  13. package/internal/src/families/index.ts +1 -1
  14. package/internal/src/future.ts +52 -15
  15. package/internal/src/index.ts +2 -2
  16. package/internal/src/mutable/create-mutable-atom-family.ts +2 -3
  17. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  18. package/internal/src/mutable/get-update-token.ts +1 -0
  19. package/internal/src/selector/delete-selector.ts +1 -1
  20. package/internal/src/selector/register-selector.ts +1 -1
  21. package/internal/src/store/deposit.ts +1 -1
  22. package/internal/src/store/store.ts +2 -2
  23. package/internal/src/store/withdraw-new-family-member.ts +1 -1
  24. package/internal/src/store/withdraw.ts +2 -3
  25. package/internal/src/subscribe/subscribe-to-state.ts +1 -0
  26. package/internal/src/subscribe/subscribe-to-timeline.ts +1 -0
  27. package/internal/src/subscribe/subscribe-to-transaction.ts +2 -1
  28. package/internal/src/timeline/add-atom-to-timeline.ts +2 -2
  29. package/internal/src/timeline/create-timeline.ts +1 -1
  30. package/internal/src/transaction/act-upon-store.ts +1 -1
  31. package/internal/src/transaction/apply-transaction.ts +1 -1
  32. package/internal/src/transaction/build-transaction.ts +2 -2
  33. package/internal/src/transaction/create-transaction.ts +2 -2
  34. package/internal/src/transaction/index.ts +1 -1
  35. package/internal/src/transaction/is-root-store.ts +1 -1
  36. package/introspection/src/attach-atom-index.ts +1 -1
  37. package/introspection/src/attach-introspection-states.ts +2 -2
  38. package/introspection/src/attach-selector-index.ts +1 -1
  39. package/introspection/src/attach-timeline-family.ts +2 -2
  40. package/introspection/src/attach-timeline-index.ts +1 -1
  41. package/introspection/src/attach-transaction-index.ts +2 -2
  42. package/introspection/src/attach-transaction-logs.ts +2 -2
  43. package/json/dist/index.cjs +35 -33
  44. package/json/dist/index.d.ts +5 -5
  45. package/json/src/index.ts +2 -3
  46. package/json/src/select-json-family.ts +1 -1
  47. package/json/src/select-json.ts +1 -2
  48. package/package.json +15 -15
  49. package/react/src/use-tl.ts +1 -1
  50. package/react-devtools/dist/index.cjs +99 -99
  51. package/react-devtools/dist/index.d.ts +2 -2
  52. package/react-devtools/dist/index.js +77 -77
  53. package/react-devtools/src/AtomIODevtools.tsx +2 -2
  54. package/react-devtools/src/TransactionIndex.tsx +2 -2
  55. package/react-devtools/src/Updates.tsx +1 -1
  56. package/react-devtools/src/index.ts +1 -1
  57. package/realtime/src/realtime-continuity.ts +1 -1
  58. package/realtime-client/dist/index.js +1 -1
  59. package/realtime-client/src/pull-atom-family-member.ts +1 -1
  60. package/realtime-client/src/pull-atom.ts +1 -1
  61. package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
  62. package/realtime-client/src/sync-continuity.ts +1 -1
  63. package/realtime-react/dist/index.js +1 -1
  64. package/realtime-react/src/use-realtime-service.ts +1 -0
  65. package/realtime-react/src/use-sync-continuity.ts +2 -1
  66. package/realtime-server/dist/index.cjs +98 -98
  67. package/realtime-server/dist/index.d.ts +14 -14
  68. package/realtime-server/dist/index.js +100 -100
  69. package/realtime-server/src/index.ts +5 -5
  70. package/realtime-server/src/ipc-sockets/parent-socket.ts +3 -3
  71. package/realtime-server/src/realtime-action-receiver.ts +1 -1
  72. package/realtime-server/src/realtime-continuity-synchronizer.ts +2 -3
  73. package/realtime-server/src/realtime-family-provider.ts +1 -1
  74. package/realtime-server/src/realtime-mutable-family-provider.ts +1 -1
  75. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  76. package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +2 -2
  77. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +1 -1
  78. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -0
  79. package/realtime-server/src/realtime-state-provider.ts +1 -1
  80. package/realtime-server/src/realtime-state-synchronizer.ts +1 -1
  81. package/realtime-testing/dist/index.js +2 -2
  82. package/realtime-testing/src/setup-realtime-test.tsx +3 -2
  83. package/src/atom.ts +1 -1
  84. package/src/find-state.ts +1 -1
  85. package/src/index.ts +1 -0
  86. package/src/selector.ts +1 -1
  87. package/src/silo.ts +4 -4
  88. package/src/subscribe.ts +2 -2
  89. package/src/timeline.ts +1 -1
  90. package/src/transaction.ts +3 -3
  91. package/transceivers/set-rtx/src/set-rtx.ts +1 -1
  92. package/dist/{chunk-ATKDGVTV.js → chunk-2AIFLP2B.js} +0 -0
  93. package/dist/{chunk-CC7IF7QF.js → chunk-3V3VWQ7X.js} +6 -6
  94. /package/dist/{chunk-MSCJWACE.js → chunk-SMZRGPN6.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  export * from "./create-atom-family"
2
- export * from "./create-regular-atom-family"
3
2
  export * from "./create-readonly-selector-family"
3
+ export * from "./create-regular-atom-family"
4
4
  export * from "./create-selector-family"
5
5
  export * from "./find-in-store"
@@ -1,5 +1,5 @@
1
1
  /**
2
- * A Promise that can be canceled.
2
+ * A Promise whose incoming value can be hot swapped.
3
3
  * @internal
4
4
  * @private
5
5
  * @typeParam T The type of the value that the promise will resolve to.
@@ -8,29 +8,66 @@
8
8
  * Can be constructed like a Promise, or from an existing Promise.
9
9
  */
10
10
  export class Future<T> extends Promise<T> {
11
- public isCanceled = false
11
+ private destiny: Promise<T> | undefined
12
+ private resolve: (value: T) => void
13
+ private reject: (reason?: any) => void
12
14
 
13
15
  public constructor(
14
16
  executor:
15
17
  | Promise<T>
16
18
  | ((resolve: (value: T) => void, reject: (reason?: any) => void) => void),
17
19
  ) {
20
+ let promise: Promise<T> | undefined
21
+ let superResolve: ((value: T) => void) | undefined
22
+ let superReject: ((reason?: any) => void) | undefined
18
23
  super((resolve, reject) => {
19
- const pass = (value: T) => {
20
- this.isCanceled ? reject(`canceled`) : resolve(value)
21
- }
22
- const fail = (reason: any) => {
23
- this.isCanceled ? reject(`canceled`) : reject(reason)
24
- }
25
- if (typeof executor === `function`) {
26
- executor(pass, fail)
27
- } else {
28
- executor.then(pass, fail)
29
- }
24
+ superResolve = resolve
25
+ superReject = reject
26
+ promise = executor instanceof Promise ? executor : new Promise(executor)
27
+ promise.then(
28
+ (value) => {
29
+ if (promise) {
30
+ this.pass(promise, value)
31
+ }
32
+ },
33
+ (reason) => {
34
+ if (promise) {
35
+ this.fail(promise, reason)
36
+ }
37
+ },
38
+ )
30
39
  })
40
+ this.destiny = promise
41
+ this.resolve = superResolve as (value: T) => void
42
+ this.reject = superReject as (reason?: any) => void
31
43
  }
32
44
 
33
- public cancel(): void {
34
- this.isCanceled = true
45
+ private pass(promise: Promise<T>, value: T) {
46
+ if (promise === this.destiny) {
47
+ this.resolve(value)
48
+ }
49
+ }
50
+ private fail(promise: Promise<T>, reason: any) {
51
+ if (promise === this.destiny) {
52
+ this.reject(reason)
53
+ }
54
+ }
55
+
56
+ public use(value: Promise<T> | T): void {
57
+ if (value instanceof Promise) {
58
+ const promise = value
59
+ this.destiny = promise
60
+ promise.then(
61
+ (resolved) => {
62
+ this.pass(promise, resolved)
63
+ },
64
+ (reason) => {
65
+ this.fail(promise, reason)
66
+ },
67
+ )
68
+ } else {
69
+ this.resolve(value)
70
+ this.destiny = undefined
71
+ }
35
72
  }
36
73
  }
@@ -5,10 +5,9 @@ import type { Transceiver } from "./mutable"
5
5
  import type { Store } from "./store"
6
6
  import type { Subject } from "./subject"
7
7
 
8
- export * from "./atom"
9
8
  export * from "./arbitrary"
9
+ export * from "./atom"
10
10
  export * from "./caching"
11
- export * from "./lineage"
12
11
  export * from "./families"
13
12
  export * from "./future"
14
13
  export * from "./get-environment-data"
@@ -16,6 +15,7 @@ export * from "./get-state"
16
15
  export * from "./ingest-updates"
17
16
  export * from "./keys"
18
17
  export * from "./lazy-map"
18
+ export * from "./lineage"
19
19
  export * from "./mutable"
20
20
  export * from "./not-found-error"
21
21
  export * from "./operation"
@@ -1,13 +1,12 @@
1
1
  import type {
2
+ FamilyMetadata,
2
3
  MutableAtomFamily,
3
4
  MutableAtomFamilyOptions,
4
5
  MutableAtomOptions,
5
6
  MutableAtomToken,
6
7
  } from "atom.io"
7
- import type { FamilyMetadata } from "atom.io"
8
8
  import type { Json } from "atom.io/json"
9
- import { selectJsonFamily } from "atom.io/json"
10
- import { stringifyJson } from "atom.io/json"
9
+ import { selectJsonFamily, stringifyJson } from "atom.io/json"
11
10
 
12
11
  import { newest } from "../lineage"
13
12
  import { createMutableAtom } from "../mutable"
@@ -1,16 +1,16 @@
1
- import type { UpdateHandler } from "atom.io"
2
1
  import type {
3
2
  FamilyMetadata,
4
3
  MutableAtomOptions,
5
4
  MutableAtomToken,
5
+ UpdateHandler,
6
6
  } from "atom.io"
7
7
  import type { Json } from "atom.io/json"
8
8
  import { selectJson } from "atom.io/json"
9
9
 
10
- import { type MutableAtom, cacheValue, setIntoStore } from ".."
10
+ import { cacheValue, type MutableAtom, setIntoStore } from ".."
11
11
  import { markAtomAsDefault } from "../atom"
12
12
  import { newest } from "../lineage"
13
- import { type Store, deposit } from "../store"
13
+ import { deposit, type Store } from "../store"
14
14
  import { Subject } from "../subject"
15
15
  import { subscribeToState } from "../subscribe"
16
16
  import { Tracker } from "./tracker"
@@ -1,5 +1,6 @@
1
1
  import type { MutableAtomToken, RegularAtomToken } from "atom.io"
2
2
  import type { Json } from "atom.io/json"
3
+
3
4
  import type { Signal, Transceiver } from "./transceiver"
4
5
 
5
6
  export const getUpdateToken = <
@@ -1,7 +1,7 @@
1
1
  import type { ReadonlySelectorToken, WritableSelectorToken } from "atom.io"
2
2
 
3
- import { newest } from ".."
4
3
  import type { Store } from ".."
4
+ import { newest } from ".."
5
5
 
6
6
  export function deleteSelector(
7
7
  selectorToken: ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>,
@@ -1,4 +1,4 @@
1
- import type { Transactors, findState } from "atom.io"
1
+ import type { findState, Transactors } from "atom.io"
2
2
 
3
3
  import { findInStore } from "../families"
4
4
  import { readOrComputeValue } from "../get-state/read-or-compute-value"
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ Func,
2
3
  MutableAtomToken,
3
4
  ReadableToken,
4
5
  ReadonlySelectorToken,
@@ -7,7 +8,6 @@ import type {
7
8
  TransactionToken,
8
9
  WritableSelectorToken,
9
10
  WritableToken,
10
- Func,
11
11
  } from "atom.io"
12
12
 
13
13
  import type {
@@ -1,6 +1,6 @@
1
- import { AtomIOLogger } from "atom.io"
2
1
  import type {
3
2
  AtomToken,
3
+ Func,
4
4
  Logger,
5
5
  MutableAtomFamily,
6
6
  ReadonlySelectorFamily,
@@ -10,8 +10,8 @@ import type {
10
10
  TransactionToken,
11
11
  WritableSelectorFamily,
12
12
  WritableSelectorToken,
13
- Func,
14
13
  } from "atom.io"
14
+ import { AtomIOLogger } from "atom.io"
15
15
 
16
16
  import { Junction } from "~/packages/rel8/junction/src"
17
17
 
@@ -14,7 +14,7 @@ import type {
14
14
  WritableSelector,
15
15
  WritableState,
16
16
  } from ".."
17
- import { NotFoundError, newest, withdraw } from ".."
17
+ import { newest, NotFoundError, withdraw } from ".."
18
18
 
19
19
  export function withdrawOrCreate<T>(
20
20
  token: RegularAtomToken<T>,
@@ -2,6 +2,7 @@ import type {
2
2
  AtomFamily,
3
3
  AtomFamilyToken,
4
4
  AtomToken,
5
+ Func,
5
6
  MutableAtomFamily,
6
7
  MutableAtomFamilyToken,
7
8
  MutableAtomToken,
@@ -22,10 +23,9 @@ import type {
22
23
  WritableSelectorFamilyToken,
23
24
  WritableSelectorToken,
24
25
  WritableToken,
25
- Func,
26
26
  } from "atom.io"
27
-
28
27
  import type { Json } from "atom.io/json"
28
+
29
29
  import type {
30
30
  Atom,
31
31
  MutableAtom,
@@ -38,7 +38,6 @@ import type {
38
38
  WritableState,
39
39
  } from ".."
40
40
  import { NotFoundError } from ".."
41
-
42
41
  import type { Timeline } from "../timeline"
43
42
  import type { Transaction } from "../transaction"
44
43
  import type { Store } from "./store"
@@ -1,4 +1,5 @@
1
1
  import type { ReadableToken, UpdateHandler } from "atom.io"
2
+
2
3
  import type { Store } from "../store"
3
4
  import { withdrawOrCreate } from "../store"
4
5
  import { subscribeToRootAtoms } from "./subscribe-to-root-atoms"
@@ -1,4 +1,5 @@
1
1
  import type { TimelineManageable, TimelineToken, TimelineUpdate } from "atom.io"
2
+
2
3
  import type { Store } from ".."
3
4
  import { withdraw } from ".."
4
5
 
@@ -1,4 +1,5 @@
1
- import type { TransactionToken, TransactionUpdateHandler, Func } from "atom.io"
1
+ import type { Func, TransactionToken, TransactionUpdateHandler } from "atom.io"
2
+
2
3
  import type { Store } from ".."
3
4
  import { withdraw } from ".."
4
5
 
@@ -1,10 +1,10 @@
1
1
  import type {
2
2
  AtomToken,
3
+ Func,
4
+ TimelineUpdate,
3
5
  TransactionToken,
4
6
  TransactionUpdate,
5
- Func,
6
7
  } from "atom.io"
7
- import type { TimelineUpdate } from "atom.io"
8
8
 
9
9
  import { newest } from "../lineage"
10
10
  import { getUpdateToken } from "../mutable"
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  AtomFamilyToken,
3
3
  FamilyMetadata,
4
+ Func,
4
5
  StateUpdate,
5
6
  TimelineManageable,
6
7
  TimelineOptions,
@@ -8,7 +9,6 @@ import type {
8
9
  TimelineUpdate,
9
10
  TokenType,
10
11
  TransactionUpdate,
11
- Func,
12
12
  } from "atom.io"
13
13
 
14
14
  import { newest } from "../lineage"
@@ -1,4 +1,4 @@
1
- import type { TransactionToken, Func } from "atom.io"
1
+ import type { Func, TransactionToken } from "atom.io"
2
2
 
3
3
  import { NotFoundError } from "../not-found-error"
4
4
  import type { Store } from "../store"
@@ -2,8 +2,8 @@ import type { Func } from "atom.io"
2
2
 
3
3
  import { ingestTransactionUpdate } from "../ingest-updates"
4
4
  import { newest } from "../lineage"
5
- import { withdraw } from "../store"
6
5
  import type { Store } from "../store"
6
+ import { withdraw } from "../store"
7
7
  import { isChildStore, isRootStore } from "./is-root-store"
8
8
  import { setEpochNumberOfAction } from "./set-epoch-number"
9
9
 
@@ -2,8 +2,6 @@ import type { findState, Func } from "atom.io"
2
2
 
3
3
  import { Junction } from "~/packages/rel8/junction/src"
4
4
 
5
- import type { TransactionProgress } from "."
6
- import { actUponStore, getEpochNumberOfAction } from "."
7
5
  import { arbitrary } from "../arbitrary"
8
6
  import { findInStore } from "../families"
9
7
  import { getEnvironmentData } from "../get-environment-data"
@@ -12,6 +10,8 @@ import { LazyMap } from "../lazy-map"
12
10
  import { newest } from "../lineage"
13
11
  import { setIntoStore } from "../set-state"
14
12
  import type { Store } from "../store"
13
+ import type { TransactionProgress } from "."
14
+ import { actUponStore, getEpochNumberOfAction } from "."
15
15
  import type { ChildStore, RootStore } from "./is-root-store"
16
16
 
17
17
  export const buildTransaction = (
@@ -1,13 +1,13 @@
1
1
  import type {
2
+ Func,
2
3
  TransactionOptions,
3
4
  TransactionToken,
4
5
  TransactionUpdate,
5
- Func,
6
6
  } from "atom.io"
7
7
 
8
8
  import { newest } from "../lineage"
9
- import { deposit } from "../store"
10
9
  import type { Store } from "../store"
10
+ import { deposit } from "../store"
11
11
  import { Subject } from "../subject"
12
12
  import { abortTransaction } from "./abort-transaction"
13
13
  import { applyTransaction } from "./apply-transaction"
@@ -1,4 +1,4 @@
1
- import type { TransactionUpdate, TransactorsWithRunAndEnv, Func } from "atom.io"
1
+ import type { Func, TransactionUpdate, TransactorsWithRunAndEnv } from "atom.io"
2
2
  import type { Junction } from "rel8/junction"
3
3
 
4
4
  export * from "./abort-transaction"
@@ -1,7 +1,7 @@
1
1
  import type { Func } from "atom.io"
2
2
 
3
- import type { TransactionEpoch, TransactionProgress } from "."
4
3
  import type { Store } from "../store"
4
+ import type { TransactionEpoch, TransactionProgress } from "."
5
5
 
6
6
  export interface RootStore extends Store {
7
7
  transactionMeta: TransactionEpoch
@@ -1,9 +1,9 @@
1
1
  import type { AtomToken, ReadonlySelectorToken } from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
3
  import {
4
- IMPLICIT,
5
4
  createRegularAtom,
6
5
  createStandaloneSelector,
6
+ IMPLICIT,
7
7
  newest,
8
8
  } from "atom.io/internal"
9
9
 
@@ -1,14 +1,14 @@
1
1
  import type {
2
+ Func,
2
3
  ReadonlySelectorFamily,
3
4
  ReadonlySelectorFamilyToken,
4
5
  ReadonlySelectorToken,
5
6
  TimelineToken,
6
7
  TransactionToken,
7
8
  TransactionUpdate,
8
- Func,
9
9
  } from "atom.io"
10
- import * as Internal from "atom.io/internal"
11
10
  import type { Timeline } from "atom.io/internal"
11
+ import * as Internal from "atom.io/internal"
12
12
 
13
13
  import { type AtomTokenIndex, attachAtomIndex } from "./attach-atom-index"
14
14
  import type { SelectorTokenIndex } from "./attach-selector-index"
@@ -1,9 +1,9 @@
1
1
  import type { ReadonlySelectorToken, WritableSelectorToken } from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
3
  import {
4
- IMPLICIT,
5
4
  createRegularAtom,
6
5
  createStandaloneSelector,
6
+ IMPLICIT,
7
7
  newest,
8
8
  } from "atom.io/internal"
9
9
 
@@ -4,10 +4,10 @@ import type {
4
4
  } from "atom.io"
5
5
  import type { Store, Timeline } from "atom.io/internal"
6
6
  import {
7
- IMPLICIT,
8
- Subject,
9
7
  createRegularAtomFamily,
10
8
  createSelectorFamily,
9
+ IMPLICIT,
10
+ Subject,
11
11
  } from "atom.io/internal"
12
12
 
13
13
  export const attachTimelineFamily = (
@@ -1,9 +1,9 @@
1
1
  import type { ReadonlySelectorToken, TimelineToken } from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
3
  import {
4
- IMPLICIT,
5
4
  createRegularAtom,
6
5
  createStandaloneSelector,
6
+ IMPLICIT,
7
7
  } from "atom.io/internal"
8
8
 
9
9
  export const attachTimelineIndex = (
@@ -1,9 +1,9 @@
1
- import type { ReadonlySelectorToken, TransactionToken, Func } from "atom.io"
1
+ import type { Func, ReadonlySelectorToken, TransactionToken } from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
3
  import {
4
- IMPLICIT,
5
4
  createRegularAtom,
6
5
  createStandaloneSelector,
6
+ IMPLICIT,
7
7
  } from "atom.io/internal"
8
8
 
9
9
  export const attachTransactionIndex = (
@@ -1,13 +1,13 @@
1
1
  import type {
2
+ Func,
2
3
  ReadonlySelectorFamilyToken,
3
4
  TransactionUpdate,
4
- Func,
5
5
  } from "atom.io"
6
6
  import type { Store } from "atom.io/internal"
7
7
  import {
8
- IMPLICIT,
9
8
  createRegularAtomFamily,
10
9
  createSelectorFamily,
10
+ IMPLICIT,
11
11
  } from "atom.io/internal"
12
12
 
13
13
  export const attachTransactionLogs = (
@@ -2,6 +2,41 @@
2
2
 
3
3
  var internal = require('atom.io/internal');
4
4
 
5
+ // json/src/select-json.ts
6
+ var selectJson = (atom, transform, store = internal.IMPLICIT.STORE) => {
7
+ return internal.createStandaloneSelector(
8
+ {
9
+ key: `${atom.key}:JSON`,
10
+ get: ({ get }) => transform.toJson(get(atom)),
11
+ set: ({ set }, newValue) => {
12
+ set(atom, transform.fromJson(newValue));
13
+ }
14
+ },
15
+ store
16
+ );
17
+ };
18
+ function selectJsonFamily(family, transform, store = internal.IMPLICIT.STORE) {
19
+ const jsonFamily = internal.createSelectorFamily(
20
+ {
21
+ key: `${family.key}:JSON`,
22
+ get: (key) => ({ get }) => transform.toJson(get(family(key))),
23
+ set: (key) => ({ set }, newValue) => {
24
+ set(family(key), transform.fromJson(newValue));
25
+ }
26
+ },
27
+ store
28
+ );
29
+ family.subject.subscribe(
30
+ `store=${store.config.name}::json-selector-family`,
31
+ (token) => {
32
+ if (token.family) {
33
+ jsonFamily(parseJson(token.family.subKey));
34
+ }
35
+ }
36
+ );
37
+ return jsonFamily;
38
+ }
39
+
5
40
  // ../anvl/src/json/json-interface.ts
6
41
  var stringSetJsonInterface = {
7
42
  toJson: (stringSet) => Array.from(stringSet),
@@ -44,39 +79,6 @@ var isNull = (input) => {
44
79
  var isPrimitive = (input) => {
45
80
  return isString(input) || isNumber(input) || isBoolean(input) || isNull(input);
46
81
  };
47
- var selectJson = (atom, transform, store = internal.IMPLICIT.STORE) => {
48
- return internal.createStandaloneSelector(
49
- {
50
- key: `${atom.key}:JSON`,
51
- get: ({ get }) => transform.toJson(get(atom)),
52
- set: ({ set }, newValue) => {
53
- set(atom, transform.fromJson(newValue));
54
- }
55
- },
56
- store
57
- );
58
- };
59
- function selectJsonFamily(family, transform, store = internal.IMPLICIT.STORE) {
60
- const jsonFamily = internal.createSelectorFamily(
61
- {
62
- key: `${family.key}:JSON`,
63
- get: (key) => ({ get }) => transform.toJson(get(family(key))),
64
- set: (key) => ({ set }, newValue) => {
65
- set(family(key), transform.fromJson(newValue));
66
- }
67
- },
68
- store
69
- );
70
- family.subject.subscribe(
71
- `store=${store.config.name}::json-selector-family`,
72
- (token) => {
73
- if (token.family) {
74
- jsonFamily(parseJson(token.family.subKey));
75
- }
76
- }
77
- );
78
- return jsonFamily;
79
- }
80
82
 
81
83
  exports.JSON_DEFAULTS = JSON_DEFAULTS;
82
84
  exports.JSON_TYPE_NAMES = JSON_TYPE_NAMES;
@@ -1,6 +1,11 @@
1
1
  import * as AtomIO from 'atom.io';
2
2
  import { Store, Transceiver } from 'atom.io/internal';
3
3
 
4
+ declare const selectJson: <T, J extends Serializable>(atom: AtomIO.AtomToken<T>, transform: JsonInterface<T, J>, store?: Store) => AtomIO.WritableSelectorToken<J>;
5
+
6
+ declare function selectJsonFamily<T extends Transceiver<any>, J extends Serializable, K extends Serializable>(atomFamily: AtomIO.MutableAtomFamily<T, J, K>, transform: JsonInterface<T, J>, store: Store): AtomIO.WritableSelectorFamily<J, K>;
7
+ declare function selectJsonFamily<T, J extends Serializable, K extends Serializable>(atomFamily: AtomIO.RegularAtomFamily<T, K>, transform: JsonInterface<T, J>, store: Store): AtomIO.WritableSelectorFamily<J, K>;
8
+
4
9
  type JsonInterface<T, J extends Serializable = Serializable> = {
5
10
  toJson: (t: T) => J;
6
11
  fromJson: (json: J) => T;
@@ -44,11 +49,6 @@ interface JsonTypes extends Record<JsonTypeName, Serializable> {
44
49
  }
45
50
  declare const JSON_DEFAULTS: JsonTypes;
46
51
 
47
- declare const selectJson: <T, J extends Serializable>(atom: AtomIO.AtomToken<T>, transform: JsonInterface<T, J>, store?: Store) => AtomIO.WritableSelectorToken<J>;
48
-
49
- declare function selectJsonFamily<T extends Transceiver<any>, J extends Serializable, K extends Serializable>(atomFamily: AtomIO.MutableAtomFamily<T, J, K>, transform: JsonInterface<T, J>, store: Store): AtomIO.WritableSelectorFamily<J, K>;
50
- declare function selectJsonFamily<T, J extends Serializable, K extends Serializable>(atomFamily: AtomIO.RegularAtomFamily<T, K>, transform: JsonInterface<T, J>, store: Store): AtomIO.WritableSelectorFamily<J, K>;
51
-
52
52
  type JsonIO = (...params: Serializable[]) => Serializable | void;
53
53
 
54
54
  export { type Empty, JSON_DEFAULTS, JSON_TYPE_NAMES, json as Json, type JsonIO, type JsonInterface, type JsonTypeName, type JsonTypes, type Stringified, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, type primitive, selectJson, selectJsonFamily, stringSetJsonInterface, stringifyJson };
package/json/src/index.ts CHANGED
@@ -1,8 +1,7 @@
1
- export * from "~/packages/anvl/src/json"
2
- export * from "~/packages/anvl/src/primitive"
3
-
4
1
  export * from "./select-json"
5
2
  export * from "./select-json-family"
3
+ export * from "~/packages/anvl/src/json"
4
+ export * from "~/packages/anvl/src/primitive"
6
5
 
7
6
  import type { Json } from "~/packages/anvl/src/json"
8
7
 
@@ -1,6 +1,6 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import type { Store, Transceiver } from "atom.io/internal"
3
- import { IMPLICIT, createSelectorFamily } from "atom.io/internal"
3
+ import { createSelectorFamily, IMPLICIT } from "atom.io/internal"
4
4
 
5
5
  import type { Json, JsonInterface } from "."
6
6
  import { parseJson } from "."
@@ -1,8 +1,7 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
- import { IMPLICIT } from "atom.io/internal"
3
+ import { createStandaloneSelector, IMPLICIT } from "atom.io/internal"
4
4
 
5
- import { createStandaloneSelector } from "atom.io/internal"
6
5
  import type { Json, JsonInterface } from "."
7
6
 
8
7
  export const selectJson = <T, J extends Json.Serializable>(