/** * 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 mpegts from 'mpegts.js'; import * as clickgo from '../clickgo'; import * as lForm from './form'; import * as lControl from './control'; import * as lCore from './core'; /** * --- 初始化系统级 ID,仅能设置一次 --- * @param id 系统级 ID */ export declare function initSysId(id: string): void; /** --- Config 配置对象 --- */ export declare let config: IConfig; /** --- App 抽象类 --- */ export declare abstract class AbstractApp { /** --- 当前 js 文件在包内的完整路径 --- */ filename: string; /** --- 系统会自动设置本项 --- */ taskId: string; /** --- App 的入口文件 --- */ abstract main(data: Record): Promise; /** * --- 以某个窗体进行正式启动这个 app(入口 form),不启动则任务也启动失败 --- * @param form 窗体对象 */ run(form: lForm.AbstractForm): Promise; /** --- 全局错误事件 --- */ onError(taskId: string, formId: string, error: Error, info: string): void | Promise; /** --- 屏幕大小改变事件 --- */ onScreenResize(): void | Promise; /** --- 系统配置变更事件 --- */ onConfigChanged(n: TK, v: T[TK]): void | Promise; /** --- 窗体创建事件 --- */ onFormCreated(taskId: string, formId: string, title: string, icon: string, showInSystemTask: boolean): void | Promise; /** --- 窗体销毁事件 */ onFormRemoved(taskId: string, formId: string, title: string, icon: string): void | Promise; /** --- 窗体标题改变事件 */ onFormTitleChanged(taskId: string, formId: string, title: string): void | Promise; /** --- 窗体图标改变事件 --- */ onFormIconChanged(taskId: string, formId: string, icon: string): void | Promise; /** --- 窗体最小化状态改变事件 --- */ onFormStateMinChanged(taskId: string, formId: string, state: boolean): void | Promise; /** --- 窗体最大化状态改变事件 --- */ onFormStateMaxChanged(taskId: string, formId: string, state: boolean): void | Promise; /** --- 窗体显示状态改变事件 --- */ onFormShowChanged(taskId: string, formId: string, state: boolean): void | Promise; /** --- 窗体获得焦点事件 --- */ onFormFocused(taskId: string, formId: string): void | Promise; /** --- 窗体丢失焦点事件 --- */ onFormBlurred(taskId: string, formId: string): void | Promise; /** --- 窗体闪烁事件 --- */ onFormFlash(taskId: string, formId: string): void | Promise; /** --- 窗体是否显示在任务栏属性改变事件 --- */ onFormShowInSystemTaskChange(taskId: string, formId: string, value: boolean): void | Promise; /** --- 窗体的 formHash 改变事件 --- */ onFormHashChange(taskId: string, formId: string, value: string, data: Record): void | Promise; /** --- 任务开始事件 --- */ onTaskStarted(taskId: string): void | Promise; /** --- 任务结束事件 --- */ onTaskEnded(taskId: string): void | Promise; /** --- launcher 文件夹名称修改事件 --- */ onLauncherFolderNameChanged(id: string, name: string): void | Promise; /** --- location hash 改变事件 --- */ onHashChanged(hash: string): void | Promise; /** --- 键盘按下事件 --- */ onKeydown(e: KeyboardEvent): void | Promise; /** --- 键盘弹起事件 --- */ onKeyup(e: KeyboardEvent): void | Promise; } export declare function setBoot(b: clickgo.AbstractBoot): void; /** * --- 主动触发系统级事件,用 this.trigger 替代 --- */ export declare function trigger(name: TGlobalEvent, taskId?: string | boolean | KeyboardEvent, formId?: string | boolean | Record | null, param1?: boolean | Error | string, param2?: string | Record, param3?: boolean): Promise; /** * --- cga blob 文件解包 --- * @param blob blob 对象 */ export declare function readApp(blob: Blob): Promise; /** * --- 从网址下载应用 --- * @param taskId 所属任务 ID * @param url 对于当前网页的相对、绝对路径,以 .cga 结尾的文件 * @param opt 选项 */ export declare function fetchApp(taskId: string, url: string, opt?: ICoreFetchAppOptions): Promise; /** * --- 获取屏幕可用区域 --- */ export declare function getAvailArea(): IAvailArea; /** * --- 修改浏览器 hash --- * @param current 当前任务 id * @param hash 修改的值,不含 # */ export declare function hash(current: TCurrent, hash: string): Promise; /** * --- 获取当前浏览器的 hash --- */ export declare function getHash(): string; /** * --- 获取当前浏览器的 host --- */ export declare function getHost(): string; /** * --- 对浏览器做跳转操作 --- * @param current 当前任务 id * @param url 要跳转的新 URL */ export declare function location(current: TCurrent, url: string): Promise; /** * --- 获取当前的浏览器的 url --- */ export declare function getLocation(): string; /** * --- 对浏览器做返回操作 --- * @param current 当前任务 id */ export declare function back(current: TCurrent): Promise; /** * --- 打开新的标签页 * @param url 要访问的网址 */ export declare function open(url: string): void; /** * --- 注册模块 --- * @param current 当前任务 id * @param name 模块名 * @param opt 选项 */ export declare function regModule(current: TCurrent, name: string, opt: { /** --- ESM 模式必填 --- */ 'version'?: string; /** --- 除 ESM 模式外必填 --- */ func?: () => any | Promise; }): Promise; /** * --- 检查特殊模块是否注册 --- * @param name 模块名 */ export declare function checkModule(name: string): boolean; export declare function getModule(name: 'tums-player'): Promise; export declare function getModule(name: 'mpegts'): Promise; export declare function getModule(name: string): Promise; /** * --- 加载模块,返回 true / false --- * @param name 模块名 */ export declare function loadModule(name: string): Promise; export declare function init(): void; /** --- Config 对象 --- */ export interface IConfig { 'locale': string; ['task.position']: 'left' | 'right' | 'top' | 'bottom'; ['task.pin']: Record; ['desktop.icon.storage']: boolean; ['desktop.icon.recycler']: boolean; ['desktop.wallpaper']: string | null; ['desktop.path']: string | null; ['launcher.list']: IConfigLauncherItem[]; } /** --- Launcher 的 item 对象 --- */ export interface IConfigLauncherItem { 'id'?: string; 'name': string; 'path'?: string; 'icon'?: string; 'list'?: Array<{ 'id'?: string; 'name': string; 'path': string; 'icon': string; }>; } /** --- 屏幕可用区域 --- */ export interface IAvailArea { 'left': number; 'top': number; 'width': number; 'height': number; 'owidth': number; 'oheight': number; } /** --- 全局事件类型 --- */ export type TGlobalEvent = 'error' | 'screenResize' | 'configChanged' | 'formCreated' | 'formRemoved' | 'formTitleChanged' | 'formIconChanged' | 'formStateMinChanged' | 'formStateMaxChanged' | 'formShowChanged' | 'formFocused' | 'formBlurred' | 'formFlash' | 'formShowInSystemTaskChange' | 'formHashChange' | 'taskStarted' | 'taskEnded' | 'launcherFolderNameChanged' | 'hashChanged' | 'keydown' | 'keyup'; /** --- 现场下载 app 的参数 --- */ export interface ICoreFetchAppOptions { 'notify'?: number | { /** --- notify id --- */ 'id'?: number; /** --- 偏移基准 --- */ 'loaded'?: number; /** --- 偏移总量 --- */ 'total'?: number; }; /** --- 网址后面附带的前缀,如 ?123 --- */ 'after'?: string; /** * --- 下载进度 --- * @param loaded 已下载字节 * @param total 总字节 * @param per 含偏移进度百分比(0 - 1) */ progress?: (loaded: number, total: number, per: number) => void | Promise; } /** --- 应用包解包后对象 --- */ export interface IApp { 'type': 'app'; /** --- 控件对象配置文件 --- */ 'config': IAppConfig; /** --- 所有已加载的文件内容 --- */ 'files': Record; /** --- 应用图标 --- */ 'icon': string; } /** --- 应用文件包 config --- */ export interface IAppConfig { /** --- 应用名 --- */ 'name': string; /** --- 发行版本 --- */ 'ver': number; /** --- 发行版本字符串 --- */ 'version': string; /** --- 作者 --- */ 'author': string; /** --- 将要加载的控件 --- */ 'controls': string[]; /** --- 将自动加载的主题 --- */ 'themes'?: string[]; /** --- 将自动申请的权限 --- */ 'permissions'?: string[]; /** --- 将自动加载的语言包,path: lang --- */ 'locales'?: Record; /** --- 全局样式,不带扩展名,系统会在末尾添加 .css --- */ 'style'?: string; /** --- 图标路径,需包含扩展名 --- */ 'icon'?: string; /** --- 将要加载的非 js 文件列表,打包为 cga 模式下此配置可省略 --- */ 'files'?: string[]; /** --- 要提前加载的库名 --- */ 'modules'?: string[]; } /** --- Vue 实例 --- */ export interface IVue { '$attrs': Record; '$data': Record; '$el': HTMLElement; $emit(name: string, ...arg: any): void; $forceUpdate(): void; $nextTick(): Promise; '$options': Record; '$parent': IVue | null; '$props': Record; '$refs': Record; '$root': IVue; '$slots': { 'default': undefined | ((o?: any) => IVNode[]); [key: string]: undefined | ((o?: any) => IVNode[]); }; '$watch': (o: any, cb: (n: any, o: any) => void, opt?: { 'immediate'?: boolean; 'deep'?: boolean; }) => void; [key: string]: any; } /** --- Vue 节点 --- */ export interface IVNode { 'children': { 'default': undefined | (() => IVNode[]); [key: string]: undefined | (() => IVNode[]); } & IVNode[]; 'props': Record; 'type': symbol | Record; [key: string]: any; } export interface IVueObject { createApp(opt: any): IVApp; ref(obj: T): { 'value': T; }; reactive(obj: T): T; watch(v: any, cb: (n: any, o: any) => void | Promise, opt: Record): void; h(tag: string, props?: Record | any[], list?: any[]): any; } /** --- Vue 选项合并函数 --- */ export type IVueOptionMergeFunction = (to: unknown, from: unknown, instance: IVue) => any; /** --- Vue 配置 --- */ export interface IVueConfig { errorHandler?(err: unknown, instance: IVue | null, info: string): void; 'globalProperties': Record; isCustomElement(tag: string): boolean; 'optionMergeStrategies': Record; 'performance': boolean; warnHandler?(msg: string, instance: IVue | null, trace: string): void; } /** --- Vue 应用 --- */ export interface IVApp { component(name: string): any | undefined; component(name: string, config: any): this; 'config': IVueConfig; directive(name: string): any | undefined; directive(name: string, config: any): this; mixin(mixin: any): this; mount(rootContainer: HTMLElement | string): IVue; provide(key: string, value: T): this; unmount(): void; 'version': string; ['_container']: HTMLElement; } export type TCurrent = string | lForm.AbstractForm | lForm.AbstractPanel | lControl.AbstractControl | lCore.AbstractApp; /** --- tums-player 模块对象 --- */ export interface ITumsPlayer { 'default': any; /** --- 开始对讲 --- */ 'startTalk': (opt: { 'sid': string; 'skey': string; 'url': string; /** --- half_duplex-半双工模式,vad-VAD 人声检测模式,aec-AEC 全双工模式,默认 vad --- */ 'mode'?: 'half_duplex' | 'vad' | 'aec'; }) => Promise; /** --- 停止对讲 --- */ 'stopTalk': () => void; }