import { IWorkspacePaneData } from '../models'; import { IUndoState, IUndoObject } from './useUndo'; /** * Merges saved session/project data with default values. * @param saved - Saved session/project data (will be null/undefined if not present). * @param defaultValue - Default value to use as base. * @returns Merged data combining default and saved values. * @internal */ export declare function mergeData(saved: unknown, defaultValue: T): T; /** * Calculate the maximum number of active intervals allowed based on workspace panes. * @param numPanes - Number of active workspace panes * @returns Maximum allowed active intervals * @internal */ export declare function calculateMaxActiveProjectDataIntervals(numPanes: number): number; /** * A hook for data that should be saved to the current project. * @param id - The unique id of the view. * @param slice - The slice name for the project data. * @param defaultValue - The default value or a function that returns the default value. * @param loadedCallback - Optional callback invoked once after data is loaded. * @returns An object with a flag indicating if the project data has been initialized, the current project data and a setter callback. */ export declare const useProjectDataSlice: (id: number, slice: string, defaultValue: T | (() => T), loadedCallback?: (value: T) => void) => [T, React.Dispatch>, boolean]; /** * A hook for data that should be saved to the current project. * @param id - The unique id of the view. * @param defaultValue - The default value or a function that returns the default value. * @returns An object with a flag indicating if the project data has been initialized, the current project data and a setter callback. */ export declare const useProjectData: (id: number, defaultValue: T | (() => T)) => { projectDataIsInitialized: boolean; projectData: T; setProjectData: React.Dispatch>; }; /** * Tells the host that a session data entry is being sent, and read back, as the JSON it is stored * as rather than as the value itself. * * @remarks * Both halves of the exchange have to say so, because the host still serves SDKs that send and * expect values: an older one leaves this out and is answered exactly as it always was. A host that * predates the option ignores it and answers with the value, which deserializeSessionData takes as * it is - so a new SDK works on an old host too, just without keeping its Longs. * @internal */ export declare const SESSION_DATA_SERIALIZED: { readonly serialized: true; }; /** * Converts session data into a string that can be sent through IPC. * @remarks * Session data takes the same values as project data, which is stored as a string produced with * jsonReplacer. Handing the raw object to Electron's Structured Clone Algorithm instead would drop * the prototypes of values such as Long, so the two hooks are serialized the same way. * * The encoder identifies a Long by a prototype flag, which Structured Clone strips, so this has to * run here rather than in the host: a Long that has already crossed IPC can no longer be recognised * as one and would be stored as a plain \{ low, high, unsigned \} object. * @param state - The session data to serialize. * @returns The serialized session data. * @internal */ export declare function serializeSessionData(state: unknown): string; /** * Converts session data received through IPC back into its original value. * @param saved - The stored session data, or null/undefined when nothing has been saved yet. * @returns The deserialized session data, or undefined if it could not be read. * @internal */ export declare function deserializeSessionData(saved: unknown): unknown; /** * Calculate the maximum number of active intervals allowed based on workspace panes. * @param numPanes - Number of active workspace panes * @returns Maximum allowed active intervals * @internal */ export declare function calculateMaxActiveSessionDataIntervals(numPanes: number): number; /** * A hook for data that should be saved to the session data. * @param id - The unique id of the view. * @param defaultValue - The default value or a function that returns the default value. * @param loadedCallback - Optional callback invoked once after data is loaded. * @returns An object with the current session data, a setter, and an initialization flag. */ export declare const useSessionData: (id: number, defaultValue: T | (() => T), loadedCallback?: (value: T) => void) => { sessionDataIsInitialized: boolean; sessionData: T; setSessionData: React.Dispatch>; }; /** * A hook for persistent (session) data tied to a specific view slice. * @param id - The unique id of the view. * @param slice - The slice name for the session data. * @param defaultValue - The default value or a function that returns the default value. * @param loadedCallback - Optional callback invoked once after data is loaded. * @returns [state, setState, loaded] the current data, setter, and loaded flag. */ export declare function useSessionDataSlice(id: number, slice: string, defaultValue: T | (() => T), loadedCallback?: (value: T) => void): [T, React.Dispatch>, boolean]; /** * Custom hook to manage undo/redo state using session data storage. * @param id - The unique id of the view. * @param slice - The slice name for the session data. * @param initialState - The initial undo state. * @returns [undoObject, loaded] - An undo object for managing state history and loaded flag. */ export declare function useUndoSessionDataSlice(id: number, slice: string, initialState?: IUndoState): [IUndoObject, boolean]; /** * Hook to get/set a workspace pane by id. */ export declare const useWorkspacePaneWithId: (id: number) => IWorkspacePaneData | null; /** * Callback type for when the view goes online. * @param isNewView - Whether the view is newly created. * @param isMounting - Whether the view is mounting. * @param onlineCounter - The number of times CanKing has gone online. */ export type OnGoingOnlineCallback = (isNewView: boolean, isMounting: boolean, onlineCounter: number) => void; /** * Callback type for when the view goes offline. * @param isNewView - Whether the view is newly created. * @param isMounting - Whether the view is mounting. * @param onlineCounter - The number of times CanKing has gone online. */ export type OnGoingOfflineCallback = (isNewView: boolean, isMounting: boolean, onlineCounter: number) => void; /** * Custom hook to synchronize session state with online/offline status changes. * @param parentIsInitialized - Whether the parent component is initialized. * @param id - The unique id of the view. * @param onGoingOnline - Callback function to handle going online. * @param onGoingOffline - Callback function to handle going offline. * @returns The current online status. */ export declare function useOnlineStatusSync(parentIsInitialized: boolean, id: number, onGoingOnline: OnGoingOnlineCallback, onGoingOffline: OnGoingOfflineCallback): boolean;