atom.io 0.27.4 → 0.28.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 +31 -29
- package/data/dist/index.js +65 -81
- package/data/src/dict.ts +9 -12
- package/data/src/join.ts +30 -33
- package/data/src/struct-family.ts +17 -23
- package/data/src/struct.ts +9 -12
- package/dist/{chunk-JRENM6KL.js → chunk-BX3MTH2Z.js} +482 -385
- package/dist/chunk-D52JNVER.js +721 -0
- package/dist/chunk-EUVKUTW3.js +89 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +35 -53
- package/ephemeral/dist/index.js +1 -1
- package/ephemeral/src/find-state.ts +1 -1
- package/immortal/dist/index.js +2 -2
- package/immortal/src/seek-state.ts +2 -2
- package/internal/dist/index.d.ts +141 -87
- package/internal/dist/index.js +1 -1
- package/internal/src/atom/create-regular-atom.ts +3 -3
- package/internal/src/atom/create-standalone-atom.ts +7 -5
- package/internal/src/atom/dispose-atom.ts +2 -9
- package/internal/src/families/create-atom-family.ts +5 -5
- package/internal/src/families/create-readonly-selector-family.ts +20 -9
- package/internal/src/families/create-regular-atom-family.ts +15 -6
- package/internal/src/families/create-selector-family.ts +5 -5
- package/internal/src/families/create-writable-selector-family.ts +20 -10
- package/internal/src/families/dispose-from-store.ts +43 -29
- package/internal/src/families/find-in-store.ts +28 -18
- package/internal/src/families/init-family-member.ts +9 -9
- package/internal/src/families/seek-in-store.ts +10 -10
- package/internal/src/get-state/get-from-store.ts +70 -47
- package/internal/src/ingest-updates/ingest-atom-update.ts +1 -1
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +15 -6
- package/internal/src/molecule/create-molecule-family.ts +1 -1
- package/internal/src/molecule/dispose-molecule.ts +7 -18
- package/internal/src/molecule/grow-molecule-in-store.ts +1 -1
- package/internal/src/molecule/make-molecule-in-store.ts +5 -5
- package/internal/src/mutable/create-mutable-atom-family.ts +15 -6
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-json-token.ts +2 -2
- package/internal/src/mutable/tracker-family.ts +3 -3
- package/internal/src/mutable/tracker.ts +14 -18
- package/internal/src/pretty-print.ts +1 -16
- package/internal/src/selector/create-readonly-selector.ts +2 -2
- package/internal/src/selector/create-standalone-selector.ts +5 -5
- package/internal/src/selector/create-writable-selector.ts +2 -2
- package/internal/src/selector/dispose-selector.ts +2 -9
- package/internal/src/selector/register-selector.ts +9 -9
- package/internal/src/set-state/set-into-store.ts +23 -33
- package/internal/src/store/circular-buffer.ts +34 -0
- package/internal/src/store/counterfeit.ts +109 -0
- package/internal/src/store/deposit.ts +67 -13
- package/internal/src/store/index.ts +1 -0
- package/internal/src/store/store.ts +4 -1
- package/internal/src/store/withdraw.ts +15 -10
- package/internal/src/subscribe/index.ts +2 -0
- package/internal/src/subscribe/subscribe-in-store.ts +62 -0
- package/internal/src/timeline/time-travel.ts +1 -1
- package/internal/src/transaction/build-transaction.ts +7 -6
- package/introspection/dist/index.d.ts +84 -4
- package/introspection/dist/index.js +1 -413
- package/introspection/src/attach-atom-index.ts +5 -8
- package/introspection/src/attach-introspection-states.ts +7 -4
- package/introspection/src/attach-selector-index.ts +6 -8
- package/introspection/src/attach-timeline-family.ts +25 -28
- package/introspection/src/attach-timeline-index.ts +5 -8
- package/introspection/src/attach-transaction-index.ts +5 -8
- package/introspection/src/attach-transaction-logs.ts +21 -27
- package/introspection/src/attach-type-selectors.ts +26 -0
- package/introspection/src/differ.ts +167 -0
- package/introspection/src/index.ts +2 -0
- package/introspection/src/refinery.ts +100 -0
- package/json/dist/index.d.ts +31 -30
- package/json/dist/index.js +2 -80
- package/json/src/entries.ts +6 -0
- package/json/src/index.ts +47 -6
- package/json/src/select-json-family.ts +4 -4
- package/json/src/select-json.ts +6 -9
- package/package.json +17 -8
- package/react/dist/index.js +7 -7
- package/react/src/parse-state-overloads.ts +2 -2
- package/react/src/use-i.ts +1 -1
- package/react/src/use-json.ts +2 -2
- package/react/src/use-o.ts +2 -2
- package/react-devtools/dist/index.d.ts +1 -91
- package/react-devtools/dist/index.js +285 -414
- package/react-devtools/src/AtomIODevtools.tsx +2 -2
- package/react-devtools/src/StateEditor.tsx +20 -12
- package/react-devtools/src/StateIndex.tsx +8 -26
- package/react-devtools/src/TimelineIndex.tsx +3 -3
- package/react-devtools/src/TransactionIndex.tsx +6 -6
- package/react-devtools/src/Updates.tsx +1 -4
- package/react-devtools/src/index.ts +0 -71
- package/react-devtools/src/store.ts +51 -0
- package/realtime/dist/index.d.ts +7 -7
- package/realtime/dist/index.js +18 -22
- package/realtime/src/realtime-continuity.ts +27 -35
- package/realtime-client/dist/index.js +59 -65
- package/realtime-client/src/pull-atom-family-member.ts +1 -1
- package/realtime-client/src/pull-atom.ts +1 -1
- package/realtime-client/src/pull-mutable-atom-family-member.ts +3 -3
- package/realtime-client/src/pull-mutable-atom.ts +3 -3
- package/realtime-client/src/realtime-client-stores/client-main-store.ts +6 -6
- package/realtime-client/src/sync-continuity.ts +55 -53
- package/realtime-react/dist/index.js +3 -3
- package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
- package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
- package/realtime-server/dist/index.js +72 -36
- package/realtime-server/src/realtime-continuity-synchronizer.ts +57 -93
- package/realtime-server/src/realtime-family-provider.ts +3 -3
- package/realtime-server/src/realtime-mutable-family-provider.ts +5 -5
- package/realtime-server/src/realtime-mutable-provider.ts +2 -2
- package/realtime-server/src/realtime-state-provider.ts +1 -1
- package/realtime-server/src/realtime-state-receiver.ts +1 -1
- package/realtime-testing/dist/index.d.ts +2 -0
- package/realtime-testing/dist/index.js +57 -15
- package/realtime-testing/src/setup-realtime-test.tsx +66 -16
- package/src/atom.ts +2 -2
- package/src/dispose-state.ts +2 -2
- package/src/get-state.ts +9 -13
- package/src/molecule.ts +1 -1
- package/src/selector.ts +2 -2
- package/src/set-state.ts +10 -7
- package/src/silo.ts +29 -55
- package/src/subscribe.ts +3 -23
- package/src/timeline.ts +2 -2
- package/web/dist/index.d.ts +9 -0
- package/{dist/chunk-H6EDLPKH.js → web/dist/index.js} +5 -4
- package/web/package.json +13 -0
- package/web/src/index.ts +1 -0
- package/web/src/persist-sync.ts +25 -0
- package/dist/chunk-AK23DRMD.js +0 -21
- package/dist/chunk-IW6WYRS7.js +0 -140
- package/internal/src/families/throw-in-case-of-conflicting-family.ts +0 -18
package/data/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as AtomIO from 'atom.io';
|
|
2
2
|
import { ReadonlySelectorFamilyToken, MutableAtomFamilyToken, SetterToolkit, disposeState, ReadonlySelectorToken } from 'atom.io';
|
|
3
3
|
import { Store, Molecule } from 'atom.io/internal';
|
|
4
|
-
import { Canonical, stringified, Json } from 'atom.io/json';
|
|
4
|
+
import { Canonical, stringified, Json as Json$1 } from 'atom.io/json';
|
|
5
5
|
import { findState } from 'atom.io/ephemeral';
|
|
6
6
|
import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
|
|
7
7
|
|
|
@@ -10,20 +10,22 @@ declare function dict<State, Key extends Canonical>(family: AtomIO.ReadonlySelec
|
|
|
10
10
|
}>;
|
|
11
11
|
|
|
12
12
|
type primitive = boolean | number | string | null;
|
|
13
|
-
|
|
14
|
-
type Serializable = primitive | Readonly<{
|
|
15
|
-
|
|
16
|
-
}> | ReadonlyArray<Serializable>;
|
|
17
|
-
type Object
|
|
13
|
+
declare namespace Json {
|
|
14
|
+
type Serializable = primitive | Readonly<{
|
|
15
|
+
[key: string]: Serializable;
|
|
16
|
+
}> | ReadonlyArray<Serializable>;
|
|
17
|
+
type Object<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
18
|
+
type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
|
|
19
|
+
}
|
|
18
20
|
|
|
19
21
|
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
20
22
|
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
21
23
|
|
|
22
|
-
interface JunctionEntries<Content extends Object
|
|
24
|
+
interface JunctionEntries<Content extends Json.Object | null> extends Json.Object {
|
|
23
25
|
readonly relations: [string, string[]][];
|
|
24
26
|
readonly contents: [string, Content][];
|
|
25
27
|
}
|
|
26
|
-
interface JunctionSchema<ASide extends string, BSide extends string> extends Object
|
|
28
|
+
interface JunctionSchema<ASide extends string, BSide extends string> extends Json.Object {
|
|
27
29
|
readonly between: [a: ASide, b: BSide];
|
|
28
30
|
readonly cardinality: Cardinality;
|
|
29
31
|
}
|
|
@@ -35,7 +37,7 @@ type BaseExternalStoreConfiguration = {
|
|
|
35
37
|
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
36
38
|
has: (a: string, b?: string) => boolean;
|
|
37
39
|
};
|
|
38
|
-
type ExternalStoreWithContentConfiguration<Content extends Object
|
|
40
|
+
type ExternalStoreWithContentConfiguration<Content extends Json.Object> = {
|
|
39
41
|
getContent: (contentKey: string) => Content | undefined;
|
|
40
42
|
setContent: (contentKey: string, content: Content) => void;
|
|
41
43
|
deleteContent: (contentKey: string) => void;
|
|
@@ -43,14 +45,14 @@ type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
|
|
|
43
45
|
type Empty<Obj extends object> = {
|
|
44
46
|
[Key in keyof Obj]?: undefined;
|
|
45
47
|
};
|
|
46
|
-
type ExternalStoreConfiguration<Content extends Object
|
|
47
|
-
type JunctionAdvancedConfiguration<Content extends Object
|
|
48
|
+
type ExternalStoreConfiguration<Content extends Json.Object | null> = Content extends Json.Object ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Json.Object>>;
|
|
49
|
+
type JunctionAdvancedConfiguration<Content extends Json.Object | null> = {
|
|
48
50
|
externalStore?: ExternalStoreConfiguration<Content>;
|
|
49
51
|
isContent?: Refinement<unknown, Content>;
|
|
50
52
|
makeContentKey?: (a: string, b: string) => string;
|
|
51
53
|
};
|
|
52
|
-
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object
|
|
53
|
-
declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object
|
|
54
|
+
type JunctionJSON<ASide extends string, BSide extends string, Content extends Json.Object | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
55
|
+
declare class Junction<const ASide extends string, const BSide extends string, const Content extends Json.Object | null = null> {
|
|
54
56
|
readonly a: ASide;
|
|
55
57
|
readonly b: BSide;
|
|
56
58
|
readonly cardinality: Cardinality;
|
|
@@ -83,18 +85,18 @@ declare class Junction<const ASide extends string, const BSide extends string, c
|
|
|
83
85
|
has(a: string, b?: string): boolean;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
interface JoinOptions<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> extends Json.Object, JunctionSchema<ASide, BSide>, Partial<JunctionEntries<Content>> {
|
|
88
|
+
interface JoinOptions<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json$1.Object | null> extends Json$1.Object, JunctionSchema<ASide, BSide>, Partial<JunctionEntries<Content>> {
|
|
87
89
|
readonly key: string;
|
|
88
90
|
readonly cardinality: Cardinality;
|
|
89
91
|
}
|
|
90
|
-
type JoinStateFamilies<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
|
|
92
|
+
type JoinStateFamilies<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json$1.Object | null> = Cardinality extends `1:1` ? (Content extends Json$1.Object ? {
|
|
91
93
|
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntryOf${Capitalize<BSide>}` : `${AB}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
92
94
|
string,
|
|
93
95
|
Content
|
|
94
96
|
] | null, string>;
|
|
95
97
|
} : {}) & {
|
|
96
98
|
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeyOf${Capitalize<BSide>}` : `${AB}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<string | null, string>;
|
|
97
|
-
} : Cardinality extends `1:n` ? (Content extends Json.Object ? {
|
|
99
|
+
} : Cardinality extends `1:n` ? (Content extends Json$1.Object ? {
|
|
98
100
|
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
99
101
|
string,
|
|
100
102
|
Content
|
|
@@ -108,7 +110,7 @@ type JoinStateFamilies<ASide extends string, BSide extends string, Cardinality e
|
|
|
108
110
|
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<string | null, string>;
|
|
109
111
|
} & {
|
|
110
112
|
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<string[], string>;
|
|
111
|
-
} : Cardinality extends `n:n` ? (Content extends Json.Object ? {
|
|
113
|
+
} : Cardinality extends `n:n` ? (Content extends Json$1.Object ? {
|
|
112
114
|
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntriesOf${Capitalize<BSide>}` : `${AB}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
113
115
|
string,
|
|
114
116
|
Content
|
|
@@ -116,7 +118,7 @@ type JoinStateFamilies<ASide extends string, BSide extends string, Cardinality e
|
|
|
116
118
|
} : {}) & {
|
|
117
119
|
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeysOf${Capitalize<BSide>}` : `${AB}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<string[], string>;
|
|
118
120
|
} : never;
|
|
119
|
-
declare class Join<const ASide extends string, const BSide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object | null = null> {
|
|
121
|
+
declare class Join<const ASide extends string, const BSide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json$1.Object | null = null> {
|
|
120
122
|
private options;
|
|
121
123
|
private defaultContent;
|
|
122
124
|
private toolkit;
|
|
@@ -136,7 +138,7 @@ declare class Join<const ASide extends string, const BSide extends string, const
|
|
|
136
138
|
in(store: Store): Join<ASide, BSide, Cardinality, Content>;
|
|
137
139
|
constructor(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content | undefined, store?: Store);
|
|
138
140
|
}
|
|
139
|
-
type JoinToken<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null = null> = {
|
|
141
|
+
type JoinToken<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json$1.Object | null = null> = {
|
|
140
142
|
key: string;
|
|
141
143
|
type: `join`;
|
|
142
144
|
cardinality: Cardinality;
|
|
@@ -145,19 +147,19 @@ type JoinToken<ASide extends string, BSide extends string, Cardinality extends `
|
|
|
145
147
|
__content?: Content;
|
|
146
148
|
};
|
|
147
149
|
declare function join<const ASide extends string, const BSide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`>(options: JoinOptions<ASide, BSide, Cardinality, null>, defaultContent?: undefined, store?: Store): JoinToken<ASide, BSide, Cardinality, null>;
|
|
148
|
-
declare function join<const ASide extends string, const BSide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object>(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content, store?: Store): JoinToken<ASide, BSide, Cardinality, Content>;
|
|
150
|
+
declare function join<const ASide extends string, const BSide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json$1.Object>(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content, store?: Store): JoinToken<ASide, BSide, Cardinality, Content>;
|
|
149
151
|
declare function getJoinMap(store: Store & {
|
|
150
152
|
joins?: Map<string, Join<any, any, any, any>>;
|
|
151
153
|
}): Map<string, Join<any, any, any, any>>;
|
|
152
|
-
declare function getJoin<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, store: Store): Join<ASide, BSide, Cardinality, Content>;
|
|
153
|
-
type JoinStates<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
|
|
154
|
+
declare function getJoin<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json$1.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, store: Store): Join<ASide, BSide, Cardinality, Content>;
|
|
155
|
+
type JoinStates<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json$1.Object | null> = Cardinality extends `1:1` ? (Content extends Json$1.Object ? {
|
|
154
156
|
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntryOf${Capitalize<BSide>}` : `${AB}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorToken<[
|
|
155
157
|
string,
|
|
156
158
|
Content
|
|
157
159
|
] | null>;
|
|
158
160
|
} : {}) & {
|
|
159
161
|
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeyOf${Capitalize<BSide>}` : `${AB}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorToken<string | null>;
|
|
160
|
-
} : Cardinality extends `1:n` ? (Content extends Json.Object ? {
|
|
162
|
+
} : Cardinality extends `1:n` ? (Content extends Json$1.Object ? {
|
|
161
163
|
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorToken<[
|
|
162
164
|
string,
|
|
163
165
|
Content
|
|
@@ -171,7 +173,7 @@ type JoinStates<ASide extends string, BSide extends string, Cardinality extends
|
|
|
171
173
|
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorToken<string | null>;
|
|
172
174
|
} & {
|
|
173
175
|
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorToken<string[]>;
|
|
174
|
-
} : Cardinality extends `n:n` ? (Content extends Json.Object ? {
|
|
176
|
+
} : Cardinality extends `n:n` ? (Content extends Json$1.Object ? {
|
|
175
177
|
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntriesOf${Capitalize<BSide>}` : `${AB}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorToken<[
|
|
176
178
|
string,
|
|
177
179
|
Content
|
|
@@ -179,12 +181,12 @@ type JoinStates<ASide extends string, BSide extends string, Cardinality extends
|
|
|
179
181
|
} : {}) & {
|
|
180
182
|
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeysOf${Capitalize<BSide>}` : `${AB}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorToken<string[]>;
|
|
181
183
|
} : never;
|
|
182
|
-
declare function findRelationsInStore<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, key: string, store: Store): JoinStates<ASide, BSide, Cardinality, Content>;
|
|
183
|
-
declare function findRelations<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, key: string): JoinStates<ASide, BSide, Cardinality, Content>;
|
|
184
|
-
declare function editRelationsInStore<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, change: (relations: Junction<ASide, BSide, Content>) => void, store: Store): void;
|
|
185
|
-
declare function editRelations<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, change: (relations: Junction<ASide, BSide, Content>) => void): void;
|
|
184
|
+
declare function findRelationsInStore<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json$1.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, key: string, store: Store): JoinStates<ASide, BSide, Cardinality, Content>;
|
|
185
|
+
declare function findRelations<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json$1.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, key: string): JoinStates<ASide, BSide, Cardinality, Content>;
|
|
186
|
+
declare function editRelationsInStore<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json$1.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, change: (relations: Junction<ASide, BSide, Content>) => void, store: Store): void;
|
|
187
|
+
declare function editRelations<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json$1.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>, change: (relations: Junction<ASide, BSide, Content>) => void): void;
|
|
186
188
|
declare function getInternalRelationsFromStore(token: JoinToken<any, any, any, any>, store: Store): MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
187
|
-
declare function getInternalRelations<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>): MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
189
|
+
declare function getInternalRelations<ASide extends string, BSide extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json$1.Object | null>(token: JoinToken<ASide, BSide, Cardinality, Content>): MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
188
190
|
|
|
189
191
|
declare function struct<Struct extends {
|
|
190
192
|
[key: string]: unknown;
|
package/data/dist/index.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { Junction } from '../../dist/chunk-IBTHB2PI.js';
|
|
2
2
|
import '../../dist/chunk-XWL6SNVU.js';
|
|
3
|
-
import { createStandaloneSelector, findInStore, IMPLICIT,
|
|
3
|
+
import { createStandaloneSelector, findInStore, IMPLICIT, withdraw, growMoleculeInStore, NotFoundError, initFamilyMemberInStore, getFromStore, setIntoStore, seekInStore, getJsonToken, disposeFromStore, createMutableAtomFamily, createRegularAtomFamily, createMoleculeFamily, newest, makeMoleculeInStore, isChildStore, createRegularAtom, createSelectorFamily, createReadonlySelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
4
4
|
import { stringifyJson } from 'atom.io/json';
|
|
5
5
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
6
6
|
|
|
7
7
|
function dict(family, index, store = IMPLICIT.STORE) {
|
|
8
|
-
return createStandaloneSelector(
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
store
|
|
20
|
-
);
|
|
8
|
+
return createStandaloneSelector(store, {
|
|
9
|
+
key: `${family.key}Dict`,
|
|
10
|
+
get: ({ get }) => {
|
|
11
|
+
const keys = get(index);
|
|
12
|
+
return keys.reduce((acc, key) => {
|
|
13
|
+
acc[key] = get(findInStore(store, family, key));
|
|
14
|
+
return acc;
|
|
15
|
+
}, {});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
21
18
|
}
|
|
22
19
|
function capitalize(string) {
|
|
23
20
|
return string[0].toUpperCase() + string.slice(1);
|
|
@@ -60,18 +57,6 @@ var Join = class _Join {
|
|
|
60
57
|
this.alternates = /* @__PURE__ */ new Map();
|
|
61
58
|
this.alternates.set(store.config.name, this);
|
|
62
59
|
this.store.miscResources.set(`join:${options.key}`, this);
|
|
63
|
-
this.toolkit = {
|
|
64
|
-
get: (...ps) => getFromStore(...ps, store),
|
|
65
|
-
set: (...ps) => {
|
|
66
|
-
setIntoStore(...ps, store);
|
|
67
|
-
},
|
|
68
|
-
find: (token, key) => findInStore(token, key, store),
|
|
69
|
-
seek: (token, key) => seekInStore(token, key, store),
|
|
70
|
-
json: (token) => getJsonToken(token, store),
|
|
71
|
-
dispose: (...ps) => {
|
|
72
|
-
disposeFromStore(...ps, store);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
60
|
this.retrieve = (token, key) => {
|
|
76
61
|
const maybeToken = this.toolkit.seek(token, key);
|
|
77
62
|
if (maybeToken) {
|
|
@@ -85,11 +70,24 @@ var Join = class _Join {
|
|
|
85
70
|
if (store.config.lifespan === `immortal`) {
|
|
86
71
|
throw new NotFoundError(token, key, store);
|
|
87
72
|
}
|
|
88
|
-
return initFamilyMemberInStore(token, key
|
|
73
|
+
return initFamilyMemberInStore(store, token, key);
|
|
74
|
+
};
|
|
75
|
+
this.toolkit = {
|
|
76
|
+
get: (...ps) => getFromStore(store, ...ps),
|
|
77
|
+
set: (...ps) => {
|
|
78
|
+
setIntoStore(store, ...ps);
|
|
79
|
+
},
|
|
80
|
+
find: this.retrieve,
|
|
81
|
+
seek: (...ps) => seekInStore(store, ...ps),
|
|
82
|
+
json: (token) => getJsonToken(store, token),
|
|
83
|
+
dispose: (...ps) => {
|
|
84
|
+
disposeFromStore(store, ...ps);
|
|
85
|
+
}
|
|
89
86
|
};
|
|
90
87
|
const aSide = options.between[0];
|
|
91
88
|
const bSide = options.between[1];
|
|
92
89
|
const relatedKeysAtoms = createMutableAtomFamily(
|
|
90
|
+
store,
|
|
93
91
|
{
|
|
94
92
|
key: `${options.key}/relatedKeys`,
|
|
95
93
|
default: () => new SetRTX(),
|
|
@@ -97,7 +95,6 @@ var Join = class _Join {
|
|
|
97
95
|
fromJson: (json) => SetRTX.fromJSON(json),
|
|
98
96
|
toJson: (set) => set.toJSON()
|
|
99
97
|
},
|
|
100
|
-
store,
|
|
101
98
|
[`join`, `relations`]
|
|
102
99
|
);
|
|
103
100
|
this.core = { findRelatedKeysState: relatedKeysAtoms };
|
|
@@ -228,32 +225,28 @@ var Join = class _Join {
|
|
|
228
225
|
let contentMolecules;
|
|
229
226
|
if (defaultContent) {
|
|
230
227
|
contentAtoms = createRegularAtomFamily(
|
|
228
|
+
store,
|
|
231
229
|
{
|
|
232
230
|
key: `${options.key}/content`,
|
|
233
231
|
default: defaultContent
|
|
234
232
|
},
|
|
235
|
-
store,
|
|
236
233
|
[`join`, `content`]
|
|
237
234
|
);
|
|
238
|
-
|
|
235
|
+
({
|
|
239
236
|
key: options.key,
|
|
240
237
|
type: `join`,
|
|
241
238
|
a: options.between[0],
|
|
242
239
|
b: options.between[1],
|
|
243
240
|
cardinality: options.cardinality
|
|
244
|
-
};
|
|
245
|
-
contentMolecules = createMoleculeFamily(
|
|
246
|
-
{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
this.key = key;
|
|
251
|
-
toolkit.bond(joinToken, { as: null });
|
|
252
|
-
}
|
|
241
|
+
});
|
|
242
|
+
contentMolecules = createMoleculeFamily(store, {
|
|
243
|
+
key: `${options.key}/content-molecules`,
|
|
244
|
+
new: class ContentMolecule {
|
|
245
|
+
constructor(_, key) {
|
|
246
|
+
this.key = key;
|
|
253
247
|
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
257
250
|
const getContent = ({ get }, key) => get(this.retrieve(contentAtoms, key));
|
|
258
251
|
const setContent = ({ set }, key, content) => {
|
|
259
252
|
set(this.retrieve(contentAtoms, key), content);
|
|
@@ -309,6 +302,7 @@ var Join = class _Join {
|
|
|
309
302
|
}
|
|
310
303
|
});
|
|
311
304
|
const createSingleKeyStateFamily = () => createReadonlySelectorFamily(
|
|
305
|
+
store,
|
|
312
306
|
{
|
|
313
307
|
key: `${options.key}/singleRelatedKey`,
|
|
314
308
|
get: (key) => ({ get }) => {
|
|
@@ -320,11 +314,11 @@ var Join = class _Join {
|
|
|
320
314
|
return null;
|
|
321
315
|
}
|
|
322
316
|
},
|
|
323
|
-
store,
|
|
324
317
|
[`join`, `keys`]
|
|
325
318
|
);
|
|
326
319
|
const getMultipleKeyStateFamily = () => {
|
|
327
320
|
return createReadonlySelectorFamily(
|
|
321
|
+
store,
|
|
328
322
|
{
|
|
329
323
|
key: `${options.key}/multipleRelatedKeys`,
|
|
330
324
|
get: (key) => ({ get }) => {
|
|
@@ -334,11 +328,11 @@ var Join = class _Join {
|
|
|
334
328
|
return json.members;
|
|
335
329
|
}
|
|
336
330
|
},
|
|
337
|
-
store,
|
|
338
331
|
[`join`, `keys`]
|
|
339
332
|
);
|
|
340
333
|
};
|
|
341
334
|
const createSingleEntryStateFamily = () => createReadonlySelectorFamily(
|
|
335
|
+
store,
|
|
342
336
|
{
|
|
343
337
|
key: `${options.key}/singleRelatedEntry`,
|
|
344
338
|
get: (key) => ({ get }) => {
|
|
@@ -353,10 +347,10 @@ var Join = class _Join {
|
|
|
353
347
|
return null;
|
|
354
348
|
}
|
|
355
349
|
},
|
|
356
|
-
store,
|
|
357
350
|
[`join`, `entries`]
|
|
358
351
|
);
|
|
359
352
|
const getMultipleEntryStateFamily = () => createReadonlySelectorFamily(
|
|
353
|
+
store,
|
|
360
354
|
{
|
|
361
355
|
key: `${options.key}/multipleRelatedEntries`,
|
|
362
356
|
get: (key) => ({ get }) => {
|
|
@@ -371,7 +365,6 @@ var Join = class _Join {
|
|
|
371
365
|
});
|
|
372
366
|
}
|
|
373
367
|
},
|
|
374
|
-
store,
|
|
375
368
|
[`join`, `entries`]
|
|
376
369
|
);
|
|
377
370
|
switch (options.cardinality) {
|
|
@@ -631,27 +624,24 @@ function struct(options, store = IMPLICIT.STORE) {
|
|
|
631
624
|
const atoms = Object.keys(options.default).reduce((acc, key) => {
|
|
632
625
|
const atomName = options.key + capitalize2(key) + `State`;
|
|
633
626
|
acc[atomName] = createRegularAtom(
|
|
627
|
+
store,
|
|
634
628
|
{
|
|
635
629
|
key: `${options.key}.${key}`,
|
|
636
630
|
default: options.default[key]
|
|
637
631
|
},
|
|
638
|
-
void 0
|
|
639
|
-
store
|
|
632
|
+
void 0
|
|
640
633
|
);
|
|
641
634
|
return acc;
|
|
642
635
|
}, {});
|
|
643
|
-
const structState = createStandaloneSelector(
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
},
|
|
653
|
-
store
|
|
654
|
-
);
|
|
636
|
+
const structState = createStandaloneSelector(store, {
|
|
637
|
+
key: options.key,
|
|
638
|
+
get: ({ get }) => {
|
|
639
|
+
return Object.keys(options.default).reduce((acc, key) => {
|
|
640
|
+
acc[key] = get(atoms[options.key + capitalize2(key) + `State`]);
|
|
641
|
+
return acc;
|
|
642
|
+
}, {});
|
|
643
|
+
}
|
|
644
|
+
});
|
|
655
645
|
return [atoms, structState];
|
|
656
646
|
}
|
|
657
647
|
var capitalize3 = (str) => str[0].toUpperCase() + str.slice(1);
|
|
@@ -659,29 +649,23 @@ var nameFamily = (topKey, subKey) => `find` + capitalize3(topKey) + capitalize3(
|
|
|
659
649
|
function structFamily(options) {
|
|
660
650
|
const atoms = Object.keys(options.default).reduce((acc, subKey) => {
|
|
661
651
|
const atomFamilyName = nameFamily(options.key, subKey);
|
|
662
|
-
acc[atomFamilyName] = createRegularAtomFamily(
|
|
663
|
-
{
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
},
|
|
667
|
-
IMPLICIT.STORE
|
|
668
|
-
);
|
|
652
|
+
acc[atomFamilyName] = createRegularAtomFamily(IMPLICIT.STORE, {
|
|
653
|
+
key: `${options.key}.${subKey}`,
|
|
654
|
+
default: options.default[subKey]
|
|
655
|
+
});
|
|
669
656
|
return acc;
|
|
670
657
|
}, {});
|
|
671
|
-
const findStructState = createSelectorFamily(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
},
|
|
683
|
-
IMPLICIT.STORE
|
|
684
|
-
);
|
|
658
|
+
const findStructState = createSelectorFamily(IMPLICIT.STORE, {
|
|
659
|
+
key: options.key,
|
|
660
|
+
get: (id) => ({ find, get }) => {
|
|
661
|
+
return Object.keys(options.default).reduce((acc, subKey) => {
|
|
662
|
+
acc[subKey] = get(
|
|
663
|
+
find(atoms[nameFamily(options.key, subKey)], id)
|
|
664
|
+
);
|
|
665
|
+
return acc;
|
|
666
|
+
}, {});
|
|
667
|
+
}
|
|
668
|
+
});
|
|
685
669
|
return [atoms, findStructState];
|
|
686
670
|
}
|
|
687
671
|
|
package/data/src/dict.ts
CHANGED
|
@@ -18,17 +18,14 @@ export function dict<State, Key extends Canonical>(
|
|
|
18
18
|
| AtomIO.WritableSelectorToken<Key[]>,
|
|
19
19
|
store: Store = IMPLICIT.STORE,
|
|
20
20
|
): AtomIO.ReadonlySelectorToken<{ [K in stringified<Key>]: State }> {
|
|
21
|
-
return createStandaloneSelector(
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, {} as any)
|
|
30
|
-
},
|
|
21
|
+
return createStandaloneSelector(store, {
|
|
22
|
+
key: `${family.key}Dict`,
|
|
23
|
+
get: ({ get }) => {
|
|
24
|
+
const keys = get(index)
|
|
25
|
+
return keys.reduce((acc, key) => {
|
|
26
|
+
acc[key] = get(findInStore(store, family, key))
|
|
27
|
+
return acc
|
|
28
|
+
}, {} as any)
|
|
31
29
|
},
|
|
32
|
-
|
|
33
|
-
)
|
|
30
|
+
})
|
|
34
31
|
}
|
package/data/src/join.ts
CHANGED
|
@@ -195,19 +195,6 @@ export class Join<
|
|
|
195
195
|
|
|
196
196
|
this.store.miscResources.set(`join:${options.key}`, this)
|
|
197
197
|
|
|
198
|
-
this.toolkit = {
|
|
199
|
-
get: ((...ps: Parameters<typeof getState>) =>
|
|
200
|
-
getFromStore(...ps, store)) as typeof getState,
|
|
201
|
-
set: ((...ps: Parameters<typeof setState>) => {
|
|
202
|
-
setIntoStore(...ps, store)
|
|
203
|
-
}) as typeof setState,
|
|
204
|
-
find: ((token, key) => findInStore(token, key, store)) as typeof findState,
|
|
205
|
-
seek: ((token, key) => seekInStore(token, key, store)) as typeof seekState,
|
|
206
|
-
json: (token) => getJsonToken(token, store),
|
|
207
|
-
dispose: ((...ps: Parameters<typeof disposeState>) => {
|
|
208
|
-
disposeFromStore(...ps, store)
|
|
209
|
-
}) as typeof disposeState,
|
|
210
|
-
}
|
|
211
198
|
this.retrieve = ((
|
|
212
199
|
token: ReadableFamilyToken<any, any>,
|
|
213
200
|
key: Json.Serializable,
|
|
@@ -224,8 +211,23 @@ export class Join<
|
|
|
224
211
|
if (store.config.lifespan === `immortal`) {
|
|
225
212
|
throw new NotFoundError(token, key, store)
|
|
226
213
|
}
|
|
227
|
-
return initFamilyMemberInStore(token, key
|
|
214
|
+
return initFamilyMemberInStore(store, token, key)
|
|
228
215
|
}) as typeof findState
|
|
216
|
+
this.toolkit = {
|
|
217
|
+
get: ((...ps: Parameters<typeof getState>) =>
|
|
218
|
+
getFromStore(store, ...ps)) as typeof getState,
|
|
219
|
+
set: ((...ps: Parameters<typeof setState>) => {
|
|
220
|
+
setIntoStore(store, ...ps)
|
|
221
|
+
}) as typeof setState,
|
|
222
|
+
find: this.retrieve,
|
|
223
|
+
seek: ((...ps: Parameters<typeof seekState>) =>
|
|
224
|
+
seekInStore(store, ...ps)) as typeof seekState,
|
|
225
|
+
json: (token) => getJsonToken(store, token),
|
|
226
|
+
dispose: ((...ps: Parameters<typeof disposeState>) => {
|
|
227
|
+
disposeFromStore(store, ...ps)
|
|
228
|
+
}) as typeof disposeState,
|
|
229
|
+
}
|
|
230
|
+
|
|
229
231
|
const aSide: ASide = options.between[0]
|
|
230
232
|
const bSide: BSide = options.between[1]
|
|
231
233
|
const relatedKeysAtoms = createMutableAtomFamily<
|
|
@@ -233,6 +235,7 @@ export class Join<
|
|
|
233
235
|
SetRTXJson<string>,
|
|
234
236
|
string
|
|
235
237
|
>(
|
|
238
|
+
store,
|
|
236
239
|
{
|
|
237
240
|
key: `${options.key}/relatedKeys`,
|
|
238
241
|
default: () => new SetRTX(),
|
|
@@ -240,7 +243,6 @@ export class Join<
|
|
|
240
243
|
fromJson: (json) => SetRTX.fromJSON(json),
|
|
241
244
|
toJson: (set) => set.toJSON(),
|
|
242
245
|
},
|
|
243
|
-
store,
|
|
244
246
|
[`join`, `relations`],
|
|
245
247
|
)
|
|
246
248
|
this.core = { findRelatedKeysState: relatedKeysAtoms }
|
|
@@ -396,11 +398,11 @@ export class Join<
|
|
|
396
398
|
>
|
|
397
399
|
if (defaultContent) {
|
|
398
400
|
contentAtoms = createRegularAtomFamily<Content, string>(
|
|
401
|
+
store,
|
|
399
402
|
{
|
|
400
403
|
key: `${options.key}/content`,
|
|
401
404
|
default: defaultContent,
|
|
402
405
|
},
|
|
403
|
-
store,
|
|
404
406
|
[`join`, `content`],
|
|
405
407
|
)
|
|
406
408
|
const joinToken = {
|
|
@@ -410,20 +412,15 @@ export class Join<
|
|
|
410
412
|
b: options.between[1],
|
|
411
413
|
cardinality: options.cardinality,
|
|
412
414
|
} as const satisfies JoinToken<ASide, BSide, Cardinality, Content>
|
|
413
|
-
contentMolecules = createMoleculeFamily(
|
|
414
|
-
{
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
) {
|
|
421
|
-
toolkit.bond(joinToken, { as: null } as any)
|
|
422
|
-
}
|
|
423
|
-
},
|
|
415
|
+
contentMolecules = createMoleculeFamily(store, {
|
|
416
|
+
key: `${options.key}/content-molecules`,
|
|
417
|
+
new: class ContentMolecule {
|
|
418
|
+
public constructor(
|
|
419
|
+
_: CtorToolkit<string>,
|
|
420
|
+
public key: string,
|
|
421
|
+
) {}
|
|
424
422
|
},
|
|
425
|
-
|
|
426
|
-
)
|
|
423
|
+
})
|
|
427
424
|
const getContent: Read<(key: string) => Content | null> = ({ get }, key) =>
|
|
428
425
|
get(this.retrieve(contentAtoms, key))
|
|
429
426
|
const setContent: Write<(key: string, content: Content) => void> = (
|
|
@@ -490,6 +487,7 @@ export class Join<
|
|
|
490
487
|
|
|
491
488
|
const createSingleKeyStateFamily = () =>
|
|
492
489
|
createReadonlySelectorFamily<string | null, string>(
|
|
490
|
+
store,
|
|
493
491
|
{
|
|
494
492
|
key: `${options.key}/singleRelatedKey`,
|
|
495
493
|
get:
|
|
@@ -503,11 +501,11 @@ export class Join<
|
|
|
503
501
|
return null
|
|
504
502
|
},
|
|
505
503
|
},
|
|
506
|
-
store,
|
|
507
504
|
[`join`, `keys`],
|
|
508
505
|
)
|
|
509
506
|
const getMultipleKeyStateFamily = () => {
|
|
510
507
|
return createReadonlySelectorFamily<string[], string>(
|
|
508
|
+
store,
|
|
511
509
|
{
|
|
512
510
|
key: `${options.key}/multipleRelatedKeys`,
|
|
513
511
|
get:
|
|
@@ -519,12 +517,12 @@ export class Join<
|
|
|
519
517
|
return json.members
|
|
520
518
|
},
|
|
521
519
|
},
|
|
522
|
-
store,
|
|
523
520
|
[`join`, `keys`],
|
|
524
521
|
)
|
|
525
522
|
}
|
|
526
523
|
const createSingleEntryStateFamily = () =>
|
|
527
524
|
createReadonlySelectorFamily<[string, Content] | null, string>(
|
|
525
|
+
store,
|
|
528
526
|
{
|
|
529
527
|
key: `${options.key}/singleRelatedEntry`,
|
|
530
528
|
get:
|
|
@@ -541,11 +539,11 @@ export class Join<
|
|
|
541
539
|
return null
|
|
542
540
|
},
|
|
543
541
|
},
|
|
544
|
-
store,
|
|
545
542
|
[`join`, `entries`],
|
|
546
543
|
)
|
|
547
544
|
const getMultipleEntryStateFamily = () =>
|
|
548
545
|
createReadonlySelectorFamily<[string, Content][], string>(
|
|
546
|
+
store,
|
|
549
547
|
{
|
|
550
548
|
key: `${options.key}/multipleRelatedEntries`,
|
|
551
549
|
get:
|
|
@@ -562,7 +560,6 @@ export class Join<
|
|
|
562
560
|
})
|
|
563
561
|
},
|
|
564
562
|
},
|
|
565
|
-
store,
|
|
566
563
|
[`join`, `entries`],
|
|
567
564
|
)
|
|
568
565
|
|
|
@@ -29,31 +29,25 @@ export function structFamily<
|
|
|
29
29
|
>}State`]: AtomIO.RegularAtomFamilyToken<Struct[K], string>
|
|
30
30
|
} = Object.keys(options.default).reduce((acc, subKey) => {
|
|
31
31
|
const atomFamilyName = nameFamily(options.key, subKey)
|
|
32
|
-
acc[atomFamilyName] = createRegularAtomFamily(
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
IMPLICIT.STORE,
|
|
38
|
-
)
|
|
32
|
+
acc[atomFamilyName] = createRegularAtomFamily(IMPLICIT.STORE, {
|
|
33
|
+
key: `${options.key}.${subKey}`,
|
|
34
|
+
default: (options.default as any)[subKey],
|
|
35
|
+
})
|
|
39
36
|
return acc
|
|
40
37
|
}, {} as any)
|
|
41
38
|
const findStructState: AtomIO.ReadonlySelectorFamilyToken<Struct, string> =
|
|
42
|
-
createSelectorFamily(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
IMPLICIT.STORE,
|
|
57
|
-
)
|
|
39
|
+
createSelectorFamily(IMPLICIT.STORE, {
|
|
40
|
+
key: options.key,
|
|
41
|
+
get:
|
|
42
|
+
(id) =>
|
|
43
|
+
({ find, get }) => {
|
|
44
|
+
return Object.keys(options.default).reduce((acc, subKey) => {
|
|
45
|
+
acc[subKey] = get(
|
|
46
|
+
find((atoms as any)[nameFamily(options.key, subKey)], id),
|
|
47
|
+
)
|
|
48
|
+
return acc
|
|
49
|
+
}, {} as any)
|
|
50
|
+
},
|
|
51
|
+
})
|
|
58
52
|
return [atoms, findStructState]
|
|
59
53
|
}
|