import { ApiError, AuthenticationData, DeviceData, EditorFileData, FileData, LiveEditorApiComponent, MediaOptions, OnboardingInfo, PreviewSettings, ProjectData, PublishResult, SiteData, UserData, WorkspaceData } from './api'; import { DataStorage } from '../utility/dataStorage'; import { AmagakiState } from '../projectType/amagaki/amagakiState'; import { Base } from '@blinkk/selective-edit/dist/mixins'; import { EditorHistory } from './recent'; import { FeatureManager } from '../utility/featureManager'; import { GrowState } from '../projectType/grow/growState'; import { ProjectTypeComponent } from '../projectType/projectType'; export declare const STORAGE_SCHEME = "live.scheme"; declare const EditorState_base: { new (...args: any[]): { _listeners?: Record void)[]> | undefined; addListener(eventName: string, callback: (...args: any) => void): void; readonly listeners: Record void)[]>; triggerListener(eventName: string, ...args: any): void; }; } & typeof Base; /** * Track the references to the editor state. * * These is done as a property of a class so that it can be used * with part configs and always have access to the latest * value without each part having to request the same information. */ export declare class EditorState extends EditorState_base { /** * API for retrieving data for the editor. */ api: LiveEditorApiComponent; /** * Information about the authentication for account management. */ authentication?: AuthenticationData | null; /** * Array of devices supported for previews. */ devices?: Array; /** * Keep track of backlogged error callbacks. */ protected errorCallbacks: Record void>>; /** * Editor experiments mangager. */ experiments: FeatureManager; /** * Editor feature mangager. */ features: FeatureManager; /** * Files in the project that can be edited by the editor. * * Value is null when fails to load. */ files?: Array | null; /** * Editor file loaded in the editor. * * Value is null when the file is not found or fails to load. */ file?: EditorFileData | null; /** * File preview url */ filePreviewUrl?: string | null; /** * Editor history. */ history: EditorHistory; /** * Path being actively loaded. * * Only set when a file is being loaded. */ loadingFilePath?: string; /** * Current onboarding status. */ onboardingInfo?: OnboardingInfo; /** * Pending file waiting to be loaded. * * When the editor loads the path information is determined from * the URL, but the file cannot be loaded until the onboarding * process is complete. The path is stored to be loaded after the * onboarding is complete. */ pendingFile?: FileData; /** * Preview server settings. * * Value is null when fails to load. */ previewConfig?: PreviewSettings | null; /** * Project type in use. */ projectType?: ProjectTypeComponent; /** * Project information. * * Value is null when fails to load. */ project?: ProjectData | null; /** * Project types states. */ projectTypes: StateProjectTypes; /** * Keep track of active promises to keep from requesting the same data * multiple times. */ protected promises: Record | boolean>; /** * Whether the user prefers dark mode. */ prefersDarkScheme: boolean; /** * Scheme for the UI. */ scheme?: Schemes | string; /** * Site configuration for the editor. */ site?: SiteData; protected storage: DataStorage; /** * Keep track of backlogged success callbacks. */ protected successCallbacks: Record void>>; /** * Users in the project that have access to the editor. */ users?: Array; /** * Workspace in use in the editor. * * Value is null when fails to load. */ workspace?: WorkspaceData | null; /** * Workspaces available to use in the editor. * * Value is null when fails to load. */ workspaces?: Array | null; constructor(api: LiveEditorApiComponent); /** * Lazy load of authentication data. * * Understands the null state when there is an error requesting. */ authenticationOrGetAuthentication(): AuthenticationData | undefined | null; checkOnboarding(callback?: (info: OnboardingInfo) => void, callbackError?: (error: ApiError) => void): void; copyFile(originalPath: string, path: string, callback?: (file: FileData) => void, callbackError?: (error: ApiError) => void): void; createFile(path: string, callback?: (file: FileData) => void, callbackError?: (error: ApiError) => void): void; createWorkspace(base: WorkspaceData, workspace: string, callback?: (workspace: WorkspaceData) => void, callbackError?: (error: ApiError) => void): void; /** * When a callback is specified for a state load it does not * always have a promise to bind to. Store the callback to be * manually be completed after the promise is complete. * * @param promiseKey Key to identify the stored promise. * @param callback Callback after the promise is completed. */ protected delayCallbacks(promiseKey: string, callback?: (value: any) => void, errorCallback?: (value: any) => void): void; deleteFile(file: FileData, callback?: () => void, callbackError?: (error: ApiError) => void): void; /** * Lazy load of files data. * * Understands the null state when there is an error requesting. */ filesOrGetFiles(): Array | undefined | null; /** * Get the authentication information to know how to handle accounts. * * Used to understand when and how to show account information. */ getAuthentication(callback?: (devices: Array) => void, callbackError?: (error: ApiError) => void): AuthenticationData | undefined | null; getDevices(callback?: (devices: Array) => void, callbackError?: (error: ApiError) => void): Array | undefined; getFile(file: FileData, callback?: (file: EditorFileData) => void, callbackError?: (error: ApiError) => void): EditorFileData | undefined | null; getFiles(callback?: (files: Array) => void, callbackError?: (error: ApiError) => void): Array | undefined | null; /** * When uploading a file the local field is allowed to override the default * remote configuration. If the `remote` config is undefined no options are * specified and can use the global configurations to determine which * configuration should be used. */ getMediaOptions(useRemote?: boolean): MediaOptions | undefined; getPreviewConfig(callback?: (previewSettings: PreviewSettings | null) => void, callbackError?: (error: ApiError) => void): PreviewSettings | null | undefined; getProject(callback?: (project: ProjectData) => void, callbackError?: (error: ApiError) => void): ProjectData | undefined | null; getWorkspace(callback?: (workspace: WorkspaceData) => void, callbackError?: (error: ApiError) => void): WorkspaceData | undefined | null; getWorkspaces(callback?: (workspaces: Array) => void, callbackError?: (error: ApiError) => void): Array | undefined | null; /** * After a promise is completed handle the cleanup and trigger * listeners and callbacks appropriately. */ protected handleDataAndCleanup(promiseKey: string, ...values: any): void; /** * After a promise fails handle the cleanup and trigger * listeners and callbacks appropriately. */ protected handleErrorAndCleanup(promiseKey: string, error: ApiError, options?: ErrorHandlingOptions): void; /** * Determines if there is an existing promise for a given key. * * @param key Key identifying the promise or loading status. */ inProgress(key: string): boolean; loadWorkspace(workspace: WorkspaceData, callback?: (workspace: WorkspaceData) => void, callbackError?: (error: ApiError) => void): void; /** * Lazy load of project data. * * Understands the null state when there is an error requesting. */ previewConfigOrGetPreviewConfig(): PreviewSettings | undefined | null; protected processPendingFilePath(): void; /** * Lazy load of project data. * * Understands the null state when there is an error requesting. */ projectOrGetProject(): ProjectData | undefined | null; get projectId(): string | undefined; publish(workspace: WorkspaceData, data: Record, callback?: (result: PublishResult) => void, callbackError?: (error: ApiError) => void): void; /** * Signal for the editor to re-render. */ render(): void; saveFile(file: EditorFileData, isRawEdit: boolean, callback?: (file: EditorFileData) => void, callbackError?: (error: ApiError) => void): void; /** * Sets the color scheme to use for the UI. * * @param scheme Scheme to use for the UI. */ setScheme(scheme: Schemes): void; setProjectType(projectType: ProjectTypeComponent): void; protected updateTitle(): void; protected updateFilePreviewUrl(path: string): void; /** * Lazy load of workspace data. * * Understands the null state when there is an error requesting. */ workspaceOrGetWorkspace(): WorkspaceData | undefined | null; /** * Lazy load of workspaces data. * * Understands the null state when there is an error requesting. */ workspacesOrGetWorkspaces(): Array | undefined | null; } export interface StateProjectTypes { amagaki: AmagakiState; grow: GrowState; } export declare const DEFAULT_DEVICES: DeviceData[]; /** * Schemes available for the editor UI. */ export declare enum Schemes { Light = "Light", Dark = "Dark" } /** * Promise keys used for tracking in operation promises for the state. */ export declare enum StatePromiseKeys { CheckOnboarding = "CheckOnboarding", CopyFile = "CopyFile", CreateFile = "CreateFile", CreateWorkspace = "CreateWorkspace", DeleteFile = "DeleteFile", GetAuthentication = "GetAuthentication", GetDevices = "GetDevices", GetFile = "GetFile", GetFiles = "GetFiles", GetPreviewConfig = "GetPreviewConfig", GetProject = "GetProject", GetWorkspace = "GetWorkspace", GetWorkspaces = "GetWorkspaces", LoadWorkspace = "LoadWorkspace", Publish = "Publish", SaveFile = "SaveFile", SetScheme = "SetScheme", SetProjectType = "SetProjectType" } export interface ErrorHandlingOptions { /** * When true, prevents opening the full notification window with * error details. */ preventDefaultHandling?: boolean; /** * When true, prevents showing a notification for the error. */ preventNotification?: boolean; } export {};