atom.io 0.6.7 → 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.
Files changed (129) hide show
  1. package/dist/index.d.mts +241 -263
  2. package/dist/index.d.ts +241 -263
  3. package/dist/index.js +28 -1911
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +5 -1871
  6. package/dist/index.mjs.map +1 -1
  7. package/introspection/dist/index.d.mts +121 -176
  8. package/introspection/dist/index.d.ts +121 -176
  9. package/introspection/dist/index.js +6 -346
  10. package/introspection/dist/index.js.map +1 -1
  11. package/introspection/dist/index.mjs +5 -324
  12. package/introspection/dist/index.mjs.map +1 -1
  13. package/json/dist/index.d.mts +37 -8
  14. package/json/dist/index.d.ts +37 -8
  15. package/json/dist/index.js +31 -48
  16. package/json/dist/index.js.map +1 -1
  17. package/json/dist/index.mjs +6 -14
  18. package/json/dist/index.mjs.map +1 -1
  19. package/package.json +30 -14
  20. package/react/dist/index.js +34 -83
  21. package/react/dist/index.js.map +1 -1
  22. package/react/dist/index.mjs +7 -43
  23. package/react/dist/index.mjs.map +1 -1
  24. package/react-devtools/dist/index.css +1 -42
  25. package/react-devtools/dist/index.css.map +1 -1
  26. package/react-devtools/dist/index.d.mts +128 -193
  27. package/react-devtools/dist/index.d.ts +128 -193
  28. package/react-devtools/dist/index.js +56 -4154
  29. package/react-devtools/dist/index.js.map +1 -1
  30. package/react-devtools/dist/index.mjs +19 -4117
  31. package/react-devtools/dist/index.mjs.map +1 -1
  32. package/realtime/dist/index.d.mts +7 -11
  33. package/realtime/dist/index.d.ts +7 -11
  34. package/realtime/dist/index.js +26 -185
  35. package/realtime/dist/index.js.map +1 -1
  36. package/realtime/dist/index.mjs +4 -149
  37. package/realtime/dist/index.mjs.map +1 -1
  38. package/realtime-react/dist/index.d.mts +12 -16
  39. package/realtime-react/dist/index.d.ts +12 -16
  40. package/realtime-react/dist/index.js +41 -214
  41. package/realtime-react/dist/index.js.map +1 -1
  42. package/realtime-react/dist/index.mjs +9 -169
  43. package/realtime-react/dist/index.mjs.map +1 -1
  44. package/src/atom.ts +7 -6
  45. package/src/index.ts +12 -9
  46. package/src/logger.ts +5 -5
  47. package/src/selector.ts +16 -14
  48. package/src/silo.ts +36 -39
  49. package/src/subscribe.ts +25 -20
  50. package/src/timeline.ts +9 -4
  51. package/src/transaction.ts +3 -4
  52. package/src/internal/atom-internal.ts +0 -54
  53. package/src/internal/families-internal.ts +0 -141
  54. package/src/internal/get.ts +0 -129
  55. package/src/internal/index.ts +0 -15
  56. package/src/internal/is-default.ts +0 -35
  57. package/src/internal/operation.ts +0 -139
  58. package/src/internal/selector/create-read-write-selector.ts +0 -66
  59. package/src/internal/selector/create-readonly-selector.ts +0 -46
  60. package/src/internal/selector/index.ts +0 -4
  61. package/src/internal/selector/lookup-selector-sources.ts +0 -16
  62. package/src/internal/selector/register-selector.ts +0 -57
  63. package/src/internal/selector/trace-selector-atoms.ts +0 -43
  64. package/src/internal/selector/update-selector-atoms.ts +0 -33
  65. package/src/internal/selector-internal.ts +0 -58
  66. package/src/internal/set.ts +0 -99
  67. package/src/internal/store.ts +0 -151
  68. package/src/internal/subject.ts +0 -24
  69. package/src/internal/subscribe-internal.ts +0 -88
  70. package/src/internal/time-travel-internal.ts +0 -91
  71. package/src/internal/timeline/add-atom-to-timeline.ts +0 -168
  72. package/src/internal/timeline/index.ts +0 -1
  73. package/src/internal/timeline-internal.ts +0 -107
  74. package/src/internal/transaction/abort-transaction.ts +0 -12
  75. package/src/internal/transaction/apply-transaction.ts +0 -57
  76. package/src/internal/transaction/build-transaction.ts +0 -33
  77. package/src/internal/transaction/index.ts +0 -25
  78. package/src/internal/transaction/redo-transaction.ts +0 -23
  79. package/src/internal/transaction/undo-transaction.ts +0 -23
  80. package/src/internal/transaction-internal.ts +0 -61
  81. package/src/introspection/attach-atom-index.ts +0 -73
  82. package/src/introspection/attach-introspection-states.ts +0 -42
  83. package/src/introspection/attach-selector-index.ts +0 -77
  84. package/src/introspection/attach-timeline-family.ts +0 -59
  85. package/src/introspection/attach-timeline-index.ts +0 -36
  86. package/src/introspection/attach-transaction-index.ts +0 -38
  87. package/src/introspection/attach-transaction-logs.ts +0 -40
  88. package/src/introspection/index.ts +0 -20
  89. package/src/json/index.ts +0 -1
  90. package/src/json/select-json.ts +0 -18
  91. package/src/react/index.ts +0 -2
  92. package/src/react/store-context.tsx +0 -13
  93. package/src/react/store-hooks.ts +0 -47
  94. package/src/react-devtools/AtomIODevtools.tsx +0 -107
  95. package/src/react-devtools/Button.tsx +0 -24
  96. package/src/react-devtools/StateEditor.tsx +0 -70
  97. package/src/react-devtools/StateIndex.tsx +0 -153
  98. package/src/react-devtools/TimelineIndex.tsx +0 -92
  99. package/src/react-devtools/TransactionIndex.tsx +0 -70
  100. package/src/react-devtools/Updates.tsx +0 -145
  101. package/src/react-devtools/devtools.scss +0 -311
  102. package/src/react-devtools/index.ts +0 -72
  103. package/src/react-explorer/AtomIOExplorer.tsx +0 -218
  104. package/src/react-explorer/explorer-effects.ts +0 -20
  105. package/src/react-explorer/explorer-states.ts +0 -217
  106. package/src/react-explorer/index.ts +0 -23
  107. package/src/react-explorer/space-states.ts +0 -72
  108. package/src/react-explorer/view-states.ts +0 -41
  109. package/src/realtime/README.md +0 -33
  110. package/src/realtime/hook-composition/expose-family.ts +0 -101
  111. package/src/realtime/hook-composition/expose-single.ts +0 -38
  112. package/src/realtime/hook-composition/expose-timeline.ts +0 -60
  113. package/src/realtime/hook-composition/index.ts +0 -12
  114. package/src/realtime/hook-composition/receive-state.ts +0 -29
  115. package/src/realtime/hook-composition/receive-transaction.ts +0 -18
  116. package/src/realtime/index.ts +0 -1
  117. package/src/realtime-react/index.ts +0 -3
  118. package/src/realtime-react/realtime-context.tsx +0 -30
  119. package/src/realtime-react/realtime-hooks.ts +0 -39
  120. package/src/realtime-react/realtime-state.ts +0 -10
  121. package/src/realtime-react/use-pull-family-member.ts +0 -26
  122. package/src/realtime-react/use-pull-family.ts +0 -24
  123. package/src/realtime-react/use-pull.ts +0 -22
  124. package/src/realtime-react/use-push.ts +0 -25
  125. package/src/realtime-react/use-server-action.ts +0 -33
  126. package/src/realtime-testing/index.ts +0 -1
  127. package/src/realtime-testing/setup-realtime-test.tsx +0 -159
  128. package/src/web-effects/index.ts +0 -1
  129. package/src/web-effects/storage.ts +0 -30
