@huolala-tech/page-spy-lynx
Version:
An SDK of PageSpy for debugging Lynx app
49 lines (48 loc) • 2.34 kB
TypeScript
import { Client } from '@huolala-tech/page-spy-base';
import type { PageSpyPlugin, PageSpyPluginLifecycle, PluginOrder, PageSpyPluginLifecycleArgs } from '@huolala-tech/page-spy-types';
import Request from './api';
import { Config, InitConfig } from './config';
export { clearStorage, getStorageItem, removeStorageItem, setStorageItem, storage, } from './plugins/storage';
type UpdateConfig = {
title?: string;
project?: string;
};
declare class PageSpy {
/** 当前 SDK 版本,由构建产物注入。 */
version: string;
/** 按执行顺序分组的插件注册表。 */
static plugins: Record<PluginOrder | 'normal', PageSpyPlugin[]>;
/** 展开后的插件执行队列:pre -> normal -> post。 */
static get pluginsWithOrder(): PageSpyPlugin[];
static client: Client;
/** 创建房间和生成 WebSocket 地址的请求实例。 */
request: Request | null;
name: string;
address: string;
roomUrl: string;
socketStore: import("./helpers/socket").LynxWebSocketStore;
config: Config;
static get instance(): PageSpy | null;
static set instance(value: PageSpy | null);
/** 根据当前 Lynx 系统信息刷新客户端标识。 */
static refreshClient(): void;
/** 注册插件实例,并根据 enforce 字段放入对应执行队列。 */
static registerPlugin(plugin: PageSpyPlugin): void;
constructor(init: InitConfig);
/** 将配置同步到 socketStore,供所有插件和消息通道共享。 */
updateConfiguration(): void;
triggerPlugins<T extends PageSpyPluginLifecycle>(lifecycle: T, ...args: PageSpyPluginLifecycleArgs<T>): void;
/** 初始化 PageSpy 房间连接,复用正在进行的初始化 Promise 防止并发建房。 */
init(): Promise<void>;
/** 重置所有插件并关闭 WebSocket 连接。 */
abort(): void;
/** 请求服务端创建调试房间,并初始化 WebSocket 通道。 */
createNewConnection(): Promise<void>;
/** 更新房间展示信息,并通知远端调试面板刷新。 */
updateRoomInfo(obj: UpdateConfig): void;
/** 获取可在浏览器中打开的 PageSpy 调试面板链接。 */
getDebugLink(): string;
/** Lynx 场景暂无内置面板,返回房间号供宿主侧展示。 */
showPanel(): Promise<never>;
}
export default PageSpy;