UNPKG

@blockprotocol/core

Version:

Implementation of the Block Protocol Core specification for blocks and embedding applications

35 lines (34 loc) 1.31 kB
import { CoreHandler } from "./core-handler.js"; import type { EmbedderInitMessage, Message } from "./types.js"; /** * Implements the Block Protocol Core Specification for blocks. */ export declare class CoreBlockHandler extends CoreHandler { private sentInitMessage; constructor({ element }: { element: HTMLElement; }); /** * Send the init message, to which an initResponse is expected from the embedder. * The response will be processed in {@link processInitMessage} * * We send it repeatedly because the embedder may not yet have attached * its listeners */ initialize(): void; private sendInitMessage; /** * Receives the {@link EmbedderInitMessage} sent by the embedding application, * which is a series of payloads namespaced by module and message name. * Calls the individual callbacks registered for each of these values. * * Useful for HTML blocks receiving messages which are sent on initialization by the app * – other types of blocks can receive these messages synchronously via properties. */ protected processInitMessage(this: CoreBlockHandler, { message, }: { event: CustomEvent; message: Message & { data: EmbedderInitMessage; }; }): void; }