@@ -1,107 +0,0 @@
1
- import type { ƒn } from "~/packages/anvl/src/function"
2
-
3
- import type { Store } from "."
4
- import { Subject, target, IMPLICIT } from "."
5
- import { addAtomToTimeline } from "./timeline/add-atom-to-timeline"
6
- import type {
7
- StateUpdate,
8
- TimelineOptions,
9
- TimelineToken,
10
- TimelineUpdate,
11
- TransactionUpdate,
12
- } from ".."
13
-
14
- export type TimelineAtomUpdate = StateUpdate<unknown> & {
15
- key: string
16
- type: `atom_update`
17
- timestamp: number
18
- }
19
- export type TimelineSelectorUpdate = {
20
- key: string
21
- type: `selector_update`
22
- timestamp: number
23
- atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[]
24
- }
25
- export type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
26
- key: string
27
- type: `transaction_update`
28
- timestamp: number
29
- }
30
-
31
- export type Timeline = {
32
- key: string
33
- at: number
34
- timeTraveling: boolean
35
- history: TimelineUpdate[]
36
- selectorTime: number | null
37
- transactionKey: string | null
38
- install: (store: Store) => void
39
- subject: Subject<
40
- | TimelineAtomUpdate
41
- | TimelineSelectorUpdate
42
- | TimelineTransactionUpdate
43
- | `redo`
44
- | `undo`
45
- >
46
- }
47
-
48
- export function timeline__INTERNAL(
49
- options: TimelineOptions,
50
- store: Store = IMPLICIT.STORE,
51
- data: Timeline | null = null,
52
- ): TimelineToken {
53
- const tl: Timeline = {
54
- key: options.key,
55
- at: 0,
56
- timeTraveling: false,
57
- selectorTime: null,
58
- transactionKey: null,
59
- ...data,
60
- history: data?.history.map((update) => ({ ...update })) ?? [],
61
- install: (store) => timeline__INTERNAL(options, store, tl),
62
- subject: new Subject(),
63
- }
64
-
65
- const core = target(store)
66
- for (const tokenOrFamily of options.atoms) {
67
- const timelineKey = core.timelineAtoms.getRelatedId(tokenOrFamily.key)
68
- if (timelineKey) {
69
- store.config.logger?.error(
70
- `❌ Failed to add atom "${tokenOrFamily.key}" to timeline "${options.key}" because it belongs to timeline "${timelineKey}"`,
71
- )
72
- continue
73
- }
74
- if (tokenOrFamily.type === `atom_family`) {
75
- const family = tokenOrFamily
76
- family.subject.subscribe((token) =>
77
- addAtomToTimeline(token, options.atoms, tl, store),
78
- )
79
- } else {
80
- const token = tokenOrFamily
81
- if (`family` in token && token.family) {
82
- const familyTimelineKey = core.timelineAtoms.getRelatedId(
83
- token.family.key,
84
- )
85
- if (familyTimelineKey) {
86
- store.config.logger?.error(
87
- `❌ Failed to add atom "${token.key}" to timeline "${options.key}" because its family "${token.family.key}" belongs to timeline "${familyTimelineKey}"`,
88
- )
89
- continue
90
- }
91
- }
92
- addAtomToTimeline(token, options.atoms, tl, store)
93
- }
94
- core.timelineAtoms = core.timelineAtoms.set({
95
- atomKey: tokenOrFamily.key,
96
- timelineKey: options.key,
97
- })
98
- }
99
-
100
- store.timelines.set(options.key, tl)
101
- const token: TimelineToken = {
102
- key: options.key,
103
- type: `timeline`,
104
- }
105
- store.subject.timelineCreation.next(token)
106
- return token
107
- }
@@ -1,12 +0,0 @@
1
- import type { Store } from ".."
2
-
3
- export const abortTransaction = (store: Store): void => {
4
- if (store.transactionStatus.phase === `idle`) {
5
- store.config.logger?.warn(
6
- `abortTransaction called outside of a transaction. This is probably a bug.`,
7
- )
8
- return
9
- }
10
- store.transactionStatus = { phase: `idle` }
11
- store.config.logger?.info(`🪂`, `transaction fail`)
12
- }
@@ -1,57 +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 } from "../.."
6
- import { setState } from "../.."
7
-
8
- export const applyTransaction = <ƒ extends ƒn>(
9
- output: ReturnType<ƒ>,
10
- store: Store,
11
- ): void => {
12
- if (store.transactionStatus.phase !== `building`) {
13
- store.config.logger?.warn(
14
- `abortTransaction called outside of a transaction. This is probably a bug.`,
15
- )
16
- return
17
- }
18
- store.config.logger?.info(
19
- `🛃 apply transaction "${store.transactionStatus.key}"`,
20
- )
21
- store.transactionStatus.phase = `applying`
22
- store.transactionStatus.output = output
23
- const { atomUpdates } = store.transactionStatus
24
-
25
- for (const { key, newValue } of atomUpdates) {
26
- const token: AtomToken<unknown> = { key, type: `atom` }
27
- if (!store.valueMap.has(token.key)) {
28
- const newAtom = store.transactionStatus.core.atoms.get(token.key)
29
- if (!newAtom) {
30
- throw new Error(
31
- `Absurd Error: Atom "${token.key}" not found while copying updates from transaction "${store.transactionStatus.key}" to store "${store.config.name}"`,
32
- )
33
- }
34
- store.atoms.set(newAtom.key, newAtom)
35
- store.valueMap.set(newAtom.key, newAtom.default)
36
- store.config.logger?.info(`🔧`, `add atom "${newAtom.key}"`)
37
- }
38
- setState(token, newValue, store)
39
- }
40
- const myTransaction = withdraw<ƒ>(
41
- { key: store.transactionStatus.key, type: `transaction` },
42
- store,
43
- )
44
- if (myTransaction === null) {
45
- throw new Error(
46
- `Transaction "${store.transactionStatus.key}" not found. Absurd. How is this running?`,
47
- )
48
- }
49
- myTransaction.subject.next({
50
- key: store.transactionStatus.key,
51
- atomUpdates,
52
- output,
53
- params: store.transactionStatus.params as Parameters<ƒ>,
54
- })
55
- store.transactionStatus = { phase: `idle` }
56
- store.config.logger?.info(`🛬`, `transaction done`)
57
- }
@@ -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: false,
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
- }