import { inject, type InjectionKey, ref, provide, getCurrentInstance } from "vue"; import { Bound } from "./utils"; export type UITool = | "track-unit-type" | "eraser" | "sticking"; export class AppStateStore extends Bound { selectedTool = ref("track-unit-type"); activeTrackUnitType = ref(0); activeStickingType = ref(1); unitMouseStart = ref(null); selectingUnits = ref(false); deselectingUnits = ref(false); } const AppStateStoreKey = Symbol("AppStateStore") as InjectionKey; export function useAppStateStore(): AppStateStore { return inject(AppStateStoreKey, () => { const store = new AppStateStore(); getCurrentInstance()?.appContext?.app.provide(AppStateStoreKey, store); return store; }, true); }