@gamesberry/karmyc-core
Version:
A flexible and powerful layout management system for React applications
89 lines (88 loc) • 4.29 kB
TypeScript
import { EnhancedSpaceSharedState, EnhancedHistoryAction, Diff, HistoryResult, HistoryStats } from '../types/historyTypes';
export interface Space {
id: string;
name: string;
color?: string;
description?: string;
sharedState: EnhancedSpaceSharedState;
}
export interface SpaceState {
spaces: Record<string, Space>;
activeSpaceId: string | null;
openSpaceIds: string[];
errors: string[];
pilotMode: 'MANUAL' | 'AUTO';
}
export interface SpaceActions {
addSpace: (spaceData: {
name: string;
description?: string;
color?: string;
sharedState?: Partial<Omit<EnhancedSpaceSharedState, 'pastActions' | 'futureActions'>>;
}) => string | undefined;
removeSpace: (id: string) => void;
setActiveSpace: (id: string | null) => void;
setPilotMode: (mode: 'MANUAL' | 'AUTO') => void;
openSpace: (id: string) => void;
closeSpace: (id: string) => void;
updateSpace: (spaceData: Partial<Space> & {
id: string;
}) => void;
updateSpaceGenericSharedState: (payload: {
spaceId: string;
changes: Partial<Omit<EnhancedSpaceSharedState, 'pastActions' | 'futureActions'>>;
actionName?: string;
actionDescription?: string;
}) => void;
clearErrors: () => void;
startAction: (spaceId: string, actionId: string) => HistoryResult;
submitAction: (spaceId: string, name: string, diffs?: Diff[], allowIndexShift?: boolean, modifiedKeys?: string[]) => HistoryResult;
cancelAction: (spaceId: string) => HistoryResult;
undoEnhanced: (spaceId: string) => HistoryResult;
redoEnhanced: (spaceId: string) => HistoryResult;
setSelectionState: (spaceId: string, selectionState: any) => void;
subscribeToHistory: (spaceId: string, subscriber: (action: EnhancedHistoryAction) => void) => () => void;
canUndo: (spaceId: string) => boolean;
canRedo: (spaceId: string) => boolean;
getCurrentAction: (spaceId: string) => EnhancedHistoryAction | null;
getHistoryLength: (spaceId: string) => number;
getHistoryStats: (spaceId: string) => HistoryStats;
clearHistory: (spaceId: string) => void;
migrateSpaceHistory: (spaceId: string) => void;
getSpaceById: (id: string) => Space | undefined;
getAllSpaces: () => Record<string, Space>;
getActiveSpace: () => Space | null;
getActiveSpaceId: () => string | null;
getOpenSpaces: () => Space[];
getSpaceErrors: () => string[];
getPilotMode: () => 'MANUAL' | 'AUTO';
jumpToHistoryAction: (spaceId: string, actionId: string) => void;
}
export type SpaceStateType = SpaceState & SpaceActions;
export declare const useSpaceStore: import("zustand").UseBoundStore<Omit<Omit<Omit<import("zustand").StoreApi<SpaceStateType>, "setState"> & {
setState(nextStateOrUpdater: SpaceStateType | Partial<SpaceStateType> | ((state: import("immer").WritableDraft<SpaceStateType>) => void), shouldReplace?: boolean | undefined): void;
}, "setState"> & {
setState<A extends string | {
type: string;
}>(nextStateOrUpdater: SpaceStateType | Partial<SpaceStateType> | ((state: import("immer").WritableDraft<SpaceStateType>) => void), shouldReplace?: boolean | undefined, action?: A | undefined): void;
}, "persist"> & {
persist: {
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SpaceStateType, {
spaces: Record<string, Partial<Omit<Space, "sharedState">> & {
sharedState: Partial<Omit<EnhancedSpaceSharedState, "pastActions" | "futureActions" | "subscribers">>;
}>;
activeSpaceId: string | null;
}>>) => void;
clearStorage: () => void;
rehydrate: () => Promise<void> | void;
hasHydrated: () => boolean;
onHydrate: (fn: (state: SpaceStateType) => void) => () => void;
onFinishHydration: (fn: (state: SpaceStateType) => void) => () => void;
getOptions: () => Partial<import("zustand/middleware").PersistOptions<SpaceStateType, {
spaces: Record<string, Partial<Omit<Space, "sharedState">> & {
sharedState: Partial<Omit<EnhancedSpaceSharedState, "pastActions" | "futureActions" | "subscribers">>;
}>;
activeSpaceId: string | null;
}>>;
};
}>;