import type { BaseCollectorReducerAction, ISerializableEventData, ISerializableStorageViewData, Uid } from "../collector/types"; import type { Cursor, View, CameraState, DisplayerCallbacks, HotKeys, Player, Room, Point, RoomMember, RoomState, Size, Callbacks, Camera, Color, CursorAdapter, Displayer, ImageInformation, Rectangle, RenderEngine, MemberState as _MemberState } from "white-web-sdk"; import type EventEmitter2 from "eventemitter2"; import type { ApplianceSingleManager } from "./single/applianceSingleManager"; import type { ApplianceMultiManager, WindowManager } from "./multi/applianceMultiManager"; import type { BaseApplianceManager } from "./baseApplianceManager"; import type { AppViewDisplayerManager, MainViewDisplayerManager } from "./baseViewContainerManager"; import type { ApplianceSinglePlugin } from "./applianceSinglePlugin"; import type { ApplianceMultiPlugin } from "./applianceMultiPlugin"; import type { ECanvasContextType, EToolsKey, EventWorkState } from "../core/enum"; import type { AuthRenderScenesData } from "../core/renderCotrol"; import type { Plugin } from "../core/plugin"; import type { TextEditorInfo } from "../component/textEditor/types"; import type { IMarkmapOptions } from "../component/svg/markmap"; export type { Room, ImageInformation, Point, Size, Rectangle, RoomMember, RoomState, Player, HotKeys, Camera, Displayer, DisplayerCallbacks, CameraState, View, Cursor, CursorAdapter, RenderEngine, _MemberState, }; export declare enum ApplianceNames { /** * 选择工具 */ selector = "selector", /** * 互动工具(无默认行为,可供 plugin 自定义) */ clicker = "clicker", /** * 激光笔 */ laserPointer = "laserPointer", /** * 铅笔工具 */ pencil = "pencil", /** * 矩形工具 */ rectangle = "rectangle", /** * 圆形工具 */ ellipse = "ellipse", /** * 图形工具 */ shape = "shape", /** * 橡皮工具 */ eraser = "eraser", /** * 橡皮工具(用来擦除铅笔笔迹的局部) */ pencilEraser = "pencilEraser", /** * 文字工具 */ text = "text", /** * 直线工具 */ straight = "straight", /** * 箭头工具 */ arrow = "arrow", /** * 抓手工具 */ hand = "hand", /** * 激光笔 */ laserPen = "laserPen" } /** 扩展的MemberState */ export type ExtendMemberState = { /** * 当前用户所选择的教具 */ currentApplianceName: ApplianceNames; /** 是否开启笔锋 */ strokeType?: EStrokeType; /** 是否删除整条线段 */ isLine?: boolean; /** 线框透明度 */ strokeOpacity?: number; /** 是否开启激光笔 */ useLaserPen?: boolean; /** 激光笔保持时间, second */ duration?: number; /** 是否使用新铅笔教具 */ useNewPencil?: boolean; /** 填充样式 */ fillColor?: Color; /** 填充透明度 */ fillOpacity?: number; /** * 使用 ``shape`` 教具时,绘制图形的具体类型 */ shapeType?: ShapeType; /** 多边形顶点数 */ vertices?: number; /** 多边形向内顶点步长 */ innerVerticeStep?: number; /** 多边形向内顶点与外顶点半径比率 */ innerRatio?: number; /** 文字透明度 */ textOpacity?: number; /** 文字背景颜色 */ textBgColor?: Color; /** 文字背景颜色透明度 */ textBgOpacity?: number; /** 水平对齐方式 */ textAlign?: "left" | "center" | "right"; /** 垂直对齐方式 */ verticalAlign?: "top" | "middle" | "bottom"; /** 位置 */ placement?: SpeechBalloonPlacement; }; export type MemberState = Omit<_MemberState, "currentApplianceName" | "shapeType"> & ExtendMemberState; export type AppliancePluginLike = ApplianceMultiPlugin | ApplianceSinglePlugin; export type ApplianceManagerLike = ApplianceMultiManager | ApplianceSingleManager | BaseApplianceManager; export type ApplianceViewManagerLike = AppViewDisplayerManager | MainViewDisplayerManager; export interface BaseSubWorkModuleProps { control: ApplianceManagerLike; internalMsgEmitter: EventEmitter2; publicMsgEmitter: EventEmitter2; } export type ApplianceAdaptor = { options: AppliancePluginOptions; logger?: Logger; cursorAdapter?: CursorAdapter; }; export type canBindMethodType = keyof Omit; export interface AppliancePluginInstance { readonly displayer: Displayer; readonly currentManager?: ApplianceManagerLike; readonly windowManager?: WindowManager; disableDeviceInputs: boolean; disableEraseImage: boolean; disableCameraTransform: boolean; /** * 获取某个场景里包含所有元素的矩形 */ getBoundingRectAsync(scenePath: string): Promise; /** * 生成屏幕快照,并写入指定的 CanvasRenderingContext2D 对象中 */ screenshotToCanvasAsync(context: CanvasRenderingContext2D, scenePath: string, width: number, height: number, camera: Camera, ratio?: number): Promise; /** * 生成场景预览 * @param scenePath 想要获取预览内容的场景的场景路径 * @param div 想要展示预览内容的 div * @param width 白板的缩放宽度:将当前白板内容,缩小到真实像素宽度。2.3.8 后,该参数为可选参数,如果不填,则默认为展示内容 div 的宽度。 * @param height 白板的缩放高度:将当前白板的内容,缩小到真实像素高度。2.3.8 后,该参数为可选参数,如果不填,则默认为展示内容 div 的高度。 */ scenePreviewAsync(scenePath: string, div: HTMLElement, width?: number, height?: number, engine?: RenderEngine): Promise; /** * 生成场景预览,和 {@link scenePreview} 的区别是此函数会选取一个框住所有元素的视角,而 scenePreview 选取的是用户当前视角 * @param scenePath 想要获取预览内容的场景的场景路径 * @param div 想要展示预览内容的 div * @param width 白板的缩放宽度:将当前白板内容,缩小到真实像素宽度。2.3.8 后,该参数为可选参数,如果不填,则默认为展示内容 div 的宽度。 * @param height 白板的缩放高度:将当前白板的内容,缩小到真实像素高度。2.3.8 后,该参数为可选参数,如果不填,则默认为展示内容 div 的高度。 */ fillSceneSnapshotAsync(scenePath: string, div: HTMLElement, width?: number, height?: number, engine?: RenderEngine): Promise; /** * 在当前场景中插入图片 * 该操作往往需要和 ``room.completeImageUpload`` 配合使用,具体例子可参考[《插入图片|教具》](/javascript-zh/home/tools#插入图片)。 */ insertImage(imageInfo: ImageInformation): void; /** * 改变图片的锁定状态。若图片被锁定,则无法被框选、无法被拖动、无法被改变大小 * @param uuid 图片的 UUID */ lockImage(uuid: string, locked: boolean): void; /** * 设置图片资源。第一参数 ``uuid`` 是图片的唯一标识符,应该与 ``room.insertImage`` 中传入的 ``uuid`` 字段相同。 * 第二参数 ``src`` 是图片资源的 URL。具体例子可参考[《插入图片|教具》](/javascript-zh/home/tools#插入图片)。 */ completeImageUpload(uuid: string, src: string): void; /** * 导出特定场景的图片信息,注意这些信息可能与插入时填写的不同。 * @param scenePath 需要导出图片信息的场景路径,必须是 ``ScenePathType`` 为 ``page`` 的路径。 */ getImagesInformation(scenePath: string): ImageInformation[]; /** * 在指定位置插入文字 * @param x 第一个字的的左侧边中点,世界坐标系中的 x 坐标 * @param y 第一个字的的左侧边中点,世界坐标系中的 y 坐标 * @param textContent 初始化文字的内容,不传则为空 * @returns 该文字的标识符 */ insertText(x: number, y: number, textContent?: string): string | undefined; /** * 编辑指定文字的内容 * @param identifier 文字的标识符。为 ``insertText()`` 的返回值。 * @param textContent 文字要改成的内容 */ updateText(identifier: string, textContent: string): void; /** 撤销 */ undo(): number; /** 恢复 */ redo(): number; /** 清空当前场景 */ cleanCurrentScene(retainPpt?: boolean): void; /** 把指定的方法注入到指定对象上 */ /** 销毁 */ destroy(): void; /** 设置当前用户的读写权限 */ setWritable(writable: boolean): Promise; /** setMemberState */ setMemberState(modifyState: Partial): void; /** 获取undo */ canUndoSteps(): number; /** 获取redo */ canRedoSteps(): number; /** 事件监听器 */ callbacks: Callbacks; /** 创建小地图 * @param viewId 多白板下白板ID, 主白板ID为 `mainView`, 其他白板ID为 addApp() return 的appID * @param div 小地图DOM容器 */ createMiniMap(viewId: string, div: HTMLElement): Promise; /** 销毁小地图 */ destroyMiniMap(viewId: string): Promise; /** 过滤笔记 * @param viewId 多白板下白板ID, 主白板ID为 `mainView`, 其他白板ID为 addApp() return 的appID * @param filter 过滤条件 * render: 定笔记是否能要渲染, [uid1, uid2, ...] 或 true. true, 即都会渲染, [uid1, uid2, ...] 为指定渲染的用户uid集合 * hide: 笔记是否隐藏, [uid1, uid2, ...] 或 true. true, 即都要隐藏, [uid1, uid2, ...] 为指定隐藏的用户uid集合 * clear: 笔记是否可被清除, [uid1, uid2, ...] 或 true. true, 即都可以被清除, [uid1, uid2, ...] 为指定可被清除的用户uid集合 * @param isSync 是否同步到其他用户, 默认为true, 即会同步到其他用户 */ filterRenderByUid(viewId: string, filter: { render?: _ArrayTrue; hide?: _ArrayTrue; clear?: _ArrayTrue; }, isSync?: boolean): void; /** 取消过滤笔记 * @param viewId 多白板下白板ID, 主白板ID为 `mainView`, 其他白板ID为 addApp() return 的appID * @param isSync 是否同步到其他用户, 默认为true, 即会同步到其他用户,保持和filterRenderByUid设置的一致 */ cancelFilterRender(viewId: string, isSync?: boolean): void; /** * 添加事件监听器 */ addListener(event: PublicEvent, callback: PublicCallback): void; /** * 移除事件监听器 */ removeListener(event: PublicEvent, callback: PublicCallback): void; /** * 使用插件 * @param plugin 插件 */ usePlugin(plugin: Plugin): void; /** * 请求空闲回调 * @param callback 回调函数 * @param timeout 超时时间 */ requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number; /** * 取消空闲回调 * @param id 空闲回调id */ cancelIdleCallback(id: number): void; /** * 把方法注入到对象上 * @param object 对象 * @param methodName 方法名 */ injectMethodToObject(object: any, methodName: string): void; /** 失去文本焦点 */ blurText(): void; /** * 指定场景下是否存在元素 * @param scenePath 场景路径, 默认取当前聚焦的场景 * @param filter 过滤条件 * @returns 是否存在元素 */ hasElements(scenePath?: string, filter?: (toolsType: EToolsKey) => boolean): boolean; /** * 获取场景下的所有元素 * @param scenePath 场景路径, 默认取当前聚焦的场景 * @param filter 过滤条件 * @returns 所有元素 */ getElements(scenePath?: string, filter?: (toolsType: EToolsKey) => boolean): BaseCollectorReducerAction[]; /** 停止Draw事件 */ stopDraw(viewId: string): Promise; /** 设置白板本地场景路径变化 */ setViewLocalScenePathChange(viewId: string, scenePath: string): Promise; /** 插入markmap */ insertMarkmap(viewId: string, markdownInfo: ISVGMarkmapInformation): Promise; /** 更新markmap */ updateMarkmap(viewId: string, markmapId: MarkmapId, markdownInfo: ISVGMarkmapInformation): Promise; /** 插入背景图片 */ insertBackgroundImage(viewId: string, imageInfo: ISVGUrlInformation): void; } export type Logger = { readonly info: (...messages: any[]) => void; readonly warn: (...messages: any[]) => void; readonly error: (...messages: any[]) => void; }; export type ExtrasOptions = { /** 是否使用 worker, 默认值为 ``auto`` * auto: 自动选择(如果浏览器支持 offscreenCanvas 则使用 webWorker, 否则使用主线程) * mainThread: 使用主线程 */ useWorker?: UseWorkerType; /** 是否使用简单模式, 默认值为 ``false`` */ useSimple?: boolean; /** 是否使用背景Svg功能, 默认值为 ``false`` */ useBackgroundThread?: boolean; /** 同步数据配置项 */ syncOpt?: SyncOpt; /** 画布配置项 */ canvasOpt?: CanvasOpt; /** 指针配置项 */ cursor?: CursorOpt; /** 画布缓存配置项 */ bufferSize?: BufferSizeOpt; /** 贝塞尔优化配置项 */ bezier?: BezierOpt; /** 局部橡皮擦配置项 */ pencilEraser?: PencilEraserOpt; /** 线条粗细范围配置项 */ strokeWidth?: StrokeWidthOpt; /** 文字编辑器配置项 */ textEditor?: TextEditorOpt; /** 长虚线配置项 */ longDottedStroke?: LongDottedOpt; /** 虚线配置项 */ dottedStroke?: DottedOpt; /** 实线配置项 */ normalStroke?: NormalOpt; /** 撤销重做配置项 */ undoRedo?: UndoRedoOpt; /** markmap 配置项 */ markmap?: MarkmapOpt; }; export type UndoRedoOpt = { /** 是否启用全局撤销重做, 默认值为 false */ enableGlobal: boolean; /** 撤销重做最大堆栈长度, 默认值为 20 */ maxStackLength?: number; }; export type MarkmapOpt = { /** 是否启用 markmap, 默认值为 true */ enable: boolean; /** markmap 配置项 */ options: Partial; /** 获取markmapId超时时间,单位:毫秒,默认值为 10000 */ timeout?: number; }; export type SnapshotOpt = { /** 获取单张图片超时时间,单位:毫秒,默认值为 10000 */ timeout: number; }; export type NormalOpt = { /** 虚线端点样式, square: 平头, round: 圆头, 默认值为 round */ lineCap: "square" | "round"; }; export type DottedOpt = { /** 虚线端点样式, square: 平头, round: 圆头, 默认值为 round */ lineCap: "square" | "round"; /** 虚线,单线段长度, 默认值为 1, 即单线段长度为 1 */ segment: number; /** 虚线,单线段间隔, 默认值为 2, 即单线段间隔为 2 * thickness */ gap: number; }; export type LongDottedOpt = { /** 长虚线端点样式, square: 平头, round: 圆头, 默认值为 round */ lineCap: "square" | "round"; /** 长虚线,单线段长度, 默认值为 1, 即单线段长度为 1 * thickness */ segment: number; /** 长虚线,单线段间隔, 默认值为 2, 即单线段间隔为 2 * thickness */ gap: number; }; export type AppliancePluginOptions = { /** cdn配置项 */ cdn: CdnOpt; /** 额外配置项 */ extras?: ExtrasOptions; }; export type RequiredExtrasOptions = { useWorker: Required; useSimple: Required; useBackgroundThread: Required; syncOpt: Required; canvasOpt: Required; cursor: Required; bufferSize: Required; bezier: Required; pencilEraser: Required; strokeWidth: Required; textEditor: Required; longDottedStroke: Required; dottedStroke: Required; normalStroke: Required; undoRedo: Required; markmap: Required; }; export type RequiredAppliancePluginOptions = { cdn: CdnOpt; extras: Required> & { canvasOpt?: CanvasOpt; }; }; export interface AppliancePluginAttributes { [key: string]: ISerializableStorageViewData | ISerializableEventData; } export declare enum EStrokeType { Normal = "Normal", Stroke = "Stroke", Dotted = "Dotted", LongDotted = "LongDotted" } export declare enum ShapeType { /** * 三角形 */ Triangle = "triangle", /** * 菱形 */ Rhombus = "rhombus", /** * 五角星 */ Pentagram = "pentagram", /** * 说话泡泡 */ SpeechBalloon = "speechBalloon", /** * 星形 * */ Star = "star", /** * 多边形 * */ Polygon = "polygon" } export type SyncOpt = { /** * 同步间隔, 单位:毫秒 * 通过降低同步频率来减少网络带宽的消耗及cpu的开销,但是会增加同步的延迟。 * 默认值:200 (每秒同步5次) * */ interval: number; /** 是否开启平滑同步, 默认开启 */ smoothSync?: boolean; }; export type CanvasOpt = { /** 指定画布上下文类型 */ contextType: ECanvasContextType; }; export type UseWorkerType = "auto" | "mainThread"; export type CdnOpt = { /** full worker url 地址, 绘制完整数据的线程 */ fullWorkerUrl?: string; /** sub worker url 地址, 绘制一帧数据的线程 */ subWorkerUrl?: string; }; export type CursorOpt = { /** 是否启用指针 */ enable: boolean; /** 指针消失过期时间 */ expirationTime?: number; /** 指针移动延迟时间 */ moveDelayTime?: number; }; export type BufferSizeOpt = { /** 分配给绘制完整数据cancanvas 缓存大小 */ full: number; /** 分配给绘制一帧数据canvas 缓存大小 */ sub: number; }; export type BezierOpt = { /** 是否开启贝塞尔曲线 */ enable: boolean; /** 合并处理贝塞尔曲线的单位时间,单位:毫秒 */ combineUnitTime?: number; /** 贝塞尔曲线最大绘制点数 */ maxDrawCount?: number; }; export type PencilEraserOpt = { /** 是否使用位图方式局部橡皮擦 */ useBitMap: boolean; /** 最大图片宽度 */ maxImageWidth?: number; /** 最大图片高度 */ maxImageHeight?: number; /** 最长合并橡皮擦处理时间间隔,单位:毫秒 */ maxCombineTime?: number; }; export type TextEditorOpt = { /** 是否显示浮动栏 */ showFloatBar?: boolean; /** 是否可以通过selector教具切换 */ canSelectorSwitch?: boolean; /** 是否右边界自动换行 */ rightBoundBreak?: boolean; /** 扩展字体列表 */ extendFontFaces?: { fontFamily: string; src: string; }[]; /** 加载字体超时时间,单位:毫秒 */ loadFontFacesTimeout?: number; }; export type StrokeWidthOpt = { /** 最小线宽 */ min: number; /** 最大线宽 */ max: number; }; export declare enum EmitEventType { /** 无 */ None = "None", /** 显示悬浮栏 */ ShowFloatBar = "ShowFloatBar", /** 设置悬浮栏层级 */ ZIndexFloatBar = "ZIndexFloatBar", /** 删除节点 */ DeleteNode = "DeleteNode", /** 复制节点 */ CopyNode = "CopyNode", /** 激活层级设置 */ /** 设置节点层级 */ ZIndexNode = "ZIndexNode", /** 设置背景svg层级 */ ZIndexBackgroundSVG = "ZIndexBackgroundSVG", /** 旋转节点 */ RotateNode = "RotateNode", /** 设置节点颜色 */ SetColorNode = "SetColorNode", /** 移动节点 */ TranslateNode = "TranslateNode", /** 拉伸节点 */ ScaleNode = "ScaleNode", /** 原始事件 */ OriginalEvent = "OriginalEvent", /** 创建canvas */ CreateScene = "CreateScene", /** 激活cursor */ ActiveCursor = "ActiveCursor", /** 移动cursor */ MoveCursor = "MoveCursor", /** 控制editor */ CommandEditor = "CommandEditor", /** 设置editor */ SetEditorData = "SetEditorData", /** 设置文字样式 */ SetFontStyle = "SetFontStyle", /** 设置坐标 */ SetPoint = "SetPoint", /** 设置是否锁定 */ SetLock = "SetLock", /** 设置shape模型的配置项 */ SetShapeOpt = "SetShapeOpt", /** 切换相机角度中 */ CameraChange = "CameraChange", /** 激活方法动作 */ ActiveMethod = "ActiveMethod", /** 隐藏浮动按钮 */ HidFloatBarBtn = "HidFloatBarBtn" } export declare enum InternalMsgEmitterType { MainEngine = "MainEngine", Cursor = "Cursor", BindMainView = "BindMainView" } export declare enum ActiveContainerType { MainView = 0, Plugin = 1, Both = 2 } export type SpeechBalloonPlacement = "top" | "left" | "right" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom"; export type TeleBoxState = "normal" | "minimized" | "maximized"; export type FilterRenderType = "show" | "hide"; export type FilterPublishAutType = "write" | "readOnly"; export type FilterRenderDataType = "page" | "uid"; export type _SetTrue = true | Set; export type _ObjectTrue = true | { [key: Uid]: true; }; export type _ArrayTrue = true | Uid[]; export declare enum EForceStopReason { /** 画笔过长 */ longPencil = "longPencil" } /** * 公开的监听器类型 */ export type PublicListener = { /** 同步页面分屏权限 */ syncPageAuth: (viewId: string, syncData: AuthRenderScenesData) => void; /** 同步用户显示权限 */ syncRenderUids: (viewId: string, syncData: { render?: _SetTrue; hide?: _SetTrue; clear?: _SetTrue; }) => void; /** 文字改变 */ textChange: (workId: string, target: HTMLElement, texts: string[], info: TextEditorInfo) => void; /** 工作状态 */ workState: (workState: EventWorkState, viewId: string) => void; /** 强制中断 */ forceStop: (reason: EForceStopReason, viewId: string) => void; /** 同步数据变化 */ syncStorageChange: (storage: ISerializableStorageViewData) => void; }; export type PublicEvent = keyof PublicListener; export type PublicCallback = PublicListener[T]; export type IconifyInformation = { /** * inconify svg url */ src: string; /** * 图片的唯一识别符 */ uuid: string; /** * 图片中点在世界坐标系中的 x 坐标 */ centerX: number; /** * 图片中点在世界坐标系中的 y 坐标 */ centerY: number; /** * 图片中点在世界坐标系中的宽 */ width: number; /** * 图片中点在世界坐标系中的高 */ height: number; /** * 图片是否被锁定 */ locked: boolean; /** * 图片是否禁止非等比放缩 */ uniformScale?: boolean; /** * 是否以跨域方式加载图片 */ crossOrigin?: boolean | string; }; export type ISVGBaseInformation = { /** * svg的唯一识别符 */ uuid: string; /** * 图片中点在世界坐标系中的 x 坐标 */ centerX: number; /** * 图片中点在世界坐标系中的 y 坐标 */ centerY: number; /** * 图片中点在世界坐标系中的宽 */ width: number; /** * 图片中点在世界坐标系中的高 */ height: number; /** * 图片是否被锁定 */ locked: boolean; /** * 图片是否禁止非等比放缩 */ uniformScale?: boolean; /** * 是否以跨域方式加载图片 */ crossOrigin?: boolean | string; }; export type ISVGUrlInformation = ISVGBaseInformation & { /** * svg 源 url, 必须为 http 或 https 协议 */ src: string; }; export type ISVGMarkmapInformation = ISVGBaseInformation & { /** * markdown 数据 tostring */ data: string; }; export type ISVGInformation = ISVGUrlInformation | ISVGMarkmapInformation; export type MarkmapId = string;