atom.io 0.6.1 → 0.6.3
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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -2
- package/dist/index.mjs.map +1 -1
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs.map +1 -1
- package/package.json +13 -3
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs.map +1 -1
- package/react-devtools/dist/index.js +32 -18
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +32 -18
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs.map +1 -1
- package/realtime-testing/dist/index.d.mts +49 -0
- package/realtime-testing/dist/index.d.ts +49 -0
- package/realtime-testing/dist/index.js +153 -0
- package/realtime-testing/dist/index.js.map +1 -0
- package/realtime-testing/dist/index.mjs +117 -0
- package/realtime-testing/dist/index.mjs.map +1 -0
- package/realtime-testing/package.json +15 -0
- package/src/atom.ts +15 -15
- package/src/index.ts +59 -59
- package/src/internal/atom-internal.ts +36 -36
- package/src/internal/families-internal.ts +114 -114
- package/src/internal/get.ts +83 -83
- package/src/internal/is-default.ts +17 -17
- package/src/internal/meta/attach-meta.ts +7 -7
- package/src/internal/meta/meta-state.ts +115 -115
- package/src/internal/operation.ts +93 -93
- package/src/internal/selector/create-read-write-selector.ts +46 -46
- package/src/internal/selector/create-readonly-selector.ts +37 -37
- package/src/internal/selector/lookup-selector-sources.ts +9 -9
- package/src/internal/selector/register-selector.ts +44 -44
- package/src/internal/selector/trace-selector-atoms.ts +30 -30
- package/src/internal/selector/update-selector-atoms.ts +25 -25
- package/src/internal/selector-internal.ts +37 -37
- package/src/internal/set.ts +78 -78
- package/src/internal/store.ts +118 -118
- package/src/internal/subscribe-internal.ts +62 -62
- package/src/internal/time-travel-internal.ts +76 -76
- package/src/internal/timeline/add-atom-to-timeline.ts +158 -153
- package/src/internal/timeline-internal.ts +80 -80
- package/src/internal/transaction/abort-transaction.ts +8 -8
- package/src/internal/transaction/apply-transaction.ts +41 -41
- package/src/internal/transaction/build-transaction.ts +28 -28
- package/src/internal/transaction/index.ts +7 -7
- package/src/internal/transaction/redo-transaction.ts +13 -13
- package/src/internal/transaction/undo-transaction.ts +13 -13
- package/src/internal/transaction-internal.ts +48 -48
- package/src/json/select-json.ts +12 -12
- package/src/logger.ts +30 -30
- package/src/react/store-context.tsx +4 -4
- package/src/react/store-hooks.ts +18 -18
- package/src/react-devtools/AtomIODevtools.tsx +83 -82
- package/src/react-devtools/StateEditor.tsx +53 -53
- package/src/react-devtools/TokenList.tsx +47 -42
- package/src/react-explorer/AtomIOExplorer.tsx +197 -185
- package/src/react-explorer/explorer-effects.ts +11 -11
- package/src/react-explorer/explorer-states.ts +186 -193
- package/src/react-explorer/index.ts +11 -11
- package/src/react-explorer/space-states.ts +48 -50
- package/src/react-explorer/view-states.ts +25 -25
- package/src/realtime/hook-composition/expose-family.ts +81 -81
- package/src/realtime/hook-composition/expose-single.ts +26 -26
- package/src/realtime/hook-composition/expose-timeline.ts +60 -0
- package/src/realtime/hook-composition/index.ts +2 -2
- package/src/realtime/hook-composition/receive-state.ts +18 -18
- package/src/realtime/hook-composition/receive-transaction.ts +8 -8
- package/src/realtime-react/realtime-context.tsx +17 -17
- package/src/realtime-react/realtime-hooks.ts +17 -17
- package/src/realtime-react/realtime-state.ts +4 -4
- package/src/realtime-react/use-pull-family-member.ts +15 -15
- package/src/realtime-react/use-pull-family.ts +13 -13
- package/src/realtime-react/use-pull.ts +12 -12
- package/src/realtime-react/use-push.ts +15 -15
- package/src/realtime-react/use-server-action.ts +21 -21
- package/src/realtime-testing/index.ts +1 -0
- package/src/realtime-testing/setup-realtime-test.tsx +160 -0
- package/src/selector.ts +25 -25
- package/src/silo.ts +38 -38
- package/src/subscribe.ts +68 -68
- package/src/timeline.ts +13 -13
- package/src/transaction.ts +28 -28
- package/src/web-effects/storage.ts +17 -17
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../../anvl/src/string/capitalize.ts","../src/internal/index.ts","../src/internal/atom-internal.ts","../src/internal/get.ts","../src/internal/is-default.ts","../src/internal/operation.ts","../src/internal/store.ts","../../anvl/src/function/index.ts","../../anvl/src/join/core-relation-data.ts","../../anvl/src/array/venn.ts","../../anvl/src/array/index.ts","../../anvl/src/object/refinement.ts","../../anvl/src/object/access.ts","../../anvl/src/object/entries.ts","../../anvl/src/object/mapObject.ts","../../anvl/src/nullish/index.ts","../../anvl/src/refinement/index.ts","../../anvl/src/join/get-related-ids.ts","../../anvl/src/join/make-json-interface.ts","../../anvl/src/join/relation-contents.ts","../../anvl/src/join/relation-record.ts","../../anvl/src/join/remove-relation.ts","../../anvl/src/object/index.ts","../../anvl/src/string/split.ts","../../anvl/src/join/set-relation.ts","../../anvl/src/join/index.ts","../src/internal/transaction-internal.ts","../src/internal/families-internal.ts","../../anvl/src/json/index.ts","../src/internal/meta/index.ts","../src/internal/meta/meta-state.ts","../src/internal/meta/attach-meta.ts","../src/internal/selector-internal.ts","../src/internal/selector/create-read-write-selector.ts","../src/internal/selector/create-readonly-selector.ts","../src/internal/selector/lookup-selector-sources.ts","../src/internal/selector/trace-selector-atoms.ts","../src/internal/selector/update-selector-atoms.ts","../src/internal/set.ts","../src/internal/selector/register-selector.ts","../src/internal/subscribe-internal.ts","../src/internal/time-travel-internal.ts","../src/internal/timeline-internal.ts","../src/internal/timeline/add-atom-to-timeline.ts","../src/internal/transaction/abort-transaction.ts","../src/internal/transaction/apply-transaction.ts","../src/internal/transaction/build-transaction.ts","../src/internal/transaction/redo-transaction.ts","../src/internal/transaction/undo-transaction.ts","../src/internal/transaction/index.ts","../src/atom.ts","../src/logger.ts","../src/selector.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"sourcesContent":["import { capitalize } from \"~/packages/anvl/src/string/capitalize\"\n\nimport {\n IMPLICIT,\n closeOperation,\n openOperation,\n getState__INTERNAL,\n setState__INTERNAL,\n isAtomDefault,\n isSelectorDefault,\n withdraw,\n} from \"./internal\"\nimport * as __INTERNAL__ from \"./internal\"\nimport type { Store } from \"./internal/store\"\n\nexport * from \"./atom\"\nexport * from \"./logger\"\nexport * from \"./selector\"\nexport * from \"./silo\"\nexport * from \"./subscribe\"\nexport * from \"./timeline\"\nexport * from \"./transaction\"\nexport { __INTERNAL__ }\nexport type { Store } from \"./internal/store\"\nexport type { Serializable } from \"~/packages/anvl/src/json\"\n\nexport type AtomToken<_> = {\n key: string\n type: `atom`\n family?: FamilyMetadata\n __brand?: _\n}\nexport type SelectorToken<_> = {\n key: string\n type: `selector`\n family?: FamilyMetadata\n __brand?: _\n}\nexport type StateToken<T> = AtomToken<T> | SelectorToken<T>\n\nexport type ReadonlySelectorToken<_> = {\n key: string\n type: `readonly_selector`\n family?: FamilyMetadata\n __brand?: _\n}\n\nexport type FamilyMetadata = {\n key: string\n subKey: string\n}\n\nexport const getState = <T>(\n token: ReadonlySelectorToken<T> | StateToken<T>,\n store: Store = IMPLICIT.STORE\n): T => {\n const state = withdraw<T>(token, store)\n if (state === null) {\n throw new Error(\n `${capitalize(token.type)} \"${token.key}\" not found in store \"${\n store.config.name\n }\".`\n )\n }\n return getState__INTERNAL(state, store)\n}\n\nexport const setState = <T, New extends T>(\n token: StateToken<T>,\n value: New | ((oldValue: T) => New),\n store: Store = IMPLICIT.STORE\n): void => {\n try {\n openOperation(token, store)\n } catch (thrown) {\n if (!(typeof thrown === `symbol`)) {\n throw thrown\n }\n return\n }\n const state = withdraw(token, store)\n if (state === null) {\n throw new Error(\n `${capitalize(token.type)} \"${token.key}\" not found in store \"${\n store.config.name\n }\".`\n )\n }\n setState__INTERNAL(state, value, store)\n closeOperation(store)\n}\n\nexport const isDefault = (\n token: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n store: Store = IMPLICIT.STORE\n): boolean =>\n token.type === `atom`\n ? isAtomDefault(token.key, store)\n : isSelectorDefault(token.key, store)\n","export const capitalize = (str: string): string =>\n str[0].toUpperCase() + str.slice(1)\n","export * from \"./atom-internal\"\nexport * from \"./families-internal\"\nexport * from \"./get\"\nexport * from \"./is-default\"\nexport * as META from \"./meta\"\nexport * from \"./operation\"\nexport * from \"./selector-internal\"\nexport * from \"./selector\"\nexport * from \"./set\"\nexport * from \"./store\"\nexport * from \"./subscribe-internal\"\nexport * from \"./time-travel-internal\"\nexport * from \"./timeline-internal\"\nexport * from \"./transaction-internal\"\nexport * from \"./transaction\"\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport { deposit } from \"./get\"\nimport { markAtomAsDefault } from \"./is-default\"\nimport { cacheValue, hasKeyBeenUsed } from \"./operation\"\nimport type { Store } from \"./store\"\nimport { IMPLICIT } from \"./store\"\nimport { target } from \"./transaction-internal\"\nimport type { AtomToken, FamilyMetadata, UpdateHandler } from \"..\"\nimport { setState, subscribe } from \"..\"\nimport type { AtomOptions } from \"../atom\"\n\nexport type Atom<T> = {\n key: string\n type: `atom`\n family?: FamilyMetadata\n subject: Rx.Subject<{ newValue: T; oldValue: T }>\n default: T\n}\n\nexport function atom__INTERNAL<T>(\n options: AtomOptions<T>,\n family?: FamilyMetadata,\n store: Store = IMPLICIT.STORE\n): AtomToken<T> {\n const core = target(store)\n if (hasKeyBeenUsed(options.key, store)) {\n store.config.logger?.error?.(\n `Key \"${options.key}\" already exists in the store.`\n )\n return deposit(core.atoms.get(options.key))\n }\n const subject = new Rx.Subject<{ newValue: T; oldValue: T }>()\n const newAtom = {\n ...options,\n subject,\n type: `atom`,\n ...(family && { family }),\n } as const\n const initialValue =\n options.default instanceof Function ? options.default() : options.default\n core.atoms = HAMT.set(newAtom.key, newAtom, core.atoms)\n markAtomAsDefault(options.key, store)\n cacheValue(options.key, initialValue, store)\n const token = deposit(newAtom)\n options.effects?.forEach((effect) =>\n effect({\n setSelf: (next) => setState(token, next, store),\n onSet: (handle: UpdateHandler<T>) => subscribe(token, handle, store),\n })\n )\n store.subject.atomCreation.next(token)\n return token as AtomToken<T>\n}\n","import HAMT from \"hamt_plus\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type {\n Atom,\n ReadonlySelector,\n Selector,\n Store,\n Timeline,\n Transaction,\n} from \".\"\nimport { target, isValueCached, readCachedValue, IMPLICIT } from \".\"\nimport type {\n AtomToken,\n ReadonlySelectorToken,\n SelectorToken,\n StateToken,\n TimelineToken,\n TransactionToken,\n} from \"..\"\n\nexport const computeSelectorState = <T>(\n selector: ReadonlySelector<T> | Selector<T>\n): T => selector.get()\n\nexport function lookup(\n key: string,\n store: Store\n): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown> {\n const core = target(store)\n const type = HAMT.has(key, core.atoms)\n ? `atom`\n : HAMT.has(key, core.selectors)\n ? `selector`\n : `readonly_selector`\n return { key, type } as any\n}\n\nexport function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | null\nexport function withdraw<T>(\n token: SelectorToken<T>,\n store: Store\n): Selector<T> | null\nexport function withdraw<T>(\n token: StateToken<T>,\n store: Store\n): Atom<T> | Selector<T> | null\nexport function withdraw<T>(\n token: ReadonlySelectorToken<T>,\n store: Store\n): ReadonlySelector<T> | null\nexport function withdraw<T>(\n token: TransactionToken<T>,\n store: Store\n): Transaction<T extends ƒn ? T : never> | null\nexport function withdraw<T>(\n token: ReadonlySelectorToken<T> | StateToken<T>,\n store: Store\n): Atom<T> | ReadonlySelector<T> | Selector<T> | null\nexport function withdraw<T>(token: TimelineToken, store: Store): Timeline | null\nexport function withdraw<T>(\n token:\n | ReadonlySelectorToken<T>\n | StateToken<T>\n | TimelineToken\n | TransactionToken<T>,\n store: Store\n):\n | Atom<T>\n | ReadonlySelector<T>\n | Selector<T>\n | Timeline\n | Transaction<T extends ƒn ? T : never>\n | null {\n const core = target(store)\n return (\n HAMT.get(token.key, core.atoms) ??\n HAMT.get(token.key, core.selectors) ??\n HAMT.get(token.key, core.readonlySelectors) ??\n HAMT.get(token.key, core.transactions) ??\n HAMT.get(token.key, core.timelines) ??\n null\n )\n}\n\nexport function deposit<T>(state: Atom<T>): AtomToken<T>\nexport function deposit<T>(state: Selector<T>): SelectorToken<T>\nexport function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>\nexport function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>\nexport function deposit<T>(\n state: Transaction<T extends ƒn ? T : never>\n): TransactionToken<T>\nexport function deposit<T>(\n state: Atom<T> | ReadonlySelector<T> | Selector<T>\n): ReadonlySelectorToken<T> | StateToken<T>\nexport function deposit<T>(\n state:\n | Atom<T>\n | ReadonlySelector<T>\n | Selector<T>\n | Transaction<T extends ƒn ? T : never>\n):\n | AtomToken<T>\n | ReadonlySelectorToken<T>\n | SelectorToken<T>\n | TransactionToken<T> {\n return {\n key: state.key,\n type: state.type,\n ...(`family` in state && { family: state.family }),\n } as any\n}\n\nexport const getState__INTERNAL = <T>(\n state: Atom<T> | ReadonlySelector<T> | Selector<T>,\n store: Store = IMPLICIT.STORE\n): T => {\n if (isValueCached(state.key, store)) {\n store.config.logger?.info(`>> read \"${state.key}\"`)\n return readCachedValue(state.key, store)\n }\n if (state.type !== `atom`) {\n store.config.logger?.info(`-> calc \"${state.key}\"`)\n return computeSelectorState(state)\n }\n store.config.logger?.error(\n `Attempted to get atom \"${state.key}\", which was never initialized in store \"${store.config.name}\".`\n )\n return state.default\n}\n","import type { Store } from \".\"\nimport { target, IMPLICIT, traceAllSelectorAtoms } from \".\"\n\nexport const isAtomDefault = (\n key: string,\n store: Store = IMPLICIT.STORE\n): boolean => {\n const core = target(store)\n return core.atomsThatAreDefault.has(key)\n}\n\nexport const markAtomAsDefault = (\n key: string,\n store: Store = IMPLICIT.STORE\n): void => {\n const core = target(store)\n core.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key)\n}\n\nexport const markAtomAsNotDefault = (\n key: string,\n store: Store = IMPLICIT.STORE\n): void => {\n const core = target(store)\n core.atomsThatAreDefault = new Set(target(store).atomsThatAreDefault)\n core.atomsThatAreDefault.delete(key)\n}\n\nexport const isSelectorDefault = (\n key: string,\n store: Store = IMPLICIT.STORE\n): boolean => {\n const roots = traceAllSelectorAtoms(key, store)\n return roots.every((root) => isAtomDefault(root.key, store))\n}\n","import type { Hamt } from \"hamt_plus\"\nimport HAMT from \"hamt_plus\"\n\nimport type { Atom, ReadonlySelector, Selector } from \".\"\nimport { target } from \".\"\nimport type { Store } from \"./store\"\nimport { IMPLICIT } from \"./store\"\nimport type { StateToken } from \"..\"\n\nexport type OperationProgress =\n | {\n open: false\n }\n | {\n open: true\n done: Set<string>\n prev: Hamt<any, string>\n time: number\n token: StateToken<any>\n }\n\nexport const openOperation = (token: StateToken<any>, store: Store): void => {\n const core = target(store)\n if (core.operation.open) {\n store.config.logger?.error(\n `❌ failed to setState to \"${token.key}\" during a setState for \"${core.operation.token.key}\"`\n )\n throw Symbol(`violation`)\n }\n core.operation = {\n open: true,\n done: new Set(),\n prev: store.valueMap,\n time: Date.now(),\n token,\n }\n store.config.logger?.info(\n `⭕ operation start from \"${token.key}\" in store \"${store.config.name}\"`\n )\n}\nexport const closeOperation = (store: Store): void => {\n const core = target(store)\n core.operation = { open: false }\n store.config.logger?.info(`🔴 operation done`)\n}\n\nexport const isDone = (key: string, store: Store = IMPLICIT.STORE): boolean => {\n const core = target(store)\n if (!core.operation.open) {\n store.config.logger?.warn(\n `isDone called outside of an operation. This is probably a bug.`\n )\n return true\n }\n return core.operation.done.has(key)\n}\nexport const markDone = (key: string, store: Store = IMPLICIT.STORE): void => {\n const core = target(store)\n if (!core.operation.open) {\n store.config.logger?.warn(\n `markDone called outside of an operation. This is probably a bug.`\n )\n return\n }\n core.operation.done.add(key)\n}\nexport const recallState = <T>(\n state: Atom<T> | ReadonlySelector<T> | Selector<T>,\n store: Store = IMPLICIT.STORE\n): T => {\n const core = target(store)\n if (!core.operation.open) {\n store.config.logger?.warn(\n `recall called outside of an operation. This is probably a bug.`\n )\n return HAMT.get(state.key, core.valueMap)\n }\n return HAMT.get(state.key, core.operation.prev)\n}\n\nexport const cacheValue = (\n key: string,\n value: unknown,\n store: Store = IMPLICIT.STORE\n): void => {\n const core = target(store)\n core.valueMap = HAMT.set(key, value, core.valueMap)\n}\n\nexport const evictCachedValue = (\n key: string,\n store: Store = IMPLICIT.STORE\n): void => {\n const core = target(store)\n core.valueMap = HAMT.remove(key, core.valueMap)\n}\nexport const readCachedValue = <T>(\n key: string,\n store: Store = IMPLICIT.STORE\n): T => HAMT.get(key, target(store).valueMap)\n\nexport const isValueCached = (\n key: string,\n store: Store = IMPLICIT.STORE\n): boolean => HAMT.has(key, target(store).valueMap)\n\nexport const storeAtom = (\n atom: Atom<any>,\n store: Store = IMPLICIT.STORE\n): void => {\n const core = target(store)\n core.atoms = HAMT.set(atom.key, atom, core.atoms)\n}\n\nexport const storeSelector = (\n selector: Selector<any>,\n store: Store = IMPLICIT.STORE\n): void => {\n const core = target(store)\n core.selectors = HAMT.set(selector.key, selector, core.selectors)\n}\n\nexport const storeReadonlySelector = (\n selector: ReadonlySelector<any>,\n store: Store = IMPLICIT.STORE\n): void => {\n const core = target(store)\n core.readonlySelectors = HAMT.set(\n selector.key,\n selector,\n core.readonlySelectors\n )\n}\n\nexport const hasKeyBeenUsed = (\n key: string,\n store: Store = IMPLICIT.STORE\n): boolean => {\n const core = target(store)\n return (\n HAMT.has(key, core.atoms) ||\n HAMT.has(key, core.selectors) ||\n HAMT.has(key, core.readonlySelectors)\n )\n}\n","import type { Hamt } from \"hamt_plus\"\nimport HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\nimport { doNothing } from \"~/packages/anvl/src/function\"\nimport { Join } from \"~/packages/anvl/src/join\"\n\nimport type {\n Atom,\n OperationProgress,\n ReadonlySelector,\n Selector,\n TransactionStatus,\n Timeline,\n Transaction,\n} from \".\"\nimport type {\n AtomToken,\n Logger,\n ReadonlySelectorToken,\n SelectorToken,\n TimelineToken,\n TransactionToken,\n} from \"..\"\n\nexport type StoreCore = Pick<\n Store,\n | `atoms`\n | `atomsThatAreDefault`\n | `operation`\n | `readonlySelectors`\n | `selectorAtoms`\n | `selectorGraph`\n | `selectors`\n | `timelineAtoms`\n | `timelines`\n | `transactions`\n | `valueMap`\n>\n\nexport interface Store {\n atoms: Hamt<Atom<any>, string>\n atomsThatAreDefault: Set<string>\n readonlySelectors: Hamt<ReadonlySelector<any>, string>\n selectorAtoms: Join<null, `selectorKey`, `atomKey`>\n selectorGraph: Join<{ source: string }>\n selectors: Hamt<Selector<any>, string>\n timelineAtoms: Join<null, `timelineKey`, `atomKey`>\n timelines: Hamt<Timeline, string>\n transactions: Hamt<Transaction<any>, string>\n valueMap: Hamt<any, string>\n\n subject: {\n atomCreation: Rx.Subject<AtomToken<unknown>>\n selectorCreation: Rx.Subject<\n ReadonlySelectorToken<unknown> | SelectorToken<unknown>\n >\n transactionCreation: Rx.Subject<TransactionToken<unknown>>\n timelineCreation: Rx.Subject<TimelineToken>\n }\n\n operation: OperationProgress\n transactionStatus: TransactionStatus<ƒn>\n config: {\n name: string\n logger: Logger | null\n logger__INTERNAL: Logger\n }\n}\n\nexport const createStore = (name: string, store: Store | null = null): Store => {\n const copiedStore = {\n ...(store ??\n (() => ({\n atomsThatAreDefault: new Set(),\n selectorAtoms: new Join({ relationType: `n:n` })\n .from(`selectorKey`)\n .to(`atomKey`),\n selectorGraph: new Join({ relationType: `n:n` }),\n valueMap: HAMT.make<any, string>(),\n }))()),\n\n atoms: HAMT.make<Atom<any>, string>(),\n readonlySelectors: HAMT.make<ReadonlySelector<any>, string>(),\n selectors: HAMT.make<Selector<any>, string>(),\n transactions: HAMT.make<Transaction<any>, string>(),\n timelines: HAMT.make<Timeline, string>(),\n\n timelineAtoms: new Join({ relationType: `1:n` })\n .from(`timelineKey`)\n .to(`atomKey`),\n\n subject: {\n atomCreation: new Rx.Subject(),\n selectorCreation: new Rx.Subject(),\n transactionCreation: new Rx.Subject(),\n timelineCreation: new Rx.Subject(),\n ...store?.subject,\n },\n\n operation: {\n open: false,\n ...store?.operation,\n },\n transactionStatus: {\n phase: `idle`,\n ...store?.transactionStatus,\n },\n config: {\n logger: {\n ...console,\n info: doNothing,\n ...store?.config?.logger,\n },\n logger__INTERNAL: console,\n ...store?.config,\n name,\n },\n } satisfies Store\n\n store?.atoms.forEach((atom) => {\n const copiedAtom = { ...atom, subject: new Rx.Subject() } satisfies Atom<any>\n copiedStore.atoms = HAMT.set(atom.key, copiedAtom, copiedStore.atoms)\n })\n store?.readonlySelectors.forEach((selector) => {\n selector.install(copiedStore)\n })\n store?.selectors.forEach((selector) => {\n selector.install(copiedStore)\n })\n store?.transactions.forEach((tx) => {\n tx.install(copiedStore)\n })\n store?.timelines.forEach((timeline) => {\n timeline.install(copiedStore)\n })\n\n return copiedStore\n}\n\nexport const IMPLICIT = {\n STORE_INTERNAL: undefined as Store | undefined,\n get STORE(): Store {\n return this.STORE_INTERNAL ?? (this.STORE_INTERNAL = createStore(`DEFAULT`))\n },\n}\n\nexport const clearStore = (store: Store = IMPLICIT.STORE): void => {\n const { config } = store\n Object.assign(store, createStore(config.name))\n store.config = config\n}\n","import type { Refinement } from \"fp-ts/Refinement\"\nexport * from \"./curry\"\n\nexport type ƒn = (...parameters: any[]) => any\n\nexport const doNothing = (): void => undefined\n\n/* eslint-disable prettier/prettier */\nexport const become =\n <T>\n (nextVersionOfThing: Modifier<T> | T) =>\n (originalThing: T | (() => T)): T =>\n nextVersionOfThing instanceof Function\n ? nextVersionOfThing(originalThing instanceof Function \n ? originalThing() \n : originalThing\n )\n : nextVersionOfThing\n/* eslint-enable prettier/prettier */\n\nexport type Applicator<X, Y> = (next: Modifier<X> | X) => Modifier<Y>\nexport type Modifier<T> = (thing: T) => T\n\nexport type OneOrMany<T> = T | T[]\n\nexport const isModifier =\n <T>(validate: Refinement<unknown, T>) =>\n (sample: T): Refinement<unknown, Modifier<T>> => {\n const sampleIsValid = validate(sample)\n if (!sampleIsValid) {\n throw new Error(`Invalid test case: JSON.stringify(${sample})`)\n }\n return (input: unknown): input is Modifier<T> => {\n if (typeof input !== `function`) return false\n const testResult = input(sample)\n return validate(testResult)\n }\n }\n\nexport const pass =\n <Params extends ReadonlyArray<any>, Out>(...params: Params) =>\n (fn: (...params: Params) => Out): Out =>\n fn(...params)\n\nexport const typeOf =\n <T>(input: unknown) =>\n (isType: Refinement<unknown, T>): boolean =>\n isType(input)\n\nexport const raiseError = (message: string): never => {\n throw new Error(message)\n}\n\nexport type Encapsulate<T extends (...args: any[]) => any> = (\n ...args: Parameters<T>\n) => void\n\nexport const attempt = (fn: () => void): boolean => {\n try {\n fn()\n return true\n } catch (_) {\n return false\n }\n}\n","import { isString } from \"fp-ts/string\"\n\nimport type { Json, JsonObj } from \"~/packages/anvl/src/json\"\n\nimport { isArray } from \"../array\"\nimport { hasExactProperties, isRecord } from \"../object/refinement\"\nimport { isLiteral } from \"../refinement\"\n\nexport const RELATION_TYPES = [`1:1`, `1:n`, `n:n`] as const\n\nexport type RelationType = (typeof RELATION_TYPES)[number]\n\nexport const isRelationType = (x: unknown): x is RelationType =>\n RELATION_TYPES.includes(x as RelationType)\n\nexport type RelationData<\n CONTENT extends JsonObj | null = null,\n A extends string = `from`,\n B extends string = `to`\n> = {\n contents: JsonObj<string, CONTENT>\n relations: JsonObj<string, string[]>\n relationType: RelationType\n a: A\n b: B\n}\n\nexport const EMPTY_RELATION_DATA: RelationData = {\n contents: {},\n relations: {},\n relationType: `n:n`,\n a: `from`,\n b: `to`,\n}\n\nexport type IsRelationDataOptions<\n CONTENT extends JsonObj | null = null,\n A extends string = `from`,\n B extends string = `to`\n> = {\n from?: A\n to?: B\n isContent?: (json: Json) => json is CONTENT\n}\nexport const isRelationData =\n <\n CONTENT extends JsonObj | null = null,\n A extends string = `from`,\n B extends string = `to`\n >({\n from: a = `from` as A,\n to: b = `to` as B,\n isContent,\n }: IsRelationDataOptions<CONTENT, A, B> = {}) =>\n (input: unknown): input is RelationData<CONTENT, A, B> => {\n return hasExactProperties<RelationData<CONTENT, A, B>>({\n contents: isContent\n ? isRecord(isString, isContent)\n : hasExactProperties({}),\n relations: isRecord(isString, isArray(isString)),\n relationType: isRelationType,\n a: isLiteral(a),\n b: isLiteral(b),\n })(input)\n }\n","export type VennCheck = (\n items: ReadonlyArray<unknown> | unknown[]\n) => (array: ReadonlyArray<unknown> | unknown[]) => boolean\n\nexport type VennTally = (\n items: ReadonlyArray<unknown> | unknown[]\n) => (array: ReadonlyArray<unknown> | unknown[]) => number\n\nexport const includesAll: VennCheck = (items) => (array) => {\n for (const item of items) {\n if (!array.includes(item)) return false\n }\n return true\n}\n\nexport const includesAny: VennCheck = (items) => (array) => {\n for (const item of items) {\n if (array.includes(item)) return true\n }\n return false\n}\n\nexport const excludesAll: VennCheck = (items) => (array) =>\n !includesAny(items)(array)\n\nexport const excludesAny: VennCheck = (items) => (array) =>\n !includesAll(items)(array)\n\nexport const comprises: VennCheck = (items) => (array) =>\n includesAll(items)(array) && includesAll(array)(items)\n\nexport const overlaps: VennTally = (items) => (array) => {\n let incidences = 0\n for (const item of items) {\n if (array.includes(item)) incidences += 1\n }\n return incidences\n}\n","export * from \"./match\"\nexport * from \"./venn\"\n\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nexport const each =\n <T>(isType: Refinement<unknown, T>) =>\n (input: unknown): T[] =>\n isType(input) ? [input] : Array.isArray(input) ? input.filter(isType) : []\n\nexport const lastOf = <T>(input: ReadonlyArray<T>): T | undefined =>\n input[input.length - 1]\n\nexport const isArray =\n <T>(isType: Refinement<unknown, T>) =>\n (input: unknown): input is T[] =>\n Array.isArray(input) && input.every((item) => isType(item))\n\nexport const at =\n <T>(index: number) =>\n (input: T[]): T | undefined =>\n input.at(index)\n\nexport const content =\n <T>(isType: Refinement<unknown, T>) =>\n (input: unknown): input is T | T[] =>\n isType(input) || isArray(isType)(input)\n\nexport const join =\n (separator?: string) =>\n (a: string[]): string =>\n a.join(separator)\n\nexport const map =\n <I, O>(f: (value: I, index: number, array: I[]) => O) =>\n (a: I[]): O[] =>\n a.map(f)\n\nexport const reduce =\n <I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n (a: I[]): O =>\n a.reduce(f, initial)\n\nexport const slice =\n (start: number, end?: number) =>\n <I>(a: I[]): I[] =>\n a.slice(start, end)\n\nexport const using =\n <I, O>(a: I[]) =>\n (f: (acc: O, value: I, index: number, array: I[]) => O) =>\n (initial: O): O =>\n a.reduce(f, initial)\n\nexport const reduceRight =\n <I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n (a: I[]): O =>\n a.reduceRight(f, initial)\n\nexport const reverse = <I>(a: I[]): I[] => a.reverse()\n\nexport const sort =\n <I>(a: I[]) =>\n (f?: (x: I, y: I) => number): I[] =>\n f ? a.sort(f) : a.sort()\n\nexport const sortBy =\n <I>(f: (value: I) => number) =>\n (a: I[]): I[] =>\n a.sort((x, y) => f(x) - f(y))\n\nexport const sortByDesc =\n <I>(f: (value: I) => number) =>\n (a: I[]): I[] =>\n a.sort((x, y) => f(y) - f(x))\n\nexport const every =\n <I>(f: (value: I, index: number, array: I[]) => boolean = Boolean) =>\n (a: I[]): boolean =>\n a.every(f)\n\nexport const allTrue = every((x: boolean) => x === true)\n\nexport const addTo =\n <I>(a: I[]) =>\n (x: I): I[] =>\n a.includes(x) ? a : [...a, x]\n\nexport const isEmptyArray = (input: unknown): input is [] =>\n Array.isArray(input) && input.length === 0\n\nexport const isOneOf =\n <T>(...args: ReadonlyArray<T>) =>\n (input: unknown): input is T =>\n args.includes(input as T)\n\nexport const filter =\n <I, O extends I>(f: (value: I, index: number, array: I[]) => value is O) =>\n (a: I[]): O[] =>\n a.filter(f)\n","import { pipe } from \"fp-ts/function\"\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nimport { access } from \"./access\"\nimport { recordToEntries } from \"./entries\"\nimport { mob } from \"./mapObject\"\nimport { allTrue, every } from \"../array\"\nimport { pass } from \"../function\"\nimport { ifNullish } from \"../nullish\"\n\nexport type PlainObject = Record<keyof any, unknown>\nexport type EmptyObject = Record<keyof any, never>\n\nexport const isNonNullObject = (input: unknown): input is object =>\n typeof input === `object` && input !== null\n\nexport const isPlainObject = (input: unknown): input is PlainObject =>\n isNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype\n\nexport const isEmptyObject = (input: unknown): input is EmptyObject =>\n isPlainObject(input) && Object.keys(input).length === 0\n\n/* prettier-ignore */\nexport const isRecord = <\n KEY extends keyof any, \n VAL\n >( \n isKey: Refinement<keyof any, KEY>,\n isValue: Refinement<unknown, VAL>\n ) =>\n (input: unknown): input is Record<KEY, VAL> =>\n isPlainObject(input) &&\n Object.entries(input).every(([k, v]) => isKey(k) && isValue(v))\n/* prettier-ignore-end */\n\nexport type HasPropertiesOptions = {\n readonly allowExtraProperties?: boolean\n}\nexport const hasProperties = <OBJ extends object>(\n isValue: {\n [K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n },\n options: HasPropertiesOptions = { allowExtraProperties: false }\n): Refinement<unknown, OBJ> => {\n const name = `{${recordToEntries(\n isValue as Record<keyof any, Refinement<any, any>>\n )\n .map(([k, v]) => String(k) + `:` + v.name)\n .join(`,`)}}`\n\n const _ = {\n [name]: (input: unknown): input is OBJ =>\n isPlainObject(input) &&\n pipe(\n isValue,\n Object.entries,\n every(([key, val]) => key in input || val(undefined))\n ) &&\n pipe(\n input,\n mob((val, key) =>\n pipe(\n isValue,\n access(key),\n ifNullish(() => options.allowExtraProperties),\n pass(val)\n )\n ),\n Object.values,\n allTrue\n ),\n }\n return _[name]\n}\n\nexport const doesExtend =\n /* alias for hasExactProperties with allowExtraProperties */\n <OBJ extends object>(isValue: {\n [K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n }): Refinement<unknown, OBJ> =>\n hasProperties(isValue, { allowExtraProperties: true })\n\nexport const hasExactProperties =\n /* alias for hasProperties without allowExtraProperties */\n <OBJ extends object>(isValue: {\n [K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n }): Refinement<unknown, OBJ> =>\n hasProperties(isValue, { allowExtraProperties: false })\n","export const key =\n <T extends object>(k: keyof T) =>\n (obj: Exclude<object, null>): unknown =>\n (obj as Record<keyof any, any>)[k]\n\nexport const access = <V, T extends Record<keyof any, V>>(\n k: keyof any\n): {\n (obj: T): T[keyof T] | undefined\n in: (obj: T) => T[keyof T] | undefined\n} =>\n Object.assign((obj: T) => obj[k as keyof T], {\n in: (obj: T) => obj[k as keyof T],\n })\n","export type Entries<K extends keyof any, V> = [key: K, value: V][]\n\nexport const recordToEntries = <K extends keyof any, V>(\n obj: Record<K, V>\n): Entries<K, V> => Object.entries(obj) as Entries<K, V>\n\nexport const entriesToRecord = <K extends keyof any, V>(\n entries: Entries<K, V>\n): Record<K, V> => Object.fromEntries(entries) as Record<K, V>\n","import { pipe } from \"fp-ts/function\"\n\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { map } from \"../array\"\n\nexport const mapObject = <K extends keyof any, I, O>(\n obj: Record<K, I>,\n fn: (val: I, key: K) => O\n): Record<K, O> =>\n pipe(\n obj,\n recordToEntries,\n map(([key, val]) => [key, fn(val, key)] as const),\n entriesToRecord\n )\n\nexport const mob =\n <K extends keyof any, I, O>(fn: (val: I, key: K) => O) =>\n (obj: Record<K, I>): Record<K, O> =>\n mapObject(obj, fn)\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nexport const isUndefined = (input: unknown): input is undefined =>\n input === undefined\n\nexport const ifDefined = <T>(\n validate: Refinement<unknown, T>\n): Refinement<unknown, T | undefined> =>\n ((input) => isUndefined(input) || validate(input)) as Refinement<\n unknown,\n T | undefined\n >\n\nexport const isNull = (input: unknown): input is null => input === null\n\nexport const isNullish = (input: unknown): input is null | undefined =>\n isUndefined(input) || isNull(input)\n\nexport type NullSafeUnion<Base, Extension> = Extension extends null\n ? Base\n : Base & Extension\n\nexport type NullSafeRest<MaybeArg> = MaybeArg extends null\n ? [] | [undefined]\n : [MaybeArg]\n\nexport interface Discard {\n readonly _discard: unique symbol\n}\n\nexport const ifNullish =\n <X, Y>(alt: Y) =>\n (input: X): Exclude<X, null | undefined> | Y =>\n (input ?? alt) as Exclude<X, null | undefined> | Y\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nexport * from \"./refined\"\n\nexport const canExist = (_: unknown): _ is unknown => true\nexport const cannotExist = (_: unknown): _ is never => false\n\nexport const isLiteral =\n <T extends boolean | number | string>(value: T): Refinement<unknown, T> =>\n (input: unknown): input is T =>\n input === value\n\nexport const isWithin =\n <Options extends ReadonlyArray<any>>(args: Options) =>\n (input: unknown): input is Options[number] =>\n args.includes(input as Options[number])\n\nexport const ensure =\n <T>(isType: Refinement<unknown, T>) =>\n (input: unknown): T => {\n if (!isType(input)) {\n throw new TypeError(`Expected ${input} to be of type ${isType.name}`)\n }\n return input as T\n }\n\nexport const ensureAgainst =\n <A, B>(isType: Refinement<unknown, A>) =>\n (input: A | B): Exclude<A | B, A> => {\n if (isType(input)) {\n throw new TypeError(`Expected ${input} to not be of type ${isType.name}`)\n }\n return input as Exclude<A | B, A>\n }\n\nexport type ExtendsSome<A, B> = Refinement<unknown, A | B> & {\n or: <C>(isType: Refinement<unknown, C>) => ExtendsSome<unknown, A | B | C>\n}\nexport const couldBe = <A>(\n isTypeA: Refinement<unknown, A>,\n logging = false,\n refinements: Refinement<unknown, any>[] = [isTypeA]\n): {\n (input: unknown): input is A\n or: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n} => {\n const name = `(${refinements.map((r) => r.name || `anon`).join(` | `)})`\n const _ = {\n [name]: (input: unknown): input is A =>\n refinements.some(\n (refinement) => (\n logging &&\n console.log(\n refinements.map((r) => r.name || `anon`).join(` | `),\n `>`,\n refinement.name ?? `anon`,\n `:`,\n refinement(input)\n ),\n refinement(input)\n )\n ),\n }\n const checkTypes: {\n (input: unknown): input is A\n or: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n } = Object.assign(_[name], {\n or: <B>(isTypeB: Refinement<unknown, B>): ExtendsSome<A, B> =>\n couldBe(isTypeB, logging, [...refinements, isTypeB]),\n })\n return checkTypes\n}\n\nexport const isUnion = couldBe(cannotExist)\n\nexport type ExtendsAll<A, B> = Refinement<unknown, A & B> & {\n and: <C>(isType: Refinement<unknown, C>) => ExtendsAll<A & B, C>\n}\n\nexport const mustBe = <A>(\n isTypeA: Refinement<unknown, A>,\n logging = false,\n refinements: Refinement<unknown, any>[] = [isTypeA]\n): {\n (input: unknown): input is A\n and: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n} => {\n const name = `(${refinements.map((r) => r.name || `anon`).join(` & `)})`\n const _ = {\n [name]: (input: unknown): input is A =>\n refinements.every(\n (refinement) => (\n logging &&\n console.log(\n refinements.map((r) => r.name || `anon`).join(` & `),\n `>`,\n refinement.name || `anon`,\n `:`,\n refinement(input)\n ),\n refinement(input)\n )\n ),\n }\n const checkTypes: {\n (input: unknown): input is A\n and: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n } = Object.assign(_[name], {\n and: <B>(isTypeB: Refinement<unknown, B>): ExtendsAll<A, B> =>\n mustBe(isTypeB, logging, [...refinements, isTypeB]) as ExtendsAll<A, B>,\n })\n return checkTypes\n}\n\nexport const isIntersection = mustBe(canExist)\n\nexport const isClass =\n <ClassSignature extends abstract new (...args: any) => any>(\n C: ClassSignature\n ) =>\n (input: unknown): input is InstanceType<ClassSignature> =>\n input instanceof C\n","import type { RelationData } from \"./core-relation-data\"\nimport type { JsonObj } from \"../json\"\n\nexport const getRelatedIds = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n relationMap: RelationData<CONTENT, A, B>,\n id: string\n): string[] => relationMap.relations[id] ?? []\n\nexport const getRelatedId = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n relationMap: RelationData<CONTENT, A, B>,\n id: string\n): string | undefined => {\n const relations = getRelatedIds(relationMap, id)\n if (relations.length > 1) {\n console.warn(\n `entry with id ${id} was not expected to have multiple relations`\n )\n }\n return relations[0]\n}\n","import type { Json, JsonInterface, JsonObj } from \"~/packages/anvl/src/json\"\n\nimport { Join } from \".\"\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\n\nexport const makeJsonInterface = <\n CONTENT extends JsonObj | null = null,\n A extends string = `from`,\n B extends string = `to`\n>(\n join: Join<CONTENT, A, B>,\n ...params: CONTENT extends null ? [] : [(x: Json) => x is CONTENT]\n): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n const isContent = params[0] as (x: Json) => x is CONTENT\n const { a, b } = join\n const options: IsRelationDataOptions<CONTENT, A, B> = {\n from: a,\n to: b,\n isContent,\n }\n return {\n toJson: (join) => join.toJSON(),\n fromJson: (json) => Join.fromJSON(json, options),\n }\n}\n","import { pipe } from \"fp-ts/function\"\n\nimport type { Identified } from \"~/packages/anvl/src/id/identified\"\nimport { isEmptyObject } from \"~/packages/anvl/src/object/refinement\"\n\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getRelationEntries } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\nimport type { JsonObj } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\n\nexport const makeContentId = (idA: string, idB: string): string =>\n [idA, idB].sort().join(`/`)\n\nexport const getContent = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n relationMap: RelationData<CONTENT, A, B>,\n idA: string,\n idB: string\n): CONTENT | undefined => relationMap.contents[makeContentId(idA, idB)]\n\nexport const setContent = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n map: RelationData<CONTENT, A, B>,\n idA: string,\n idB: string,\n content: CONTENT\n): RelationData<CONTENT, A, B> => ({\n ...map,\n contents: {\n ...map.contents,\n [makeContentId(idA, idB)]: content,\n },\n})\n\nexport const getRelations = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n relationMap: RelationData<CONTENT, A, B>,\n id: string\n): (CONTENT extends null ? Identified : CONTENT & Identified)[] =>\n getRelationEntries(relationMap, id).map(\n ([id, content]) =>\n ({\n id,\n ...content,\n } as CONTENT extends null ? Identified : CONTENT & Identified)\n )\n\nexport const setRelations = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n current: RelationData<CONTENT, A, B>,\n subject: { [from in A]: string } | { [to in B]: string },\n relations: (CONTENT extends null ? Identified : CONTENT & Identified)[]\n): RelationData<CONTENT, A, B> => {\n const idA: string | undefined = (subject as { [from in A]: string })[current.a]\n const idB: string | undefined = (subject as { [to in B]: string })[current.b]\n return pipe(\n current,\n (relationData) => {\n const relatedIds = getRelatedIds(current, idA)\n const removedIds = relatedIds.filter(\n (id) => !relations.some((r) => r.id === id)\n )\n let step = relationData\n for (const id of removedIds) {\n const remove = {\n [current.a]: idA ?? id,\n [current.b]: idB ?? id,\n } as Record<A | B, string>\n step = removeRelation(step, remove)\n }\n return step\n },\n (relationData) => {\n let step = relationData\n for (const { id, ...rest } of relations) {\n const content = isEmptyObject(rest) ? undefined : rest\n step = setRelationWithContent(\n step,\n { [current.a]: idA ?? id, [current.b]: idB ?? id } as Record<\n A | B,\n string\n >,\n // @ts-expect-error hacky\n content as NullSafeRest<CONTENT>\n )\n }\n return step\n },\n (relationData) => {\n const newlyOrderedIds = relations.map((r) => r.id)\n return {\n ...relationData,\n relations: {\n ...relationData.relations,\n [idA ?? idB]: newlyOrderedIds,\n },\n }\n }\n )\n}\n","import type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getContent } from \"./relation-contents\"\nimport type { JsonObj } from \"../json\"\n\nexport const getRelationEntries = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n relationMap: RelationData<CONTENT, A, B>,\n idA: string\n): [string, CONTENT][] =>\n getRelatedIds(relationMap, idA).map((idB) => [\n idB,\n getContent(relationMap, idA, idB) as CONTENT,\n ])\n\nexport const getRelationRecord = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n relationMap: RelationData<CONTENT, A, B>,\n id: string\n): Record<string, CONTENT> =>\n Object.fromEntries(getRelationEntries(relationMap, id))\n","import { pipe } from \"fp-ts/function\"\nimport { isString } from \"fp-ts/string\"\n\nimport type { RelationData } from \"./core-relation-data\"\nimport { isEmptyArray, isOneOf, map } from \"../array\"\nimport { comprises } from \"../array/venn\"\nimport type { JsonObj } from \"../json\"\nimport type { RequireAtLeastOne } from \"../object\"\nimport { treeShake as removeProperties } from \"../object\"\nimport { entriesToRecord, recordToEntries } from \"../object/entries\"\nimport { split } from \"../string/split\"\n\nexport const removeSpecific = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n current: RelationData<CONTENT, A, B>,\n idA: string,\n idB: string\n): RelationData<CONTENT, A, B> => {\n const isIdForRemoval = isOneOf(idA, idB)\n return {\n ...current,\n relations: pipe(\n current.relations,\n recordToEntries,\n map(([id, relations]): [id: string, fewerRelations: string[]] => [\n id,\n isIdForRemoval(id)\n ? relations.filter((relation) => !isIdForRemoval(relation))\n : relations,\n ]),\n entriesToRecord,\n removeProperties(isEmptyArray)\n ),\n contents: pipe(\n current.contents,\n removeProperties(\n (_, key) => isString(key) && pipe(key, split(`/`), comprises([idA, idB]))\n )\n ),\n }\n}\n\nexport const removeAll = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n current: RelationData<CONTENT, A, B>,\n idToRemove: string\n): RelationData<CONTENT, A, B> => {\n const next: RelationData<CONTENT, A, B> = {\n ...current,\n relations: pipe(\n current.relations,\n recordToEntries,\n map(([id, relations]): [id: string, fewerRelations: string[]] => [\n id,\n relations.filter((relation) => relation !== idToRemove),\n ]),\n entriesToRecord,\n removeProperties((val, key) => key === idToRemove || isEmptyArray(val))\n ),\n contents: pipe(\n current.contents,\n removeProperties(\n (_, key) => isString(key) && key.split(`/`).includes(idToRemove)\n )\n ),\n }\n return next\n}\n\nexport const removeRelation = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n current: RelationData<CONTENT, A, B>,\n relation: Partial<Record<A | B, string>>\n): RelationData<CONTENT, A, B> => {\n const idA: string | undefined = (relation as { [key in A | B]: string })[\n current.a\n ]\n const idB: string | undefined = (relation as { [key in A | B]: string })[\n current.b\n ]\n return idB ? removeSpecific(current, idA, idB) : removeAll(current, idA)\n}\n","import { flow, pipe } from \"fp-ts/function\"\nimport type { Refinement } from \"fp-ts/lib/Refinement\"\n\nimport { deepMob } from \"./deepMob\"\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { isPlainObject } from \"./refinement\"\nimport { includesAny, map, reduce, filter } from \"../array\"\nimport { isUndefined } from \"../nullish\"\n\nexport * from \"./access\"\nexport * from \"./deepMob\"\nexport * from \"./entries\"\nexport * from \"./mapObject\"\nexport * from \"./modify\"\nexport * from \"./patch\"\nexport * from \"./refinement\"\nexport * from \"./sprawl\"\n\nexport const redact =\n <K extends keyof any>(...args: K[]) =>\n <O extends Record<K, any>>(obj: O): Omit<O, K> =>\n reduce<K, O>((acc, key) => (delete acc[key], acc), obj)(args)\n\nexport type Redacted<Holder, RedactProp extends keyof any> = Omit<\n {\n [K in keyof Holder]: Holder[K] extends (infer Item)[]\n ? Redacted<Item, RedactProp>[]\n : Redacted<Omit<Holder[K], RedactProp>, RedactProp>\n },\n RedactProp\n>\nexport const redactDeep =\n <K extends keyof any>(...args: K[]) =>\n <O extends Record<K, any>>(base: O): Redacted<O, K> =>\n deepMob(base, (node, path) =>\n includesAny(args)(path)\n ? {\n meta: { pathComplete: true },\n }\n : {\n data: isPlainObject(node)\n ? redact(...args)(node as Record<keyof any, any>)\n : node,\n }\n )\n\nexport const select =\n <Key extends keyof any>(...args: Key[]) =>\n <Obj extends object>(\n obj: Obj\n ): {\n // @ts-expect-error fuk u\n [K in keyof Pick<Obj, Key>]: any extends Pick<Obj, Key>[K]\n ? undefined\n : // @ts-expect-error fuk u\n Pick<Obj, Key>[K]\n } =>\n // @ts-expect-error fuk u ts\n reduce<Key, Pick<Obj, Key>>(\n // @ts-expect-error i will fite u\n (acc, key) => (key in obj ? (acc[key] = obj[key as keyof Obj]) : acc, acc),\n // @ts-expect-error fuk u\n {} as Pick<Obj, Key>\n )(args)\n\nexport const treeShake =\n (shouldDiscard: (val: unknown, key: keyof any) => boolean = isUndefined) =>\n <T extends object>(\n obj: T\n ): T extends Record<keyof any, unknown> ? T : Partial<T> => {\n const newObj = {} as T\n const entries = Object.entries(obj) as [keyof T, any][]\n entries.forEach(([key, val]) =>\n !shouldDiscard(val, key) ? (newObj[key] = val) : null\n )\n return newObj as T extends Record<keyof any, unknown> ? T : Partial<T>\n }\n\nexport type KeysExtending<T, V> = keyof {\n [K in keyof T]: T[K] extends V ? K : never\n}\n\nconst a: never | null = null\n\nexport const filterProperties =\n <DiscardVal, DiscardKey extends keyof any>(\n shouldDiscardVal: Refinement<unknown, DiscardVal>,\n shouldDiscardKey: Refinement<unknown, DiscardKey>\n ) =>\n <P extends Record<keyof any, any>>(\n props: P\n ): DiscardVal extends never\n ? DiscardKey extends never\n ? P\n : Omit<P, DiscardKey>\n : Omit<P, DiscardKey | KeysExtending<P, DiscardVal>> =>\n // @ts-expect-error oh well\n pipe(\n props,\n recordToEntries,\n filter(\n (\n entry\n ): entry is [\n Exclude<keyof P, DiscardKey>,\n Exclude<P[keyof P], DiscardVal>\n ] => !shouldDiscardKey(entry[0]) || !shouldDiscardVal(entry[1])\n ),\n entriesToRecord\n )\n\nexport const delve = (\n obj: Record<keyof any, any>,\n path: ReadonlyArray<keyof any>\n): Error | { found: unknown } => {\n const found = path.reduce((acc, key) => acc?.[key], obj)\n return found === undefined ? new Error(`Not found`) : { found }\n}\n\nexport const tweak = (\n obj: Record<keyof any, any>,\n path: ReadonlyArray<keyof any>,\n value: unknown\n): void =>\n path.reduce((acc, key, i) => {\n if (i === path.length - 1) {\n acc[key] = value\n }\n if (acc[key] === undefined) {\n acc[key] = typeof key === `number` ? [] : {}\n }\n return acc[key]\n }, obj)\n\nexport type RequireAtLeastOne<T> = {\n [K in keyof T]-?: Partial<Pick<T, Exclude<keyof T, K>>> & Required<Pick<T, K>>\n}[keyof T]\n","export const split =\n (separator: string) =>\n (str: string): string[] =>\n str.split(separator)\n","import type { RelationData } from \"./core-relation-data\"\nimport { getRelatedId } from \"./get-related-ids\"\nimport { setContent } from \"./relation-contents\"\nimport { addTo, isEmptyArray } from \"../array\"\nimport type { JsonObj } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\nimport { treeShake as removeProperties } from \"../object\"\n\nexport const setManyToMany = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n map: RelationData<CONTENT, A, B>,\n idA: string,\n idB: string,\n ...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n const next = {\n ...map,\n relations: {\n ...map.relations,\n [idA]: addTo(map.relations[idA] ?? [])(idB),\n [idB]: addTo(map.relations[idB] ?? [])(idA),\n },\n }\n const content = rest[0] as CONTENT | undefined\n return content ? setContent(next, idA, idB, content) : next\n}\n\nconst removeEmpties = removeProperties(isEmptyArray)\n\nexport const set1ToMany = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n current: RelationData<CONTENT, A, B>,\n leaderId: string,\n followerId: string,\n ...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n const relations = { ...current.relations }\n const prevLeaderId = getRelatedId(current, followerId)\n const next = {\n ...current,\n relations: removeEmpties({\n ...relations,\n ...(prevLeaderId &&\n prevLeaderId !== leaderId && {\n [prevLeaderId]: relations[prevLeaderId].filter(\n (id) => id !== followerId\n ),\n }),\n [followerId]: [leaderId],\n [leaderId]: addTo(relations[leaderId] ?? [])(followerId),\n }),\n }\n const content = rest[0] as CONTENT | undefined\n return content ? setContent(next, leaderId, followerId, content) : next\n}\n\nexport const set1To1 = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n current: RelationData<CONTENT, A, B>,\n wifeId: string,\n husbandId: string,\n ...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n const prevWifeId = getRelatedId(current, husbandId)\n const prevHusbandId = getRelatedId(current, wifeId)\n const next = {\n ...current,\n relations: removeEmpties({\n ...current.relations,\n ...(prevWifeId && { [prevWifeId]: [] }),\n ...(prevHusbandId && { [prevHusbandId]: [] }),\n [wifeId]: [husbandId],\n [husbandId]: [wifeId],\n }),\n }\n\n const content = rest[0] as CONTENT | undefined\n return content ? setContent(next, wifeId, husbandId, content) : next\n}\n\nexport const setRelationWithContent = <\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n>(\n current: RelationData<CONTENT, A, B>,\n relation: Record<A | B, string>,\n ...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n const { [current.a]: idA, [current.b]: idB } = relation\n // console.log({\n // current,\n // relation,\n // idA,\n // idB,\n // })\n switch (current.relationType) {\n case `1:1`:\n return set1To1(current, idA, idB, ...rest)\n case `1:n`:\n return set1ToMany(current, idA, idB, ...rest)\n case `n:n`:\n return setManyToMany(current, idA, idB, ...rest)\n }\n}\n","import type { Refinement } from \"fp-ts/lib/Refinement\"\n\nimport type { Identified } from \"~/packages/anvl/src/id/identified\"\n\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\nimport { EMPTY_RELATION_DATA, isRelationData } from \"./core-relation-data\"\nimport { getRelatedId, getRelatedIds } from \"./get-related-ids\"\nimport { makeJsonInterface } from \"./make-json-interface\"\nimport { getContent, getRelations, setRelations } from \"./relation-contents\"\nimport { getRelationEntries, getRelationRecord } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\nimport type { Json, JsonInterface, JsonObj } from \"../json\"\nimport type { NullSafeRest, NullSafeUnion } from \"../nullish\"\n\nexport class Join<\n CONTENT extends JsonObj | null = null,\n A extends string = `from`,\n B extends string = `to`\n> implements RelationData<CONTENT, A, B>\n{\n public readonly relationType: `1:1` | `1:n` | `n:n`\n public readonly a: A = `from` as A\n public readonly b: B = `to` as B\n public readonly relations: Record<string, string[]>\n public readonly contents: Record<string, CONTENT>\n public constructor(json?: Partial<RelationData<CONTENT, A, B>>) {\n Object.assign(this, {\n ...EMPTY_RELATION_DATA,\n ...json,\n makeJsonInterface: this.makeJsonInterface,\n })\n }\n public toJSON(): RelationData<CONTENT, A, B> {\n return {\n relationType: this.relationType,\n relations: this.relations,\n contents: this.contents,\n a: this.a,\n b: this.b,\n }\n }\n public static fromJSON<\n CONTENT extends JsonObj | null,\n A extends string,\n B extends string\n >(\n json: Json,\n options?: IsRelationDataOptions<CONTENT, A, B>\n ): Join<CONTENT, A, B> {\n const isValid = isRelationData<CONTENT, A, B>(options)(json)\n if (isValid) {\n return new Join<CONTENT, A, B>(json)\n }\n throw new Error(\n `Saved JSON for this Join is invalid: ${JSON.stringify(json)}`\n )\n }\n\n public from<AA extends string>(newA: AA): Join<CONTENT, AA, B> {\n return new Join({ ...this, a: newA })\n }\n\n public to<BB extends string>(newB: BB): Join<CONTENT, A, BB> {\n return new Join({ ...this, b: newB })\n }\n\n public makeJsonInterface = (\n ...params: CONTENT extends null ? [] : [Refinement<unknown, CONTENT>]\n ): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n return makeJsonInterface<CONTENT, A, B>(this, ...params)\n }\n\n public getRelatedId(id: string): string | undefined {\n return getRelatedId(this, id)\n }\n public getRelatedIds(id: string): string[] {\n return getRelatedIds(this, id)\n }\n public getContent(idA: string, idB: string): CONTENT | undefined {\n return getContent(this, idA, idB)\n }\n public getRelationEntries(id: string): [string, CONTENT][] {\n return getRelationEntries(this, id)\n }\n public getRelationRecord(id: string): Record<string, CONTENT> {\n return getRelationRecord(this, id)\n }\n public getRelation(\n id: string\n ): NullSafeUnion<Identified, CONTENT> | undefined {\n return getRelations(this, id)[0]\n }\n public getRelations(id: string): NullSafeUnion<Identified, CONTENT>[] {\n return getRelations(this, id)\n }\n public setRelations(\n subject: { [from in A]: string } | { [to in B]: string },\n relations: NullSafeUnion<Identified, CONTENT>[]\n ): Join<CONTENT, A, B> {\n return new Join(setRelations(this, subject, relations))\n }\n public set(\n relation: { [key in A | B]: string },\n ...rest: NullSafeRest<CONTENT>\n ): Join<CONTENT, A, B> {\n return new Join(setRelationWithContent(this, relation, ...rest))\n }\n public remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B> {\n return new Join(\n removeRelation(this, relation as Partial<Record<A | B, string>>)\n )\n }\n}\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store, StoreCore } from \".\"\nimport {\n abortTransaction,\n applyTransaction,\n buildTransaction,\n deposit,\n IMPLICIT,\n} from \".\"\nimport type { TransactionOptions, TransactionToken, TransactionUpdate } from \"..\"\nimport { getState, setState } from \"..\"\n\nexport type Transaction<ƒ extends ƒn> = {\n key: string\n type: `transaction`\n install: (store: Store) => void\n subject: Rx.Subject<TransactionUpdate<ƒ>>\n run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>\n}\n\nexport function transaction__INTERNAL<ƒ extends ƒn>(\n options: TransactionOptions<ƒ>,\n store: Store = IMPLICIT.STORE\n): TransactionToken<ƒ> {\n const newTransaction: Transaction<ƒ> = {\n key: options.key,\n type: `transaction`,\n run: (...params: Parameters<ƒ>) => {\n buildTransaction(options.key, params, store)\n try {\n const output = options.do(\n {\n get: (token) => getState(token, store),\n set: (token, value) => setState(token, value, store),\n },\n ...params\n )\n applyTransaction(output, store)\n return output\n } catch (thrown) {\n abortTransaction(store)\n store.config.logger?.error(`Transaction ${options.key} failed`, thrown)\n throw thrown\n }\n },\n install: (store) => transaction__INTERNAL(options, store),\n subject: new Rx.Subject(),\n }\n const core = target(store)\n core.transactions = HAMT.set(\n newTransaction.key,\n newTransaction,\n core.transactions\n )\n const token = deposit(newTransaction)\n store.subject.transactionCreation.next(token)\n return token\n}\n\nexport const target = (store: Store = IMPLICIT.STORE): StoreCore =>\n store.transactionStatus.phase === `building`\n ? store.transactionStatus.core\n : store\n","import * as Rx from \"rxjs\"\n\nimport type { Serializable } from \"~/packages/anvl/src/json\"\nimport { stringifyJson } from \"~/packages/anvl/src/json\"\n\nimport type { Store } from \".\"\nimport {\n atom__INTERNAL,\n withdraw,\n selector__INTERNAL,\n target,\n deposit,\n IMPLICIT,\n} from \".\"\nimport type {\n AtomFamily,\n AtomFamilyOptions,\n AtomToken,\n FamilyMetadata,\n ReadonlySelectorFamily,\n ReadonlySelectorFamilyOptions,\n ReadonlySelectorToken,\n SelectorFamily,\n SelectorFamilyOptions,\n SelectorToken,\n} from \"..\"\n\nexport function atomFamily__INTERNAL<T, K extends Serializable>(\n options: AtomFamilyOptions<T, K>,\n store: Store = IMPLICIT.STORE\n): AtomFamily<T, K> {\n const subject = new Rx.Subject<AtomToken<T>>()\n return Object.assign(\n (key: K): AtomToken<T> => {\n const subKey = stringifyJson(key)\n const family: FamilyMetadata = { key: options.key, subKey }\n const fullKey = `${options.key}(${subKey})`\n const existing = withdraw({ key: fullKey, type: `atom` }, store)\n const token: AtomToken<any> = existing\n ? deposit(existing)\n : atom__INTERNAL<T>(\n {\n key: fullKey,\n default:\n options.default instanceof Function\n ? options.default(key)\n : options.default,\n effects: options.effects?.(key),\n },\n family,\n store\n )\n subject.next(token)\n return token\n },\n {\n key: options.key,\n type: `atom_family`,\n subject,\n } as const\n )\n}\n\nexport function readonlySelectorFamily__INTERNAL<T, K extends Serializable>(\n options: ReadonlySelectorFamilyOptions<T, K>,\n store?: Store\n): ReadonlySelectorFamily<T, K> {\n const core = target(store)\n const subject = new Rx.Subject<ReadonlySelectorToken<T>>()\n return Object.assign(\n (key: K): ReadonlySelectorToken<T> => {\n const subKey = stringifyJson(key)\n const family: FamilyMetadata = { key: options.key, subKey }\n const fullKey = `${options.key}(${subKey})`\n const existing = core.readonlySelectors.get(fullKey)\n if (existing) {\n return deposit(existing)\n }\n return selector__INTERNAL<T>(\n {\n key: fullKey,\n get: options.get(key),\n },\n family,\n store\n ) as ReadonlySelectorToken<T>\n },\n {\n key: options.key,\n type: `readonly_selector_family`,\n subject,\n } as const\n ) as ReadonlySelectorFamily<T, K>\n}\n\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n options: SelectorFamilyOptions<T, K>,\n store?: Store\n): SelectorFamily<T, K>\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n options: ReadonlySelectorFamilyOptions<T, K>,\n store?: Store\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n options: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n store: Store = IMPLICIT.STORE\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n const isReadonly = !(`set` in options)\n\n if (isReadonly) {\n return readonlySelectorFamily__INTERNAL(options, store)\n }\n const core = target(store)\n const subject = new Rx.Subject<SelectorToken<T>>()\n\n return Object.assign(\n (key: K): SelectorToken<T> => {\n const subKey = stringifyJson(key)\n const family: FamilyMetadata = { key: options.key, subKey }\n const fullKey = `${options.key}(${subKey})`\n const existing = core.selectors.get(fullKey)\n if (existing) {\n return deposit(existing)\n }\n const token = selector__INTERNAL<T>(\n {\n key: fullKey,\n get: options.get(key),\n set: options.set(key),\n },\n family,\n store\n )\n subject.next(token)\n return token\n },\n {\n key: options.key,\n type: `selector_family`,\n } as const\n ) as SelectorFamily<T, K>\n}\n","import { pipe } from \"fp-ts/function\"\n\nexport * from \"./refine\"\nexport * from \"./json-interface\"\n\nexport const serializeSet = <T>(set: Set<T>): string =>\n pipe(set, Array.from, JSON.stringify)\n\nexport const deserializeSet = <T>(str: string): Set<T> =>\n pipe(str, JSON.parse, Array.from, (a) => new Set(a as T[]))\n\nexport type Primitive = boolean | number | string | null\n\nexport type Serializable =\n | Primitive\n | Readonly<{ [key: string]: Serializable }>\n | ReadonlyArray<Serializable>\n\nexport type JsonObj<\n Key extends string = string,\n Value extends Serializable = Serializable\n> = Record<Key, Value>\n\nexport type JsonArr<Element extends Serializable = Serializable> =\n ReadonlyArray<Element>\n\nexport type Json = JsonArr | JsonObj | Primitive\n\nexport const parseJson = <J extends Json, S extends Stringified<J> | string>(\n str: S | string\n): S extends Stringified<J> ? J : Json => JSON.parse(str)\n\nexport type Stringified<J extends Json> = string & { __json: J }\n\nexport const stringifyJson = <J extends Json>(json: J): Stringified<J> =>\n JSON.stringify(json) as Stringified<J>\n\nexport type Empty = Record<string, never>\n\nexport const JSON_TYPE_NAMES = [\n `array`,\n `boolean`,\n `null`,\n `number`,\n `object`,\n `string`,\n] as const\n\nexport type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json> {\n array: JsonArr\n boolean: boolean\n null: null\n number: number\n object: JsonObj\n string: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n array: [],\n boolean: false,\n null: null,\n number: 0,\n object: {},\n string: ``,\n}\n","export * from \"./attach-meta\"\nexport * from \"./meta-state\"\nexport * from \"./meta-timelines\"\nexport * from \"./meta-transactions\"\n","import type { AtomToken, ReadonlySelectorToken, SelectorToken } from \"../..\"\nimport { selector, atom } from \"../..\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\n\nexport type StateTokenIndex<\n Token extends\n | AtomToken<unknown>\n | ReadonlySelectorToken<unknown>\n | SelectorToken<unknown>,\n> = Record<\n string,\n | Token\n | {\n key: string\n familyMembers: Record<string, Token>\n }\n>\n\nexport type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>\nexport type SelectorTokenIndex = StateTokenIndex<\n ReadonlySelectorToken<unknown> | SelectorToken<unknown>\n>\n\nexport const attachMetaAtoms = (\n store: Store = IMPLICIT.STORE\n): ReadonlySelectorToken<AtomTokenIndex> => {\n const atomTokenIndexState__INTERNAL = atom<AtomTokenIndex>({\n key: `👁🗨_atom_token_index__INTERNAL`,\n default: () =>\n [...store.atoms].reduce<AtomTokenIndex>((acc, [key]) => {\n acc[key] = { key, type: `atom` }\n return acc\n }, {}),\n effects: [\n ({ setSelf }) => {\n store.subject.atomCreation.subscribe((atomToken) => {\n if (store.operation.open) {\n return\n }\n setSelf((state) => {\n const { key, family } = atomToken\n if (family) {\n const { key: familyKey, subKey } = family\n const current = state[familyKey]\n if (current === undefined || `familyMembers` in current) {\n const familyKeyState = current || {\n key: familyKey,\n familyMembers: {},\n }\n return {\n ...state,\n [familyKey]: {\n ...familyKeyState,\n familyMembers: {\n ...familyKeyState.familyMembers,\n [subKey]: atomToken,\n },\n },\n }\n }\n }\n return {\n ...state,\n [key]: atomToken,\n }\n })\n })\n },\n ],\n })\n return selector({\n key: `👁🗨_atom_token_index`,\n get: ({ get }) => get(atomTokenIndexState__INTERNAL),\n })\n}\n\nexport const attachMetaSelectors = (\n store: Store = IMPLICIT.STORE\n): ReadonlySelectorToken<SelectorTokenIndex> => {\n const readonlySelectorTokenIndexState__INTERNAL = atom<SelectorTokenIndex>({\n key: `👁🗨_selector_token_index__INTERNAL`,\n default: () =>\n Object.assign(\n [...store.readonlySelectors].reduce<SelectorTokenIndex>((acc, [key]) => {\n acc[key] = { key, type: `readonly_selector` }\n return acc\n }, {}),\n [...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {\n acc[key] = { key, type: `selector` }\n return acc\n }, {})\n ),\n effects: [\n ({ setSelf }) => {\n store.subject.selectorCreation.subscribe((selectorToken) => {\n if (store.operation.open) {\n return\n }\n setSelf((state) => {\n const { key, family } = selectorToken\n if (family) {\n const { key: familyKey, subKey } = family\n const current = state[familyKey]\n if (current === undefined || `familyMembers` in current) {\n const familyKeyState = current || {\n key: familyKey,\n familyMembers: {},\n }\n return {\n ...state,\n [familyKey]: {\n ...familyKeyState,\n familyMembers: {\n ...familyKeyState.familyMembers,\n [subKey]: selectorToken,\n },\n },\n }\n }\n }\n return {\n ...state,\n [key]: selectorToken,\n }\n })\n })\n },\n ],\n })\n return selector({\n key: `👁🗨_selector_token_index`,\n get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),\n })\n}\n","import type { AtomTokenIndex, SelectorTokenIndex } from \"./meta-state\"\nimport { attachMetaAtoms, attachMetaSelectors } from \"./meta-state\"\nimport type { ReadonlySelectorToken } from \"../..\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\n\nexport const attachMetaState = (\n store: Store = IMPLICIT.STORE\n): {\n atomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>\n selectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>\n} => {\n return {\n atomTokenIndexState: attachMetaAtoms(store),\n selectorTokenIndexState: attachMetaSelectors(store),\n }\n}\n","import HAMT from \"hamt_plus\"\nimport type * as Rx from \"rxjs\"\n\nimport type { Store } from \".\"\nimport { target, IMPLICIT } from \".\"\nimport { createReadWriteSelector } from \"./selector/create-read-write-selector\"\nimport { createReadonlySelector } from \"./selector/create-readonly-selector\"\nimport type {\n FamilyMetadata,\n ReadonlySelectorOptions,\n ReadonlySelectorToken,\n SelectorOptions,\n SelectorToken,\n} from \"..\"\n\nexport type Selector<T> = {\n key: string\n type: `selector`\n family?: FamilyMetadata\n install: (store: Store) => void\n subject: Rx.Subject<{ newValue: T; oldValue: T }>\n get: () => T\n set: (newValue: T | ((oldValue: T) => T)) => void\n}\nexport type ReadonlySelector<T> = {\n key: string\n type: `readonly_selector`\n family?: FamilyMetadata\n install: (store: Store) => void\n subject: Rx.Subject<{ newValue: T; oldValue: T }>\n get: () => T\n}\n\nexport function selector__INTERNAL<T>(\n options: SelectorOptions<T>,\n family?: FamilyMetadata,\n store?: Store\n): SelectorToken<T>\nexport function selector__INTERNAL<T>(\n options: ReadonlySelectorOptions<T>,\n family?: FamilyMetadata,\n store?: Store\n): ReadonlySelectorToken<T>\nexport function selector__INTERNAL<T>(\n options: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n family?: FamilyMetadata,\n store: Store = IMPLICIT.STORE\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n const core = target(store)\n\n if (HAMT.has(options.key, core.selectors)) {\n store.config.logger?.error(\n `Key \"${options.key}\" already exists in the store.`\n )\n }\n\n if (!(`set` in options)) {\n return createReadonlySelector(options, family, store, core)\n }\n return createReadWriteSelector(options, family, store, core)\n}\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport { become } from \"~/packages/anvl/src/function\"\n\nimport {\n type Store,\n type Selector,\n type StoreCore,\n registerSelector,\n selector__INTERNAL,\n} from \"..\"\nimport type { FamilyMetadata, SelectorToken } from \"../..\"\nimport type { SelectorOptions } from \"../../selector\"\nimport { cacheValue, markDone } from \"../operation\"\n\nexport const createReadWriteSelector = <T>(\n options: SelectorOptions<T>,\n family: FamilyMetadata | undefined,\n store: Store,\n core: StoreCore\n): SelectorToken<T> => {\n const subject = new Rx.Subject<{ newValue: T; oldValue: T }>()\n\n const { get, set } = registerSelector(options.key, store)\n const getSelf = () => {\n const value = options.get({ get })\n cacheValue(options.key, value, store)\n return value\n }\n\n const setSelf = (next: T | ((oldValue: T) => T)): void => {\n store.config.logger?.info(` <- \"${options.key}\" became`, next)\n const oldValue = getSelf()\n const newValue = become(next)(oldValue)\n cacheValue(options.key, newValue, store)\n markDone(options.key, store)\n if (store.transactionStatus.phase === `idle`) {\n subject.next({ newValue, oldValue })\n }\n options.set({ get, set }, newValue)\n }\n const mySelector: Selector<T> = {\n ...options,\n subject,\n install: (s: Store) => selector__INTERNAL(options, family, s),\n get: getSelf,\n set: setSelf,\n type: `selector`,\n ...(family && { family }),\n }\n core.selectors = HAMT.set(options.key, mySelector, core.selectors)\n const initialValue = getSelf()\n store.config.logger?.info(` ✨ \"${options.key}\" =`, initialValue)\n const token: SelectorToken<T> = {\n key: options.key,\n type: `selector`,\n family,\n }\n store.subject.selectorCreation.next(token)\n return token\n}\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport { registerSelector } from \"./register-selector\"\nimport type {\n FamilyMetadata,\n ReadonlySelectorOptions,\n ReadonlySelectorToken,\n Store,\n} from \"../..\"\nimport { cacheValue } from \"../operation\"\nimport { selector__INTERNAL, type ReadonlySelector } from \"../selector-internal\"\nimport type { StoreCore } from \"../store\"\n\nexport const createReadonlySelector = <T>(\n options: ReadonlySelectorOptions<T>,\n family: FamilyMetadata | undefined,\n store: Store,\n core: StoreCore\n): ReadonlySelectorToken<T> => {\n const subject = new Rx.Subject<{ newValue: T; oldValue: T }>()\n\n const { get } = registerSelector(options.key, store)\n const getSelf = () => {\n const value = options.get({ get })\n cacheValue(options.key, value, store)\n return value\n }\n\n const readonlySelector: ReadonlySelector<T> = {\n ...options,\n subject,\n install: (s: Store) => selector__INTERNAL(options, family, s),\n get: getSelf,\n type: `readonly_selector`,\n ...(family && { family }),\n }\n core.readonlySelectors = HAMT.set(\n options.key,\n readonlySelector,\n core.readonlySelectors\n )\n const initialValue = getSelf()\n store.config.logger?.info(` ✨ \"${options.key}\" =`, initialValue)\n const token: ReadonlySelectorToken<T> = {\n key: options.key,\n type: `readonly_selector`,\n family,\n }\n store.subject.selectorCreation.next(token)\n return token\n}\n","import type { Store } from \"..\"\nimport { target, lookup } from \"..\"\nimport type { AtomToken, ReadonlySelectorToken, SelectorToken } from \"../..\"\n\nexport const lookupSelectorSources = (\n key: string,\n store: Store\n): (\n | AtomToken<unknown>\n | ReadonlySelectorToken<unknown>\n | SelectorToken<unknown>\n)[] =>\n target(store)\n .selectorGraph.getRelations(key)\n .filter(({ source }) => source !== key)\n .map(({ source }) => lookup(source, store))\n","import { lookupSelectorSources } from \"./lookup-selector-sources\"\nimport type { Store, AtomToken, ReadonlySelectorToken, StateToken } from \"../..\"\n\nexport const traceSelectorAtoms = (\n selectorKey: string,\n dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n store: Store\n): AtomToken<unknown>[] => {\n const roots: AtomToken<unknown>[] = []\n\n const sources = lookupSelectorSources(dependency.key, store)\n let depth = 0\n while (sources.length > 0) {\n /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n const source = sources.shift()!\n ++depth\n if (depth > 999) {\n throw new Error(\n `Maximum selector dependency depth exceeded in selector \"${selectorKey}\".`\n )\n }\n\n if (source.type !== `atom`) {\n sources.push(...lookupSelectorSources(source.key, store))\n } else {\n roots.push(source)\n }\n }\n\n return roots\n}\n\nexport const traceAllSelectorAtoms = (\n selectorKey: string,\n store: Store\n): AtomToken<unknown>[] => {\n const sources = lookupSelectorSources(selectorKey, store)\n return sources.flatMap((source) =>\n source.type === `atom`\n ? source\n : traceSelectorAtoms(selectorKey, source, store)\n )\n}\n","import { traceSelectorAtoms } from \"./trace-selector-atoms\"\nimport type { Store } from \"..\"\nimport { target } from \"..\"\nimport type { ReadonlySelectorToken, StateToken } from \"../..\"\n\nexport const updateSelectorAtoms = (\n selectorKey: string,\n dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n store: Store\n): void => {\n const core = target(store)\n if (dependency.type === `atom`) {\n core.selectorAtoms = core.selectorAtoms.set({\n selectorKey,\n atomKey: dependency.key,\n })\n store.config.logger?.info(\n ` || adding root for \"${selectorKey}\": ${dependency.key}`\n )\n return\n }\n const roots = traceSelectorAtoms(selectorKey, dependency, store)\n store.config.logger?.info(\n ` || adding roots for \"${selectorKey}\":`,\n roots.map((r) => r.key)\n )\n for (const root of roots) {\n core.selectorAtoms = core.selectorAtoms.set({\n selectorKey,\n atomKey: root.key,\n })\n }\n}\n","import HAMT from \"hamt_plus\"\n\nimport { become } from \"~/packages/anvl/src/function\"\n\nimport type { Atom, Selector, Store } from \".\"\nimport {\n IMPLICIT,\n cacheValue,\n emitUpdate,\n evictCachedValue,\n getState__INTERNAL,\n isAtomDefault,\n isDone,\n markAtomAsNotDefault,\n markDone,\n stowUpdate,\n target,\n} from \".\"\n\nexport const evictDownStream = <T>(\n state: Atom<T>,\n store: Store = IMPLICIT.STORE\n): void => {\n const core = target(store)\n const downstream = core.selectorAtoms.getRelations(state.key)\n const downstreamKeys = downstream.map(({ id }) => id)\n store.config.logger?.info(\n ` || ${downstreamKeys.length} downstream:`,\n downstreamKeys\n )\n if (core.operation.open) {\n store.config.logger?.info(` ||`, [...core.operation.done], `already done`)\n }\n downstream.forEach(({ id: stateKey }) => {\n if (isDone(stateKey, store)) {\n store.config.logger?.info(` || ${stateKey} already done`)\n return\n }\n const state =\n HAMT.get(stateKey, core.selectors) ??\n HAMT.get(stateKey, core.readonlySelectors)\n if (!state) {\n store.config.logger?.info(\n ` || ${stateKey} is an atom, and can't be downstream`\n )\n return\n }\n evictCachedValue(stateKey, store)\n store.config.logger?.info(` xx evicted \"${stateKey}\"`)\n\n markDone(stateKey, store)\n })\n}\n\nexport const setAtomState = <T>(\n atom: Atom<T>,\n next: T | ((oldValue: T) => T),\n store: Store = IMPLICIT.STORE\n): void => {\n const oldValue = getState__INTERNAL(atom, store)\n const newValue = become(next)(oldValue)\n store.config.logger?.info(`<< setting atom \"${atom.key}\" to`, newValue)\n cacheValue(atom.key, newValue, store)\n if (isAtomDefault(atom.key, store)) {\n markAtomAsNotDefault(atom.key, store)\n }\n markDone(atom.key, store)\n store.config.logger?.info(\n ` || evicting caches downstream from \"${atom.key}\"`\n )\n evictDownStream(atom, store)\n const update = { oldValue, newValue }\n if (store.transactionStatus.phase !== `building`) {\n emitUpdate(atom, update, store)\n } else {\n stowUpdate(atom, update, store)\n }\n}\nexport const setSelectorState = <T>(\n selector: Selector<T>,\n next: T | ((oldValue: T) => T),\n store: Store = IMPLICIT.STORE\n): void => {\n const oldValue = getState__INTERNAL(selector, store)\n const newValue = become(next)(oldValue)\n\n store.config.logger?.info(`<< setting selector \"${selector.key}\" to`, newValue)\n store.config.logger?.info(` || propagating change made to \"${selector.key}\"`)\n\n selector.set(newValue)\n}\nexport const setState__INTERNAL = <T>(\n state: Atom<T> | Selector<T>,\n value: T | ((oldValue: T) => T),\n store: Store = IMPLICIT.STORE\n): void => {\n if (`set` in state) {\n setSelectorState(state, value, store)\n } else {\n setAtomState(state, value, store)\n }\n}\n","import { updateSelectorAtoms } from \"./update-selector-atoms\"\nimport type { Transactors } from \"../../transaction\"\nimport { getState__INTERNAL, withdraw } from \"../get\"\nimport { setState__INTERNAL } from \"../set\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\nimport { target } from \"../transaction-internal\"\n\nexport const registerSelector = (\n selectorKey: string,\n store: Store = IMPLICIT.STORE\n): Transactors => ({\n get: (dependency) => {\n const core = target(store)\n const alreadyRegistered = core.selectorGraph\n .getRelations(selectorKey)\n .some(({ source }) => source === dependency.key)\n\n const dependencyState = withdraw(dependency, store)\n if (dependencyState === null) {\n throw new Error(\n `State \"${dependency.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`\n )\n }\n const dependencyValue = getState__INTERNAL(dependencyState, store)\n\n if (alreadyRegistered) {\n store.config.logger?.info(\n ` || ${selectorKey} <- ${dependency.key} =`,\n dependencyValue\n )\n } else {\n store.config.logger?.info(\n `🔌 registerSelector \"${selectorKey}\" <- ( \"${dependency.key}\" =`,\n dependencyValue,\n `)`\n )\n core.selectorGraph = core.selectorGraph.set(\n { from: dependency.key, to: selectorKey },\n {\n source: dependency.key,\n }\n )\n }\n updateSelectorAtoms(selectorKey, dependency, store)\n return dependencyValue\n },\n set: (stateToken, newValue) => {\n const state = withdraw(stateToken, store)\n if (state === null) {\n throw new Error(\n `State \"${stateToken.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`\n )\n }\n setState__INTERNAL(state, newValue, store)\n },\n})\n","import type { Atom, ReadonlySelector, Selector, Store } from \".\"\nimport {\n getState__INTERNAL,\n withdraw,\n recallState,\n traceAllSelectorAtoms,\n} from \".\"\nimport type { StateUpdate } from \"..\"\n\nexport const prepareUpdate = <T>(\n state: Atom<T> | ReadonlySelector<T> | Selector<T>,\n store: Store\n): StateUpdate<T> => {\n const oldValue = recallState(state, store)\n const newValue = getState__INTERNAL(state, store)\n return { newValue, oldValue }\n}\n\nexport const stowUpdate = <T>(\n state: Atom<T>,\n update: StateUpdate<T>,\n store: Store\n): void => {\n const { key } = state\n const { logger } = store.config\n if (store.transactionStatus.phase !== `building`) {\n store.config.logger?.warn(\n `stowUpdate called outside of a transaction. This is probably a bug.`\n )\n return\n }\n store.transactionStatus.atomUpdates.push({ key, ...update })\n logger?.info(`📝 ${key} stowed (`, update.oldValue, `->`, update.newValue, `)`)\n}\n\nexport const emitUpdate = <T>(\n state: Atom<T> | ReadonlySelector<T> | Selector<T>,\n update: StateUpdate<T>,\n store: Store\n): void => {\n const { key } = state\n const { logger } = store.config\n logger?.info(\n `📢 ${state.type} \"${key}\" went (`,\n update.oldValue,\n `->`,\n update.newValue,\n `)`\n )\n state.subject.next(update)\n}\n\nexport const subscribeToRootAtoms = <T>(\n state: ReadonlySelector<T> | Selector<T>,\n store: Store\n): { unsubscribe: () => void }[] | null => {\n const dependencySubscriptions =\n `default` in state\n ? null\n : traceAllSelectorAtoms(state.key, store).map((atomToken) => {\n const atom = withdraw(atomToken, store)\n if (atom === null) {\n throw new Error(\n `Atom \"${atomToken.key}\", a dependency of selector \"${state.key}\", not found in store \"${store.config.name}\".`\n )\n }\n return atom.subject.subscribe((atomChange) => {\n store.config.logger?.info(\n `📢 selector \"${state.key}\" saw root \"${atomToken.key}\" go (`,\n atomChange.oldValue,\n `->`,\n atomChange.newValue,\n `)`\n )\n const oldValue = recallState(state, store)\n const newValue = getState__INTERNAL(state, store)\n store.config.logger?.info(` <- ${state.key} became`, newValue)\n state.subject.next({ newValue, oldValue })\n })\n })\n return dependencySubscriptions\n}\n","import type { Store } from \".\"\nimport { IMPLICIT } from \".\"\nimport type { TimelineToken } from \"..\"\nimport { setState } from \"..\"\n\nexport const redo__INTERNAL = (\n token: TimelineToken,\n store: Store = IMPLICIT.STORE\n): void => {\n store.config.logger?.info(`⏩ redo \"${token.key}\"`)\n const timelineData = store.timelines.get(token.key)\n if (!timelineData) {\n store.config.logger?.error(\n `Failed to redo on timeline \"${token.key}\". This timeline has not been initialized.`\n )\n return\n }\n if (timelineData.at === timelineData.history.length) {\n store.config.logger?.warn(\n `Failed to redo at the end of timeline \"${token.key}\". There is nothing to redo.`\n )\n return\n }\n timelineData.timeTraveling = true\n const update = timelineData.history[timelineData.at]\n switch (update.type) {\n case `atom_update`: {\n const { key, newValue } = update\n setState({ key, type: `atom` }, newValue, store)\n break\n }\n case `selector_update`:\n case `transaction_update`: {\n for (const atomUpdate of update.atomUpdates) {\n const { key, newValue } = atomUpdate\n setState({ key, type: `atom` }, newValue, store)\n }\n break\n }\n }\n ++timelineData.at\n timelineData.timeTraveling = false\n store.config.logger?.info(\n `⏹️ \"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`\n )\n}\n\nexport const undo__INTERNAL = (\n token: TimelineToken,\n store: Store = IMPLICIT.STORE\n): void => {\n store.config.logger?.info(`⏪ undo \"${token.key}\"`)\n const timelineData = store.timelines.get(token.key)\n if (!timelineData) {\n store.config.logger?.error(\n `Failed to undo on timeline \"${token.key}\". This timeline has not been initialized.`\n )\n return\n }\n if (timelineData.at === 0) {\n store.config.logger?.warn(\n `Failed to undo at the beginning of timeline \"${token.key}\". There is nothing to undo.`\n )\n return\n }\n timelineData.timeTraveling = true\n\n --timelineData.at\n const update = timelineData.history[timelineData.at]\n switch (update.type) {\n case `atom_update`: {\n const { key, oldValue } = update\n setState({ key, type: `atom` }, oldValue, store)\n break\n }\n case `selector_update`:\n case `transaction_update`: {\n for (const atomUpdate of update.atomUpdates) {\n const { key, oldValue } = atomUpdate\n setState({ key, type: `atom` }, oldValue, store)\n }\n break\n }\n }\n timelineData.timeTraveling = false\n store.config.logger?.info(\n `⏹️ \"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`\n )\n}\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \".\"\nimport { target, IMPLICIT } from \".\"\nimport { addAtomToTimeline } from \"./timeline/add-atom-to-timeline\"\nimport type {\n StateUpdate,\n TimelineOptions,\n TimelineToken,\n TimelineUpdate,\n TransactionUpdate,\n} from \"..\"\n\nexport type TimelineAtomUpdate = StateUpdate<unknown> & {\n key: string\n type: `atom_update`\n timestamp: number\n}\nexport type TimelineSelectorUpdate = {\n key: string\n type: `selector_update`\n timestamp: number\n atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[]\n}\nexport type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {\n key: string\n type: `transaction_update`\n timestamp: number\n}\n\nexport type Timeline = {\n key: string\n at: number\n timeTraveling: boolean\n history: TimelineUpdate[]\n selectorTime: number | null\n transactionKey: string | null\n install: (store: Store) => void\n subject: Rx.Subject<\n TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate\n >\n}\n\nexport function timeline__INTERNAL(\n options: TimelineOptions,\n store: Store = IMPLICIT.STORE,\n data: Timeline | null = null\n): TimelineToken {\n const tl: Timeline = {\n key: options.key,\n at: 0,\n timeTraveling: false,\n selectorTime: null,\n transactionKey: null,\n ...data,\n history: data?.history.map((update) => ({ ...update })) ?? [],\n install: (store) => timeline__INTERNAL(options, store, tl),\n subject: new Rx.Subject(),\n }\n\n const core = target(store)\n for (const tokenOrFamily of options.atoms) {\n const timelineKey = core.timelineAtoms.getRelatedId(tokenOrFamily.key)\n if (timelineKey) {\n store.config.logger?.error(\n `❌ Failed to add atom \"${tokenOrFamily.key}\" to timeline \"${options.key}\" because it belongs to timeline \"${timelineKey}\"`\n )\n continue\n }\n if (tokenOrFamily.type === `atom_family`) {\n const family = tokenOrFamily\n family.subject.subscribe((token) =>\n addAtomToTimeline(token, options.atoms, tl, store)\n )\n } else {\n const token = tokenOrFamily\n if (`family` in token && token.family) {\n const familyTimelineKey = core.timelineAtoms.getRelatedId(\n token.family.key\n )\n if (familyTimelineKey) {\n store.config.logger?.error(\n `❌ Failed to add atom \"${token.key}\" to timeline \"${options.key}\" because its family \"${token.family.key}\" belongs to timeline \"${familyTimelineKey}\"`\n )\n continue\n }\n }\n addAtomToTimeline(token, options.atoms, tl, store)\n }\n core.timelineAtoms = core.timelineAtoms.set({\n atomKey: tokenOrFamily.key,\n timelineKey: options.key,\n })\n }\n\n store.timelines = HAMT.set(options.key, tl, store.timelines)\n const token: TimelineToken = {\n key: options.key,\n type: `timeline`,\n }\n store.subject.timelineCreation.next(token)\n return token\n}\n","import { IMPLICIT, withdraw } from \"..\"\nimport type {\n TimelineSelectorUpdate,\n Timeline,\n Store,\n TimelineTransactionUpdate,\n TimelineAtomUpdate,\n} from \"..\"\nimport type { AtomFamily, AtomToken, TimelineUpdate } from \"../..\"\n\nexport const addAtomToTimeline = (\n atomToken: AtomToken<any>,\n atoms: (AtomFamily<any> | AtomToken<any>)[],\n tl: Timeline,\n store: Store = IMPLICIT.STORE\n): void => {\n const atom = withdraw(atomToken, store)\n if (atom === null) {\n throw new Error(\n `Cannot subscribe to atom \"${atomToken.key}\" because it has not been initialized in store \"${store.config.name}\"`\n )\n }\n atom.subject.subscribe((update) => {\n const currentSelectorKey =\n store.operation.open && store.operation.token.type === `selector`\n ? store.operation.token.key\n : null\n const currentSelectorTime =\n store.operation.open && store.operation.token.type === `selector`\n ? store.operation.time\n : null\n const currentTransactionKey =\n store.transactionStatus.phase === `applying`\n ? store.transactionStatus.key\n : null\n const currentTransactionTime =\n store.transactionStatus.phase === `applying`\n ? store.transactionStatus.time\n : null\n\n store.config.logger?.info(\n `⏳ timeline \"${tl.key}\" saw atom \"${atomToken.key}\" go (`,\n update.oldValue,\n `->`,\n update.newValue,\n currentTransactionKey\n ? `) in transaction \"${currentTransactionKey}\"`\n : currentSelectorKey\n ? `) in selector \"${currentSelectorKey}\"`\n : `)`\n )\n\n if (tl.timeTraveling === false) {\n if (tl.selectorTime && tl.selectorTime !== currentSelectorTime) {\n const mostRecentUpdate: TimelineUpdate = tl.history.at(-1)!\n if (mostRecentUpdate.type === `selector_update`) {\n tl.subject.next(mostRecentUpdate)\n }\n }\n if (\n currentTransactionKey &&\n store.transactionStatus.phase === `applying`\n ) {\n const currentTransaction = withdraw(\n { key: currentTransactionKey, type: `transaction` },\n store\n )\n if (currentTransaction === null) {\n throw new Error(\n `Transaction \"${currentTransactionKey}\" not found in store \"${store.config.name}\". This is surprising, because we are in the application phase of \"${currentTransactionKey}\".`\n )\n }\n if (tl.transactionKey !== currentTransactionKey) {\n if (tl.transactionKey) {\n store.config.logger?.error(\n `Timeline \"${tl.key}\" was unable to resolve transaction \"${tl.transactionKey}. This is probably a bug.`\n )\n }\n tl.transactionKey = currentTransactionKey\n const subscription = currentTransaction.subject.subscribe((update) => {\n if (tl.timeTraveling === false && currentTransactionTime) {\n if (tl.at !== tl.history.length) {\n tl.history.splice(tl.at)\n }\n const timelineTransactionUpdate: TimelineTransactionUpdate = {\n type: `transaction_update`,\n timestamp: currentTransactionTime,\n ...update,\n atomUpdates: update.atomUpdates.filter((atomUpdate) =>\n atoms.some((atom) => atom.key === atomUpdate.key)\n ),\n }\n tl.history.push(timelineTransactionUpdate)\n tl.subject.next(timelineTransactionUpdate)\n }\n tl.at = tl.history.length\n subscription.unsubscribe()\n tl.transactionKey = null\n store.config.logger?.info(\n `⌛ timeline \"${tl.key}\" got a transaction_update \"${update.key}\"`\n )\n })\n }\n } else if (currentSelectorKey && currentSelectorTime) {\n if (currentSelectorTime !== tl.selectorTime) {\n const newSelectorUpdate: TimelineSelectorUpdate = {\n type: `selector_update`,\n timestamp: currentSelectorTime,\n key: currentSelectorKey,\n atomUpdates: [],\n }\n newSelectorUpdate.atomUpdates.push({\n key: atom.key,\n type: `atom_update`,\n ...update,\n })\n if (tl.at !== tl.history.length) {\n tl.history.splice(tl.at)\n }\n tl.history.push(newSelectorUpdate)\n\n store.config.logger?.info(\n `⌛ timeline \"${tl.key}\" got a selector_update \"${currentSelectorKey}\" with`,\n newSelectorUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)\n )\n tl.at = tl.history.length\n tl.selectorTime = currentSelectorTime\n } else {\n const latestUpdate = tl.history.at(-1)\n if (latestUpdate?.type === `selector_update`) {\n latestUpdate.atomUpdates.push({\n key: atom.key,\n type: `atom_update`,\n ...update,\n })\n store.config.logger?.info(\n ` ⌛ timeline \"${tl.key}\" set selector_update \"${currentSelectorKey}\" to`,\n latestUpdate?.atomUpdates.map((atomUpdate) => atomUpdate.key)\n )\n }\n }\n } else {\n const timestamp = Date.now()\n tl.selectorTime = null\n if (tl.at !== tl.history.length) {\n tl.history.splice(tl.at)\n }\n const atomUpdate: TimelineAtomUpdate = {\n type: `atom_update`,\n timestamp,\n key: atom.key,\n oldValue: update.oldValue,\n newValue: update.newValue,\n }\n tl.history.push(atomUpdate)\n tl.subject.next(atomUpdate)\n store.config.logger?.info(\n `⌛ timeline \"${tl.key}\" got a state_update to \"${atom.key}\"`\n )\n tl.at = tl.history.length\n }\n }\n })\n}\n","import type { Store } from \"..\"\n\nexport const abortTransaction = (store: Store): void => {\n if (store.transactionStatus.phase === `idle`) {\n store.config.logger?.warn(\n `abortTransaction called outside of a transaction. This is probably a bug.`\n )\n return\n }\n store.transactionStatus = { phase: `idle` }\n store.config.logger?.info(`🪂`, `transaction fail`)\n}\n","import HAMT from \"hamt_plus\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const applyTransaction = <ƒ extends ƒn>(\n output: ReturnType<ƒ>,\n store: Store\n): void => {\n if (store.transactionStatus.phase !== `building`) {\n store.config.logger?.warn(\n `abortTransaction called outside of a transaction. This is probably a bug.`\n )\n return\n }\n store.config.logger?.info(\n `🛃 apply transaction \"${store.transactionStatus.key}\"`\n )\n store.transactionStatus.phase = `applying`\n store.transactionStatus.output = output\n const { atomUpdates } = store.transactionStatus\n\n for (const { key, newValue } of atomUpdates) {\n const token: AtomToken<unknown> = { key, type: `atom` }\n if (!HAMT.has(token.key, store.valueMap)) {\n const newAtom = HAMT.get(token.key, store.transactionStatus.core.atoms)\n store.atoms = HAMT.set(newAtom.key, newAtom, store.atoms)\n store.valueMap = HAMT.set(newAtom.key, newAtom.default, store.valueMap)\n store.config.logger?.info(`🔧`, `add atom \"${newAtom.key}\"`)\n }\n setState(token, newValue, store)\n }\n const myTransaction = withdraw<ƒ>(\n { key: store.transactionStatus.key, type: `transaction` },\n store\n )\n if (myTransaction === null) {\n throw new Error(\n `Transaction \"${store.transactionStatus.key}\" not found. Absurd. How is this running?`\n )\n }\n myTransaction.subject.next({\n key: store.transactionStatus.key,\n atomUpdates,\n output,\n params: store.transactionStatus.params as Parameters<ƒ>,\n })\n store.transactionStatus = { phase: `idle` }\n store.config.logger?.info(`🛬`, `transaction done`)\n}\n","import type { Store } from \"..\"\n\nexport const buildTransaction = (\n key: string,\n params: any[],\n store: Store\n): void => {\n store.transactionStatus = {\n key,\n phase: `building`,\n time: Date.now(),\n core: {\n atoms: store.atoms,\n atomsThatAreDefault: store.atomsThatAreDefault,\n operation: { open: false },\n readonlySelectors: store.readonlySelectors,\n timelines: store.timelines,\n timelineAtoms: store.timelineAtoms,\n transactions: store.transactions,\n selectorAtoms: store.selectorAtoms,\n selectorGraph: store.selectorGraph,\n selectors: store.selectors,\n valueMap: store.valueMap,\n },\n atomUpdates: [],\n params,\n output: undefined,\n }\n store.config.logger?.info(\n `🛫`,\n `transaction \"${key}\" started in store \"${store.config.name}\"`\n )\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken, TransactionUpdate } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const redoTransactionUpdate = <ƒ extends ƒn>(\n update: TransactionUpdate<ƒ>,\n store: Store\n): void => {\n store.config.logger?.info(` ⏭ redo transaction \"${update.key}\" (redo)`)\n for (const { key, newValue } of update.atomUpdates) {\n const token: AtomToken<unknown> = { key, type: `atom` }\n const state = withdraw(token, store)\n if (state === null) {\n throw new Error(\n `State \"${token.key}\" not found in this store. This is surprising, because we are navigating the history of the store.`\n )\n }\n setState(state, newValue, store)\n }\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken, TransactionUpdate } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const undoTransactionUpdate = <ƒ extends ƒn>(\n update: TransactionUpdate<ƒ>,\n store: Store\n): void => {\n store.config.logger?.info(` ⏮ undo transaction \"${update.key}\" (undo)`)\n for (const { key, oldValue } of update.atomUpdates) {\n const token: AtomToken<unknown> = { key, type: `atom` }\n const state = withdraw(token, store)\n if (state === null) {\n throw new Error(\n `State \"${token.key}\" not found in this store. This is surprising, because we are navigating the history of the store.`\n )\n }\n setState(state, oldValue, store)\n }\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { StoreCore } from \"..\"\nimport type { StateUpdate, TransactionUpdate } from \"../..\"\n\nexport * from \"./abort-transaction\"\nexport * from \"./apply-transaction\"\nexport * from \"./build-transaction\"\nexport * from \"./redo-transaction\"\nexport * from \"./undo-transaction\"\n\nexport const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const\nexport type TransactionPhase = (typeof TRANSACTION_PHASES)[number]\n\nexport type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {\n phase: `applying` | `building`\n time: number\n core: StoreCore\n}\nexport type TransactionIdle = {\n phase: `idle`\n}\nexport type TransactionStatus<ƒ extends ƒn> =\n | TransactionIdle\n | TransactionUpdateInProgress<ƒ>\n","import type * as Rx from \"rxjs\"\n\nimport type { Serializable } from \"~/packages/anvl/src/json\"\n\nimport type { AtomToken } from \".\"\nimport { atomFamily__INTERNAL, atom__INTERNAL } from \"./internal\"\n\nexport type Effectors<T> = {\n setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n onSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => void\n\nexport type AtomOptions<T> = {\n key: string\n default: T | (() => T)\n effects?: AtomEffect<T>[]\n}\n\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T> {\n return atom__INTERNAL<T>(options)\n}\n\nexport type AtomFamilyOptions<T, K extends Serializable> = {\n key: string\n default: T | ((key: K) => T)\n effects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Serializable = Serializable> = ((\n key: K\n) => AtomToken<T>) & {\n key: string\n type: `atom_family`\n subject: Rx.Subject<AtomToken<T>>\n}\n\nexport function atomFamily<T, K extends Serializable>(\n options: AtomFamilyOptions<T, K>\n): AtomFamily<T, K> {\n return atomFamily__INTERNAL<T, K>(options)\n}\n","import { doNothing } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"./internal/store\"\nimport { IMPLICIT } from \"./internal/store\"\n\nexport type Logger = Pick<Console, `error` | `info` | `warn`>\nexport const LOG_LEVELS: ReadonlyArray<keyof Logger> = [\n `info`,\n `warn`,\n `error`,\n] as const\n\nexport const setLogLevel = (\n preferredLevel: `error` | `info` | `warn` | null,\n store: Store = IMPLICIT.STORE\n): void => {\n const { logger__INTERNAL } = store.config\n if (preferredLevel === null) {\n store.config.logger = null\n } else {\n store.config.logger = { ...console }\n LOG_LEVELS.forEach((logLevel) => {\n if (LOG_LEVELS.indexOf(logLevel) < LOG_LEVELS.indexOf(preferredLevel)) {\n /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n store.config.logger![logLevel] = doNothing\n } else {\n /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n store.config.logger![logLevel] = logger__INTERNAL[logLevel]\n }\n })\n }\n}\n\nexport const useLogger = (\n logger: Logger,\n store: Store = IMPLICIT.STORE\n): void => {\n const currentLogLevel =\n store.config.logger === null\n ? null\n : LOG_LEVELS.find(\n (logLevel) => store.config.logger?.[logLevel] !== doNothing\n ) ?? null\n store.config.logger__INTERNAL = { ...logger }\n setLogLevel(currentLogLevel, store)\n}\n","import type * as Rx from \"rxjs\"\n\nimport type { Serializable } from \"~/packages/anvl/src/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport { selectorFamily__INTERNAL, selector__INTERNAL } from \"./internal\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n key: string\n get: Read<() => T>\n set: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n key: string\n get: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n options: ReadonlySelectorOptions<T>\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n options: ReadonlySelectorOptions<T> | SelectorOptions<T>\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n return selector__INTERNAL(options)\n}\n\nexport type SelectorFamilyOptions<T, K extends Serializable> = {\n key: string\n get: (key: K) => Read<() => T>\n set: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {\n key: string\n get: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<T, K extends Serializable = Serializable> = ((\n key: K\n) => SelectorToken<T>) & {\n key: string\n type: `selector_family`\n subject: Rx.Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((\n key: K\n) => ReadonlySelectorToken<T>) & {\n key: string\n type: `readonly_selector_family`\n subject: Rx.Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Serializable>(\n options: SelectorFamilyOptions<T, K>\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Serializable>(\n options: ReadonlySelectorFamilyOptions<T, K>\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Serializable>(\n options: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n return selectorFamily__INTERNAL(options)\n}\n","import type { redo, timeline, undo } from \".\"\nimport { getState, setState, subscribe } from \".\"\nimport type { atom, atomFamily } from \"./atom\"\nimport type { Store } from \"./internal\"\nimport {\n atomFamily__INTERNAL,\n atom__INTERNAL,\n createStore,\n redo__INTERNAL,\n selectorFamily__INTERNAL,\n selector__INTERNAL,\n timeline__INTERNAL,\n transaction__INTERNAL,\n undo__INTERNAL,\n} from \"./internal\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { transaction } from \"./transaction\"\n\nexport type Silo = ReturnType<typeof silo>\n\nexport const silo = (\n name: string,\n fromStore: Store | null = null\n): {\n store: Store\n atom: typeof atom\n atomFamily: typeof atomFamily\n selector: typeof selector\n selectorFamily: typeof selectorFamily\n transaction: typeof transaction\n timeline: typeof timeline\n getState: typeof getState\n setState: typeof setState\n subscribe: typeof subscribe\n undo: typeof undo\n redo: typeof redo\n} => {\n const store = createStore(name, fromStore)\n return {\n store,\n atom: (options) => atom__INTERNAL(options, undefined, store),\n atomFamily: (options) => atomFamily__INTERNAL(options, store),\n selector: (options) => selector__INTERNAL(options, undefined, store) as any,\n selectorFamily: (options) => selectorFamily__INTERNAL(options, store) as any,\n transaction: (options) => transaction__INTERNAL(options, store),\n timeline: (options) => timeline__INTERNAL(options, store),\n getState: (token) => getState(token, store),\n setState: (token, newValue) => setState(token, newValue, store),\n subscribe: (token, handler) => subscribe(token, handler, store),\n undo: (token) => undo__INTERNAL(token, store),\n redo: (token) => redo__INTERNAL(token, store),\n }\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type {\n ReadonlySelectorToken,\n StateToken,\n TimelineToken,\n TimelineUpdate,\n TransactionToken,\n TransactionUpdate,\n} from \".\"\nimport type { Store } from \"./internal\"\nimport { IMPLICIT, subscribeToRootAtoms, withdraw } from \"./internal\"\n\nexport type StateUpdate<T> = { newValue: T; oldValue: T }\nexport type KeyedStateUpdate<T> = StateUpdate<T> & { key: string }\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\n\nexport const subscribe = <T>(\n token: ReadonlySelectorToken<T> | StateToken<T>,\n handleUpdate: UpdateHandler<T>,\n store: Store = IMPLICIT.STORE\n): (() => void) => {\n const state = withdraw<T>(token, store)\n if (state === null) {\n throw new Error(\n `State \"${token.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`\n )\n }\n const subscription = state.subject.subscribe(handleUpdate)\n store.config.logger?.info(`👀 subscribe to \"${state.key}\"`)\n const dependencySubscriptions =\n state.type !== `atom` ? subscribeToRootAtoms(state, store) : null\n\n const unsubscribe =\n dependencySubscriptions === null\n ? () => {\n store.config.logger?.info(`🙈 unsubscribe from \"${state.key}\"`)\n subscription.unsubscribe()\n }\n : () => {\n store.config.logger?.info(\n `🙈 unsubscribe from \"${state.key}\" and its dependencies`\n )\n subscription.unsubscribe()\n for (const dependencySubscription of dependencySubscriptions) {\n dependencySubscription.unsubscribe()\n }\n }\n\n return unsubscribe\n}\n\nexport type TransactionUpdateHandler<ƒ extends ƒn> = (\n data: TransactionUpdate<ƒ>\n) => void\n\nexport const subscribeToTransaction = <ƒ extends ƒn>(\n token: TransactionToken<ƒ>,\n handleUpdate: TransactionUpdateHandler<ƒ>,\n store = IMPLICIT.STORE\n): (() => void) => {\n const tx = withdraw(token, store)\n if (tx === null) {\n throw new Error(\n `Cannot subscribe to transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`\n )\n }\n store.config.logger?.info(`👀 subscribe to transaction \"${token.key}\"`)\n const subscription = tx.subject.subscribe(handleUpdate)\n const unsubscribe = () => {\n store.config.logger?.info(`🙈 unsubscribe from transaction \"${token.key}\"`)\n subscription.unsubscribe()\n }\n return unsubscribe\n}\n\nexport const subscribeToTimeline = (\n token: TimelineToken,\n handleUpdate: (update: TimelineUpdate) => void,\n store = IMPLICIT.STORE\n): (() => void) => {\n const tl = withdraw(token, store)\n if (tl === null) {\n throw new Error(\n `Cannot subscribe to timeline \"${token.key}\": timeline not found in store \"${store.config.name}\".`\n )\n }\n store.config.logger?.info(`👀 subscribe to timeline \"${token.key}\"`)\n const subscription = tl.subject.subscribe(handleUpdate)\n const unsubscribe = () => {\n store.config.logger?.info(`🙈 unsubscribe from timeline \"${token.key}\"`)\n subscription.unsubscribe()\n }\n return unsubscribe\n}\n","import type { AtomFamily, AtomToken } from \".\"\nimport type {\n TimelineAtomUpdate,\n TimelineSelectorUpdate,\n TimelineTransactionUpdate,\n} from \"./internal\"\nimport { IMPLICIT } from \"./internal\"\nimport { redo__INTERNAL, timeline__INTERNAL, undo__INTERNAL } from \"./internal/\"\n\nexport type TimelineToken = {\n key: string\n type: `timeline`\n}\n\nexport type TimelineOptions = {\n key: string\n atoms: (AtomFamily<any> | AtomToken<any>)[]\n}\n\nexport type TimelineUpdate =\n | TimelineAtomUpdate\n | TimelineSelectorUpdate\n | TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n return timeline__INTERNAL(options)\n}\n\nexport const redo = (token: TimelineToken): void => {\n return redo__INTERNAL(token, IMPLICIT.STORE)\n}\n\nexport const undo = (token: TimelineToken): void => {\n return undo__INTERNAL(token, IMPLICIT.STORE)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { KeyedStateUpdate, ReadonlySelectorToken, StateToken } from \".\"\nimport type { Store } from \"./internal\"\nimport { IMPLICIT, transaction__INTERNAL, withdraw } from \"./internal\"\n\nexport type TransactionToken<_> = {\n key: string\n type: `transaction`\n __brand?: _\n}\n\nexport type TransactionUpdate<ƒ extends ƒn> = {\n key: string\n atomUpdates: KeyedStateUpdate<unknown>[]\n params: Parameters<ƒ>\n output: ReturnType<ƒ>\n}\n\nexport type Transactors = {\n get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S\n set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void\n}\nexport type ReadonlyTransactors = Pick<Transactors, `get`>\n\nexport type Read<ƒ extends ƒn> = (\n transactors: ReadonlyTransactors,\n ...parameters: Parameters<ƒ>\n) => ReturnType<ƒ>\n\nexport type Write<ƒ extends ƒn> = (\n transactors: Transactors,\n ...parameters: Parameters<ƒ>\n) => ReturnType<ƒ>\n\nexport type TransactionOptions<ƒ extends ƒn> = {\n key: string\n do: Write<ƒ>\n}\n\nexport type TransactionIO<Token extends TransactionToken<any>> =\n Token extends TransactionToken<infer ƒ> ? ƒ : never\n\nexport function transaction<ƒ extends ƒn>(\n options: TransactionOptions<ƒ>\n): TransactionToken<ƒ> {\n return transaction__INTERNAL(options)\n}\n\nexport const runTransaction =\n <ƒ extends ƒn>(token: TransactionToken<ƒ>, store: Store = IMPLICIT.STORE) =>\n (...parameters: Parameters<ƒ>): ReturnType<ƒ> => {\n const tx = withdraw(token, store)\n if (tx) {\n return tx.run(...parameters)\n }\n throw new Error(\n `Cannot run transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`\n )\n }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,aAAa,CAAC,QACzB,IAAI,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;;;ACDpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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M,KAAK,KAAK;","names":["import_hamt_plus","Rx","selector","HAMT","import_hamt_plus","import_hamt_plus","import_function","join","import_function","import_function","import_string","import_function","map","map","id","HAMT","atom","selector","timeline","HAMT","atom","selector","import_hamt_plus","Rx","token","store","HAMT","HAMT","Rx","import_function","import_hamt_plus","import_hamt_plus","Rx","_a","HAMT","import_hamt_plus","Rx","import_hamt_plus","_a","_b","state","HAMT","atom","selector","HAMT","HAMT","atom","import_hamt_plus","Rx","atom","update","_a","store","token","HAMT","import_hamt_plus","HAMT","_a","_a"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../../anvl/src/string/capitalize.ts","../src/internal/index.ts","../src/internal/atom-internal.ts","../src/internal/get.ts","../src/internal/is-default.ts","../src/internal/operation.ts","../src/internal/store.ts","../../anvl/src/function/index.ts","../../anvl/src/join/core-relation-data.ts","../../anvl/src/array/venn.ts","../../anvl/src/array/index.ts","../../anvl/src/object/refinement.ts","../../anvl/src/object/access.ts","../../anvl/src/object/entries.ts","../../anvl/src/object/mapObject.ts","../../anvl/src/nullish/index.ts","../../anvl/src/refinement/index.ts","../../anvl/src/join/get-related-ids.ts","../../anvl/src/join/make-json-interface.ts","../../anvl/src/join/relation-contents.ts","../../anvl/src/join/relation-record.ts","../../anvl/src/join/remove-relation.ts","../../anvl/src/object/index.ts","../../anvl/src/string/split.ts","../../anvl/src/join/set-relation.ts","../../anvl/src/join/index.ts","../src/internal/transaction-internal.ts","../src/internal/families-internal.ts","../../anvl/src/json/index.ts","../src/internal/meta/index.ts","../src/internal/meta/meta-state.ts","../src/internal/meta/attach-meta.ts","../src/internal/selector-internal.ts","../src/internal/selector/create-read-write-selector.ts","../src/internal/selector/create-readonly-selector.ts","../src/internal/selector/lookup-selector-sources.ts","../src/internal/selector/trace-selector-atoms.ts","../src/internal/selector/update-selector-atoms.ts","../src/internal/set.ts","../src/internal/selector/register-selector.ts","../src/internal/subscribe-internal.ts","../src/internal/time-travel-internal.ts","../src/internal/timeline-internal.ts","../src/internal/timeline/add-atom-to-timeline.ts","../src/internal/transaction/abort-transaction.ts","../src/internal/transaction/apply-transaction.ts","../src/internal/transaction/build-transaction.ts","../src/internal/transaction/redo-transaction.ts","../src/internal/transaction/undo-transaction.ts","../src/internal/transaction/index.ts","../src/atom.ts","../src/logger.ts","../src/selector.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"sourcesContent":["import { capitalize } from \"~/packages/anvl/src/string/capitalize\"\n\nimport {\n\tIMPLICIT,\n\tcloseOperation,\n\topenOperation,\n\tgetState__INTERNAL,\n\tsetState__INTERNAL,\n\tisAtomDefault,\n\tisSelectorDefault,\n\twithdraw,\n} from \"./internal\"\nimport * as __INTERNAL__ from \"./internal\"\nimport type { Store } from \"./internal/store\"\n\nexport * from \"./atom\"\nexport * from \"./logger\"\nexport * from \"./selector\"\nexport * from \"./silo\"\nexport * from \"./subscribe\"\nexport * from \"./timeline\"\nexport * from \"./transaction\"\nexport { __INTERNAL__ }\nexport type { Store } from \"./internal/store\"\nexport type { Serializable } from \"~/packages/anvl/src/json\"\n\nexport type AtomToken<_> = {\n\tkey: string\n\ttype: `atom`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\nexport type SelectorToken<_> = {\n\tkey: string\n\ttype: `selector`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\nexport type StateToken<T> = AtomToken<T> | SelectorToken<T>\n\nexport type ReadonlySelectorToken<_> = {\n\tkey: string\n\ttype: `readonly_selector`\n\tfamily?: FamilyMetadata\n\t__brand?: _\n}\n\nexport type FamilyMetadata = {\n\tkey: string\n\tsubKey: string\n}\n\nexport const getState = <T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tconst state = withdraw<T>(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\n\treturn getState__INTERNAL(state, store)\n}\n\nexport const setState = <T, New extends T>(\n\ttoken: StateToken<T>,\n\tvalue: New | ((oldValue: T) => New),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\ttry {\n\t\topenOperation(token, store)\n\t} catch (thrown) {\n\t\tif (!(typeof thrown === `symbol`)) {\n\t\t\tthrow thrown\n\t\t}\n\t\treturn\n\t}\n\tconst state = withdraw(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\n\tsetState__INTERNAL(state, value, store)\n\tcloseOperation(store)\n}\n\nexport const isDefault = (\n\ttoken: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store = IMPLICIT.STORE,\n): boolean =>\n\ttoken.type === `atom`\n\t\t? isAtomDefault(token.key, store)\n\t\t: isSelectorDefault(token.key, store)\n","export const capitalize = (str: string): string =>\n\tstr[0].toUpperCase() + str.slice(1)\n","export * from \"./atom-internal\"\nexport * from \"./families-internal\"\nexport * from \"./get\"\nexport * from \"./is-default\"\nexport * as META from \"./meta\"\nexport * from \"./operation\"\nexport * from \"./selector-internal\"\nexport * from \"./selector\"\nexport * from \"./set\"\nexport * from \"./store\"\nexport * from \"./subscribe-internal\"\nexport * from \"./time-travel-internal\"\nexport * from \"./timeline-internal\"\nexport * from \"./transaction-internal\"\nexport * from \"./transaction\"\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport { deposit } from \"./get\"\nimport { markAtomAsDefault } from \"./is-default\"\nimport { cacheValue, hasKeyBeenUsed } from \"./operation\"\nimport type { Store } from \"./store\"\nimport { IMPLICIT } from \"./store\"\nimport { target } from \"./transaction-internal\"\nimport type { AtomToken, FamilyMetadata, UpdateHandler } from \"..\"\nimport { setState, subscribe } from \"..\"\nimport type { AtomOptions } from \"../atom\"\n\nexport type Atom<T> = {\n\tkey: string\n\ttype: `atom`\n\tfamily?: FamilyMetadata\n\tsubject: Rx.Subject<{ newValue: T; oldValue: T }>\n\tdefault: T\n}\n\nexport function atom__INTERNAL<T>(\n\toptions: AtomOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore: Store = IMPLICIT.STORE,\n): AtomToken<T> {\n\tconst core = target(store)\n\tif (hasKeyBeenUsed(options.key, store)) {\n\t\tstore.config.logger?.error?.(\n\t\t\t`Key \"${options.key}\" already exists in the store.`,\n\t\t)\n\t\treturn deposit(core.atoms.get(options.key))\n\t}\n\tconst subject = new Rx.Subject<{ newValue: T; oldValue: T }>()\n\tconst newAtom = {\n\t\t...options,\n\t\tsubject,\n\t\ttype: `atom`,\n\t\t...(family && { family }),\n\t} as const\n\tconst initialValue =\n\t\toptions.default instanceof Function ? options.default() : options.default\n\tcore.atoms = HAMT.set(newAtom.key, newAtom, core.atoms)\n\tmarkAtomAsDefault(options.key, store)\n\tcacheValue(options.key, initialValue, store)\n\tconst token = deposit(newAtom)\n\toptions.effects?.forEach((effect) =>\n\t\teffect({\n\t\t\tsetSelf: (next) => setState(token, next, store),\n\t\t\tonSet: (handle: UpdateHandler<T>) => subscribe(token, handle, store),\n\t\t}),\n\t)\n\tstore.subject.atomCreation.next(token)\n\treturn token as AtomToken<T>\n}\n","import HAMT from \"hamt_plus\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type {\n\tAtom,\n\tReadonlySelector,\n\tSelector,\n\tStore,\n\tTimeline,\n\tTransaction,\n} from \".\"\nimport { target, isValueCached, readCachedValue, IMPLICIT } from \".\"\nimport type {\n\tAtomToken,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTransactionToken,\n} from \"..\"\n\nexport const computeSelectorState = <T>(\n\tselector: ReadonlySelector<T> | Selector<T>,\n): T => selector.get()\n\nexport function lookup(\n\tkey: string,\n\tstore: Store,\n): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown> {\n\tconst core = target(store)\n\tconst type = HAMT.has(key, core.atoms)\n\t\t? `atom`\n\t\t: HAMT.has(key, core.selectors)\n\t\t? `selector`\n\t\t: `readonly_selector`\n\treturn { key, type } as any\n}\n\nexport function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | null\nexport function withdraw<T>(\n\ttoken: SelectorToken<T>,\n\tstore: Store,\n): Selector<T> | null\nexport function withdraw<T>(\n\ttoken: StateToken<T>,\n\tstore: Store,\n): Atom<T> | Selector<T> | null\nexport function withdraw<T>(\n\ttoken: ReadonlySelectorToken<T>,\n\tstore: Store,\n): ReadonlySelector<T> | null\nexport function withdraw<T>(\n\ttoken: TransactionToken<T>,\n\tstore: Store,\n): Transaction<T extends ƒn ? T : never> | null\nexport function withdraw<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Store,\n): Atom<T> | ReadonlySelector<T> | Selector<T> | null\nexport function withdraw<T>(token: TimelineToken, store: Store): Timeline | null\nexport function withdraw<T>(\n\ttoken:\n\t\t| ReadonlySelectorToken<T>\n\t\t| StateToken<T>\n\t\t| TimelineToken\n\t\t| TransactionToken<T>,\n\tstore: Store,\n):\n\t| Atom<T>\n\t| ReadonlySelector<T>\n\t| Selector<T>\n\t| Timeline\n\t| Transaction<T extends ƒn ? T : never>\n\t| null {\n\tconst core = target(store)\n\treturn (\n\t\tHAMT.get(token.key, core.atoms) ??\n\t\tHAMT.get(token.key, core.selectors) ??\n\t\tHAMT.get(token.key, core.readonlySelectors) ??\n\t\tHAMT.get(token.key, core.transactions) ??\n\t\tHAMT.get(token.key, core.timelines) ??\n\t\tnull\n\t)\n}\n\nexport function deposit<T>(state: Atom<T>): AtomToken<T>\nexport function deposit<T>(state: Selector<T>): SelectorToken<T>\nexport function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>\nexport function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>\nexport function deposit<T>(\n\tstate: Transaction<T extends ƒn ? T : never>,\n): TransactionToken<T>\nexport function deposit<T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n): ReadonlySelectorToken<T> | StateToken<T>\nexport function deposit<T>(\n\tstate:\n\t\t| Atom<T>\n\t\t| ReadonlySelector<T>\n\t\t| Selector<T>\n\t\t| Transaction<T extends ƒn ? T : never>,\n):\n\t| AtomToken<T>\n\t| ReadonlySelectorToken<T>\n\t| SelectorToken<T>\n\t| TransactionToken<T> {\n\treturn {\n\t\tkey: state.key,\n\t\ttype: state.type,\n\t\t...(`family` in state && { family: state.family }),\n\t} as any\n}\n\nexport const getState__INTERNAL = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tif (isValueCached(state.key, store)) {\n\t\tstore.config.logger?.info(`>> read \"${state.key}\"`)\n\t\treturn readCachedValue(state.key, store)\n\t}\n\tif (state.type !== `atom`) {\n\t\tstore.config.logger?.info(`-> calc \"${state.key}\"`)\n\t\treturn computeSelectorState(state)\n\t}\n\tstore.config.logger?.error(\n\t\t`Attempted to get atom \"${state.key}\", which was never initialized in store \"${store.config.name}\".`,\n\t)\n\treturn state.default\n}\n","import type { Store } from \".\"\nimport { target, IMPLICIT, traceAllSelectorAtoms } from \".\"\n\nexport const isAtomDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst core = target(store)\n\treturn core.atomsThatAreDefault.has(key)\n}\n\nexport const markAtomAsDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key)\n}\n\nexport const markAtomAsNotDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atomsThatAreDefault = new Set(target(store).atomsThatAreDefault)\n\tcore.atomsThatAreDefault.delete(key)\n}\n\nexport const isSelectorDefault = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst roots = traceAllSelectorAtoms(key, store)\n\treturn roots.every((root) => isAtomDefault(root.key, store))\n}\n","import type { Hamt } from \"hamt_plus\"\nimport HAMT from \"hamt_plus\"\n\nimport type { Atom, ReadonlySelector, Selector } from \".\"\nimport { target } from \".\"\nimport type { Store } from \"./store\"\nimport { IMPLICIT } from \"./store\"\nimport type { StateToken } from \"..\"\n\nexport type OperationProgress =\n\t| {\n\t\t\topen: false\n\t }\n\t| {\n\t\t\topen: true\n\t\t\tdone: Set<string>\n\t\t\tprev: Hamt<any, string>\n\t\t\ttime: number\n\t\t\ttoken: StateToken<any>\n\t }\n\nexport const openOperation = (token: StateToken<any>, store: Store): void => {\n\tconst core = target(store)\n\tif (core.operation.open) {\n\t\tstore.config.logger?.error(\n\t\t\t`❌ failed to setState to \"${token.key}\" during a setState for \"${core.operation.token.key}\"`,\n\t\t)\n\t\tthrow Symbol(`violation`)\n\t}\n\tcore.operation = {\n\t\topen: true,\n\t\tdone: new Set(),\n\t\tprev: store.valueMap,\n\t\ttime: Date.now(),\n\t\ttoken,\n\t}\n\tstore.config.logger?.info(\n\t\t`⭕ operation start from \"${token.key}\" in store \"${store.config.name}\"`,\n\t)\n}\nexport const closeOperation = (store: Store): void => {\n\tconst core = target(store)\n\tcore.operation = { open: false }\n\tstore.config.logger?.info(`🔴 operation done`)\n}\n\nexport const isDone = (key: string, store: Store = IMPLICIT.STORE): boolean => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`isDone called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn true\n\t}\n\treturn core.operation.done.has(key)\n}\nexport const markDone = (key: string, store: Store = IMPLICIT.STORE): void => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`markDone called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tcore.operation.done.add(key)\n}\nexport const recallState = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store = IMPLICIT.STORE,\n): T => {\n\tconst core = target(store)\n\tif (!core.operation.open) {\n\t\tstore.config.logger?.warn(\n\t\t\t`recall called outside of an operation. This is probably a bug.`,\n\t\t)\n\t\treturn HAMT.get(state.key, core.valueMap)\n\t}\n\treturn HAMT.get(state.key, core.operation.prev)\n}\n\nexport const cacheValue = (\n\tkey: string,\n\tvalue: unknown,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.valueMap = HAMT.set(key, value, core.valueMap)\n}\n\nexport const evictCachedValue = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.valueMap = HAMT.remove(key, core.valueMap)\n}\nexport const readCachedValue = <T>(\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): T => HAMT.get(key, target(store).valueMap)\n\nexport const isValueCached = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => HAMT.has(key, target(store).valueMap)\n\nexport const storeAtom = (\n\tatom: Atom<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.atoms = HAMT.set(atom.key, atom, core.atoms)\n}\n\nexport const storeSelector = (\n\tselector: Selector<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.selectors = HAMT.set(selector.key, selector, core.selectors)\n}\n\nexport const storeReadonlySelector = (\n\tselector: ReadonlySelector<any>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tcore.readonlySelectors = HAMT.set(\n\t\tselector.key,\n\t\tselector,\n\t\tcore.readonlySelectors,\n\t)\n}\n\nexport const hasKeyBeenUsed = (\n\tkey: string,\n\tstore: Store = IMPLICIT.STORE,\n): boolean => {\n\tconst core = target(store)\n\treturn (\n\t\tHAMT.has(key, core.atoms) ||\n\t\tHAMT.has(key, core.selectors) ||\n\t\tHAMT.has(key, core.readonlySelectors)\n\t)\n}\n","import type { Hamt } from \"hamt_plus\"\nimport HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\nimport { doNothing } from \"~/packages/anvl/src/function\"\nimport { Join } from \"~/packages/anvl/src/join\"\n\nimport type {\n\tAtom,\n\tOperationProgress,\n\tReadonlySelector,\n\tSelector,\n\tTransactionStatus,\n\tTimeline,\n\tTransaction,\n} from \".\"\nimport type {\n\tAtomToken,\n\tLogger,\n\tReadonlySelectorToken,\n\tSelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n} from \"..\"\n\nexport type StoreCore = Pick<\n\tStore,\n\t| `atoms`\n\t| `atomsThatAreDefault`\n\t| `operation`\n\t| `readonlySelectors`\n\t| `selectorAtoms`\n\t| `selectorGraph`\n\t| `selectors`\n\t| `timelineAtoms`\n\t| `timelines`\n\t| `transactions`\n\t| `valueMap`\n>\n\nexport interface Store {\n\tatoms: Hamt<Atom<any>, string>\n\tatomsThatAreDefault: Set<string>\n\treadonlySelectors: Hamt<ReadonlySelector<any>, string>\n\tselectorAtoms: Join<null, `selectorKey`, `atomKey`>\n\tselectorGraph: Join<{ source: string }>\n\tselectors: Hamt<Selector<any>, string>\n\ttimelineAtoms: Join<null, `timelineKey`, `atomKey`>\n\ttimelines: Hamt<Timeline, string>\n\ttransactions: Hamt<Transaction<any>, string>\n\tvalueMap: Hamt<any, string>\n\n\tsubject: {\n\t\tatomCreation: Rx.Subject<AtomToken<unknown>>\n\t\tselectorCreation: Rx.Subject<\n\t\t\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n\t\t>\n\t\ttransactionCreation: Rx.Subject<TransactionToken<unknown>>\n\t\ttimelineCreation: Rx.Subject<TimelineToken>\n\t}\n\n\toperation: OperationProgress\n\ttransactionStatus: TransactionStatus<ƒn>\n\tconfig: {\n\t\tname: string\n\t\tlogger: Logger | null\n\t\tlogger__INTERNAL: Logger\n\t}\n}\n\nexport const createStore = (name: string, store: Store | null = null): Store => {\n\tconst copiedStore = {\n\t\t...(store ??\n\t\t\t(() => ({\n\t\t\t\tatomsThatAreDefault: new Set(),\n\t\t\t\tselectorAtoms: new Join({ relationType: `n:n` })\n\t\t\t\t\t.from(`selectorKey`)\n\t\t\t\t\t.to(`atomKey`),\n\t\t\t\tselectorGraph: new Join({ relationType: `n:n` }),\n\t\t\t\tvalueMap: HAMT.make<any, string>(),\n\t\t\t}))()),\n\n\t\tatoms: HAMT.make<Atom<any>, string>(),\n\t\treadonlySelectors: HAMT.make<ReadonlySelector<any>, string>(),\n\t\tselectors: HAMT.make<Selector<any>, string>(),\n\t\ttransactions: HAMT.make<Transaction<any>, string>(),\n\t\ttimelines: HAMT.make<Timeline, string>(),\n\n\t\ttimelineAtoms: new Join({ relationType: `1:n` })\n\t\t\t.from(`timelineKey`)\n\t\t\t.to(`atomKey`),\n\n\t\tsubject: {\n\t\t\tatomCreation: new Rx.Subject(),\n\t\t\tselectorCreation: new Rx.Subject(),\n\t\t\ttransactionCreation: new Rx.Subject(),\n\t\t\ttimelineCreation: new Rx.Subject(),\n\t\t\t...store?.subject,\n\t\t},\n\n\t\toperation: {\n\t\t\topen: false,\n\t\t\t...store?.operation,\n\t\t},\n\t\ttransactionStatus: {\n\t\t\tphase: `idle`,\n\t\t\t...store?.transactionStatus,\n\t\t},\n\t\tconfig: {\n\t\t\tlogger: {\n\t\t\t\t...console,\n\t\t\t\tinfo: doNothing,\n\t\t\t\t...store?.config?.logger,\n\t\t\t},\n\t\t\tlogger__INTERNAL: console,\n\t\t\t...store?.config,\n\t\t\tname,\n\t\t},\n\t} satisfies Store\n\n\tstore?.atoms.forEach((atom) => {\n\t\tconst copiedAtom = { ...atom, subject: new Rx.Subject() } satisfies Atom<any>\n\t\tcopiedStore.atoms = HAMT.set(atom.key, copiedAtom, copiedStore.atoms)\n\t})\n\tstore?.readonlySelectors.forEach((selector) => {\n\t\tselector.install(copiedStore)\n\t})\n\tstore?.selectors.forEach((selector) => {\n\t\tselector.install(copiedStore)\n\t})\n\tstore?.transactions.forEach((tx) => {\n\t\ttx.install(copiedStore)\n\t})\n\tstore?.timelines.forEach((timeline) => {\n\t\ttimeline.install(copiedStore)\n\t})\n\n\treturn copiedStore\n}\n\nexport const IMPLICIT = {\n\tSTORE_INTERNAL: undefined as Store | undefined,\n\tget STORE(): Store {\n\t\treturn this.STORE_INTERNAL ?? (this.STORE_INTERNAL = createStore(`DEFAULT`))\n\t},\n}\n\nexport const clearStore = (store: Store = IMPLICIT.STORE): void => {\n\tconst { config } = store\n\tObject.assign(store, createStore(config.name))\n\tstore.config = config\n}\n","import type { Refinement } from \"fp-ts/Refinement\"\nexport * from \"./curry\"\n\nexport type ƒn = (...parameters: any[]) => any\n\nexport const doNothing = (): void => undefined\n\n/* eslint-disable prettier/prettier */\nexport const become =\n\t<T>(nextVersionOfThing: Modifier<T> | T) =>\n\t(originalThing: T | (() => T)): T =>\n\t\tnextVersionOfThing instanceof Function\n\t\t\t? nextVersionOfThing(\n\t\t\t\t\toriginalThing instanceof Function ? originalThing() : originalThing,\n\t\t\t )\n\t\t\t: nextVersionOfThing\n/* eslint-enable prettier/prettier */\n\nexport type Applicator<X, Y> = (next: Modifier<X> | X) => Modifier<Y>\nexport type Modifier<T> = (thing: T) => T\n\nexport type OneOrMany<T> = T | T[]\n\nexport const isModifier =\n\t<T>(validate: Refinement<unknown, T>) =>\n\t(sample: T): Refinement<unknown, Modifier<T>> => {\n\t\tconst sampleIsValid = validate(sample)\n\t\tif (!sampleIsValid) {\n\t\t\tthrow new Error(`Invalid test case: JSON.stringify(${sample})`)\n\t\t}\n\t\treturn (input: unknown): input is Modifier<T> => {\n\t\t\tif (typeof input !== `function`) return false\n\t\t\tconst testResult = input(sample)\n\t\t\treturn validate(testResult)\n\t\t}\n\t}\n\nexport const pass =\n\t<Params extends ReadonlyArray<any>, Out>(...params: Params) =>\n\t(fn: (...params: Params) => Out): Out =>\n\t\tfn(...params)\n\nexport const typeOf =\n\t<T>(input: unknown) =>\n\t(isType: Refinement<unknown, T>): boolean =>\n\t\tisType(input)\n\nexport const raiseError = (message: string): never => {\n\tthrow new Error(message)\n}\n\nexport type Encapsulate<T extends (...args: any[]) => any> = (\n\t...args: Parameters<T>\n) => void\n\nexport const attempt = (fn: () => void): boolean => {\n\ttry {\n\t\tfn()\n\t\treturn true\n\t} catch (_) {\n\t\treturn false\n\t}\n}\n","import { isString } from \"fp-ts/string\"\n\nimport type { Json, JsonObj } from \"~/packages/anvl/src/json\"\n\nimport { isArray } from \"../array\"\nimport { hasExactProperties, isRecord } from \"../object/refinement\"\nimport { isLiteral } from \"../refinement\"\n\nexport const RELATION_TYPES = [`1:1`, `1:n`, `n:n`] as const\n\nexport type RelationType = typeof RELATION_TYPES[number]\n\nexport const isRelationType = (x: unknown): x is RelationType =>\n\tRELATION_TYPES.includes(x as RelationType)\n\nexport type RelationData<\n\tCONTENT extends JsonObj | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tcontents: JsonObj<string, CONTENT>\n\trelations: JsonObj<string, string[]>\n\trelationType: RelationType\n\ta: A\n\tb: B\n}\n\nexport const EMPTY_RELATION_DATA: RelationData = {\n\tcontents: {},\n\trelations: {},\n\trelationType: `n:n`,\n\ta: `from`,\n\tb: `to`,\n}\n\nexport type IsRelationDataOptions<\n\tCONTENT extends JsonObj | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> = {\n\tfrom?: A\n\tto?: B\n\tisContent?: (json: Json) => json is CONTENT\n}\nexport const isRelationData =\n\t<\n\t\tCONTENT extends JsonObj | null = null,\n\t\tA extends string = `from`,\n\t\tB extends string = `to`,\n\t>({\n\t\tfrom: a = `from` as A,\n\t\tto: b = `to` as B,\n\t\tisContent,\n\t}: IsRelationDataOptions<CONTENT, A, B> = {}) =>\n\t(input: unknown): input is RelationData<CONTENT, A, B> => {\n\t\treturn hasExactProperties<RelationData<CONTENT, A, B>>({\n\t\t\tcontents: isContent\n\t\t\t\t? isRecord(isString, isContent)\n\t\t\t\t: hasExactProperties({}),\n\t\t\trelations: isRecord(isString, isArray(isString)),\n\t\t\trelationType: isRelationType,\n\t\t\ta: isLiteral(a),\n\t\t\tb: isLiteral(b),\n\t\t})(input)\n\t}\n","export type VennCheck = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => boolean\n\nexport type VennTally = (\n\titems: ReadonlyArray<unknown> | unknown[],\n) => (array: ReadonlyArray<unknown> | unknown[]) => number\n\nexport const includesAll: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (!array.includes(item)) return false\n\t}\n\treturn true\n}\n\nexport const includesAny: VennCheck = (items) => (array) => {\n\tfor (const item of items) {\n\t\tif (array.includes(item)) return true\n\t}\n\treturn false\n}\n\nexport const excludesAll: VennCheck = (items) => (array) =>\n\t!includesAny(items)(array)\n\nexport const excludesAny: VennCheck = (items) => (array) =>\n\t!includesAll(items)(array)\n\nexport const comprises: VennCheck = (items) => (array) =>\n\tincludesAll(items)(array) && includesAll(array)(items)\n\nexport const overlaps: VennTally = (items) => (array) => {\n\tlet incidences = 0\n\tfor (const item of items) {\n\t\tif (array.includes(item)) incidences += 1\n\t}\n\treturn incidences\n}\n","export * from \"./match\"\nexport * from \"./venn\"\n\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nexport const each =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T[] =>\n\t\tisType(input) ? [input] : Array.isArray(input) ? input.filter(isType) : []\n\nexport const lastOf = <T>(input: ReadonlyArray<T>): T | undefined =>\n\tinput[input.length - 1]\n\nexport const isArray =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T[] =>\n\t\tArray.isArray(input) && input.every((item) => isType(item))\n\nexport const at =\n\t<T>(index: number) =>\n\t(input: T[]): T | undefined =>\n\t\tinput.at(index)\n\nexport const content =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): input is T | T[] =>\n\t\tisType(input) || isArray(isType)(input)\n\nexport const join = (separator?: string) => (a: string[]): string =>\n\ta.join(separator)\n\nexport const map =\n\t<I, O>(f: (value: I, index: number, array: I[]) => O) =>\n\t(a: I[]): O[] =>\n\t\ta.map(f)\n\nexport const reduce =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduce(f, initial)\n\nexport const slice = (start: number, end?: number) => <I>(a: I[]): I[] =>\n\ta.slice(start, end)\n\nexport const using =\n\t<I, O>(a: I[]) =>\n\t(f: (acc: O, value: I, index: number, array: I[]) => O) =>\n\t(initial: O): O =>\n\t\ta.reduce(f, initial)\n\nexport const reduceRight =\n\t<I, O>(f: (acc: O, value: I, index: number, array: I[]) => O, initial: O) =>\n\t(a: I[]): O =>\n\t\ta.reduceRight(f, initial)\n\nexport const reverse = <I>(a: I[]): I[] => a.reverse()\n\nexport const sort =\n\t<I>(a: I[]) =>\n\t(f?: (x: I, y: I) => number): I[] =>\n\t\tf ? a.sort(f) : a.sort()\n\nexport const sortBy =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(x) - f(y))\n\nexport const sortByDesc =\n\t<I>(f: (value: I) => number) =>\n\t(a: I[]): I[] =>\n\t\ta.sort((x, y) => f(y) - f(x))\n\nexport const every =\n\t<I>(f: (value: I, index: number, array: I[]) => boolean = Boolean) =>\n\t(a: I[]): boolean =>\n\t\ta.every(f)\n\nexport const allTrue = every((x: boolean) => x === true)\n\nexport const addTo =\n\t<I>(a: I[]) =>\n\t(x: I): I[] =>\n\t\ta.includes(x) ? a : [...a, x]\n\nexport const isEmptyArray = (input: unknown): input is [] =>\n\tArray.isArray(input) && input.length === 0\n\nexport const isOneOf =\n\t<T>(...args: ReadonlyArray<T>) =>\n\t(input: unknown): input is T =>\n\t\targs.includes(input as T)\n\nexport const filter =\n\t<I, O extends I>(f: (value: I, index: number, array: I[]) => value is O) =>\n\t(a: I[]): O[] =>\n\t\ta.filter(f)\n","import { pipe } from \"fp-ts/function\"\nimport type { Refinement } from \"fp-ts/Refinement\"\n\nimport { access } from \"./access\"\nimport { recordToEntries } from \"./entries\"\nimport { mob } from \"./mapObject\"\nimport { allTrue, every } from \"../array\"\nimport { pass } from \"../function\"\nimport { ifNullish } from \"../nullish\"\n\nexport type PlainObject = Record<keyof any, unknown>\nexport type EmptyObject = Record<keyof any, never>\n\nexport const isNonNullObject = (input: unknown): input is object =>\n\ttypeof input === `object` && input !== null\n\nexport const isPlainObject = (input: unknown): input is PlainObject =>\n\tisNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype\n\nexport const isEmptyObject = (input: unknown): input is EmptyObject =>\n\tisPlainObject(input) && Object.keys(input).length === 0\n\n/* prettier-ignore */\nexport const isRecord =\n\t<KEY extends keyof any, VAL>(\n\t\tisKey: Refinement<keyof any, KEY>,\n\t\tisValue: Refinement<unknown, VAL>,\n\t) =>\n\t(input: unknown): input is Record<KEY, VAL> =>\n\t\tisPlainObject(input) &&\n\t\tObject.entries(input).every(([k, v]) => isKey(k) && isValue(v))\n/* prettier-ignore-end */\n\nexport type HasPropertiesOptions = {\n\treadonly allowExtraProperties?: boolean\n}\nexport const hasProperties = <OBJ extends object>(\n\tisValue: {\n\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t},\n\toptions: HasPropertiesOptions = { allowExtraProperties: false },\n): Refinement<unknown, OBJ> => {\n\tconst name = `{${recordToEntries(\n\t\tisValue as Record<keyof any, Refinement<any, any>>,\n\t)\n\t\t.map(([k, v]) => String(k) + `:` + v.name)\n\t\t.join(`,`)}}`\n\n\tconst _ = {\n\t\t[name]: (input: unknown): input is OBJ =>\n\t\t\tisPlainObject(input) &&\n\t\t\tpipe(\n\t\t\t\tisValue,\n\t\t\t\tObject.entries,\n\t\t\t\tevery(([key, val]) => key in input || val(undefined)),\n\t\t\t) &&\n\t\t\tpipe(\n\t\t\t\tinput,\n\t\t\t\tmob((val, key) =>\n\t\t\t\t\tpipe(\n\t\t\t\t\t\tisValue,\n\t\t\t\t\t\taccess(key),\n\t\t\t\t\t\tifNullish(() => options.allowExtraProperties),\n\t\t\t\t\t\tpass(val),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tObject.values,\n\t\t\t\tallTrue,\n\t\t\t),\n\t}\n\treturn _[name]\n}\n\nexport const doesExtend =\n\t/* alias for hasExactProperties with allowExtraProperties */\n\t<OBJ extends object>(\n\t\tisValue: {\n\t\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t\t},\n\t): Refinement<unknown, OBJ> =>\n\t\thasProperties(isValue, { allowExtraProperties: true })\n\nexport const hasExactProperties =\n\t/* alias for hasProperties without allowExtraProperties */\n\t<OBJ extends object>(\n\t\tisValue: {\n\t\t\t[K in keyof OBJ]: Refinement<unknown, OBJ[K]>\n\t\t},\n\t): Refinement<unknown, OBJ> =>\n\t\thasProperties(isValue, { allowExtraProperties: false })\n","export const key =\n\t<T extends object>(k: keyof T) =>\n\t(obj: Exclude<object, null>): unknown =>\n\t\t(obj as Record<keyof any, any>)[k]\n\nexport const access = <V, T extends Record<keyof any, V>>(\n\tk: keyof any,\n): {\n\t(obj: T): T[keyof T] | undefined\n\tin: (obj: T) => T[keyof T] | undefined\n} =>\n\tObject.assign((obj: T) => obj[k as keyof T], {\n\t\tin: (obj: T) => obj[k as keyof T],\n\t})\n","export type Entries<K extends keyof any, V> = [key: K, value: V][]\n\nexport const recordToEntries = <K extends keyof any, V>(\n\tobj: Record<K, V>,\n): Entries<K, V> => Object.entries(obj) as Entries<K, V>\n\nexport const entriesToRecord = <K extends keyof any, V>(\n\tentries: Entries<K, V>,\n): Record<K, V> => Object.fromEntries(entries) as Record<K, V>\n","import { pipe } from \"fp-ts/function\"\n\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { map } from \"../array\"\n\nexport const mapObject = <K extends keyof any, I, O>(\n\tobj: Record<K, I>,\n\tfn: (val: I, key: K) => O,\n): Record<K, O> =>\n\tpipe(\n\t\tobj,\n\t\trecordToEntries,\n\t\tmap(([key, val]) => [key, fn(val, key)] as const),\n\t\tentriesToRecord,\n\t)\n\nexport const mob =\n\t<K extends keyof any, I, O>(fn: (val: I, key: K) => O) =>\n\t(obj: Record<K, I>): Record<K, O> =>\n\t\tmapObject(obj, fn)\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nexport const isUndefined = (input: unknown): input is undefined =>\n\tinput === undefined\n\nexport const ifDefined = <T>(\n\tvalidate: Refinement<unknown, T>,\n): Refinement<unknown, T | undefined> =>\n\t((input) => isUndefined(input) || validate(input)) as Refinement<\n\t\tunknown,\n\t\tT | undefined\n\t>\n\nexport const isNull = (input: unknown): input is null => input === null\n\nexport const isNullish = (input: unknown): input is null | undefined =>\n\tisUndefined(input) || isNull(input)\n\nexport type NullSafeUnion<Base, Extension> = Extension extends null\n\t? Base\n\t: Base & Extension\n\nexport type NullSafeRest<MaybeArg> = MaybeArg extends null\n\t? [] | [undefined]\n\t: [MaybeArg]\n\nexport interface Discard {\n\treadonly _discard: unique symbol\n}\n\nexport const ifNullish =\n\t<X, Y>(alt: Y) =>\n\t(input: X): Exclude<X, null | undefined> | Y =>\n\t\t(input ?? alt) as Exclude<X, null | undefined> | Y\n","import type { Refinement } from \"fp-ts/Refinement\"\n\nexport * from \"./refined\"\n\nexport const canExist = (_: unknown): _ is unknown => true\nexport const cannotExist = (_: unknown): _ is never => false\n\nexport const isLiteral =\n\t<T extends boolean | number | string>(value: T): Refinement<unknown, T> =>\n\t(input: unknown): input is T =>\n\t\tinput === value\n\nexport const isWithin =\n\t<Options extends ReadonlyArray<any>>(args: Options) =>\n\t(input: unknown): input is Options[number] =>\n\t\targs.includes(input as Options[number])\n\nexport const ensure =\n\t<T>(isType: Refinement<unknown, T>) =>\n\t(input: unknown): T => {\n\t\tif (!isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to be of type ${isType.name}`)\n\t\t}\n\t\treturn input as T\n\t}\n\nexport const ensureAgainst =\n\t<A, B>(isType: Refinement<unknown, A>) =>\n\t(input: A | B): Exclude<A | B, A> => {\n\t\tif (isType(input)) {\n\t\t\tthrow new TypeError(`Expected ${input} to not be of type ${isType.name}`)\n\t\t}\n\t\treturn input as Exclude<A | B, A>\n\t}\n\nexport type ExtendsSome<A, B> = Refinement<unknown, A | B> & {\n\tor: <C>(isType: Refinement<unknown, C>) => ExtendsSome<unknown, A | B | C>\n}\nexport const couldBe = <A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n} => {\n\tconst name = `(${refinements.map((r) => r.name || `anon`).join(` | `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.some(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` | `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name ?? `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tor: <B>(isTypeB: Refinement<unknown, B>) => ExtendsSome<A, B>\n\t} = Object.assign(_[name], {\n\t\tor: <B>(isTypeB: Refinement<unknown, B>): ExtendsSome<A, B> =>\n\t\t\tcouldBe(isTypeB, logging, [...refinements, isTypeB]),\n\t})\n\treturn checkTypes\n}\n\nexport const isUnion = couldBe(cannotExist)\n\nexport type ExtendsAll<A, B> = Refinement<unknown, A & B> & {\n\tand: <C>(isType: Refinement<unknown, C>) => ExtendsAll<A & B, C>\n}\n\nexport const mustBe = <A>(\n\tisTypeA: Refinement<unknown, A>,\n\tlogging = false,\n\trefinements: Refinement<unknown, any>[] = [isTypeA],\n): {\n\t(input: unknown): input is A\n\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n} => {\n\tconst name = `(${refinements.map((r) => r.name || `anon`).join(` & `)})`\n\tconst _ = {\n\t\t[name]: (input: unknown): input is A =>\n\t\t\trefinements.every(\n\t\t\t\t(refinement) => (\n\t\t\t\t\tlogging &&\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\trefinements.map((r) => r.name || `anon`).join(` & `),\n\t\t\t\t\t\t\t`>`,\n\t\t\t\t\t\t\trefinement.name || `anon`,\n\t\t\t\t\t\t\t`:`,\n\t\t\t\t\t\t\trefinement(input),\n\t\t\t\t\t\t),\n\t\t\t\t\trefinement(input)\n\t\t\t\t),\n\t\t\t),\n\t}\n\tconst checkTypes: {\n\t\t(input: unknown): input is A\n\t\tand: <B>(isTypeB: Refinement<unknown, B>) => ExtendsAll<A, B>\n\t} = Object.assign(_[name], {\n\t\tand: <B>(isTypeB: Refinement<unknown, B>): ExtendsAll<A, B> =>\n\t\t\tmustBe(isTypeB, logging, [...refinements, isTypeB]) as ExtendsAll<A, B>,\n\t})\n\treturn checkTypes\n}\n\nexport const isIntersection = mustBe(canExist)\n\nexport const isClass =\n\t<ClassSignature extends abstract new (...args: any) => any>(\n\t\tC: ClassSignature,\n\t) =>\n\t(input: unknown): input is InstanceType<ClassSignature> =>\n\t\tinput instanceof C\n","import type { RelationData } from \"./core-relation-data\"\nimport type { JsonObj } from \"../json\"\n\nexport const getRelatedIds = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string[] => relationMap.relations[id] ?? []\n\nexport const getRelatedId = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): string | undefined => {\n\tconst relations = getRelatedIds(relationMap, id)\n\tif (relations.length > 1) {\n\t\tconsole.warn(\n\t\t\t`entry with id ${id} was not expected to have multiple relations`,\n\t\t)\n\t}\n\treturn relations[0]\n}\n","import type { Json, JsonInterface, JsonObj } from \"~/packages/anvl/src/json\"\n\nimport { Join } from \".\"\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\n\nexport const makeJsonInterface = <\n\tCONTENT extends JsonObj | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n>(\n\tjoin: Join<CONTENT, A, B>,\n\t...params: CONTENT extends null ? [] : [(x: Json) => x is CONTENT]\n): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\tconst isContent = params[0] as (x: Json) => x is CONTENT\n\tconst { a, b } = join\n\tconst options: IsRelationDataOptions<CONTENT, A, B> = {\n\t\tfrom: a,\n\t\tto: b,\n\t\tisContent,\n\t}\n\treturn {\n\t\ttoJson: (join) => join.toJSON(),\n\t\tfromJson: (json) => Join.fromJSON(json, options),\n\t}\n}\n","import { pipe } from \"fp-ts/function\"\n\nimport type { Identified } from \"~/packages/anvl/src/id/identified\"\nimport { isEmptyObject } from \"~/packages/anvl/src/object/refinement\"\n\nimport type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getRelationEntries } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\nimport type { JsonObj } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\n\nexport const makeContentId = (idA: string, idB: string): string =>\n\t[idA, idB].sort().join(`/`)\n\nexport const getContent = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): CONTENT | undefined => relationMap.contents[makeContentId(idA, idB)]\n\nexport const setContent = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\tcontent: CONTENT,\n): RelationData<CONTENT, A, B> => ({\n\t...map,\n\tcontents: {\n\t\t...map.contents,\n\t\t[makeContentId(idA, idB)]: content,\n\t},\n})\n\nexport const getRelations = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): (CONTENT extends null ? Identified : CONTENT & Identified)[] =>\n\tgetRelationEntries(relationMap, id).map(\n\t\t([id, content]) =>\n\t\t\t({\n\t\t\t\tid,\n\t\t\t\t...content,\n\t\t\t}) as CONTENT extends null ? Identified : CONTENT & Identified,\n\t)\n\nexport const setRelations = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tsubject: { [from in A]: string } | { [to in B]: string },\n\trelations: (CONTENT extends null ? Identified : CONTENT & Identified)[],\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (subject as { [from in A]: string })[current.a]\n\tconst idB: string | undefined = (subject as { [to in B]: string })[current.b]\n\treturn pipe(\n\t\tcurrent,\n\t\t(relationData) => {\n\t\t\tconst relatedIds = getRelatedIds(current, idA)\n\t\t\tconst removedIds = relatedIds.filter(\n\t\t\t\t(id) => !relations.some((r) => r.id === id),\n\t\t\t)\n\t\t\tlet step = relationData\n\t\t\tfor (const id of removedIds) {\n\t\t\t\tconst remove = {\n\t\t\t\t\t[current.a]: idA ?? id,\n\t\t\t\t\t[current.b]: idB ?? id,\n\t\t\t\t} as Record<A | B, string>\n\t\t\t\tstep = removeRelation(step, remove)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tlet step = relationData\n\t\t\tfor (const { id, ...rest } of relations) {\n\t\t\t\tconst content = isEmptyObject(rest) ? undefined : rest\n\t\t\t\tstep = setRelationWithContent(\n\t\t\t\t\tstep,\n\t\t\t\t\t{ [current.a]: idA ?? id, [current.b]: idB ?? id } as Record<\n\t\t\t\t\t\tA | B,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>,\n\t\t\t\t\t// @ts-expect-error hacky\n\t\t\t\t\tcontent as NullSafeRest<CONTENT>,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn step\n\t\t},\n\t\t(relationData) => {\n\t\t\tconst newlyOrderedIds = relations.map((r) => r.id)\n\t\t\treturn {\n\t\t\t\t...relationData,\n\t\t\t\trelations: {\n\t\t\t\t\t...relationData.relations,\n\t\t\t\t\t[idA ?? idB]: newlyOrderedIds,\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t)\n}\n","import type { RelationData } from \"./core-relation-data\"\nimport { getRelatedIds } from \"./get-related-ids\"\nimport { getContent } from \"./relation-contents\"\nimport type { JsonObj } from \"../json\"\n\nexport const getRelationEntries = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tidA: string,\n): [string, CONTENT][] =>\n\tgetRelatedIds(relationMap, idA).map((idB) => [\n\t\tidB,\n\t\tgetContent(relationMap, idA, idB) as CONTENT,\n\t])\n\nexport const getRelationRecord = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\trelationMap: RelationData<CONTENT, A, B>,\n\tid: string,\n): Record<string, CONTENT> =>\n\tObject.fromEntries(getRelationEntries(relationMap, id))\n","import { pipe } from \"fp-ts/function\"\nimport { isString } from \"fp-ts/string\"\n\nimport type { RelationData } from \"./core-relation-data\"\nimport { isEmptyArray, isOneOf, map } from \"../array\"\nimport { comprises } from \"../array/venn\"\nimport type { JsonObj } from \"../json\"\nimport type { RequireAtLeastOne } from \"../object\"\nimport { treeShake as removeProperties } from \"../object\"\nimport { entriesToRecord, recordToEntries } from \"../object/entries\"\nimport { split } from \"../string/split\"\n\nexport const removeSpecific = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n): RelationData<CONTENT, A, B> => {\n\tconst isIdForRemoval = isOneOf(idA, idB)\n\treturn {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\tisIdForRemoval(id)\n\t\t\t\t\t? relations.filter((relation) => !isIdForRemoval(relation))\n\t\t\t\t\t: relations,\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties(isEmptyArray),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) =>\n\t\t\t\t\tisString(key) && pipe(key, split(`/`), comprises([idA, idB])),\n\t\t\t),\n\t\t),\n\t}\n}\n\nexport const removeAll = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tidToRemove: string,\n): RelationData<CONTENT, A, B> => {\n\tconst next: RelationData<CONTENT, A, B> = {\n\t\t...current,\n\t\trelations: pipe(\n\t\t\tcurrent.relations,\n\t\t\trecordToEntries,\n\t\t\tmap(([id, relations]): [id: string, fewerRelations: string[]] => [\n\t\t\t\tid,\n\t\t\t\trelations.filter((relation) => relation !== idToRemove),\n\t\t\t]),\n\t\t\tentriesToRecord,\n\t\t\tremoveProperties((val, key) => key === idToRemove || isEmptyArray(val)),\n\t\t),\n\t\tcontents: pipe(\n\t\t\tcurrent.contents,\n\t\t\tremoveProperties(\n\t\t\t\t(_, key) => isString(key) && key.split(`/`).includes(idToRemove),\n\t\t\t),\n\t\t),\n\t}\n\treturn next\n}\n\nexport const removeRelation = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Partial<Record<A | B, string>>,\n): RelationData<CONTENT, A, B> => {\n\tconst idA: string | undefined = (relation as { [key in A | B]: string })[\n\t\tcurrent.a\n\t]\n\tconst idB: string | undefined = (relation as { [key in A | B]: string })[\n\t\tcurrent.b\n\t]\n\treturn idB ? removeSpecific(current, idA, idB) : removeAll(current, idA)\n}\n","import { flow, pipe } from \"fp-ts/function\"\nimport type { Refinement } from \"fp-ts/lib/Refinement\"\n\nimport { deepMob } from \"./deepMob\"\nimport { entriesToRecord, recordToEntries } from \"./entries\"\nimport { isPlainObject } from \"./refinement\"\nimport { includesAny, map, reduce, filter } from \"../array\"\nimport { isUndefined } from \"../nullish\"\n\nexport * from \"./access\"\nexport * from \"./deepMob\"\nexport * from \"./entries\"\nexport * from \"./mapObject\"\nexport * from \"./modify\"\nexport * from \"./patch\"\nexport * from \"./refinement\"\nexport * from \"./sprawl\"\n\nexport const redact =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(obj: O): Omit<O, K> =>\n\t\treduce<K, O>((acc, key) => (delete acc[key], acc), obj)(args)\n\nexport type Redacted<Holder, RedactProp extends keyof any> = Omit<\n\t{\n\t\t[K in keyof Holder]: Holder[K] extends (infer Item)[]\n\t\t\t? Redacted<Item, RedactProp>[]\n\t\t\t: Redacted<Omit<Holder[K], RedactProp>, RedactProp>\n\t},\n\tRedactProp\n>\nexport const redactDeep =\n\t<K extends keyof any>(...args: K[]) =>\n\t<O extends Record<K, any>>(base: O): Redacted<O, K> =>\n\t\tdeepMob(base, (node, path) =>\n\t\t\tincludesAny(args)(path)\n\t\t\t\t? {\n\t\t\t\t\t\tmeta: { pathComplete: true },\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tdata: isPlainObject(node)\n\t\t\t\t\t\t\t? redact(...args)(node as Record<keyof any, any>)\n\t\t\t\t\t\t\t: node,\n\t\t\t\t },\n\t\t)\n\nexport const select =\n\t<Key extends keyof any>(...args: Key[]) =>\n\t<Obj extends object>(\n\t\tobj: Obj,\n\t): {\n\t\t// @ts-expect-error fuk u\n\t\t[K in keyof Pick<Obj, Key>]: any extends Pick<Obj, Key>[K]\n\t\t\t? undefined\n\t\t\t: // @ts-expect-error fuk u\n\t\t\t Pick<Obj, Key>[K]\n\t} =>\n\t\t// @ts-expect-error fuk u ts\n\t\treduce<Key, Pick<Obj, Key>>(\n\t\t\t// @ts-expect-error i will fite u\n\t\t\t(acc, key) => (key in obj ? (acc[key] = obj[key as keyof Obj]) : acc, acc),\n\t\t\t// @ts-expect-error fuk u\n\t\t\t{} as Pick<Obj, Key>,\n\t\t)(args)\n\nexport const treeShake =\n\t(shouldDiscard: (val: unknown, key: keyof any) => boolean = isUndefined) =>\n\t<T extends object>(\n\t\tobj: T,\n\t): T extends Record<keyof any, unknown> ? T : Partial<T> => {\n\t\tconst newObj = {} as T\n\t\tconst entries = Object.entries(obj) as [keyof T, any][]\n\t\tentries.forEach(([key, val]) =>\n\t\t\t!shouldDiscard(val, key) ? (newObj[key] = val) : null,\n\t\t)\n\t\treturn newObj as T extends Record<keyof any, unknown> ? T : Partial<T>\n\t}\n\nexport type KeysExtending<T, V> = keyof {\n\t[K in keyof T]: T[K] extends V ? K : never\n}\n\nconst a: never | null = null\n\nexport const filterProperties =\n\t<DiscardVal, DiscardKey extends keyof any>(\n\t\tshouldDiscardVal: Refinement<unknown, DiscardVal>,\n\t\tshouldDiscardKey: Refinement<unknown, DiscardKey>,\n\t) =>\n\t<P extends Record<keyof any, any>>(\n\t\tprops: P,\n\t): DiscardVal extends never\n\t\t? DiscardKey extends never\n\t\t\t? P\n\t\t\t: Omit<P, DiscardKey>\n\t\t: Omit<P, DiscardKey | KeysExtending<P, DiscardVal>> =>\n\t\t// @ts-expect-error oh well\n\t\tpipe(\n\t\t\tprops,\n\t\t\trecordToEntries,\n\t\t\tfilter(\n\t\t\t\t(\n\t\t\t\t\tentry,\n\t\t\t\t): entry is [\n\t\t\t\t\tExclude<keyof P, DiscardKey>,\n\t\t\t\t\tExclude<P[keyof P], DiscardVal>,\n\t\t\t\t] => !shouldDiscardKey(entry[0]) || !shouldDiscardVal(entry[1]),\n\t\t\t),\n\t\t\tentriesToRecord,\n\t\t)\n\nexport const delve = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n): Error | { found: unknown } => {\n\tconst found = path.reduce((acc, key) => acc?.[key], obj)\n\treturn found === undefined ? new Error(`Not found`) : { found }\n}\n\nexport const tweak = (\n\tobj: Record<keyof any, any>,\n\tpath: ReadonlyArray<keyof any>,\n\tvalue: unknown,\n): void =>\n\tpath.reduce((acc, key, i) => {\n\t\tif (i === path.length - 1) {\n\t\t\tacc[key] = value\n\t\t}\n\t\tif (acc[key] === undefined) {\n\t\t\tacc[key] = typeof key === `number` ? [] : {}\n\t\t}\n\t\treturn acc[key]\n\t}, obj)\n\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Partial<Pick<T, Exclude<keyof T, K>>> & Required<Pick<T, K>>\n}[keyof T]\n","export const split = (separator: string) => (str: string): string[] =>\n\tstr.split(separator)\n","import type { RelationData } from \"./core-relation-data\"\nimport { getRelatedId } from \"./get-related-ids\"\nimport { setContent } from \"./relation-contents\"\nimport { addTo, isEmptyArray } from \"../array\"\nimport type { JsonObj } from \"../json\"\nimport type { NullSafeRest } from \"../nullish\"\nimport { treeShake as removeProperties } from \"../object\"\n\nexport const setManyToMany = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tmap: RelationData<CONTENT, A, B>,\n\tidA: string,\n\tidB: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst next = {\n\t\t...map,\n\t\trelations: {\n\t\t\t...map.relations,\n\t\t\t[idA]: addTo(map.relations[idA] ?? [])(idB),\n\t\t\t[idB]: addTo(map.relations[idB] ?? [])(idA),\n\t\t},\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, idA, idB, content) : next\n}\n\nconst removeEmpties = removeProperties(isEmptyArray)\n\nexport const set1ToMany = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\tleaderId: string,\n\tfollowerId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst relations = { ...current.relations }\n\tconst prevLeaderId = getRelatedId(current, followerId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...relations,\n\t\t\t...(prevLeaderId &&\n\t\t\t\tprevLeaderId !== leaderId && {\n\t\t\t\t\t[prevLeaderId]: relations[prevLeaderId].filter(\n\t\t\t\t\t\t(id) => id !== followerId,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t[followerId]: [leaderId],\n\t\t\t[leaderId]: addTo(relations[leaderId] ?? [])(followerId),\n\t\t}),\n\t}\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, leaderId, followerId, content) : next\n}\n\nexport const set1To1 = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\twifeId: string,\n\thusbandId: string,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst prevWifeId = getRelatedId(current, husbandId)\n\tconst prevHusbandId = getRelatedId(current, wifeId)\n\tconst next = {\n\t\t...current,\n\t\trelations: removeEmpties({\n\t\t\t...current.relations,\n\t\t\t...(prevWifeId && { [prevWifeId]: [] }),\n\t\t\t...(prevHusbandId && { [prevHusbandId]: [] }),\n\t\t\t[wifeId]: [husbandId],\n\t\t\t[husbandId]: [wifeId],\n\t\t}),\n\t}\n\n\tconst content = rest[0] as CONTENT | undefined\n\treturn content ? setContent(next, wifeId, husbandId, content) : next\n}\n\nexport const setRelationWithContent = <\n\tCONTENT extends JsonObj | null,\n\tA extends string,\n\tB extends string,\n>(\n\tcurrent: RelationData<CONTENT, A, B>,\n\trelation: Record<A | B, string>,\n\t...rest: NullSafeRest<CONTENT>\n): RelationData<CONTENT, A, B> => {\n\tconst { [current.a]: idA, [current.b]: idB } = relation\n\t// console.log({\n\t// current,\n\t// relation,\n\t// idA,\n\t// idB,\n\t// })\n\tswitch (current.relationType) {\n\t\tcase `1:1`:\n\t\t\treturn set1To1(current, idA, idB, ...rest)\n\t\tcase `1:n`:\n\t\t\treturn set1ToMany(current, idA, idB, ...rest)\n\t\tcase `n:n`:\n\t\t\treturn setManyToMany(current, idA, idB, ...rest)\n\t}\n}\n","import type { Refinement } from \"fp-ts/lib/Refinement\"\n\nimport type { Identified } from \"~/packages/anvl/src/id/identified\"\n\nimport type { IsRelationDataOptions, RelationData } from \"./core-relation-data\"\nimport { EMPTY_RELATION_DATA, isRelationData } from \"./core-relation-data\"\nimport { getRelatedId, getRelatedIds } from \"./get-related-ids\"\nimport { makeJsonInterface } from \"./make-json-interface\"\nimport { getContent, getRelations, setRelations } from \"./relation-contents\"\nimport { getRelationEntries, getRelationRecord } from \"./relation-record\"\nimport { removeRelation } from \"./remove-relation\"\nimport { setRelationWithContent } from \"./set-relation\"\nimport type { Json, JsonInterface, JsonObj } from \"../json\"\nimport type { NullSafeRest, NullSafeUnion } from \"../nullish\"\n\nexport class Join<\n\tCONTENT extends JsonObj | null = null,\n\tA extends string = `from`,\n\tB extends string = `to`,\n> implements RelationData<CONTENT, A, B>\n{\n\tpublic readonly relationType: `1:1` | `1:n` | `n:n`\n\tpublic readonly a: A = `from` as A\n\tpublic readonly b: B = `to` as B\n\tpublic readonly relations: Record<string, string[]>\n\tpublic readonly contents: Record<string, CONTENT>\n\tpublic constructor(json?: Partial<RelationData<CONTENT, A, B>>) {\n\t\tObject.assign(this, {\n\t\t\t...EMPTY_RELATION_DATA,\n\t\t\t...json,\n\t\t\tmakeJsonInterface: this.makeJsonInterface,\n\t\t})\n\t}\n\tpublic toJSON(): RelationData<CONTENT, A, B> {\n\t\treturn {\n\t\t\trelationType: this.relationType,\n\t\t\trelations: this.relations,\n\t\t\tcontents: this.contents,\n\t\t\ta: this.a,\n\t\t\tb: this.b,\n\t\t}\n\t}\n\tpublic static fromJSON<\n\t\tCONTENT extends JsonObj | null,\n\t\tA extends string,\n\t\tB extends string,\n\t>(\n\t\tjson: Json,\n\t\toptions?: IsRelationDataOptions<CONTENT, A, B>,\n\t): Join<CONTENT, A, B> {\n\t\tconst isValid = isRelationData<CONTENT, A, B>(options)(json)\n\t\tif (isValid) {\n\t\t\treturn new Join<CONTENT, A, B>(json)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Saved JSON for this Join is invalid: ${JSON.stringify(json)}`,\n\t\t)\n\t}\n\n\tpublic from<AA extends string>(newA: AA): Join<CONTENT, AA, B> {\n\t\treturn new Join({ ...this, a: newA })\n\t}\n\n\tpublic to<BB extends string>(newB: BB): Join<CONTENT, A, BB> {\n\t\treturn new Join({ ...this, b: newB })\n\t}\n\n\tpublic makeJsonInterface = (\n\t\t...params: CONTENT extends null ? [] : [Refinement<unknown, CONTENT>]\n\t): JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>> => {\n\t\treturn makeJsonInterface<CONTENT, A, B>(this, ...params)\n\t}\n\n\tpublic getRelatedId(id: string): string | undefined {\n\t\treturn getRelatedId(this, id)\n\t}\n\tpublic getRelatedIds(id: string): string[] {\n\t\treturn getRelatedIds(this, id)\n\t}\n\tpublic getContent(idA: string, idB: string): CONTENT | undefined {\n\t\treturn getContent(this, idA, idB)\n\t}\n\tpublic getRelationEntries(id: string): [string, CONTENT][] {\n\t\treturn getRelationEntries(this, id)\n\t}\n\tpublic getRelationRecord(id: string): Record<string, CONTENT> {\n\t\treturn getRelationRecord(this, id)\n\t}\n\tpublic getRelation(\n\t\tid: string,\n\t): NullSafeUnion<Identified, CONTENT> | undefined {\n\t\treturn getRelations(this, id)[0]\n\t}\n\tpublic getRelations(id: string): NullSafeUnion<Identified, CONTENT>[] {\n\t\treturn getRelations(this, id)\n\t}\n\tpublic setRelations(\n\t\tsubject: { [from in A]: string } | { [to in B]: string },\n\t\trelations: NullSafeUnion<Identified, CONTENT>[],\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelations(this, subject, relations))\n\t}\n\tpublic set(\n\t\trelation: { [key in A | B]: string },\n\t\t...rest: NullSafeRest<CONTENT>\n\t): Join<CONTENT, A, B> {\n\t\treturn new Join(setRelationWithContent(this, relation, ...rest))\n\t}\n\tpublic remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B> {\n\t\treturn new Join(\n\t\t\tremoveRelation(this, relation as Partial<Record<A | B, string>>),\n\t\t)\n\t}\n}\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store, StoreCore } from \".\"\nimport {\n\tabortTransaction,\n\tapplyTransaction,\n\tbuildTransaction,\n\tdeposit,\n\tIMPLICIT,\n} from \".\"\nimport type { TransactionOptions, TransactionToken, TransactionUpdate } from \"..\"\nimport { getState, setState } from \"..\"\n\nexport type Transaction<ƒ extends ƒn> = {\n\tkey: string\n\ttype: `transaction`\n\tinstall: (store: Store) => void\n\tsubject: Rx.Subject<TransactionUpdate<ƒ>>\n\trun: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>\n}\n\nexport function transaction__INTERNAL<ƒ extends ƒn>(\n\toptions: TransactionOptions<ƒ>,\n\tstore: Store = IMPLICIT.STORE,\n): TransactionToken<ƒ> {\n\tconst newTransaction: Transaction<ƒ> = {\n\t\tkey: options.key,\n\t\ttype: `transaction`,\n\t\trun: (...params: Parameters<ƒ>) => {\n\t\t\tbuildTransaction(options.key, params, store)\n\t\t\ttry {\n\t\t\t\tconst output = options.do(\n\t\t\t\t\t{\n\t\t\t\t\t\tget: (token) => getState(token, store),\n\t\t\t\t\t\tset: (token, value) => setState(token, value, store),\n\t\t\t\t\t},\n\t\t\t\t\t...params,\n\t\t\t\t)\n\t\t\t\tapplyTransaction(output, store)\n\t\t\t\treturn output\n\t\t\t} catch (thrown) {\n\t\t\t\tabortTransaction(store)\n\t\t\t\tstore.config.logger?.error(`Transaction ${options.key} failed`, thrown)\n\t\t\t\tthrow thrown\n\t\t\t}\n\t\t},\n\t\tinstall: (store) => transaction__INTERNAL(options, store),\n\t\tsubject: new Rx.Subject(),\n\t}\n\tconst core = target(store)\n\tcore.transactions = HAMT.set(\n\t\tnewTransaction.key,\n\t\tnewTransaction,\n\t\tcore.transactions,\n\t)\n\tconst token = deposit(newTransaction)\n\tstore.subject.transactionCreation.next(token)\n\treturn token\n}\n\nexport const target = (store: Store = IMPLICIT.STORE): StoreCore =>\n\tstore.transactionStatus.phase === `building`\n\t\t? store.transactionStatus.core\n\t\t: store\n","import * as Rx from \"rxjs\"\n\nimport type { Serializable } from \"~/packages/anvl/src/json\"\nimport { stringifyJson } from \"~/packages/anvl/src/json\"\n\nimport type { Store } from \".\"\nimport {\n\tatom__INTERNAL,\n\twithdraw,\n\tselector__INTERNAL,\n\ttarget,\n\tdeposit,\n\tIMPLICIT,\n} from \".\"\nimport type {\n\tAtomFamily,\n\tAtomFamilyOptions,\n\tAtomToken,\n\tFamilyMetadata,\n\tReadonlySelectorFamily,\n\tReadonlySelectorFamilyOptions,\n\tReadonlySelectorToken,\n\tSelectorFamily,\n\tSelectorFamilyOptions,\n\tSelectorToken,\n} from \"..\"\n\nexport function atomFamily__INTERNAL<T, K extends Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomFamily<T, K> {\n\tconst subject = new Rx.Subject<AtomToken<T>>()\n\treturn Object.assign(\n\t\t(key: K): AtomToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = withdraw({ key: fullKey, type: `atom` }, store)\n\t\t\tconst token: AtomToken<any> = existing\n\t\t\t\t? deposit(existing)\n\t\t\t\t: atom__INTERNAL<T>(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkey: fullKey,\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\toptions.default instanceof Function\n\t\t\t\t\t\t\t\t\t? options.default(key)\n\t\t\t\t\t\t\t\t\t: options.default,\n\t\t\t\t\t\t\teffects: options.effects?.(key),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tfamily,\n\t\t\t\t\t\tstore,\n\t\t\t\t )\n\t\t\tsubject.next(token)\n\t\t\treturn token\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `atom_family`,\n\t\t\tsubject,\n\t\t} as const,\n\t)\n}\n\nexport function readonlySelectorFamily__INTERNAL<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): ReadonlySelectorFamily<T, K> {\n\tconst core = target(store)\n\tconst subject = new Rx.Subject<ReadonlySelectorToken<T>>()\n\treturn Object.assign(\n\t\t(key: K): ReadonlySelectorToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = core.readonlySelectors.get(fullKey)\n\t\t\tif (existing) {\n\t\t\t\treturn deposit(existing)\n\t\t\t}\n\t\t\treturn selector__INTERNAL<T>(\n\t\t\t\t{\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tget: options.get(key),\n\t\t\t\t},\n\t\t\t\tfamily,\n\t\t\t\tstore,\n\t\t\t) as ReadonlySelectorToken<T>\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `readonly_selector_family`,\n\t\t\tsubject,\n\t\t} as const,\n\t) as ReadonlySelectorFamily<T, K>\n}\n\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): SelectorFamily<T, K>\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n\tstore?: Store,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily__INTERNAL<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\tconst isReadonly = !(`set` in options)\n\n\tif (isReadonly) {\n\t\treturn readonlySelectorFamily__INTERNAL(options, store)\n\t}\n\tconst core = target(store)\n\tconst subject = new Rx.Subject<SelectorToken<T>>()\n\n\treturn Object.assign(\n\t\t(key: K): SelectorToken<T> => {\n\t\t\tconst subKey = stringifyJson(key)\n\t\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\t\tconst fullKey = `${options.key}(${subKey})`\n\t\t\tconst existing = core.selectors.get(fullKey)\n\t\t\tif (existing) {\n\t\t\t\treturn deposit(existing)\n\t\t\t}\n\t\t\tconst token = selector__INTERNAL<T>(\n\t\t\t\t{\n\t\t\t\t\tkey: fullKey,\n\t\t\t\t\tget: options.get(key),\n\t\t\t\t\tset: options.set(key),\n\t\t\t\t},\n\t\t\t\tfamily,\n\t\t\t\tstore,\n\t\t\t)\n\t\t\tsubject.next(token)\n\t\t\treturn token\n\t\t},\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `selector_family`,\n\t\t} as const,\n\t) as SelectorFamily<T, K>\n}\n","import { pipe } from \"fp-ts/function\"\n\nexport * from \"./refine\"\nexport * from \"./json-interface\"\n\nexport const serializeSet = <T>(set: Set<T>): string =>\n\tpipe(set, Array.from, JSON.stringify)\n\nexport const deserializeSet = <T>(str: string): Set<T> =>\n\tpipe(str, JSON.parse, Array.from, (a) => new Set(a as T[]))\n\nexport type Primitive = boolean | number | string | null\n\nexport type Serializable =\n\t| Primitive\n\t| Readonly<{ [key: string]: Serializable }>\n\t| ReadonlyArray<Serializable>\n\nexport type JsonObj<\n\tKey extends string = string,\n\tValue extends Serializable = Serializable,\n> = Record<Key, Value>\n\nexport type JsonArr<Element extends Serializable = Serializable> =\n\tReadonlyArray<Element>\n\nexport type Json = JsonArr | JsonObj | Primitive\n\nexport const parseJson = <J extends Json, S extends Stringified<J> | string>(\n\tstr: S | string,\n): S extends Stringified<J> ? J : Json => JSON.parse(str)\n\nexport type Stringified<J extends Json> = string & { __json: J }\n\nexport const stringifyJson = <J extends Json>(json: J): Stringified<J> =>\n\tJSON.stringify(json) as Stringified<J>\n\nexport type Empty = Record<string, never>\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = typeof JSON_TYPE_NAMES[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json> {\n\tarray: JsonArr\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: JsonObj\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n","export * from \"./attach-meta\"\nexport * from \"./meta-state\"\nexport * from \"./meta-timelines\"\nexport * from \"./meta-transactions\"\n","import type { AtomToken, ReadonlySelectorToken, SelectorToken } from \"../..\"\nimport { selector, atom } from \"../..\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\n\nexport type StateTokenIndex<\n\tToken extends\n\t\t| AtomToken<unknown>\n\t\t| ReadonlySelectorToken<unknown>\n\t\t| SelectorToken<unknown>,\n> = Record<\n\tstring,\n\t| Token\n\t| {\n\t\t\tkey: string\n\t\t\tfamilyMembers: Record<string, Token>\n\t }\n>\n\nexport type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>\nexport type SelectorTokenIndex = StateTokenIndex<\n\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n>\n\nexport const attachMetaAtoms = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<AtomTokenIndex> => {\n\tconst atomTokenIndexState__INTERNAL = atom<AtomTokenIndex>({\n\t\tkey: `👁🗨_atom_token_index__INTERNAL`,\n\t\tdefault: () =>\n\t\t\t[...store.atoms].reduce<AtomTokenIndex>((acc, [key]) => {\n\t\t\t\tacc[key] = { key, type: `atom` }\n\t\t\t\treturn acc\n\t\t\t}, {}),\n\t\teffects: [\n\t\t\t({ setSelf }) => {\n\t\t\t\tstore.subject.atomCreation.subscribe((atomToken) => {\n\t\t\t\t\tif (store.operation.open) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\tconst { key, family } = atomToken\n\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t[subKey]: atomToken,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[key]: atomToken,\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t},\n\t\t],\n\t})\n\treturn selector({\n\t\tkey: `👁🗨_atom_token_index`,\n\t\tget: ({ get }) => get(atomTokenIndexState__INTERNAL),\n\t})\n}\n\nexport const attachMetaSelectors = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<SelectorTokenIndex> => {\n\tconst readonlySelectorTokenIndexState__INTERNAL = atom<SelectorTokenIndex>({\n\t\tkey: `👁🗨_selector_token_index__INTERNAL`,\n\t\tdefault: () =>\n\t\t\tObject.assign(\n\t\t\t\t[...store.readonlySelectors].reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\tacc[key] = { key, type: `readonly_selector` }\n\t\t\t\t\treturn acc\n\t\t\t\t}, {}),\n\t\t\t\t[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\tacc[key] = { key, type: `selector` }\n\t\t\t\t\treturn acc\n\t\t\t\t}, {}),\n\t\t\t),\n\t\teffects: [\n\t\t\t({ setSelf }) => {\n\t\t\t\tstore.subject.selectorCreation.subscribe((selectorToken) => {\n\t\t\t\t\tif (store.operation.open) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\tconst { key, family } = selectorToken\n\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t[subKey]: selectorToken,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[key]: selectorToken,\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t},\n\t\t],\n\t})\n\treturn selector({\n\t\tkey: `👁🗨_selector_token_index`,\n\t\tget: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),\n\t})\n}\n","import type { AtomTokenIndex, SelectorTokenIndex } from \"./meta-state\"\nimport { attachMetaAtoms, attachMetaSelectors } from \"./meta-state\"\nimport type { ReadonlySelectorToken } from \"../..\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\n\nexport const attachMetaState = (\n\tstore: Store = IMPLICIT.STORE,\n): {\n\tatomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>\n\tselectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>\n} => {\n\treturn {\n\t\tatomTokenIndexState: attachMetaAtoms(store),\n\t\tselectorTokenIndexState: attachMetaSelectors(store),\n\t}\n}\n","import HAMT from \"hamt_plus\"\nimport type * as Rx from \"rxjs\"\n\nimport type { Store } from \".\"\nimport { target, IMPLICIT } from \".\"\nimport { createReadWriteSelector } from \"./selector/create-read-write-selector\"\nimport { createReadonlySelector } from \"./selector/create-readonly-selector\"\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorOptions,\n\tReadonlySelectorToken,\n\tSelectorOptions,\n\tSelectorToken,\n} from \"..\"\n\nexport type Selector<T> = {\n\tkey: string\n\ttype: `selector`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Rx.Subject<{ newValue: T; oldValue: T }>\n\tget: () => T\n\tset: (newValue: T | ((oldValue: T) => T)) => void\n}\nexport type ReadonlySelector<T> = {\n\tkey: string\n\ttype: `readonly_selector`\n\tfamily?: FamilyMetadata\n\tinstall: (store: Store) => void\n\tsubject: Rx.Subject<{ newValue: T; oldValue: T }>\n\tget: () => T\n}\n\nexport function selector__INTERNAL<T>(\n\toptions: SelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore?: Store,\n): SelectorToken<T>\nexport function selector__INTERNAL<T>(\n\toptions: ReadonlySelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore?: Store,\n): ReadonlySelectorToken<T>\nexport function selector__INTERNAL<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n\tfamily?: FamilyMetadata,\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\tconst core = target(store)\n\n\tif (HAMT.has(options.key, core.selectors)) {\n\t\tstore.config.logger?.error(\n\t\t\t`Key \"${options.key}\" already exists in the store.`,\n\t\t)\n\t}\n\n\tif (!(`set` in options)) {\n\t\treturn createReadonlySelector(options, family, store, core)\n\t}\n\treturn createReadWriteSelector(options, family, store, core)\n}\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport { become } from \"~/packages/anvl/src/function\"\n\nimport {\n\ttype Store,\n\ttype Selector,\n\ttype StoreCore,\n\tregisterSelector,\n\tselector__INTERNAL,\n} from \"..\"\nimport type { FamilyMetadata, SelectorToken } from \"../..\"\nimport type { SelectorOptions } from \"../../selector\"\nimport { cacheValue, markDone } from \"../operation\"\n\nexport const createReadWriteSelector = <T>(\n\toptions: SelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n\tcore: StoreCore,\n): SelectorToken<T> => {\n\tconst subject = new Rx.Subject<{ newValue: T; oldValue: T }>()\n\n\tconst { get, set } = registerSelector(options.key, store)\n\tconst getSelf = () => {\n\t\tconst value = options.get({ get })\n\t\tcacheValue(options.key, value, store)\n\t\treturn value\n\t}\n\n\tconst setSelf = (next: T | ((oldValue: T) => T)): void => {\n\t\tstore.config.logger?.info(` <- \"${options.key}\" became`, next)\n\t\tconst oldValue = getSelf()\n\t\tconst newValue = become(next)(oldValue)\n\t\tcacheValue(options.key, newValue, store)\n\t\tmarkDone(options.key, store)\n\t\tif (store.transactionStatus.phase === `idle`) {\n\t\t\tsubject.next({ newValue, oldValue })\n\t\t}\n\t\toptions.set({ get, set }, newValue)\n\t}\n\tconst mySelector: Selector<T> = {\n\t\t...options,\n\t\tsubject,\n\t\tinstall: (s: Store) => selector__INTERNAL(options, family, s),\n\t\tget: getSelf,\n\t\tset: setSelf,\n\t\ttype: `selector`,\n\t\t...(family && { family }),\n\t}\n\tcore.selectors = HAMT.set(options.key, mySelector, core.selectors)\n\tconst initialValue = getSelf()\n\tstore.config.logger?.info(` ✨ \"${options.key}\" =`, initialValue)\n\tconst token: SelectorToken<T> = {\n\t\tkey: options.key,\n\t\ttype: `selector`,\n\t\tfamily,\n\t}\n\tstore.subject.selectorCreation.next(token)\n\treturn token\n}\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport { registerSelector } from \"./register-selector\"\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorOptions,\n\tReadonlySelectorToken,\n\tStore,\n} from \"../..\"\nimport { cacheValue } from \"../operation\"\nimport { selector__INTERNAL, type ReadonlySelector } from \"../selector-internal\"\nimport type { StoreCore } from \"../store\"\n\nexport const createReadonlySelector = <T>(\n\toptions: ReadonlySelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n\tstore: Store,\n\tcore: StoreCore,\n): ReadonlySelectorToken<T> => {\n\tconst subject = new Rx.Subject<{ newValue: T; oldValue: T }>()\n\n\tconst { get } = registerSelector(options.key, store)\n\tconst getSelf = () => {\n\t\tconst value = options.get({ get })\n\t\tcacheValue(options.key, value, store)\n\t\treturn value\n\t}\n\n\tconst readonlySelector: ReadonlySelector<T> = {\n\t\t...options,\n\t\tsubject,\n\t\tinstall: (s: Store) => selector__INTERNAL(options, family, s),\n\t\tget: getSelf,\n\t\ttype: `readonly_selector`,\n\t\t...(family && { family }),\n\t}\n\tcore.readonlySelectors = HAMT.set(\n\t\toptions.key,\n\t\treadonlySelector,\n\t\tcore.readonlySelectors,\n\t)\n\tconst initialValue = getSelf()\n\tstore.config.logger?.info(` ✨ \"${options.key}\" =`, initialValue)\n\tconst token: ReadonlySelectorToken<T> = {\n\t\tkey: options.key,\n\t\ttype: `readonly_selector`,\n\t\tfamily,\n\t}\n\tstore.subject.selectorCreation.next(token)\n\treturn token\n}\n","import type { Store } from \"..\"\nimport { target, lookup } from \"..\"\nimport type { AtomToken, ReadonlySelectorToken, SelectorToken } from \"../..\"\n\nexport const lookupSelectorSources = (\n\tkey: string,\n\tstore: Store,\n): (\n\t| AtomToken<unknown>\n\t| ReadonlySelectorToken<unknown>\n\t| SelectorToken<unknown>\n)[] =>\n\ttarget(store)\n\t\t.selectorGraph.getRelations(key)\n\t\t.filter(({ source }) => source !== key)\n\t\t.map(({ source }) => lookup(source, store))\n","import { lookupSelectorSources } from \"./lookup-selector-sources\"\nimport type { Store, AtomToken, ReadonlySelectorToken, StateToken } from \"../..\"\n\nexport const traceSelectorAtoms = (\n\tselectorKey: string,\n\tdependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store,\n): AtomToken<unknown>[] => {\n\tconst roots: AtomToken<unknown>[] = []\n\n\tconst sources = lookupSelectorSources(dependency.key, store)\n\tlet depth = 0\n\twhile (sources.length > 0) {\n\t\t// rome-ignore lint/style/noNonNullAssertion: just checked length ^^^\n\t\tconst source = sources.shift()!\n\t\t++depth\n\t\tif (depth > 999) {\n\t\t\tthrow new Error(\n\t\t\t\t`Maximum selector dependency depth exceeded in selector \"${selectorKey}\".`,\n\t\t\t)\n\t\t}\n\n\t\tif (source.type !== `atom`) {\n\t\t\tsources.push(...lookupSelectorSources(source.key, store))\n\t\t} else {\n\t\t\troots.push(source)\n\t\t}\n\t}\n\n\treturn roots\n}\n\nexport const traceAllSelectorAtoms = (\n\tselectorKey: string,\n\tstore: Store,\n): AtomToken<unknown>[] => {\n\tconst sources = lookupSelectorSources(selectorKey, store)\n\treturn sources.flatMap((source) =>\n\t\tsource.type === `atom`\n\t\t\t? source\n\t\t\t: traceSelectorAtoms(selectorKey, source, store),\n\t)\n}\n","import { traceSelectorAtoms } from \"./trace-selector-atoms\"\nimport type { Store } from \"..\"\nimport { target } from \"..\"\nimport type { ReadonlySelectorToken, StateToken } from \"../..\"\n\nexport const updateSelectorAtoms = (\n\tselectorKey: string,\n\tdependency: ReadonlySelectorToken<unknown> | StateToken<unknown>,\n\tstore: Store,\n): void => {\n\tconst core = target(store)\n\tif (dependency.type === `atom`) {\n\t\tcore.selectorAtoms = core.selectorAtoms.set({\n\t\t\tselectorKey,\n\t\t\tatomKey: dependency.key,\n\t\t})\n\t\tstore.config.logger?.info(\n\t\t\t` || adding root for \"${selectorKey}\": ${dependency.key}`,\n\t\t)\n\t\treturn\n\t}\n\tconst roots = traceSelectorAtoms(selectorKey, dependency, store)\n\tstore.config.logger?.info(\n\t\t` || adding roots for \"${selectorKey}\":`,\n\t\troots.map((r) => r.key),\n\t)\n\tfor (const root of roots) {\n\t\tcore.selectorAtoms = core.selectorAtoms.set({\n\t\t\tselectorKey,\n\t\t\tatomKey: root.key,\n\t\t})\n\t}\n}\n","import HAMT from \"hamt_plus\"\n\nimport { become } from \"~/packages/anvl/src/function\"\n\nimport type { Atom, Selector, Store } from \".\"\nimport {\n\tIMPLICIT,\n\tcacheValue,\n\temitUpdate,\n\tevictCachedValue,\n\tgetState__INTERNAL,\n\tisAtomDefault,\n\tisDone,\n\tmarkAtomAsNotDefault,\n\tmarkDone,\n\tstowUpdate,\n\ttarget,\n} from \".\"\n\nexport const evictDownStream = <T>(\n\tstate: Atom<T>,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst core = target(store)\n\tconst downstream = core.selectorAtoms.getRelations(state.key)\n\tconst downstreamKeys = downstream.map(({ id }) => id)\n\tstore.config.logger?.info(\n\t\t` || ${downstreamKeys.length} downstream:`,\n\t\tdownstreamKeys,\n\t)\n\tif (core.operation.open) {\n\t\tstore.config.logger?.info(` ||`, [...core.operation.done], `already done`)\n\t}\n\tdownstream.forEach(({ id: stateKey }) => {\n\t\tif (isDone(stateKey, store)) {\n\t\t\tstore.config.logger?.info(` || ${stateKey} already done`)\n\t\t\treturn\n\t\t}\n\t\tconst state =\n\t\t\tHAMT.get(stateKey, core.selectors) ??\n\t\t\tHAMT.get(stateKey, core.readonlySelectors)\n\t\tif (!state) {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t` || ${stateKey} is an atom, and can't be downstream`,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tevictCachedValue(stateKey, store)\n\t\tstore.config.logger?.info(` xx evicted \"${stateKey}\"`)\n\n\t\tmarkDone(stateKey, store)\n\t})\n}\n\nexport const setAtomState = <T>(\n\tatom: Atom<T>,\n\tnext: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst oldValue = getState__INTERNAL(atom, store)\n\tconst newValue = become(next)(oldValue)\n\tstore.config.logger?.info(`<< setting atom \"${atom.key}\" to`, newValue)\n\tcacheValue(atom.key, newValue, store)\n\tif (isAtomDefault(atom.key, store)) {\n\t\tmarkAtomAsNotDefault(atom.key, store)\n\t}\n\tmarkDone(atom.key, store)\n\tstore.config.logger?.info(\n\t\t` || evicting caches downstream from \"${atom.key}\"`,\n\t)\n\tevictDownStream(atom, store)\n\tconst update = { oldValue, newValue }\n\tif (store.transactionStatus.phase !== `building`) {\n\t\temitUpdate(atom, update, store)\n\t} else {\n\t\tstowUpdate(atom, update, store)\n\t}\n}\nexport const setSelectorState = <T>(\n\tselector: Selector<T>,\n\tnext: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst oldValue = getState__INTERNAL(selector, store)\n\tconst newValue = become(next)(oldValue)\n\n\tstore.config.logger?.info(`<< setting selector \"${selector.key}\" to`, newValue)\n\tstore.config.logger?.info(` || propagating change made to \"${selector.key}\"`)\n\n\tselector.set(newValue)\n}\nexport const setState__INTERNAL = <T>(\n\tstate: Atom<T> | Selector<T>,\n\tvalue: T | ((oldValue: T) => T),\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tif (`set` in state) {\n\t\tsetSelectorState(state, value, store)\n\t} else {\n\t\tsetAtomState(state, value, store)\n\t}\n}\n","import { updateSelectorAtoms } from \"./update-selector-atoms\"\nimport type { Transactors } from \"../../transaction\"\nimport { getState__INTERNAL, withdraw } from \"../get\"\nimport { setState__INTERNAL } from \"../set\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\nimport { target } from \"../transaction-internal\"\n\nexport const registerSelector = (\n\tselectorKey: string,\n\tstore: Store = IMPLICIT.STORE,\n): Transactors => ({\n\tget: (dependency) => {\n\t\tconst core = target(store)\n\t\tconst alreadyRegistered = core.selectorGraph\n\t\t\t.getRelations(selectorKey)\n\t\t\t.some(({ source }) => source === dependency.key)\n\n\t\tconst dependencyState = withdraw(dependency, store)\n\t\tif (dependencyState === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${dependency.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t\t)\n\t\t}\n\t\tconst dependencyValue = getState__INTERNAL(dependencyState, store)\n\n\t\tif (alreadyRegistered) {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t` || ${selectorKey} <- ${dependency.key} =`,\n\t\t\t\tdependencyValue,\n\t\t\t)\n\t\t} else {\n\t\t\tstore.config.logger?.info(\n\t\t\t\t`🔌 registerSelector \"${selectorKey}\" <- ( \"${dependency.key}\" =`,\n\t\t\t\tdependencyValue,\n\t\t\t\t`)`,\n\t\t\t)\n\t\t\tcore.selectorGraph = core.selectorGraph.set(\n\t\t\t\t{ from: dependency.key, to: selectorKey },\n\t\t\t\t{\n\t\t\t\t\tsource: dependency.key,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tupdateSelectorAtoms(selectorKey, dependency, store)\n\t\treturn dependencyValue\n\t},\n\tset: (stateToken, newValue) => {\n\t\tconst state = withdraw(stateToken, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${stateToken.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t\t)\n\t\t}\n\t\tsetState__INTERNAL(state, newValue, store)\n\t},\n})\n","import type { Atom, ReadonlySelector, Selector, Store } from \".\"\nimport {\n\tgetState__INTERNAL,\n\twithdraw,\n\trecallState,\n\ttraceAllSelectorAtoms,\n} from \".\"\nimport type { StateUpdate } from \"..\"\n\nexport const prepareUpdate = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): StateUpdate<T> => {\n\tconst oldValue = recallState(state, store)\n\tconst newValue = getState__INTERNAL(state, store)\n\treturn { newValue, oldValue }\n}\n\nexport const stowUpdate = <T>(\n\tstate: Atom<T>,\n\tupdate: StateUpdate<T>,\n\tstore: Store,\n): void => {\n\tconst { key } = state\n\tconst { logger } = store.config\n\tif (store.transactionStatus.phase !== `building`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`stowUpdate called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.transactionStatus.atomUpdates.push({ key, ...update })\n\tlogger?.info(`📝 ${key} stowed (`, update.oldValue, `->`, update.newValue, `)`)\n}\n\nexport const emitUpdate = <T>(\n\tstate: Atom<T> | ReadonlySelector<T> | Selector<T>,\n\tupdate: StateUpdate<T>,\n\tstore: Store,\n): void => {\n\tconst { key } = state\n\tconst { logger } = store.config\n\tlogger?.info(\n\t\t`📢 ${state.type} \"${key}\" went (`,\n\t\tupdate.oldValue,\n\t\t`->`,\n\t\tupdate.newValue,\n\t\t`)`,\n\t)\n\tstate.subject.next(update)\n}\n\nexport const subscribeToRootAtoms = <T>(\n\tstate: ReadonlySelector<T> | Selector<T>,\n\tstore: Store,\n): { unsubscribe: () => void }[] | null => {\n\tconst dependencySubscriptions =\n\t\t`default` in state\n\t\t\t? null\n\t\t\t: traceAllSelectorAtoms(state.key, store).map((atomToken) => {\n\t\t\t\t\tconst atom = withdraw(atomToken, store)\n\t\t\t\t\tif (atom === null) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Atom \"${atomToken.key}\", a dependency of selector \"${state.key}\", not found in store \"${store.config.name}\".`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn atom.subject.subscribe((atomChange) => {\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t`📢 selector \"${state.key}\" saw root \"${atomToken.key}\" go (`,\n\t\t\t\t\t\t\tatomChange.oldValue,\n\t\t\t\t\t\t\t`->`,\n\t\t\t\t\t\t\tatomChange.newValue,\n\t\t\t\t\t\t\t`)`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tconst oldValue = recallState(state, store)\n\t\t\t\t\t\tconst newValue = getState__INTERNAL(state, store)\n\t\t\t\t\t\tstore.config.logger?.info(` <- ${state.key} became`, newValue)\n\t\t\t\t\t\tstate.subject.next({ newValue, oldValue })\n\t\t\t\t\t})\n\t\t\t })\n\treturn dependencySubscriptions\n}\n","import type { Store } from \".\"\nimport { IMPLICIT } from \".\"\nimport type { TimelineToken } from \"..\"\nimport { setState } from \"..\"\n\nexport const redo__INTERNAL = (\n\ttoken: TimelineToken,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tstore.config.logger?.info(`⏩ redo \"${token.key}\"`)\n\tconst timelineData = store.timelines.get(token.key)\n\tif (!timelineData) {\n\t\tstore.config.logger?.error(\n\t\t\t`Failed to redo on timeline \"${token.key}\". This timeline has not been initialized.`,\n\t\t)\n\t\treturn\n\t}\n\tif (timelineData.at === timelineData.history.length) {\n\t\tstore.config.logger?.warn(\n\t\t\t`Failed to redo at the end of timeline \"${token.key}\". There is nothing to redo.`,\n\t\t)\n\t\treturn\n\t}\n\ttimelineData.timeTraveling = true\n\tconst update = timelineData.history[timelineData.at]\n\tswitch (update.type) {\n\t\tcase `atom_update`: {\n\t\t\tconst { key, newValue } = update\n\t\t\tsetState({ key, type: `atom` }, newValue, store)\n\t\t\tbreak\n\t\t}\n\t\tcase `selector_update`:\n\t\tcase `transaction_update`: {\n\t\t\tfor (const atomUpdate of update.atomUpdates) {\n\t\t\t\tconst { key, newValue } = atomUpdate\n\t\t\t\tsetState({ key, type: `atom` }, newValue, store)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\t++timelineData.at\n\ttimelineData.timeTraveling = false\n\tstore.config.logger?.info(\n\t\t`⏹️ \"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`,\n\t)\n}\n\nexport const undo__INTERNAL = (\n\ttoken: TimelineToken,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tstore.config.logger?.info(`⏪ undo \"${token.key}\"`)\n\tconst timelineData = store.timelines.get(token.key)\n\tif (!timelineData) {\n\t\tstore.config.logger?.error(\n\t\t\t`Failed to undo on timeline \"${token.key}\". This timeline has not been initialized.`,\n\t\t)\n\t\treturn\n\t}\n\tif (timelineData.at === 0) {\n\t\tstore.config.logger?.warn(\n\t\t\t`Failed to undo at the beginning of timeline \"${token.key}\". There is nothing to undo.`,\n\t\t)\n\t\treturn\n\t}\n\ttimelineData.timeTraveling = true\n\n\t--timelineData.at\n\tconst update = timelineData.history[timelineData.at]\n\tswitch (update.type) {\n\t\tcase `atom_update`: {\n\t\t\tconst { key, oldValue } = update\n\t\t\tsetState({ key, type: `atom` }, oldValue, store)\n\t\t\tbreak\n\t\t}\n\t\tcase `selector_update`:\n\t\tcase `transaction_update`: {\n\t\t\tfor (const atomUpdate of update.atomUpdates) {\n\t\t\t\tconst { key, oldValue } = atomUpdate\n\t\t\t\tsetState({ key, type: `atom` }, oldValue, store)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\ttimelineData.timeTraveling = false\n\tstore.config.logger?.info(\n\t\t`⏹️ \"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`,\n\t)\n}\n","import HAMT from \"hamt_plus\"\nimport * as Rx from \"rxjs\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \".\"\nimport { target, IMPLICIT } from \".\"\nimport { addAtomToTimeline } from \"./timeline/add-atom-to-timeline\"\nimport type {\n\tStateUpdate,\n\tTimelineOptions,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionUpdate,\n} from \"..\"\n\nexport type TimelineAtomUpdate = StateUpdate<unknown> & {\n\tkey: string\n\ttype: `atom_update`\n\ttimestamp: number\n}\nexport type TimelineSelectorUpdate = {\n\tkey: string\n\ttype: `selector_update`\n\ttimestamp: number\n\tatomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[]\n}\nexport type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {\n\tkey: string\n\ttype: `transaction_update`\n\ttimestamp: number\n}\n\nexport type Timeline = {\n\tkey: string\n\tat: number\n\ttimeTraveling: boolean\n\thistory: TimelineUpdate[]\n\tselectorTime: number | null\n\ttransactionKey: string | null\n\tinstall: (store: Store) => void\n\tsubject: Rx.Subject<\n\t\tTimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate\n\t>\n}\n\nexport function timeline__INTERNAL(\n\toptions: TimelineOptions,\n\tstore: Store = IMPLICIT.STORE,\n\tdata: Timeline | null = null,\n): TimelineToken {\n\tconst tl: Timeline = {\n\t\tkey: options.key,\n\t\tat: 0,\n\t\ttimeTraveling: false,\n\t\tselectorTime: null,\n\t\ttransactionKey: null,\n\t\t...data,\n\t\thistory: data?.history.map((update) => ({ ...update })) ?? [],\n\t\tinstall: (store) => timeline__INTERNAL(options, store, tl),\n\t\tsubject: new Rx.Subject(),\n\t}\n\n\tconst core = target(store)\n\tfor (const tokenOrFamily of options.atoms) {\n\t\tconst timelineKey = core.timelineAtoms.getRelatedId(tokenOrFamily.key)\n\t\tif (timelineKey) {\n\t\t\tstore.config.logger?.error(\n\t\t\t\t`❌ Failed to add atom \"${tokenOrFamily.key}\" to timeline \"${options.key}\" because it belongs to timeline \"${timelineKey}\"`,\n\t\t\t)\n\t\t\tcontinue\n\t\t}\n\t\tif (tokenOrFamily.type === `atom_family`) {\n\t\t\tconst family = tokenOrFamily\n\t\t\tfamily.subject.subscribe((token) =>\n\t\t\t\taddAtomToTimeline(token, options.atoms, tl, store),\n\t\t\t)\n\t\t} else {\n\t\t\tconst token = tokenOrFamily\n\t\t\tif (`family` in token && token.family) {\n\t\t\t\tconst familyTimelineKey = core.timelineAtoms.getRelatedId(\n\t\t\t\t\ttoken.family.key,\n\t\t\t\t)\n\t\t\t\tif (familyTimelineKey) {\n\t\t\t\t\tstore.config.logger?.error(\n\t\t\t\t\t\t`❌ Failed to add atom \"${token.key}\" to timeline \"${options.key}\" because its family \"${token.family.key}\" belongs to timeline \"${familyTimelineKey}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\taddAtomToTimeline(token, options.atoms, tl, store)\n\t\t}\n\t\tcore.timelineAtoms = core.timelineAtoms.set({\n\t\t\tatomKey: tokenOrFamily.key,\n\t\t\ttimelineKey: options.key,\n\t\t})\n\t}\n\n\tstore.timelines = HAMT.set(options.key, tl, store.timelines)\n\tconst token: TimelineToken = {\n\t\tkey: options.key,\n\t\ttype: `timeline`,\n\t}\n\tstore.subject.timelineCreation.next(token)\n\treturn token\n}\n","import { IMPLICIT, withdraw } from \"..\"\nimport type {\n\tTimelineSelectorUpdate,\n\tTimeline,\n\tStore,\n\tTimelineTransactionUpdate,\n\tTimelineAtomUpdate,\n} from \"..\"\nimport type { AtomFamily, AtomToken, TimelineUpdate } from \"../..\"\n\nexport const addAtomToTimeline = (\n\tatomToken: AtomToken<any>,\n\tatoms: (AtomFamily<any> | AtomToken<any>)[],\n\ttl: Timeline,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst atom = withdraw(atomToken, store)\n\tif (atom === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to atom \"${atomToken.key}\" because it has not been initialized in store \"${store.config.name}\"`,\n\t\t)\n\t}\n\tatom.subject.subscribe((update) => {\n\t\tconst currentSelectorKey =\n\t\t\tstore.operation.open && store.operation.token.type === `selector`\n\t\t\t\t? store.operation.token.key\n\t\t\t\t: null\n\t\tconst currentSelectorTime =\n\t\t\tstore.operation.open && store.operation.token.type === `selector`\n\t\t\t\t? store.operation.time\n\t\t\t\t: null\n\t\tconst currentTransactionKey =\n\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t\t? store.transactionStatus.key\n\t\t\t\t: null\n\t\tconst currentTransactionTime =\n\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t\t? store.transactionStatus.time\n\t\t\t\t: null\n\n\t\tstore.config.logger?.info(\n\t\t\t`⏳ timeline \"${tl.key}\" saw atom \"${atomToken.key}\" go (`,\n\t\t\tupdate.oldValue,\n\t\t\t`->`,\n\t\t\tupdate.newValue,\n\t\t\tcurrentTransactionKey\n\t\t\t\t? `) in transaction \"${currentTransactionKey}\"`\n\t\t\t\t: currentSelectorKey\n\t\t\t\t? `) in selector \"${currentSelectorKey}\"`\n\t\t\t\t: `)`,\n\t\t)\n\n\t\tif (tl.timeTraveling === false) {\n\t\t\tif (tl.selectorTime && tl.selectorTime !== currentSelectorTime) {\n\t\t\t\tconst mostRecentUpdate: TimelineUpdate | undefined = tl.history.at(-1)\n\t\t\t\tif (mostRecentUpdate === undefined) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Timeline \"${tl.key}\" has a selectorTime, but no history. This is most likely a bug in AtomIO.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (mostRecentUpdate.type === `selector_update`) {\n\t\t\t\t\ttl.subject.next(mostRecentUpdate)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tcurrentTransactionKey &&\n\t\t\t\tstore.transactionStatus.phase === `applying`\n\t\t\t) {\n\t\t\t\tconst currentTransaction = withdraw(\n\t\t\t\t\t{ key: currentTransactionKey, type: `transaction` },\n\t\t\t\t\tstore,\n\t\t\t\t)\n\t\t\t\tif (currentTransaction === null) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Transaction \"${currentTransactionKey}\" not found in store \"${store.config.name}\". This is surprising, because we are in the application phase of \"${currentTransactionKey}\".`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (tl.transactionKey !== currentTransactionKey) {\n\t\t\t\t\tif (tl.transactionKey) {\n\t\t\t\t\t\tstore.config.logger?.error(\n\t\t\t\t\t\t\t`Timeline \"${tl.key}\" was unable to resolve transaction \"${tl.transactionKey}. This is probably a bug.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\ttl.transactionKey = currentTransactionKey\n\t\t\t\t\tconst subscription = currentTransaction.subject.subscribe((update) => {\n\t\t\t\t\t\tif (tl.timeTraveling === false && currentTransactionTime) {\n\t\t\t\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timelineTransactionUpdate: TimelineTransactionUpdate = {\n\t\t\t\t\t\t\t\ttype: `transaction_update`,\n\t\t\t\t\t\t\t\ttimestamp: currentTransactionTime,\n\t\t\t\t\t\t\t\t...update,\n\t\t\t\t\t\t\t\tatomUpdates: update.atomUpdates.filter((atomUpdate) =>\n\t\t\t\t\t\t\t\t\tatoms.some((atom) => atom.key === atomUpdate.key),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttl.history.push(timelineTransactionUpdate)\n\t\t\t\t\t\t\ttl.subject.next(timelineTransactionUpdate)\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttl.at = tl.history.length\n\t\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t\t\t\ttl.transactionKey = null\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t`⌛ timeline \"${tl.key}\" got a transaction_update \"${update.key}\"`,\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else if (currentSelectorKey && currentSelectorTime) {\n\t\t\t\tif (currentSelectorTime !== tl.selectorTime) {\n\t\t\t\t\tconst newSelectorUpdate: TimelineSelectorUpdate = {\n\t\t\t\t\t\ttype: `selector_update`,\n\t\t\t\t\t\ttimestamp: currentSelectorTime,\n\t\t\t\t\t\tkey: currentSelectorKey,\n\t\t\t\t\t\tatomUpdates: [],\n\t\t\t\t\t}\n\t\t\t\t\tnewSelectorUpdate.atomUpdates.push({\n\t\t\t\t\t\tkey: atom.key,\n\t\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\t\t...update,\n\t\t\t\t\t})\n\t\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t\t}\n\t\t\t\t\ttl.history.push(newSelectorUpdate)\n\n\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t`⌛ timeline \"${tl.key}\" got a selector_update \"${currentSelectorKey}\" with`,\n\t\t\t\t\t\tnewSelectorUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key),\n\t\t\t\t\t)\n\t\t\t\t\ttl.at = tl.history.length\n\t\t\t\t\ttl.selectorTime = currentSelectorTime\n\t\t\t\t} else {\n\t\t\t\t\tconst latestUpdate = tl.history.at(-1)\n\t\t\t\t\tif (latestUpdate?.type === `selector_update`) {\n\t\t\t\t\t\tlatestUpdate.atomUpdates.push({\n\t\t\t\t\t\t\tkey: atom.key,\n\t\t\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\t\t\t...update,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t\t` ⌛ timeline \"${tl.key}\" set selector_update \"${currentSelectorKey}\" to`,\n\t\t\t\t\t\t\tlatestUpdate?.atomUpdates.map((atomUpdate) => atomUpdate.key),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst timestamp = Date.now()\n\t\t\t\ttl.selectorTime = null\n\t\t\t\tif (tl.at !== tl.history.length) {\n\t\t\t\t\ttl.history.splice(tl.at)\n\t\t\t\t}\n\t\t\t\tconst atomUpdate: TimelineAtomUpdate = {\n\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\ttimestamp,\n\t\t\t\t\tkey: atom.key,\n\t\t\t\t\toldValue: update.oldValue,\n\t\t\t\t\tnewValue: update.newValue,\n\t\t\t\t}\n\t\t\t\ttl.history.push(atomUpdate)\n\t\t\t\ttl.subject.next(atomUpdate)\n\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t`⌛ timeline \"${tl.key}\" got a state_update to \"${atom.key}\"`,\n\t\t\t\t)\n\t\t\t\ttl.at = tl.history.length\n\t\t\t}\n\t\t}\n\t})\n}\n","import type { Store } from \"..\"\n\nexport const abortTransaction = (store: Store): void => {\n\tif (store.transactionStatus.phase === `idle`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`abortTransaction called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.transactionStatus = { phase: `idle` }\n\tstore.config.logger?.info(`🪂`, `transaction fail`)\n}\n","import HAMT from \"hamt_plus\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const applyTransaction = <ƒ extends ƒn>(\n\toutput: ReturnType<ƒ>,\n\tstore: Store,\n): void => {\n\tif (store.transactionStatus.phase !== `building`) {\n\t\tstore.config.logger?.warn(\n\t\t\t`abortTransaction called outside of a transaction. This is probably a bug.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.config.logger?.info(\n\t\t`🛃 apply transaction \"${store.transactionStatus.key}\"`,\n\t)\n\tstore.transactionStatus.phase = `applying`\n\tstore.transactionStatus.output = output\n\tconst { atomUpdates } = store.transactionStatus\n\n\tfor (const { key, newValue } of atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tif (!HAMT.has(token.key, store.valueMap)) {\n\t\t\tconst newAtom = HAMT.get(token.key, store.transactionStatus.core.atoms)\n\t\t\tstore.atoms = HAMT.set(newAtom.key, newAtom, store.atoms)\n\t\t\tstore.valueMap = HAMT.set(newAtom.key, newAtom.default, store.valueMap)\n\t\t\tstore.config.logger?.info(`🔧`, `add atom \"${newAtom.key}\"`)\n\t\t}\n\t\tsetState(token, newValue, store)\n\t}\n\tconst myTransaction = withdraw<ƒ>(\n\t\t{ key: store.transactionStatus.key, type: `transaction` },\n\t\tstore,\n\t)\n\tif (myTransaction === null) {\n\t\tthrow new Error(\n\t\t\t`Transaction \"${store.transactionStatus.key}\" not found. Absurd. How is this running?`,\n\t\t)\n\t}\n\tmyTransaction.subject.next({\n\t\tkey: store.transactionStatus.key,\n\t\tatomUpdates,\n\t\toutput,\n\t\tparams: store.transactionStatus.params as Parameters<ƒ>,\n\t})\n\tstore.transactionStatus = { phase: `idle` }\n\tstore.config.logger?.info(`🛬`, `transaction done`)\n}\n","import type { Store } from \"..\"\n\nexport const buildTransaction = (\n\tkey: string,\n\tparams: any[],\n\tstore: Store,\n): void => {\n\tstore.transactionStatus = {\n\t\tkey,\n\t\tphase: `building`,\n\t\ttime: Date.now(),\n\t\tcore: {\n\t\t\tatoms: store.atoms,\n\t\t\tatomsThatAreDefault: store.atomsThatAreDefault,\n\t\t\toperation: { open: false },\n\t\t\treadonlySelectors: store.readonlySelectors,\n\t\t\ttimelines: store.timelines,\n\t\t\ttimelineAtoms: store.timelineAtoms,\n\t\t\ttransactions: store.transactions,\n\t\t\tselectorAtoms: store.selectorAtoms,\n\t\t\tselectorGraph: store.selectorGraph,\n\t\t\tselectors: store.selectors,\n\t\t\tvalueMap: store.valueMap,\n\t\t},\n\t\tatomUpdates: [],\n\t\tparams,\n\t\toutput: undefined,\n\t}\n\tstore.config.logger?.info(\n\t\t`🛫`,\n\t\t`transaction \"${key}\" started in store \"${store.config.name}\"`,\n\t)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken, TransactionUpdate } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const redoTransactionUpdate = <ƒ extends ƒn>(\n\tupdate: TransactionUpdate<ƒ>,\n\tstore: Store,\n): void => {\n\tstore.config.logger?.info(` ⏭ redo transaction \"${update.key}\" (redo)`)\n\tfor (const { key, newValue } of update.atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tconst state = withdraw(token, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${token.key}\" not found in this store. This is surprising, because we are navigating the history of the store.`,\n\t\t\t)\n\t\t}\n\t\tsetState(state, newValue, store)\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"..\"\nimport { withdraw } from \"..\"\nimport type { AtomToken, TransactionUpdate } from \"../..\"\nimport { setState } from \"../..\"\n\nexport const undoTransactionUpdate = <ƒ extends ƒn>(\n\tupdate: TransactionUpdate<ƒ>,\n\tstore: Store,\n): void => {\n\tstore.config.logger?.info(` ⏮ undo transaction \"${update.key}\" (undo)`)\n\tfor (const { key, oldValue } of update.atomUpdates) {\n\t\tconst token: AtomToken<unknown> = { key, type: `atom` }\n\t\tconst state = withdraw(token, store)\n\t\tif (state === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`State \"${token.key}\" not found in this store. This is surprising, because we are navigating the history of the store.`,\n\t\t\t)\n\t\t}\n\t\tsetState(state, oldValue, store)\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { StoreCore } from \"..\"\nimport type { StateUpdate, TransactionUpdate } from \"../..\"\n\nexport * from \"./abort-transaction\"\nexport * from \"./apply-transaction\"\nexport * from \"./build-transaction\"\nexport * from \"./redo-transaction\"\nexport * from \"./undo-transaction\"\n\nexport const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const\nexport type TransactionPhase = typeof TRANSACTION_PHASES[number]\n\nexport type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {\n\tphase: `applying` | `building`\n\ttime: number\n\tcore: StoreCore\n}\nexport type TransactionIdle = {\n\tphase: `idle`\n}\nexport type TransactionStatus<ƒ extends ƒn> =\n\t| TransactionIdle\n\t| TransactionUpdateInProgress<ƒ>\n","import type * as Rx from \"rxjs\"\n\nimport type { Serializable } from \"~/packages/anvl/src/json\"\n\nimport type { AtomToken } from \".\"\nimport { atomFamily__INTERNAL, atom__INTERNAL } from \"./internal\"\n\nexport type Effectors<T> = {\n\tsetSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n\tonSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => void\n\nexport type AtomOptions<T> = {\n\tkey: string\n\tdefault: T | (() => T)\n\teffects?: AtomEffect<T>[]\n}\n\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T> {\n\treturn atom__INTERNAL<T>(options)\n}\n\nexport type AtomFamilyOptions<T, K extends Serializable> = {\n\tkey: string\n\tdefault: T | ((key: K) => T)\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Serializable = Serializable> = ((\n\tkey: K,\n) => AtomToken<T>) & {\n\tkey: string\n\ttype: `atom_family`\n\tsubject: Rx.Subject<AtomToken<T>>\n}\n\nexport function atomFamily<T, K extends Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n): AtomFamily<T, K> {\n\treturn atomFamily__INTERNAL<T, K>(options)\n}\n","import { doNothing } from \"~/packages/anvl/src/function\"\n\nimport type { Store } from \"./internal/store\"\nimport { IMPLICIT } from \"./internal/store\"\n\nexport type Logger = Pick<Console, `error` | `info` | `warn`>\nexport const LOG_LEVELS: ReadonlyArray<keyof Logger> = [\n\t`info`,\n\t`warn`,\n\t`error`,\n] as const\n\nexport const setLogLevel = (\n\tpreferredLevel: `error` | `info` | `warn` | null,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst { logger__INTERNAL } = store.config\n\tif (preferredLevel === null) {\n\t\tstore.config.logger = null\n\t} else {\n\t\tstore.config.logger = { ...console }\n\t\tLOG_LEVELS.forEach((logLevel) => {\n\t\t\tif (LOG_LEVELS.indexOf(logLevel) < LOG_LEVELS.indexOf(preferredLevel)) {\n\t\t\t\t// rome-ignore lint/style/noNonNullAssertion: we just set it\n\t\t\t\tstore.config.logger![logLevel] = doNothing\n\t\t\t} else {\n\t\t\t\t// rome-ignore lint/style/noNonNullAssertion: we just set it\n\t\t\t\tstore.config.logger![logLevel] = logger__INTERNAL[logLevel]\n\t\t\t}\n\t\t})\n\t}\n}\n\nexport const useLogger = (\n\tlogger: Logger,\n\tstore: Store = IMPLICIT.STORE,\n): void => {\n\tconst currentLogLevel =\n\t\tstore.config.logger === null\n\t\t\t? null\n\t\t\t: LOG_LEVELS.find(\n\t\t\t\t\t(logLevel) => store.config.logger?.[logLevel] !== doNothing,\n\t\t\t ) ?? null\n\tstore.config.logger__INTERNAL = { ...logger }\n\tsetLogLevel(currentLogLevel, store)\n}\n","import type * as Rx from \"rxjs\"\n\nimport type { Serializable } from \"~/packages/anvl/src/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport { selectorFamily__INTERNAL, selector__INTERNAL } from \"./internal\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n\tset: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\treturn selector__INTERNAL(options)\n}\n\nexport type SelectorFamilyOptions<T, K extends Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<T, K extends Serializable = Serializable> = ((\n\tkey: K,\n) => SelectorToken<T>) & {\n\tkey: string\n\ttype: `selector_family`\n\tsubject: Rx.Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((\n\tkey: K,\n) => ReadonlySelectorToken<T>) & {\n\tkey: string\n\ttype: `readonly_selector_family`\n\tsubject: Rx.Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\treturn selectorFamily__INTERNAL(options)\n}\n","import type { redo, timeline, undo } from \".\"\nimport { getState, setState, subscribe } from \".\"\nimport type { atom, atomFamily } from \"./atom\"\nimport type { Store } from \"./internal\"\nimport {\n\tatomFamily__INTERNAL,\n\tatom__INTERNAL,\n\tcreateStore,\n\tredo__INTERNAL,\n\tselectorFamily__INTERNAL,\n\tselector__INTERNAL,\n\ttimeline__INTERNAL,\n\ttransaction__INTERNAL,\n\tundo__INTERNAL,\n} from \"./internal\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { transaction } from \"./transaction\"\n\nexport type Silo = ReturnType<typeof silo>\n\nexport const silo = (\n\tname: string,\n\tfromStore: Store | null = null,\n): {\n\tstore: Store\n\tatom: typeof atom\n\tatomFamily: typeof atomFamily\n\tselector: typeof selector\n\tselectorFamily: typeof selectorFamily\n\ttransaction: typeof transaction\n\ttimeline: typeof timeline\n\tgetState: typeof getState\n\tsetState: typeof setState\n\tsubscribe: typeof subscribe\n\tundo: typeof undo\n\tredo: typeof redo\n} => {\n\tconst store = createStore(name, fromStore)\n\treturn {\n\t\tstore,\n\t\tatom: (options) => atom__INTERNAL(options, undefined, store),\n\t\tatomFamily: (options) => atomFamily__INTERNAL(options, store),\n\t\tselector: (options) => selector__INTERNAL(options, undefined, store) as any,\n\t\tselectorFamily: (options) => selectorFamily__INTERNAL(options, store) as any,\n\t\ttransaction: (options) => transaction__INTERNAL(options, store),\n\t\ttimeline: (options) => timeline__INTERNAL(options, store),\n\t\tgetState: (token) => getState(token, store),\n\t\tsetState: (token, newValue) => setState(token, newValue, store),\n\t\tsubscribe: (token, handler) => subscribe(token, handler, store),\n\t\tundo: (token) => undo__INTERNAL(token, store),\n\t\tredo: (token) => redo__INTERNAL(token, store),\n\t}\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type {\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionToken,\n\tTransactionUpdate,\n} from \".\"\nimport type { Store } from \"./internal\"\nimport { IMPLICIT, subscribeToRootAtoms, withdraw } from \"./internal\"\n\nexport type StateUpdate<T> = { newValue: T; oldValue: T }\nexport type KeyedStateUpdate<T> = StateUpdate<T> & { key: string }\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\n\nexport const subscribe = <T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tstore: Store = IMPLICIT.STORE,\n): (() => void) => {\n\tconst state = withdraw<T>(token, store)\n\tif (state === null) {\n\t\tthrow new Error(\n\t\t\t`State \"${token.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t)\n\t}\n\tconst subscription = state.subject.subscribe(handleUpdate)\n\tstore.config.logger?.info(`👀 subscribe to \"${state.key}\"`)\n\tconst dependencySubscriptions =\n\t\tstate.type !== `atom` ? subscribeToRootAtoms(state, store) : null\n\n\tconst unsubscribe =\n\t\tdependencySubscriptions === null\n\t\t\t? () => {\n\t\t\t\t\tstore.config.logger?.info(`🙈 unsubscribe from \"${state.key}\"`)\n\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t }\n\t\t\t: () => {\n\t\t\t\t\tstore.config.logger?.info(\n\t\t\t\t\t\t`🙈 unsubscribe from \"${state.key}\" and its dependencies`,\n\t\t\t\t\t)\n\t\t\t\t\tsubscription.unsubscribe()\n\t\t\t\t\tfor (const dependencySubscription of dependencySubscriptions) {\n\t\t\t\t\t\tdependencySubscription.unsubscribe()\n\t\t\t\t\t}\n\t\t\t }\n\n\treturn unsubscribe\n}\n\nexport type TransactionUpdateHandler<ƒ extends ƒn> = (\n\tdata: TransactionUpdate<ƒ>,\n) => void\n\nexport const subscribeToTransaction = <ƒ extends ƒn>(\n\ttoken: TransactionToken<ƒ>,\n\thandleUpdate: TransactionUpdateHandler<ƒ>,\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tx = withdraw(token, store)\n\tif (tx === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.config.logger?.info(`👀 subscribe to transaction \"${token.key}\"`)\n\tconst subscription = tx.subject.subscribe(handleUpdate)\n\tconst unsubscribe = () => {\n\t\tstore.config.logger?.info(`🙈 unsubscribe from transaction \"${token.key}\"`)\n\t\tsubscription.unsubscribe()\n\t}\n\treturn unsubscribe\n}\n\nexport const subscribeToTimeline = (\n\ttoken: TimelineToken,\n\thandleUpdate: (update: TimelineUpdate) => void,\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tl = withdraw(token, store)\n\tif (tl === null) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to timeline \"${token.key}\": timeline not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.config.logger?.info(`👀 subscribe to timeline \"${token.key}\"`)\n\tconst subscription = tl.subject.subscribe(handleUpdate)\n\tconst unsubscribe = () => {\n\t\tstore.config.logger?.info(`🙈 unsubscribe from timeline \"${token.key}\"`)\n\t\tsubscription.unsubscribe()\n\t}\n\treturn unsubscribe\n}\n","import type { AtomFamily, AtomToken } from \".\"\nimport type {\n\tTimelineAtomUpdate,\n\tTimelineSelectorUpdate,\n\tTimelineTransactionUpdate,\n} from \"./internal\"\nimport { IMPLICIT } from \"./internal\"\nimport { redo__INTERNAL, timeline__INTERNAL, undo__INTERNAL } from \"./internal/\"\n\nexport type TimelineToken = {\n\tkey: string\n\ttype: `timeline`\n}\n\nexport type TimelineOptions = {\n\tkey: string\n\tatoms: (AtomFamily<any, any> | AtomToken<any>)[]\n}\n\nexport type TimelineUpdate =\n\t| TimelineAtomUpdate\n\t| TimelineSelectorUpdate\n\t| TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n\treturn timeline__INTERNAL(options)\n}\n\nexport const redo = (token: TimelineToken): void => {\n\tredo__INTERNAL(token, IMPLICIT.STORE)\n}\n\nexport const undo = (token: TimelineToken): void => {\n\tundo__INTERNAL(token, IMPLICIT.STORE)\n}\n","import type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport type { KeyedStateUpdate, ReadonlySelectorToken, StateToken } from \".\"\nimport type { Store } from \"./internal\"\nimport { IMPLICIT, transaction__INTERNAL, withdraw } from \"./internal\"\n\nexport type TransactionToken<_> = {\n\tkey: string\n\ttype: `transaction`\n\t__brand?: _\n}\n\nexport type TransactionUpdate<ƒ extends ƒn> = {\n\tkey: string\n\tatomUpdates: KeyedStateUpdate<unknown>[]\n\tparams: Parameters<ƒ>\n\toutput: ReturnType<ƒ>\n}\n\nexport type Transactors = {\n\tget: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S\n\tset: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void\n}\nexport type ReadonlyTransactors = Pick<Transactors, `get`>\n\nexport type Read<ƒ extends ƒn> = (\n\ttransactors: ReadonlyTransactors,\n\t...parameters: Parameters<ƒ>\n) => ReturnType<ƒ>\n\nexport type Write<ƒ extends ƒn> = (\n\ttransactors: Transactors,\n\t...parameters: Parameters<ƒ>\n) => ReturnType<ƒ>\n\nexport type TransactionOptions<ƒ extends ƒn> = {\n\tkey: string\n\tdo: Write<ƒ>\n}\n\nexport type TransactionIO<Token extends TransactionToken<any>> =\n\tToken extends TransactionToken<infer ƒ> ? ƒ : never\n\nexport function transaction<ƒ extends ƒn>(\n\toptions: TransactionOptions<ƒ>,\n): TransactionToken<ƒ> {\n\treturn transaction__INTERNAL(options)\n}\n\nexport const runTransaction =\n\t<ƒ extends ƒn>(token: TransactionToken<ƒ>, store: Store = IMPLICIT.STORE) =>\n\t(...parameters: Parameters<ƒ>): ReturnType<ƒ> => {\n\t\tconst tx = withdraw(token, store)\n\t\tif (tx) {\n\t\t\treturn tx.run(...parameters)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Cannot run transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,aAAa,CAAC,QAC1B,IAAI,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;;;ACDnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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OAAO,KAAK;AACtC,iBAAe,KAAK;AACrB;AAEO,IAAM,YAAY,CACxB,OACA,QAAe,SAAS,UAExB,MAAM,SAAS,SACZ,cAAc,MAAM,KAAK,KAAK,IAC9B,kBAAkB,MAAM,KAAK,KAAK;","names":["import_hamt_plus","Rx","selector","HAMT","import_hamt_plus","import_hamt_plus","import_function","join","import_function","import_function","import_string","import_function","map","map","id","HAMT","atom","selector","timeline","HAMT","atom","selector","import_hamt_plus","Rx","token","store","HAMT","HAMT","Rx","import_function","import_hamt_plus","import_hamt_plus","Rx","_a","HAMT","import_hamt_plus","Rx","import_hamt_plus","_a","_b","state","HAMT","atom","selector","HAMT","HAMT","atom","import_hamt_plus","Rx","atom","update","_a","store","token","HAMT","import_hamt_plus","HAMT","_a","_a"]}
|