@persona/layout-editor-remote-module
Version:
Shared manifest format, Vite plugin, and host/iframe bridge for remotely-defined dashboard layout modules in Persona dashboard apps.
51 lines (50 loc) • 1.86 kB
text/typescript
import { t as Json } from "./types-CBSiNsDJ.mjs";
import { t as RemoteModuleContext } from "./protocol-ClWDYwW2.mjs";
import { ReactNode } from "react";
//#region src/bridge/origin.d.ts
declare function personaDashboardHostOrigins(origin: string): boolean;
//#endregion
//#region src/bridge/iframe/createModuleBridge.d.ts
type ModuleBridgeInitPayload = {
data: Json;
context: RemoteModuleContext | null;
};
type CreateModuleBridgeOptions = {
allowedHostOrigins?: (string | RegExp)[] | ((origin: string) => boolean);
resolveTimeoutMs?: number;
signalsLoaded?: boolean;
};
type ModuleBridge = {
ready: () => Promise<ModuleBridgeInitPayload>;
getData: () => Json;
getContext: () => RemoteModuleContext | null;
subscribe: (listener: () => void) => () => void;
reportRenderError: (message: string) => void;
resolveDataPath: (dataPath: string, variableMap?: Record<string, string | number>) => Promise<Json>;
observeHeight: (element: Element) => () => void;
signalLoaded: () => void;
destroy: () => void;
};
//#endregion
//#region src/bridge/iframe/LayoutModuleBridge.d.ts
type LayoutModuleBridgeRenderProps = {
data: ReturnType<ModuleBridge['getData']>;
context: RemoteModuleContext | null;
resolveDataPath: ModuleBridge['resolveDataPath'];
};
type LayoutModuleBridgeProps = {
allowedHostOrigins?: CreateModuleBridgeOptions['allowedHostOrigins'];
resolveTimeoutMs?: number;
observeHeight?: boolean;
fallback?: ReactNode;
children: (props: LayoutModuleBridgeRenderProps) => ReactNode;
};
declare function LayoutModuleBridge({
allowedHostOrigins,
resolveTimeoutMs,
observeHeight,
fallback,
children
}: LayoutModuleBridgeProps): ReactNode;
//#endregion
export { type Json, LayoutModuleBridge, type LayoutModuleBridgeProps, type LayoutModuleBridgeRenderProps, type RemoteModuleContext, personaDashboardHostOrigins };