atom.io 0.21.1 → 0.23.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.cjs +152 -63
- package/data/dist/index.d.ts +6 -0
- package/data/dist/index.js +3 -3
- package/data/src/join.ts +164 -51
- package/data/src/struct-family.ts +2 -2
- package/dist/chunk-6MLFYN32.js +18 -0
- package/dist/{chunk-HITX3MO4.js → chunk-7DT3PVS3.js} +151 -62
- package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
- package/dist/chunk-OAYGID5B.js +27 -0
- package/dist/index.cjs +4 -18
- package/dist/index.d.ts +71 -28
- package/dist/index.js +6 -19
- package/ephemeral/dist/index.cjs +11 -0
- package/ephemeral/dist/index.js +9 -0
- package/ephemeral/package.json +16 -0
- package/ephemeral/src/index.ts +1 -0
- package/eslint-plugin/dist/index.cjs +155 -1
- package/eslint-plugin/dist/index.js +155 -1
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/lifespan.ts +203 -0
- package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +1 -65
- package/eslint-plugin/src/walk.ts +73 -0
- package/immortal/dist/index.cjs +260 -0
- package/immortal/dist/index.js +212 -0
- package/immortal/package.json +16 -0
- package/immortal/src/index.ts +3 -0
- package/immortal/src/make-molecule.ts +222 -0
- package/immortal/src/molecule.ts +167 -0
- package/immortal/src/seek-state.ts +73 -0
- package/internal/dist/index.cjs +1242 -837
- package/internal/dist/index.d.ts +135 -22
- package/internal/dist/index.js +1215 -838
- package/internal/src/atom/create-regular-atom.ts +0 -2
- package/internal/src/atom/create-standalone-atom.ts +6 -2
- package/internal/src/atom/dispose-atom.ts +26 -3
- package/internal/src/families/create-readonly-selector-family.ts +15 -10
- package/internal/src/families/create-regular-atom-family.ts +20 -21
- package/internal/src/families/create-writable-selector-family.ts +13 -9
- package/{src/dispose.ts → internal/src/families/dispose-from-store.ts} +7 -4
- package/internal/src/families/find-in-store.ts +11 -6
- package/internal/src/families/index.ts +3 -0
- package/internal/src/families/init-family-member.ts +112 -0
- package/internal/src/families/seek-in-store.ts +123 -0
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/ingest-updates/index.ts +1 -0
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +104 -0
- package/internal/src/ingest-updates/ingest-transaction-update.ts +26 -4
- package/internal/src/mutable/create-mutable-atom-family.ts +22 -24
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-json-family.ts +2 -2
- package/internal/src/mutable/get-json-token.ts +26 -12
- package/internal/src/mutable/tracker-family.ts +21 -19
- package/internal/src/not-found-error.ts +16 -3
- package/internal/src/selector/create-readonly-selector.ts +2 -3
- package/internal/src/selector/create-standalone-selector.ts +6 -2
- package/internal/src/selector/create-writable-selector.ts +2 -3
- package/internal/src/selector/dispose-selector.ts +68 -24
- package/internal/src/selector/register-selector.ts +10 -5
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/set-state/stow-update.ts +5 -1
- package/internal/src/store/deposit.ts +41 -7
- package/internal/src/store/index.ts +0 -1
- package/internal/src/store/store.ts +29 -5
- package/internal/src/store/withdraw.ts +28 -1
- package/internal/src/subscribe/subscribe-to-state.ts +2 -2
- package/internal/src/timeline/add-atom-to-timeline.ts +206 -182
- package/internal/src/timeline/create-timeline.ts +181 -60
- package/internal/src/timeline/time-travel.ts +20 -0
- package/internal/src/transaction/apply-transaction.ts +2 -12
- package/internal/src/transaction/build-transaction.ts +16 -2
- package/introspection/dist/index.cjs +40 -53
- package/introspection/dist/index.js +40 -53
- package/introspection/src/attach-atom-index.ts +38 -48
- package/introspection/src/attach-selector-index.ts +45 -50
- package/introspection/src/attach-timeline-family.ts +1 -0
- package/json/dist/index.cjs +40 -6
- package/json/dist/index.js +44 -9
- package/json/src/select-json-family.ts +47 -9
- package/package.json +30 -10
- package/react/dist/index.cjs +1 -1
- package/react/dist/index.js +1 -1
- package/react/src/use-json.ts +1 -1
- package/react-devtools/dist/index.cjs +69 -57
- package/react-devtools/dist/index.js +62 -49
- package/react-devtools/src/StateIndex.tsx +2 -1
- package/react-devtools/src/TimelineIndex.tsx +17 -14
- package/react-devtools/src/TransactionIndex.tsx +7 -7
- package/react-devtools/src/Updates.tsx +41 -32
- package/realtime-client/dist/index.cjs +3 -3
- package/realtime-client/dist/index.js +3 -3
- package/realtime-client/src/pull-mutable-atom-family-member.ts +1 -1
- package/realtime-client/src/pull-mutable-atom.ts +1 -1
- package/realtime-client/src/sync-continuity.ts +1 -2
- package/realtime-react/dist/index.cjs +1 -1
- package/realtime-react/dist/index.js +1 -1
- package/realtime-server/dist/index.cjs +39 -27
- package/realtime-server/dist/index.d.ts +1 -1
- package/realtime-server/dist/index.js +27 -16
- package/realtime-server/src/realtime-continuity-synchronizer.ts +5 -3
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -1
- package/realtime-server/src/realtime-mutable-provider.ts +1 -1
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +21 -11
- package/realtime-testing/dist/index.cjs +7 -2
- package/realtime-testing/dist/index.js +8 -5
- package/realtime-testing/src/setup-realtime-test.tsx +5 -2
- package/src/atom.ts +19 -7
- package/src/dispose-state.ts +10 -0
- package/src/index.ts +5 -2
- package/src/selector.ts +13 -7
- package/src/silo.ts +3 -3
- package/src/subscribe.ts +8 -4
- package/src/timeline.ts +18 -1
- package/src/transaction.ts +59 -4
- package/dist/chunk-BF4MVQF6.js +0 -44
- package/internal/src/store/withdraw-new-family-member.ts +0 -69
- /package/{src → ephemeral/src}/find-state.ts +0 -0
package/src/timeline.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { MoleculeFamilyToken } from "atom.io/immortal"
|
|
1
2
|
import type {
|
|
2
3
|
Timeline,
|
|
3
4
|
TimelineAtomUpdate,
|
|
5
|
+
TimelineMoleculeCreation,
|
|
6
|
+
TimelineMoleculeDisposal,
|
|
4
7
|
TimelineSelectorUpdate,
|
|
8
|
+
TimelineStateCreation,
|
|
9
|
+
TimelineStateDisposal,
|
|
5
10
|
TimelineTransactionUpdate,
|
|
6
11
|
} from "atom.io/internal"
|
|
7
12
|
import { createTimeline, IMPLICIT, timeTravel } from "atom.io/internal"
|
|
@@ -9,6 +14,14 @@ import { createTimeline, IMPLICIT, timeTravel } from "atom.io/internal"
|
|
|
9
14
|
import type { AtomFamilyToken, AtomToken } from "."
|
|
10
15
|
|
|
11
16
|
export type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>
|
|
17
|
+
export type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<
|
|
18
|
+
any,
|
|
19
|
+
any
|
|
20
|
+
>
|
|
21
|
+
? AtomToken<any>
|
|
22
|
+
: M extends AtomToken<any>
|
|
23
|
+
? M
|
|
24
|
+
: never
|
|
12
25
|
|
|
13
26
|
export type TimelineToken<M> = {
|
|
14
27
|
key: string
|
|
@@ -18,7 +31,7 @@ export type TimelineToken<M> = {
|
|
|
18
31
|
|
|
19
32
|
export type TimelineOptions<ManagedAtom extends TimelineManageable> = {
|
|
20
33
|
key: string
|
|
21
|
-
|
|
34
|
+
scope: (ManagedAtom | MoleculeFamilyToken<any, any, any>)[]
|
|
22
35
|
shouldCapture?: (
|
|
23
36
|
update: TimelineUpdate<ManagedAtom>,
|
|
24
37
|
timeline: Timeline<TimelineManageable>,
|
|
@@ -27,7 +40,11 @@ export type TimelineOptions<ManagedAtom extends TimelineManageable> = {
|
|
|
27
40
|
|
|
28
41
|
export type TimelineUpdate<ManagedAtom extends TimelineManageable> =
|
|
29
42
|
| TimelineAtomUpdate<ManagedAtom>
|
|
43
|
+
| TimelineMoleculeCreation<any>
|
|
44
|
+
| TimelineMoleculeDisposal<any>
|
|
30
45
|
| TimelineSelectorUpdate<ManagedAtom>
|
|
46
|
+
| TimelineStateCreation<AtomOnly<ManagedAtom>>
|
|
47
|
+
| TimelineStateDisposal<AtomOnly<ManagedAtom>>
|
|
31
48
|
| TimelineTransactionUpdate
|
|
32
49
|
|
|
33
50
|
export const timeline = <ManagedAtom extends TimelineManageable>(
|
package/src/transaction.ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { findState } from "atom.io/ephemeral"
|
|
2
|
+
import type {
|
|
3
|
+
makeMolecule,
|
|
4
|
+
MoleculeFamilyToken,
|
|
5
|
+
MoleculeToken,
|
|
6
|
+
seekState,
|
|
7
|
+
} from "atom.io/immortal"
|
|
8
|
+
import type { EnvironmentData, Transceiver } from "atom.io/internal"
|
|
2
9
|
import {
|
|
3
10
|
actUponStore,
|
|
4
11
|
arbitrary,
|
|
5
12
|
createTransaction,
|
|
6
13
|
IMPLICIT,
|
|
7
14
|
} from "atom.io/internal"
|
|
15
|
+
import type { Json } from "atom.io/json"
|
|
8
16
|
|
|
9
17
|
import type {
|
|
10
|
-
|
|
18
|
+
disposeState,
|
|
11
19
|
Func,
|
|
12
20
|
KeyedStateUpdate,
|
|
21
|
+
MutableAtomToken,
|
|
22
|
+
ReadableToken,
|
|
13
23
|
ReadonlySelectorToken,
|
|
24
|
+
TokenType,
|
|
25
|
+
WritableSelectorToken,
|
|
14
26
|
WritableToken,
|
|
15
27
|
} from "."
|
|
16
28
|
|
|
@@ -20,11 +32,41 @@ export type TransactionToken<F extends Func> = {
|
|
|
20
32
|
__F?: F
|
|
21
33
|
}
|
|
22
34
|
|
|
35
|
+
export type StateCreation<Token extends ReadableToken<any>> = {
|
|
36
|
+
type: `state_creation`
|
|
37
|
+
token: Token
|
|
38
|
+
}
|
|
39
|
+
export type StateDisposal<Token extends ReadableToken<any>> = {
|
|
40
|
+
type: `state_disposal`
|
|
41
|
+
token: Token
|
|
42
|
+
value?: TokenType<Token>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type MoleculeCreation<Key extends Json.Serializable> = {
|
|
46
|
+
type: `molecule_creation`
|
|
47
|
+
token: MoleculeToken<Key, any, any>
|
|
48
|
+
family: MoleculeFamilyToken<Key, any, any>
|
|
49
|
+
context: MoleculeToken<any, any, any>[]
|
|
50
|
+
params: any[]
|
|
51
|
+
}
|
|
52
|
+
export type MoleculeDisposal<Key extends Json.Serializable> = {
|
|
53
|
+
type: `molecule_disposal`
|
|
54
|
+
token: MoleculeToken<Key, any, any>
|
|
55
|
+
family: MoleculeFamilyToken<any, any, any>
|
|
56
|
+
context: MoleculeToken<any, any, any>[]
|
|
57
|
+
familyKeys: string[]
|
|
58
|
+
}
|
|
59
|
+
|
|
23
60
|
export type TransactionUpdateContent =
|
|
24
61
|
| KeyedStateUpdate<unknown>
|
|
62
|
+
| MoleculeCreation<any>
|
|
63
|
+
| MoleculeDisposal<any>
|
|
64
|
+
| StateCreation<ReadableToken<unknown>>
|
|
65
|
+
| StateDisposal<ReadableToken<unknown>>
|
|
25
66
|
| TransactionUpdate<Func>
|
|
26
67
|
|
|
27
68
|
export type TransactionUpdate<F extends Func> = {
|
|
69
|
+
type: `transaction_update`
|
|
28
70
|
key: string
|
|
29
71
|
id: string
|
|
30
72
|
epoch: number
|
|
@@ -34,12 +76,16 @@ export type TransactionUpdate<F extends Func> = {
|
|
|
34
76
|
}
|
|
35
77
|
|
|
36
78
|
export type Transactors = Readonly<{
|
|
37
|
-
get: <S>(state:
|
|
79
|
+
get: <S>(state: ReadableToken<S>) => S
|
|
38
80
|
set: <S, New extends S>(
|
|
39
81
|
state: WritableToken<S>,
|
|
40
82
|
newValue: New | ((oldValue: S) => New),
|
|
41
83
|
) => void
|
|
42
84
|
find: typeof findState
|
|
85
|
+
seek: typeof seekState
|
|
86
|
+
json: <T extends Transceiver<any>, J extends Json.Serializable>(
|
|
87
|
+
state: MutableAtomToken<T, J>,
|
|
88
|
+
) => WritableSelectorToken<J>
|
|
43
89
|
}>
|
|
44
90
|
export type TransactorsWithRunAndEnv = Readonly<{
|
|
45
91
|
get: <S>(state: ReadonlySelectorToken<S> | WritableToken<S>) => S
|
|
@@ -48,10 +94,19 @@ export type TransactorsWithRunAndEnv = Readonly<{
|
|
|
48
94
|
newValue: New | ((oldValue: S) => New),
|
|
49
95
|
) => void
|
|
50
96
|
find: typeof findState
|
|
97
|
+
seek: typeof seekState
|
|
98
|
+
json: <T extends Transceiver<any>, J extends Json.Serializable>(
|
|
99
|
+
state: MutableAtomToken<T, J>,
|
|
100
|
+
) => WritableSelectorToken<J>
|
|
101
|
+
make: typeof makeMolecule
|
|
102
|
+
dispose: typeof disposeState
|
|
51
103
|
run: typeof runTransaction
|
|
52
104
|
env: () => EnvironmentData
|
|
53
105
|
}>
|
|
54
|
-
export type ReadonlyTransactors = Pick<
|
|
106
|
+
export type ReadonlyTransactors = Pick<
|
|
107
|
+
Transactors,
|
|
108
|
+
`find` | `get` | `json` | `seek`
|
|
109
|
+
>
|
|
55
110
|
|
|
56
111
|
export type Read<F extends Func> = (
|
|
57
112
|
transactors: ReadonlyTransactors,
|
package/dist/chunk-BF4MVQF6.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// ../anvl/src/json/json-interface.ts
|
|
2
|
-
var stringSetJsonInterface = {
|
|
3
|
-
toJson: (stringSet) => Array.from(stringSet),
|
|
4
|
-
fromJson: (json) => new Set(json)
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// ../anvl/src/json/index.ts
|
|
8
|
-
var parseJson = (str) => JSON.parse(str);
|
|
9
|
-
var stringifyJson = (json) => JSON.stringify(json);
|
|
10
|
-
var JSON_TYPE_NAMES = [
|
|
11
|
-
`array`,
|
|
12
|
-
`boolean`,
|
|
13
|
-
`null`,
|
|
14
|
-
`number`,
|
|
15
|
-
`object`,
|
|
16
|
-
`string`
|
|
17
|
-
];
|
|
18
|
-
var JSON_DEFAULTS = {
|
|
19
|
-
array: [],
|
|
20
|
-
boolean: false,
|
|
21
|
-
null: null,
|
|
22
|
-
number: 0,
|
|
23
|
-
object: {},
|
|
24
|
-
string: ``
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// ../anvl/src/primitive/index.ts
|
|
28
|
-
var isString = (input) => {
|
|
29
|
-
return typeof input === `string`;
|
|
30
|
-
};
|
|
31
|
-
var isNumber = (input) => {
|
|
32
|
-
return typeof input === `number`;
|
|
33
|
-
};
|
|
34
|
-
var isBoolean = (input) => {
|
|
35
|
-
return typeof input === `boolean`;
|
|
36
|
-
};
|
|
37
|
-
var isNull = (input) => {
|
|
38
|
-
return input === null;
|
|
39
|
-
};
|
|
40
|
-
var isPrimitive = (input) => {
|
|
41
|
-
return isString(input) || isNumber(input) || isBoolean(input) || isNull(input);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, stringSetJsonInterface, stringifyJson };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ReadableToken,
|
|
3
|
-
ReadonlySelectorToken,
|
|
4
|
-
RegularAtomToken,
|
|
5
|
-
WritableSelectorToken,
|
|
6
|
-
WritableToken,
|
|
7
|
-
} from "atom.io"
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
Atom,
|
|
11
|
-
ReadableState,
|
|
12
|
-
ReadonlySelector,
|
|
13
|
-
Store,
|
|
14
|
-
WritableSelector,
|
|
15
|
-
WritableState,
|
|
16
|
-
} from ".."
|
|
17
|
-
import { newest, NotFoundError, withdraw } from ".."
|
|
18
|
-
|
|
19
|
-
export function withdrawOrCreate<T>(
|
|
20
|
-
token: RegularAtomToken<T>,
|
|
21
|
-
store: Store,
|
|
22
|
-
): Atom<T>
|
|
23
|
-
export function withdrawOrCreate<T>(
|
|
24
|
-
token: WritableSelectorToken<T>,
|
|
25
|
-
store: Store,
|
|
26
|
-
): WritableSelector<T>
|
|
27
|
-
export function withdrawOrCreate<T>(
|
|
28
|
-
token: ReadonlySelectorToken<T>,
|
|
29
|
-
store: Store,
|
|
30
|
-
): ReadonlySelector<T>
|
|
31
|
-
export function withdrawOrCreate<T>(
|
|
32
|
-
token: WritableToken<T>,
|
|
33
|
-
store: Store,
|
|
34
|
-
): WritableState<T>
|
|
35
|
-
export function withdrawOrCreate<T>(
|
|
36
|
-
token: ReadableToken<T>,
|
|
37
|
-
store: Store,
|
|
38
|
-
): ReadableState<T>
|
|
39
|
-
export function withdrawOrCreate<T>(
|
|
40
|
-
token: ReadableToken<T>,
|
|
41
|
-
store: Store,
|
|
42
|
-
): ReadableState<T> {
|
|
43
|
-
try {
|
|
44
|
-
const state = withdraw(token, store)
|
|
45
|
-
return state
|
|
46
|
-
} catch (notFoundError) {
|
|
47
|
-
if (token.family) {
|
|
48
|
-
store.logger.info(
|
|
49
|
-
`👪`,
|
|
50
|
-
token.type,
|
|
51
|
-
token.key,
|
|
52
|
-
`creating new family member in store "${store.config.name}"`,
|
|
53
|
-
)
|
|
54
|
-
const target = newest(store)
|
|
55
|
-
const family = target.families.get(token.family.key)
|
|
56
|
-
if (family) {
|
|
57
|
-
const jsonSubKey = JSON.parse(token.family.subKey)
|
|
58
|
-
family(jsonSubKey)
|
|
59
|
-
const state = withdraw(token, store)
|
|
60
|
-
return state
|
|
61
|
-
}
|
|
62
|
-
throw new NotFoundError(
|
|
63
|
-
{ key: token.family.key, type: `${token.type}_family` },
|
|
64
|
-
store,
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
throw notFoundError
|
|
68
|
-
}
|
|
69
|
-
}
|
|
File without changes
|