atom.io 0.25.6 → 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.
- package/data/dist/index.d.ts +3 -3
- package/data/dist/index.js +33 -25
- package/data/package.json +1 -4
- package/data/src/dict.ts +3 -3
- package/dist/chunk-AK23DRMD.js +21 -0
- package/dist/{chunk-HYXKCFVY.js → chunk-IBTHB2PI.js} +59 -60
- package/dist/{chunk-MR5NETHW.js → chunk-IW6WYRS7.js} +4 -5
- package/dist/chunk-XWL6SNVU.js +7 -0
- package/dist/index.d.ts +32 -54
- package/dist/index.js +33 -21
- package/ephemeral/dist/index.d.ts +7 -7
- package/ephemeral/dist/index.js +1 -1
- package/ephemeral/package.json +1 -4
- package/ephemeral/src/find-state.ts +7 -7
- package/eslint-plugin/dist/index.js +7 -8
- package/eslint-plugin/package.json +1 -4
- package/immortal/dist/index.d.ts +7 -7
- package/immortal/dist/index.js +1 -1
- package/immortal/package.json +1 -4
- package/immortal/src/seek-state.ts +8 -8
- package/internal/dist/index.d.ts +56 -59
- package/internal/dist/index.js +178 -170
- package/internal/package.json +1 -4
- package/internal/src/families/create-atom-family.ts +4 -4
- package/internal/src/families/create-readonly-selector-family.ts +2 -2
- package/internal/src/families/create-regular-atom-family.ts +2 -2
- package/internal/src/families/create-selector-family.ts +4 -4
- package/internal/src/families/create-writable-selector-family.ts +2 -2
- package/internal/src/families/dispose-from-store.ts +3 -7
- package/internal/src/families/find-in-store.ts +9 -9
- package/internal/src/families/init-family-member.ts +25 -37
- package/internal/src/families/seek-in-store.ts +11 -10
- package/internal/src/get-state/get-from-store.ts +3 -3
- package/internal/src/molecule/grow-molecule-in-store.ts +9 -9
- package/internal/src/mutable/index.ts +0 -1
- package/internal/src/mutable/tracker-family.ts +2 -2
- package/internal/src/set-state/set-into-store.ts +4 -4
- package/internal/src/store/deposit.ts +3 -3
- package/internal/src/store/withdraw.ts +10 -9
- package/introspection/dist/index.js +32 -30
- package/introspection/package.json +1 -4
- package/json/dist/index.d.ts +10 -27
- package/json/dist/index.js +3 -3
- package/json/package.json +1 -4
- package/json/src/index.ts +8 -3
- package/json/src/select-json-family.ts +4 -4
- package/package.json +36 -65
- package/react/dist/index.d.ts +4 -4
- package/react/dist/index.js +2 -2
- package/react/package.json +1 -4
- package/react/src/parse-state-overloads.ts +4 -4
- package/react/src/use-i.ts +3 -3
- package/react/src/use-json.ts +3 -3
- package/react/src/use-o.ts +3 -3
- package/react-devtools/dist/index.d.ts +1 -1
- package/react-devtools/dist/index.js +90 -72
- package/react-devtools/package.json +1 -4
- package/react-devtools/src/StateIndex.tsx +5 -4
- package/realtime/dist/index.d.ts +3 -3
- package/realtime/dist/index.js +8 -9
- package/realtime/package.json +1 -4
- package/realtime/src/realtime-continuity.ts +2 -2
- package/realtime-client/dist/index.js +6 -6
- package/realtime-client/package.json +1 -4
- package/realtime-react/dist/index.d.ts +4 -4
- package/realtime-react/dist/index.js +9 -11
- package/realtime-react/package.json +1 -4
- package/realtime-react/src/use-pull-atom-family-member.ts +2 -2
- package/realtime-react/src/use-pull-mutable-family-member.ts +2 -2
- package/realtime-react/src/use-pull-selector-family-member.ts +2 -2
- package/realtime-server/dist/index.d.ts +9 -9
- package/realtime-server/dist/index.js +59 -54
- package/realtime-server/package.json +1 -4
- package/realtime-server/src/ipc-sockets/custom-socket.ts +2 -2
- package/realtime-server/src/realtime-family-provider.ts +3 -2
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
- package/realtime-testing/dist/index.js +3 -3
- package/realtime-testing/package.json +1 -4
- package/src/atom.ts +15 -42
- package/src/dispose-state.ts +2 -2
- package/src/get-state.ts +4 -4
- package/src/index.ts +5 -5
- package/src/molecule.ts +4 -3
- package/src/selector.ts +17 -39
- package/src/set-state.ts +3 -2
- package/src/silo.ts +4 -4
- package/transceivers/set-rtx/dist/index.js +11 -11
- package/transceivers/set-rtx/package.json +1 -4
- package/transceivers/set-rtx/src/set-rtx.ts +5 -5
- package/data/dist/index.cjs +0 -953
- package/dist/chunk-BF4MVQF6.js +0 -44
- package/dist/chunk-S4N6XNPH.js +0 -38
- package/dist/index.cjs +0 -215
- package/ephemeral/dist/index.cjs +0 -11
- package/eslint-plugin/dist/index.cjs +0 -388
- package/immortal/dist/index.cjs +0 -14
- package/internal/dist/index.cjs +0 -3405
- package/internal/src/mutable/is-mutable.ts +0 -16
- package/introspection/dist/index.cjs +0 -449
- package/json/dist/index.cjs +0 -128
- package/react/dist/index.cjs +0 -118
- package/react-devtools/dist/index.cjs +0 -2191
- package/realtime/dist/index.cjs +0 -120
- package/realtime-client/dist/index.cjs +0 -569
- package/realtime-react/dist/index.cjs +0 -189
- package/realtime-server/dist/index.cjs +0 -965
- package/realtime-testing/dist/index.cjs +0 -201
- package/transceivers/set-rtx/dist/index.cjs +0 -215
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
159
|
-
>(
|
|
160
|
-
|
|
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
|
-
):
|
|
165
|
-
export function atomFamily<T, K extends
|
|
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
|
}
|
package/src/dispose-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, 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
|
|
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 {
|
|
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
|
|
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:
|
|
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?:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
26
|
+
import type { Canonical, Json } from "atom.io/json"
|
|
27
|
+
import { stringifyJson } from "atom.io/json"
|
|
27
28
|
|
|
28
|
-
export type CtorToolkit<K extends
|
|
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
|
|
57
|
+
spawn<Key extends Canonical, Ctor extends MoleculeConstructor>(
|
|
57
58
|
family: MoleculeFamilyToken<Ctor>,
|
|
58
59
|
key: Key,
|
|
59
60
|
...params: MoleculeParams<Ctor>
|
package/src/selector.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createStandaloneSelector,
|
|
5
5
|
IMPLICIT,
|
|
6
6
|
} from "atom.io/internal"
|
|
7
|
-
import type {
|
|
7
|
+
import type { Canonical } from "atom.io/json"
|
|
8
8
|
|
|
9
9
|
import type { ReadonlySelectorToken, WritableSelectorToken } from "."
|
|
10
10
|
import type { Read, StateCreation, StateDisposal, Write } from "./transaction"
|
|
@@ -31,35 +31,25 @@ export function selector<T>(
|
|
|
31
31
|
return createStandaloneSelector(options, IMPLICIT.STORE)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export type WritableSelectorFamilyOptions<T, K extends
|
|
34
|
+
export type WritableSelectorFamilyOptions<T, K extends Canonical> = {
|
|
35
35
|
key: string
|
|
36
36
|
get: (key: K) => Read<() => T>
|
|
37
37
|
set: (key: K) => Write<(newValue: T) => void>
|
|
38
38
|
}
|
|
39
|
-
export type ReadonlySelectorFamilyOptions<T, K extends
|
|
39
|
+
export type ReadonlySelectorFamilyOptions<T, K extends Canonical> = {
|
|
40
40
|
key: string
|
|
41
41
|
get: (key: K) => Read<() => T>
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export type WritableSelectorFamilyToken<T, K extends
|
|
44
|
+
export type WritableSelectorFamilyToken<T, K extends Canonical> = {
|
|
45
45
|
key: string
|
|
46
46
|
type: `selector_family`
|
|
47
47
|
__T?: T
|
|
48
48
|
__K?: K
|
|
49
49
|
}
|
|
50
|
+
|
|
50
51
|
// biome-ignore format: intersection
|
|
51
|
-
export type
|
|
52
|
-
T,
|
|
53
|
-
K extends Json.Serializable,
|
|
54
|
-
> =
|
|
55
|
-
& WritableSelectorFamilyToken<T, K>
|
|
56
|
-
& {
|
|
57
|
-
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
58
|
-
/* eslint-disable-next-line @typescript-eslint/prefer-function-type */
|
|
59
|
-
(key: K): WritableSelectorToken<T>
|
|
60
|
-
}
|
|
61
|
-
// biome-ignore format: intersection
|
|
62
|
-
export type WritableSelectorFamily<T, K extends Json.Serializable> =
|
|
52
|
+
export type WritableSelectorFamily<T, K extends Canonical> =
|
|
63
53
|
& WritableSelectorFamilyToken<T, K>
|
|
64
54
|
& {
|
|
65
55
|
(key: K): WritableSelectorToken<T>
|
|
@@ -67,25 +57,15 @@ export type WritableSelectorFamily<T, K extends Json.Serializable> =
|
|
|
67
57
|
install: (store: Store) => void
|
|
68
58
|
}
|
|
69
59
|
|
|
70
|
-
export type ReadonlySelectorFamilyToken<T, K extends
|
|
60
|
+
export type ReadonlySelectorFamilyToken<T, K extends Canonical> = {
|
|
71
61
|
key: string
|
|
72
62
|
type: `readonly_selector_family`
|
|
73
63
|
__T?: T
|
|
74
64
|
__K?: K
|
|
75
65
|
}
|
|
66
|
+
|
|
76
67
|
// biome-ignore format: intersection
|
|
77
|
-
export type
|
|
78
|
-
T,
|
|
79
|
-
K extends Json.Serializable,
|
|
80
|
-
> =
|
|
81
|
-
& ReadonlySelectorFamilyToken<T, K>
|
|
82
|
-
& {
|
|
83
|
-
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
84
|
-
/* eslint-disable-next-line @typescript-eslint/prefer-function-type */
|
|
85
|
-
(key: K): ReadonlySelectorToken<T>
|
|
86
|
-
}
|
|
87
|
-
// biome-ignore format: intersection
|
|
88
|
-
export type ReadonlySelectorFamily<T, K extends Json.Serializable> =
|
|
68
|
+
export type ReadonlySelectorFamily<T, K extends Canonical> =
|
|
89
69
|
& ((key: K) => ReadonlySelectorToken<T>)
|
|
90
70
|
& {
|
|
91
71
|
key: string
|
|
@@ -96,25 +76,23 @@ export type ReadonlySelectorFamily<T, K extends Json.Serializable> =
|
|
|
96
76
|
__K?: K
|
|
97
77
|
}
|
|
98
78
|
|
|
99
|
-
export type SelectorFamily<T, K extends
|
|
79
|
+
export type SelectorFamily<T, K extends Canonical> =
|
|
100
80
|
| ReadonlySelectorFamily<T, K>
|
|
101
81
|
| WritableSelectorFamily<T, K>
|
|
102
|
-
export type SelectorFamilyToken<T, K extends
|
|
82
|
+
export type SelectorFamilyToken<T, K extends Canonical> =
|
|
103
83
|
| ReadonlySelectorFamilyToken<T, K>
|
|
104
84
|
| WritableSelectorFamilyToken<T, K>
|
|
105
85
|
|
|
106
|
-
export function selectorFamily<T, K extends
|
|
86
|
+
export function selectorFamily<T, K extends Canonical>(
|
|
107
87
|
options: WritableSelectorFamilyOptions<T, K>,
|
|
108
|
-
):
|
|
109
|
-
export function selectorFamily<T, K extends
|
|
88
|
+
): WritableSelectorFamilyToken<T, K>
|
|
89
|
+
export function selectorFamily<T, K extends Canonical>(
|
|
110
90
|
options: ReadonlySelectorFamilyOptions<T, K>,
|
|
111
|
-
):
|
|
112
|
-
export function selectorFamily<T, K extends
|
|
91
|
+
): ReadonlySelectorFamilyToken<T, K>
|
|
92
|
+
export function selectorFamily<T, K extends Canonical>(
|
|
113
93
|
options:
|
|
114
94
|
| ReadonlySelectorFamilyOptions<T, K>
|
|
115
95
|
| WritableSelectorFamilyOptions<T, K>,
|
|
116
|
-
):
|
|
117
|
-
| ReadonlySelectorFamilyTokenWithCall<T, K>
|
|
118
|
-
| WritableSelectorFamilyTokenWithCall<T, K> {
|
|
96
|
+
): ReadonlySelectorFamilyToken<T, K> | WritableSelectorFamilyToken<T, K> {
|
|
119
97
|
return createSelectorFamily(options, IMPLICIT.STORE)
|
|
120
98
|
}
|
package/src/set-state.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Internal from "atom.io/internal"
|
|
2
|
+
import type { Canonical } from "atom.io/json"
|
|
2
3
|
import type { Json } from "rel8"
|
|
3
4
|
|
|
4
5
|
import type { WritableFamilyToken, WritableToken } from "."
|
|
@@ -24,14 +25,14 @@ export function setState<T, New extends T>(
|
|
|
24
25
|
* @param value - The new value of the state.
|
|
25
26
|
* @overload Streamlined
|
|
26
27
|
*/
|
|
27
|
-
export function setState<T, K extends
|
|
28
|
+
export function setState<T, K extends Canonical, New extends T>(
|
|
28
29
|
token: WritableFamilyToken<T, K>,
|
|
29
30
|
key: K,
|
|
30
31
|
value: New | ((oldValue: T) => New),
|
|
31
32
|
): void
|
|
32
33
|
|
|
33
34
|
export function setState<T, New extends T>(
|
|
34
|
-
token: WritableFamilyToken<T,
|
|
35
|
+
token: WritableFamilyToken<T, Canonical> | WritableToken<T>,
|
|
35
36
|
p1: Json.Serializable | New | ((oldValue: T) => New),
|
|
36
37
|
p2?: New | ((oldValue: T) => New),
|
|
37
38
|
): void {
|
package/src/silo.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
Store,
|
|
17
17
|
timeTravel,
|
|
18
18
|
} from "atom.io/internal"
|
|
19
|
-
import type { Json } from "atom.io/json"
|
|
19
|
+
import type { Canonical, Json } from "atom.io/json"
|
|
20
20
|
|
|
21
21
|
import type {
|
|
22
22
|
AtomToken,
|
|
@@ -73,12 +73,12 @@ export class Silo {
|
|
|
73
73
|
function _atomFamily<
|
|
74
74
|
T extends Transceiver<any>,
|
|
75
75
|
J extends Json.Serializable,
|
|
76
|
-
K extends
|
|
76
|
+
K extends Canonical,
|
|
77
77
|
>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>
|
|
78
|
-
function _atomFamily<T, K extends
|
|
78
|
+
function _atomFamily<T, K extends Canonical>(
|
|
79
79
|
options: RegularAtomFamilyOptions<T, K>,
|
|
80
80
|
): RegularAtomFamily<T, K>
|
|
81
|
-
function _atomFamily<T, K extends
|
|
81
|
+
function _atomFamily<T, K extends Canonical>(
|
|
82
82
|
options:
|
|
83
83
|
| MutableAtomFamilyOptions<any, any, any>
|
|
84
84
|
| RegularAtomFamilyOptions<T, K>,
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import '../../../dist/chunk-
|
|
1
|
+
import '../../../dist/chunk-XWL6SNVU.js';
|
|
2
2
|
import { Subject } from 'atom.io/internal';
|
|
3
3
|
import { stringifyJson, parseJson } from 'atom.io/json';
|
|
4
4
|
|
|
5
5
|
var SetRTX = class _SetRTX extends Set {
|
|
6
|
+
mode = `record`;
|
|
7
|
+
subject = new Subject();
|
|
8
|
+
cacheLimit = 0;
|
|
9
|
+
cache = [];
|
|
10
|
+
cacheIdx = -1;
|
|
11
|
+
cacheUpdateNumber = -1;
|
|
6
12
|
constructor(values, cacheLimit = 0) {
|
|
7
13
|
super(values);
|
|
8
|
-
this.mode = `record`;
|
|
9
|
-
this.subject = new Subject();
|
|
10
|
-
this.cacheLimit = 0;
|
|
11
|
-
this.cache = [];
|
|
12
|
-
this.cacheIdx = -1;
|
|
13
|
-
this.cacheUpdateNumber = -1;
|
|
14
|
-
this.child = null;
|
|
15
|
-
this.transactionUpdates = null;
|
|
16
14
|
if (values instanceof _SetRTX) {
|
|
17
15
|
this.parent = values;
|
|
18
16
|
this.cacheUpdateNumber = values.cacheUpdateNumber;
|
|
@@ -67,13 +65,15 @@ var SetRTX = class _SetRTX extends Set {
|
|
|
67
65
|
}
|
|
68
66
|
return result;
|
|
69
67
|
}
|
|
68
|
+
parent;
|
|
69
|
+
child = null;
|
|
70
|
+
transactionUpdates = null;
|
|
70
71
|
transaction(run) {
|
|
71
72
|
this.mode = `transaction`;
|
|
72
73
|
this.transactionUpdates = [];
|
|
73
74
|
this.child = new _SetRTX(this);
|
|
74
75
|
const unsubscribe = this.child._subscribe(`transaction`, (update) => {
|
|
75
|
-
|
|
76
|
-
(_a = this.transactionUpdates) == null ? void 0 : _a.push(update);
|
|
76
|
+
this.transactionUpdates?.push(update);
|
|
77
77
|
});
|
|
78
78
|
try {
|
|
79
79
|
const shouldCommit = run(this.child);
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
"name": "atom.io-transceivers-set-rtx",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"private": true,
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"module": "dist/index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": {
|
|
10
9
|
"import": "./dist/index.js",
|
|
11
|
-
"browser": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs",
|
|
13
10
|
"types": "./dist/index.d.ts"
|
|
14
11
|
}
|
|
15
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Lineage, Transceiver, TransceiverMode } from "atom.io/internal"
|
|
2
2
|
import { Subject } from "atom.io/internal"
|
|
3
|
-
import type { Json, primitive,
|
|
3
|
+
import type { Json, primitive, stringified } from "atom.io/json"
|
|
4
4
|
import { parseJson, stringifyJson } from "atom.io/json"
|
|
5
5
|
|
|
6
6
|
export type SetUpdate =
|
|
@@ -145,13 +145,13 @@ export class SetRTX<P extends primitive>
|
|
|
145
145
|
const value = update.substring(typeValueBreak + 1)
|
|
146
146
|
switch (type) {
|
|
147
147
|
case `add`:
|
|
148
|
-
this.add(parseJson(value as
|
|
148
|
+
this.add(parseJson(value as stringified<P>))
|
|
149
149
|
break
|
|
150
150
|
case `clear`:
|
|
151
151
|
this.clear()
|
|
152
152
|
break
|
|
153
153
|
case `del`:
|
|
154
|
-
this.delete(parseJson(value as
|
|
154
|
+
this.delete(parseJson(value as stringified<P>))
|
|
155
155
|
break
|
|
156
156
|
case `tx`:
|
|
157
157
|
for (const subUpdate of value.split(`;`)) {
|
|
@@ -214,10 +214,10 @@ export class SetRTX<P extends primitive>
|
|
|
214
214
|
const value = update.substring(breakpoint + 1)
|
|
215
215
|
switch (type) {
|
|
216
216
|
case `add`:
|
|
217
|
-
this.delete(parseJson(value as
|
|
217
|
+
this.delete(parseJson(value as stringified<P>))
|
|
218
218
|
break
|
|
219
219
|
case `del`:
|
|
220
|
-
this.add(parseJson(value as
|
|
220
|
+
this.add(parseJson(value as stringified<P>))
|
|
221
221
|
break
|
|
222
222
|
case `clear`: {
|
|
223
223
|
const values = JSON.parse(value) as P[]
|