atom.io 0.27.1 → 0.27.3
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 +12 -12
- package/data/dist/index.js +20 -14
- package/data/src/dict.ts +4 -4
- package/data/src/join.ts +23 -18
- package/data/src/struct-family.ts +2 -2
- package/dist/chunk-ETCFHO7J.js +3087 -0
- package/dist/index.d.ts +4 -31
- package/eslint-plugin/dist/index.js +8 -0
- package/eslint-plugin/src/walk.ts +8 -0
- package/internal/dist/index.d.ts +52 -19
- package/internal/dist/index.js +2 -3044
- package/internal/src/families/create-atom-family.ts +6 -5
- package/internal/src/families/create-readonly-selector-family.ts +38 -29
- package/internal/src/families/create-regular-atom-family.ts +40 -31
- package/internal/src/families/create-selector-family.ts +6 -5
- package/internal/src/families/create-writable-selector-family.ts +39 -30
- package/internal/src/families/throw-in-case-of-conflicting-family.ts +18 -0
- package/internal/src/index.ts +76 -2
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +0 -1
- package/internal/src/ingest-updates/ingest-selector-update.ts +1 -1
- package/internal/src/molecule/dispose-molecule.ts +0 -1
- package/internal/src/molecule/grow-molecule-in-store.ts +27 -17
- package/internal/src/mutable/create-mutable-atom-family.ts +41 -32
- package/internal/src/mutable/get-json-family.ts +2 -1
- package/internal/src/mutable/get-update-family.ts +23 -0
- package/internal/src/mutable/index.ts +1 -0
- package/internal/src/mutable/tracker-family.ts +5 -3
- package/internal/src/not-found-error.ts +2 -35
- package/internal/src/pretty-print.ts +37 -0
- package/internal/src/store/store.ts +10 -4
- package/internal/src/store/withdraw.ts +8 -8
- package/introspection/dist/index.js +3 -3
- package/introspection/src/attach-timeline-family.ts +1 -1
- package/introspection/src/attach-transaction-logs.ts +2 -2
- package/json/dist/index.d.ts +2 -2
- package/json/dist/index.js +16 -12
- package/json/src/select-json-family.ts +21 -18
- package/package.json +4 -4
- package/realtime-server/dist/index.d.ts +1 -1
- package/src/atom.ts +2 -32
- package/src/get-state.ts +2 -2
- package/src/index.ts +1 -10
- package/src/selector.ts +1 -26
- package/src/set-state.ts +2 -2
- package/src/silo.ts +7 -5
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
AtomFamilyToken,
|
|
3
3
|
MutableAtomFamilyOptions,
|
|
4
|
-
|
|
4
|
+
MutableAtomFamilyToken,
|
|
5
5
|
RegularAtomFamilyOptions,
|
|
6
|
+
RegularAtomFamilyToken,
|
|
6
7
|
} from "atom.io"
|
|
7
8
|
import type { Canonical, Json } from "atom.io/json"
|
|
8
9
|
|
|
@@ -17,17 +18,17 @@ export function createAtomFamily<
|
|
|
17
18
|
>(
|
|
18
19
|
options: MutableAtomFamilyOptions<T, J, K>,
|
|
19
20
|
store: Store,
|
|
20
|
-
):
|
|
21
|
+
): MutableAtomFamilyToken<T, J, K>
|
|
21
22
|
export function createAtomFamily<T, K extends Canonical>(
|
|
22
23
|
options: RegularAtomFamilyOptions<T, K>,
|
|
23
24
|
store: Store,
|
|
24
|
-
):
|
|
25
|
+
): RegularAtomFamilyToken<T, K>
|
|
25
26
|
export function createAtomFamily<T, K extends Canonical>(
|
|
26
27
|
options:
|
|
27
28
|
| MutableAtomFamilyOptions<any, any, any>
|
|
28
29
|
| RegularAtomFamilyOptions<T, K>,
|
|
29
30
|
store: Store,
|
|
30
|
-
):
|
|
31
|
+
): AtomFamilyToken<any, any> {
|
|
31
32
|
const isMutable = `mutable` in options
|
|
32
33
|
|
|
33
34
|
if (isMutable) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
FamilyMetadata,
|
|
3
|
-
ReadonlySelectorFamily,
|
|
4
3
|
ReadonlySelectorFamilyOptions,
|
|
4
|
+
ReadonlySelectorFamilyToken,
|
|
5
5
|
ReadonlySelectorToken,
|
|
6
6
|
StateCreation,
|
|
7
7
|
StateDisposal,
|
|
@@ -9,46 +9,55 @@ import type {
|
|
|
9
9
|
import type { Canonical } from "atom.io/json"
|
|
10
10
|
import { stringifyJson } from "atom.io/json"
|
|
11
11
|
|
|
12
|
+
import type { ReadonlySelectorFamily } from ".."
|
|
12
13
|
import { newest } from "../lineage"
|
|
13
14
|
import { createReadonlySelector } from "../selector"
|
|
14
15
|
import type { Store } from "../store"
|
|
15
16
|
import { Subject } from "../subject"
|
|
17
|
+
import { throwInCaseOfConflictingFamily } from "./throw-in-case-of-conflicting-family"
|
|
16
18
|
|
|
17
19
|
export function createReadonlySelectorFamily<T, K extends Canonical>(
|
|
18
20
|
options: ReadonlySelectorFamilyOptions<T, K>,
|
|
19
21
|
store: Store,
|
|
20
|
-
|
|
22
|
+
internalRoles?: string[],
|
|
23
|
+
): ReadonlySelectorFamilyToken<T, K> {
|
|
24
|
+
const familyToken = {
|
|
25
|
+
key: options.key,
|
|
26
|
+
type: `readonly_selector_family`,
|
|
27
|
+
} as const satisfies ReadonlySelectorFamilyToken<T, K>
|
|
28
|
+
|
|
29
|
+
throwInCaseOfConflictingFamily(familyToken, store)
|
|
30
|
+
|
|
21
31
|
const subject = new Subject<
|
|
22
32
|
| StateCreation<ReadonlySelectorToken<T>>
|
|
23
33
|
| StateDisposal<ReadonlySelectorToken<T>>
|
|
24
34
|
>()
|
|
25
35
|
|
|
26
|
-
const
|
|
27
|
-
(key
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
) satisfies ReadonlySelectorFamily<T, K>
|
|
36
|
+
const familyFunction = (key: K): ReadonlySelectorToken<T> => {
|
|
37
|
+
const subKey = stringifyJson(key)
|
|
38
|
+
const family: FamilyMetadata = { key: options.key, subKey }
|
|
39
|
+
const fullKey = `${options.key}(${subKey})`
|
|
40
|
+
const target = newest(store)
|
|
41
|
+
|
|
42
|
+
const token = createReadonlySelector(
|
|
43
|
+
{
|
|
44
|
+
key: fullKey,
|
|
45
|
+
get: options.get(key),
|
|
46
|
+
},
|
|
47
|
+
family,
|
|
48
|
+
target,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
subject.next({ type: `state_creation`, token })
|
|
52
|
+
return token
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const readonlySelectorFamily = Object.assign(familyFunction, familyToken, {
|
|
56
|
+
subject,
|
|
57
|
+
install: (s: Store) => createReadonlySelectorFamily(options, s),
|
|
58
|
+
internalRoles,
|
|
59
|
+
}) satisfies ReadonlySelectorFamily<T, K>
|
|
60
|
+
|
|
52
61
|
store.families.set(options.key, readonlySelectorFamily)
|
|
53
|
-
return
|
|
62
|
+
return familyToken
|
|
54
63
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
FamilyMetadata,
|
|
3
|
-
RegularAtomFamily,
|
|
4
3
|
RegularAtomFamilyOptions,
|
|
4
|
+
RegularAtomFamilyToken,
|
|
5
5
|
RegularAtomOptions,
|
|
6
6
|
RegularAtomToken,
|
|
7
7
|
StateCreation,
|
|
@@ -10,47 +10,56 @@ import type {
|
|
|
10
10
|
import type { Canonical } from "atom.io/json"
|
|
11
11
|
import { stringifyJson } from "atom.io/json"
|
|
12
12
|
|
|
13
|
+
import type { RegularAtomFamily } from ".."
|
|
13
14
|
import { createRegularAtom } from "../atom"
|
|
14
15
|
import { newest } from "../lineage"
|
|
15
16
|
import type { Store } from "../store"
|
|
16
17
|
import { Subject } from "../subject"
|
|
18
|
+
import { throwInCaseOfConflictingFamily } from "./throw-in-case-of-conflicting-family"
|
|
17
19
|
|
|
18
20
|
export function createRegularAtomFamily<T, K extends Canonical>(
|
|
19
21
|
options: RegularAtomFamilyOptions<T, K>,
|
|
20
22
|
store: Store,
|
|
21
|
-
|
|
23
|
+
internalRoles?: string[],
|
|
24
|
+
): RegularAtomFamilyToken<T, K> {
|
|
25
|
+
const familyToken = {
|
|
26
|
+
key: options.key,
|
|
27
|
+
type: `atom_family`,
|
|
28
|
+
} as const satisfies RegularAtomFamilyToken<T, K>
|
|
29
|
+
|
|
30
|
+
throwInCaseOfConflictingFamily(familyToken, store)
|
|
31
|
+
|
|
22
32
|
const subject = new Subject<
|
|
23
33
|
StateCreation<RegularAtomToken<T>> | StateDisposal<RegularAtomToken<T>>
|
|
24
34
|
>()
|
|
25
35
|
|
|
26
|
-
const
|
|
27
|
-
(key
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
) satisfies RegularAtomFamily<T, K>
|
|
36
|
+
const familyFunction = (key: K): RegularAtomToken<any> => {
|
|
37
|
+
const subKey = stringifyJson(key)
|
|
38
|
+
const family: FamilyMetadata = { key: options.key, subKey }
|
|
39
|
+
const fullKey = `${options.key}(${subKey})`
|
|
40
|
+
const target = newest(store)
|
|
41
|
+
|
|
42
|
+
const def = options.default
|
|
43
|
+
const individualOptions: RegularAtomOptions<T> = {
|
|
44
|
+
key: fullKey,
|
|
45
|
+
default: def instanceof Function ? def(key) : def,
|
|
46
|
+
}
|
|
47
|
+
if (options.effects) {
|
|
48
|
+
individualOptions.effects = options.effects(key)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const token = createRegularAtom(individualOptions, family, target)
|
|
52
|
+
|
|
53
|
+
subject.next({ type: `state_creation`, token })
|
|
54
|
+
return token
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const atomFamily = Object.assign(familyFunction, familyToken, {
|
|
58
|
+
subject,
|
|
59
|
+
install: (s: Store) => createRegularAtomFamily(options, s),
|
|
60
|
+
internalRoles,
|
|
61
|
+
}) satisfies RegularAtomFamily<T, K>
|
|
62
|
+
|
|
54
63
|
store.families.set(options.key, atomFamily)
|
|
55
|
-
return
|
|
64
|
+
return familyToken
|
|
56
65
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
ReadonlySelectorFamily,
|
|
3
2
|
ReadonlySelectorFamilyOptions,
|
|
4
|
-
|
|
3
|
+
ReadonlySelectorFamilyToken,
|
|
4
|
+
SelectorFamilyToken,
|
|
5
5
|
WritableSelectorFamilyOptions,
|
|
6
|
+
WritableSelectorFamilyToken,
|
|
6
7
|
} from "atom.io"
|
|
7
8
|
import type { Canonical } from "atom.io/json"
|
|
8
9
|
|
|
@@ -13,17 +14,17 @@ import { createWritableSelectorFamily } from "./create-writable-selector-family"
|
|
|
13
14
|
export function createSelectorFamily<T, K extends Canonical>(
|
|
14
15
|
options: WritableSelectorFamilyOptions<T, K>,
|
|
15
16
|
store: Store,
|
|
16
|
-
):
|
|
17
|
+
): WritableSelectorFamilyToken<T, K>
|
|
17
18
|
export function createSelectorFamily<T, K extends Canonical>(
|
|
18
19
|
options: ReadonlySelectorFamilyOptions<T, K>,
|
|
19
20
|
store: Store,
|
|
20
|
-
):
|
|
21
|
+
): ReadonlySelectorFamilyToken<T, K>
|
|
21
22
|
export function createSelectorFamily<T, K extends Canonical>(
|
|
22
23
|
options:
|
|
23
24
|
| ReadonlySelectorFamilyOptions<T, K>
|
|
24
25
|
| WritableSelectorFamilyOptions<T, K>,
|
|
25
26
|
store: Store,
|
|
26
|
-
):
|
|
27
|
+
): SelectorFamilyToken<T, K> {
|
|
27
28
|
const isWritable = `set` in options
|
|
28
29
|
|
|
29
30
|
if (isWritable) {
|
|
@@ -2,54 +2,63 @@ import type {
|
|
|
2
2
|
FamilyMetadata,
|
|
3
3
|
StateCreation,
|
|
4
4
|
StateDisposal,
|
|
5
|
-
WritableSelectorFamily,
|
|
6
5
|
WritableSelectorFamilyOptions,
|
|
6
|
+
WritableSelectorFamilyToken,
|
|
7
7
|
WritableSelectorToken,
|
|
8
8
|
} from "atom.io"
|
|
9
9
|
import type { Canonical } from "atom.io/json"
|
|
10
10
|
import { stringifyJson } from "atom.io/json"
|
|
11
11
|
|
|
12
|
+
import type { WritableSelectorFamily } from ".."
|
|
12
13
|
import { newest } from "../lineage"
|
|
13
14
|
import { createWritableSelector } from "../selector"
|
|
14
15
|
import type { Store } from "../store"
|
|
15
16
|
import { Subject } from "../subject"
|
|
17
|
+
import { throwInCaseOfConflictingFamily } from "./throw-in-case-of-conflicting-family"
|
|
16
18
|
|
|
17
19
|
export function createWritableSelectorFamily<T, K extends Canonical>(
|
|
18
20
|
options: WritableSelectorFamilyOptions<T, K>,
|
|
19
21
|
store: Store,
|
|
20
|
-
|
|
22
|
+
internalRoles?: string[],
|
|
23
|
+
): WritableSelectorFamilyToken<T, K> {
|
|
24
|
+
const familyToken = {
|
|
25
|
+
key: options.key,
|
|
26
|
+
type: `selector_family`,
|
|
27
|
+
} as const satisfies WritableSelectorFamilyToken<T, K>
|
|
28
|
+
|
|
29
|
+
throwInCaseOfConflictingFamily(familyToken, store)
|
|
30
|
+
|
|
21
31
|
const subject = new Subject<
|
|
22
32
|
| StateCreation<WritableSelectorToken<T>>
|
|
23
33
|
| StateDisposal<WritableSelectorToken<T>>
|
|
24
34
|
>()
|
|
25
35
|
|
|
26
|
-
const
|
|
27
|
-
(key
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
) satisfies WritableSelectorFamily<T, K>
|
|
36
|
+
const familyFunction = (key: K): WritableSelectorToken<T> => {
|
|
37
|
+
const subKey = stringifyJson(key)
|
|
38
|
+
const family: FamilyMetadata = { key: options.key, subKey }
|
|
39
|
+
const fullKey = `${options.key}(${subKey})`
|
|
40
|
+
const target = newest(store)
|
|
41
|
+
|
|
42
|
+
const token = createWritableSelector(
|
|
43
|
+
{
|
|
44
|
+
key: fullKey,
|
|
45
|
+
get: options.get(key),
|
|
46
|
+
set: options.set(key),
|
|
47
|
+
},
|
|
48
|
+
family,
|
|
49
|
+
target,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
subject.next({ type: `state_creation`, token })
|
|
53
|
+
return token
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const selectorFamily = Object.assign(familyFunction, familyToken, {
|
|
57
|
+
subject,
|
|
58
|
+
install: (s: Store) => createWritableSelectorFamily(options, s),
|
|
59
|
+
internalRoles,
|
|
60
|
+
}) satisfies WritableSelectorFamily<T, K>
|
|
61
|
+
|
|
53
62
|
store.families.set(options.key, selectorFamily)
|
|
54
|
-
return
|
|
63
|
+
return familyToken
|
|
55
64
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AtomFamilyToken, SelectorFamilyToken } from "atom.io"
|
|
2
|
+
|
|
3
|
+
import { prettyPrintTokenType } from "../pretty-print"
|
|
4
|
+
import type { Store } from "../store"
|
|
5
|
+
|
|
6
|
+
export function throwInCaseOfConflictingFamily(
|
|
7
|
+
family: AtomFamilyToken<any, any> | SelectorFamilyToken<any, any>,
|
|
8
|
+
store: Store,
|
|
9
|
+
): void {
|
|
10
|
+
const existingFamily = store.families.get(family.key)
|
|
11
|
+
if (existingFamily) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Tried to create ${family.type === `atom_family` ? `an` : `a`} ${prettyPrintTokenType(family)} with key "${family.key}", but "${family.key}" already exists in store "${store.config.name}" as ${existingFamily.type === `atom_family` ? `an` : `a`} ${prettyPrintTokenType(
|
|
14
|
+
existingFamily,
|
|
15
|
+
)}`,
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
}
|
package/internal/src/index.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AtomToken,
|
|
3
|
+
FamilyMetadata,
|
|
4
|
+
MutableAtomFamilyToken,
|
|
5
|
+
MutableAtomToken,
|
|
6
|
+
ReadonlySelectorToken,
|
|
7
|
+
RegularAtomFamilyToken,
|
|
8
|
+
RegularAtomToken,
|
|
9
|
+
StateCreation,
|
|
10
|
+
StateDisposal,
|
|
11
|
+
WritableSelectorFamilyToken,
|
|
12
|
+
WritableSelectorToken,
|
|
13
|
+
} from "atom.io"
|
|
14
|
+
import type { Canonical, Json, JsonInterface } from "atom.io/json"
|
|
3
15
|
|
|
4
16
|
import type { Transceiver } from "./mutable"
|
|
5
17
|
import type { Store } from "./store"
|
|
@@ -20,6 +32,7 @@ export * from "./molecule"
|
|
|
20
32
|
export * from "./mutable"
|
|
21
33
|
export * from "./not-found-error"
|
|
22
34
|
export * from "./operation"
|
|
35
|
+
export * from "./pretty-print"
|
|
23
36
|
export * from "./selector"
|
|
24
37
|
export * from "./set-state"
|
|
25
38
|
export * from "./store"
|
|
@@ -67,3 +80,64 @@ export type Selector<T> = ReadonlySelector<T> | WritableSelector<T>
|
|
|
67
80
|
|
|
68
81
|
export type WritableState<T> = Atom<T> | WritableSelector<T>
|
|
69
82
|
export type ReadableState<T> = Atom<T> | Selector<T>
|
|
83
|
+
|
|
84
|
+
// biome-ignore format: intersection
|
|
85
|
+
export type RegularAtomFamily<T, K extends Canonical> =
|
|
86
|
+
& RegularAtomFamilyToken<T, K>
|
|
87
|
+
& {
|
|
88
|
+
(key: K): RegularAtomToken<T>
|
|
89
|
+
subject: Subject<StateCreation<AtomToken<T>> | StateDisposal<AtomToken<T>>>
|
|
90
|
+
install: (store: Store) => void
|
|
91
|
+
internalRoles: string[] | undefined
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// biome-ignore format: intersection
|
|
95
|
+
export type MutableAtomFamily<
|
|
96
|
+
T extends Transceiver<any>,
|
|
97
|
+
J extends Json.Serializable,
|
|
98
|
+
K extends Canonical,
|
|
99
|
+
> =
|
|
100
|
+
& JsonInterface<T, J>
|
|
101
|
+
& MutableAtomFamilyToken<T, J, K>
|
|
102
|
+
& {
|
|
103
|
+
(key: K): MutableAtomToken<T, J>
|
|
104
|
+
subject: Subject<StateCreation<MutableAtomToken<T, J>> | StateDisposal<MutableAtomToken<T, J>>>
|
|
105
|
+
install: (store: Store) => void
|
|
106
|
+
internalRoles: string[] | undefined
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type AtomFamily<T, K extends Canonical = Canonical> =
|
|
110
|
+
| MutableAtomFamily<T extends Transceiver<any> ? T : never, any, K>
|
|
111
|
+
| RegularAtomFamily<T, K>
|
|
112
|
+
|
|
113
|
+
// biome-ignore format: intersection
|
|
114
|
+
export type WritableSelectorFamily<T, K extends Canonical> =
|
|
115
|
+
& WritableSelectorFamilyToken<T, K>
|
|
116
|
+
& {
|
|
117
|
+
(key: K): WritableSelectorToken<T>
|
|
118
|
+
subject: Subject<StateCreation<WritableSelectorToken<T>> | StateDisposal<WritableSelectorToken<T>>>
|
|
119
|
+
install: (store: Store) => void
|
|
120
|
+
internalRoles : string[] | undefined
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// biome-ignore format: intersection
|
|
124
|
+
export type ReadonlySelectorFamily<T, K extends Canonical> =
|
|
125
|
+
& ((key: K) => ReadonlySelectorToken<T>)
|
|
126
|
+
& {
|
|
127
|
+
key: string
|
|
128
|
+
type: `readonly_selector_family`
|
|
129
|
+
subject: Subject<StateCreation<ReadonlySelectorToken<T>> | StateDisposal<ReadonlySelectorToken<T>>>
|
|
130
|
+
install: (store: Store) => void
|
|
131
|
+
internalRoles : string[] | undefined
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type SelectorFamily<T, K extends Canonical> =
|
|
135
|
+
| ReadonlySelectorFamily<T, K>
|
|
136
|
+
| WritableSelectorFamily<T, K>
|
|
137
|
+
|
|
138
|
+
export type WritableFamily<T, K extends Canonical> =
|
|
139
|
+
| AtomFamily<T, K>
|
|
140
|
+
| WritableSelectorFamily<T, K>
|
|
141
|
+
export type ReadableFamily<T, K extends Canonical> =
|
|
142
|
+
| AtomFamily<T, K>
|
|
143
|
+
| SelectorFamily<T, K>
|
|
@@ -9,7 +9,6 @@ import { parseJson, stringifyJson } from "atom.io/json"
|
|
|
9
9
|
|
|
10
10
|
import { disposeFromStore, initFamilyMemberInStore } from "../families"
|
|
11
11
|
import { growMoleculeInStore, makeMoleculeInStore } from "../molecule"
|
|
12
|
-
import { setIntoStore } from "../set-state"
|
|
13
12
|
import { type Store, withdraw } from "../store"
|
|
14
13
|
|
|
15
14
|
export function ingestCreationEvent(
|
|
@@ -10,7 +10,7 @@ export function ingestSelectorUpdate(
|
|
|
10
10
|
const updates =
|
|
11
11
|
applying === `newValue`
|
|
12
12
|
? selectorUpdate.atomUpdates
|
|
13
|
-
:
|
|
13
|
+
: selectorUpdate.atomUpdates.toReversed()
|
|
14
14
|
for (const atomUpdate of updates) {
|
|
15
15
|
ingestAtomUpdate(applying, atomUpdate, store)
|
|
16
16
|
}
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
AtomFamilyToken,
|
|
3
3
|
AtomToken,
|
|
4
|
-
|
|
4
|
+
MutableAtomFamilyToken,
|
|
5
5
|
MutableAtomToken,
|
|
6
|
-
|
|
6
|
+
ReadableFamilyToken,
|
|
7
7
|
ReadableToken,
|
|
8
|
-
|
|
8
|
+
ReadonlySelectorFamilyToken,
|
|
9
9
|
ReadonlySelectorToken,
|
|
10
|
-
|
|
10
|
+
RegularAtomFamilyToken,
|
|
11
11
|
RegularAtomToken,
|
|
12
|
-
|
|
12
|
+
SelectorFamilyToken,
|
|
13
13
|
SelectorToken,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
WritableFamilyToken,
|
|
15
|
+
WritableSelectorFamilyToken,
|
|
16
16
|
WritableSelectorToken,
|
|
17
17
|
WritableToken,
|
|
18
18
|
} from "atom.io"
|
|
19
19
|
import type { Canonical, Json } from "atom.io/json"
|
|
20
20
|
|
|
21
|
+
import type {
|
|
22
|
+
AtomFamily,
|
|
23
|
+
MutableAtomFamily,
|
|
24
|
+
ReadableFamily,
|
|
25
|
+
ReadonlySelectorFamily,
|
|
26
|
+
RegularAtomFamily,
|
|
27
|
+
SelectorFamily,
|
|
28
|
+
WritableFamily,
|
|
29
|
+
WritableSelectorFamily,
|
|
30
|
+
} from ".."
|
|
21
31
|
import { initFamilyMemberInStore } from "../families"
|
|
22
32
|
import type { Transceiver } from "../mutable"
|
|
23
33
|
import type { Store } from "../store"
|
|
@@ -30,47 +40,47 @@ export function growMoleculeInStore<
|
|
|
30
40
|
K extends Canonical,
|
|
31
41
|
>(
|
|
32
42
|
molecule: Molecule<any>,
|
|
33
|
-
family:
|
|
43
|
+
family: MutableAtomFamilyToken<T, J, K>,
|
|
34
44
|
store: Store,
|
|
35
45
|
): MutableAtomToken<T, J>
|
|
36
46
|
export function growMoleculeInStore<T, K extends Canonical>(
|
|
37
47
|
molecule: Molecule<any>,
|
|
38
|
-
family:
|
|
48
|
+
family: RegularAtomFamilyToken<T, K>,
|
|
39
49
|
store: Store,
|
|
40
50
|
): RegularAtomToken<T>
|
|
41
51
|
export function growMoleculeInStore<T, K extends Canonical>(
|
|
42
52
|
molecule: Molecule<any>,
|
|
43
|
-
family:
|
|
53
|
+
family: AtomFamilyToken<T, K>,
|
|
44
54
|
store: Store,
|
|
45
55
|
): AtomToken<T>
|
|
46
56
|
export function growMoleculeInStore<T, K extends Canonical>(
|
|
47
57
|
molecule: Molecule<any>,
|
|
48
|
-
family:
|
|
58
|
+
family: WritableSelectorFamilyToken<T, K>,
|
|
49
59
|
store: Store,
|
|
50
60
|
): WritableSelectorToken<T>
|
|
51
61
|
export function growMoleculeInStore<T, K extends Canonical>(
|
|
52
62
|
molecule: Molecule<any>,
|
|
53
|
-
family:
|
|
63
|
+
family: ReadonlySelectorFamilyToken<T, K>,
|
|
54
64
|
store: Store,
|
|
55
65
|
): ReadonlySelectorToken<T>
|
|
56
66
|
export function growMoleculeInStore<T, K extends Canonical>(
|
|
57
67
|
molecule: Molecule<any>,
|
|
58
|
-
family:
|
|
68
|
+
family: SelectorFamilyToken<T, K>,
|
|
59
69
|
store: Store,
|
|
60
70
|
): SelectorToken<T>
|
|
61
71
|
export function growMoleculeInStore<T, K extends Canonical>(
|
|
62
72
|
molecule: Molecule<any>,
|
|
63
|
-
family:
|
|
73
|
+
family: WritableFamilyToken<T, K>,
|
|
64
74
|
store: Store,
|
|
65
75
|
): WritableToken<T>
|
|
66
76
|
export function growMoleculeInStore<T, K extends Canonical>(
|
|
67
77
|
molecule: Molecule<any>,
|
|
68
|
-
family:
|
|
78
|
+
family: ReadableFamilyToken<T, K>,
|
|
69
79
|
store: Store,
|
|
70
80
|
): ReadableToken<T>
|
|
71
81
|
export function growMoleculeInStore(
|
|
72
82
|
molecule: Molecule<any>,
|
|
73
|
-
family:
|
|
83
|
+
family: ReadableFamilyToken<any, any>,
|
|
74
84
|
store: Store,
|
|
75
85
|
): ReadableToken<any> {
|
|
76
86
|
const stateToken = initFamilyMemberInStore(family, molecule.key, store)
|