Datalayer VS Code Extension - v0.0.9
    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> = ...

    Map of request ID to response callbacks for request/response message pattern.

    _context: ExtensionContext

    VS Code extension context providing access to storage, subscriptions, etc.

    _messageRouter: DocumentMessageRouter

    Message router for handling webview messages and routing to appropriate handlers.

    _networkBridge: NetworkBridgeService

    Network bridge service for HTTP/WebSocket communication between extension and webview.

    _onDidChangeCustomDocument: EventEmitter<CustomDocumentEditEvent<TDocument>> = ...

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

    _requestId: number = 1

    Counter for generating unique request IDs in request/response pattern.

    _runners: Map<WebviewPanel, Runner> = ...

    Map of webview panels to their Runner instances. Runners handle tool execution via the BridgeExecutor pattern.

    _runtimeBridge: RuntimeBridgeService

    Runtime bridge service for managing runtime lifecycle and selection.

    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

    • Gets the Runner for a specific webview panel.

      Parameters

      • webviewPanel: WebviewPanel

        The webview panel

      Returns Runner

      The Runner instance, or undefined if not initialized

    • Initializes a Runner for a webview panel. Subclasses should call this in their resolveCustomEditor implementation.

      The Runner uses a BridgeExecutor to send tool execution requests to the webview, where they are executed by the webview's own Runner with DefaultExecutor.

      Parameters

      • webviewPanel: WebviewPanel

        The webview panel to create a Runner for

      Returns Runner

      The created Runner instance

      async resolveCustomEditor(document, webviewPanel, token) {
      // Initialize Runner for this webview
      this.initializeRunnerForWebview(webviewPanel);

      // ... rest of setup
      }
    • 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