# uniMP小程序

# 初始化 sdk 全局环境

interface IInitConfig {
  debug?: boolean
}
function init(ability: UIAbility, stage: window.WindowStage, config?: IInitConfig)

# 获取uni小程序应用资源部署路径

function getUniMPRunPath(appID: string): string

# 判断应用资源是否已经部署

function isExistsUniMP(appId: string): boolean

# 将wgt应用资源包部署到运行路径中

type ReleaseWgtToRunPathCallback = (code: 1 | -1, error?: Error) => void
function releaseWgtToRunPath(appID: string, wgtPath: string, callback: ReleaseWgtToRunPathCallback)

# 获取已经部署的小程序应用资源版本信息

interface IAppVersionInfo {
  name: string
  code: string
}
function getAppVersionInfo(appId: string): IAppVersionInfo | null

# 启动小程序应用并获得IUniMP实例

interface ICapsuleStyle {
  backgroundColor?: string
  textColor?: string
  highlightColor?: string
  borderColor?: string
}

interface ICapsuleMenuActionSheetItem {
  id: string
  title: string
}

interface IOpenUniMPConfig {
  showCapsuleButton?: boolean
  capsuleMenuActionSheetItems?: ICapsuleMenuActionSheetItem[]
  capsuleButtonStyle?: ICapsuleStyle
}

export interface IUniMP {
  hide(): void
  show(): void
  close(): void
  sendUniMPEvent: (event: string, data: ESObject) => void
  on(event: 'uniMPEvent', callback: (event: string, data: ESObject, notify: (...args: ESObject[]) => void) => void): void
  on(event: 'menuItemClick', callback: (id: string) => void): void
  on(event: 'close' | 'show' | 'hide', callback: () => void): void
  off(name: string, callback: Function): void
}

function openUniMP(appID: string, config?: IOpenUniMPConfig): IUniMP

# IUniMP实例下的API

# 隐藏当前小程序应用

hide(): void

# 显示当前小程序应用

show(): void

# 关闭当前小程序应用

close(): void

# 向小程序发送事件

sendUniMPEvent: (event: string, data: ESObject) => void

# 监听小程序发送过来的事件

on(event: 'uniMPEvent', callback: (event: string, data: ESObject, notify: (...args: ESObject[]) => void) => void): void

# 监听右上角菜单的点击事件

on(event: 'menuItemClick', callback: (id: string) => void): void

# 监听小程序隐藏、显示、关闭事件

on(event: 'close' | 'show' | 'hide', callback: () => void): void

# 移除对应的监听事件

off(name: string, callback: Function): void