UNPKG

@comapeo/ipc

Version:
44 lines (43 loc) 2.01 kB
/** * @param {MessagePortLike} messagePort * @param {Parameters<typeof createClient>[1]} [opts] * * @returns {ComapeoCoreClientApi} */ export function createComapeoCoreClient(messagePort: MessagePortLike, opts?: Parameters<typeof createClient>[1]): ComapeoCoreClientApi; /** * @param {ComapeoCoreClientApi} client client created with `createComapeoCoreClient` * @returns {Promise<void>} */ export function closeComapeoCoreClient(client: ComapeoCoreClientApi): Promise<void>; /** * @typedef {ClientApi<ComapeoServicesApi>} ComapeoServicesClientApi */ /** * Create a client for the app-provided services that live outside * `@comapeo/core` — the map server today, and the blob and icon servers in the * future (once extracted from core). The host app implements the server side; * see {@link ComapeoServicesApi}. * * @param {MessagePortLike} messagePort * @param {Parameters<typeof createClient>[1]} [opts] * @return {ComapeoServicesClientApi} */ export function createComapeoServicesClient(messagePort: MessagePortLike, opts?: Parameters<typeof createClient>[1]): ComapeoServicesClientApi; /** * Close the services client (removes listeners but does not close the message port) * * @param {ComapeoServicesClientApi} servicesClient client created with `createComapeoServicesClient` */ export function closeComapeoServicesClient(servicesClient: ComapeoServicesClientApi): void; export type ComapeoServicesClientApi = ClientApi<ComapeoServicesApi>; export type ComapeoProjectClientApi = ClientApi<MapeoProject>; export type ComapeoCoreClientApi = ClientApi<Omit<MapeoManager, "getProject"> & { getProject: (projectPublicId: string) => Promise<ComapeoProjectClientApi>; }>; import type { MessagePortLike } from 'rpc-reflector'; import { createClient } from 'rpc-reflector/client.js'; import type { ComapeoServicesApi } from './server.js'; import type { ClientApi } from 'rpc-reflector'; import type { MapeoProject } from '@comapeo/core'; import type { MapeoManager } from '@comapeo/core';