import { MessageConnection } from 'vscode-jsonrpc'; import { IDisposable } from '../IDisposable'; export type MarshaledObjectLifetime = 'call' | 'explicit'; declare const enum JsonRpcMarshaled { /** * A real object is being marshaled. The receiver should generate a new proxy (or retrieve an existing one) that directs all RPC requests back to the sender referencing the value of the `handle` property. */ realObject = 1, /** * A marshaled proxy is being sent *back* to its owner. The owner uses the `handle` property to look up the original object and use it as the provided value. */ proxyReturned = 0 } export declare function registerReleaseMarshaledObjectCallback(connection: MessageConnection): void; /** * An interface to be implemented by objects that should be marshaled across RPC instead of serialized. * An object that also implements {@link IDisposable} will have its {@link IDisposable.dispose} method invoked * when the receiver disposes of the proxy. */ export interface RpcMarshalable { readonly _jsonRpcMarshalableLifetime: MarshaledObjectLifetime; readonly _jsonRpcOptionalInterfaces?: number[]; } export declare namespace RpcMarshalable { function is(value: any): value is RpcMarshalable; } /** * Describes the contract for JSON-RPC marshaled objects as specified by https://github.com/microsoft/vs-streamjsonrpc/blob/main/doc/general_marshaled_objects.md */ export interface IJsonRpcMarshaledObject { /** * A required property that identifies a marshaled object and its significance. */ __jsonrpc_marshaled: JsonRpcMarshaled; /** * A number that SHOULD be unique within the scope and duration of the entire JSON-RPC connection. * A single object is assigned a new handle each time it gets marshaled and each handle's lifetime is distinct. */ handle: number; /** * When set to `call`, the marshaled object may only be invoked until the containing RPC call completes. This value is only allowed when used within a JSON-RPC argument. No explicit release using `$/releaseMarshaledObject` is required. * When set to `explicit`, the marshaled object may be invoked until `$/releaseMarshaledObject` releases it. **This is the default behavior when the `lifetime` property is omitted.** */ lifetime?: MarshaledObjectLifetime; /** * Specify that the marshaled object implements additional known interfaces, where each array element represents one of these interfaces. * Each element is expected to add to some base functionality that is assumed to be present for this object even if `optionalInterfaces` were omitted. * These integers MUST be within the range of a signed, 32-bit integer. * Each element in the array SHOULD be unique. * A receiver MUST NOT consider order of the integers to be significant, and MUST NOT assume they will be sorted. */ optionalInterfaces?: number[]; } export interface MarshaledObjectProxy extends IDisposable { _jsonrpcMarshaledHandle: number; } export declare namespace MarshaledObjectProxy { function is(value: any): value is MarshaledObjectProxy; } export declare namespace IJsonRpcMarshaledObject { /** * Tests whether a given object implements {@link IJsonRpcMarshaledObject}. * @param value the value to be tested. * @returns true if the object conforms to the contract. */ function is(value: any): value is IJsonRpcMarshaledObject; /** * Creates a JSON-RPC serializable object that provides the receiver with a means to invoke methods on the object. * @param value The object to create a JSON-RPC marshalable wrapper around. */ function wrap(value: RpcMarshalable | MarshaledObjectProxy, jsonConnection: MessageConnection): IJsonRpcMarshaledObject; function cancelWrap(value: IJsonRpcMarshaledObject, jsonConnection: MessageConnection): void; /** * Produces a proxy for a marshaled object received over JSON-RPC. * @param value The value received over JSON-RPC that is expected to contain data for remotely invoking another object. * @returns An RPC proxy. This should be disposed of when done to release resources held by the remote party. */ function unwrap(value: IJsonRpcMarshaledObject, jsonConnection: MessageConnection): T; } export {};