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

    Custom editor provider for Jupyter notebooks with dual-mode support. Handles both local file-based notebooks and collaborative Datalayer notebooks with runtime management, webview communication, and real-time synchronization.

    Hierarchy (View Summary)

    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<NotebookDocument>,
    > = ...

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

    _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.

    autoConnectService: AutoConnectService = ...

    Auto-connect service for automatically connecting to runtimes

    documents: Map<string, NotebookDocument> = ...

    Maps document URIs to NotebookDocument instances. Used to retrieve documents for makeEdit calls from webview content changes.

    onDidChangeCustomDocument: Event<CustomDocumentEditEvent<NotebookDocument>> = ...

    Event for document changes (required by CustomEditorProvider interface).

    webviews: WebviewCollection = ...

    Tracks all known webviews

    newNotebookFileId: number = 1
    viewType: "datalayer.jupyter-notebook"

    Methods

    • Creates a backup of a custom document.

      Parameters

      • document: NotebookDocument

        Document to backup

      • context: CustomDocumentBackupContext

        Backup context with destination

      • cancellation: CancellationToken

        Cancellation token

      Returns Thenable<CustomDocumentBackup>

      Promise resolving to backup descriptor

    • Clean LLM completion output by removing markdown code blocks.

      Parameters

      • completion: string

        Raw completion from LLM

      Returns string

      Cleaned completion

    • Proactively create LSP virtual documents for all Python and Markdown cells. This allows Pylance to start analyzing BEFORE the webview finishes loading, providing instant completions when the user presses Tab.

      Native VS Code notebooks create TextDocuments immediately when opening, giving Pylance time to analyze. Datalayer notebooks now do the same!

      Parameters

      • notebookId: string

        Unique notebook identifier

      • documentData: Uint8Array

        Raw .ipynb file bytes

      Returns Promise<void>

    • Get the static HTML used for the editor's webviews.

      Parameters

      • webview: Webview

        The webview instance

      Returns string

      HTML content for the webview

    • Get LLM completion from VS Code Language Model API.

      Parameters

      • prefix: string

        Code before cursor

      • suffix: string

        Code after cursor

      • language: string

        Programming language

      Returns Promise<string>

      Completion string or null

    • 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 Promise<Runner>

      The created Runner instance

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

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

    • Resolves a custom editor by setting up the webview and initializing communication.

      Parameters

      • document: NotebookDocument

        The notebook document to display

      • webviewPanel: WebviewPanel

        The webview panel for the editor

      • _token: CancellationToken

        Cancellation token

      Returns Promise<void>

      Promise that resolves when editor is ready

    • Send a message to a webview panel and wait for a response. Uses the request/response pattern inherited from BaseDocumentProvider.

      Parameters

      • panel: WebviewPanel

        Webview panel to send message to

      • message: unknown

        Message to send (should include type and requestId)

      • requestId: string

        Request ID to match response

      Returns Promise<unknown>

      Promise resolving to the response

    • Attempts to auto-connect the document to a runtime using configured strategies.

      Parameters

      • documentUri: Uri

        URI of the document being opened

      Returns Promise<void>

    • Registers the notebook editor provider and commands.

      Parameters

      • context: ExtensionContext

        Extension context for resource management

      Returns Disposable

      Disposable for cleanup