Datalayer VS Code Extension - v0.0.4
    Preparing search index...

    Class BaseDocumentProvider<TDocument>Abstract

    Abstract base class for document providers. Handles common provider patterns including webview lifecycle, message routing, and request/response.

    Type Parameters

    • TDocument extends vscode.CustomDocument

      The document type (NotebookDocument or LexicalDocument)

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    _callbacks: Map<string | number, (response: unknown) => void> = ...
    _context: ExtensionContext
    _messageRouter: DocumentMessageRouter
    _networkBridge: NetworkBridgeService
    _onDidChangeCustomDocument: EventEmitter<CustomDocumentEditEvent<TDocument>> = ...

    Event emitter for document changes. Subclasses should fire this event when documents change.

    _requestId: number = 1
    _runtimeBridge: RuntimeBridgeService
    onDidChangeCustomDocument: Event<CustomDocumentEditEvent<TDocument>> = ...

    Event for document changes (required by CustomEditorProvider interface).

    Methods

    • Backs up the document. Default implementation throws - subclasses should override if needed.

      Parameters

      • _document: TDocument

        Document to backup

      • _context: CustomDocumentBackupContext

        Backup context

      • _cancellation: CancellationToken

        Cancellation token

      Returns Thenable<CustomDocumentBackup>

      Promise resolving to backup information

    • Handles messages received from the webview. Delegates to the message router for all message types.

      Parameters

      • webviewPanel: WebviewPanel

        The webview panel that sent the message

      • document: TDocument

        The document associated with the webview

      • message: ExtensionMessage

        The message from the webview

      Returns Promise<void>

    • Opens a custom document. Subclasses must implement document creation logic.

      Parameters

      • uri: Uri

        Document URI

      • openContext: { backupId?: string }

        Open context with backup information

      • token: CancellationToken

        Cancellation token

      Returns Promise<TDocument>

      Promise resolving to the document

    • Posts a message to the webview without expecting a response.

      Parameters

      • panel: WebviewPanel

        Target webview panel

      • type: string

        Message type

      • body: unknown

        Message body

      • Optionalid: string

        Optional message ID

      Returns void

    • Posts a message to the webview and waits for a response. Uses the request/response pattern with requestId tracking.

      Type Parameters

      • R = unknown

      Parameters

      • panel: WebviewPanel

        Target webview panel

      • type: string

        Message type

      • body: unknown

        Message body

      Returns Promise<R>

      Promise resolving to the response

    • Registers all message handlers with the message router. Called during constructor initialization. Subclasses can override to add custom handlers.

      Returns void

    • Resolves a custom editor for a document. Subclasses must implement webview setup logic.

      Parameters

      • document: TDocument

        The document to display

      • webviewPanel: WebviewPanel

        The webview panel to use

      • token: CancellationToken

        Cancellation token

      Returns Promise<void>

      Promise that resolves when editor is ready

    • Reverts the document to its saved state. Default implementation throws - subclasses should override if needed.

      Parameters

      • _document: TDocument

        Document to revert

      • _cancellation: CancellationToken

        Cancellation token

      Returns Thenable<void>

      Promise that resolves when revert is complete

    • Saves the document. Default implementation throws - subclasses should override if saving is supported.

      Parameters

      • _document: TDocument

        Document to save

      • _cancellation: CancellationToken

        Cancellation token

      Returns Thenable<void>

      Promise that resolves when save is complete

    • Saves the document to a new location. Default implementation throws - subclasses should override if needed.

      Parameters

      • _document: TDocument

        Document to save

      • _destination: Uri

        Destination URI

      • _cancellation: CancellationToken

        Cancellation token

      Returns Thenable<void>

      Promise that resolves when save is complete