@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Interface ManagedWebview<S>

    A webview the framework manages: HTML, a typed RPC channel, and cleanup that happens once however the content goes away.

    interface ManagedWebview<S extends WebviewRpcSchema = WebviewRpcSchema> {
        cspSource: string;
        rpc: WebviewRpc<S>;
        asWebviewUri(extensionRelativePath: string): string;
        onMessage(listener: (message: unknown) => void): PlatformRegistration;
        post(message: unknown): Promise<boolean>;
        setHtml(html: string): void;
        setHtmlFromTemplate(
            templatePath: string,
            variables?: Readonly<Record<string, string>>,
        ): Promise<void>;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index
    cspSource: string

    The source a content security policy has to allow.

    Typed request/response and events over the raw message channel. Types do not perform runtime payload validation at the webview boundary.

    • Rewrites an extension-relative path into a uri the content may load.

      Parameters

      • extensionRelativePath: string

      Returns string

    post

    • post(message: unknown): Promise<boolean>

      Sends a raw message accepted by the platform's webview serialization boundary. For request/response, use ManagedWebview.rpc. Resolves false when the platform reports that the content is no longer live.

      Parameters

      • message: unknown

      Returns Promise<boolean>

    • Replaces the rendered HTML. The caller owns the complete document and its CSP; this method performs no sanitization.

      Parameters

      • html: string

      Returns void

    • Renders a template file shipped with the extension.

      Placeholders:

      • {{name}} — the value, HTML-escaped
      • {{raw:name}} — the value verbatim, which is an injection vector unless you produced the value yourself
      • {{webviewUri:media/app.js}} — a uri the content may actually load

      Parameters

      • templatePath: string
      • Optionalvariables: Readonly<Record<string, string>>

      Returns Promise<void>

      await panel.setHtmlFromTemplate('media/editor.html', {
      title: 'Editor',
      cspSource: panel.cspSource,
      });