/** * Copyright 2007-2025 MAIYUN.NET * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import * as clickgo from '../clickgo'; import * as lCore from './core'; /** * --- 初始化系统级 ID,仅能设置一次 --- * @param id 系统级 ID */ export declare function initSysId(id: string): void; /** --- hue 色盘 --- */ export declare const hues: string[]; /** * --- 判断一个元素是否还存在于页面当中 --- * @param el 要判断的元素 */ export declare function inPage(el: HTMLElement): boolean; export declare const dpi: number; /** * --- 设置全局鼠标样式 --- * @param type 样式或留空,留空代表取消 */ export declare function setGlobalCursor(type?: string): void; /** * ---启用/禁用全局 transition --- * @param enable 是否启用 */ export declare function setGlobalTransition(enable: boolean): void; /** * --- 创建任务时连同一起创建的 style 标签 --- * @param taskId 任务 id */ export declare function createToStyleList(taskId: string): void; /** * --- 任务结束时需要移除 task 的所有 style --- * @param taskId 任务 id */ export declare function removeFromStyleList(taskId: string): void; /** * --- 将 style 内容写入 dom --- * @param taskId 当前任务 ID * @param style 样式内容 * @param type 插入的类型 * @param formId 当前窗体 ID(global 下可空,theme 下为主题唯一标识符,control 下为控件名) * @param panelId 若是 panel 中创建的则需要指定 panelId,仅 type 为 form 有效 */ export declare function pushStyle(taskId: string, style: string, type?: 'global' | 'theme' | 'control' | 'form', formId?: string, panelId?: string): void; /** * --- 移除 style 样式 dom --- * @param taskId 要移除的任务 ID * @param type 移除的类型 * @param formId 要移除的窗体 ID * @param panelId type 为 form 模式下若不指定则当前 form 包含 panel 的样式都会被移除 */ export declare function removeStyle(taskId: string, type?: 'global' | 'theme' | 'control' | 'form', formId?: string, panelId?: string): void; /** * --- 获取任务中子类有几个子元素 --- * @param taskId 任务 ID * @param type 类型 */ export declare function getStyleCount(taskId: clickgo.core.TCurrent, type: 'theme' | 'control' | 'form'): number; /** * --- 添加监视 Element 对象位置,元素移除后自动停止监视,已经监视中的不会再次监视,请短时间使用(虽然本方法也可以监听 element 的大小改变,但这是监听位置改变的副产品,如果仅仅监听大小改变请使用效率更高的 watch size) --- * @param el 要监视的大小 * @param cb 回调函数 * @param immediate 立刻先执行一次回调 */ export declare function watchPosition(el: HTMLElement, cb: (state: { 'position': boolean; 'size': boolean; }) => void | Promise, immediate?: boolean): boolean; /** * --- 移除监视 Element 对象位置 --- * @param el 要移除监视 */ export declare function unwatchPosition(el: HTMLElement): void; /** * --- 检测一个标签是否正在被 watchSize --- * @param el 要检测的标签 */ export declare function isWatchPosition(el: HTMLElement): boolean; /** * --- 清除某个窗体的所有 watch position 监视,虽然窗体结束后相关监视永远不会再被执行,但是会形成冗余 --- * @param formId 窗体 id * @param panelId 若指定则只清除当前窗体的某个 panel 的 watch */ export declare function clearWatchPosition(formId: string, panelId?: string): void; /** * --- 获取当前 watch size 中的元素总数 --- * @param taskId 留空则获取全部总数 --- */ export declare function getWatchSizeCount(taskId?: lCore.TCurrent): number; /** * --- 添加监视 Element 对象大小,元素移除后自动停止监视(浏览器原生效果),已经监视中的不会再次监视 --- * @param current 当前执行的任务 * @param el 要监视的大小 * @param cb 回调函数 * @param immediate 立刻先执行一次回调 */ export declare function watchSize(current: lCore.TCurrent, el: HTMLElement, cb: () => void | Promise, immediate?: boolean): boolean; /** * --- 移除监视 Element 对象大小 --- * @param el 要移除监视 */ export declare function unwatchSize(el: HTMLElement): void; /** * --- 检测一个标签是否正在被 watchSize --- * @param el 要检测的标签 */ export declare function isWatchSize(el: HTMLElement): boolean; /** * --- 清除某个任务的所有 watch size 监视 --- * @param taskId 任务 id */ export declare function clearWatchSize(taskId: lCore.TCurrent): void; /** * --- 获取当前 watch 中的元素总数 --- * @param taskId 留空则获取全部总数 --- */ export declare function getWatchCount(taskId?: string): number; /** * --- 添加 DOM 内容变化监视 --- * @param current 当前任务 * @param el dom 对象 * @param cb 回调 * @param mode 监听模式,默认 default */ export declare function watch(current: lCore.TCurrent, el: HTMLElement, cb: (mutations: MutationRecord[]) => void | Promise, mode?: 'child' | 'childsub' | 'style' | 'text' | 'default', immediate?: boolean): boolean; /** * --- 移除监视 Element 对象变动 --- * @param taskId 任务 id * @param el 要移除监视 */ export declare function unwatch(taskId: lCore.TCurrent, el: HTMLElement): void; /** * --- 检测一个标签是否正在被 watchSize --- * @param el 要检测的标签 */ export declare function isWatch(el: HTMLElement): boolean; /** * --- 清除某个任务下面的所有 watch 监视 --- * @param taskId 任务 id */ export declare function clearWatch(taskId: lCore.TCurrent): void; /** * --- 监听一个标签的计算后样式的变化 --- * @param el 对象 * @param name 样式名 * @param cb 变更回调 * @param immediate 是否立刻执行一次 */ export declare function watchStyle(el: HTMLElement, name: string | string[], cb: (name: string, value: string, old: string) => void | Promise, immediate?: boolean): void; /** * --- 检测一个标签是否正在被 watchStyle --- * @param el 要检测的标签 */ export declare function isWatchStyle(el: HTMLElement): boolean; /** * --- 清除某个窗体的所有 watch style 监视 --- * @param formId 窗体 id * @param panelId 若指定则只清除当前窗体的某个 panel 的 watch */ export declare function clearWatchStyle(formId: string, panelId?: string): void; /** * --- 监听一个对象的属性变化 --- * @param el 对象 * @param name 属性名 * @param cb 回调函数 * @param immediate 是否立即执行一次 */ export declare function watchProperty(el: HTMLElement, name: string | string[], cb: (name: string, value: any) => void | Promise, immediate?: boolean): void; /** * --- 检测一个标签是否正在被 watchProperty --- * @param el 要检测的标签 */ export declare function isWatchProperty(el: HTMLElement): boolean; /** * --- 清除某个窗体的所有 watch property 监视,虽然窗体结束后相关监视永远不会再被执行,但是会形成冗余 --- * @param formId 窗体 id * @param panelId 若指定则只清除当前窗体的某个 panel 的 watch */ export declare function clearWatchProperty(formId: string, panelId?: string): void; export declare function getWatchInfo(): IGetWatchInfoResult; /** --- 相关状态 --- */ export declare let is: { 'move': boolean; 'shift': boolean; 'ctrl': boolean; 'meta': boolean; /** --- 当前是否是全屏 --- */ 'full': boolean; /** --- 是否是黑暗模式 --- */ 'dark': boolean; /** --- 虚拟键盘是否正在显示 --- */ 'keyboard': boolean; /** --- 动画开启状态 --- */ 'transition': boolean; }; /** * --- 通过 data 名查找上层所有标签是否存在 --- * @param el 当前标签 * @param name 要查找的 data 名 * @param value data 对应的值,留空则代表只要匹配了名就可以 */ export declare function findParentByData(el: HTMLElement, name: string, value?: string): HTMLElement | null; /** * --- 通过 class 名查找上层所有标签是否存在 --- * @param el 当前标签 * @param name 要查找的 class 名 */ export declare function findParentByClass(el: HTMLElement, name: string): HTMLElement | null; /** * --- 通过 tagname 查找上层所有标签是否存在 --- * @param el 当前标签 * @param name 要查找的 tagname 名,小写,如 table */ export declare function findParentByTag(el: HTMLElement, name: string): HTMLElement | null; /** * --- 判断一个元素是当前同级的第几位 --- * @param el 要判断的元素 */ export declare function index(el: HTMLElement): number; /** * --- 查找指定 el 的同级所有元素 --- * @param el 基准 * @returns HTMLElement[] */ export declare function siblings(el: HTMLElement): HTMLElement[]; /** * --- 查找指定 el 的同级的存在 data 的元素 --- * @param el 基准 * @param name data 名,不含 data- * @returns HTMLElement[] */ export declare function siblingsData(el: HTMLElement, name: string): HTMLElement[]; /** * --- 全屏 --- */ export declare function fullscreen(): Promise; /** * --- 退出全屏 --- */ export declare function exitFullscreen(): Promise; /** * --- 创建 element --- * @param tagName 标签名 */ export declare function createElement(tagName: T): HTMLElementTagNameMap[T]; /** --- 获取元素的相对位置信息 --- */ export declare function getElementRPosition(el: HTMLElement, wrap: HTMLElement): { 'left': number; 'top': number; 'width': number; 'height': number; }; /** --- 根据角位置获取八角坐标 --- */ export declare function getRectPoint(el: HTMLElement, wrap: HTMLElement, pos: 'lt' | 't' | 'tr' | 'r' | 'rb' | 'b' | 'bl' | 'l'): { 'x': number; 'y': number; }; /** --- 麦克风通过 WebSocket 对讲 --- */ export declare const mic: { /** * --- 开始对讲 --- * @param ws ws:// wss:// * @param opts 选项 */ start: (ws: string, opts?: { /** --- 需要初次 message 认证返回 { "result": 1 } 后才开始对讲,默认为 true --- */ "rtn"?: boolean; /** --- 开始事件回调,此时说话才会被发送 --- */ onStart?: () => void | Promise; /** --- 有人声开始 --- */ onVoiceStart?: () => void | Promise; /** --- 有人声结束 --- */ onVoiceEnd?: () => void | Promise; /** --- rms 音量回调 --- */ onProcess?: (data: { "rms": number; }) => void | Promise; /** --- 结束事件回调,主动结束也会回调 --- */ onStop?: () => void | Promise; }) => Promise; /** --- 结束对讲 --- */ stop: () => void; }; export declare function init(): void; /** --- 方向类型,从左上开始 --- */ export type TDomBorder = 'lt' | 't' | 'tr' | 'r' | 'rb' | 'b' | 'bl' | 'l' | ''; export type TDomBorderCustom = TDomBorder | { 'left': number; 'top'?: number; 'width': number; 'height'?: number; }; /** --- Element 的大小 --- */ export interface IDomSize { 'top': number; 'right': number; 'bottom': number; 'left': number; 'width': number; 'height': number; 'padding': { 'top': number; 'right': number; 'bottom': number; 'left': number; }; 'border': { 'top': number; 'right': number; 'bottom': number; 'left': number; }; 'clientHeight': number; 'clientWidth': number; 'innerWidth': number; 'innerHeight': number; 'scrollWidth': number; 'scrollHeight': number; } /** --- 监视位置中的元素 --- */ export interface IWatchPositionItem { 'el': HTMLElement; 'rect': DOMRect; 'handler': (state: { 'position': boolean; 'size': boolean; }) => void | Promise; } /** --- 监视大小中的元素 --- */ export interface IWatchSizeItem { 'el': HTMLElement; 'handler': () => void | Promise; 'taskId': string | null; } /** --- 监视变化中的元素 --- */ export interface IWatchItem { 'el': HTMLElement; 'mo': MutationObserver; 'taskId'?: string; } /** --- 获取当前正在监视中的 property、style 和 position 的元素信息 --- */ export interface IGetWatchInfoResult { 'formId': string; 'default': Record; 'panels': Record>; }