/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type { LexicalBuilder } from '../LexicalBuilder.js'; import { type AnyLexicalExtension, type ExtensionBuildState, type ExtensionInitState, type ExtensionRegisterState, type InitialEditorConfig, type LexicalEditor, type LexicalExtensionConfig, type LexicalExtensionDependency, type LexicalExtensionInit, type LexicalExtensionOutput } from 'lexical'; export declare const ExtensionRepStateIds: { readonly unmarked: 0; readonly temporary: 1; readonly permanent: 2; readonly configured: 3; readonly initialized: 4; readonly built: 5; readonly registered: 6; readonly afterRegistration: 7; }; interface UnmarkedState { id: (typeof ExtensionRepStateIds)['unmarked']; } interface TemporaryState { id: (typeof ExtensionRepStateIds)['temporary']; } interface PermanentState { id: (typeof ExtensionRepStateIds)['permanent']; } interface ConfiguredState { id: (typeof ExtensionRepStateIds)['configured']; config: LexicalExtensionConfig; registerState: ExtensionInitState; } interface InitializedState extends Omit, 'id' | 'registerState'> { id: (typeof ExtensionRepStateIds)['initialized']; initResult: LexicalExtensionInit; registerState: ExtensionBuildState>; } interface BuiltState extends Omit, 'id' | 'registerState'> { id: (typeof ExtensionRepStateIds)['built']; initResult: LexicalExtensionInit; output: LexicalExtensionOutput; registerState: ExtensionRegisterState, LexicalExtensionOutput>; } interface RegisteredState extends Omit, 'id'> { id: (typeof ExtensionRepStateIds)['registered']; } interface AfterRegistrationState extends Omit, 'id'> { id: (typeof ExtensionRepStateIds)['afterRegistration']; } export type ExtensionRepState = UnmarkedState | TemporaryState | PermanentState | ConfiguredState | InitializedState | BuiltState | RegisteredState | AfterRegistrationState; export declare function isExactlyUnmarkedExtensionRepState(state: ExtensionRepState): state is UnmarkedState; export declare function isExactlyPermanentExtensionRepState(state: ExtensionRepState): state is PermanentState; export declare function applyTemporaryMark(state: ExtensionRepState): TemporaryState; export declare function applyPermanentMark(state: ExtensionRepState): PermanentState; export declare function applyConfiguredState(state: PermanentState, config: LexicalExtensionConfig, registerState: ExtensionInitState): ConfiguredState; export declare function applyInitializedState(state: ConfiguredState, initResult: LexicalExtensionInit, registerState: ExtensionBuildState>): InitializedState; export declare function applyBuiltState(state: InitializedState, output: LexicalExtensionOutput, registerState: ExtensionRegisterState, LexicalExtensionOutput>): BuiltState; export declare function applyRegisteredState(state: BuiltState): never; export declare function applyAfterRegistrationState(state: RegisteredState): AfterRegistrationState; export declare function rollbackToBuiltState(state: AfterRegistrationState): BuiltState; /** * @internal */ export declare class ExtensionRep { builder: LexicalBuilder; configs: Set>>; _dependency?: LexicalExtensionDependency; _peerNameSet?: Set; extension: Extension; state: ExtensionRepState; _signal?: AbortSignal; constructor(builder: LexicalBuilder, extension: Extension); mergeConfigs(): LexicalExtensionConfig; init(editorConfig: InitialEditorConfig): void; build(editor: LexicalEditor): void; register(editor: LexicalEditor, signal: AbortSignal): undefined | (() => void); afterRegistration(editor: LexicalEditor): undefined | (() => void); getSignal(): AbortSignal; getInitResult(): LexicalExtensionInit; getInitPeer(name: PeerExtension['name']): undefined | Omit, 'output' | 'init'>; getExtensionInitDependency(): Omit, 'output' | 'init'>; getPeer(name: PeerExtension['name']): undefined | LexicalExtensionDependency; getInitDependency(dep: Dependency): Omit, 'output' | 'init'>; getDependency(dep: Dependency): LexicalExtensionDependency; getState(): AfterRegistrationState; getDirectDependentNames(): ReadonlySet; getPeerNameSet(): ReadonlySet; getExtensionDependency(): LexicalExtensionDependency; } export {};