atom.io 0.21.0 → 0.22.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 +139 -66
- package/data/dist/index.d.ts +6 -0
- package/data/dist/index.js +3 -3
- package/data/src/join.ts +135 -56
- package/data/src/struct-family.ts +2 -2
- package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
- package/dist/{chunk-KGZGBCYS.js → chunk-JA4V7TJY.js} +135 -62
- package/dist/index.cjs +2 -7
- package/dist/index.d.ts +29 -14
- package/dist/index.js +4 -8
- 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 +156 -1
- package/eslint-plugin/dist/index.js +156 -1
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/lifespan.ts +204 -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 +100 -0
- package/immortal/dist/index.js +97 -0
- package/immortal/package.json +16 -0
- package/immortal/src/index.ts +2 -0
- package/immortal/src/molecule.ts +134 -0
- package/immortal/src/seek-state.ts +60 -0
- package/internal/dist/index.cjs +211 -194
- package/internal/dist/index.d.ts +30 -14
- package/internal/dist/index.js +210 -194
- package/internal/src/atom/dispose-atom.ts +4 -1
- package/internal/src/families/create-readonly-selector-family.ts +9 -9
- package/internal/src/families/create-regular-atom-family.ts +15 -20
- package/internal/src/families/create-writable-selector-family.ts +6 -7
- package/internal/src/families/find-in-store.ts +11 -5
- package/internal/src/families/index.ts +2 -0
- package/internal/src/families/init-family-member.ts +91 -0
- package/internal/src/families/seek-in-store.ts +106 -0
- package/internal/src/future.ts +6 -20
- package/internal/src/get-state/get-from-store.ts +2 -3
- package/internal/src/mutable/create-mutable-atom-family.ts +17 -23
- package/internal/src/mutable/create-mutable-atom.ts +3 -1
- package/internal/src/mutable/get-json-family.ts +2 -2
- package/internal/src/mutable/get-json-token.ts +27 -12
- package/internal/src/mutable/tracker-family.ts +14 -12
- package/internal/src/mutable/tracker.ts +2 -24
- package/internal/src/not-found-error.ts +11 -3
- package/internal/src/operation.ts +0 -1
- package/internal/src/selector/create-readonly-selector.ts +2 -2
- package/internal/src/selector/create-writable-selector.ts +2 -2
- package/internal/src/selector/dispose-selector.ts +40 -23
- package/internal/src/selector/register-selector.ts +8 -5
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/store/index.ts +0 -1
- package/internal/src/store/store.ts +18 -5
- package/internal/src/subscribe/recall-state.ts +3 -3
- package/internal/src/subscribe/subscribe-to-state.ts +18 -5
- package/internal/src/transaction/build-transaction.ts +7 -2
- package/introspection/dist/index.cjs +39 -65
- package/introspection/dist/index.js +39 -65
- package/introspection/src/attach-atom-index.ts +38 -48
- package/introspection/src/attach-introspection-states.ts +0 -1
- package/introspection/src/attach-selector-index.ts +45 -50
- package/introspection/src/attach-timeline-family.ts +2 -17
- package/json/dist/index.cjs +38 -4
- package/json/dist/index.js +40 -6
- package/json/src/select-json-family.ts +46 -7
- package/package.json +31 -11
- 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 +11 -10
- package/react-devtools/dist/index.js +2 -1
- package/react-devtools/src/StateIndex.tsx +2 -1
- package/react-devtools/src/TimelineIndex.tsx +2 -1
- package/react-devtools/src/TransactionIndex.tsx +7 -7
- 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 +18 -17
- package/realtime-server/dist/index.js +7 -6
- 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-testing/dist/index.cjs +6 -2
- package/realtime-testing/dist/index.js +8 -5
- package/realtime-testing/src/setup-realtime-test.tsx +5 -2
- package/src/atom.ts +10 -4
- package/src/index.ts +1 -2
- package/src/selector.ts +10 -4
- package/src/silo.ts +3 -3
- package/src/transaction.ts +5 -2
- package/src/validators.ts +0 -6
- package/internal/src/store/withdraw-new-family-member.ts +0 -69
- /package/{src → ephemeral/src}/find-state.ts +0 -0
- /package/src/{dispose.ts → dispose-state.ts} +0 -0
|
@@ -76,7 +76,10 @@ export const setupRealtimeTestServer = (
|
|
|
76
76
|
options: TestSetupOptions,
|
|
77
77
|
): RealtimeTestServer => {
|
|
78
78
|
++testNumber
|
|
79
|
-
const silo = new AtomIO.Silo(
|
|
79
|
+
const silo = new AtomIO.Silo(
|
|
80
|
+
{ name: `SERVER-${testNumber}`, lifespan: `ephemeral` },
|
|
81
|
+
IMPLICIT.STORE,
|
|
82
|
+
)
|
|
80
83
|
|
|
81
84
|
const httpServer = http.createServer((_, res) => res.end(`Hello World!`))
|
|
82
85
|
const address = httpServer.listen(options.port).address()
|
|
@@ -139,7 +142,7 @@ export const setupRealtimeTestClient = (
|
|
|
139
142
|
const socket: ClientSocket = io(`http://localhost:${port}/`, {
|
|
140
143
|
auth: { token: `test`, username: `${name}-${testNumber}` },
|
|
141
144
|
})
|
|
142
|
-
const silo = new AtomIO.Silo(name, IMPLICIT.STORE)
|
|
145
|
+
const silo = new AtomIO.Silo({ name, lifespan: `ephemeral` }, IMPLICIT.STORE)
|
|
143
146
|
for (const [key, value] of silo.store.valueMap.entries()) {
|
|
144
147
|
if (Array.isArray(value)) {
|
|
145
148
|
silo.store.valueMap.set(key, [...value])
|
package/src/atom.ts
CHANGED
|
@@ -57,8 +57,11 @@ export type RegularAtomFamilyTokenWithCall<
|
|
|
57
57
|
K extends Json.Serializable,
|
|
58
58
|
> =
|
|
59
59
|
& RegularAtomFamilyToken<T, K>
|
|
60
|
-
&
|
|
61
|
-
|
|
60
|
+
& {
|
|
61
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
62
|
+
/* eslint-disable-next-line @typescript-eslint/prefer-function-type */
|
|
63
|
+
(key: K): RegularAtomToken<T>
|
|
64
|
+
}
|
|
62
65
|
// biome-ignore format: intersection
|
|
63
66
|
export type RegularAtomFamily<T, K extends Json.Serializable> =
|
|
64
67
|
& RegularAtomFamilyToken<T, K>
|
|
@@ -100,8 +103,11 @@ export type MutableAtomFamilyTokenWithCall<
|
|
|
100
103
|
K extends Json.Serializable,
|
|
101
104
|
> =
|
|
102
105
|
& MutableAtomFamilyToken<T, J, K>
|
|
103
|
-
&
|
|
104
|
-
|
|
106
|
+
& {
|
|
107
|
+
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
108
|
+
/* eslint-disable-next-line @typescript-eslint/prefer-function-type */
|
|
109
|
+
(key: K): MutableAtomToken<T, J>
|
|
110
|
+
}
|
|
105
111
|
// biome-ignore format: intersection
|
|
106
112
|
export type MutableAtomFamily<
|
|
107
113
|
T extends Transceiver<any>,
|
package/src/index.ts
CHANGED
package/src/selector.ts
CHANGED
|
@@ -53,8 +53,11 @@ export type WritableSelectorFamilyTokenWithCall<
|
|
|
53
53
|
K extends Json.Serializable,
|
|
54
54
|
> =
|
|
55
55
|
& WritableSelectorFamilyToken<T, K>
|
|
56
|
-
&
|
|
57
|
-
|
|
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
|
+
}
|
|
58
61
|
// biome-ignore format: intersection
|
|
59
62
|
export type WritableSelectorFamily<T, K extends Json.Serializable> =
|
|
60
63
|
& WritableSelectorFamilyToken<T, K>
|
|
@@ -76,8 +79,11 @@ export type ReadonlySelectorFamilyTokenWithCall<
|
|
|
76
79
|
K extends Json.Serializable,
|
|
77
80
|
> =
|
|
78
81
|
& ReadonlySelectorFamilyToken<T, K>
|
|
79
|
-
&
|
|
80
|
-
|
|
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
|
+
}
|
|
81
87
|
// biome-ignore format: intersection
|
|
82
88
|
export type ReadonlySelectorFamily<T, K extends Json.Serializable> =
|
|
83
89
|
& ((key: K) => ReadonlySelectorToken<T>)
|
package/src/silo.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { findState } from "atom.io/ephemeral"
|
|
1
2
|
import type { Transceiver } from "atom.io/internal"
|
|
2
3
|
import {
|
|
3
4
|
createAtomFamily,
|
|
@@ -16,7 +17,6 @@ import type { Json } from "atom.io/json"
|
|
|
16
17
|
|
|
17
18
|
import type {
|
|
18
19
|
AtomToken,
|
|
19
|
-
findState,
|
|
20
20
|
getState,
|
|
21
21
|
MutableAtomFamily,
|
|
22
22
|
MutableAtomFamilyOptions,
|
|
@@ -50,8 +50,8 @@ export class Silo {
|
|
|
50
50
|
public subscribe: typeof subscribe
|
|
51
51
|
public undo: typeof undo
|
|
52
52
|
public redo: typeof redo
|
|
53
|
-
public constructor(
|
|
54
|
-
const s = new Store(
|
|
53
|
+
public constructor(config: Store[`config`], fromStore: Store | null = null) {
|
|
54
|
+
const s = new Store(config, fromStore)
|
|
55
55
|
function _atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>
|
|
56
56
|
function _atom<T extends Transceiver<any>, J extends Json.Serializable>(
|
|
57
57
|
options: MutableAtomOptions<T, J>,
|
package/src/transaction.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { findState } from "atom.io/ephemeral"
|
|
1
2
|
import type { EnvironmentData } from "atom.io/internal"
|
|
2
3
|
import {
|
|
3
4
|
actUponStore,
|
|
@@ -6,8 +7,8 @@ import {
|
|
|
6
7
|
IMPLICIT,
|
|
7
8
|
} from "atom.io/internal"
|
|
8
9
|
|
|
10
|
+
import type { seekState } from "../immortal/src/seek-state"
|
|
9
11
|
import type {
|
|
10
|
-
findState,
|
|
11
12
|
Func,
|
|
12
13
|
KeyedStateUpdate,
|
|
13
14
|
ReadonlySelectorToken,
|
|
@@ -40,6 +41,7 @@ export type Transactors = Readonly<{
|
|
|
40
41
|
newValue: New | ((oldValue: S) => New),
|
|
41
42
|
) => void
|
|
42
43
|
find: typeof findState
|
|
44
|
+
seek: typeof seekState
|
|
43
45
|
}>
|
|
44
46
|
export type TransactorsWithRunAndEnv = Readonly<{
|
|
45
47
|
get: <S>(state: ReadonlySelectorToken<S> | WritableToken<S>) => S
|
|
@@ -48,10 +50,11 @@ export type TransactorsWithRunAndEnv = Readonly<{
|
|
|
48
50
|
newValue: New | ((oldValue: S) => New),
|
|
49
51
|
) => void
|
|
50
52
|
find: typeof findState
|
|
53
|
+
seek: typeof seekState
|
|
51
54
|
run: typeof runTransaction
|
|
52
55
|
env: () => EnvironmentData
|
|
53
56
|
}>
|
|
54
|
-
export type ReadonlyTransactors = Pick<Transactors, `find` | `get`>
|
|
57
|
+
export type ReadonlyTransactors = Pick<Transactors, `find` | `get` | `seek`>
|
|
55
58
|
|
|
56
59
|
export type Read<F extends Func> = (
|
|
57
60
|
transactors: ReadonlyTransactors,
|
package/src/validators.ts
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
MutableAtomFamily,
|
|
3
2
|
MutableAtomFamilyToken,
|
|
4
3
|
MutableAtomToken,
|
|
5
|
-
ReadableFamily,
|
|
6
4
|
ReadableFamilyToken,
|
|
7
5
|
ReadableToken,
|
|
8
|
-
ReadonlySelectorFamily,
|
|
9
6
|
ReadonlySelectorFamilyToken,
|
|
10
7
|
ReadonlySelectorToken,
|
|
11
|
-
RegularAtomFamily,
|
|
12
8
|
RegularAtomFamilyToken,
|
|
13
9
|
RegularAtomToken,
|
|
14
|
-
WritableFamily,
|
|
15
10
|
WritableFamilyToken,
|
|
16
|
-
WritableSelectorFamily,
|
|
17
11
|
WritableSelectorFamilyToken,
|
|
18
12
|
WritableSelectorToken,
|
|
19
13
|
WritableToken,
|
|
@@ -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
|
|
File without changes
|