atom.io 0.16.3 → 0.18.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 +62 -40
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.ts +8 -2
- package/data/dist/index.js +64 -42
- package/data/dist/index.js.map +1 -1
- package/data/src/dict.ts +8 -4
- package/data/src/join.ts +74 -33
- package/data/src/struct-family.ts +18 -17
- package/dist/chunk-OEVFAUPE.js +289 -0
- package/dist/chunk-OEVFAUPE.js.map +1 -0
- package/dist/index.cjs +36 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +64 -53
- package/dist/index.js +15 -36
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +211 -81
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +100 -72
- package/internal/dist/index.js +200 -75
- package/internal/dist/index.js.map +1 -1
- package/internal/src/arbitrary.ts +3 -0
- package/internal/src/atom/create-regular-atom.ts +2 -3
- package/internal/src/caching.ts +8 -6
- package/internal/src/families/find-in-store.ts +16 -0
- package/internal/src/get-environment-data.ts +4 -7
- package/internal/src/get-state/get-from-store.ts +14 -0
- package/internal/src/get-state/index.ts +2 -0
- package/internal/src/{read-or-compute-value.ts → get-state/read-or-compute-value.ts} +3 -3
- package/internal/src/index.ts +7 -6
- package/internal/src/ingest-updates/ingest-atom-update.ts +2 -2
- package/internal/src/ingest-updates/ingest-transaction-update.ts +0 -1
- package/internal/src/mutable/create-mutable-atom.ts +3 -4
- package/internal/src/mutable/tracker.ts +18 -13
- package/internal/src/selector/create-standalone-selector.ts +0 -2
- package/internal/src/selector/register-selector.ts +1 -1
- package/internal/src/set-state/index.ts +1 -0
- package/internal/src/set-state/set-atom.ts +15 -19
- package/internal/src/set-state/set-into-store.ts +24 -0
- package/internal/src/store/store.ts +14 -2
- package/internal/src/store/withdraw.ts +72 -2
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +1 -1
- package/internal/src/subscribe/subscribe-to-timeline.ts +2 -2
- package/internal/src/subscribe/subscribe-to-transaction.ts +2 -2
- package/internal/src/timeline/create-timeline.ts +12 -1
- package/internal/src/transaction/act-upon-store.ts +19 -0
- package/internal/src/transaction/apply-transaction.ts +7 -1
- package/internal/src/transaction/assign-transaction-to-continuity.ts +18 -0
- package/internal/src/transaction/build-transaction.ts +11 -8
- package/internal/src/transaction/create-transaction.ts +1 -1
- package/internal/src/transaction/get-epoch-number.ts +40 -0
- package/internal/src/transaction/index.ts +10 -1
- package/internal/src/transaction/set-epoch-number.ts +31 -0
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.ts +3 -3
- package/introspection/dist/index.js.map +1 -1
- package/introspection/src/attach-introspection-states.ts +6 -2
- package/introspection/src/attach-timeline-family.ts +5 -2
- package/introspection/src/attach-transaction-logs.ts +2 -2
- package/json/dist/index.d.ts +3 -1
- package/json/src/index.ts +6 -2
- package/package.json +24 -13
- package/react/dist/index.cjs +3 -3
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +1 -1
- package/react/dist/index.js +5 -5
- package/react/dist/index.js.map +1 -1
- package/react/src/use-i.ts +2 -3
- package/react/src/use-json.ts +1 -1
- package/react/src/use-o.ts +3 -4
- package/react-devtools/dist/index.cjs +131 -134
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.css +2 -2
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.ts +3 -3
- package/react-devtools/dist/index.js +103 -106
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +6 -6
- package/react-devtools/src/StateIndex.tsx +2 -5
- package/react-devtools/src/TimelineIndex.tsx +3 -3
- package/react-devtools/src/TransactionIndex.tsx +9 -8
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/index.ts +4 -4
- package/realtime/dist/index.cjs +72 -0
- package/realtime/dist/index.cjs.map +1 -0
- package/realtime/dist/index.d.ts +39 -0
- package/realtime/dist/index.js +68 -0
- package/realtime/dist/index.js.map +1 -0
- package/realtime/package.json +16 -0
- package/realtime/src/index.ts +1 -0
- package/realtime/src/realtime-continuity.ts +152 -0
- package/realtime-client/dist/index.cjs +403 -59
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +16 -9
- package/realtime-client/dist/index.js +114 -48
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +8 -5
- package/realtime-client/src/{pull-family-member.ts → pull-atom-family-member.ts} +5 -5
- package/realtime-client/src/{pull-state.ts → pull-atom.ts} +5 -5
- package/realtime-client/src/{pull-mutable-family-member.ts → pull-mutable-atom-family-member.ts} +5 -5
- package/realtime-client/src/{pull-mutable.ts → pull-mutable-atom.ts} +5 -5
- package/realtime-client/src/pull-selector-family-member.ts +42 -0
- package/realtime-client/src/pull-selector.ts +38 -0
- package/realtime-client/src/realtime-client-stores/client-main-store.ts +2 -2
- package/realtime-client/src/realtime-client-stores/client-sync-store.ts +7 -7
- package/realtime-client/src/sync-continuity.ts +321 -0
- package/realtime-client/src/sync-server-action.ts +22 -21
- package/realtime-client/src/sync-state.ts +3 -3
- package/realtime-react/dist/index.cjs +330 -15
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +26 -6
- package/realtime-react/dist/index.js +43 -12
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +6 -3
- package/realtime-react/src/use-pull-atom-family-member.ts +21 -0
- package/realtime-react/src/{use-pull.ts → use-pull-atom.ts} +6 -5
- package/realtime-react/src/{use-pull-mutable.ts → use-pull-mutable-atom.ts} +4 -3
- package/realtime-react/src/use-pull-mutable-family-member.ts +9 -4
- package/realtime-react/src/use-pull-selector-family-member.ts +21 -0
- package/realtime-react/src/{use-pull-family-member.ts → use-pull-selector.ts} +7 -5
- package/realtime-react/src/use-push.ts +3 -2
- package/realtime-react/src/use-server-action.ts +3 -2
- package/realtime-react/src/use-sync-continuity.ts +12 -0
- package/realtime-react/src/use-sync-server-action.ts +3 -2
- package/realtime-server/dist/index.cjs +582 -256
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +124 -49
- package/realtime-server/dist/index.js +566 -249
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +18 -2
- package/realtime-server/src/ipc-socket.ts +230 -0
- package/realtime-server/src/realtime-action-receiver.ts +8 -5
- package/realtime-server/src/realtime-action-synchronizer.ts +53 -35
- package/realtime-server/src/realtime-continuity-synchronizer.ts +247 -0
- package/realtime-server/src/realtime-family-provider.ts +37 -73
- package/realtime-server/src/realtime-mutable-family-provider.ts +26 -87
- package/realtime-server/src/realtime-mutable-provider.ts +3 -2
- package/realtime-server/src/realtime-server-stores/index.ts +3 -1
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +90 -0
- package/realtime-server/src/realtime-server-stores/server-room-store.ts +97 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +2 -72
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +14 -29
- package/realtime-server/src/realtime-state-provider.ts +3 -3
- package/realtime-server/src/realtime-state-receiver.ts +2 -3
- package/realtime-server/src/realtime-state-synchronizer.ts +3 -3
- package/realtime-testing/dist/index.cjs +28 -28
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.js +28 -27
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +38 -28
- package/src/atom.ts +49 -31
- package/src/get-state.ts +2 -11
- package/src/logger.ts +10 -5
- package/src/selector.ts +44 -25
- package/src/set-state.ts +1 -13
- package/src/silo.ts +7 -3
- package/src/subscribe.ts +2 -1
- package/src/timeline.ts +4 -4
- package/src/transaction.ts +13 -17
- package/src/validators.ts +15 -9
- package/dist/chunk-H4Q5FTPZ.js +0 -11
- package/dist/chunk-H4Q5FTPZ.js.map +0 -1
- package/internal/src/set-state/copy-mutable-in-transaction.ts +0 -19
package/src/transaction.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type { EnvironmentData
|
|
2
|
-
import {
|
|
1
|
+
import type { EnvironmentData } from "atom.io/internal"
|
|
2
|
+
import {
|
|
3
|
+
IMPLICIT,
|
|
4
|
+
actUponStore,
|
|
5
|
+
arbitrary,
|
|
6
|
+
createTransaction,
|
|
7
|
+
} from "atom.io/internal"
|
|
3
8
|
|
|
4
9
|
import type {
|
|
5
10
|
KeyedStateUpdate,
|
|
@@ -77,18 +82,9 @@ export function transaction<ƒ extends ƒn>(
|
|
|
77
82
|
return createTransaction(options, IMPLICIT.STORE)
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
export
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(...parameters: Parameters<ƒ>): ReturnType<ƒ> => {
|
|
87
|
-
const tx = withdraw(token, store)
|
|
88
|
-
if (tx) {
|
|
89
|
-
return tx.run(parameters, id)
|
|
90
|
-
}
|
|
91
|
-
throw new Error(
|
|
92
|
-
`Cannot run transaction "${token.key}": transaction not found in store "${store.config.name}".`,
|
|
93
|
-
)
|
|
94
|
-
}
|
|
85
|
+
export function runTransaction<ƒ extends ƒn>(
|
|
86
|
+
token: TransactionToken<ƒ>,
|
|
87
|
+
id = arbitrary(),
|
|
88
|
+
): (...parameters: Parameters<ƒ>) => ReturnType<ƒ> {
|
|
89
|
+
return actUponStore(token, id, IMPLICIT.STORE)
|
|
90
|
+
}
|
package/src/validators.ts
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
MutableAtomFamily,
|
|
3
|
+
MutableAtomFamilyToken,
|
|
3
4
|
MutableAtomToken,
|
|
4
5
|
ReadableFamily,
|
|
6
|
+
ReadableFamilyToken,
|
|
5
7
|
ReadableToken,
|
|
6
8
|
ReadonlySelectorFamily,
|
|
9
|
+
ReadonlySelectorFamilyToken,
|
|
7
10
|
ReadonlySelectorToken,
|
|
8
11
|
RegularAtomFamily,
|
|
12
|
+
RegularAtomFamilyToken,
|
|
9
13
|
RegularAtomToken,
|
|
10
14
|
WritableFamily,
|
|
15
|
+
WritableFamilyToken,
|
|
11
16
|
WritableSelectorFamily,
|
|
17
|
+
WritableSelectorFamilyToken,
|
|
12
18
|
WritableSelectorToken,
|
|
13
19
|
WritableToken,
|
|
14
20
|
} from "atom.io"
|
|
15
21
|
|
|
16
22
|
export type TokenType<
|
|
17
|
-
Comparison extends
|
|
23
|
+
Comparison extends ReadableFamilyToken<any, any> | ReadableToken<any>,
|
|
18
24
|
> = Comparison extends ReadableToken<infer RepresentedValue>
|
|
19
25
|
? RepresentedValue
|
|
20
|
-
: Comparison extends
|
|
26
|
+
: Comparison extends ReadableFamilyToken<infer RepresentedValue, any>
|
|
21
27
|
? RepresentedValue
|
|
22
28
|
: never
|
|
23
29
|
|
|
@@ -52,31 +58,31 @@ export function isToken<KnownToken extends ReadableToken<any>>(
|
|
|
52
58
|
return knownToken.key === unknownToken.key
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
export function belongsTo<Family extends
|
|
61
|
+
export function belongsTo<Family extends RegularAtomFamilyToken<any, any>>(
|
|
56
62
|
family: Family,
|
|
57
63
|
unknownToken: ReadableToken<any>,
|
|
58
64
|
): unknownToken is RegularAtomToken<TokenType<Family>>
|
|
59
|
-
export function belongsTo<Family extends
|
|
65
|
+
export function belongsTo<Family extends MutableAtomFamilyToken<any, any, any>>(
|
|
60
66
|
family: Family,
|
|
61
67
|
unknownToken: ReadableToken<any>,
|
|
62
68
|
): unknownToken is MutableAtomToken<TokenType<Family>, any>
|
|
63
|
-
export function belongsTo<Family extends
|
|
69
|
+
export function belongsTo<Family extends WritableSelectorFamilyToken<any, any>>(
|
|
64
70
|
family: Family,
|
|
65
71
|
unknownToken: ReadableToken<any>,
|
|
66
72
|
): unknownToken is WritableSelectorToken<TokenType<Family>>
|
|
67
|
-
export function belongsTo<Family extends
|
|
73
|
+
export function belongsTo<Family extends ReadonlySelectorFamilyToken<any, any>>(
|
|
68
74
|
family: Family,
|
|
69
75
|
unknownToken: ReadableToken<any>,
|
|
70
76
|
): unknownToken is ReadonlySelectorToken<TokenType<Family>>
|
|
71
|
-
export function belongsTo<Family extends
|
|
77
|
+
export function belongsTo<Family extends WritableFamilyToken<any, any>>(
|
|
72
78
|
family: Family,
|
|
73
79
|
unknownToken: ReadableToken<any>,
|
|
74
80
|
): unknownToken is WritableToken<TokenType<Family>>
|
|
75
|
-
export function belongsTo<Family extends
|
|
81
|
+
export function belongsTo<Family extends ReadableFamilyToken<any, any>>(
|
|
76
82
|
family: Family,
|
|
77
83
|
unknownToken: ReadableToken<any>,
|
|
78
84
|
): unknownToken is ReadableToken<TokenType<Family>>
|
|
79
|
-
export function belongsTo<Family extends
|
|
85
|
+
export function belongsTo<Family extends ReadableFamilyToken<any, any>>(
|
|
80
86
|
family: Family,
|
|
81
87
|
unknownToken: ReadableToken<any>,
|
|
82
88
|
): unknownToken is ReadableToken<TokenType<Family>> {
|
package/dist/chunk-H4Q5FTPZ.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// internal/src/transaction/is-root-store.ts
|
|
2
|
-
function isRootStore(store) {
|
|
3
|
-
return `epoch` in store.transactionMeta;
|
|
4
|
-
}
|
|
5
|
-
function isChildStore(store) {
|
|
6
|
-
return `phase` in store.transactionMeta;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { isChildStore, isRootStore };
|
|
10
|
-
//# sourceMappingURL=out.js.map
|
|
11
|
-
//# sourceMappingURL=chunk-H4Q5FTPZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../internal/src/transaction/is-root-store.ts"],"names":[],"mappings":";AAgBO,SAAS,YAAY,OAAkC;AAC7D,SAAO,WAAW,MAAM;AACzB;AAEO,SAAS,aAAa,OAAmC;AAC/D,SAAO,WAAW,MAAM;AACzB","sourcesContent":["import type { ƒn } from \"atom.io\"\n\nimport type { TransactionEpoch, TransactionProgress } from \".\"\nimport type { Store } from \"../store\"\n\nexport interface RootStore extends Store {\n\ttransactionMeta: TransactionEpoch\n\tparent: null\n\tchild: ChildStore | null\n}\nexport interface ChildStore extends Store {\n\ttransactionMeta: TransactionProgress<ƒn>\n\tparent: ChildStore | RootStore\n\tchild: ChildStore | null\n}\n\nexport function isRootStore(store: Store): store is RootStore {\n\treturn `epoch` in store.transactionMeta\n}\n\nexport function isChildStore(store: Store): store is ChildStore {\n\treturn `phase` in store.transactionMeta\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { newest } from ".."
|
|
2
|
-
import type { Atom, Store } from ".."
|
|
3
|
-
import { copyMutableIfNeeded } from "./copy-mutable-if-needed"
|
|
4
|
-
|
|
5
|
-
export function copyMutableIfWithinTransaction<T>(
|
|
6
|
-
oldValue: T,
|
|
7
|
-
atom: Atom<T>,
|
|
8
|
-
store: Store,
|
|
9
|
-
): T {
|
|
10
|
-
const target = newest(store)
|
|
11
|
-
const parent = target.parent
|
|
12
|
-
if (parent !== null) {
|
|
13
|
-
if (atom.type === `mutable_atom`) {
|
|
14
|
-
const copiedValue = copyMutableIfNeeded(atom, parent, target)
|
|
15
|
-
return copiedValue
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return oldValue
|
|
19
|
-
}
|