/** * Indicates the Json types, incldue `undefind` cause of * Sometimes we allow some typing property is optional. */ export type Json = undefined | null | boolean | number | string | Json[] | { [prop: string]: Json; }; /** * The plain object */ export type PlainObject = Record; /** * 保证第一层Map不存在 `Record` */ export type PlainObjectNoFunction = Record; /** * 支持注册同步方法对象(对象里面包含方法或者属性) * OR * 支持注册异步方法对象(对象里面包含方法或者属性) */ export type RegisterPlainObject = { [propName: string]: Json | K; }; /** * 1. Web注册的函数, 处理Native请求返回调用Native的数据类型 * 2. 或者Web主动调用Native接口参数类型. * Note: 基础类型或者深度Map类型, 但是不包含函数 */ export type CallNtvData = Json; /** * Web注册的函数, 接收Native主动调用的参数类型约束 * Note: 基础类型或者深度Map类型, 但是不包含函数 */ export type FromNtvData = Json; /** * Web调用收到Native回调的数据类型约束 */ export type ReceiveNtvCallbackData = Json; /** * Web用来异步接收Native处理结果, 回调回来的数据处理函数 */ export type ReceiveNtvCallback = (data: FabricCallbackData) => void; /** * 接口返回报文通讯协议范型, 只针对接口返回结果给调用者. 发起的调用参数不需要约束 * 1. 所有的传输报文(发送/接收)都放到一个参数字段下面, 这个字段类型由具体接口实现进行约定. * 2. 所有约定好的bridge传输参数对象(发送/接收)都必须经过JSON.stringify()序列化之后传输. * 3. 接口传输报文可以是 `T extends Primitive` 等任何数据类型.但是都需要经过JSON序列化 如 字符串1 系列化成 `"1"` */ export type FabricCallbackData = { /** * code: 字符串 '0' 的时候为接口处理成功, 否则为接口处理异常 * 具体处理异常可以根据接口具体的场景进行1对1约定. 比如 '1' 在网络请求中表示网络不通. 等 * 如果页面bridgejs报错则code='fabric_catched_error' * `ntv_input_error`->如果Native解析当前插件输入参数失败, 如入参不匹配, 入参jsonParse error等 * `ntv_parse_error`->如果Native处理完插件任务,转换结果出错了, 则统一抛出此`code` * `ntv_method_not_found`-> 如果Native处理未定义此插件, 则统一抛出此`code` * `ntv_permission_reject`->如果Native处理过程中遇到未授权, 则统一抛出此`code`, 注意如果权限需要细分, 则catch住使用业务data.xx契约定义 * `ntv_view_window_cancelled`->如果Native带有VIEW视窗,通常需要提供cancel取消的能力, 则统一抛出此`code`, 如需要细分则使用业务data.xx契约定义 */ code: "fabric_catched_error" | "ntv_method_not_found" | "ntv_input_error" | "ntv_parse_error" | "ntv_permission_reject" | "ntv_view_window_cancelled" | string; /** * 业务报文数据存放, 根据业务场景约定, 比如文件上传, 可能包含complete参数, 表示当前还为完成, * 为了方便, data里面也同时传回complete, 不使用协议层的complete参数. */ data: T; /** * 业务报文数据存放, Native端解析出错, 异常, 或者发生了什么不可预知的错误的时候会放到message里面 */ message?: string; }; /** * 注册同步回调函数的函数类型 * @param data 接收native主动调用的参数对象 * @returns 同步回调给native的数据(`ICallbackToNtvData`) */ export type RegisterSyncCallback = (data: IFromNtvData) => FabricCallbackData; /** * 注册异步回调函数的函数类型 * @param data 接收native主动调用的参数对象 */ export type RegisterAsyncCallback = (data: IFromNtvData, /** * @param data 异步回调给native的数据(`ICallbackToNtvData`) * @param complete default is `true` */ callback: (data: FabricCallbackData, complete?: boolean) => void) => void; /** * call is overload definition, we must make sure that the priority of `signature` as below */ export interface WebviewJavascriptBridgeApi { /** * Call Native API In javascript `synchronous call` with `void` return * @param method */ call(method: TMethod): void; /** * Call Native API In javascript `synchronous call` * @example * ```ts * const result = call('http'); * console.log(result.code); * ``` */ call(method: TMethod): FabricCallbackData; /** * Call Native API In javascript `synchronous call` with options with `void` return * @param method * @param options */ call(method: TMethod, options: TOptions): void; /** * Call Native API In javascript `synchronous call` * @example * ```ts * const result1 = call('http', { name: 'name' }); * console.log(result1.code); * ``` */ call(method: TMethod, options: TOptions): FabricCallbackData; /** * Call Native API In javascript `asynchronous call` * @example * ```ts * call('http', function (data) { * console.log(data.code); * }); * ``` */ call(method: TMethod, callback: ReceiveNtvCallback): void; /** * Call Native API In javascript `asynchronous call` * @example * ```ts * call('http', { name: 'ddd' }, function (data) { * console.log(data.code); * }); * ``` */ call(method: TMethod, options: TOptions, callback?: string | ReceiveNtvCallback): void; /** * 注册一个同步方法 * @param method 方法名, 字符串, 可以带命名空间e.g. `addValue`、`http.addValue` * @param fun 注册内容体, 函数, 或者对象(里面包含多个函数) */ registerSync(name: string, fun: RegisterSyncCallback | RegisterPlainObject): void; /** * 注册一个异步方法 * @param method 方法名, 字符串, 可以带命名空间e.g. `addValue`、`http.addValue` * @param fun 注册内容体, 函数, 或者对象(里面包含多个函数) */ registerAsync(name: string, fun: RegisterAsyncCallback | RegisterPlainObject): void; /** * Native内置接口, 判断指定调用的接口是否存在. * @param name 接口名称 * @param type android 只支持`all`, 此参数用处不大. */ ntvHasMethod: (name: string, type?: "all") => boolean; /** * 当存在 Native主动call->web提供的注册接口的情况(registerSync,registerAsync). * 我们需要考虑等待Web端接口注册完毕, 才处理存储的native提前发过来的消息(android)或者告知native可以调用web注册的接口了(ios) */ webIsReady(): void; /** * 函数check window 一个变量是否存在,给一个最大的等待时间,如果超过这个时间还是没有这个变量,则认为是不存在的。 * @param methodName Android的插件方法名, 支持 path 检测。 * @param maxWaitTime 最大等待时间, 默认500毫秒 * @returns true 插件准备就绪,false 插件未准备就绪 */ awaitNtvPluginReady(methodName: string, maxWaitTime?: number): Promise; } export declare const core: WebviewJavascriptBridgeApi; declare class FabricError extends Error { code: string; message: string; data: any; protected constructor(code: string, message: string, data: any); toJSON: () => { name: any; code: any; data: any; message: any; description: any; number: any; fileName: any; lineNumber: any; columnNumber: any; stack: any; }; } export declare const errors: { fabricErrors: { FABRIC_API_CODE_NO_ZERO_ERROR: { code: string; message: string; }; FABRIC_JS_CATCH_ERROR: { code: string; message: string; }; FABRIC_NATIVE_METHOD_NOT_FOUND_ERROR: { code: string; message: string; }; FABRIC_NATIVE_INPUT_PARSE_ERROR: { code: string; message: string; }; FABRIC_NATIVE_RESULT_PARSE_ERROR: { code: string; message: string; }; FABRIC_NATIVE_PERMISSION_REJECT_ERROR: { code: string; message: string; }; FABRIC_NATIVE_VIEW_WINDOW_CANCELLED_ERROR: { code: string; message: string; }; }; isFabricError: (err?: Error | FabricError | null) => err is FabricError; filterFabricErrors: (code: string, message?: string, data?: any) => FabricError | null; }; /** * 返回登陆成功的结果信息, 用户信息+acessToken */ export type FabricLoginCallbackData = { /** * 当前动作为用户主动取消登陆流程. 如果不传则为正常逻辑. */ action?: "cancelled"; /** * 当前携带的用户信息 */ userInfo: T; /** * 如果取消登陆, 返回的accessToken就等于空字符串 */ accessToken: string; }; export type AuthLogin = () => Promise>; export type AuthLogout = () => void; /** * Auth API * @interface */ export type FabricAuthApi = { /** * 无论当前未登录/已经登陆都不启动登陆界面, 但是返回已存在的`授权`数据 */ tryLogin: AuthLogin; /** * 如果当前未登录: 则强制启动登陆面板执行完登陆流程, 返回调用端`授权`数据; 如果已登陆, 则直接返回`授权`不启动登陆面板. */ forceLogin: AuthLogin; /** * 同步接口, 注销用户信息, 注销用户已有的授权信息 */ logout: AuthLogout; }; export declare const fabricAuth: FabricAuthApi; export type FabricCryptoStateOptions = { /** * '0': 状态关闭, '1': 标识 fabric_http.request 开启加密 * @default '1' */ state: "0" | "1"; }; export type FabricCryptoStateCallbackData = FabricCryptoStateOptions; export type FabricHttpSetCryptoStateApi = (options: FabricCryptoStateOptions) => boolean; export type FabricHttpCheckCryptoStateApi = () => FabricCryptoStateCallbackData; /** * 文件下载输入报文 */ export type FabricHttpFileDownloadOptions = { /** * 下载资源的 url */ url: string; /** * 指定文件下载后存储的路径 */ filePath?: string; /** * HTTP 请求的 Header,Header 中不能设置 Referer */ headers?: Record; /** * 超时时间,单位为毫秒 */ timeout?: number; }; /** * 文件下载输入报文 */ export type FabricHttpFileDownloadCallbackData = { /** * 用户文件路径 (本地路径)。传入 filePath 时会返回,跟传入的 filePath 一致 */ filePath: string; /** * 临时文件路径 (本地路径)。没传入 filePath 指定文件存储路径时会返回,下载后的文件会存储到一个临时文件 */ tempFilePath: string; /** * 开发者服务器返回的 HTTP 状态码 */ statusCode: number; /** * 上传进度0-1, 1:标识当前文件下载完成, * 此处一定会等于1, 并且==1的时候Native执行callback complete清理内存 */ progress: number; }; export type FabricHttpDownloadApi = (options: FabricHttpFileDownloadOptions) => Promise; /** * 网络请求的输入报文 */ export type FabricHttpRequestOptions = { /** * 开发者服务器接口地址 */ url: string; /** * 请求的参数, object, GET请求, 则自动拼接到URL query, POST则post body发送服务器 */ data?: T; /** * HTTP 请求方法 * @default 'GET' */ method: "GET" | "POST"; /** * 设置请求的 header,header 中不能设置 Referer。content-type 默认为 application/json */ headers?: Record; /** * 超时时间,单位为秒second * @default 60 s */ timeout?: number; }; /** * 发送网络请求, 返回业务数据报文协议 */ export type FabricHttpRequestCallbackData = { /** * 开发者服务器返回的数据 */ data: T; /** * 开发者服务器返回的 HTTP Response Header */ headers: Record; /** * 开发者服务器返回的 HTTP 状态码 */ statusCode: number; }; export type FabricHttpRequestApi = = Record>(options: FabricHttpRequestOptions) => Promise>; /** * 文件上传输入报文 */ export type FabricHttpFileUploadOptions = { /** * 开发者服务器地址 */ url: string; /** * 文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容 */ name: string; /** * 要上传文件资源的路径 (本地路径), 可以传多少张图 * http://temp/sfs23423042.png */ filePath: string[]; /** * HTTP 请求中其他额外的 form data */ formData?: Record; /** * HTTP 请求 Header,Header 中不能设置 Referer */ headers?: Record; /** * 超时时间,单位为毫秒 */ timeout?: number; }; /** * 文件上传接收报文 */ export type FabricHttpFileUploadCallbackData = { /** * 开发者服务器返回的数据, 只有在prgress = 100 的时候才有值 */ data?: T; /** * 发者服务器返回的 HTTP 状态码 */ statusCode?: number; /** * 上传进度0-100, 100:标识当前文件上传完成, * 此处一定会等于100, 并且==100的时候Native执行callback complete清理内存 */ progress: number; }; /** * 当前文件上传的状态 */ export type FabricHttpUploadFileStatus = "uploading" | "complete"; export type FabricHttpUploadFileApi = (options: FabricHttpFileUploadOptions, callback?: (err: FabricError | null, status: FabricHttpUploadFileStatus, result: FabricHttpFileUploadCallbackData) => void) => void; export type FabricHttpApi = { /** * 发送网络请求, 返回业务数据报文协议 */ request: FabricHttpRequestApi; /** * 下载网络文件到本地 */ downloadFile: FabricHttpDownloadApi; /** * 上传本地文件到网络服务器 */ uploadFile: FabricHttpUploadFileApi; /** * 置网络通道是否走全报文加密. */ setCryptoState: FabricHttpSetCryptoStateApi; /** * 获取网络通道是否走全报文加密的标识位. */ checkCryptoState: FabricHttpCheckCryptoStateApi; }; export declare const fabricHttp: FabricHttpApi; /** * 获取当前的地理位置、速度。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。 * 地图相关使用的坐标格式应为 gcj02, 注意此处iOS使用内置地图引擎(非高德) */ export type FabricLocationOptions = { /** * wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 * @default wgs84 */ type?: string; /** * 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 */ altitude?: boolean; /** * 开启高精度定位 * @default false */ isHighAccuracy?: boolean; /** * 定位超时时间(ms), 不提供则无限等待定位结果 * @default 30000 */ expireTime?: number; }; /** * 打开调试模式, 结果返回 */ export type FabricLocationCallbackData = { /** * 纬度,范围为 -90~90,负数表示南纬 */ latitude: string; /** * 经度,范围为 -180~180,负数表示西经 */ longitude: string; /** * 速度,单位 m/s */ speed: string; /** * 位置的精确度 */ accuracy: string; /** * 高度,单位 m */ altitude: string; /** * 城市名称 */ cityName?: string; }; export type FabricLocationGetLocationApi = (options: FabricLocationOptions) => Promise; export type FabricLocationApi = { /** * 获取当前的地理位置、速度。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间 * 如果定位被用户强制关闭, 或者用户点了拒绝, 或者在设置里面禁用了, 返回错误code:`location_permission_disallow` */ getLocation: FabricLocationGetLocationApi; }; export declare const fabricLocation: FabricLocationApi; declare enum FabricAnnotationType { /** * 点标注 */ image = "image", /** * 大头针标注, 地图内置. */ pin = "pin", /** * 动画标注 */ animation = "animation" } declare enum FabricAnnotationAnimationType { /** * 无动画 */ none = "none", /** * 移动动画,主要用于司机卡车移动, 只有更新已有标注才有效 */ move = "move" } declare enum CalloutRichTextDockDirection { top = "top", right = "right", bottom = "bottom", left = "left" } declare enum MapDistanceSearchType { /** * 直线距离 */ DistanceSearchTypeStraight = 0, /** * 驾车导航距离 */ DistanceSearchTypeDrive = 1, /** * 步行导航距离 */ DistanceSearchTypeWalk = 3 } declare enum FabricMapErrorCode { /** * 非法URL */ invalidURL = "invalidURL", /** * 非法参数 */ invalidParam = "invalidParam", /** * 地图未找到 */ mapNotFound = "mapNotFound", /** * 地图加载失败 */ mapDidFailLoading = "mapDidFailLoading", /** * 地图定位用户失败 */ mapDidFailToLocateUser = "mapDidFailToLocateUser", /** * 地图搜索类初始化失败 */ mapSearchAPIFailToInit = "searchAPIFailToInit", /** * 地图搜索方法不存在 */ mapSearchMethodNotFound = "mapSearchMethodNotFound", /** * 地图搜索参数不存在 */ mapSearchParamNotFound = "mapSearchParamNotFound", /** * 地图搜索参数序列化出错 */ mapSearchParamSerializeError = "mapSearchParamSerializeError" } declare enum MAPinAnnotationColor { /** * 红色大头针 */ ColorRed = 0, /** * 绿色大头针 */ ColorGreen = 1, /** * 紫色大头针 */ ColorPurple = 2 } declare enum MapSupplierType { /** * AMap */ MapSupplierTypeAMap = -1, /** * Baidu */ MapSupplierTypeBaidu = 0, /** * MapBar */ MapSupplierTypeMapBar = 1, /** * MapABC */ MapSupplierTypeMapABC = 2, /** * SoSoMap */ MapSupplierTypeSoSoMap = 3, /** * AliYun */ MapSupplierTypeAliYun = 4, /** * Google */ MapSupplierTypeGoogle = 5, /** * GPS */ MapSupplierTypeGPS = 6 } declare enum FabricMapNaviType { /** * 自驾 */ drive = 0, /** * 步行 */ walking = 1, /** * 公共交通 */ bus = 2, /** * 火车 */ railway = 3, /** * 骑行 */ riding = 4 } declare enum FabricMapPathType { /** * 单路径 */ singleLine = 0, /** * 多路径 */ multiLine = 1 } declare enum FabricMALineJoinType { /** * 斜面连接点 */ kMALineJoinBevel = 0, /** * 斜接连接点 */ kMALineJoinMiter = 1, /** * 圆角连接点 */ kMALineJoinRound = 2 } declare enum FabricMALineCapType { /** * 普通头 */ kMALineCapButt = 0, /** * 扩展头 */ kMALineCapSquare = 1, /** * 箭头 */ kMALineCapArrow = 2, /** * 圆形头 */ kMALineCapRound = 3 } declare enum FabricMALineDashType { /** * 不画虚线 */ kMALineDashTypeNone = 0, /** * 方块样式 */ kMALineDashTypeSquare = 1, /** * 圆点样式 */ kMALineDashTypeDot = 2 } export type MapSize = { /** * 矩形x->宽度 * 网页的绝对PX, 和div高度定义的高度一致, Native自动根据屏幕分辨率做转换 iphone 12可能是390宽度 */ width: number; /** * 矩形y->高度 * 网页的绝对PX, 和div高度定义的高度一致, Native自动根据屏幕分辨率做转换 iphone 12可能是390宽度 */ height: number; }; export type MapPoint = { /** * 网页的绝对PX, 和div高度定义的高度一致, Native自动根据屏幕分辨率做转换 iphone 12可能是390宽度 */ x: number; /** * 网页的绝对PX, 和div高度定义的高度一致, Native自动根据屏幕分辨率做转换 iphone 12可能是390宽度 */ y: number; }; /** * 屏幕矩形区域; 矩形起点: {x,y }, width, height 决定一个热曲(矩形) */ export type MapRectangleArea = MapSize & MapPoint; /** * 经纬度, description中格式为 <经度,纬度> */ export type MapGeoPoint = { /** * 经度(水平方向) */ longitude: number; /** * 纬度(垂直方向) */ latitude: number; }; /** * 行政区划 */ export type MapDistrict = { /** * 区域编码 */ adcode: string; /** * 城市编码 */ citycode: string; /** * 行政区名称 */ name: string; /** * 级别 */ level: string; /** * 城市中心点 */ center: MapGeoPoint; /** * 下级行政区域数组 */ districts: MapDistrict[]; /** * 行政区边界坐标点, NSString 数组 */ polylines: string[]; }; /** * 城市 */ export type MapCity = { /** * 城市名称 */ city: string; /** * 城市编码 */ citycode: string; /** * 城市区域编码 */ adcode: string; /** * 此区域的建议结果数目, AMapSuggestion 中使用 */ num: number; /** * 途径区域 AMapDistrict 数组,AMepStep中使用,只有name和adcode。 */ districts: MapDistrict[]; }; /** * 建议信息 */ export type MapSuggestion = { /** * NSString 数组 */ keywords: string[]; /** * AMapCity 数组 */ cities: MapCity[]; }; export type MapIndoorData = { /** * 楼层,为0时为POI本身 */ floor: number; /** * 楼层名称 */ floorName: string; /** * 建筑物ID */ pid: string; }; /** * 兴趣区域 */ export type MapAOI = { /** * AOI全局唯一ID */ uid: string; /** * 名称 */ name: string; /** * 所在区域编码 */ adcode: string; /** * 中心点经纬度 */ location: MapGeoPoint; /** * 面积,单位平方米 */ area: number; }; export type MapPOI = { /** * POI全局唯一ID */ uid: string; /** * 名称 */ name: string; /** * 兴趣点类型 */ type: string; /** * 类型编码 */ typecode: string; /** * 经纬度 */ location: MapGeoPoint; /** * 地址 */ address: string; /** * 电话 */ tel: string; /** * 距中心点的距离,单位米。在周边搜索时有效 */ distance: number; /** * 停车场类型,地上、地下、路边 */ parkingType: string; /** * 商铺id */ shopID: string; /** * 邮编 */ postcode: string; /** * 网址 */ website: string; /** * 电子邮件 */ email: string; /** * 省 */ province: string; /** * 省编码 */ pcode: string; /** * 城市名称 */ city: string; /** * 城市编码 */ citycode: string; /** * 区域名称 */ district: string; /** * 区域编码 */ adcode: string; /** * 地理格ID */ gridcode: string; /** * 入口经纬度 */ enterLocation: MapGeoPoint; /** * 出口经纬度 */ exitLocation: MapGeoPoint; /** * 方向 */ direction: string; /** * 是否有室内地图 */ hasIndoorMap: boolean; /** * 所在商圈 */ businessArea: string; /** * 室内信息 */ indoorData: MapIndoorData; /** * 子POI列表 */ subPOIs: MapSubPOT[]; /** * 图片列表 */ images: MapImage[]; }; /** * POI图片信息 */ export type MapImage = { /** * 标题 */ title: string; /** * url */ url: string; }; export type MapSubPOT = { /** * POI全局唯一ID */ uid: string; /** * 名称 */ name: string; /** * 名称简写 */ sname: string; /** * 经纬度 */ location: MapGeoPoint; /** * 地址 */ address: string; /** * 距中心点距离 */ distance: number; /** * 子POI类型 */ subtype: string; }; /** * POI搜索参数基础数据结构 */ export type PoiSearchParam = { /** * 当前页数, 范围1-100, [default = 1] * @default 1 */ page?: number; /** * 每页记录数, 范围1-25, [default = 20] * @default 20 */ offset?: number; /** * 类型,多个类型用“|”分割 可选值:文本分类、分类代码 */ types?: string; /** * 排序规则, 0-距离排序;1-综合排序, 默认0 */ sortrule?: number; /** * 建筑物POI编号,传入建筑物POI之后,则只在该建筑物之内进行搜索(since 4.5.0) */ building?: string; /** * 是否返回子POI,默认为 NO。 */ requireSubPOIs?: boolean; } & T; /** * POI搜索参数返回结基础数据结构 */ export type PoiSearchResult = { /** * POI结果,AMapPOI 数组 */ pois: MapPOI[]; } & T; /** * 地址组成要素 */ export type MapAddressComponent = { /** * 国家(since 5.7.0) */ country: string; /** * 国家简码(since 7.4.0)仅海外生效 */ countryCode: string; /** * 省/直辖市 */ province: string; /** * 市 */ city: string; /** * 城市编码 */ citycode: string; /** * 区 */ district: string; /** * 区域编码 */ adcode: string; /** * 乡镇街道 */ township: string; /** * 乡镇街道编码 */ towncode: string; /** * 社区 */ neighborhood: string; /** * 建筑 */ building: string; }; /** * 道路 */ export type MapRoad = { /** * 道路ID */ uid: string; /** * 道路名称 */ name: string; /** * 距离(单位:米) */ distance: number; /** * 方向 */ direction: string; /** * 坐标点 */ location: MapGeoPoint; }; /** * 道路交叉口 */ export type MapRoadInter = { /** * 距离(单位:米) */ distance: number; /** * 方向 */ direction: string; /** * 经纬度 */ location: MapGeoPoint; /** * 第一条道路ID */ firstId: string; /** * 第一条道路名称 */ firstName: string; /** * 第二条道路ID */ secondId: string; /** * 第二条道路名称 */ secondName: string; }; /** * 逆地理编码 */ export type MapReGeocode = { /** * 格式化地址 */ formattedAddress: string; /** * 地址组成要素 */ addressComponent: MapAddressComponent; /** * 道路信息 AMapRoad 数组 */ roads: MapRoad[]; /** * 道路路口信息 AMapRoadInter 数组 */ roadinters: MapRoadInter[]; /** * 兴趣点信息 AMapPOI 数组 */ pois: MapPOI[]; /** * 兴趣区域信息 AMapAOI 数组 */ aois: MapAOI[]; }; /** * 路段基本信息 */ export type MapStep = { /** * 唯一ID, 暂时不考虑多路径; 如果多条, 每条都包含 */ id: string; /** * 行走指示 */ instruction: string; /** * 方向 */ orientation: string; /** * 道路名称 */ road: string; /** * 此路段长度(单位:米) */ distance: number; /** * 此路段预计耗时(单位:秒) */ duration: number; /** * 此路段坐标点串 */ polyline: string; /** * 导航主要动作 */ action: string; /** * 导航辅助动作 */ assistantAction: string; /** * 此段收费(单位:元) */ tolls: number; /** * 收费路段长度(单位:米) */ tollDistance: number; /** * 主要收费路段 */ tollRoad: string; /** * 途径城市 AMapCity 数组,只有驾车路径规划时有效 */ cities: Array; /** * 路况信息数组,只有驾车路径规划时有效 */ tmcs: Array; }; /** * 实时路况信息 */ export type MapTMC = { /** * 长度(单位:米) */ distance: number; /** * 路况状态描述:0 未知,1 畅通,2 缓行,3 拥堵,4 严重拥堵 */ status: string; /** * 此路段坐标点串 */ polyline: string; }; /** * 步行、骑行、驾车方案 */ export type MapPath = { /** * 唯一ID, 暂时不考虑多路径; 如果多条, 每条都包含 */ id: string; /** * 起点和终点的距离 */ distance: number; /** * 预计耗时(单位:秒) */ duration: number; /** * 导航策略 */ strategy: string; /** * 导航路段 AMapStep 数组 */ steps: Array; /** * 此方案费用(单位:元) */ tolls: number; /** * 此方案收费路段长度(单位:米) */ tollDistance: number; /** * 此方案交通信号灯个数 */ totalTrafficLights: number; /** * 限行信息,仅在驾车和货车路径规划时有效。(since 6.0.0) * 驾车路径规划时: * 0 代表限行已规避或未限行; 1 代表限行无法规避。 * 货车路径规划时: * 0,未知(未输入完整/正确车牌号信息时候显示) * 1,已规避限行 * 2,起点限行 * 3,途径点在限行区域内(设置途径点才出现此报错) * 4,途径限行区域 * 5,终点限行 */ restriction: number; /** * 规划路径完整坐标点串集合 */ polyline: string; /** * 经纬度数组 */ coordinates: MapPoint[]; }; /** * 公交方案 */ export type MapTransit = { /** * 此公交方案价格(单位:元) */ cost: number; /** * 此换乘方案预期时间(单位:秒) */ duration: number; /** * 是否是夜班车 */ nightflag: boolean; /** * 此方案总步行距离(单位:米) */ walkingDistance: number; /** * 换乘路段 MapSegment 数组 */ segments: Array; /** * 当前方案的总距离 */ distance: number; }; /** * 公交换乘路段,如果walking和buslines同时有值,则是先walking后buslines */ export type MapSegment = { /** * 此路段步行导航信息 */ walking: MapWalking; /** * 此路段可供选择的不同公交线路 AMapBusLine 数组 */ buslines: Array; /** * 出租车信息,跨城时有效 */ taxi: MapTaxi; /** * 火车信息,跨城时有效 */ railway: MapRailway; /** * 入口名称 */ enterName: string; /** * 入口经纬度 */ enterLocation: MapGeoPoint; /** * 出口名称 */ exitName: string; /** * 出口经纬度 */ exitLocation: MapGeoPoint; }; /** * 出租车信息 */ export type MapTaxi = { /** * 起点坐标 */ origin: MapGeoPoint; /** * 终点坐标 */ destination: MapGeoPoint; /** * 距离,单位米 */ distance: number; /** * 耗时,单位秒 */ duration: number; /** * 起点名称 */ sname: string; /** * 终点名称 */ tname: string; }; /** * 公交线路 */ export type MapBusLine = { /** * 公交线路ID */ uid: string; /** * 公交类型 */ type: string; /** * 公交线路名称 */ name: string; /** * 坐标集合 */ polyline: string; /** * 城市编码 */ citycode: string; /** * 首发站 */ startStop: string; /** * 终点站 */ endStop: string; /** * 当查询公交站点时,返回的 AMapBusLine 中含有该字段 */ location: MapGeoPoint; /** * 首班车时间 */ startTime: string; /** * 末班车时间 */ endTime: string; /** * 所属公交公司 */ company: string; /** * 距离。在公交线路查询时,该值为此线路的全程距离,单位为千米; 在公交路径规划时,该值为乘坐此路公交车的行驶距离,单位为米 */ distance: number; /** * 起步价 */ basicPrice: number; /** * 全程票价 */ totalPrice: number; /** * 本线路公交站 AMapBusStop 数组 */ busStops: Array; /** * 起程站 */ departureStop: MapBusStop; /** * 下车站 */ arrivalStop: MapBusStop; /** * 途径公交站 AMapBusStop 数组 */ viaBusStops: Array; /** * 预计行驶时间(单位:秒) */ duration: number; }; /** * 公交站 */ export type MapBusStop = { /** * 公交站点ID */ uid: string; /** * 区域编码 */ adcode: string; /** * 公交站名 */ name: string; /** * 城市编码 */ citycode: string; /** * 经纬度坐标 */ location: MapGeoPoint; /** * 途径此站的公交路线 AMapBusLine 数组 */ buslines: Array; /** * 查询公交线路时的第几站 */ sequence: string; }; /** * TODO: 暂时未定义, 以后根据使用情况再决定. */ export type MapRailway = { [index: string]: any; }; /** * 步行换乘信息 */ export type MapWalking = { /** * 起点坐标 */ origin: MapGeoPoint; /** * 终点坐标 */ destination: MapGeoPoint; /** * 起点和终点的步行距离 */ distance: number; /** * 步行预计时间 */ duration: number; /** * 步行路段 AMapStep 数组 */ steps: Array; }; /** * 路径规划 */ export type MapRoute = { /** * 起点坐标 */ origin: MapGeoPoint; /** * 终点坐标 */ destination: MapGeoPoint; /** * 出租车费用(单位:元) */ taxiCost: number; /** * 步行、骑行、驾车方案列表 MapPath 数组 */ paths: Array; /** * 公交换乘方案列表 AMapTransit 数组 */ transits: Array; }; /** * 多边形, 当传入两个点的时候,当做矩形处理:左下-右上两个顶点;其他情况视为多边形,几个点即为几边型。 */ export type MapGeoPolygon = { /** * 坐标集, AMapGeoPoint 数组 */ points: Array; }; export type CalloutRichTextContentItemBase = { /** * 文本内容 */ data: string; /** * 上右下左 * @default [0,0,0,0] */ padding?: [ number, number, number, number ]; /** * 是否单行 * true 单行展示 * false 多行展示 * @default false */ singleLine?: boolean; } & T; export type CalloutRichTextContentItemImage = CalloutRichTextContentItemBase<{ /** * 内容类型 */ type: "image"; /** * 如果type:'image', 则提供图片大小 */ imageSize?: MapSize; }>; export type CalloutRichTextContentItemText = CalloutRichTextContentItemBase<{ /** * 内容类型 */ type: "text"; /** * 是否加粗 * @default false */ bold?: boolean; /** * 最大宽度, 如果超过直接换行. 如果是多行, 每行超过则自动换行. */ maxWidth?: number; /** * 字体颜色, 常用透明度对应16进制关系 * 颜色, 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` * @example `#11010010` */ color?: string; /** * 内容是Label阴影半径 */ textShadowColor?: string; /** * 内容是Label阴影半径 */ textShadowBlurRadius?: number; /** * 内容是Label的描边宽度,正值会导致空心,负值导致 * textStrokeWidth这个属性在 andriod 和 ios 上值的含义不一样 * ios是字体宽度的百分比、andriod 是像素 */ textStrokeWidth?: number; /** * 内容是Label的阴影偏移 */ textStrokeColor?: string; /** * 内容是Label的阴影偏移 */ textShadowOffset?: MapPoint; /** * 字体大小 PX */ fontSize?: number; }>; export type AnnotationItem = { /** * 唯一标识 */ id: string; /** * 是否被选中 * @default false */ isSelected: boolean; /** * 原生标题, 如果存在了`calloutHTML`则优先级以`calloutHTML`高 */ title?: string; /** * 原生副标题, 如果存在了`calloutHTML`则优先级以`calloutHTML`高 */ subtitle?: string; /** * 网页富文本, 点击标注弹起的浮窗WebView html内容 */ calloutHTML?: string; /** * 网页富文本, 点击标注弹起的浮窗 WebView 的 大小 */ calloutHTMLSize?: { /** * 网页的绝对PX, 和div高度定义的高度一致, Native自动根据屏幕分辨率做转换 iphone 12可能是390宽度 */ width: number; /** * 网页的绝对PX, 和div高度定义的高度一致, Native自动根据屏幕分辨率做转换 iphone 12可能是390宽度 */ height: number; }; /** * 弹出框默认位于view正中上方,可以设置calloutOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是屏幕坐标 */ calloutOffset?: MapPoint; /** * Native 富文本 */ calloutRichText?: { /** * 最大宽度, 如果超过直接显示.... */ maxWidth?: number; /** * 全局背景色 * 颜色, 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` * @example `#11010010` */ bgColor?: string; /** * 最外层圆角 */ boxRadius?: number; /** * 上右下左 * @default [0,0,0,0] */ boxPadding?: [ number, number, number, number ]; /** * 合子阴影 * https://cssgenerator.org/box-shadow-css-generator.html */ boxShadow?: { offsetX: number; offsetY: number; spreadRadius: number; /** * 颜色, 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` * @example `#11010010` */ color: string; }; /** * 内容组装, 3维数组: * @example * ```ts * contents: [ * // 第一维数组: 左右结构 * [ * // 第二维数组: 上下结构 * [ * // 第三维数组: 左右结构 * {type:'text', data:''},{type:'text'},{type:'image'} * ], * [ * // 第三维数组: 左右结构 * {type:'text'},{type:'text'},{type:'image'} * ], * ], * // 第一维数组: 左右结构 * [ * [],[] * ] * ] * ``` */ contents: Array>[]; /** * 气泡停靠在标记点的方位. * - top - 停靠在标记点上方 * - right - 停靠在标记点右边 * - bottom - 停靠在标记点底边 * - left - 停靠在标记点左边 * - 默认值: top */ dockDirection?: CalloutRichTextDockDirection; }; /** * 默认为YES,当为NO时view忽略触摸事件 */ enabled?: boolean; /** * 是否可以拖动 * @default false */ draggable?: boolean; /** * annotationView是否突出显示(一般不需要手动设置) */ highlighted?: boolean; /** * 设置是否可以显示callout,默认为 Yes * @default true */ canShowCallout?: boolean; /** * 设置是否允许点击地图关闭callout,默认为 Yes * @default true */ canHideCallout?: boolean; /** * Note: FabricAnnotationType.pin (地图内置, 需要传递 `pinColor`) */ type: FabricAnnotationType; /** * @default FabricAnnotationAnimationType.none */ animationType: FabricAnnotationAnimationType; /** * `animationType`如果是FabricAnnotationAnimationType.move * 注意android最小支持的值为: 1s * @default 0.25s */ moveAnimationTime?: number; /** * type === FabricAnnotationType.pin 生效, 需要传递此值 */ pinColor?: MAPinAnnotationColor; /** * Base64 Image String Or Image */ image: string; /** * 图片大小 */ imageSize?: MapSize; /** * Base64 Image String Or Image */ animatedImages?: string[]; /** * 经纬度 */ coordinate: MapGeoPoint; /** * annotationView的中心默认位于annotation的坐标位置,可以设置centerOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是屏幕坐标 */ centerOffset?: MapPoint; /** * z值,大值在上,默认为0。 * @default 0 */ zIndex?: number; /** * 是否固定在屏幕一点, 注意,拖动或者手动改变经纬度,都会导致设置失效, * NOTE: 地图中间那个大头针通常是一个annotation锁屏之后, 并给予一个lockedScreenPoint位置来实现. * @default false */ isLockedToScreen?: boolean; /** * 固定屏幕点的坐标 */ lockedScreenPoint?: MapPoint; /** * 移动方向. 正北为0度,顺时针方向。即正东90,正南180,正西270, * 如果FabricAnnotationAnimationType.Move 的时候Native会尝试计算2个点经纬度的方向, 产生一个动画. 比如2个点之间的路径规划, 小车🚗的行驶方向. * 如果headerDirection存在自定义值, 则native 首先使用自定义的为准, 其次才是自动计算. * 如果不传递Android接收默认值为null, 可以自动计算前后点的角度. */ headerDirection?: string; }; /** * 更新标注的时候会返回当前标注的信息以及屏幕中点的位置. */ export type AnnotationResultBase = AnnotationItem & { /** * 当前点在屏幕中的pixel位置, H5可以考虑实现类似tooltip的模型来代替native 的显示浮窗 * 通常情况下,需求可能存在各种高亮, 颜色, 字体形态的变化, H5可以比较容易自定义UI */ screenPoint: MapPoint; } & T; /** * 删除 标注(大头针等) * @type `removeAnnotations` */ export type RemoveAnnotationsParam = { /** * 删除标点集合 */ annotations: Array>; }; /** * 删除 标注(大头针等)返回结果 */ export type RemoveAnnotationsResult = Array>; /** * 添加、更新标注(大头针等, 注意如果需要将2个点规划的路径限定到特定的区域范围, 可以调用`setMapInView`来实现. * @type `updateAnnotations` */ export type UpdateAnnotationsParam = { /** * 更新标点集合 */ annotations: Array & Required>>; }; /** * 添加、更新标注返回结果 */ export type UpdateAnnotationsResult = { annotations: Array>; }; /** * 获取 标注(大头针等,自身定位除外) * @type `getAllAnnotations` */ export type GetAllAnnotationsParam = {}; /** * 获取 标注(大头针等,自身定位除外),返回结果 */ export type GetAllAnnotationsResult = { annotations: Array>; }; /** * 选中标注(显示浮窗) * @type `selectAnntations` */ export type SelectAnntationsParam = { /** * 选中标注选择, 只需要传递一个值 */ annotations: Array>; }; /** * 选中标注(显示浮窗),返回结果 */ export type SelectAnntationsResult = { annotations: Array>; }; /** * 取消选定标注 (隐藏浮窗) * @type `deselectAnntations` */ export type DeselectAnntationsParam = { /** * 取消标注选择, 只需要传递一个值 */ annotations: Array>; }; /** * 取消选定标注 (隐藏浮窗),返回结果 */ export type DeselectAnntationsResult = { annotations: Array>; }; /** * 更新大头针旗杆, 如需要删除直接使用`removeAnnotations` * @type `updateFlagstick` */ export type UpdateFlagstickParam = Partial> & Required>; /** * 更新大头针旗杆, 返回结果 */ export type UpdateFlagstickResult = { annotations: Array>; }; /** * 移动指定经纬度(点)到地图可视区域中心点, 如果屏幕设置有“大头针小黑柱子”, Native统一会统一执行吸附动画, 移动coordinate到大头针下面. * @type `setMapCenterCoordinate` */ export type SetMapCenterCoordinateParam = { /** * 移动指定经纬度(点)到地图可视区域中心点, 如果屏幕设置有“大头针小黑柱子”, Native统一会统一执行吸附动画, 移动coordinate到大头针下面. * 如果不传递, 默认为当前用户的实时位置, 可以传递指定的经纬度的点. */ coordinate?: MapGeoPoint; /** * 缩放级别(默认3-19,有室内地图时为3-20), Native 初始化默认值 16 * +/-/0, 传递0 不做缩放动作, 但是可以通过返回值回去当下是否可以放大/缩小 */ zoomLevel?: number; }; /** * 根据两个经纬度计算方向角 * @type `coordinateDirection` */ export type GetCoordinateDirectionParam = { /** * 起点坐标 */ origin: MapGeoPoint; /** * 终点坐标 */ destination: MapGeoPoint; }; export type GetCoordinateDirectionResult = { /** * 方向的角度. */ direction: number; }; /** * 根据两个经纬度计算屏幕像素距离 * @type `coordinateScreenDistance` */ export type GetCoordinateScreenDistanceParam = { /** * 起点坐标 */ origin: MapGeoPoint; /** * 终点坐标 */ destination: MapGeoPoint; }; export type GetCoordinateScreenDistanceResult = { /** * 对应点在屏幕中2个点之间的pixel距离. */ distance: number; }; /** * 计算给予的经纬度在屏幕中绝对的pixel位置{x,y} * @type `coordinateScreenPosition` */ export type GetCoordinateScreenPositionParam = { /** * 点的经纬度列表 */ coordinates: MapGeoPoint[]; }; export type GetCoordinateScreenPositionResult = { /** * 对应点在屏幕中的绝对像素位置. */ screenPositions: MapPoint[]; }; export type SetMapPathOperatorItem = { /** * 唯一ID */ id: string; /** * 用于生成笔触纹理id的图片, 优先级高于 strokeColor(支持非PowerOfTwo图片如果您需要减轻绘制产生的锯齿,您可以参考AMap.bundle中的traffic_texture_blue.png的方式,在image两边增加部分透明像素.)。(since 5.3.0) */ strokeImage?: string; /** * 笔触颜色,默认是kMAOverlayRendererDefaultStrokeColor * 需要转换成Native约定的ARGB格式, 透明度放前2位 * 公式如: background: rgba(125, 0, 0, .3); 表示的是30%不透明度的红色背景。把30%的不透明度转换成十六制呢的方法如下:先计算#AA的的十进制x,x/255 = 3/10,解得x=3*255/10,然后再把x换算成十六进制,约等于4C。 * 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` */ strokeColor?: string; /** * 笔触宽度, 单位屏幕点坐标,默认是10 */ lineWidth?: number; /** * LineJoin,默认是kMALineJoinBevel */ lineJoinType?: FabricMALineJoinType; /** * LineCap,默认是kMALineCapButt */ lineCapType?: FabricMALineCapType; /** * 虚线类型, since 5.5.0, 只有设置strokeColor 才有效 */ lineDashType?: FabricMALineDashType; /** * 路径经纬度数组 */ coordinates: MapGeoPoint[]; /** * 是否启用显示范围,YES启用,不启用时展示全路径 since 7.5.0 * Note:启用之后, showRange必须存在. */ showRangeEnabled?: boolean; /** * 显示范围 since 7.5.0 */ showRange?: { /** * <起点位置,整数部分表示起点索引,小数部分表示在线段上的位置 */ begin: number; /** * <终点位置,整数部分表示起点索引,小数部分表示在线段上的位置 */ end: number; }; }; /** * 添加路径 * @type `addPaths` */ export type SetMapAddPathsParam = { paths: [ SetMapPathOperatorItem ]; }; /** * 删除路径 * @type `removePaths` */ export type SetMapRemovePathsParam = { paths: Array>; }; /** * 获取路径 * @type `getAllPaths` */ export type SetMapGetAllPathsParam = {}; /** * 获取路径返回信息 */ export type SetMapGetAllPathsResult = { paths: [ SetMapPathOperatorItem ]; }; /** * 更新路径 * @type `updatePaths` */ export type SetMapUpdatePathsParam = { paths: Array & Pick>; }; /** * 交换路径 * @type `exchangePath` */ export type SetMapExchangePathParam = { path1: Pick; path2: Pick; }; /** * 根据起点/终点智能规划路径, 路径效果暂时native应编码一个版本即可. * 注意如果需要将2个点规划的路径限定到特定的区域范围, 可以调用`setMapInView`来实现. * @type `setMapPathPlanning` */ export type SetMapPathPlanningParam = { /** * 步行/驾车/打车 */ naviType?: FabricMapNaviType; /** * 路径类型; 单路径/多路径 */ pathType?: FabricMapPathType; /** * 驾车导航策略,默认策略为0。 * 0,速度优先(时间);1,费用优先(不走收费路段的最快道路);2,距离优先;3,不走快速路;4,躲避拥堵; * 5,多策略(同时使用速度优先、费用优先、距离优先三个策略计算路径),其中必须说明,就算使用三个策略算路,会根据路况不固定的返回一至三条路径规划信息; * 6,不走高速;7,不走高速且避免收费;8,躲避收费和拥堵;9,不走高速且躲避收费和拥堵; * 10,多备选,时间最短,距离最短,躲避拥堵(考虑路况); * 11,多备选,时间最短,距离最短; * 12,多备选,躲避拥堵(考虑路况); * 13,多备选,不走高速; * 14,多备选,费用优先; * 15,多备选,躲避拥堵,不走高速(考虑路况); * 16,多备选,费用有限,不走高速; * 17,多备选,躲避拥堵,费用优先(考虑路况); * 18,多备选,躲避拥堵,不走高速,费用优先(考虑路况); * 19,多备选,高速优先; * 20,多备选,高速优先,躲避拥堵(考虑路况) * @default 0 */ strategy?: number; /** * 起始点 */ origin: MapGeoPoint; /** * 终点 */ destination: MapGeoPoint; /** * 路径是否自动移动到可视区域内(`setMapScreenViewportArea`) * @default true */ moveToViewportArea?: boolean; /** * 途经点 AMapGeoPoint 数组,目前最多支持6个途经点 */ waypoints?: Array; /** * Base64 Image String, 绘制路径的笔触图片, 路径平铺背景图. 如果不传Native 可能显示一个默认的颜色. */ strokeImage?: string; }; /** * 根据起点/终点智能规划路径, 路径规划成功后返回的信息 */ export type SetMapPathPlanningResult = MapRoute; /** * 设置Native地图中划线起点/终点落在的区域,Native 需要根据这个区域做适当的缩放计算. * @type `setMapScreenViewportArea` */ export type SetMapScreenViewportAreaParam = { /** * 可视区域 */ area: MapRectangleArea; /** * 可视点; 可选, 如果配置当前希望实时聚焦移动到area的中心. */ coordinates?: Array; }; /** * 设置地图居中展示区域的中心点位置的API输入参数, 其他地图移动都会依据这个显示位置的缩放, 移动, 聚拢. * 同时默认情况下, Native会自动更新用户位置, 自动移动到中心点位置; 注意此处如果native获取定位更早, 他可能会移动到native * 默认的中心点, 而不是我们自定义的中心点, 此时可以通过调用`setMapCenterCoordinate`来主动移动. * @type `setMapScreenViewportCenter` */ export type SetMapScreenViewportCenterParam = { /** * 屏幕地图展示区域的中心点显示位置. */ point: MapPoint; }; /** * 转换地图厂商的经纬度, 百度坐标系转换为腾讯等地图的经纬度坐标转换为高德坐标系 * @type `mapSupplierCoordinateExchange` */ export type MapSupplierCoordinateExchangeParam = { /** * 地图厂商类型 * 百度, 腾讯,... */ type: MapSupplierType; /** * 对应厂商经纬度, type:百度 对应coordinate为百度的坐标, 目标转化为高度的坐标系 */ coordinate: MapGeoPoint; }; /** * 转换地图厂商的经纬度, 百度坐标系转换为腾讯等地图的经纬度坐标转换为高德坐标系 * @type `mapSupplierCoordinateExchange` */ export type MapSupplierCoordinateExchangeResult = { /** * 转换后的高德地图坐标系的经纬度. */ coordinate: MapGeoPoint; }; declare enum UserTrackMode { /** * 不追踪用户的location更新 */ none = 0, /** * 追踪用户的location更新 */ follow = 1, /** * 追踪用户的location与heading更新 */ followWithHeading = 2 } /** * 更新用户定位标注 * @type `setUserLocationRepresentation` */ export type SetUserLocationRepresentationParam = { /** * 用户信息位置是否显示, 默认true * @default true */ showsUserLocation?: boolean; /** * 用户跟踪模式 * @default `UserTrackMode.followWithHeading` */ userTrackMode?: UserTrackMode; /** * 精度圈是否显示,默认YES * @default true */ showsAccuracyRing?: boolean; /** * 是否显示方向指示(followWithHeading模式开启)。默认为YES * @default true */ showsHeadingIndicator?: boolean; /** * 精度圈 填充颜色, 默认 [UIColor colorWithRed:136/255.0 green:166/255.0 blue:227/255.0 alpha:.3] * 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` * @default `#11010010` */ fillColor?: string; /** * 精度圈 边线颜色, 默认 [UIColor colorWithRed:136/255.0 green:166/255.0 blue:227/255.0 alpha:.3] * 需要转换成Native约定的ARGB格式, 透明度放前2位 * 公式如: background: rgba(125, 0, 0, .3); 表示的是30%不透明度的红色背景。把30%的不透明度转换成十六制呢的方法如下:先计算#AA的的十进制x,x/255 = 3/10,解得x=3*255/10,然后再把x换算成十六进制,约等于4C。 * 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` */ strokeColor?: string; /** * 精度圈 边线宽度,默认0 * @default 0 */ lineWidth?: string; /** * 定位点背景色,不设置默认白色 * 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` */ locationDotBgColor?: string; /** * 定位点蓝色圆点颜色,不设置默认蓝色 * 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` */ locationDotFillColor?: string; /** * 内部蓝色圆点是否使用律动效果, 默认YES * @default true */ enablePulseAnnimation?: boolean; /** * 定位图标, 与蓝色原点互斥base * @example `base64,iV.....` 不包含`data:image/png;前缀` */ image?: string; /** * 定位图标大小 */ imageSize?: MapSize; /** * 定位图标中心点偏移 */ centerOffset?: MapPoint; }; /** * 缩放地图的API输入参数 * @type `setMapZoom` */ export type SetMapZoomParam = { /** * 缩放级别(默认3-19,有室内地图时为3-20, Native 初始化默认值 16 * +/-/0, 传递0 不做缩放动作, 但是可以通过返回值回去当下是否可以放大/缩小 */ zoomLevel?: number; }; /** * 缩放地图返回的数据结构. * @type `setMapZoom` */ export type SetMapZoomParamResult = { /** * 最大的缩放等级 */ maxZoomLevel: number; /** * 当前的缩放等级 */ zoomLevel: number; /** * 最小的缩放等级 */ minZoomLevel: number; }; export type FabricMapOperationEventType = "setMapScreenViewportCenter" | "setMapScreenViewportArea" | "setMapPathPlanning" | "addPaths" | "removePaths" | "getAllPaths" | "updatePaths" | "exchangePath" | "setMapZoom" | "setUserLocationRepresentation" | "setMapCenterCoordinate" | "removeAnnotations" | "updateAnnotations" | "getAllAnnotations" | "selectAnntations" | "deselectAnntations" | "updateFlagstick" | "mapSupplierCoordinateExchange" | "coordinateDirection" | "coordinateScreenPosition" | "coordinateScreenDistance"; /** * 更新路径规划中的小车🚗配置比如行驶方向. */ export type FabricSetMapCarOptions = Pick; export type FabricSetMapCarApi = (options: FabricSetMapCarOptions) => Promise; /** * subscribe点击地图上标注浮窗上的事件. * @type `mapAnnotationViewCalloutClicked` */ export type MapAnnotationViewCalloutClickedEventData = { /** * 被点击地图上标注浮窗的信息内容 */ annotation: AnnotationItem; }; /** * subscribe点击地图上任何位置, 返回这个点击位置的经纬度 * @type `mapDidClickAtCoordinate` */ export type MapDidClickAtCoordinateEventData = { /** * 点击地图上点的经纬度, 如果需要额外的地址信息, 我们需要单独调用 */ coordinate: MapGeoPoint; }; /** * subscribe初始化监听用户定位失败 * @type `mapDidFailToLocateUser` */ export type MapDidFailToLocateUserEventData = {}; /** * subscribe初始化监听整个地图加载失败 * @type `mapDidFailLoading` */ export type MapDidFailLoadingEventData = {}; /** * subscribe初始化监听地图中地形加载失败 * @type `mapDidFailLoadTerrain` */ export type MapDidFailLoadTerrainEventData = {}; /** * subscribe初始化监听地图更新好的用户最新的实时位置(经纬度) * @type `mapDidUpdateUserLocation` */ export type MapDidUpdateUserLocationEventData = { /** * 当前用户所在经纬度, 如果需要额外的地址信息, 我们需要单独调用 */ coordinate: MapGeoPoint; }; /** * subscribe 地图准备移动事件 * @type `mapWillMove` */ export type MapWillMoveEventData = { /** * 用户操作,true, 表示用户滑动, 其他属于地图自身的移动. */ wasUserAction: boolean; /** * 中心点经纬度 */ coordinate: MapGeoPoint; /** * 标识当前地图中心位置是否在中国范围外。此属性不是精确判断,不能用于边界区域 */ isAbroad: boolean; /** * 缩放等级 */ zoomLevel: number; }; /** * subscribe 地图移动之后的事件 * @type `mapDidMove` */ export type MapDidMoveEventData = { /** * 用户操作,true, 表示用户滑动, 其他属于地图自身的移动. */ wasUserAction: boolean; /** * 中心点经纬度 */ coordinate: MapGeoPoint; /** * 标识当前地图中心位置是否在中国范围外。此属性不是精确判断,不能用于边界区域 */ isAbroad: boolean; }; /** * subscribe 地图准备移动事件 * @type `mapWillZoom` */ export type MapWillZoomEventData = { /** * 用户操作,true, 表示用户滑动, 其他属于地图自身的移动. */ wasUserAction: boolean; /** * 中心点经纬度 */ coordinate: MapGeoPoint; /** * 标识当前地图中心位置是否在中国范围外。此属性不是精确判断,不能用于边界区域 */ isAbroad: boolean; /** * 缩放等级 */ zoomLevel: number; }; /** * subscribe 地图移动之后的事件 * @type `mapDidZoom` */ export type MapDidZoomEventData = { /** * 用户操作,true, 表示用户滑动, 其他属于地图自身的移动. */ wasUserAction: boolean; /** * 中心点经纬度 */ coordinate: MapGeoPoint; /** * 标识当前地图中心位置是否在中国范围外。此属性不是精确判断,不能用于边界区域 */ isAbroad: boolean; }; export type FabricMapEventListenerType = "mapDidUpdateUserLocation" | "mapWillMove" | "mapDidMove" | "mapDidClickAtCoordinate" | "mapAnnotationViewCalloutClicked" | "mapDidFailToLocateUser" | "mapDidFailLoading" | "mapDidFailLoadTerrain" | "mapWillZoom" | "mapDidZoom"; export type MapSubscribeEventData = T extends "mapDidUpdateUserLocation" ? MapDidUpdateUserLocationEventData : T extends "mapWillMove" ? MapWillMoveEventData : T extends "mapDidMove" ? MapDidMoveEventData : T extends "mapDidZoom" ? MapDidZoomEventData : T extends "mapWillZoom" ? MapWillZoomEventData : T extends "mapDidClickAtCoordinate" ? MapDidClickAtCoordinateEventData : T extends "mapAnnotationViewCalloutClicked" ? MapAnnotationViewCalloutClickedEventData : T extends "mapDidFailToLocateUser" ? MapDidFailToLocateUserEventData : T extends "mapDidFailLoading" ? MapDidFailLoadingEventData : T extends "mapDidFailLoadTerrain" ? MapDidFailLoadTerrainEventData : never; /** * 注注册回调事件接受Native主动通知H5的各种事件. * 1. 如地图拖动Move, 缩放, 初始化成功, 打标等各种事件. */ export type FabricMapSubscribeEventOptions = { [eventName in T]?: (error: null | FabricError, data: MapSubscribeEventData) => void | Promise; }; export type FabricMapSubscribeEventApi = (options: FabricMapSubscribeEventOptions) => void; /** * 传输时间热区位置点, 到Native, 当前热区只支持矩形, 坐标原点为左上角定点. */ export type FabricMapSetHotRegionOptions = { /** * 一次可以传递多个热区点矩形 */ regions: Array; }; export type FabricMapSetHotRegionApi = (options: FabricMapSetHotRegionOptions) => Promise; /** * 获取当前的地理位置、速度。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。 * 地图相关使用的坐标格式应为 gcj02, 注意此处iOS/android均使用(高德)地图引擎 */ export type MapLocationOptions = { /** * 是否返回高度信息,需要较高精确度,会减慢接口返回速度 */ altitude?: boolean; /** * 开启高精度定位 * @default false */ isHighAccuracy?: boolean; /** * 定位超时时间(ms), 不提供则无限等待定位结果. * @default 30000 */ expireTime?: number; /** * 是否在无权限时,显示系统设置弹框 * @default false */ isShowOpenSettingWhenDisallowed?: boolean; }; /** * 打开调试模式, 结果返回 */ export type MapLocationCallbackResult = { /** * 纬度,范围为 -90~90,负数表示南纬 */ latitude: string; /** * 经度,范围为 -180~180,负数表示西经 */ longitude: string; /** * 速度,单位 m/s */ speed: string; /** * 位置的精确度 */ accuracy: string; /** * 高度,单位 m */ altitude: string; /** * 逆地理编码结果 */ regeocode: { /** * 格式化地址 */ formattedAddress: string; /** * 国家 */ country: string; /** * 省/直辖市 */ province: string; /** * 市 */ city: string; /** * 区 */ district: string; /** * 城市编码 */ citycode: string; /** * 区域编码 */ adcode: string; /** * 街道名称 */ street: string; /** * 门牌号 */ number: string; /** * 兴趣点名称 */ POIName: string; /** * 所属兴趣点名称 */ AOIName: string; }; }; export type MapLocationGetLocationApi = (options: MapLocationOptions) => Promise; /** * 启动打车插件配置选项 */ export type FabricMapStartOptions = { /** * 全屏webview还是半屏webview * Note: 半屏webview不支持自定义, 大小有native 写死. */ screen: "full" | "half"; /** * 动画方向从下往上top, 动画方向从右往左left, 从左往右只支持全屏, 半屏幕支持上往下, 左往右 */ direction?: "top" | "left"; /** * 启动打车插件配置 */ config: { /** * 启动页H5地址 https:// */ entryPage: string; /** * 缩放级别(默认3-19,有室内地图时为3-20) * +/-/0, 传递0 不做缩放动作, 但是可以通过返回值回去当下是否可以放大/缩小 * 也可以单独调用`setMap`.`setMapZoom` API * @default 16 */ zoomLevel?: SetMapZoomParam["zoomLevel"]; /** * 设置地图居中展示区域的中心点位置的API输入参数, 其他地图移动都会依据这个显示位置的缩放, 移动, 聚拢. * 也可以单独调用`setMap`.`setMapScreenViewportCenter` API */ mapScreenViewportCenter?: SetMapScreenViewportCenterParam; /** * 设置Native地图中划线起点/终点落在的区域,Native 需要根据这个区域做适当的缩放计算. * 也可以单独调用`setMap`.`setMapScreenViewportArea` API */ mapScreenViewportArea?: SetMapScreenViewportAreaParam; }; }; export type FabricMapStartApi = (options: FabricMapStartOptions) => Promise; /** * 打车路径规划并附带小车配置. */ export type FabricSetMapPlanningPathOptions = SetMapPathPlanningParam & { /** * Native是否自动计算移动方向, 如果设置为true, 同时当前存在路径规划的的行车路径, native会自动计算当前annotation的点的方向. * 目前用来处理小车🚗的行驶方向. * @default false */ carAnnotation?: Pick; }; export type FabricSetMapPathPlanningApi = (options: FabricSetMapPlanningPathOptions) => Promise; /** * 搜索启点到终点之间的驾车路径规划 * @method drivingRouteSearch */ export type DrivingRouteSearchParam = { /** * 出发点 */ origin: MapGeoPoint; /** * 目的地 */ destination: MapGeoPoint; /** * 驾车导航策略,默认策略为0。 * 0,速度优先(时间);1,费用优先(不走收费路段的最快道路);2,距离优先;3,不走快速路;4,躲避拥堵; * 5,多策略(同时使用速度优先、费用优先、距离优先三个策略计算路径),其中必须说明,就算使用三个策略算路,会根据路况不固定的返回一至三条路径规划信息; * 6,不走高速;7,不走高速且避免收费;8,躲避收费和拥堵;9,不走高速且躲避收费和拥堵; * 10,多备选,时间最短,距离最短,躲避拥堵(考虑路况); * 11,多备选,时间最短,距离最短; * 12,多备选,躲避拥堵(考虑路况); * 13,多备选,不走高速; * 14,多备选,费用优先; * 15,多备选,躲避拥堵,不走高速(考虑路况); * 16,多备选,费用有限,不走高速; * 17,多备选,躲避拥堵,费用优先(考虑路况); * 18,多备选,躲避拥堵,不走高速,费用优先(考虑路况); * 19,多备选,高速优先; * 20,多备选,高速优先,躲避拥堵(考虑路况) * @default 0 */ strategy?: number; /** * 途经点 AMapGeoPoint 数组,目前最多支持6个途经点 */ waypoints?: Array; /** * 避让区域 AMapGeoPolygon 数组,目前最多支持100个避让区域,每个区域16个点 */ avoidpolygons?: Array; /** * 避让道路名 */ avoidroad?: string; /** * 出发点 POI ID */ originId?: string; /** * 目的地 POI ID */ destinationId?: string; /** * 出发点POI类型编码,此值可以辅助更精准的起点算路,0:普通道路、1:高架上、2:高架下、3:主路、4:辅路、5:隧道、7:环岛、9:停车场内部 */ origintype?: string; /** * 目的地POI类型编码 */ destinationtype?: string; /** * 车牌信息,如京AHA322,支持6位传统车牌和7位新能源车牌,用于判断是否限行 */ plate: string; /** * 是否返回扩展信息,默认为 NO */ requireExtension?: string; /** * 车牌省份,用汉字填入车牌省份缩写。用于判断是否限行 */ plateProvince?: string; /** * 车牌详情,填入除省份及标点之外的字母和数字(需大写)。用于判断是否限行。 */ plateNumber?: string; /** * 使用轮渡,0使用1不使用,默认为0使用 */ ferry?: number; /** * 驾车路径规划车辆类型,默认策略为0。 * 0:普通汽车(默认值); * 1:纯电动车; * 2:插电混动车 */ cartype?: number; }; /** * 搜索启点到终点之间的驾车路径路径规划返回结果 */ export type DrivingRouteSearchResult = { /** * 路径规划信息数目 */ count: number; /** * 路径规划信息 */ route: MapRoute; }; declare enum FabricMapSearchMethod { /** * 地图POI ID 搜索 */ poiIDSearch = "poiIDSearch", /** * POI 关键字查询接口 */ poiKeywordsSearch = "poiKeywordsSearch", /** * POI 周边查询接口 */ poiAroundSearch = "poiAroundSearch", /** * POI 多边形查询接口 */ poiPolygonSearch = "poiPolygonSearch", /** * 沿途查询接口 */ routePOISearch = "routePOISearch", /** * 地址编码查询接口 */ geocodeSearch = "geocodeSearch", /** * 逆地址编码查询接口 */ reGeocodeSearch = "reGeocodeSearch", /** * 输入提示查询接口 */ inputTipsSearch = "inputTipsSearch", /** * 公交站点查询接口 */ busStopSearch = "busStopSearch", /** * 公交线路ID查询 */ busLineIDSearch = "busLineIDSearch", /** * 公交线路关键字查询 */ busLineNameSearch = "busLineNameSearch", /** * 行政区域查询接口 */ districtSearch = "districtSearch", /** * 驾车路径规划查询接口 */ drivingRouteSearch = "drivingRouteSearch", /** * 步行路径规划查询接口 */ walkingRouteSearch = "walkingRouteSearch", /** * 公交路径规划查询接口 */ transitRouteSearch = "transitRouteSearch", /** * 骑行路径规划查询接口 */ ridingRouteSearch = "ridingRouteSearch", /** * 货车路径规划查询接口 */ truckRouteSearch = "truckRouteSearch", /** * 未来路线规划查询接口 */ futureRouteSearch = "futureRouteSearch", /** * 天气查询接口 */ weatherRouteSearch = "weatherRouteSearch", /** * 距离查询 */ distanceSearch = "distanceSearch", /** * 企业地图周边查询接口 */ cloudPOIAroundSearch = "cloudPOIAroundSearch", /** * 企业地图polygon区域查询接口 */ cloudPOIPolygonSearch = "cloudPOIPolygonSearch", /** * 企业地图ID查询接口 */ cloudPOIIDSearch = "cloudPOIIDSearch", /** * 企业地图本地查询接口 */ cloudPOILocalSearch = "cloudPOILocalSearch", /** * 位置短串分享接口 */ locationShareSearch = "locationShareSearch", /** * 兴趣点短串分享接口 */ poiShareSearch = "poiShareSearch", /** * 路线规划短串分享接口 */ routeShareSearch = "routeShareSearch", /** * 导航短串分享接口 */ navigationShareSearch = "navigationShareSearch" } /** * 距离查询请求 * @method distanceSearch */ export type DistanceSearchParam = { /** * 起点坐标数组,最多支持100个点。 */ origins: Array; /** * 终点坐标 */ destination: MapGeoPoint; /** * 路径计算的类型,当type为导航距离时,会考虑路况,故在不同时间请求返回结果可能不同; */ type: MapDistanceSearchType; /** * 驾车距离测量策略,参考驾车路径规划。仅当type为`DistanceSearchTypeDrive`时有效,默认4 */ strategy?: number; /** * 是否返回扩展信息,默认为 NO (since 7.6.0) */ requireExtension?: boolean; }; export type MapDistanceResult = { /** * 起点坐标,起点坐标序列号(从1开始) */ originID: number; /** * 终点坐标,终点坐标序列号(从1开始) */ destID: number; /** * 路径距离,单位:米 */ distance: number; /** * 预计行驶时间,单位:秒 */ duration: number; /** * 错误信息,建议用此字段判断请求是否成功 */ info: string; /** * 在驾车模式下有效。默认为0;1:指定地点之间没有可以行车的道路;2:起点/终点 距离所有道路均距离过远(例如在海洋/矿业);3;起点/终点不在中国境内; */ code: number; }; /** * 距离查询结果 */ export type DistanceSearchResult = { /** * 距离查询结果 AMapDistanceResult 数组。 */ results: Array; }; /** * POI 关键字查询接口入参数 * @method poiKeywordsSearch */ export type PoiKeywordsSearchParam = PoiSearchParam<{ /** * 查询关键字,多个关键字用“|”分割 */ keywords: string; /** * 查询城市,可选值:cityname(中文或中文全拼)、citycode、adcode.(注:台湾省的城市一律设置为【台湾】,不具体到市。) */ city?: string; /** * 强制城市限制功能 默认NO,例如:在上海搜索天安门,如果citylimit为true,将不返回北京的天安门相关的POI * @default false */ cityLimit?: boolean; /** * 设置后,如果sortrule==0,则返回结果会按照距离此点的远近来排序,since 5.2.1 */ location?: MapGeoPoint; }>; export type PoiKeywordsSearchResult = PoiSearchResult<{ /** * 返回的POI数目 */ count: number; /** * 关键字建议列表和城市建议列表 */ suggestion: MapSuggestion; }>; /** * 逆地址编码查询接口, 根据经纬度查询用户的地址信息. * @method `reGeocodeSearch` */ export type ReGeocodeSearchParam = PoiSearchParam<{ /** * 是否返回扩展信息,默认NO。 */ requireExtension?: boolean; /** * 中心点坐标。 */ location: MapGeoPoint; /** * 查询半径,单位米,范围0~3000,默认1000。 */ radius?: number; /** * 指定返回结果poi数组中的POI类型,在requireExtension=YES时生效。输入为typecode, 支持传入多个typecode, 多值时用“|”分割 */ poitype?: number; /** * distance 按距离返回,score 按权重返回,仅海外生效(since 7.4.0) */ mode?: string; }>; export type ReGeocodeSearchResult = { /** * 逆地理编码结果 */ regeocode: MapReGeocode; }; export type FabricSearchMapMethodType = keyof Pick; /** * POI 周边查询接口 * @method poiAroundSearch */ export type PoiAroundSearchParam = PoiSearchParam<{ /** * 查询关键字,多个关键字用“|”分割 */ keywords?: string; /** * 中心点坐标 */ location?: MapGeoPoint; /** * 查询半径,范围:0-50000,单位:米 [default = 1500] * @default 1500 */ radius?: number; /** * 查询城市,可选值:cityname(中文或中文全拼)、citycode、adcode。注:当用户指定的经纬度和city出现冲突,若范围内有用户指定city的数据,则返回相关数据,否则返回为空。(since 5.7.0) */ city?: string; /** * 是否对结果进行人工干预,如火车站,原因为poi较为特殊,结果存在人工干预,干预结果优先,所以距离优先的排序未生效,默认为YES (since 7.4.0) */ special?: boolean; }>; export type PoiAroundSearchResult = PoiSearchResult; export type FabricSearchMapOptions = { /** * 搜索方法 */ method: T; /** * 搜索参数 */ param: T extends "poiKeywordsSearch" ? PoiKeywordsSearchParam : T extends "poiAroundSearch" ? PoiAroundSearchParam : T extends "reGeocodeSearch" ? ReGeocodeSearchParam : T extends "distanceSearch" ? DistanceSearchParam : T extends "drivingRouteSearch" ? DrivingRouteSearchParam : never; }; export type FabricSearchMapResult = T extends "poiKeywordsSearch" ? PoiKeywordsSearchResult : T extends "poiAroundSearch" ? PoiAroundSearchResult : T extends "reGeocodeSearch" ? ReGeocodeSearchResult : T extends "distanceSearch" ? DistanceSearchResult : T extends "drivingRouteSearch" ? DrivingRouteSearchResult : never; export type FabricSearchMapApi = (options: FabricSearchMapOptions) => Promise>; /** * 设置地图事件. */ export type FabricMapOptions = { type: T; param: T extends "setMapScreenViewportCenter" ? SetMapScreenViewportCenterParam : T extends "setMapScreenViewportArea" ? SetMapScreenViewportAreaParam : T extends "setMapZoom" ? SetMapZoomParam : T extends "setUserLocationRepresentation" ? SetUserLocationRepresentationParam : T extends "setMapCenterCoordinate" ? SetMapCenterCoordinateParam : T extends "removeAnnotations" ? RemoveAnnotationsParam : T extends "updateAnnotations" ? UpdateAnnotationsParam : T extends "getAllAnnotations" ? GetAllAnnotationsParam : T extends "selectAnntations" ? SelectAnntationsParam : T extends "deselectAnntations" ? DeselectAnntationsParam : T extends "updateFlagstick" ? UpdateFlagstickParam : T extends "mapSupplierCoordinateExchange" ? MapSupplierCoordinateExchangeParam : T extends "coordinateDirection" ? GetCoordinateDirectionParam : T extends "coordinateScreenPosition" ? GetCoordinateScreenPositionParam : T extends "coordinateScreenDistance" ? GetCoordinateScreenDistanceParam : T extends "setMapPathPlanning" ? SetMapPathPlanningParam : T extends "addPaths" ? SetMapAddPathsParam : T extends "removePaths" ? SetMapRemovePathsParam : T extends "getAllPaths" ? SetMapGetAllPathsParam : T extends "updatePaths" ? SetMapUpdatePathsParam : T extends "exchangePath" ? SetMapExchangePathParam : undefined; }; export type FabricMapResult = T extends "setMapZoom" ? SetMapZoomParamResult : T extends "getAllAnnotations" ? GetAllAnnotationsResult : T extends "mapSupplierCoordinateExchange" ? MapSupplierCoordinateExchangeResult : T extends "updateAnnotations" ? UpdateAnnotationsResult : T extends "updateFlagstick" ? UpdateFlagstickResult : T extends "selectAnntations" ? SelectAnntationsResult : T extends "removeAnnotations" ? RemoveAnnotationsResult : T extends "deselectAnntations" ? DeselectAnntationsResult : T extends "coordinateDirection" ? GetCoordinateDirectionResult : T extends "coordinateScreenDistance" ? GetCoordinateScreenDistanceResult : T extends "coordinateScreenPosition" ? GetCoordinateScreenPositionResult : T extends "setMapPathPlanning" ? SetMapPathPlanningResult : T extends "getAllPaths" ? SetMapGetAllPathsResult : undefined; export type FabricMapApi = (options: FabricMapOptions) => Promise>; export type ConstantsType = { /** * 标柱的动画效果配置 */ annotationAnimationType: typeof FabricAnnotationAnimationType; /** * (地图内置, 需要传递 `pinColor`),点标注 \大头针标注、 地图内置 \ 动画标注 */ annotationType: typeof FabricAnnotationType; /** * 地图操作常用错误状态码定义 */ mapErrorCode: typeof FabricMapErrorCode; /** * 步行/驾车/打车 */ mapNaviType: typeof FabricMapNaviType; /** * 路径规划, 单路径, 还是多路径 */ mapPathType: typeof FabricMapPathType; /** * 地图厂商坐标类型枚举, 百度, 高德, 腾讯, google.... */ mapSupplierType: typeof MapSupplierType; /** * 距离测量类型 */ distanceSearchType: typeof MapDistanceSearchType; /** * 高德地图 pinColor 内置大头针的枚举 */ mapInAnnotationColor: typeof MAPinAnnotationColor; }; export type FabricMapExportApi = { /** * 启动打车插件. */ startMap: FabricMapStartApi; /** * 传输时间热区位置点, 到Native, 当前热区只支持矩形, 坐标原点为左上角定点. */ setHotRegion: FabricMapSetHotRegionApi; /** * 设置地图各种API */ setMap: FabricMapApi; /** * 打车路径规划中的小车配置 */ setMapCar: FabricSetMapCarApi; /** * 设置地图行车路径规划 */ setMapPathPlanning: FabricSetMapPathPlanningApi; /** * 通过地址搜索位置. */ searchMap: FabricSearchMapApi; /** * 注注册回调事件接受Native主动通知H5的各种事件. */ subscribe: FabricMapSubscribeEventApi; /** * 获取当前的地理位置、速度。开启高精度定位,接口耗时会增加,可指定 expireTime 作为超时时间 * 1. 如果定位被用户强制关闭, 或者用户点了拒绝, 或者在设置里面禁用了, 返回错误code:`location_permission_disallow` * 2. 如果定位超时了, 则返回错误code: `location_service_timeout` * 3. 如果定位未决定, 则返回错误code: `location_service_not_determined`(iOS可能弹出来用户很久未点, 会自动抛出系统BUG) */ getLocation: MapLocationGetLocationApi; /** * 常用的枚举常量 */ constants: ConstantsType; }; /** * Fabric打车插件. */ export declare const fabricMap: FabricMapExportApi; /** * 展示人脸识别返回结果. */ export type FabricShowFaceIdOptions = {}; /** * 展示人脸识别返回结果. */ export type FabricShowFaceIdCallbackData = { /** * success = '0' (识别成功) */ status: "0"; /** * 预留消息 */ message: string; /** * 用于校验上传数据的校验字符串 */ delta: string; /** * 用于假脸判定,请传MegLive SDK返回的用作云端假脸攻击判定的照片,FaceID将使用image_env进行假脸判定,完整返回face_genuineness对象中的所有字段。 */ imageEnv?: string; /** * 识别的人脸图片内容, 目前返回base64 */ faceImgBase64: string; }; export type FabricMarkShowFaceIdApi = (options: FabricShowFaceIdOptions) => Promise; /** * 人脸识别V5请求参数 * @bizToken 通过后台接口获取, 参考 https://faceid.com/document/faceid-guide-docs/app_api_product_analyze */ export type FaceIDV5Options = { bizToken: string; }; /** * 人脸识别V5返回结果 * @message 预留消息 */ export type FaceIDV5Response = { message: string; }; export type FabricMarkShowFaceIdV5Api = (options: FaceIDV5Options) => Promise; /** * 展示身份证正反面识别输入参数配置 */ export type FabricMarkShowIdCardOptions = { /** * 正面还是反面. * @default false */ isPositive: boolean; /** * 是否打开相册. */ isNeedAlbum: boolean; }; /** * 从本地相册选择图片或使用相机拍照, 结果返回. */ export type FabricMarkShowIdCardCallbackData = { /** * 调用成功时始终返回 status = "0" */ status: "0"; /** * 预留消息 */ message: string; /** * 正面图片/反面图片, 如果参数传递`isPositive`则返回正面的base64, 否则返回反面base64 */ idCardImgBase64?: string; }; export type FabricMarkShowIdCardApi = (options: FabricMarkShowIdCardOptions) => Promise; export type FabricMarkApi = { /** * 展示人脸识别 */ showFaceId: FabricMarkShowFaceIdApi; showFaceIdV5: FabricMarkShowFaceIdV5Api; /** * 展示身份证正反面识别 */ showIdCard: FabricMarkShowIdCardApi; }; export declare const fabricMark: FabricMarkApi; /** * 从本地相册选择图片或使用相机拍照接口请求参数 */ export type FabricChooseImageOptions = { /** * 最多可以选择的图片张数 * @default 9 */ count?: number; /** 是否需要返回图片base64内容, 可指定尺寸 */ resizedBase64?: null | { width: number; height: number; }; /** 是否需要裁剪图片, 可指定裁剪比例 */ crop?: null | { ratio: number; }; /** * 图片质量, original: 原图、compressed: 压缩图、Number: (0-1] * @default 'original' */ sizeType?: "original" | "compressed" | T; /** * 图片来源, album: 相册、camera: 相机、all: 相册 + 相机 * @default 'album' */ sourceType?: "album" | "camera" | "all"; }; /** * 从本地相册选择图片或使用相机拍照, 结果返回. */ export type FabricChooseImageCallbackData = { /** 图片的本地临时文件列表 */ tempFiles: Array<{ /** 本地临时文件路径 */ path: string; /** 配置 resizedBase64 时才返回 */ base64?: string; /** 本地临时文件大小,单位 B */ size: number; }>; }; export type FabricPhotoChooseImageFileApi = (options?: FabricChooseImageOptions) => Promise; export type FabricPreviewImageUrlItem = { /** * 唯一标识, 可选, 可能增加click点击事件的时候需要回传. */ id?: string; /** * Http网络图片地址, 或者本地图片地址. */ url: string; /** * 当前图片的描述信息 */ desc?: string; }; export type WatermarkInfo = { /** * 水平间距 * @default 80 */ horizontalSpace?: number; /** * 垂直间距 * @default 100 */ verticalSpace?: number; /** * 水印文字大小 * @default 17 */ fontSize?: number; /** * 水印文字颜色 * @default `#FFFFFFFF` */ textColor?: string; /** * 水印文字 * @default '' */ text?: string; }; /** * 在新页面中全屏预览图片。 */ export type FabricPreviewImageOptions = { /** * 需要预览的图片链接列表。可以是本地链接, 也可以是网络地址 */ urls: FabricPreviewImageUrlItem[]; /** * 描述信息显示的总行数 */ lines: number; /** * 当前显示图片的链接位置索引值, 默认:urls 的第一张 * @default 0 */ current?: number; /** * 水印信息 */ watermark?: WatermarkInfo; }; export type FabricPhotoPreviewImageFileApi = (options: FabricPreviewImageOptions, callback?: (err: FabricError | null, id?: string) => void) => void; /** * 关闭图片预览器 */ export type FabricClosePhotoPreviewImageFileApi = () => void; /** * 保存图片到本地相册; 比如保存二维码.接口请求参数 */ export type FabricPhotoSaveImageToPhotosAlbumOptions = { /** * 当前图片类型, 网络图片, 本地图片, base64 */ type: "http" | "local" | "base64"; /** * 图片文件路径,可以是临时文件路径或永久文件路径 (本地路径) ,或者网络路径 或者 文件数据(base64), */ filePath: string; }; /** * 保存图片到本地相册后的返回路径, 可以是本地的虚拟路径, 此路径可以预览接口一样 * 可以进行上传, 访问 `previewImage`访问 */ export type FabricPhotoSaveImageToPhotosAlbumCallbackData = { /** * 图片保存后的本地路径. */ filePath: string; }; export type FabricPhotoSaveImageToPhotosAlbumApi = (options: FabricPhotoSaveImageToPhotosAlbumOptions) => Promise; export type FabricPhotoApi = { /** * 从本地相册选择图片或使用相机拍照。 */ chooseImage: FabricPhotoChooseImageFileApi; /** * 关闭当前图片预览器 */ closePreviewImage: FabricClosePhotoPreviewImageFileApi; /** * 在新页面中全屏预览图片。 */ previewImage: FabricPhotoPreviewImageFileApi; /** * 保存图片到本地相册; 比如保存二维码. */ saveImageToPhotosAlbum: FabricPhotoSaveImageToPhotosAlbumApi; }; export declare const fabricPhoto: FabricPhotoApi; export type FabricShareWxOptions = { /** * 分享标题 */ title: string; /** * 分享描述 */ desc: string; /** * 分享链接 */ link: string; /** * 分享类型,music、video, img, text或link,选填 不填默认为link * @default 'link' */ type?: "link" | "music" | "video" | "img" | "text"; /** * 发送到朋友圈——timeline(默认);发送到聊天界面——session;添加到微信收藏——favorite */ scene?: string; /** * 分享图标 * @default APP 默认的图标 */ imgUrl?: string; /** * 如果type是music或video,则要提供数据链接,选填 默认为空 */ dataUrl?: string; /** * 分享的base64格式图片,优先级高于imgUrl 选填 默认 App 图标 * @default APP 默认的图标 */ imgBase64?: string; }; /** * 分享操作执行成功, * 1: 成功; 0:取消 */ export type FabricShareWxCallbackData = "0" | "1"; /** * 微信分享 */ export type FabricShareWxApi = (option: FabricShareWxOptions) => Promise; declare const uniformTypeIdentifier: { PDF: string; QuickTimeMovies: string; HtmlDocuments: string; JPEGFiles: string; }; /** * IOS文件分享 */ export type FabricShareDocumentApi = (option: FabricShareDocumentOption) => Promise<{}>; export type FabricShareDocumentOption = { url: string; type: T; }; /** * Share API * @interface */ export type FabricShareApi = { /** * 微信分享 */ openShareWx: FabricShareWxApi; /** * IOS文件分享 */ openShareDocument: FabricShareDocumentApi; }; export declare const fabricShare: FabricShareApi; export type FabricStorageGetStorageApi = (key: string) => Promise; export type FabricStorageInfoCallbackData = { /** * 当前 storage 中所有的 key */ keys: string[]; /** * 当前占用的空间大小, 单位 KB */ currentSize: number; /** * 限制的空间大小,单位 KB */ limitSize: number; }; export type FabricStorageGetStorageInfoApi = () => Promise; export type FabricStorageInfoSyncCallbackData = { /** * 当前 storage 中所有的 key */ keys: string[]; /** * 当前占用的空间大小, 单位 KB */ currentSize: number; /** * 限制的空间大小,单位 KB */ limitSize: number; }; export type FabricStorageGetStorageSyncInfoApi = () => FabricStorageInfoSyncCallbackData; export type FabricStorageGetStorageSyncApi = (key: string) => T; export type FabricStorageApi = { /** * 清理本地数据缓存 */ clearStorage: () => Promise; /** * 同步接口, 清理本地数据缓存 */ clearStorageSync: () => boolean; /** * 异步获取当前storage的相关信息 */ getStorageInfo: FabricStorageGetStorageInfoApi; /** * 同步接口, 获取当前storage的相关信息 */ getStorageInfoSync: FabricStorageGetStorageSyncInfoApi; /** * 从本地缓存中异步获取指定 key 的内容 */ getStorage: FabricStorageGetStorageApi; /** * 同步接口, 从本地缓存中同步获取指定 key 的内容 */ getStorageSync: FabricStorageGetStorageSyncApi; /** * 从本地缓存中移除指定 key。 */ removeStorage: (key: string) => Promise; /** * 同步接口, 从本地缓存中移除指定 key。 */ removeStorageSync: (key: string) => boolean; /** * 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 */ setStorage: (key: string, data: Json) => Promise; /** * 同步接口, 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 */ setStorageSync: (key: string, data: Json) => boolean; }; export declare const fabricStorage: FabricStorageApi; export type FabricToastCloseIndicatorApi = () => void; export type FabricToastShowMessageOptions = { /** * Icon 类型 */ icon?: "success" | "error" | "warn"; /** * 是否显示背景遮罩层, 默认显示, 遮罩层会覆盖住navbar. * @default true */ mask?: boolean; /** * 自定义加载标题 */ message: string; /** * 关闭时间 [2000, 3500] 之间 * @default 2000 */ expireTime?: number; }; export type FabricToastShowMessageApi = (options: FabricToastShowMessageOptions) => Promise; export type FabricToastShowSpinnerOptions = { /** * 是否显示背景遮罩层, 默认显示, 遮罩层会覆盖住navbar. * @default true */ mask?: boolean; /** * 自定义加载标题 */ title?: string; /** * 针对Android有效, 当前打开的spinner, 点击back键是否连同当前webview一起关闭. * @default false */ backCloseWithHostView?: boolean; }; export type FabricToastCloseSpinnerOptions = { /** * 当前关闭toast loading 动画是否清空全部计数器, 关闭. 因为toast是可以多次调用, 每次计数器+1 * 只显示一个 * @default false */ closeAll?: boolean; }; export type FabricToastShowSpinnerApi = (options?: FabricToastShowSpinnerOptions) => void; export type FabricToastCloseSpinnerApi = (options?: FabricToastCloseSpinnerOptions) => void; export type FabricToastApi = { /** * 显示Native全屏动画 */ showSpinner: FabricToastShowSpinnerApi; /** * 关闭Native全屏幕动画 */ closeSpinner: FabricToastCloseSpinnerApi; /** * 关闭Native全屏幕动画 */ closeIndicator: FabricToastCloseIndicatorApi; /** * 弹出toast tip message */ showMessage: FabricToastShowMessageApi; }; export declare const fabricToast: FabricToastApi; export type FabricToolbarResetNavbarApi = () => void; export type ToolbarNavbarItemWithIcon = { /** * 按钮大小 IOS 30 X 30 默认尺寸 * Note: ICON设计准则: 周边留白为24px, 内容空间80 X 80; 总尺寸128 * 128为原图 * https://www.iconfont.cn/collections/detail?spm=a313x.7781069.1998910419.d9df05512&cid=16472 * type===`icon` */ iconSize?: number; }; export type ToolbarNavbarItemWithText = { /** * navbar字体大小 * @default 18 */ fontSize?: number; /** * 字体样式. 加粗, 斜体, 下划线. */ fontStyle?: Array<"bold" | "italic" | "underline">; /** * navbar字体颜色 */ fontColor?: string; /** * 仅`iOS`支持 * 字体权重, 支持字符串和数字,字符串支持, * 字符串类型: `ultraLight,thin,light,regular,medium,semibold,bold,heavy,black` * 数字类型: `1-1000`,`包含1和1000` * 字体权重 */ fontWeight?: "ultraLight" | "thin" | "light" | "regular" | "medium" | "semibold" | "bold" | "heavy" | "black" | number; }; export type ToolbarNavbarItemType = "icon" | "text"; export type ToolbarNavbarItem = (T extends "icon" ? ToolbarNavbarItemWithIcon : ToolbarNavbarItemWithText) & { /** * 自定义内容, 用来标识当前传递的内容项, 当自定义区域按钮点击时间的时候会返回这个tag用来标识当前点击的项 */ tag?: string; /** * 定义一个标记, 标识当前的item与默认的back按钮行为一致 * @default undefined */ asBackButton?: boolean; /** * 类型, `icon`|`text` */ type: T; /** * type: 'icon' * https://www.iconfont.cn/collections/detail?spm=a313x.7781069.1998910419.d9df05512&cid=16472 * `data:image/png;base64,iVBORw0K....` 如果是图片传递需要去掉`data:image/png;base64,` */ value: string; /** * 左边距 */ marginLeft?: number; /** * 右边距, */ marginRight?: number; }; export type FabricToolbarNavbarOptions = { /** * 状态栏/navbar背景色透明度, 采用字符串, 考虑到android内部number默认有值0, 不能区分是否为更新的设置的0还是默认值. * 0-255 */ opacity?: string; /** * 状态栏/navbar的背景色 */ bgColor?: string; /** * 线性梯度渐变. 优先级在bgColor之上. * 网页的rgba, 最后2位数是代表透明度. 取值16进制从00 -> FF(越小越透明),00表示完全透明, FF就是全不透明, 后面六位是色值 * 需要转换成Native约定的ARGB格式, 透明度放前2位 * background: -webkit-linear-gradient(top, #CE5937FF 0%, #1C6EA4FF 42%, #C59237FF 100%); * 公式如: background: rgba(125, 0, 0, .3); 表示的是30%不透明度的红色背景。把30%的不透明度转换成十六制呢的方法如下:先计算#AA的的十进制x,x/255 = 3/10,解得x=3*255/10,然后再把x换算成十六进制,约等于4C。 * 常用透明度对应16进制关系 * ``` * .0(00) .1(19) .05(0C) .15(26) * .2(33) .3(4C) .25(3F) .35(59) * .4(66) .5(7F) .45(72) .55(8C) * .6(99) .7(B2) .65(A5) .75(BF) * .8(CC) .9(E5) .85(D8) .95(F2) * ``` * @see https://html-css-js.com/css/generator/gradient/ * @example * ```ts * { * direction: "top", * gradients:[ * ["#FFCE5937", 0] * ["#FF1C6EA4", 0.42] * ["#FFC59237", 1] * ] * } * ``` */ linearGradient?: { /** * 方位起点'top'|'left' */ direction: "top" | "left"; /** * 渐变数据 */ gradients: Array<[ string, number ]>; }; /** * 当自定义toolbar的back按钮的时候, 是否开启当前webview返回按钮默认行为支持浏览器栈(默认开启) * 当开启: 当前webview的`locationTo`(location.href)产生的栈, 返回默认优先返回浏览器的栈, 待无浏览器栈的时候再掉用户自定义callback(如果为定义callback, 直接返回上一级) * 当未开启: 点back按钮直接退出当前webview * 注意Note: 如果用户未配置navbar此时的back按钮应该保持默认支持浏览器栈的行为能力. * 注意Note: 如果当前没有`asBackButton`配置, 如果通过`asBackButton`找到最后一次back应该响应JS注册回调时间, 如果找不到`asBackButton` Native * 会尝试找默认back按钮(`left`未被占用)此时走native默认back行为. * @default true */ browserHistory?: boolean; /** * 状态栏风格 */ statusBarStyle?: "dark" | "light"; /** * navbar布局顺序, 默认值: `right-left-center(最后一个剩余空间(`center`)居中)`. * 如果需要让中间内容居中`left-center-right(最后一个剩余空间(`right`)居右)`或者`right-center-left(最后一个剩余空间`left`居左)` * @default `left-center-right` (形态2) */ layout?: "left-center-right" | "right-center-left" | "left-right-center" | "right-left-center" | "center-left-right" | "center-right-left"; /** * left[0]=左边区域左侧位置,left[1]=左边区域右侧位置 */ left?: ToolbarNavbarItem[]; /** * center[0]=中间区域左侧位置,center[1]=中间区域右侧位置 */ center?: ToolbarNavbarItem[]; /** * right[0]=右边区域左侧位置,right[1]=右边区域右侧位置 */ right?: ToolbarNavbarItem[]; }; export type ToolbarCallbackAction = "reset" | "update"; export type FabricToolbarSetNavbarApi = (options: FabricToolbarNavbarOptions, callback?: ((err: FabricError | null, clickedItemTag: string, action: ToolbarCallbackAction) => void) | undefined) => void; export type FabricToolbarSetPageTitleOptions = { bgColor?: string; fontColor?: string; statusBarStyle?: "dark" | "light"; }; export type FabricToolbarSetPageTitleApi = (title: string, options?: FabricToolbarSetPageTitleOptions) => void; export type FabricToolbarUpdateNavbarApi = (options: FabricToolbarNavbarOptions, callback?: ((err: FabricError | null, clickedItemTag: string, action: ToolbarCallbackAction) => void) | undefined) => void; export type FabricToolbarApi = { /** * 设置navbar. 如果开启float模式则需要在H5 url上增加 `ntv_float`参数 * 注意数据内容的配置与UI上`left`,`center`,`right`保持一致. */ setNavbar: FabricToolbarSetNavbarApi; /** * 更新navbar. 在极端情况下, 我们可能需要多次更新navbar, 这个时候我们不想每次全量传输数据, 比如有图片base64有性能问题. * 这个时候我们需要调用updateNavbar()进行第一级别的差异更新. * `opacity`, `bgColor`, `statusBarStyle`,`left`,`center`,`right` */ updateNavbar: FabricToolbarUpdateNavbarApi; /** * 重置标题栏, 如果当前是float模式, 仍然保持, 只是重置调toolbar设置的按钮相关功能. */ resetNavbar: FabricToolbarResetNavbarApi; /** * 设置自定义标题 */ setPageTitle: FabricToolbarSetPageTitleApi; }; export declare const fabricToolbar: FabricToolbarApi; /** * 选择通讯录 */ export type FabricUtilsGetContactOptions = { /** * 单选还是多选. 默认只允许选择一个联系人 * @default false */ multi: boolean; }; /** * 返回通讯录列表 */ export type FabricUtilsGetContactsCallbackData = { contacts: Array<{ mobile: string[]; contactName: string; }>; }; /** * 选择通讯录, 会弹出通讯录界面, 让用户选择单个联系人 */ export type FabricUtilsGetContactApi = (options: FabricUtilsGetContactOptions) => Promise; /** * 获取通讯录列表, 异步调用 */ export type FabricUtilsGetContactsApi = () => Promise; /** * 获取重力感应毁掉数据 */ export type FabricGetGravityCallbackData = { /** * 状态 0:不支持 ; 1:成功 ; 2:失败 */ status: "0" | "1" | "2"; /** * 重力信息 */ gravityInfo?: { x: string; y: string; z: string; }; }; /** * 获取重力感应信息, 使用异步实现来 */ export type FabricUtilsGetGravityApi = () => Promise; /** * 获取本机安装的app列表 */ export type FabricGetInstalledAppsCallbackData = { /** * 安装的app列表 */ appList?: Array<{ name: string; }>; }; /** * 获取本机安装的app列表 */ export type FabricUtilsGetInstalledAppsApi = () => Promise; /** * 返回当前是否有权限读取APP站外目录权限 * 用户同意后返回: { allowed: true },没有权限时跑出统一的权限拒绝错误码: ntv_permission_reject */ export type FabricUtilsGetOutsidePathReadPermissionCallbackData = { allowed: boolean; }; /** * 使用场景举例: * 判断文件存储的路径是否是存储截屏图片的目录,来监听用户动作是否是截屏操作 */ export type FabricUtilsGetOutsidePathReadPermissionApi = () => Promise; export type FabricUtilsGetOutsidePathReadPermissionStatusApi = () => FabricUtilsGetOutsidePathReadPermissionCallbackData; export type FabricUtilsGetPermissionOptions = { type: "camera" | "microphone"; }; export type FabricUtilsGetPermissionApi = (options: FabricUtilsGetPermissionOptions) => Promise<{}>; /** * 获取本地运行时配置的动态数据, 比如调试工具提供的`tagline`, 自定义`accessToken` */ export type FabricGetRuntimeConfigCallbackData = { /** * 客户端调试工具模拟的并行环境tagline?, 对应APP需要去实现. * 注意并行环境的使用业务侧当下需要排除掉生产环境或者准生产环境, 避免生产日志干扰. */ tagline?: string; /** * 客户端调试工具模拟的accessToken?, 对应APP需要去实现. */ accessToken?: string; }; declare const getRuntimeConfig: () => Partial; /** * 在竖屏正方向下的安全区域 */ export type SafeArea = { /** * 安全区域左上角横坐标 * @example iphonex `44` */ left: number; /** * 安全区域右下角横坐标 * @example iphonex `375` */ right: number; /** * 安全区域左上角纵坐标 * @example iphonex `44` */ top: number; /** * 安全区域右下角纵坐标 * @example iphonex `778` */ bottom: number; /** * 安全区域的宽度,单位逻辑像素 * @example iphonex `375` */ width: number; /** * 安全区域的高度,单位逻辑像素 * @example iphonex `734` */ height: number; }; /** * 获取标准系统设备信息 */ export type FabricGetSystemInfoCallbackData = { /** * 设备品牌 */ brand: string; /** * 设备型号。新机型刚推出一段时间会显示unknown,微信会尽快进行适配。 * case "iPod1,1": return "iPod Touch 1G" * case "iPod2,1": return "iPod Touch 2G" * case "iPod3,1": return "iPod Touch 3G" * case "iPod4,1": return "iPod Touch 4G" * case "iPod5,1": return "iPod Touch (5 Gen)" * case "iPod7,1": return "iPod touch 6G" * ///iphone * case "iPhone1,1": return "iPhone 1G" * case "iPhone1,2": return "iPhone 3G" * case "iPhone2,1": return "iPhone 3GS" * case "iPhone3,1", "iPhone3,2", "iPhone3,3": return "iPhone 4" * case "iPhone4,1": return "iPhone 4S" * case "iPhone5,1", "iPhone5,2": return "iPhone 5" * case "iPhone5,3","iPhone5,4": return "iPhone 5C" * @example `iPhone X` */ model: string; /** * 设备像素比 * @example `3` */ pixelRatio: number; /** * 屏幕宽度,单位px * @example iphonex `375` */ screenWidth: number; /** * 屏幕高度,单位px * @example '768' */ screenHeight: number; /** * 屏幕真实高度,在刘海屏的时候不会减去刘海屏高度,单位px, android独有. * @example '804' */ realScreenHeight?: number; /** * 可使用窗口宽度,单位px * @example iphonex `375` */ windowWidth: number; /** * 可使用窗口高度,单位px * @example iphonex `642` */ windowHeight: number; /** * 状态栏的高度,单位px * @example `44` */ statusBarHeight: number; /** * 设置的语言, 默认`zh_CN` */ language: string; /** * 客户端平台 * @example `devtools` */ platform: string; /** * 地理位置定位能力是否可用, 如果定位被用户强制关闭, 或者在设置里面禁用了则为不可用, 如果能弹出让用户授权允许的弹窗认为是可用. * 此值参考值, 如果用户初次进入app打开了定位授权, 中途用户自行关闭了设置, 这个值不会得到及时更新, 如果需要及时准确请使用插件`get_location` */ locationEnabled: boolean; /** * Wi-Fi 的系统开关 */ wifiEnabled: boolean; /** * 在竖屏正方向下的安全区域 */ safeArea: SafeArea; /** * IOS 专有, true 表示模糊定位,false 表示精确定位 */ locationReducedAccuracy: boolean; /** * 统当前主题,取值为light或dark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏) */ theme: "dark" | "light"; /** * 是否已打开调试。可通过右上角菜单或 fabric.setEnableDebug 打开调试。 */ enableDebug: boolean; /** * 设备方向 * @example `portrait` */ deviceOrientation: "portrait" | "landscape"; /** * 操作系统及版本 * @example `iOS 10.0.1` */ system: string; /** * 当前应用的名字. */ appName: string; /** * App版本号, 当前应用的版本号.`1.0.0` */ appVersion: string; /** * 纬度,范围为 -90~90,负数表示南纬, 获取缓存的版本 * `getLocation`插件会更新此缓存 */ latitude: string; /** * 经度,范围为 -180~180,负数表示西经, 获取缓存的版本 * `getLocation`插件会更新此缓存 */ longitude: string; /** * IOS 专有 */ idfa?: string; /** * Android 设备特有, IOS 无法获取 */ mac?: string; /** * 渠道, ios只有一个appStore */ appChannel?: string; /** * Android 设备特有 * 规则就行imei > oaid > android_id */ androidId?: string; /** * Android 设备特有, 移动设备国际身份码 15位数字组成,有一定编码规则 */ imei?: string; /** * Android 设备特有 */ oaid?: string; /** * 网络类型 * @example 'WIFI | GPRS | 2G | 2.75G Edge | 3G | 3.5G HSDPA | 3.5G HSUPA | HRPD | 4G | 5G | 5G NSA' */ networkType: string; /** * clientIP地址, android:1; iOS:1 * @example '10.10.35.37' */ clientIp: string; /** * 设备号, 每个设备生成的唯一值, 标识当前设备, 相对稳定 * @example '63A20CC9-9978-42B7-9689-771F415A6B75' */ deviceId: string; /** * refId, 渠道ID, 当前应用的下载渠道, android独有. * @example '5866741' */ refId: string; /** * 设备标识符, ios独有. */ adid?: string; /** * 设备指纹 */ deviceToken: string; /** * 设备名称 * @example 'OPPO Reno9 5G'、'iPhone14,2' */ deviceName: string; }; /** * 获取系统扩展信息。 */ export type FabricGetSystemInfoExtendCallbackData = { /** * APP数量 * @example '' */ appAmt: string; /** * 是否充电 */ charging: boolean; /** * 系统是否已录入指纹 */ isEnrolledFingerPrints: boolean; /** * 系统是否已录入人脸 */ isEnrolledFacePrints: boolean; /** * 是否刷机 */ isRoot: boolean; /** * 是否支持人脸 */ isSupportFaceID: boolean; /** * 是否设置锁屏密码,1代表是 */ isKeyguardSecure: boolean; /** * 是否支持指纹解锁,1代表是 */ isSupportTouchID: boolean; /** * 系统时区 * @example 'Asia/Shanghai (GMT+8) offset 28800' */ systemTimezone: string; /** * 推送通知app内部开关 与 appNotifySwitch 相同 */ systemNotifySwitch: boolean; /** * 系统日期包含时间戳 * @example 1637894302771 */ systemDate: string; /** * 支持视频分辨率范围 * @example ['4032x3024', '192x144']; */ videoResolutionRanges: string[]; /** * 可自由使用存储容量,kb单位 * @example 151594816 */ freeDiskSpace: string; /** * 短信内容权限 */ msgCompetence: boolean; /** * 全部存储空间容量,kb单位 * @example 249880148 */ totalDiskSpace: string; /** * 国际移动用户识别码 经常变更随机值 */ imsi: string; /** * 电池状态,0-1值,1代表满电,0代表空电 * @example '0.50' */ soc: string; /** * 支持图片分辨率范围 * @example ['4032x3024', '192x144'] */ photoResolutionRanges: string[]; /** * 屏幕亮度 0 - 1 * @example 0.76 */ screenBrightness: string; /** * 推送通知app内部开关 */ appNotifySwitch: boolean; /** * 可自由使用的运行内存容量,kb单位 * @example 1246960 */ freeRAM: string; /** * sim卡卡号,标准20位,各家运营商逻辑略有不同,可查询归属地 */ iccid: string; /** * 风控要求参考旅行APP拼接的设备拓展信息,ios、android拼接规则不同 * Android拼接规则:"4^" + 系统版本 + ",5^" + 手机型号 + ",6^" + 网络类型 * Ios拼接规则: "2^\(AppInfo.bundleIdentifier),4^\(DeviceInfo.getDeviceSystemVersion()),5^\(DeviceInfo.getDeviceCode())" * @example android: '4^13,5^PHM110,6^WIFI' * @example ios: '2^com.ly.wallet,4^16.2,5^iPhone14,2' */ extend?: string; }; declare enum SupportedRuntimeObject { imei = "imei", location = "location" } export type FabricGetSystemRuntimeInfoOptions = { /** * 当前需要实时获取的Native对象(location,...) */ objects: Array; }; export type FabricGetSystemRuntimeInfoCallbackData = { [key in keyof typeof SupportedRuntimeObject]: Json; }; export type FabricGetSystemRuntimeInfoApi = (options: FabricGetSystemRuntimeInfoOptions) => Promise; /** * PDFviewer参数选项 */ export type FabricUtilsOpenPdfViewerOptions = { /** * PDF网络地址 */ url: string; /** * PDF显示的标题 */ title?: string; /** * 是否禁止录屏、截图 */ disableScreenRecord?: boolean; }; export type FabricUtilsOpenPdfViewerCallbackFunc = (data: FabricUtilsOpenPdfViewerCallbackData) => void; export type FabricUtilsOpenPdfViewerApi = (options: FabricUtilsOpenPdfViewerOptions, callback?: FabricUtilsOpenPdfViewerCallbackFunc) => void; export type FabricUtilsOpenPdfViewerCallbackData = { state: "onLoad" | "onShow" | "onHide" | "onDestroy" | "onScrollBottom" | "onBackground"; }; export type FabricUtilsOpenAppSettingsOptions = { type: "permission" | "location"; } | undefined; export type FabricUtilsOpenAppSettingsApi = (options?: FabricUtilsOpenAppSettingsOptions) => Promise; export type FabricUtilsScanQrCodeOptions = { needResult?: boolean; }; export type FabricUtilsScanQrCodeResult = { content: string; }; export type FabricUtilsScanQrCodeApi = (options: FabricUtilsScanQrCodeOptions) => Promise; /** * 打开发短信应用, 并初始化接受者电话, 短信内容 */ export type FabricUtilsSendTextMsgOptions = { /** * 接受者电话 */ receiver?: string; /** * 短信内容 */ body?: string; }; export type FabricUtilsSendTextMsgApi = (options: FabricUtilsSendTextMsgOptions) => Promise; /** * 打电话 */ export type FabricUtilsCallPhoneNumberOptions = { /** * 手机号码 */ phone: string; }; export type FabricUtilsCallPhoneNumberApi = (options: FabricUtilsCallPhoneNumberOptions) => Promise; export type FabricUtilsApi = { /** * 选择通讯录, 会弹出通讯录界面, 让用户选择单个联系人 */ getContact: FabricUtilsGetContactApi; /** * 获取通讯录列表, 异步调用 */ getContacts: FabricUtilsGetContactsApi; /** * 检查当前是否有权限获取通讯录信息, 业务上可能在有权限再去获取, 避免权限弹窗干扰. */ getContactsPermissionStatus: () => boolean; /** * 获取本机安装的app列表 */ getInstalledApps: FabricUtilsGetInstalledAppsApi; /** * 获取本地运行时配置的动态数据, 比如调试工具提供的`tagline`, 自定义`accessToken` */ getRuntimeConfig: typeof getRuntimeConfig; /** * 获取系统信息, 使用同步实现来返回。 */ getSystemInfo: () => FabricGetSystemInfoCallbackData; /** * 获取系统扩展信息, 使用同步实现来返回, 增强设备端信息获取. 有合规风险 */ getSystemInfoExtend: () => FabricGetSystemInfoExtendCallbackData; /** * 异步获取当前设备需要动态获取权限的API */ getSystemRuntimeInfo: FabricGetSystemRuntimeInfoApi; /** * 获取重力感应毁掉数据, 会使用同步实现来返回。 */ getGravityInfo: FabricUtilsGetGravityApi; /** * 设置系统剪贴板的内容。调用成功后,会弹出 toast 提示"内容已复制",持续 1.5s */ setClipboardData: (data: Json) => Promise; /** * 获取系统剪贴板的内容 */ getClipboardData: () => Promise; /** * 打开PDF文件预览 */ openPdfViewer: FabricUtilsOpenPdfViewerApi; /** * 扫描二维码 */ scanQrCode: FabricUtilsScanQrCodeApi; /** * 拨打手机号码 */ callPhoneNumber: FabricUtilsCallPhoneNumberApi; /** * 打开应用设置面板. */ openAppSettings: FabricUtilsOpenAppSettingsApi; /** * 打开发短信应用, 并初始化接受者电话, 短信内容 */ sendTextMsg: FabricUtilsSendTextMsgApi; /** * Android专用,异步调用 * 向用户索要APP站外目录读取权限 */ getOutsidePathReadPermissionStatus: FabricUtilsGetOutsidePathReadPermissionStatusApi; getOutsidePathReadPermission: FabricUtilsGetOutsidePathReadPermissionApi; /** * 获取权限 */ getPermission: FabricUtilsGetPermissionApi; }; export declare const fabricUtils: FabricUtilsApi; /** * 跨 `webview` 异步调用任何webview的数据内容, 并获取返回的回调结果 * Note: 注意当使用sendCrossWebviewCall通知其他webview执行H5注册的回调的时候, 如果当前webview需要退出, 则务必使用sendCrossWebviewCall的needClose 来控制 * 不能在sendCrossWebviewCall 通过使用needClose=false, 来执行通知, 同时执行webviewback()主动关闭当前webview这样操作可能会存在时机问题导致执行结果不符合预期. */ export type FabricCrossWebviewCallOptions = { /** * 返回的页面数,如果 delta 大于现有页面数,则返回到首页, 可以通过 `getCurrentPages()`返回所有的栈 * e.g. A->B->C->D (当前焦点webview为D) * delta为正值(+1)表示当前webview往前面(D->A)的webview通讯, delta为负值(-1),表示当前webview往后面(A->D)的webview通讯. * @default +1 */ delta: number; /** * 当前delta为正的时候并且超出了所有的webview栈个数, 我们处理方式, 如果needClose=true我们是关闭所有, 但是有的业务场景希望, 这个时候只关闭当前webview * 可以通过这个设置为返回 `1` */ overflowDelta?: number; /** * 当且仅当delta为正的值的时候, 往前面的webview通讯的时候才有是否关闭通讯webview之间的其他webview (D -> A), 默认关闭B,C * @default true */ needClose?: boolean; /** * 被调用的webview栈的web注册好的方法名字 */ method: string; /** * 传递给被调用webview栈的web注册方法的数据内容 */ data: T; }; export type FabricWebviewCrossWebviewCallApi = (options: FabricCrossWebviewCallOptions) => void; export type FabricWebviewGetCurrentPagesOptions = { /** * 是否计算webview栈中穿插native页面 * @default true */ includeNativePage?: boolean; }; export type FabricWebviewGetCurrentPagesApi = (options?: FabricWebviewGetCurrentPagesOptions) => number; export type FabricWebviewHideNavbarApi = () => void; export type FabricWebviewLocationToOptions = { /** * 让指定网页地址在当前webview容器跳转, 并指定是否产生浏览器栈, 默认产生 replace: false */ url: string; /** * 是否提供当前浏览器的栈, 类似location.replace的能力. * @default false */ replace?: boolean; }; export type FabricWebviewLocationToApi = (options: FabricWebviewLocationToOptions) => void; export type FabricWebviewNavigateBackOptions = { /** * 返回的页面数,如果 delta 大于现有页面数,则返回到首页。 * @default 1 */ delta: number; /** * 是否计算webview栈中穿插native页面 * @default true */ includeNativePage?: boolean; }; export type FabricWebviewNavgateBackApi = (options?: FabricWebviewNavigateBackOptions) => void; export type FabricWebviewNavigateToOptions = { /** * 需要跳转的应用内非 tabBar 的页面的路径 (代码包路径), 路径后可以带参数。 * 参数与路径之间使用 ? 分隔,参数键与参数值用 = 相连,不同参数用 & 分隔; * 如 'path?key=value&key2=value2' */ url: string; /** * 是否保留加载webview的动画加载器, true: 保持动画不关闭,手动关闭; false: 资源加载完毕后自动关闭 * @default false */ keepIndicator?: boolean; /** * 是否禁用手势返回, IOS支持, 部分安卓华为机器也有其类似功能, URL协议启动webview默认都是不禁用gestureBack能力的. * @default true */ disableGestureBack?: boolean; /** * 不透明度 * @default 0.5 */ overlayOpacity?: number; /** * 点击透明遮罩是否关闭当前webview * @default false */ overlayClickClose?: boolean; /** * 全屏webview还是半屏webview * Note: 半屏webview不支持自定义, 大小有native 写死, `half`模式只支持iOS(单独启一个容器栈, 而不是一个webview, android 暂不支持.) */ screen?: "full" | "half" | T; /** * 动画方向从下往上top, 动画方向从右往左left, 从左往右只支持全屏, 从上往下支持全屏+半屏+自定义高度 */ direction?: "top" | "left"; }; export type FabricWebviewNavigateToApi = (options: FabricWebviewNavigateToOptions) => void; export type FabricWebviewRedirectToOptions = { /** * 需要跳转的应用内非 tabBar 的页面的路径 (代码包路径), 路径后可以带参数。 * 参数与路径之间使用 ? 分隔,参数键与参数值用 = 相连,不同参数用 & 分隔;如 'path?key=value&key2=value2' */ url: string; /** * 是否保留加载webview的动画加载器, true: 保持动画不关闭,手动关闭; false: 资源加载完毕后自动关闭 * @default false */ keepIndicator?: boolean; /** * 不透明度 * @default 0.5 */ overlayOpacity?: number; /** * 点击透明遮罩是否关闭当前webview * @default false */ overlayClickClose?: boolean; /** * 全屏webview还是半屏webview * Note: 半屏webview不支持自定义, 大小有native 写死, `half`模式只支持iOS(单独启一个容器栈, 而不是一个webview, android 暂不支持.) */ screen?: "full" | "half" | T; /** * 动画方向从下往上top, 动画方向从右往左left, 从左往右只支持全屏, 从上往下支持全屏+半屏+自定义高度 */ direction?: "top" | "left"; }; export type FabricWebviewRedirectToApi = (options: FabricWebviewRedirectToOptions) => void; /** * 关闭所有页面,打开到应用内的某个页面 */ export type FabricWebviewRelaunchOptions = { /** * 需要跳转的应用内页面路径,路径后可以带参数。 * 参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2' */ url: string; /** * 是否保留加载webview的动画加载器, true: 保持动画不关闭,手动关闭; false: 资源加载完毕后自动关闭 * @default false */ keepIndicator?: boolean; /** * 不透明度 * @default 0.5 */ overlayOpacity?: number; /** * 点击透明遮罩是否关闭当前webview * @default false */ overlayClickClose?: boolean; /** * 全屏webview还是半屏webview * Note: 半屏webview不支持自定义, 大小有native 写死, `half`模式只支持iOS(单独启一个容器栈, 而不是一个webview, android 暂不支持.) */ screen?: "full" | "half" | T; /** * 动画方向从下往上top, 动画方向从右往左left, 从左往右只支持全屏, 从上往下支持全屏+半屏+自定义高度 */ direction?: "top" | "left"; }; export type FabricWebviewRelaunchApi = (options: FabricWebviewRelaunchOptions) => void; /** * 注册当前webview的onShow, onHide * 考虑场景 WebviewA->webviewB, webviewB 退出 WebviewA, webviewA 再次打开WebviewB. * 1. 启动webviewA, A 执行onload, 当A 打开 B, 则A执行onHide, B执行onLoad * 2. B返回 A, B执行onDestroy, A执行onShow, A再此打开B, A执行onHide, B执行onLoad. * 3. 直到A再返回, A执行onDestory * 4. 进入后台执行onHide, 后台进入前台执行onShow */ export type FabricWebviewSubscriptionOptions = { /** * webview处于激活状态的时候执行. 第一次打开不执行onShow只执行onLoad */ onShow?: (() => void) | (() => Promise); /** * 当前webview实例处于非激活态(切换到后台、手机熄屏、页面前进等) */ onHide?: (() => void) | (() => Promise); /** * 页面第一次加载完毕后执行,首次执行, 每次webview只执行一次 */ onLoad?: (() => void) | (() => Promise); /** * 切换到后台时触发 */ onBackground?: (() => void) | (() => Promise); /** * iOS特有, 当未禁用backGesture的时候, 可以尝试调用backGesture功能. * 注意此处的callback 不要做网络请求, 以及其他异步耗时较长的逻辑 * Note *通常此处用来调用 `sendCrossWebviewCall(delta值需要手动减1, 因为动画结束栈已经退出)`* * @returns */ onIosBackGesture?: (() => void) | (() => Promise); /** * 用户触发截屏时触发(Android需要在APP启动时检查文件路径读取权限,有权限再初始化截屏监听) */ onScreenShot?: ((res?: { webviewActive: boolean; }) => void) | (() => Promise); }; export type FabricWebviewSubscriptionApi = (options: FabricWebviewSubscriptionOptions) => { off: () => void; }; export type FabricWebviewSwitchTabOptions = { /** * 需要跳转的 tabBar 页面的索引值 `0,1,2,3,4` */ index: number; /** * 是否要清理掉当前tab中已启动的栈列表, Android所有tab共享一个栈, always会清掉, 此配置只针对IOS * @default true */ cleanStacks?: boolean; }; export type FabricWebviewSwitchTabApi = (options: FabricWebviewSwitchTabOptions) => void; export type FabricWebviewApi = { /** * 跨 `webview` 异步调用任何webview的数据内容, 并获取返回的回调结果 */ sendCrossWebviewCall: FabricWebviewCrossWebviewCallApi; /** * 获取当前webview页面栈。数组中第一个元素为首页,最后一个元素为当前页面 */ getCurrentPages: FabricWebviewGetCurrentPagesApi; /** * 关闭当前页面,返回上一页面或多级页面。可通过获取当前的页面栈, 决定需要返回几层 */ navigateBack: FabricWebviewNavgateBackApi; /** * 保留当前页面,打开新的webview页面, 但是不能跳到 tabbar 页面。 * 使用 navigateBack 可以返回到原页面。 */ navigateTo: FabricWebviewNavigateToApi; /** * 关闭当前页面,打开新的webview页面。但是不允许跳转到 tabbar 页面 */ redirectTo: FabricWebviewRedirectToApi; /** * 保留当前webview窗口,刷新打开下一个指定的网页, 并且自动强制重置navbar的所有配置(自动重新获取新的URL地址的document.title) * 并且让默认的back按钮支持栈会退, 再到webview退出, 如果新页面自定义配置了navbar, 新Navbar行为能力与 `setNavbar`配置能力为准. */ locationTo: FabricWebviewLocationToApi; /** * 关闭所有页面,打开到应用内的某个页面, 保留当前tabbar, 停留的页面如果有. */ reLaunch: FabricWebviewRelaunchApi; /** * 跳转到 tabBar 页面,并关闭其他所有非 tabBar webview页面 */ switchTab: FabricWebviewSwitchTabApi; /** * 订阅webview状态, 目前支持onShow, onHide, onLoad, onBackground, onIosBackGesture. */ subscription: FabricWebviewSubscriptionApi; /** * 隐藏navbar */ hideNavbar: FabricWebviewHideNavbarApi; }; export declare const fabricWebview: FabricWebviewApi; /** * 提供bridge启动入口, 注意此处是异步返回bridge注册入口, 此处是异步ready. * 告知ios当前web注册的接口已ready, 如果是android则处理提前存储起来的native发送过来的消息. * 因为业务端并不知道什么时候bridge相关javascript环境是注册好了, 可以调用bridgeAPI * 封装入口, 只能从ready里面去调用 * FIXME: 注意如果native存在主动调用webview注册的方法的可能性, 如果当前webview网页并为注册ready(). * 可能会存在native缓存到队列里面的消息不断增长的内存泄漏问题, 如: onShow, onHide, onLoad */ export declare const ready: (callback?: (apis: Omit) => void) => void; export declare const utils: { log: { logData: (...args: any[]) => void; logError: (...args: any[]) => void; logWarn: (...args: any[]) => void; }; parse: { jsonParse: (str: string) => T; }; webview: { isAndroid: (ua?: string) => boolean; isIphone: (ua?: string) => boolean; isHarmony: (ua?: string) => boolean; isFabricWebview: (ua?: string) => boolean; }; }; export {};