@launchmenu/core
Version:
An environment for visual keyboard controlled applets
153 lines • 6.57 kB
TypeScript
/// <reference types="react" />
import { DataCacher, Field, IDataHook, IDataRetriever, Observer } from "model-react";
import { IOContext } from "../../context/IOContext";
import { IPrioritizedMenuItem } from "../../menus/menu/_types/IPrioritizedMenuItem";
import { IQuery } from "../../menus/menu/_types/IQuery";
import { SettingsContext } from "../../settings/SettingsContext";
import { KeyEvent } from "../../keyHandler/KeyEvent";
import { TextField } from "../../textFields/TextField";
import { LaunchMenu } from "../LaunchMenu";
import { IApplet } from "../applets/_types/IApplet";
import { LMSessionMenu } from "./LMSessionMenu";
import { IMenuItem } from "../../menus/items/_types/IMenuItem";
import { IUUID } from "../../_types/IUUID";
import { UILayer } from "../../uiLayers/standardUILayer/UILayer";
import { IMenuSearchable } from "../../actions/types/search/_types/IMenuSearchable";
import { IActionBinding } from "../../actions/_types/IActionBinding";
import { IStandardUILayerData } from "../../uiLayers/standardUILayer/_types/IStandardUILayerData";
import { SearchExecuter } from "../../utils/searchExecuter/SearchExecuter";
/**
* An application session
*/
export declare class LMSession {
/** The view that can be used to render this session */
view: JSX.Element;
/** The IO context for this session */
context: IOContext;
/** The home UI layer */
homeLayer: UILayer;
/** The unique runtime id of this session */
readonly ID: string;
/** The LaunchMenu runtime instance this session is part of */
LM: LaunchMenu;
/** The main search field of this session */
searchField: TextField;
/** The main results menu of this session */
menu: LMSessionMenu;
/** Additional applets for this session */
extraApplets: Field<IApplet<import("../../settings/_types/IIdentifiedSettingsConfig").IIdentifiedSettingsConfig<import("../../_types/IJSON").IJSON, import("../../settings/_types/ISettingsFolderMenuItem").ISettingsFolderMenuItem<import("../../settings/_types/IRenderableSettingsTree").IRenderableSettingsTree>>>[]>;
/** Additional searchable sources for this session */
extraSearchables: Field<import("../../utils/searchExecuter/_types/ISearchable").ISearchable<IQuery, IPrioritizedMenuItem>[]>;
/** The search executer responsible for making the searches */
searchExecuter: SearchExecuter<IQuery, IPrioritizedMenuItem>;
/** The applet that's currently selected */
selectedApplet: Field<IApplet<import("../../settings/_types/IIdentifiedSettingsConfig").IIdentifiedSettingsConfig<import("../../_types/IJSON").IJSON, import("../../settings/_types/ISettingsFolderMenuItem").ISettingsFolderMenuItem<import("../../settings/_types/IRenderableSettingsTree").IRenderableSettingsTree>>> | null>;
observers: {
settingsContext?: Observer<SettingsContext>;
search?: Observer<string>;
menuCursor?: Observer<IMenuItem | null>;
};
/** Listeners that listen for close events */
protected closeListeners: (() => void)[];
/**
* Creates a new app session
* @param lm The LM instance this is a session for
*/
constructor(lm: LaunchMenu);
/**
* Disposes of all data attached to this session
*/
destroy(): void;
/**
* Emits a key event to the session
* @param event The event to dispatch
* @returns Whether the event was caught
*/
emit(event: KeyEvent): Promise<boolean>;
/**
* Initializes the ioContext for this session
*/
protected setupContext(): void;
/**
* Retrieves the context menu items that should be global in this session
* @returns The menu items
*/
protected getGlobalContextMenuBindings(): IDataRetriever<IActionBinding[]>;
/**
* Initializes the view for this session
*/
protected setupView(): void;
/**
* Initializes all the UI
*/
protected setupUI(): Promise<void>;
/**
* Initializes the menu to be displayed
*/
protected setupMenu(): Promise<(IStandardUILayerData & {
onClose: () => void;
})[]>;
/**
* Initializes the field to be displayed
*/
protected setupField(): Promise<IStandardUILayerData[]>;
/**
* Adds a listener that listens for close events
* @param listener The listener to be added
*/
addCloseListener(listener: () => void): void;
/**
* Removes a listener that listens for close events
* @param listener The listener to be removed
*/
removeCloseListener(listener: () => void): void;
/**
* Emits the close event
*/
protected emitClose(): void;
/**
* Checks whether this session is on the "home screen", I.e. has no menu opens on top
* @param hook The hook to subscribe to changes
* @returns Whether on the home screen
*/
isHome(hook?: IDataHook): boolean;
/**
* Closes all layers and removes the search input
* @param close Whether to also exit LM
*/
goHome(close?: boolean): Promise<void>;
/**
* Retrieves the applets initialized with this session data
* @param hook The hook to subscribe to changes
* @returns The initialized applets
*/
getApplets(hook?: IDataHook): IApplet[];
/**
* Retrieves the searchables in this session
* @param hook The hook to subscribe to changes
* @returns The searchables
*/
getSearchables(hook?: IDataHook): IMenuSearchable[];
/**
* The applet data obtained from the applet manager
*/
appletData: DataCacher<{
applet: IApplet;
initializedApplet: IApplet;
version: IUUID;
searchable?: import("../../utils/searchExecuter/_types/ISearchable").ISearchable<IQuery, IPrioritizedMenuItem> | undefined;
}[]>;
/**
* Calls the reload of the given applet and sets up the disposers (Modifies the onCloseSession of the applet)
* @param applet The applet to call reload on
*/
protected callAppletReload(applet: IApplet): void;
/**
* Wraps the search method of an applet to inject the applets category into the results
* @param applet The applet to retrieve the searchable with results for
* @param ID The ID of the searchable
* @returns The menu searchable
*/
protected getAppletSearchWithCategory(applet: IApplet, ID?: IUUID): IMenuSearchable;
}
//# sourceMappingURL=LMSession.d.ts.map