import type { DockviewApi, GridviewApi, IGridviewPanel, IDockviewPanel, IPaneviewPanel, ISplitviewPanel, SplitviewApi, PaneviewApi, GridviewFrameworkOptions, DockviewFrameworkOptions, SplitviewFrameworkOptions, PaneviewFrameworkOptions, IDockviewPanelHeaderProps, IWatermarkPanelProps, IDockviewHeaderActionsProps, Orientation } from "dockview-core"; import { type Component, type Snippet } from "svelte"; import type { IPaneviewReactProps, IDockviewReactProps, IGridviewReactProps, ISplitviewReactProps, IGridviewPanelProps, IDockviewPanelProps, IPaneviewPanelProps, ISplitviewPanelProps } from "dockview"; import type { RecordLike, RequiredAndPartial, ComponentExports, ConstrainedComponent, OmitNever } from "./types.js"; export declare const themes: readonly ["light", "dark", "vs", "replit", "abyss", "dracula"]; export type Theme = typeof themes[number]; /** * The props for the React version of the different view components */ export type ReactViewPropsByView = { grid: IGridviewReactProps; dock: IDockviewReactProps; pane: IPaneviewReactProps; split: ISplitviewReactProps; }; /** The keys of the different view types */ export type ViewKey = keyof ReactViewPropsByView; /** The props of the components underlying the added panels within the different views */ export type PanelComponentProps = { grid: IGridviewPanelProps; dock: IDockviewPanelProps; pane: IPaneviewPanelProps; split: ISplitviewPanelProps; }[T]; export type OriginalPanelPropKeys = keyof PanelComponentProps; /** The type of the panel returned by `api.addPanel` for the different views */ export type AddedPanelByView = { grid: IGridviewPanel; dock: IDockviewPanel; pane: IPaneviewPanel; split: ISplitviewPanel; }[T]; /** A collection of svelte components (v5 / "runes mode" and/or v4 / "legacy mode") that can be used as panel componets (their props are restricted according to the view type) */ export type ComponentsConstraint = Record, Record, any>, () => Symbol>>; export type CustomComponentConstraint> = Record, any>>; /** A collection of snippets that can be used as panel componets (their props are restricted according to the view type) */ export type SnippetsConstraint = Record]>>; export type CustomSnippetsConstraint> = Record>; /** A collection of the different component types that can be used as header components for Pane views */ export type PanePanelHeaderConstraint = { components: ComponentsConstraint<"pane">; snippets: SnippetsConstraint<"pane">; }; export type DockviewTabConstraint = { components: CustomComponentConstraint; snippets: CustomSnippetsConstraint; }; type SnippetOrComponentTuple> = { component: CustomComponentConstraint[string]; } | { snippet: CustomSnippetsConstraint[string]; }; export type DockviewSpecificComponentConstraint = { watermark: SnippetOrComponentTuple; defaultTab: SnippetOrComponentTuple; rightHeaderActions: SnippetOrComponentTuple; leftHeaderActions: SnippetOrComponentTuple; prefixHeaderActions: SnippetOrComponentTuple; }; /** * A type that takes panel props for each view type and selectively requires certain keys while keeping others optional. * The Required parameter controls which keys from the original panel props become required. */ export type SelectivelyRequiredPanelComponentPropsByView = { grid: RequiredAndPartial, Required>; dock: RequiredAndPartial, Required>; pane: RequiredAndPartial, Required>; split: RequiredAndPartial, Required>; }; export type FrameworkOptions = { grid: GridviewFrameworkOptions; dock: DockviewFrameworkOptions; pane: PaneviewFrameworkOptions; split: SplitviewFrameworkOptions; }[ViewType]; /** */ type RawAddPanelOptions = Parameters[0]["api"]["addPanel"]>[0]; export type AdditionalAddPanelOptions = ViewType extends "pane" ? { headers: PanePanelHeaderConstraint; } : ViewType extends "dock" ? { tabs: DockviewTabConstraint; } & DockviewSpecificComponentConstraint : never; type BaseOmittedPanelOptionKeys = "id" | "component" | "params"; type OmittedPanelOptionKeysPerType = T extends "pane" ? "headerComponent" : never; type CustomizedAddPanelOptions = never> = (Omit, BaseOmittedPanelOptionKeys | OmittedPanelOptionKeysPerType>) & { id?: string; } & (T extends "pane" ? Additional extends AdditionalAddPanelOptions<"pane"> ? { headerComponent?: keyof (Additional["headers"]["components"] | Additional["headers"]["snippets"]); } : {} : {}); type ComponentPanelPropParams> = Components[K] extends Component ? Props["params"] : never; type SpreadAddComponentPanelOptions, Additional extends AdditionalAddPanelOptions> = ComponentPanelPropParams extends Record ? [ComponentPanelPropParams] | [ComponentPanelPropParams, CustomizedAddPanelOptions] : [null | undefined | {}, CustomizedAddPanelOptions] | []; type SpreadAddSnippetPanelOptions, Additional extends AdditionalAddPanelOptions> = Snippets[K] extends Snippet ? [Params[0]["params"]] | [Params[0]["params"], CustomizedAddPanelOptions] : [null | undefined | {}, CustomizedAddPanelOptions] | []; export declare const signal: (getter: () => T) => T; export type ExtendedGridAPI, Snippets extends SnippetsConstraint, Additional extends AdditionalAddPanelOptions = AdditionalAddPanelOptions> = { addComponentPanel: (name: string extends K ? never : K, ...params: SpreadAddComponentPanelOptions) => Promise<{ exports: ComponentExports; panel: AddedPanelByView; reference: string; }>; addSnippetPanel: (name: string extends K ? never : K, ...params: SpreadAddSnippetPanelOptions) => Promise<{ panel: AddedPanelByView; reference: string; }>; signal: (getter: () => T) => T; }; export type RawViewAPIs = { grid: GridviewApi; dock: DockviewApi; pane: PaneviewApi; split: SplitviewApi; }; export type RawViewAPI = RawViewAPIs[ViewType]; export type ViewAPI, Snippets extends SnippetsConstraint, Additional extends AdditionalAddPanelOptions = never> = RawViewAPIs[ViewType] & ExtendedGridAPI; type RawViewProps = ReactViewPropsByView[ViewType]; type OnReady = RawViewProps["onReady"]; type CustomizedViewProps, Snippets extends SnippetsConstraint, Additional extends AdditionalAddPanelOptions = never> = { /** * CAUTION: Snippets with no arguments (like the one below) do unfortunately satisfy the `components` type costraint, but must be provided within the `snippets` object * @example * ```ts * {#snippet snippetWithNoArguments()} * {/snippet} * * * ``` * */ components?: Components; snippets?: Snippets; onReady?: (event: Parameters>[0] & { api: ExtendedGridAPI; }) => ReturnType>; theme?: Theme; } & ("orientation" extends keyof RawViewProps ? { orientation: Orientation | "HORIZONTAL" | "VERTICAL"; } : {}); type OverridenDockviewReactPropNames = "tabComponents" | "watermarkComponent" | "defaultTabComponent" | "rightHeaderActionsComponent" | "leftHeaderActionsComponent" | "prefixHeaderActionsComponent"; export type ModifiedProps, Snippets extends SnippetsConstraint, Additional extends AdditionalAddPanelOptions = never> = Omit, (keyof CustomizedViewProps) | (ViewType extends "pane" ? "headerComponents" : never) | (ViewType extends "dock" ? OverridenDockviewReactPropNames : never) | ("orientation" extends keyof RawViewProps ? "orientation" : never)> & CustomizedViewProps & ("orientation" extends keyof RawViewProps ? { orientation: Orientation | "HORIZONTAL" | "VERTICAL"; } : {}); export type AdditionalPaneProps; snippets: SnippetsConstraint<"pane">; }> = { headers?: Partial; }; export declare const extractCoreOptions: (props: In, propertyKeys: (keyof In | keyof Out)[]) => Out; export declare const prefix: { readonly component: "c_"; readonly snippet: "s_"; }; export declare const createExtendedAPI: , Snippets extends SnippetsConstraint>(type: ViewType, api: RawViewAPIs[ViewType], viewIndex: number) => { addComponentPanel: (name: string extends K ? never : K, ...params: SpreadAddComponentPanelOptions>) => Promise<{ exports: ComponentExports; panel: AddedPanelByView; reference: string; }>; addSnippetPanel: (name: string extends K ? never : K, ...params: SpreadAddSnippetPanelOptions>) => Promise<{ panel: AddedPanelByView; reference: string; }>; signal: (getter: () => T) => T; }; export declare const getComponentToMount: , Snippets extends SnippetsConstraint>(type: ViewType, components: Components | undefined, snippets: Snippets | undefined, { name }: Parameters["createComponent"]>[0]) => { component: ConstrainedComponent; propsPostProcessor: ((props: PanelComponentProps) => void) | undefined; name: string; }; export type Renderables = Record[string] | SnippetsConstraint[string]>; export type ExtractComponentsFromRenderables> = OmitNever<{ [k in keyof TRenderables]: TRenderables[k] extends Snippet ? never : TRenderables[k] extends ComponentsConstraint[string] ? TRenderables[k] : never; }>; export type ExtractSnippetsFromRenderables> = OmitNever<{ [k in keyof TRenderables]: TRenderables[k] extends Snippet ? TRenderables[k] : never; }>; export {};