@manycore/idp-sdk
Advanced tools
Comparing version 1.0.0-alpha.10 to 1.0.0-alpha.11
{ | ||
"name": "@manycore/idp-sdk", | ||
"version": "1.0.0-alpha.10", | ||
"version": "1.0.0-alpha.11", | ||
"description": "idp sdk typings", | ||
@@ -5,0 +5,0 @@ "homepage": "", |
@@ -1,2 +0,2 @@ | ||
import { View } from "../../miniapp-types"; | ||
import { View as RawView } from "../../miniapp-types"; | ||
declare global { | ||
@@ -22,2 +22,3 @@ namespace IDP { | ||
export {}; | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
type MountPoints = { | ||
@@ -32,12 +33,5 @@ /** | ||
leftPanel: number; | ||
} & View["mountPoints"]; | ||
interface ViewManager extends View { | ||
}; | ||
interface View extends RawView { | ||
readonly mountPoints: MountPoints; | ||
/** | ||
* 设置小程序iframe容器位置,位置生效方式视容器而定 | ||
* @param x 左上角x | ||
* @param y 左上角y | ||
* @param mountPointIndex 容器标识,见`mountPoints`,默认值0 | ||
*/ | ||
setContainerPosition(x: number, y: number, mountPointIndex?: number): void; | ||
} | ||
@@ -51,4 +45,7 @@ declare global { | ||
namespace Miniapp { | ||
const viewManager: ViewManager; | ||
/** | ||
* 小程序视图实例,用于控制iframe挂载,创建等 | ||
*/ | ||
const view: View; | ||
/** | ||
* 退出小程序 | ||
@@ -61,2 +58,20 @@ */ | ||
export {}; | ||
interface Toast { | ||
/** | ||
* 显示一个info形式的toast | ||
* @param message 消息 | ||
*/ | ||
info(message: string): void; | ||
/** | ||
* 显示一个warn形式的toast | ||
* @param message 消息 | ||
*/ | ||
warn(message: string): void; | ||
/** | ||
* 显示一个error形式的toast | ||
* @param message 消息 | ||
*/ | ||
error(message: string): void; | ||
} | ||
type Theme = "light-theme" | "dark-theme"; | ||
declare global { | ||
@@ -69,20 +84,2 @@ // ui | ||
namespace UI { | ||
type Theme = "light-theme" | "dark-theme"; | ||
interface Toast { | ||
/** | ||
* 显示一个info形式的toast | ||
* @param message 消息 | ||
*/ | ||
info(message: string): void; | ||
/** | ||
* 显示一个warn形式的toast | ||
* @param message 消息 | ||
*/ | ||
warn(message: string): void; | ||
/** | ||
* 显示一个error形式的toast | ||
* @param message 消息 | ||
*/ | ||
error(message: string): void; | ||
} | ||
/** | ||
@@ -94,3 +91,3 @@ * 注册一个回调当主题发生变更的时候触发 | ||
/** | ||
* 隐藏所有ui元素 | ||
* 隐藏除了场景之外的所有ui元素,包括左侧栏,顶部栏等 | ||
*/ | ||
@@ -97,0 +94,0 @@ function hideAll(): void; |
@@ -16,5 +16,6 @@ /** 有承载放传递过来的promise,需配合`await`使用 */ | ||
* 挂载当前iframe | ||
* @param mountPointIndex 容器挂载点索引, @see View.mountPoints | ||
* @returns 当前iframe是否挂载成功 | ||
*/ | ||
mount(): boolean; | ||
mount(mountPointIndex: number): boolean; | ||
/** | ||
@@ -25,8 +26,2 @@ * 卸载当前iframe | ||
/** | ||
* 赋予当前iframe资源和挂载点, 需要确认当前的iframe是否挂载状态,挂载状态下修改不会生效 | ||
* @param srcIndex iframe src资源索引, @see View.views | ||
* @param mountPointIndex 容器挂载点索引, @see View.mountPoints | ||
*/ | ||
applySource(srcIndex: number, mountPointIndex: number): void; | ||
/** | ||
* 缩放当前iframe | ||
@@ -67,21 +62,2 @@ */ | ||
/** | ||
* available view keys, same as view property in manifest | ||
* 页面资源缩影键值对,key同manifest.json中的view字段 | ||
* 如果manifest.json中view为一个string,则此字段值会变成为`{ main: 0 }` | ||
* | ||
* @remarks | ||
* ```ts | ||
* // manifest.json | ||
* { | ||
* "view": { "a": "a.html", "b": "b.html" }, | ||
* //.... | ||
* } | ||
* | ||
* view.mount(view.view.a); | ||
* ``` | ||
*/ | ||
readonly views: { | ||
[viewKey: string]: number; | ||
}; | ||
/** | ||
* 可用的挂载点,具体参照应用挂载点说明 | ||
@@ -97,39 +73,7 @@ */ | ||
/** | ||
* 挂载默认的iframe | ||
* @param srcIndex 视图资源索引, 默认值0,即manifest.json中view字段下第一个值 | ||
* @param mountPointIndex 挂载点索引, 默认值0 | ||
* @returns 是否挂载成功 | ||
*/ | ||
mount(srcIndex?: number, mountPointIndex?: number): boolean; | ||
/** | ||
* 卸载默认的iframe | ||
*/ | ||
unmount(): void; | ||
/** | ||
* 创建一个iframe | ||
* @param srcIndex 视图资源索引, 默认值0,即manifest.json中view字段下第一个值 | ||
* @param mountPointIndex 挂载点索引, 默认值0 | ||
* @param srcName 视图资源名称 | ||
* @returns 创建完成的iframe | ||
*/ | ||
createFrame(srcIndex?: number, mountPoint?: number): FrameHost; | ||
/** | ||
* 等价于 `defaultFrame.resize` | ||
*/ | ||
resize(width: number, height: number): void; | ||
/** | ||
* 等价于 `defaultFrame.onReady` | ||
*/ | ||
onReady(callback: () => void): void; | ||
/** | ||
* 等价于 `defaultFrame.onMessageReceive` | ||
*/ | ||
onMessageReceive(callback: (data: any, origin: string) => void): void; | ||
/** | ||
* 等价于 `defaultFrame.onResize` | ||
*/ | ||
onResize(fn: (width: number, height: number) => void): void; | ||
/** | ||
* 等价于 `defaultFrame.postMessage` | ||
*/ | ||
postMessage(data: any, origin?: string): void; | ||
createFrame(srcName: string): FrameHost; | ||
} | ||
@@ -136,0 +80,0 @@ /** |
60923
1725