import { Json, stringified } from "atom.io/foundations/json"; import { UList } from "atom.io/transceivers/u-list"; import { MapOverlay } from "atom.io/foundations/overlays"; import { StatefulSubject, Subject } from "atom.io/foundations/subject"; import { Future } from "atom.io/foundations/future"; import { ActorToolkit, AtomCreationEvent, AtomDisposalEvent, AtomFamilyToken, AtomIOLogger, AtomIOToken, AtomLifecycleEvent, AtomToken, AtomUpdateEvent, FamilyMetadata, HeldSelectorFamilyToken, HeldSelectorToken, JoinOptions, JoinStates, JoinToken, Logger, MoleculeCreationEvent, MoleculeDisposalEvent, MoleculeTransferEvent, MutableAtomFamilyOptions, MutableAtomFamilyToken, MutableAtomOptions, MutableAtomToken, PureSelectorFamilyToken, PureSelectorToken, ReadableFamilyToken, ReadableToken, ReadonlyHeldSelectorFamilyOptions, ReadonlyHeldSelectorFamilyToken, ReadonlyHeldSelectorOptions, ReadonlyHeldSelectorToken, ReadonlyPureSelectorFamilyOptions, ReadonlyPureSelectorFamilyToken, ReadonlyPureSelectorOptions, ReadonlyPureSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, RegularAtomFamilyOptions, RegularAtomFamilyToken, RegularAtomOptions, RegularAtomToken, SelectorFamilyToken, SelectorToken, Setter, StateUpdate, TimelineEvent, TimelineFamilyOptions, TimelineFamilyScope, TimelineFamilyToken, TimelineManageable, TimelineOptions, TimelineSelectorUpdateEvent, TimelineToken, TimelineUpdate, TransactionOptions, TransactionOutcomeEvent, TransactionToken, TransactionUpdateHandler, UpdateHandler, ViewOf, WritableFamilyToken, WritableHeldSelectorFamilyOptions, WritableHeldSelectorFamilyToken, WritableHeldSelectorOptions, WritableHeldSelectorToken, WritablePureSelectorFamilyOptions, WritablePureSelectorFamilyToken, WritablePureSelectorOptions, WritablePureSelectorToken, WritableSelectorFamilyToken, WritableSelectorToken, WritableToken, WriterToolkit } from "atom.io"; import { Junction } from "atom.io/foundations/junction"; import { Above, CompoundFrom, CompoundTypedKey, Hierarchy, SingularTypedKey, ValidKey, Vassal } from "atom.io/experiments/realms"; import { Canonical } from "atom.io/foundations/canonical"; import { Flat } from "atom.io/foundations/type-utils"; //#region src/internal/arbitrary.d.ts declare function arbitrary(random?: () => number): string; //#endregion //#region src/internal/store/circular-buffer.d.ts declare class CircularBuffer { protected _buffer: T[]; protected _index: number; constructor(array: T[]); constructor(length: number); get buffer(): ReadonlyArray; get index(): number; add(item: T): void; copy(): CircularBuffer; } //#endregion //#region src/internal/mutable/transceiver.d.ts interface Transceiver void) => () => void; }, S extends Json.Serializable, J extends Json.Serializable> { READONLY_VIEW: V; do: (update: S) => number | `OUT_OF_RANGE` | null; undo: (update: S) => void; subscribe: (key: string, fn: (update: S) => void) => () => void; toJSON: () => J; } /** * Controls whether a mutable atom may participate in native Atom.io time * travel. Append-only transceivers implement history by recording new signals; * rewinding their object graph would violate their consistency contract. */ type TransceiverTimelinePolicy = `append-only` | `reversible`; type TransceiverConstructor> = (new () => T) & { fromJSON: (json: J) => T; readonly timelinePolicy?: TransceiverTimelinePolicy; }; declare function isTransceiver(value: unknown): value is Transceiver; type TransceiverMode = `playback` | `record` | `transaction`; type SignalFrom> = T extends Transceiver ? S : never; type AsJSON> = T extends Transceiver ? J : never; type ConstructorOf> = TransceiverConstructor, T>; //#endregion //#region src/internal/mutable/create-mutable-atom.d.ts declare function createMutableAtom>(store: Store, options: MutableAtomOptions, family: FamilyMetadata | undefined): MutableAtomToken; //#endregion //#region src/internal/utility-types.d.ts type Fn = (...parameters: any[]) => any; type Ctor = new (...args: any[]) => T; type Count = [...A, any][`length`] extends N ? A[`length`] : A[`length`] | Count; type Each = { [P in Count]: E[P]; }; type Refinement = (a: A) => a is B; //#endregion //#region src/internal/transaction/transaction-meta-progress.d.ts declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"]; type TransactionPhase = (typeof TRANSACTION_PHASES)[number]; type TransactionProgress = { phase: `applying` | `building`; update: TransactionOutcomeEvent>; toolkit: ActorToolkit; }; type RootTransactionMeta = { phase: `idle`; }; //#endregion //#region src/internal/transaction/is-root-store.d.ts interface RootStore extends Store { transactionMeta: RootTransactionMeta; parent: null; child: ChildStore | null; } interface ChildStore extends Store { transactionMeta: TransactionProgress; parent: ChildStore | RootStore; child: ChildStore | null; valueMap: MapOverlay; } declare function isRootStore(store: Store): store is RootStore; declare function isChildStore(store: Store): store is ChildStore; //#endregion //#region src/internal/transaction/abort-transaction.d.ts declare function abortTransaction(target: ChildStore): void; //#endregion //#region src/internal/transaction/act-upon-store.d.ts declare function actUponStore(store: Store, token: TransactionToken, id: string): (...parameters: Parameters) => ReturnType; //#endregion //#region src/internal/transaction/apply-transaction.d.ts declare function applyTransaction(store: ChildStore, output: ReturnType): void; //#endregion //#region src/internal/transaction/build-transaction.d.ts declare function buildTransaction(store: RootStore, token: TransactionToken, params: any[], id: string): ChildStore; //#endregion //#region src/internal/transaction/create-transaction.d.ts type Transaction = { key: string; type: `transaction`; install: (store: RootStore) => void; subject: Subject>>; run: (parameters: Parameters, id?: string) => ReturnType; }; declare function createTransaction(store: RootStore, options: TransactionOptions): TransactionToken; //#endregion //#region src/internal/mutable/create-mutable-atom-family.d.ts declare function createMutableAtomFamily, K extends Canonical>(store: RootStore, options: MutableAtomFamilyOptions, internalRoles?: string[]): MutableAtomFamilyToken; //#endregion //#region src/internal/timeline/clear-timeline.d.ts declare function clearTimelineInStore(store: Store, token: TimelineToken): void; //#endregion //#region src/internal/timeline/create-timeline.d.ts type TimelineRecordCallback = (event: { readonly type: `timeline_record`; readonly event: TimelineEvent; }) => void; type Timeline = { type: `timeline`; key: string; family?: FamilyMetadata; at: number; timeTraveling: `into_future` | `into_past` | null; history: TimelineEvent[]; selectorTime: number | null; transactionKey: string | null; onRecordCallbacks: Set; pendingRecord: TimelineEvent | null; pendingUndoStepLimit: number | null; cleanup: (() => void) | null; ownedTopicKeys: Set; install: (store: RootStore) => void; subject: Subject>; subscriptions: Map void>; }; declare function createTimeline(store: RootStore, options: TimelineOptions, data?: Timeline, family?: FamilyMetadata): TimelineToken; declare function addAtomToTimeline(store: Store, atomToken: AtomToken, tl: Timeline): void; declare function handleStateLifecycleEvent(store: Store, event: AtomCreationEvent | AtomDisposalEvent, tl: Timeline): void; //#endregion //#region src/internal/timeline/create-timeline-family.d.ts type TimelineFamily = { type: `timeline_family`; key: string; install: (store: RootStore) => void; options: TimelineFamilyOptions; routes: Map>; routedAtoms: Map>>; subscriptions: Map void>; create: (key: Key, data?: Timeline) => TimelineToken; }; declare function createTimelineFamily>(store: RootStore, options: TimelineFamilyOptions): TimelineFamilyToken; declare function createTimelineFamilyMember(store: RootStore, familyToken: TimelineFamilyToken, key: Key, data?: Timeline): TimelineToken; declare function seekTimelineInStore(store: Store, family: TimelineFamilyToken, key: NoInfer): TimelineToken | undefined; declare function findTimelineInStore(store: RootStore, familyToken: TimelineFamilyToken, key: NoInfer): TimelineToken; //#endregion //#region src/internal/timeline/dispose-timeline.d.ts declare function disposeTimelineInStore(store: Store, token: TimelineToken): void; declare function disposeTimelineInStore(store: Store, family: TimelineFamilyToken, key: NoInfer): void; //#endregion //#region src/internal/timeline/inspect-timeline.d.ts type TimelineInspection = { at: number; length: number; }; declare function inspectTimelineInStore(store: Store, token: TimelineToken): TimelineInspection; //#endregion //#region src/internal/timeline/time-travel.d.ts declare function timeTravel(store: Store, action: `redo` | `undo`, token: TimelineToken): void; //#endregion //#region src/internal/timeline/timeline-transaction-group.d.ts declare const TIMELINE_TRANSACTION_GROUP: unique symbol; type TimelineTransactionGroup = { sequence: number; timelineKeys: Set; }; type GroupedTimelineTransactionEvent = TimelineEvent & TransactionOutcomeEvent> & { [TIMELINE_TRANSACTION_GROUP]: TimelineTransactionGroup; }; declare function addTimelineToTransactionGroup(outcome: TransactionOutcomeEvent>, timelineKey: string): TimelineTransactionGroup; declare function getTimelineTransactionGroup(event: TimelineEvent): TimelineTransactionGroup | undefined; //#endregion //#region src/internal/timeline/time-travel-transaction.d.ts type TransactionTimeTravel = `redo` | `undo`; declare function timeTravelTransactionInStore(store: Store, action: TransactionTimeTravel, token: TransactionToken, id?: string): void; declare function timeTravelTransactionGroupInStore(store: Store, action: TransactionTimeTravel, group: TimelineTransactionGroup): boolean; declare function getTimelineTransactionAtHead(timeline: Timeline, action: TransactionTimeTravel): TimelineTransactionGroup | undefined; //#endregion //#region src/internal/state-types.d.ts type AtomIOState = { key: string; family?: FamilyMetadata; install: (store: RootStore) => void; subject: Subject>; }; type RegularAtom = Flat T); cleanup?: () => void; internalRoles?: InternalRole[]; catch?: readonly Ctor[]; __T?: T; __E?: E; }>; type MutableAtom> = Flat; cleanup?: () => void; __T?: T; }>; type Atom = RegularAtom | (T extends Transceiver ? MutableAtom : never); type WritableHeldSelector = Flat T; setSelf: (newValue: T) => void; __T?: T; }>; type ReadonlyHeldSelector = Flat T; __T?: T; }>; type WritablePureSelector = Flat E | T; setSelf: (newValue: T) => void; catch?: readonly Ctor[]; __T?: T; __E?: E; }>; type ReadonlyPureSelector = Flat E | T; catch?: readonly Ctor[]; __T?: T; __E?: E; }>; type ReadonlySelector = ReadonlyHeldSelector | ReadonlyPureSelector; type WritableSelector = WritableHeldSelector | WritablePureSelector; type HeldSelector = ReadonlyHeldSelector | WritableHeldSelector; type PureSelector = ReadonlyPureSelector | WritablePureSelector; type Selector = ReadonlyHeldSelector | ReadonlyPureSelector | WritableHeldSelector | WritablePureSelector; type WritableState = Atom | WritableSelector; type ReadableState = Atom | Selector; type RegularAtomFamily = Flat & { create: (key: Key) => RegularAtomToken; default: T | ((key: K) => T); install: (store: RootStore) => void; internalRoles: string[] | undefined; subject: Subject>>; }>; type MutableAtomFamily, K extends Canonical> = Flat & { create: (key: Key) => MutableAtomToken; class: ConstructorOf; install: (store: RootStore) => void; internalRoles: string[] | undefined; subject: Subject>>; }>; type AtomFamily = MutableAtomFamily ? T : never, K> | RegularAtomFamily; type WritablePureSelectorFamily = Flat & { create: (key: Key) => WritablePureSelectorToken; default: (key: K) => T; install: (store: RootStore) => void; internalRoles: string[] | undefined; }>; type WritableHeldSelectorFamily = Flat & { create: (key: Key) => WritableHeldSelectorToken; default: (key: K) => T; install: (store: RootStore) => void; internalRoles: string[] | undefined; }>; type ReadonlyPureSelectorFamily = Flat & { create: (key: Key) => ReadonlyPureSelectorToken; default: (key: K) => T; install: (store: RootStore) => void; internalRoles: string[] | undefined; }>; type ReadonlyHeldSelectorFamily = Flat & { create: (key: Key) => ReadonlyHeldSelectorToken; default: (key: K) => T; install: (store: RootStore) => void; internalRoles: string[] | undefined; }>; type PureSelectorFamily = ReadonlyPureSelectorFamily | WritablePureSelectorFamily; type HeldSelectorFamily = ReadonlyHeldSelectorFamily | WritableHeldSelectorFamily; type ReadonlySelectorFamily = ReadonlyHeldSelectorFamily | ReadonlyPureSelectorFamily; type WritableSelectorFamily = WritableHeldSelectorFamily | WritablePureSelectorFamily; type SelectorFamily = HeldSelectorFamily | PureSelectorFamily; type WritableFamily = AtomFamily | WritableSelectorFamily; type ReadableFamily = AtomFamily | SelectorFamily; type AtomIOInternalResource = ReadableFamily | ReadableState | Timeline | TimelineFamily | Transaction; //#endregion //#region src/internal/mutable/get-json-family.d.ts declare function getJsonFamily, Key extends Canonical>(mutableAtomFamily: MutableAtomFamilyToken, store: Store): WritablePureSelectorFamily, Key, never>; //#endregion //#region src/internal/mutable/get-json-token-from-store.d.ts declare const getJsonTokenFromStore: >(store: Store, mutableAtomToken: MutableAtomToken) => WritablePureSelectorToken>; //#endregion //#region src/internal/mutable/get-update-family.d.ts declare function getUpdateFamily, K extends string>(mutableAtomFamily: MutableAtomFamilyToken, store: Store): RegularAtomFamily, K, never>; //#endregion //#region src/internal/mutable/get-update-token.d.ts declare function getUpdateToken>(mutableAtomToken: MutableAtomToken): RegularAtomToken>; //#endregion //#region src/internal/mutable/tracker.d.ts /** * @internal Give the tracker a transceiver state and a store, and it will * subscribe to the transceiver's inner value. When the inner value changes, * the tracker will update its own state to reflect the change. */ declare class Tracker> { private initializeSignalAtom; private unsubscribeFromInnerValue; private unsubscribeFromState; private captureSignalsFromCore; private supplySignalsToCore; mutableAtomToken: MutableAtomToken; latestSignalToken: RegularAtomToken | null>; [Symbol.dispose]: () => void; constructor(mutableAtomToken: MutableAtomToken, store: Store); } //#endregion //#region src/internal/mutable/tracker-family.d.ts declare class FamilyTracker, K extends Canonical> { private trackers; readonly latestSignalAtoms: RegularAtomFamily | null, K>; readonly mutableAtoms: MutableAtomFamily; constructor(mutableAtoms: MutableAtomFamily, store: RootStore); } //#endregion //#region src/internal/store/deposit.d.ts declare function deposit(state: RegularAtom): RegularAtomToken; declare function deposit>(state: MutableAtom): MutableAtomToken; declare function deposit(state: Atom): AtomToken; declare function deposit(state: WritablePureSelector): WritablePureSelectorToken; declare function deposit(state: ReadonlyPureSelector): ReadonlyPureSelectorToken; declare function deposit(state: Selector): SelectorToken; declare function deposit(state: WritableState): WritableToken; declare function deposit(state: ReadableState): ReadableToken; declare function deposit(state: RegularAtomFamily): RegularAtomFamilyToken; declare function deposit, K extends Canonical>(state: MutableAtomFamily): MutableAtomFamilyToken; declare function deposit(state: AtomFamily): AtomFamilyToken; declare function deposit(state: WritablePureSelectorFamily): WritablePureSelectorFamilyToken; declare function deposit(state: ReadonlyPureSelectorFamily): ReadonlyPureSelectorFamilyToken; declare function deposit(state: SelectorFamily): SelectorFamilyToken; declare function deposit(state: WritableFamily): WritableFamilyToken; declare function deposit(state: ReadableFamily): ReadableFamilyToken; declare function deposit(state: Transaction): TransactionToken; declare function deposit(state: TimelineFamily): TimelineFamilyToken; declare function deposit(state: Timeline): TimelineToken; declare function deposit(resource: AtomIOInternalResource): AtomIOToken; //#endregion //#region src/internal/join/create-join.d.ts declare function createJoin(store: RootStore, options: JoinOptions): JoinToken; //#endregion //#region src/internal/join/edit-relations-in-store.d.ts declare function editRelationsInStore(store: Store, token: JoinToken, change: (relations: Junction) => void): void; //#endregion //#region src/internal/join/find-relations-in-store.d.ts declare function findRelationsInStore(store: Store, token: JoinToken, key: A | B): JoinStates; //#endregion //#region src/internal/join/get-internal-relations-from-store.d.ts declare function getInternalRelationsFromStore(store: Store, token: JoinToken): MutableAtomFamilyToken | UList, A | B>; declare function getInternalRelationsFromStore(store: Store, token: JoinToken, split: `split`): [atob: MutableAtomFamilyToken, A>, btoa: MutableAtomFamilyToken, B>]; //#endregion //#region src/internal/join/join-internal.d.ts type JoinStateFamilies = Cardinality extends `1:1` ? { readonly [N in AName as `${N}KeyOf${Capitalize}`]: ReadonlyPureSelectorFamilyToken; } & { readonly [N in BName as `${N}KeyOf${Capitalize}`]: ReadonlyPureSelectorFamilyToken; } : Cardinality extends `1:n` ? { readonly [N in BName as `${N}KeysOf${Capitalize}`]: ReadonlyPureSelectorFamilyToken; } : Cardinality extends `n:n` ? { readonly [N in AName as `${N}KeysOf${Capitalize}`]: ReadonlyPureSelectorFamilyToken; } & { readonly [N in BName as `${N}KeysOf${Capitalize}`]: ReadonlyPureSelectorFamilyToken; } : never; declare class Join { private toolkit; options: JoinOptions; relations: Junction; states: JoinStateFamilies; relatedKeysAtoms: MutableAtomFamilyToken | UList, A | B>; transact(toolkit: WriterToolkit, run: (join: Join) => void): void; store: Store; [Symbol.dispose](): void; constructor(store: RootStore, options: JoinOptions); } //#endregion //#region src/internal/join/get-join.d.ts declare function getJoin(store: Store, token: JoinToken): Join; //#endregion //#region src/internal/lineage.d.ts interface Lineage { parent: Lineage | null; child: Lineage | null; } declare function newest(origin: T): Exclude | T; declare function eldest(origin: T): Exclude; //#endregion //#region src/internal/molecule.d.ts type Molecule = { readonly key: K; readonly stringKey: stringified; readonly dependsOn: `all` | `any`; readonly subject: Subject; }; declare function simpleCompound(a: string, b: string): string; declare function decomposeCompound(compound: Canonical): [type: string, a: string, b: string] | null; declare function makeRootMoleculeInStore(store: Store, key: S): S; declare function allocateIntoStore, A extends Above>(store: Store, provenance: A, key: V, dependsOn?: `all` | `any`): ValidKey; declare function fuseWithinStore, T extends (C extends CompoundTypedKey ? t : never), A extends (C extends CompoundTypedKey ? a : never), B extends (C extends CompoundTypedKey ? b : never)>(store: Store, type: T, sideA: SingularTypedKey, sideB: SingularTypedKey): ValidKey>; declare function createDeallocateTX, CompoundTypedKey>>(store: RootStore): TransactionToken<(claim: ValidKey) => void>; declare function deallocateFromStore>(target: Store, claim: ValidKey): void; declare function createClaimTX, CompoundTypedKey>, A extends Above>(store: RootStore): TransactionToken<(newProvenance: A, claim: ValidKey, exclusive?: `exclusive`) => void>; declare function claimWithinStore, CompoundTypedKey>, A extends Above>(store: Store, newProvenance: A, claim: ValidKey, exclusive?: `exclusive`): ValidKey; //#endregion //#region src/internal/operation.d.ts type OperationProgress = OpenOperation | { open: false; }; type OpenOperation = ReadableToken> = { open: true; token: R; done: Set; prev: Map; timestamp: number; subEvents: (AtomUpdateEvent | AtomCreationEvent)[]; }; declare function openOperation(store: Store, token: ReadableToken): number | (Store & { operation: OpenOperation; }); declare function closeOperation(store: Store): void; declare function isDone(store: Store, key: string): boolean; declare function markDone(store: Store, key: string): void; //#endregion //#region src/internal/store/store.d.ts type StoreConfig = { name: string; lifespan: `ephemeral` | `immortal`; isProduction: boolean; }; declare class Store implements Lineage { parent: ChildStore | RootStore | null; child: ChildStore | null; valueMap: Map; defaults: Map; atoms: Map>; writableSelectors: Map>; readonlySelectors: Map>; atomsThatAreDefault: Set; selectorAtoms: Junction<`selectorKey`, string, `atomKey`, string>; selectorGraph: Junction<`upstreamSelectorKey`, string, `downstreamSelectorKey`, string, { source: string; }>; trackers: Map>>; families: Map | MutableAtomFamily | PureSelectorFamily | RegularAtomFamily>; joins: Map>; transactions: Map>; transactionMeta: RootTransactionMeta | TransactionProgress; timelines: Map>; timelineFamilies: Map>; timelineTopics: Junction<`timelineKey`, string, `topicKey`, string, { topicType: `atom_family` | `atom` | `molecule_family` | `molecule`; }>; disposalTraces: CircularBuffer<{ key: string; trace: string; }>; molecules: Map>; moleculeGraph: Junction<`upstreamMoleculeKey`, stringified | `"root"`, `downstreamMoleculeKey`, stringified, { source: stringified; }>; moleculeData: Junction<`moleculeKey`, stringified, `stateFamilyKey`, string>; keyRefsInJoins: Junction<`moleculeKey`, stringified, `joinKey`, string>; miscResources: Map; on: StoreEventCarrier; operation: OperationProgress; config: StoreConfig; loggers: AtomIOLogger[]; logger: Logger; constructor(config: Store[`config`], store?: Store | null); } type StoreEventCarrier = { atomCreation: Subject>; atomDisposal: Subject>; selectorCreation: Subject>; selectorDisposal: Subject>; timelineCreation: Subject>; timelineDisposal: Subject>; transactionCreation: Subject>; transactionApplying: StatefulSubject | null>; operationClose: Subject; moleculeCreation: Subject; moleculeDisposal: Subject; }; declare global { var ATOM_IO_IMPLICIT_STORE: RootStore | undefined; } declare const IMPLICIT: { readonly STORE: RootStore; }; declare function clearStore(store: Store): void; //#endregion //#region src/internal/store/withdraw.d.ts declare function withdraw(store: Store, token: RegularAtomToken): RegularAtom; declare function withdraw>(store: Store, token: MutableAtomToken): MutableAtom; declare function withdraw(store: Store, token: AtomToken): Atom; declare function withdraw(store: Store, token: WritableHeldSelectorToken): WritableHeldSelector; declare function withdraw(store: Store, token: ReadonlyHeldSelectorToken): ReadonlyHeldSelector; declare function withdraw(store: Store, token: WritablePureSelectorToken): WritablePureSelector; declare function withdraw(store: Store, token: ReadonlyPureSelectorToken): ReadonlyPureSelector; declare function withdraw(store: Store, token: ReadonlySelectorToken): ReadonlySelector; declare function withdraw(store: Store, token: WritableSelectorToken): WritableSelector; declare function withdraw(store: Store, token: HeldSelectorToken): HeldSelector; declare function withdraw(store: Store, token: PureSelectorToken): PureSelector; declare function withdraw(store: Store, token: SelectorToken): Selector; declare function withdraw(store: Store, token: WritableToken): WritableState; declare function withdraw(store: Store, token: ReadableToken): ReadableState; declare function withdraw(store: Store, token: RegularAtomFamilyToken): RegularAtomFamily; declare function withdraw, K extends Canonical>(store: Store, token: MutableAtomFamilyToken): MutableAtomFamily; declare function withdraw(store: Store, token: AtomFamilyToken): AtomFamily; declare function withdraw(store: Store, token: ReadonlyHeldSelectorFamilyToken): ReadonlyHeldSelectorFamily; declare function withdraw(store: Store, token: WritableHeldSelectorFamilyToken): WritableHeldSelectorFamily; declare function withdraw(store: Store, token: ReadonlyPureSelectorFamilyToken): ReadonlyPureSelectorFamily; declare function withdraw(store: Store, token: WritablePureSelectorFamilyToken): WritablePureSelectorFamily; declare function withdraw(store: Store, token: ReadonlySelectorFamilyToken): ReadonlySelectorFamily; declare function withdraw(store: Store, token: WritableSelectorFamilyToken): WritableSelectorFamily; declare function withdraw(store: Store, token: HeldSelectorFamilyToken): HeldSelectorFamily; declare function withdraw(store: Store, token: PureSelectorFamilyToken): PureSelectorFamily; declare function withdraw(store: Store, token: SelectorFamilyToken): SelectorFamily; declare function withdraw(store: Store, token: WritableFamilyToken): WritableFamily; declare function withdraw(store: Store, token: ReadableFamilyToken): ReadableFamily; declare function withdraw(store: Store, token: TransactionToken): Transaction; declare function withdraw(store: Store, token: TimelineFamilyToken): TimelineFamily; declare function withdraw(store: Store, token: TimelineToken): Timeline; declare function withdraw(store: Store, token: WritableToken): WritableState; declare function withdraw(store: Store, token: ReadableToken): ReadableState; declare function withdraw(store: Store, token: AtomIOToken): AtomIOInternalResource; //#endregion //#region src/internal/atom/has-role.d.ts declare const INTERNAL_ROLES: readonly ["tracker:signal"]; type InternalRole = (typeof INTERNAL_ROLES)[number]; declare function hasRole(atom: Atom, role: InternalRole): boolean; //#endregion //#region src/internal/atom/create-regular-atom.d.ts declare function createRegularAtom(store: Store, options: RegularAtomOptions, family: FamilyMetadata | undefined, internalRoles?: InternalRole[]): RegularAtomToken; //#endregion //#region src/internal/atom/dispose-atom.d.ts declare function disposeAtom(store: Store, atomToken: AtomToken): void; //#endregion //#region src/internal/caching.d.ts declare function writeToCache(target: Store, state: ReadableState, value: E | T): E | T; declare function writeToCache, E>(target: Store, state: ReadableState, value: T): Future>; /** * @param target - the newest layer of the store * @param state - the state to read from cache * @param mut - whether the value is intended to be mutable * @returns the state's current value */ declare function readFromCache(target: Store, state: ReadableState, mut: `mut` | undefined): E | T; declare function evictCachedValue(target: Store, key: string): void; //#endregion //#region src/internal/capitalize.d.ts declare function capitalize(string: S): Capitalize; //#endregion //#region src/internal/events/ingest-atom-update.d.ts declare function ingestAtomUpdateEvent(store: Store, event: AtomUpdateEvent, applying: `newValue` | `oldValue`): void; //#endregion //#region src/internal/events/ingest-creation-disposal.d.ts declare function ingestCreationEvent(store: Store, event: AtomCreationEvent, applying: `newValue` | `oldValue`): void; declare function ingestDisposalEvent(store: Store, event: AtomDisposalEvent, applying: `newValue` | `oldValue`): void; declare function ingestMoleculeCreationEvent(store: Store, event: MoleculeCreationEvent, applying: `newValue` | `oldValue`): void; declare function ingestMoleculeDisposalEvent(store: Store, event: MoleculeDisposalEvent, applying: `newValue` | `oldValue`): void; declare function ingestMoleculeTransferEvent(store: Store, event: MoleculeTransferEvent, applying: `newValue` | `oldValue`): void; //#endregion //#region src/internal/events/ingest-selector-update.d.ts declare function ingestSelectorUpdateEvent(store: Store, selectorUpdate: TimelineSelectorUpdateEvent, applying: `newValue` | `oldValue`): void; //#endregion //#region src/internal/events/ingest-transaction-update.d.ts declare function ingestTransactionOutcomeEvent>(store: Store, event: TransactionOutcomeEvent, applying: `newValue` | `oldValue`): void; //#endregion //#region src/internal/families/create-readonly-pure-selector-family.d.ts declare function createReadonlyPureSelectorFamily(store: RootStore, options: ReadonlyPureSelectorFamilyOptions, internalRoles?: string[]): ReadonlyPureSelectorFamilyToken; //#endregion //#region src/internal/families/create-regular-atom-family.d.ts declare function createRegularAtomFamily(store: RootStore, options: RegularAtomFamilyOptions, internalRoles?: string[]): RegularAtomFamilyToken; //#endregion //#region src/internal/families/create-selector-family.d.ts declare function createSelectorFamily(store: RootStore, options: WritableHeldSelectorFamilyOptions): WritableHeldSelectorFamilyToken; declare function createSelectorFamily(store: RootStore, options: ReadonlyHeldSelectorFamilyOptions): ReadonlyHeldSelectorFamilyToken; declare function createSelectorFamily(store: RootStore, options: WritablePureSelectorFamilyOptions): WritablePureSelectorFamilyToken; declare function createSelectorFamily(store: RootStore, options: ReadonlyPureSelectorFamilyOptions): ReadonlyPureSelectorFamilyToken; //#endregion //#region src/internal/families/create-writable-pure-selector-family.d.ts declare function createWritablePureSelectorFamily(store: Store, options: WritablePureSelectorFamilyOptions, internalRoles?: string[]): WritablePureSelectorFamilyToken; //#endregion //#region src/internal/families/dispose-from-store.d.ts declare function disposeFromStore(store: Store, token: ReadableToken): void; declare function disposeFromStore(store: Store, token: ReadableFamilyToken, key: NoInfer): void; declare function disposeFromStore(store: Store, ...params: [token: ReadableFamilyToken, key: NoInfer] | [token: ReadableToken]): void; //#endregion //#region src/internal/families/find-in-store.d.ts declare function findInStore, K extends Canonical, Key extends K>(store: Store, familyToken: MutableAtomFamilyToken, key: Key): MutableAtomToken; declare function findInStore(store: Store, familyToken: RegularAtomFamilyToken, key: Key): RegularAtomToken; declare function findInStore(store: Store, familyToken: AtomFamilyToken, key: Key): AtomToken; declare function findInStore(store: Store, familyToken: WritablePureSelectorFamilyToken, key: Key): WritablePureSelectorToken; declare function findInStore(store: Store, familyToken: ReadonlyPureSelectorFamilyToken, key: Key): ReadonlyPureSelectorToken; declare function findInStore(store: Store, familyToken: SelectorFamilyToken, key: Key): SelectorToken; declare function findInStore(store: Store, familyToken: WritableFamilyToken, key: Key): WritableToken; declare function findInStore(store: Store, familyToken: ReadableFamilyToken, key: Key): ReadableToken; //#endregion //#region src/internal/families/get-family-of-token.d.ts declare function getFamilyOfToken, K extends Canonical>(store: Store, token: MutableAtomToken): MutableAtomFamily; declare function getFamilyOfToken(store: Store, token: RegularAtomToken): RegularAtomFamily; declare function getFamilyOfToken(store: Store, token: AtomToken): AtomFamily; declare function getFamilyOfToken(store: Store, token: WritablePureSelectorToken): WritablePureSelectorFamily; declare function getFamilyOfToken(store: Store, token: ReadonlyPureSelectorToken): ReadonlyPureSelectorFamily; declare function getFamilyOfToken(store: Store, token: WritableToken): WritableFamily; declare function getFamilyOfToken(store: Store, token: ReadableToken): ReadableFamily; //#endregion //#region src/internal/families/seek-in-store.d.ts declare function seekInStore, K extends Canonical, Key extends K>(store: Store, token: MutableAtomFamilyToken, key: Key): MutableAtomToken | undefined; declare function seekInStore(store: Store, token: RegularAtomFamilyToken, key: Key): RegularAtomToken | undefined; declare function seekInStore(store: Store, token: AtomFamilyToken, key: Key): AtomToken | undefined; declare function seekInStore(store: Store, token: WritablePureSelectorFamilyToken, key: Key): WritablePureSelectorToken | undefined; declare function seekInStore(store: Store, token: ReadonlyPureSelectorFamilyToken, key: Key): ReadonlyPureSelectorToken | undefined; declare function seekInStore(store: Store, token: SelectorFamilyToken, key: Key): SelectorToken | undefined; declare function seekInStore(store: Store, token: WritableFamilyToken, key: Key): WritableToken | undefined; declare function seekInStore(store: Store, token: ReadableFamilyToken, key: Key): ReadableToken | undefined; //#endregion //#region src/internal/get-environment-data.d.ts type EnvironmentData = { store: Store; }; declare function getEnvironmentData(store: Store): EnvironmentData; //#endregion //#region src/internal/get-state/get-from-store.d.ts declare function getFromStore(store: Store, token: ReadableToken): ViewOf; declare function getFromStore(store: Store, token: ReadableFamilyToken, key: NoInfer): ViewOf; declare function getFromStore(store: Store, ...params: [token: ReadableFamilyToken, key: NoInfer] | [token: ReadableToken]): ViewOf; //#endregion //#region src/internal/get-state/read-or-compute-value.d.ts declare function readOrComputeValue(target: Store, state: ReadableState, mut?: undefined): ViewOf; declare function readOrComputeValue(target: Store, state: ReadableState, mut: `mut`): E | T; //#endregion //#region src/internal/get-trace.d.ts declare function getTrace(error: Error): string; //#endregion //#region src/internal/install-into-store.d.ts /** * @public * Install the given tokens into the target store * @param tokens - States, families, transactions, and timelines to install into the target store * @param target - The store to install the tokens into * @param source - The store to install the tokens from * */ declare function installIntoStore(tokens: AtomIOToken[], target: RootStore, source: Store): void; //#endregion //#region src/internal/is-fn.d.ts declare function isFn(input: unknown): input is Fn; //#endregion //#region src/internal/keys.d.ts type AtomKey = string & { __atomKey?: never; __brand?: T; }; type SelectorKey = string & { __selectorKey?: never; __brand?: T; }; type ReadonlySelectorKey = string & { __readonlySelectorKey?: never; __brand?: T; }; declare const isAtomKey: (store: Store, key: string) => key is AtomKey; declare const isSelectorKey: (store: Store, key: string) => key is SelectorKey; declare const isReadonlySelectorKey: (store: Store, key: string) => key is ReadonlySelectorKey; type StateKey = AtomKey | ReadonlySelectorKey | SelectorKey; declare const isStateKey: (store: Store, key: string) => key is StateKey; //#endregion //#region src/internal/reserved-keys.d.ts type ReservedIntrospectionKey = `🔍 ${string}`; declare function isReservedIntrospectionKey(value: string): value is ReservedIntrospectionKey; //#endregion //#region src/internal/selector/create-readonly-held-selector.d.ts declare function createReadonlyHeldSelector(store: Store, options: ReadonlyHeldSelectorOptions, family: FamilyMetadata | undefined): ReadonlyHeldSelectorToken; //#endregion //#region src/internal/selector/create-readonly-pure-selector.d.ts declare function createReadonlyPureSelector(store: Store, options: ReadonlyPureSelectorOptions, family: FamilyMetadata | undefined): ReadonlyPureSelectorToken; //#endregion //#region src/internal/selector/create-standalone-selector.d.ts declare function createStandaloneSelector(store: Store, options: WritableHeldSelectorOptions): WritableHeldSelectorToken; declare function createStandaloneSelector(store: Store, options: ReadonlyHeldSelectorOptions): ReadonlyHeldSelectorToken; declare function createStandaloneSelector(store: Store, options: WritablePureSelectorOptions): WritablePureSelectorToken; declare function createStandaloneSelector(store: Store, options: ReadonlyPureSelectorOptions): ReadonlyPureSelectorToken; //#endregion //#region src/internal/selector/create-writable-held-selector.d.ts declare function createWritableHeldSelector(store: Store, options: WritableHeldSelectorOptions, family: FamilyMetadata | undefined): WritableHeldSelectorToken; //#endregion //#region src/internal/selector/create-writable-pure-selector.d.ts declare function createWritablePureSelector(store: Store, options: WritablePureSelectorOptions, family: FamilyMetadata | undefined): WritablePureSelectorToken; //#endregion //#region src/internal/selector/dispose-selector.d.ts declare function disposeSelector(store: Store, selectorToken: SelectorToken): void; //#endregion //#region src/internal/selector/get-selector-dependency-keys.d.ts declare function getSelectorDependencyKeys(store: Store, key: string): (AtomKey | ReadonlySelectorKey | SelectorKey)[]; //#endregion //#region src/internal/selector/register-selector.d.ts declare function registerSelector(store: Store, selectorType: `readonly_held_selector` | `readonly_pure_selector` | `writable_held_selector` | `writable_pure_selector`, selectorKey: string, covered: Set): WriterToolkit; //#endregion //#region src/internal/selector/trace-selector-atoms.d.ts declare function traceRootSelectorAtoms(store: Store, selectorKey: string, covered?: Set): Map>; //#endregion //#region src/internal/selector/update-selector-atoms.d.ts declare function updateSelectorAtoms(store: Store, selectorType: `readonly_held_selector` | `readonly_pure_selector` | `writable_held_selector` | `writable_pure_selector`, selectorKey: string, dependency: ReadableToken, covered: Set): void; //#endregion //#region src/internal/set-state/become.d.ts declare function become(nextVersionOfThing: T | ((prev: T) => T), originalThing: T): T; //#endregion //#region src/internal/set-state/evict-downstream.d.ts declare function evictDownstreamFromAtom(store: Store, atom: Atom): void; declare function evictDownstreamFromSelector(store: Store, selectorKey: string): void; //#endregion //#region src/internal/set-state/reset-in-store.d.ts declare const RESET_STATE: unique symbol; declare function resetInStore(store: Store, token: WritableToken): void; declare function resetInStore(store: Store, token: WritableFamilyToken, key: NoInfer): void; declare function resetInStore(store: Store, ...params: [token: WritableFamilyToken, key: NoInfer] | [token: WritableToken]): void; //#endregion //#region src/internal/set-state/operate-on-store.d.ts type ProtoUpdate = { oldValue?: T; newValue: T; }; declare const OWN_OP: unique symbol; declare const JOIN_OP: unique symbol; declare function operateOnStore(opMode: typeof JOIN_OP | typeof OWN_OP, store: Store, ...params: [token: WritableFamilyToken, key: NoInfer, value: Setter | TT | typeof RESET_STATE] | [token: WritableToken, value: Setter | TT | typeof RESET_STATE]): void; //#endregion //#region src/internal/set-state/reset-atom-or-selector.d.ts declare function resetAtomOrSelector(target: Store & { operation: OpenOperation; }, state: WritableState): ProtoUpdate; //#endregion //#region src/internal/set-state/set-atom-or-selector.d.ts declare function setAtomOrSelector(target: Store & { operation: OpenOperation; }, state: WritableState, value: NoInfer | ((oldValue: T) => NoInfer)): ProtoUpdate; //#endregion //#region src/internal/set-state/set-into-store.d.ts declare function setIntoStore(store: Store, token: WritableToken, value: Setter | TT | typeof RESET_STATE): void; declare function setIntoStore(store: Store, token: WritableFamilyToken, key: NoInfer, value: Setter | TT | typeof RESET_STATE): void; declare function setIntoStore(store: Store, ...params: [token: WritableFamilyToken, key: NoInfer, value: Setter | TT | typeof RESET_STATE] | [token: WritableToken, value: Setter | TT | typeof RESET_STATE]): void; //#endregion //#region src/internal/subscribe/recall-state.d.ts declare function recallState(store: Store, state: ReadableState): T; //#endregion //#region src/internal/subscribe/subscribe-in-store.d.ts declare function subscribeInStore(store: Store, token: ReadableToken, handleUpdate: UpdateHandler, key?: string): () => void; declare function subscribeInStore(store: Store, token: TransactionToken, handleUpdate: TransactionUpdateHandler, key?: string): () => void; declare function subscribeInStore(store: Store, token: TimelineToken, handleUpdate: (update: TimelineEvent | `clear` | `redo` | `undo`) => void, key?: string): () => void; declare function subscribeInStore(store: RootStore, family: TimelineFamilyToken, memberKey: NoInfer, handleUpdate: (update: TimelineUpdate) => void, key?: string): () => void; declare function subscribeInStore(store: Store, ...params: [token: ReadableToken | TimelineToken | TransactionToken, handleUpdate: TransactionUpdateHandler | UpdateHandler | ((update: TimelineUpdate) => void), key?: string] | [family: TimelineFamilyToken, memberKey: Canonical, handleUpdate: (update: TimelineUpdate) => void, key?: string]): () => void; //#endregion //#region src/internal/subscribe/subscribe-to-root-atoms.d.ts declare function subscribeToRootDependency(target: Store, selector: Selector, atom: Atom): () => void; //#endregion //#region src/internal/subscribe/subscribe-to-state.d.ts declare function subscribeToState(store: Store, token: ReadableToken, key: string, handleUpdate: UpdateHandler): () => void; //#endregion //#region src/internal/subscribe/subscribe-to-timeline.d.ts declare function subscribeToTimeline(store: Store, token: TimelineToken, key: string, handleUpdate: (update: TimelineUpdate) => void): () => void; //#endregion //#region src/internal/subscribe/subscribe-to-transaction.d.ts declare function subscribeToTransaction(store: Store, token: TransactionToken, key: string, handleUpdate: TransactionUpdateHandler): () => void; //#endregion export { AsJSON, type Atom, type AtomFamily, type AtomIOInternalResource, type AtomIOState, AtomKey, ChildStore, CircularBuffer, ConstructorOf, type Count, type Ctor, type Each, EnvironmentData, FamilyTracker, type Fn, GroupedTimelineTransactionEvent, type HeldSelector, type HeldSelectorFamily, IMPLICIT, INTERNAL_ROLES, InternalRole, JOIN_OP, Join, JoinStateFamilies, Lineage, Molecule, type MutableAtom, type MutableAtomFamily, OWN_OP, OpenOperation, OperationProgress, ProtoUpdate, type PureSelector, type PureSelectorFamily, RESET_STATE, type ReadableFamily, type ReadableState, type ReadonlyHeldSelector, type ReadonlyHeldSelectorFamily, type ReadonlyPureSelector, type ReadonlyPureSelectorFamily, type ReadonlySelector, type ReadonlySelectorFamily, ReadonlySelectorKey, type Refinement, type RegularAtom, type RegularAtomFamily, ReservedIntrospectionKey, RootStore, RootTransactionMeta, type Selector, type SelectorFamily, SelectorKey, SignalFrom, StateKey, Store, StoreConfig, StoreEventCarrier, TIMELINE_TRANSACTION_GROUP, TRANSACTION_PHASES, Timeline, TimelineFamily, TimelineInspection, TimelineTransactionGroup, Tracker, Transaction, TransactionPhase, TransactionProgress, Transceiver, TransceiverConstructor, TransceiverMode, TransceiverTimelinePolicy, type WritableFamily, type WritableHeldSelector, type WritableHeldSelectorFamily, type WritablePureSelector, type WritablePureSelectorFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, addAtomToTimeline, addTimelineToTransactionGroup, allocateIntoStore, applyTransaction, arbitrary, become, buildTransaction, capitalize, claimWithinStore, clearStore, clearTimelineInStore, closeOperation, createClaimTX, createDeallocateTX, createJoin, createMutableAtom, createMutableAtomFamily, createReadonlyHeldSelector, createReadonlyPureSelector, createReadonlyPureSelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneSelector, createTimeline, createTimelineFamily, createTimelineFamilyMember, createTransaction, createWritableHeldSelector, createWritablePureSelector, createWritablePureSelectorFamily, deallocateFromStore, decomposeCompound, deposit, disposeAtom, disposeFromStore, disposeSelector, disposeTimelineInStore, editRelationsInStore, eldest, evictCachedValue, evictDownstreamFromAtom, evictDownstreamFromSelector, findInStore, findRelationsInStore, findTimelineInStore, fuseWithinStore, getEnvironmentData, getFamilyOfToken, getFromStore, getInternalRelationsFromStore, getJoin, getJsonFamily, getJsonTokenFromStore, getSelectorDependencyKeys, getTimelineTransactionAtHead, getTimelineTransactionGroup, getTrace, getUpdateFamily, getUpdateToken, handleStateLifecycleEvent, hasRole, ingestAtomUpdateEvent, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdateEvent, ingestTransactionOutcomeEvent, inspectTimelineInStore, installIntoStore, isAtomKey, isChildStore, isDone, isFn, isReadonlySelectorKey, isReservedIntrospectionKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markDone, newest, openOperation, operateOnStore, readFromCache, readOrComputeValue, recallState, registerSelector, resetAtomOrSelector, resetInStore, seekInStore, seekTimelineInStore, setAtomOrSelector, setIntoStore, simpleCompound, subscribeInStore, subscribeToRootDependency, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, timeTravelTransactionGroupInStore, timeTravelTransactionInStore, traceRootSelectorAtoms, updateSelectorAtoms, withdraw, writeToCache }; //# sourceMappingURL=index.d.ts.map