import { AbortControllerRegistry } from "./abort-controller-registry.js"; import { UnknownState } from "./state.js"; import { Simplify, UnionToIntersection } from "@videojs/utils/types"; //#region src/core/slice.d.ts type Attach = (ctx: AttachContext) => void; interface AttachStore { readonly state: UnknownState; subscribe: (callback: () => void) => () => void; } interface AttachContext { target: Target; signal: AbortSignal; store: AttachStore; get: () => Readonly; set: (partial: Partial) => void; reportError: (error: unknown) => void; } interface StateContext { /** Returns the current target. Throws if not attached. */ target: () => Target; /** * Cancellation signals for async operations. * * - `signals.base` — Aborts on detach or reattach. Use for cleanup. * - `signals.supersede(key)` — Returns a signal that aborts when the same key * is superseded or when base aborts. Use for operations that should cancel * previous in-flight work (e.g., seek superseding seek). * - `signals.clear()` — Aborts all keyed signals. Use when starting fresh * (e.g., loading a new source cancels pending seeks). */ signals: AbortControllerRegistry; /** Read current slice state. Safe to use inside action closures (not during `state()` init). */ get: () => Readonly>; /** Patch the slice state. Safe to use inside action closures (not during `state()` init). */ set: (partial: Record) => void; } interface SliceConfig { /** Debug label. Used as `displayName` on selectors created from this slice. */ name?: string; state: (ctx: StateContext) => State; attach?: (ctx: AttachContext) => void; } type Slice = SliceConfig; type AnySlice = Slice; type SliceFactory = (config: SliceConfig) => Slice; declare function defineSlice(): SliceFactory; type InferSliceTarget = S extends Slice ? Target : never; type InferSliceState = S extends Slice ? State : never; type UnionSliceState = Simplify>>; //#endregion export { AnySlice, Attach, AttachContext, AttachStore, InferSliceState, InferSliceTarget, Slice, SliceConfig, SliceFactory, StateContext, UnionSliceState, defineSlice }; //# sourceMappingURL=slice.d.ts.map