atom.io 0.18.0 → 0.18.1
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/{chunk-OEVFAUPE.js → chunk-IZHOMSXA.js} +53 -11
- package/dist/chunk-IZHOMSXA.js.map +1 -0
- package/dist/chunk-JDUNWJFB.js +18 -0
- package/dist/chunk-JDUNWJFB.js.map +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +64 -34
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +1 -1
- package/internal/dist/index.js +64 -34
- package/internal/dist/index.js.map +1 -1
- package/internal/src/atom/delete-atom.ts +7 -6
- package/internal/src/caching.ts +6 -6
- package/internal/src/ingest-updates/ingest-atom-update.ts +6 -2
- package/internal/src/set-state/copy-mutable-if-needed.ts +5 -0
- package/internal/src/set-state/emit-update.ts +25 -11
- package/internal/src/set-state/set-atom.ts +4 -3
- package/internal/src/transaction/apply-transaction.ts +0 -1
- package/internal/src/transaction/set-epoch-number.ts +0 -1
- package/json/src/index.ts +3 -3
- package/package.json +241 -241
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.js +1 -15
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +6 -6
- package/react-devtools/src/StateIndex.tsx +2 -2
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/index.ts +3 -3
- package/realtime/dist/index.cjs +50 -2
- package/realtime/dist/index.cjs.map +1 -1
- package/realtime/dist/index.d.ts +110 -3
- package/realtime/dist/index.js +47 -4
- package/realtime/dist/index.js.map +1 -1
- package/realtime/src/index.ts +1 -0
- package/realtime/src/realtime-continuity.ts +14 -4
- package/realtime/src/shared-room-store.ts +48 -0
- package/realtime-client/dist/index.cjs +113 -200
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +2 -5
- package/realtime-client/dist/index.js +17 -161
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +0 -2
- package/realtime-client/src/pull-mutable-atom-family-member.ts +5 -5
- package/realtime-client/src/realtime-client-stores/client-main-store.ts +10 -0
- package/realtime-client/src/sync-continuity.ts +56 -9
- package/realtime-react/dist/index.cjs +51 -26
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +2 -6
- package/realtime-react/dist/index.js +2 -17
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +0 -2
- package/realtime-server/dist/index.cjs +399 -327
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +55 -60
- package/realtime-server/dist/index.js +394 -319
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +2 -4
- package/realtime-server/src/ipc-sockets/child-socket.ts +135 -0
- package/realtime-server/src/ipc-sockets/custom-socket.ts +90 -0
- package/realtime-server/src/ipc-sockets/index.ts +3 -0
- package/realtime-server/src/ipc-sockets/parent-socket.ts +185 -0
- package/realtime-server/src/realtime-continuity-synchronizer.ts +225 -96
- package/realtime-server/src/realtime-server-stores/index.ts +2 -1
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +50 -31
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +64 -0
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +42 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +49 -26
- package/realtime-testing/dist/index.cjs +8 -6
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.ts +1 -0
- package/realtime-testing/dist/index.js +7 -6
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +8 -6
- package/src/logger.ts +5 -1
- package/dist/chunk-OEVFAUPE.js.map +0 -1
- package/realtime-client/src/sync-server-action.ts +0 -168
- package/realtime-client/src/sync-state.ts +0 -19
- package/realtime-react/src/use-sync-server-action.ts +0 -17
- package/realtime-react/src/use-sync.ts +0 -17
- package/realtime-server/src/ipc-socket.ts +0 -230
- package/realtime-server/src/realtime-action-synchronizer.ts +0 -164
- package/realtime-server/src/realtime-server-stores/server-room-store.ts +0 -97
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AtomToken } from "atom.io"
|
|
2
2
|
|
|
3
3
|
import type { Store } from ".."
|
|
4
|
-
import { deleteSelector, newest } from ".."
|
|
4
|
+
import { deleteSelector, getUpdateToken, newest } from ".."
|
|
5
5
|
|
|
6
|
-
export function deleteAtom(
|
|
7
|
-
atomToken: RegularAtomToken<unknown>,
|
|
8
|
-
store: Store,
|
|
9
|
-
): void {
|
|
6
|
+
export function deleteAtom(atomToken: AtomToken<unknown>, store: Store): void {
|
|
10
7
|
const target = newest(store)
|
|
11
8
|
const { key } = atomToken
|
|
12
9
|
const atom = target.atoms.get(key)
|
|
@@ -35,5 +32,9 @@ export function deleteAtom(
|
|
|
35
32
|
target.selectorAtoms.delete(key)
|
|
36
33
|
target.atomsThatAreDefault.delete(key)
|
|
37
34
|
target.timelineAtoms.delete(key)
|
|
35
|
+
if (atomToken.type === `mutable_atom`) {
|
|
36
|
+
const updateToken = getUpdateToken(atomToken)
|
|
37
|
+
deleteAtom(updateToken, store)
|
|
38
|
+
}
|
|
38
39
|
store.logger.info(`🔥`, `atom`, `${key}`, `deleted`)
|
|
39
40
|
}
|
package/internal/src/caching.ts
CHANGED
|
@@ -53,12 +53,12 @@ export const readCachedValue = <T>(
|
|
|
53
53
|
token: ReadableState<any>,
|
|
54
54
|
target: Store,
|
|
55
55
|
): T => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
let value = target.valueMap.get(token.key) as T
|
|
57
|
+
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
58
|
+
const { parent } = target
|
|
59
|
+
const copiedValue = copyMutableIfNeeded(token, parent, target)
|
|
60
|
+
value = copiedValue
|
|
61
|
+
}
|
|
62
62
|
return value
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KeyedStateUpdate } from "atom.io"
|
|
1
|
+
import type { KeyedStateUpdate, RegularAtomToken } from "atom.io"
|
|
2
2
|
|
|
3
3
|
import { setIntoStore } from "../set-state"
|
|
4
4
|
import type { Store } from "../store"
|
|
@@ -10,5 +10,9 @@ export function ingestAtomUpdate(
|
|
|
10
10
|
): void {
|
|
11
11
|
const { key, newValue, oldValue } = atomUpdate
|
|
12
12
|
const value = applying === `newValue` ? newValue : oldValue
|
|
13
|
-
|
|
13
|
+
const token: RegularAtomToken<unknown> = { key, type: `atom` }
|
|
14
|
+
if (atomUpdate.family) {
|
|
15
|
+
Object.assign(token, { family: atomUpdate.family })
|
|
16
|
+
}
|
|
17
|
+
setIntoStore(token, value, store)
|
|
14
18
|
}
|
|
@@ -9,7 +9,12 @@ export function copyMutableIfNeeded<T extends Transceiver<any>>(
|
|
|
9
9
|
): T {
|
|
10
10
|
const originValue = origin.valueMap.get(atom.key)
|
|
11
11
|
const targetValue = target.valueMap.get(atom.key)
|
|
12
|
+
|
|
12
13
|
if (originValue === targetValue) {
|
|
14
|
+
if (originValue === undefined) {
|
|
15
|
+
return typeof atom.default === `function` ? atom.default() : atom.default
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
origin.logger.info(`📃`, `atom`, `${atom.key}`, `copying`)
|
|
14
19
|
const jsonValue = atom.toJson(originValue)
|
|
15
20
|
const copiedValue = atom.fromJson(jsonValue)
|
|
@@ -8,16 +8,30 @@ export const emitUpdate = <T>(
|
|
|
8
8
|
update: StateUpdate<T>,
|
|
9
9
|
store: Store,
|
|
10
10
|
): void => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
switch (state.type) {
|
|
12
|
+
case `mutable_atom`:
|
|
13
|
+
store.logger.info(
|
|
14
|
+
`📢`,
|
|
15
|
+
state.type,
|
|
16
|
+
state.key,
|
|
17
|
+
`is now (`,
|
|
18
|
+
update.newValue,
|
|
19
|
+
`) subscribers:`,
|
|
20
|
+
state.subject.subscribers,
|
|
21
|
+
)
|
|
22
|
+
break
|
|
23
|
+
default:
|
|
24
|
+
store.logger.info(
|
|
25
|
+
`📢`,
|
|
26
|
+
state.type,
|
|
27
|
+
state.key,
|
|
28
|
+
`went (`,
|
|
29
|
+
update.oldValue,
|
|
30
|
+
`->`,
|
|
31
|
+
update.newValue,
|
|
32
|
+
`) subscribers:`,
|
|
33
|
+
state.subject.subscribers,
|
|
34
|
+
)
|
|
35
|
+
}
|
|
22
36
|
state.subject.next(update)
|
|
23
37
|
}
|
|
@@ -42,12 +42,13 @@ export const setAtom = <T>(
|
|
|
42
42
|
const mutableKey = atom.key.slice(1)
|
|
43
43
|
const mutableAtom = target.atoms.get(mutableKey) as Atom<any>
|
|
44
44
|
let transceiver: Transceiver<any> = target.valueMap.get(mutableKey)
|
|
45
|
-
if (
|
|
45
|
+
if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
|
|
46
46
|
const { parent } = target
|
|
47
|
-
const copiedValue = copyMutableIfNeeded(
|
|
47
|
+
const copiedValue = copyMutableIfNeeded(mutableAtom, parent, target)
|
|
48
48
|
transceiver = copiedValue
|
|
49
49
|
}
|
|
50
|
-
transceiver.do(update.newValue)
|
|
50
|
+
const accepted = transceiver.do(update.newValue) === null
|
|
51
|
+
if (accepted) evictDownStream(mutableAtom, target)
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -60,7 +60,6 @@ export const applyTransaction = <ƒ extends ƒn>(
|
|
|
60
60
|
}
|
|
61
61
|
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent)
|
|
62
62
|
if (isRootStore(parent)) {
|
|
63
|
-
console.log(child.transactionMeta.update)
|
|
64
63
|
setEpochNumberOfAction(
|
|
65
64
|
child.transactionMeta.update.key,
|
|
66
65
|
child.transactionMeta.update.epoch,
|
package/json/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "anvl/json"
|
|
2
|
-
export * from "anvl/primitive"
|
|
1
|
+
export * from "~/packages/anvl/src/json"
|
|
2
|
+
export * from "~/packages/anvl/src/primitive"
|
|
3
3
|
|
|
4
4
|
export * from "./select-json"
|
|
5
5
|
export * from "./select-json-family"
|
|
6
6
|
|
|
7
|
-
import type { Json } from "anvl/json"
|
|
7
|
+
import type { Json } from "~/packages/anvl/src/json"
|
|
8
8
|
|
|
9
9
|
export type JsonIO = (...params: Json.Serializable[]) => Json.Serializable | void
|