atom.io 0.5.0 → 0.6.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/dist/index.d.mts +82 -66
- package/dist/index.d.ts +82 -66
- package/dist/index.js +482 -360
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +481 -360
- package/dist/index.mjs.map +1 -1
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs.map +1 -1
- package/package.json +12 -5
- package/react/dist/index.d.mts +18 -11
- package/react/dist/index.d.ts +18 -11
- package/react/dist/index.js +45 -21
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +31 -21
- package/react/dist/index.mjs.map +1 -1
- package/react-devtools/dist/index.d.mts +4 -4
- package/react-devtools/dist/index.d.ts +4 -4
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.d.mts +3 -1
- package/realtime/dist/index.d.ts +3 -1
- package/realtime/dist/index.js +23 -0
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs +22 -0
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.d.mts +45 -0
- package/realtime-react/dist/index.d.ts +45 -0
- package/realtime-react/dist/index.js +213 -0
- package/realtime-react/dist/index.js.map +1 -0
- package/realtime-react/dist/index.mjs +168 -0
- package/realtime-react/dist/index.mjs.map +1 -0
- package/realtime-react/package.json +15 -0
- package/src/index.ts +0 -6
- package/src/internal/get.ts +17 -3
- package/src/internal/index.ts +2 -0
- package/src/internal/meta/meta-state.ts +1 -1
- package/src/internal/operation.ts +3 -1
- package/src/internal/selector/create-read-write-selector.ts +62 -0
- package/src/internal/selector/create-readonly-selector.ts +52 -0
- package/src/internal/selector/index.ts +4 -0
- package/src/internal/selector/lookup-selector-sources.ts +16 -0
- package/src/internal/selector/register-selector.ts +57 -0
- package/src/internal/selector/trace-selector-atoms.ts +43 -0
- package/src/internal/selector/update-selector-atoms.ts +33 -0
- package/src/internal/selector-internal.ts +9 -207
- package/src/internal/store.ts +43 -16
- package/src/internal/subscribe-internal.ts +1 -1
- package/src/internal/time-travel-internal.ts +7 -7
- package/src/internal/timeline/add-atom-to-timeline.ts +164 -0
- package/src/internal/timeline/index.ts +1 -0
- package/src/internal/timeline-internal.ts +37 -156
- package/src/internal/transaction/abort-transaction.ts +12 -0
- package/src/internal/transaction/apply-transaction.ts +54 -0
- package/src/internal/transaction/build-transaction.ts +33 -0
- package/src/internal/transaction/index.ts +25 -0
- package/src/internal/transaction/redo-transaction.ts +23 -0
- package/src/internal/transaction/undo-transaction.ts +23 -0
- package/src/internal/transaction-internal.ts +14 -146
- package/src/react/index.ts +2 -46
- package/src/react/store-context.tsx +14 -0
- package/src/react/store-hooks.ts +48 -0
- package/src/react-devtools/AtomIODevtools.tsx +1 -1
- package/src/react-explorer/AtomIOExplorer.tsx +2 -2
- package/src/react-explorer/space-states.ts +2 -2
- package/src/realtime/README.md +33 -0
- package/src/realtime/hook-composition/index.ts +1 -0
- package/src/realtime/hook-composition/receive-state.ts +29 -0
- package/src/realtime/hook-composition/receive-transaction.ts +2 -3
- package/src/realtime-react/index.ts +3 -0
- package/src/realtime-react/realtime-context.tsx +31 -0
- package/src/realtime-react/realtime-hooks.ts +39 -0
- package/src/realtime-react/realtime-state.ts +10 -0
- package/src/realtime-react/use-pull-family-member.ts +27 -0
- package/src/realtime-react/use-pull-family.ts +25 -0
- package/src/realtime-react/use-pull.ts +23 -0
- package/src/realtime-react/use-push.ts +26 -0
- package/src/realtime-react/use-server-action.ts +34 -0
- package/src/silo.ts +12 -4
- package/src/subscribe.ts +30 -2
- package/src/timeline.ts +10 -0
- package/src/transaction.ts +15 -10
- package/src/realtime-client/hook-composition/compose-realtime-hooks.ts +0 -62
- package/src/realtime-client/hook-composition/realtime-client-family-member.ts +0 -28
- package/src/realtime-client/hook-composition/realtime-client-family.ts +0 -26
- package/src/realtime-client/hook-composition/realtime-client-single.ts +0 -24
- package/src/realtime-client/hook-composition/realtime-client-transaction.ts +0 -35
- package/src/realtime-client/index.ts +0 -1
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react"
|
|
2
|
-
|
|
3
|
-
import * as AtomIO from "atom.io"
|
|
4
|
-
import type * as SocketIO from "socket.io-client"
|
|
5
|
-
|
|
6
|
-
import type { Json } from "~/packages/anvl/src/json"
|
|
7
|
-
|
|
8
|
-
export const realtimeClientFamilyHook =
|
|
9
|
-
(
|
|
10
|
-
socket: SocketIO.Socket,
|
|
11
|
-
store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE
|
|
12
|
-
) =>
|
|
13
|
-
<J extends Json>(
|
|
14
|
-
family: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>
|
|
15
|
-
): void => {
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
socket.on(`serve:${family.key}`, (key: Json, data: J) => {
|
|
18
|
-
AtomIO.setState(family(key), data, store)
|
|
19
|
-
})
|
|
20
|
-
socket.emit(`sub:${family.key}`)
|
|
21
|
-
return () => {
|
|
22
|
-
socket.off(`serve:${family.key}`)
|
|
23
|
-
socket.emit(`unsub:${family.key}`)
|
|
24
|
-
}
|
|
25
|
-
}, [family.key])
|
|
26
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
|
|
3
|
-
import * as AtomIO from "atom.io"
|
|
4
|
-
import type * as SocketIO from "socket.io-client"
|
|
5
|
-
|
|
6
|
-
import type { Json } from "~/packages/anvl/src/json"
|
|
7
|
-
|
|
8
|
-
export const realtimeClientSingleHook =
|
|
9
|
-
(
|
|
10
|
-
socket: SocketIO.Socket,
|
|
11
|
-
store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE
|
|
12
|
-
) =>
|
|
13
|
-
<J extends Json>(token: AtomIO.StateToken<J>): void => {
|
|
14
|
-
React.useEffect(() => {
|
|
15
|
-
socket.on(`serve:${token.key}`, (data: J) => {
|
|
16
|
-
AtomIO.setState(token, data, store)
|
|
17
|
-
})
|
|
18
|
-
socket.emit(`sub:${token.key}`)
|
|
19
|
-
return () => {
|
|
20
|
-
socket.off(`serve:${token.key}`)
|
|
21
|
-
socket.emit(`unsub:${token.key}`)
|
|
22
|
-
}
|
|
23
|
-
}, [token.key])
|
|
24
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react"
|
|
2
|
-
|
|
3
|
-
import * as AtomIO from "atom.io"
|
|
4
|
-
import type * as SocketIO from "socket.io-client"
|
|
5
|
-
|
|
6
|
-
import type { ƒn } from "~/packages/anvl/src/function"
|
|
7
|
-
|
|
8
|
-
const TX_SUBS = new Map<string, number>()
|
|
9
|
-
export const realtimeClientTransactionHook =
|
|
10
|
-
(
|
|
11
|
-
socket: SocketIO.Socket,
|
|
12
|
-
store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE
|
|
13
|
-
) =>
|
|
14
|
-
<ƒ extends ƒn>(
|
|
15
|
-
token: AtomIO.TransactionToken<ƒ>
|
|
16
|
-
): ((...parameters: Parameters<ƒ>) => ReturnType<ƒ>) => {
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const count = TX_SUBS.get(token.key) ?? 0
|
|
19
|
-
TX_SUBS.set(token.key, count + 1)
|
|
20
|
-
const unsubscribe =
|
|
21
|
-
count === 0
|
|
22
|
-
? AtomIO.subscribeToTransaction(
|
|
23
|
-
token,
|
|
24
|
-
(update) => socket.emit(`tx:${token.key}`, update),
|
|
25
|
-
store
|
|
26
|
-
)
|
|
27
|
-
: () => null
|
|
28
|
-
return () => {
|
|
29
|
-
const newCount = TX_SUBS.get(token.key) ?? 0
|
|
30
|
-
TX_SUBS.set(token.key, newCount - 1)
|
|
31
|
-
unsubscribe()
|
|
32
|
-
}
|
|
33
|
-
}, [token.key])
|
|
34
|
-
return AtomIO.runTransaction(token, store)
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./hook-composition/compose-realtime-hooks"
|