UNPKG

@comapeo/ipc

Version:
64 lines (63 loc) 2.59 kB
/** @import { MessagePortLike } from 'rpc-reflector' */ /** * @param {import('@comapeo/core').MapeoManager} manager * @param {MessagePortLike} messagePort * @param {Parameters<typeof createServer>[2]} [opts] */ export function createComapeoCoreServer(manager: import("@comapeo/core").MapeoManager, messagePort: MessagePortLike, opts?: Parameters<typeof createServer>[2]): { close(): void; }; /** * The contract for 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 this; `@comapeo/core-react` * and other consumers reach it through `createComapeoServicesClient`. * * @typedef {object} ComapeoServicesApi * @property {object} mapServer * @property {() => Promise<string>} mapServer.getBaseUrl Return the base URL of the map server */ /** * Serve the app-provided services API (see {@link ComapeoServicesApi}) over * the shared message port. * * @param {ComapeoServicesApi} services * @param {MessagePortLike} messagePort * @param {Parameters<typeof createServer>[2]} [opts] */ export function createComapeoServicesServer(services: ComapeoServicesApi, messagePort: MessagePortLike, opts?: Parameters<typeof createServer>[2]): { close(): void; }; export class ProjectRoutingApi { /** * @param {{ getProjectInstance: (projectId: string) => Promise<string> }} opts */ constructor({ getProjectInstance }: { getProjectInstance: (projectId: string) => Promise<string>; }); /** * Verify the project exists, opening it (or re-opening it after close) * if necessary, and return the per-instance subchannel id the client * should use for per-project messages. The returned id is unique to the * current open lifetime of the project — closing and re-opening yields * a different id. * * @param {string} projectId * @returns {Promise<string>} instance id */ assertProjectExists(projectId: string): Promise<string>; #private; } /** * The contract for 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 this; `@comapeo/core-react` * and other consumers reach it through `createComapeoServicesClient`. */ export type ComapeoServicesApi = { mapServer: { getBaseUrl: () => Promise<string>; }; }; import type { MessagePortLike } from 'rpc-reflector'; import { createServer } from 'rpc-reflector/server.js';