atom.io 0.38.1 → 0.39.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/internal/index.d.ts +115 -78
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +400 -276
- package/dist/internal/index.js.map +1 -1
- package/dist/main/index.d.ts +45 -35
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js.map +1 -1
- package/dist/realtime-client/index.js +5 -5
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-server/index.js +4 -4
- package/dist/realtime-server/index.js.map +1 -1
- package/package.json +10 -11
- package/src/internal/atom/create-regular-atom.ts +2 -6
- package/src/internal/caching.ts +2 -4
- package/src/internal/{ingest-updates → events}/ingest-atom-update.ts +4 -5
- package/src/internal/{ingest-updates → events}/ingest-creation-disposal.ts +37 -37
- package/src/internal/{ingest-updates → events}/ingest-selector-update.ts +5 -5
- package/src/internal/events/ingest-transaction-update.ts +45 -0
- package/src/internal/families/create-readonly-held-selector-family.ts +1 -1
- package/src/internal/families/create-readonly-pure-selector-family.ts +1 -1
- package/src/internal/families/create-regular-atom-family.ts +1 -1
- package/src/internal/families/create-writable-held-selector-family.ts +1 -1
- package/src/internal/families/create-writable-pure-selector-family.ts +1 -1
- package/src/internal/families/find-in-store.ts +2 -2
- package/src/internal/families/get-family-of-token.ts +1 -0
- package/src/internal/families/index.ts +0 -1
- package/src/internal/families/mint-in-store.ts +30 -64
- package/src/internal/get-state/get-from-store.ts +2 -3
- package/src/internal/get-state/read-or-compute-value.ts +4 -14
- package/src/internal/get-state/reduce-reference.ts +52 -11
- package/src/internal/index.ts +2 -2
- package/src/internal/junction.ts +177 -133
- package/src/internal/molecule.ts +3 -1
- package/src/internal/mutable/create-mutable-atom-family.ts +1 -1
- package/src/internal/overlays/index.ts +3 -0
- package/src/internal/overlays/map-overlay.ts +86 -0
- package/src/internal/{lazy-map.ts → overlays/relations-overlay.ts} +6 -6
- package/src/internal/overlays/set-overlay.ts +55 -0
- package/src/internal/selector/create-readonly-held-selector.ts +8 -11
- package/src/internal/selector/create-readonly-pure-selector.ts +8 -10
- package/src/internal/selector/create-writable-held-selector.ts +6 -6
- package/src/internal/selector/create-writable-pure-selector.ts +2 -2
- package/src/internal/selector/register-selector.ts +3 -4
- package/src/internal/set-state/dispatch-state-update.ts +45 -11
- package/src/internal/set-state/operate-on-store.ts +7 -7
- package/src/internal/set-state/set-atom.ts +1 -1
- package/src/internal/set-state/set-selector.ts +1 -1
- package/src/internal/store/withdraw.ts +4 -4
- package/src/internal/timeline/time-travel.ts +11 -11
- package/src/internal/transaction/apply-transaction.ts +5 -5
- package/src/internal/transaction/build-transaction.ts +17 -26
- package/src/internal/transaction/create-transaction.ts +1 -1
- package/src/internal/transaction/is-root-store.ts +2 -2
- package/src/main/events.ts +14 -3
- package/src/main/logger.ts +43 -32
- package/src/realtime-client/continuity/register-and-attempt-confirmed-update.ts +5 -5
- package/src/realtime-server/continuity/subscribe-to-continuity-perpectives.ts +4 -4
- package/src/internal/families/init-family-member.ts +0 -33
- package/src/internal/ingest-updates/ingest-transaction-update.ts +0 -47
- /package/src/internal/{ingest-updates → events}/index.ts +0 -0
package/src/main/logger.ts
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
const LOGGER_ICON_DICTIONARY = {
|
|
2
|
+
// Lifecycle
|
|
3
|
+
"🔨": `Create state`,
|
|
4
|
+
"🛠️": `Install state into store`,
|
|
5
|
+
// Families
|
|
6
|
+
"👪": `Family member added`,
|
|
7
|
+
"🔥": `Family member deleted`,
|
|
8
|
+
// Cache
|
|
9
|
+
"📃": `Copy mutable`,
|
|
10
|
+
"📖": `Read from cache`,
|
|
11
|
+
"📝": `Write to cache`,
|
|
12
|
+
"❔": `Cache miss`,
|
|
13
|
+
"✨": `Value derived`,
|
|
14
|
+
"⭐": `Value set`,
|
|
15
|
+
// Operations
|
|
16
|
+
"⭕": `Operation start`,
|
|
17
|
+
"🔴": `Operation complete`,
|
|
18
|
+
"🚫": `Operation blocked`,
|
|
19
|
+
"🟢": `Operation unblocked`,
|
|
20
|
+
// Selectors
|
|
21
|
+
"🗑": `Evict cached value`,
|
|
22
|
+
"🧹": `Prepare to evict`,
|
|
23
|
+
"🧮": `Computing selector`,
|
|
24
|
+
"🔌": `Register direct dependency`,
|
|
25
|
+
"🔍": `Discover root`,
|
|
26
|
+
// Transactions
|
|
27
|
+
"📁": `Stow update`,
|
|
28
|
+
"🛫": `Begin transaction`,
|
|
29
|
+
"🛄": `Apply transaction`,
|
|
30
|
+
"🛬": `Complete transaction`,
|
|
31
|
+
"💥": `Transaction caught error`,
|
|
32
|
+
"🪂": `Abort transaction`,
|
|
33
|
+
// Timelines
|
|
2
34
|
"⌛": `Timeline event fully captured`,
|
|
3
35
|
"⏩": `Timeline redo`,
|
|
4
36
|
"⏪": `Timeline undo`,
|
|
@@ -6,51 +38,30 @@ const LOGGER_ICON_DICTIONARY = {
|
|
|
6
38
|
"⏮️": `Transaction undo`,
|
|
7
39
|
"⏳": `Timeline event partially captured`,
|
|
8
40
|
"⏹️": `Time-travel complete`,
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"💣": `Dangerous action likely to cause bad errors`,
|
|
41
|
+
// Problems
|
|
42
|
+
"💣": `Dangerous action likely to cause bad errors down the line`,
|
|
12
43
|
"❗": `Dangerous action unless in development mode`,
|
|
13
44
|
"❌": `Conflict prevents attempted action`,
|
|
14
|
-
"⭕": `Operation start`,
|
|
15
|
-
"🔴": `Operation complete`,
|
|
16
|
-
"🚫": `Operation blocked`,
|
|
17
|
-
"🟢": `Operation unblocked`,
|
|
18
45
|
"🐞": `Possible bug in AtomIO`,
|
|
46
|
+
"💁": `Advice and guidance to the developer`,
|
|
47
|
+
// Subscriptions
|
|
19
48
|
"👀": `Subscription added`,
|
|
20
|
-
"
|
|
21
|
-
"👍": `Realtime acknowledgment`,
|
|
22
|
-
"👪": `Family member added`,
|
|
23
|
-
"💁": `Notice`,
|
|
24
|
-
"💥": `Caught`,
|
|
25
|
-
"📁": `Stow update`,
|
|
26
|
-
"📃": `Copy mutable`,
|
|
27
|
-
"📖": `Read state`,
|
|
28
|
-
"📝": `Write state`,
|
|
49
|
+
"🙈": `Subscription canceled`,
|
|
29
50
|
"📢": `Notify subscribers`,
|
|
30
|
-
"🔄": `Realtime transaction synchronized`,
|
|
31
|
-
"🔌": `Register dependency`,
|
|
32
|
-
"🔍": `Discover root`,
|
|
33
|
-
"🔥": `Delete state`,
|
|
34
|
-
"🔧": `Create mutable atom`,
|
|
35
|
-
"🔨": `Create immutable atom`,
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
"🙈": `Subscription canceled`,
|
|
52
|
+
// Realtime
|
|
39
53
|
"🚀": `Performance measure`,
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"🛫": `Begin transaction`,
|
|
43
|
-
"🛬": `Complete transaction`,
|
|
44
|
-
"🧮": `Computing selector`,
|
|
45
|
-
"🧹": `Prepare to evict`,
|
|
46
|
-
"🪂": `Abort transaction`,
|
|
54
|
+
"✅": `Realtime transaction success`,
|
|
55
|
+
"🔄": `Realtime transaction synchronized`,
|
|
47
56
|
"🤞": `Realtime optimistic update enqueued`,
|
|
48
57
|
"👈": `Realtime confirmed update enqueued`,
|
|
49
58
|
"🧑⚖️": `Realtime update beginning reconciliation`,
|
|
50
59
|
"🛎️": `Realtime transaction received`,
|
|
60
|
+
"👁": `Determining perspective`,
|
|
51
61
|
"🔭": `Determining realtime perspective`,
|
|
52
62
|
"🖌": `Redacting realtime update`,
|
|
53
|
-
"
|
|
63
|
+
"👋": `Realtime greeting`,
|
|
64
|
+
"👍": `Realtime acknowledgment`,
|
|
54
65
|
} as const
|
|
55
66
|
export type LoggerIcon = keyof typeof LOGGER_ICON_DICTIONARY
|
|
56
67
|
export type TokenDenomination =
|
|
@@ -3,7 +3,7 @@ import type { Fn, Store } from "atom.io/internal"
|
|
|
3
3
|
import {
|
|
4
4
|
actUponStore,
|
|
5
5
|
getEpochNumberOfContinuity,
|
|
6
|
-
|
|
6
|
+
ingestTransactionOutcomeEvent,
|
|
7
7
|
isRootStore,
|
|
8
8
|
setEpochNumberOfContinuity,
|
|
9
9
|
setIntoStore,
|
|
@@ -79,7 +79,7 @@ export const useRegisterAndAttemptConfirmedUpdate =
|
|
|
79
79
|
)
|
|
80
80
|
const reversedOptimisticUpdates = optimisticUpdates.toReversed()
|
|
81
81
|
for (const subsequentOptimistic of reversedOptimisticUpdates) {
|
|
82
|
-
|
|
82
|
+
ingestTransactionOutcomeEvent(store, subsequentOptimistic, `oldValue`)
|
|
83
83
|
}
|
|
84
84
|
store.logger.info(
|
|
85
85
|
`⏪`,
|
|
@@ -88,7 +88,7 @@ export const useRegisterAndAttemptConfirmedUpdate =
|
|
|
88
88
|
`undid optimistic updates:`,
|
|
89
89
|
reversedOptimisticUpdates,
|
|
90
90
|
)
|
|
91
|
-
|
|
91
|
+
ingestTransactionOutcomeEvent(store, optimisticUpdate, `oldValue`)
|
|
92
92
|
store.logger.info(
|
|
93
93
|
`⏪`,
|
|
94
94
|
`continuity`,
|
|
@@ -96,7 +96,7 @@ export const useRegisterAndAttemptConfirmedUpdate =
|
|
|
96
96
|
`undid zeroth optimistic update`,
|
|
97
97
|
optimisticUpdate,
|
|
98
98
|
)
|
|
99
|
-
|
|
99
|
+
ingestTransactionOutcomeEvent(store, confirmedUpdate, `newValue`)
|
|
100
100
|
store.logger.info(
|
|
101
101
|
`⏩`,
|
|
102
102
|
`continuity`,
|
|
@@ -200,7 +200,7 @@ export const useRegisterAndAttemptConfirmedUpdate =
|
|
|
200
200
|
continuityKey,
|
|
201
201
|
`integrating update #${confirmed.epoch} (${confirmed.token.key} ${confirmed.id})`,
|
|
202
202
|
)
|
|
203
|
-
|
|
203
|
+
ingestTransactionOutcomeEvent(store, confirmed, `newValue`)
|
|
204
204
|
socket.emit(`ack:${continuityKey}`, confirmed.epoch)
|
|
205
205
|
setEpochNumberOfContinuity(store, continuityKey, confirmed.epoch)
|
|
206
206
|
} else if (isRoot && continuityEpoch !== undefined) {
|
|
@@ -26,13 +26,13 @@ export function subscribeToContinuityPerspectives(
|
|
|
26
26
|
userViewState,
|
|
27
27
|
`sync-continuity:${continuityKey}:${userKey}:perspective:${perspective.resourceAtoms.key}`,
|
|
28
28
|
({ oldValue, newValue }) => {
|
|
29
|
-
const oldKeys = oldValue
|
|
29
|
+
const oldKeys = oldValue?.map((token) => token.key)
|
|
30
30
|
const newKeys = newValue.map((token) => token.key)
|
|
31
|
-
const concealed = oldValue
|
|
31
|
+
const concealed = oldValue?.filter(
|
|
32
32
|
(token) => !newKeys.includes(token.key),
|
|
33
33
|
)
|
|
34
34
|
const revealed = newValue
|
|
35
|
-
.filter((token) => !oldKeys
|
|
35
|
+
.filter((token) => !oldKeys?.includes(token.key))
|
|
36
36
|
.flatMap((token) => {
|
|
37
37
|
const resourceToken =
|
|
38
38
|
token.type === `mutable_atom` ? getJsonToken(store, token) : token
|
|
@@ -49,7 +49,7 @@ export function subscribeToContinuityPerspectives(
|
|
|
49
49
|
if (revealed.length > 0) {
|
|
50
50
|
socket?.emit(`reveal:${continuityKey}`, revealed)
|
|
51
51
|
}
|
|
52
|
-
if (concealed.length > 0) {
|
|
52
|
+
if (concealed && concealed.length > 0) {
|
|
53
53
|
socket?.emit(`conceal:${continuityKey}`, concealed)
|
|
54
54
|
}
|
|
55
55
|
},
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ReadableFamilyToken,
|
|
3
|
-
ReadableToken,
|
|
4
|
-
WritableFamilyToken,
|
|
5
|
-
WritableToken,
|
|
6
|
-
} from "atom.io"
|
|
7
|
-
import type { Canonical } from "atom.io/json"
|
|
8
|
-
|
|
9
|
-
import type { Store } from "../store"
|
|
10
|
-
import { withdraw } from "../store"
|
|
11
|
-
|
|
12
|
-
export function initFamilyMemberInStore<T, K extends Canonical, Key extends K>(
|
|
13
|
-
store: Store,
|
|
14
|
-
token: WritableFamilyToken<T, K>,
|
|
15
|
-
key: Key,
|
|
16
|
-
): WritableToken<T, K>
|
|
17
|
-
|
|
18
|
-
export function initFamilyMemberInStore<T, K extends Canonical, Key extends K>(
|
|
19
|
-
store: Store,
|
|
20
|
-
token: ReadableFamilyToken<T, K>,
|
|
21
|
-
key: Key,
|
|
22
|
-
): ReadableToken<T, K>
|
|
23
|
-
|
|
24
|
-
export function initFamilyMemberInStore(
|
|
25
|
-
store: Store,
|
|
26
|
-
token: ReadableFamilyToken<any, any>,
|
|
27
|
-
key: Canonical,
|
|
28
|
-
): ReadableToken<any> {
|
|
29
|
-
const family = withdraw(store, token)
|
|
30
|
-
const state = family(key)
|
|
31
|
-
|
|
32
|
-
return state
|
|
33
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { TransactionOutcomeEvent } from "atom.io"
|
|
2
|
-
|
|
3
|
-
import type { Store } from "../store"
|
|
4
|
-
import { ingestAtomUpdate } from "./ingest-atom-update"
|
|
5
|
-
import {
|
|
6
|
-
ingestCreationEvent,
|
|
7
|
-
ingestDisposalEvent,
|
|
8
|
-
ingestMoleculeCreationEvent,
|
|
9
|
-
ingestMoleculeDisposalEvent,
|
|
10
|
-
ingestMoleculeTransferEvent,
|
|
11
|
-
} from "./ingest-creation-disposal"
|
|
12
|
-
|
|
13
|
-
export function ingestTransactionUpdate(
|
|
14
|
-
applying: `newValue` | `oldValue`,
|
|
15
|
-
transactionUpdate: TransactionOutcomeEvent<any>,
|
|
16
|
-
store: Store,
|
|
17
|
-
): void {
|
|
18
|
-
const updates =
|
|
19
|
-
applying === `newValue`
|
|
20
|
-
? transactionUpdate.subEvents
|
|
21
|
-
: [...transactionUpdate.subEvents].reverse()
|
|
22
|
-
for (const updateFromTransaction of updates) {
|
|
23
|
-
switch (updateFromTransaction.type) {
|
|
24
|
-
case `atom_update`:
|
|
25
|
-
ingestAtomUpdate(applying, updateFromTransaction, store)
|
|
26
|
-
break
|
|
27
|
-
case `state_creation`:
|
|
28
|
-
ingestCreationEvent(updateFromTransaction, applying, store)
|
|
29
|
-
break
|
|
30
|
-
case `state_disposal`:
|
|
31
|
-
ingestDisposalEvent(updateFromTransaction, applying, store)
|
|
32
|
-
break
|
|
33
|
-
case `molecule_creation`:
|
|
34
|
-
ingestMoleculeCreationEvent(updateFromTransaction, applying, store)
|
|
35
|
-
break
|
|
36
|
-
case `molecule_disposal`:
|
|
37
|
-
ingestMoleculeDisposalEvent(updateFromTransaction, applying, store)
|
|
38
|
-
break
|
|
39
|
-
case `molecule_transfer`:
|
|
40
|
-
ingestMoleculeTransferEvent(updateFromTransaction, applying, store)
|
|
41
|
-
break
|
|
42
|
-
case `transaction_outcome`:
|
|
43
|
-
ingestTransactionUpdate(applying, updateFromTransaction, store)
|
|
44
|
-
break
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
File without changes
|