atom.io 0.6.8 → 0.6.9
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 +226 -258
- package/dist/index.d.ts +226 -258
- package/dist/index.js +28 -1917
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1877
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.d.mts +117 -171
- package/introspection/dist/index.d.ts +117 -171
- package/introspection/dist/index.js +6 -346
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/index.mjs +5 -324
- package/introspection/dist/index.mjs.map +1 -1
- package/json/dist/index.d.mts +32 -1
- package/json/dist/index.d.ts +32 -1
- package/json/dist/index.js +31 -48
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs +6 -14
- package/json/dist/index.mjs.map +1 -1
- package/package.json +22 -14
- package/react/dist/index.js +34 -83
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +7 -43
- package/react/dist/index.mjs.map +1 -1
- package/react-devtools/dist/index.css +1 -50
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +124 -188
- package/react-devtools/dist/index.d.ts +124 -188
- package/react-devtools/dist/index.js +56 -4674
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +19 -4642
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.d.mts +1 -3
- package/realtime/dist/index.d.ts +1 -3
- package/realtime/dist/index.js +26 -184
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs +4 -148
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.d.mts +2 -4
- package/realtime-react/dist/index.d.ts +2 -4
- package/realtime-react/dist/index.js +41 -214
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs +9 -169
- package/realtime-react/dist/index.mjs.map +1 -1
- package/src/atom.ts +4 -3
- package/src/index.ts +12 -9
- package/src/logger.ts +5 -5
- package/src/selector.ts +3 -3
- package/src/silo.ts +36 -39
- package/src/subscribe.ts +24 -19
- package/src/timeline.ts +9 -4
- package/src/transaction.ts +3 -4
- package/src/internal/atom-internal.ts +0 -54
- package/src/internal/families-internal.ts +0 -144
- package/src/internal/get.ts +0 -129
- package/src/internal/index.ts +0 -15
- package/src/internal/is-default.ts +0 -35
- package/src/internal/operation.ts +0 -139
- package/src/internal/selector/create-read-write-selector.ts +0 -68
- package/src/internal/selector/create-readonly-selector.ts +0 -48
- package/src/internal/selector/index.ts +0 -4
- package/src/internal/selector/lookup-selector-sources.ts +0 -16
- package/src/internal/selector/register-selector.ts +0 -57
- package/src/internal/selector/trace-selector-atoms.ts +0 -43
- package/src/internal/selector/update-selector-atoms.ts +0 -33
- package/src/internal/selector-internal.ts +0 -58
- package/src/internal/set.ts +0 -99
- package/src/internal/store.ts +0 -151
- package/src/internal/subscribe-internal.ts +0 -88
- package/src/internal/time-travel-internal.ts +0 -91
- package/src/internal/timeline/add-atom-to-timeline.ts +0 -168
- package/src/internal/timeline/index.ts +0 -1
- package/src/internal/timeline-internal.ts +0 -107
- package/src/internal/transaction/abort-transaction.ts +0 -12
- package/src/internal/transaction/apply-transaction.ts +0 -57
- package/src/internal/transaction/build-transaction.ts +0 -33
- package/src/internal/transaction/index.ts +0 -25
- package/src/internal/transaction/redo-transaction.ts +0 -23
- package/src/internal/transaction/undo-transaction.ts +0 -23
- package/src/internal/transaction-internal.ts +0 -61
- package/src/introspection/attach-atom-index.ts +0 -73
- package/src/introspection/attach-introspection-states.ts +0 -42
- package/src/introspection/attach-selector-index.ts +0 -77
- package/src/introspection/attach-timeline-family.ts +0 -59
- package/src/introspection/attach-timeline-index.ts +0 -36
- package/src/introspection/attach-transaction-index.ts +0 -38
- package/src/introspection/attach-transaction-logs.ts +0 -40
- package/src/introspection/index.ts +0 -20
- package/src/json/index.ts +0 -1
- package/src/json/select-json.ts +0 -18
- package/src/react/index.ts +0 -2
- package/src/react/store-context.tsx +0 -13
- package/src/react/store-hooks.ts +0 -47
- package/src/react-devtools/AtomIODevtools.tsx +0 -107
- package/src/react-devtools/Button.tsx +0 -24
- package/src/react-devtools/StateEditor.tsx +0 -74
- package/src/react-devtools/StateIndex.tsx +0 -156
- package/src/react-devtools/TimelineIndex.tsx +0 -92
- package/src/react-devtools/TransactionIndex.tsx +0 -70
- package/src/react-devtools/Updates.tsx +0 -145
- package/src/react-devtools/devtools.scss +0 -310
- package/src/react-devtools/index.ts +0 -72
- package/src/react-explorer/AtomIOExplorer.tsx +0 -218
- package/src/react-explorer/explorer-effects.ts +0 -20
- package/src/react-explorer/explorer-states.ts +0 -217
- package/src/react-explorer/index.ts +0 -23
- package/src/react-explorer/space-states.ts +0 -72
- package/src/react-explorer/view-states.ts +0 -41
- package/src/realtime/README.md +0 -33
- package/src/realtime/hook-composition/expose-family.ts +0 -101
- package/src/realtime/hook-composition/expose-single.ts +0 -38
- package/src/realtime/hook-composition/expose-timeline.ts +0 -60
- package/src/realtime/hook-composition/index.ts +0 -12
- package/src/realtime/hook-composition/receive-state.ts +0 -29
- package/src/realtime/hook-composition/receive-transaction.ts +0 -18
- package/src/realtime/index.ts +0 -1
- package/src/realtime-react/index.ts +0 -3
- package/src/realtime-react/realtime-context.tsx +0 -30
- package/src/realtime-react/realtime-hooks.ts +0 -39
- package/src/realtime-react/realtime-state.ts +0 -10
- package/src/realtime-react/use-pull-family-member.ts +0 -26
- package/src/realtime-react/use-pull-family.ts +0 -24
- package/src/realtime-react/use-pull.ts +0 -24
- package/src/realtime-react/use-push.ts +0 -27
- package/src/realtime-react/use-server-action.ts +0 -33
- package/src/realtime-testing/index.ts +0 -1
- package/src/realtime-testing/setup-realtime-test.tsx +0 -159
- package/src/tracker/index.ts +0 -3
- package/src/tracker/tracker.ts +0 -61
- package/src/web-effects/index.ts +0 -1
- package/src/web-effects/storage.ts +0 -30
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Store } from ".."
|
|
2
|
-
|
|
3
|
-
export const buildTransaction = (
|
|
4
|
-
key: string,
|
|
5
|
-
params: any[],
|
|
6
|
-
store: Store,
|
|
7
|
-
): void => {
|
|
8
|
-
store.transactionStatus = {
|
|
9
|
-
key,
|
|
10
|
-
phase: `building`,
|
|
11
|
-
time: Date.now(),
|
|
12
|
-
core: {
|
|
13
|
-
atoms: new Map(store.atoms),
|
|
14
|
-
atomsThatAreDefault: store.atomsThatAreDefault,
|
|
15
|
-
operation: { open: false },
|
|
16
|
-
readonlySelectors: new Map(store.readonlySelectors),
|
|
17
|
-
timelines: new Map(store.timelines),
|
|
18
|
-
timelineAtoms: store.timelineAtoms,
|
|
19
|
-
transactions: new Map(store.transactions),
|
|
20
|
-
selectorAtoms: store.selectorAtoms,
|
|
21
|
-
selectorGraph: store.selectorGraph,
|
|
22
|
-
selectors: new Map(store.selectors),
|
|
23
|
-
valueMap: new Map(store.valueMap),
|
|
24
|
-
},
|
|
25
|
-
atomUpdates: [],
|
|
26
|
-
params,
|
|
27
|
-
output: undefined,
|
|
28
|
-
}
|
|
29
|
-
store.config.logger?.info(
|
|
30
|
-
`🛫`,
|
|
31
|
-
`transaction "${key}" started in store "${store.config.name}"`,
|
|
32
|
-
)
|
|
33
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ƒn } from "~/packages/anvl/src/function"
|
|
2
|
-
|
|
3
|
-
import type { StoreCore } from ".."
|
|
4
|
-
import type { StateUpdate, TransactionUpdate } from "../.."
|
|
5
|
-
|
|
6
|
-
export * from "./abort-transaction"
|
|
7
|
-
export * from "./apply-transaction"
|
|
8
|
-
export * from "./build-transaction"
|
|
9
|
-
export * from "./redo-transaction"
|
|
10
|
-
export * from "./undo-transaction"
|
|
11
|
-
|
|
12
|
-
export const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const
|
|
13
|
-
export type TransactionPhase = typeof TRANSACTION_PHASES[number]
|
|
14
|
-
|
|
15
|
-
export type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
|
|
16
|
-
phase: `applying` | `building`
|
|
17
|
-
time: number
|
|
18
|
-
core: StoreCore
|
|
19
|
-
}
|
|
20
|
-
export type TransactionIdle = {
|
|
21
|
-
phase: `idle`
|
|
22
|
-
}
|
|
23
|
-
export type TransactionStatus<ƒ extends ƒn> =
|
|
24
|
-
| TransactionIdle
|
|
25
|
-
| TransactionUpdateInProgress<ƒ>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ƒn } from "~/packages/anvl/src/function"
|
|
2
|
-
|
|
3
|
-
import type { Store } from ".."
|
|
4
|
-
import { withdraw } from ".."
|
|
5
|
-
import type { AtomToken, TransactionUpdate } from "../.."
|
|
6
|
-
import { setState } from "../.."
|
|
7
|
-
|
|
8
|
-
export const redoTransactionUpdate = <ƒ extends ƒn>(
|
|
9
|
-
update: TransactionUpdate<ƒ>,
|
|
10
|
-
store: Store,
|
|
11
|
-
): void => {
|
|
12
|
-
store.config.logger?.info(` ⏭ redo transaction "${update.key}" (redo)`)
|
|
13
|
-
for (const { key, newValue } of update.atomUpdates) {
|
|
14
|
-
const token: AtomToken<unknown> = { key, type: `atom` }
|
|
15
|
-
const state = withdraw(token, store)
|
|
16
|
-
if (state === null) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
`State "${token.key}" not found in this store. This is surprising, because we are navigating the history of the store.`,
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
setState(state, newValue, store)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ƒn } from "~/packages/anvl/src/function"
|
|
2
|
-
|
|
3
|
-
import type { Store } from ".."
|
|
4
|
-
import { withdraw } from ".."
|
|
5
|
-
import type { AtomToken, TransactionUpdate } from "../.."
|
|
6
|
-
import { setState } from "../.."
|
|
7
|
-
|
|
8
|
-
export const undoTransactionUpdate = <ƒ extends ƒn>(
|
|
9
|
-
update: TransactionUpdate<ƒ>,
|
|
10
|
-
store: Store,
|
|
11
|
-
): void => {
|
|
12
|
-
store.config.logger?.info(` ⏮ undo transaction "${update.key}" (undo)`)
|
|
13
|
-
for (const { key, oldValue } of update.atomUpdates) {
|
|
14
|
-
const token: AtomToken<unknown> = { key, type: `atom` }
|
|
15
|
-
const state = withdraw(token, store)
|
|
16
|
-
if (state === null) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
`State "${token.key}" not found in this store. This is surprising, because we are navigating the history of the store.`,
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
setState(state, oldValue, store)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { ƒn } from "~/packages/anvl/src/function"
|
|
2
|
-
|
|
3
|
-
import type { Store, StoreCore } from "."
|
|
4
|
-
import {
|
|
5
|
-
Subject,
|
|
6
|
-
abortTransaction,
|
|
7
|
-
applyTransaction,
|
|
8
|
-
buildTransaction,
|
|
9
|
-
deposit,
|
|
10
|
-
IMPLICIT,
|
|
11
|
-
} from "."
|
|
12
|
-
import type { TransactionOptions, TransactionToken, TransactionUpdate } from ".."
|
|
13
|
-
import { getState, setState } from ".."
|
|
14
|
-
|
|
15
|
-
export type Transaction<ƒ extends ƒn> = {
|
|
16
|
-
key: string
|
|
17
|
-
type: `transaction`
|
|
18
|
-
install: (store: Store) => void
|
|
19
|
-
subject: Subject<TransactionUpdate<ƒ>>
|
|
20
|
-
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function transaction__INTERNAL<ƒ extends ƒn>(
|
|
24
|
-
options: TransactionOptions<ƒ>,
|
|
25
|
-
store: Store = IMPLICIT.STORE,
|
|
26
|
-
): TransactionToken<ƒ> {
|
|
27
|
-
const newTransaction: Transaction<ƒ> = {
|
|
28
|
-
key: options.key,
|
|
29
|
-
type: `transaction`,
|
|
30
|
-
run: (...params: Parameters<ƒ>) => {
|
|
31
|
-
buildTransaction(options.key, params, store)
|
|
32
|
-
try {
|
|
33
|
-
const output = options.do(
|
|
34
|
-
{
|
|
35
|
-
get: (token) => getState(token, store),
|
|
36
|
-
set: (token, value) => setState(token, value, store),
|
|
37
|
-
},
|
|
38
|
-
...params,
|
|
39
|
-
)
|
|
40
|
-
applyTransaction(output, store)
|
|
41
|
-
return output
|
|
42
|
-
} catch (thrown) {
|
|
43
|
-
abortTransaction(store)
|
|
44
|
-
store.config.logger?.error(`Transaction ${options.key} failed`, thrown)
|
|
45
|
-
throw thrown
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
install: (store) => transaction__INTERNAL(options, store),
|
|
49
|
-
subject: new Subject(),
|
|
50
|
-
}
|
|
51
|
-
const core = target(store)
|
|
52
|
-
core.transactions.set(newTransaction.key, newTransaction)
|
|
53
|
-
const token = deposit(newTransaction)
|
|
54
|
-
store.subject.transactionCreation.next(token)
|
|
55
|
-
return token
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const target = (store: Store = IMPLICIT.STORE): StoreCore =>
|
|
59
|
-
store.transactionStatus.phase === `building`
|
|
60
|
-
? store.transactionStatus.core
|
|
61
|
-
: store
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { AtomToken, ReadonlySelectorToken } from "atom.io"
|
|
2
|
-
import { __INTERNAL__ } from "atom.io"
|
|
3
|
-
|
|
4
|
-
import type { StateTokenIndex } from "."
|
|
5
|
-
|
|
6
|
-
export type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>
|
|
7
|
-
|
|
8
|
-
export const attachAtomIndex = (
|
|
9
|
-
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
10
|
-
): ReadonlySelectorToken<AtomTokenIndex> => {
|
|
11
|
-
const atomTokenIndexState__INTERNAL =
|
|
12
|
-
__INTERNAL__.atom__INTERNAL<AtomTokenIndex>(
|
|
13
|
-
{
|
|
14
|
-
key: `👁🗨 Atom Token Index (Internal)`,
|
|
15
|
-
default: () =>
|
|
16
|
-
[...store.atoms]
|
|
17
|
-
.filter(([key]) => !key.includes(`👁🗨`))
|
|
18
|
-
.reduce<AtomTokenIndex>((acc, [key]) => {
|
|
19
|
-
acc[key] = { key, type: `atom` }
|
|
20
|
-
return acc
|
|
21
|
-
}, {}),
|
|
22
|
-
effects: [
|
|
23
|
-
({ setSelf }) => {
|
|
24
|
-
store.subject.atomCreation.subscribe((atomToken) => {
|
|
25
|
-
if (store.operation.open) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
if (atomToken.key.includes(`👁🗨`)) {
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
setSelf((state) => {
|
|
32
|
-
const { key, family } = atomToken
|
|
33
|
-
if (family) {
|
|
34
|
-
const { key: familyKey, subKey } = family
|
|
35
|
-
const current = state[familyKey]
|
|
36
|
-
if (current === undefined || `familyMembers` in current) {
|
|
37
|
-
const familyKeyState = current || {
|
|
38
|
-
key: familyKey,
|
|
39
|
-
familyMembers: {},
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
...state,
|
|
43
|
-
[familyKey]: {
|
|
44
|
-
...familyKeyState,
|
|
45
|
-
familyMembers: {
|
|
46
|
-
...familyKeyState.familyMembers,
|
|
47
|
-
[subKey]: atomToken,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
...state,
|
|
55
|
-
[key]: atomToken,
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
undefined,
|
|
63
|
-
store,
|
|
64
|
-
)
|
|
65
|
-
return __INTERNAL__.selector__INTERNAL(
|
|
66
|
-
{
|
|
67
|
-
key: `👁🗨 Atom Token Index`,
|
|
68
|
-
get: ({ get }) => get(atomTokenIndexState__INTERNAL),
|
|
69
|
-
},
|
|
70
|
-
undefined,
|
|
71
|
-
store,
|
|
72
|
-
)
|
|
73
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { __INTERNAL__ } from "atom.io"
|
|
2
|
-
import type {
|
|
3
|
-
ReadonlySelectorFamily,
|
|
4
|
-
ReadonlySelectorToken,
|
|
5
|
-
TimelineToken,
|
|
6
|
-
TimelineUpdate,
|
|
7
|
-
TransactionToken,
|
|
8
|
-
TransactionUpdate,
|
|
9
|
-
} from "atom.io"
|
|
10
|
-
|
|
11
|
-
import type { ƒn } from "~/packages/anvl/src/function"
|
|
12
|
-
|
|
13
|
-
import { attachAtomIndex, type AtomTokenIndex } from "./attach-atom-index"
|
|
14
|
-
import {
|
|
15
|
-
attachSelectorIndex,
|
|
16
|
-
type SelectorTokenIndex,
|
|
17
|
-
} from "./attach-selector-index"
|
|
18
|
-
import { attachTimelineFamily } from "./attach-timeline-family"
|
|
19
|
-
import { attachTimelineIndex } from "./attach-timeline-index"
|
|
20
|
-
import { attachTransactionIndex } from "./attach-transaction-index"
|
|
21
|
-
import { attachTransactionLogs } from "./attach-transaction-logs"
|
|
22
|
-
import type { Timeline } from "../internal"
|
|
23
|
-
|
|
24
|
-
export const attachIntrospectionStates = (
|
|
25
|
-
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
26
|
-
): {
|
|
27
|
-
atomIndex: ReadonlySelectorToken<AtomTokenIndex>
|
|
28
|
-
selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>
|
|
29
|
-
transactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>
|
|
30
|
-
findTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<ƒn>[]>
|
|
31
|
-
timelineIndex: ReadonlySelectorToken<TimelineToken[]>
|
|
32
|
-
findTimelineState: ReadonlySelectorFamily<Timeline>
|
|
33
|
-
} => {
|
|
34
|
-
return {
|
|
35
|
-
atomIndex: attachAtomIndex(store),
|
|
36
|
-
selectorIndex: attachSelectorIndex(store),
|
|
37
|
-
transactionIndex: attachTransactionIndex(store),
|
|
38
|
-
findTransactionLogState: attachTransactionLogs(store),
|
|
39
|
-
timelineIndex: attachTimelineIndex(store),
|
|
40
|
-
findTimelineState: attachTimelineFamily(store),
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { __INTERNAL__ } from "atom.io"
|
|
2
|
-
import type { ReadonlySelectorToken, SelectorToken } from "atom.io"
|
|
3
|
-
|
|
4
|
-
import type { StateTokenIndex } from "."
|
|
5
|
-
|
|
6
|
-
export type SelectorTokenIndex = StateTokenIndex<
|
|
7
|
-
ReadonlySelectorToken<unknown> | SelectorToken<unknown>
|
|
8
|
-
>
|
|
9
|
-
|
|
10
|
-
export const attachSelectorIndex = (
|
|
11
|
-
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
12
|
-
): ReadonlySelectorToken<SelectorTokenIndex> => {
|
|
13
|
-
const readonlySelectorTokenIndexState__INTERNAL =
|
|
14
|
-
__INTERNAL__.atom__INTERNAL<SelectorTokenIndex>(
|
|
15
|
-
{
|
|
16
|
-
key: `👁🗨 Selector Token Index (Internal)`,
|
|
17
|
-
default: () =>
|
|
18
|
-
Object.assign(
|
|
19
|
-
[...store.readonlySelectors]
|
|
20
|
-
.filter(([key]) => !key.includes(`👁🗨`))
|
|
21
|
-
.reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
22
|
-
acc[key] = { key, type: `readonly_selector` }
|
|
23
|
-
return acc
|
|
24
|
-
}, {}),
|
|
25
|
-
[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
26
|
-
acc[key] = { key, type: `selector` }
|
|
27
|
-
return acc
|
|
28
|
-
}, {}),
|
|
29
|
-
),
|
|
30
|
-
effects: [
|
|
31
|
-
({ setSelf }) => {
|
|
32
|
-
store.subject.selectorCreation.subscribe((selectorToken) => {
|
|
33
|
-
if (store.operation.open) {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
if (selectorToken.key.includes(`👁🗨`)) {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
setSelf((state) => {
|
|
40
|
-
const { key, family } = selectorToken
|
|
41
|
-
if (family) {
|
|
42
|
-
const { key: familyKey, subKey } = family
|
|
43
|
-
const current = state[familyKey]
|
|
44
|
-
if (current === undefined || `familyMembers` in current) {
|
|
45
|
-
const familyKeyState = current || {
|
|
46
|
-
key: familyKey,
|
|
47
|
-
familyMembers: {},
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
...state,
|
|
51
|
-
[familyKey]: {
|
|
52
|
-
...familyKeyState,
|
|
53
|
-
familyMembers: {
|
|
54
|
-
...familyKeyState.familyMembers,
|
|
55
|
-
[subKey]: selectorToken,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
...state,
|
|
63
|
-
[key]: selectorToken,
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
undefined,
|
|
71
|
-
store,
|
|
72
|
-
)
|
|
73
|
-
return __INTERNAL__.selector__INTERNAL({
|
|
74
|
-
key: `👁🗨 Selector Token Index`,
|
|
75
|
-
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
|
|
76
|
-
})
|
|
77
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { ReadonlySelectorFamily, Store } from "atom.io"
|
|
2
|
-
import { __INTERNAL__, timeline } from "atom.io"
|
|
3
|
-
|
|
4
|
-
import { withdraw, type Timeline, Subject } from "../internal"
|
|
5
|
-
|
|
6
|
-
export const attachTimelineFamily = (
|
|
7
|
-
store: Store = __INTERNAL__.IMPLICIT.STORE,
|
|
8
|
-
): ReadonlySelectorFamily<Timeline> => {
|
|
9
|
-
const findTimelineLogState__INTERNAL = __INTERNAL__.atomFamily__INTERNAL<
|
|
10
|
-
Timeline,
|
|
11
|
-
string
|
|
12
|
-
>(
|
|
13
|
-
{
|
|
14
|
-
key: `👁🗨 Timeline Update Log (Internal)`,
|
|
15
|
-
default: (key) =>
|
|
16
|
-
store.timelines.get(key) ?? {
|
|
17
|
-
key: ``,
|
|
18
|
-
at: 0,
|
|
19
|
-
timeTraveling: null,
|
|
20
|
-
history: [],
|
|
21
|
-
selectorTime: null,
|
|
22
|
-
transactionKey: null,
|
|
23
|
-
install: () => {},
|
|
24
|
-
subject: new Subject(),
|
|
25
|
-
},
|
|
26
|
-
effects: (key) => [
|
|
27
|
-
({ setSelf }) => {
|
|
28
|
-
const tl = store.timelines.get(key)
|
|
29
|
-
tl?.subject.subscribe((_) => {
|
|
30
|
-
if (store.operation.open === true) {
|
|
31
|
-
const subscription = store.subject.operationStatus.subscribe(
|
|
32
|
-
(operationStatus) => {
|
|
33
|
-
if (operationStatus.open === false) {
|
|
34
|
-
subscription.unsubscribe()
|
|
35
|
-
setSelf({ ...tl })
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
)
|
|
39
|
-
} else {
|
|
40
|
-
setSelf({ ...tl })
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
store,
|
|
47
|
-
)
|
|
48
|
-
const findTimelineLogState = __INTERNAL__.selectorFamily__INTERNAL<
|
|
49
|
-
Timeline,
|
|
50
|
-
string
|
|
51
|
-
>(
|
|
52
|
-
{
|
|
53
|
-
key: `👁🗨 Timeline Update Log`,
|
|
54
|
-
get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key)),
|
|
55
|
-
},
|
|
56
|
-
store,
|
|
57
|
-
)
|
|
58
|
-
return findTimelineLogState
|
|
59
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { ReadonlySelectorToken, Store, TimelineToken } from "atom.io"
|
|
2
|
-
import { __INTERNAL__ } from "atom.io"
|
|
3
|
-
|
|
4
|
-
export const attachTimelineIndex = (
|
|
5
|
-
store: Store = __INTERNAL__.IMPLICIT.STORE,
|
|
6
|
-
): ReadonlySelectorToken<TimelineToken[]> => {
|
|
7
|
-
const timelineTokenIndexState__INTERNAL = __INTERNAL__.atom__INTERNAL<
|
|
8
|
-
TimelineToken[]
|
|
9
|
-
>(
|
|
10
|
-
{
|
|
11
|
-
key: `👁🗨 Timeline Token Index (Internal)`,
|
|
12
|
-
default: () =>
|
|
13
|
-
[...store.timelines].map(([key]) => {
|
|
14
|
-
return { key, type: `timeline` }
|
|
15
|
-
}),
|
|
16
|
-
effects: [
|
|
17
|
-
({ setSelf }) => {
|
|
18
|
-
store.subject.timelineCreation.subscribe((timelineToken) => {
|
|
19
|
-
setSelf((state) => [...state, timelineToken])
|
|
20
|
-
})
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
undefined,
|
|
25
|
-
store,
|
|
26
|
-
)
|
|
27
|
-
const timelineTokenIndex = __INTERNAL__.selector__INTERNAL(
|
|
28
|
-
{
|
|
29
|
-
key: `👁🗨 Timeline Token Index`,
|
|
30
|
-
get: ({ get }) => get(timelineTokenIndexState__INTERNAL),
|
|
31
|
-
},
|
|
32
|
-
undefined,
|
|
33
|
-
store,
|
|
34
|
-
)
|
|
35
|
-
return timelineTokenIndex
|
|
36
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ReadonlySelectorToken, TransactionToken } from "atom.io"
|
|
2
|
-
import { __INTERNAL__ } from "atom.io"
|
|
3
|
-
|
|
4
|
-
import type { ƒn } from "~/packages/anvl/src/function"
|
|
5
|
-
|
|
6
|
-
export const attachTransactionIndex = (
|
|
7
|
-
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
8
|
-
): ReadonlySelectorToken<TransactionToken<ƒn>[]> => {
|
|
9
|
-
const transactionTokenIndexState__INTERNAL = __INTERNAL__.atom__INTERNAL<
|
|
10
|
-
TransactionToken<ƒn>[]
|
|
11
|
-
>(
|
|
12
|
-
{
|
|
13
|
-
key: `👁🗨 Transaction Token Index (Internal)`,
|
|
14
|
-
default: () =>
|
|
15
|
-
[...store.transactions].map(([key]) => {
|
|
16
|
-
return { key, type: `transaction` }
|
|
17
|
-
}),
|
|
18
|
-
effects: [
|
|
19
|
-
({ setSelf }) => {
|
|
20
|
-
store.subject.transactionCreation.subscribe((transactionToken) => {
|
|
21
|
-
setSelf((state) => [...state, transactionToken])
|
|
22
|
-
})
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
undefined,
|
|
27
|
-
store,
|
|
28
|
-
)
|
|
29
|
-
const transactionTokenIndex = __INTERNAL__.selector__INTERNAL(
|
|
30
|
-
{
|
|
31
|
-
key: `👁🗨 Transaction Token Index`,
|
|
32
|
-
get: ({ get }) => get(transactionTokenIndexState__INTERNAL),
|
|
33
|
-
},
|
|
34
|
-
undefined,
|
|
35
|
-
store,
|
|
36
|
-
)
|
|
37
|
-
return transactionTokenIndex
|
|
38
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { ReadonlySelectorFamily, TransactionUpdate } from "atom.io"
|
|
2
|
-
import { __INTERNAL__ } from "atom.io"
|
|
3
|
-
|
|
4
|
-
import type { ƒn } from "~/packages/anvl/src/function"
|
|
5
|
-
|
|
6
|
-
export const attachTransactionLogs = (
|
|
7
|
-
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
8
|
-
): ReadonlySelectorFamily<TransactionUpdate<ƒn>[]> => {
|
|
9
|
-
const findTransactionUpdateLog = __INTERNAL__.atomFamily__INTERNAL<
|
|
10
|
-
TransactionUpdate<ƒn>[],
|
|
11
|
-
string
|
|
12
|
-
>(
|
|
13
|
-
{
|
|
14
|
-
key: `👁🗨 Transaction Update Log (Internal)`,
|
|
15
|
-
default: () => [],
|
|
16
|
-
effects: (key) => [
|
|
17
|
-
({ setSelf }) => {
|
|
18
|
-
const tx = store.transactions.get(key)
|
|
19
|
-
tx?.subject.subscribe((transactionUpdate) => {
|
|
20
|
-
if (transactionUpdate.key === key) {
|
|
21
|
-
setSelf((state) => [...state, transactionUpdate])
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
store,
|
|
28
|
-
)
|
|
29
|
-
const findTransactionUpdateLogState = __INTERNAL__.selectorFamily__INTERNAL<
|
|
30
|
-
TransactionUpdate<ƒn>[],
|
|
31
|
-
string
|
|
32
|
-
>(
|
|
33
|
-
{
|
|
34
|
-
key: `👁🗨 Transaction Update Log`,
|
|
35
|
-
get: (key) => ({ get }) => get(findTransactionUpdateLog(key)),
|
|
36
|
-
},
|
|
37
|
-
store,
|
|
38
|
-
)
|
|
39
|
-
return findTransactionUpdateLogState
|
|
40
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "atom.io"
|
|
2
|
-
|
|
3
|
-
export * from "./attach-introspection-states"
|
|
4
|
-
|
|
5
|
-
export type FamilyNode<
|
|
6
|
-
Token extends
|
|
7
|
-
| AtomToken<unknown>
|
|
8
|
-
| ReadonlySelectorToken<unknown>
|
|
9
|
-
| SelectorToken<unknown>,
|
|
10
|
-
> = {
|
|
11
|
-
key: string
|
|
12
|
-
familyMembers: Record<string, Token>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type StateTokenIndex<
|
|
16
|
-
Token extends
|
|
17
|
-
| AtomToken<unknown>
|
|
18
|
-
| ReadonlySelectorToken<unknown>
|
|
19
|
-
| SelectorToken<unknown>,
|
|
20
|
-
> = Record<string, FamilyNode<Token> | Token>
|
package/src/json/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./select-json"
|
package/src/json/select-json.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as AtomIO from "atom.io"
|
|
2
|
-
|
|
3
|
-
import type { Json, JsonInterface } from "~/packages/anvl/src/json"
|
|
4
|
-
|
|
5
|
-
export const selectJson = <T, J extends Json.Serializable>(
|
|
6
|
-
atom: AtomIO.AtomToken<T>,
|
|
7
|
-
transform: JsonInterface<T, J>,
|
|
8
|
-
store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE,
|
|
9
|
-
): AtomIO.SelectorToken<J> =>
|
|
10
|
-
AtomIO.__INTERNAL__.selector__INTERNAL(
|
|
11
|
-
{
|
|
12
|
-
key: `${atom.key}JSON`,
|
|
13
|
-
get: ({ get }) => transform.toJson(get(atom)),
|
|
14
|
-
set: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),
|
|
15
|
-
},
|
|
16
|
-
undefined,
|
|
17
|
-
store,
|
|
18
|
-
)
|
package/src/react/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as AtomIO from "atom.io"
|
|
2
|
-
import * as React from "react"
|
|
3
|
-
|
|
4
|
-
export const StoreContext = React.createContext<AtomIO.Store>(
|
|
5
|
-
AtomIO.__INTERNAL__.IMPLICIT.STORE,
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
export const StoreProvider: React.FC<{
|
|
9
|
-
children: React.ReactNode
|
|
10
|
-
store?: AtomIO.Store
|
|
11
|
-
}> = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => (
|
|
12
|
-
<StoreContext.Provider value={store}>{children}</StoreContext.Provider>
|
|
13
|
-
)
|
package/src/react/store-hooks.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as AtomIO from "atom.io"
|
|
2
|
-
import * as React from "react"
|
|
3
|
-
|
|
4
|
-
import type { Modifier } from "~/packages/anvl/src/function"
|
|
5
|
-
|
|
6
|
-
import { StoreContext } from "./store-context"
|
|
7
|
-
|
|
8
|
-
export type StoreHooks = {
|
|
9
|
-
useI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void
|
|
10
|
-
useO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T
|
|
11
|
-
useIO: <T>(token: AtomIO.StateToken<T>) => [T, (next: Modifier<T> | T) => void]
|
|
12
|
-
}
|
|
13
|
-
export const storeHooks: StoreHooks = { useI, useO, useIO }
|
|
14
|
-
|
|
15
|
-
export function useI<T>(
|
|
16
|
-
token: AtomIO.StateToken<T>,
|
|
17
|
-
): (next: Modifier<T> | T) => void {
|
|
18
|
-
const store = React.useContext(StoreContext)
|
|
19
|
-
const update = (next: Modifier<T> | T) => AtomIO.setState(token, next, store)
|
|
20
|
-
return update
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function useO<T>(
|
|
24
|
-
token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>,
|
|
25
|
-
): T {
|
|
26
|
-
const store = React.useContext(StoreContext)
|
|
27
|
-
return React.useSyncExternalStore<T>(
|
|
28
|
-
(observe) => AtomIO.subscribe(token, observe, store),
|
|
29
|
-
() => AtomIO.getState(token, store),
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function useIO<T>(
|
|
34
|
-
token: AtomIO.StateToken<T>,
|
|
35
|
-
): [T, (next: Modifier<T> | T) => void] {
|
|
36
|
-
return [useO(token), useI(token)]
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function useStore<T>(
|
|
40
|
-
token: AtomIO.StateToken<T>,
|
|
41
|
-
): [T, (next: Modifier<T> | T) => void]
|
|
42
|
-
export function useStore<T>(token: AtomIO.ReadonlySelectorToken<T>): T
|
|
43
|
-
export function useStore<T>(
|
|
44
|
-
token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>,
|
|
45
|
-
): T | [T, (next: Modifier<T> | T) => void] {
|
|
46
|
-
return token.type === `readonly_selector` ? useO(token) : useIO(token)
|
|
47
|
-
}
|