Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(taro): 按照微信小程序文档的分类方式拆分 index.d.ts 为 87 个文件 #4557

Merged
merged 4 commits into from
Oct 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/taro-router/src/__tests__/router-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('router component', () => {
}
}

const routerComponent = <RouterComponent />
const routerComponent: any = <RouterComponent />
const getComputedStyle = window.getComputedStyle
Nerv.render(routerComponent, document.createElement('div'))
const dom = routerComponent.dom
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-router/src/router/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class Route extends Taro.Component<RouteProps, {}> {
<div
className="taro_page"
ref={this.getWrapRef}
style={"min-height: 100%"}>
style={{ height: '100%' }}>
<WrappedComponent ref={this.getRef} />
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-router/src/router/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Router extends Taro.Component<Props, State> {
return (
<div
className="taro_router"
style={"height: 100%"}>
style={{ height: '100%' }}>
{this.state.routeStack.map(({ path, componentLoader, isIndex, key, isRedirect }, k) => {
return (
<Route
Expand Down
3 changes: 3 additions & 0 deletions packages/taro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
"license": "MIT",
"dependencies": {
"@tarojs/utils": "1.3.19"
},
"devDependencies": {
"@types/react": "^16.9.4"
}
}
6 changes: 6 additions & 0 deletions packages/taro/types/api/advertisement/advertisement.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare namespace Taro {
// TODO: wx.createRewardedVideoAd
// TODO: wx.createInterstitialAd
// TODO: InterstitialAd
// TODO: RewardedVideoAd
}
7 changes: 7 additions & 0 deletions packages/taro/types/api/alipay/alipay.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare namespace Taro {
/**
* @since 10.1.35
* 此接口可获取支付宝会员的基础信息
*/
function getOpenUserInfo(): Promise<string>
}
47 changes: 47 additions & 0 deletions packages/taro/types/api/base/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
declare namespace Taro {
/**
* **注意:此接口从基础库 1.1.1 版本开始支持。**
*
* 判断小程序的API,回调,参数,组件等是否在当前版本可用。
*
* **String参数说明:** 使用`${API}.${method}.${param}.${options}`或者`${component}.${attribute}.${option}`方式来调用,例如:
*
* * `${API}` 代表 API 名字
* * `${method}` 代表调用方式,有效值为`return`, `success`, `object`, `callback`
* * `${param}` 代表参数或者返回值
* * `${options}` 代表参数的可选值
* * `${component}` 代表组件名字
* * `${attribute}` 代表组件属性
* * `${option}` 代表组件属性的可选值
*
* 例子:
*
* **示例:**
*
```js
Taro.canIUse('openBluetoothAdapter')
Taro.canIUse('getSystemInfoSync.return.screenWidth')
Taro.canIUse('getSystemInfo.success.screenWidth')
Taro.canIUse('showToast.object.image')
Taro.canIUse('onCompassChange.callback.direction')
Taro.canIUse('request.object.method.GET')
Taro.canIUse('live-player')
Taro.canIUse('text.selectable')
Taro.canIUse('button.open-type.contact')
```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.canIUse.html
*/
function canIUse(String: any): boolean

type arrayBuffer = Uint8Array | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | ArrayBuffer

/**
* 将 Base64 字符串转成 ArrayBuffer 数据
*/
function base64ToArrayBuffer(base64: string): arrayBuffer

/**
* 将 ArrayBuffer 数据转成 Base64 字符串
*/
function arrayBufferToBase64(buffer: arrayBuffer): string
}
84 changes: 84 additions & 0 deletions packages/taro/types/api/base/base.debug.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
declare namespace Taro {
namespace setEnableDebug {
type Promised = {
/**
* 调用结果
*/
errMsg: string
}
type Param = {
/**
* 是否打开调试
*/
enableDebug: boolean
}
}
/**
* @since 1.4.0
*
* 设置是否打开调试开关,此开关对正式版也能生效。
*
* **示例代码:**
*
```javascript
// 打开调试
Taro.setEnableDebug({
enableDebug: true
})
// 关闭调试
Taro.setEnableDebug({
enableDebug: false
})
```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.setEnableDebug.html
*/
function setEnableDebug(OBJECT: setEnableDebug.Param): Promise<setEnableDebug.Promised>

namespace getLogManager {
type Param = {
/**
* @since 2.3.2
*
* 取值为0/1,取值为0表示是否会把 App、Page 的生命周期函数和 wx 命名空间下的函数调用写入日志,取值为1则不会。默认值是 0
*/
level?: number
}
type Return = {
/**
* 写 debug 日志
*/
debug(...args: any[]): void
/**
* 写 info 日志
*/
info(...args: any[]): void
/**
* 写 log 日志
*/
log(...args: any[]): void
/**
* 写 warn 日志
*/
warn(...args: any[]): void
}
}
/**
* @since 2.1.0
*
* 获取日志管理器对象。
*
* **示例代码:**
*
```javascript
const logger = Taro.getLogManager({level: 1})
logger.log({str: 'hello world'}, 'basic log', 100, [1, 2, 3])
logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])
logger.debug({str: 'hello world'}, 'debug log', 100, [1, 2, 3])
logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])
```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.getLogManager.html
*/
function getLogManager(OBJECT?: getLogManager.Param): getLogManager.Return

// TODO: wx.getRealtimeLogManager
}
195 changes: 195 additions & 0 deletions packages/taro/types/api/base/base.system.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
declare namespace Taro {
/**
* 系统信息
*/

namespace getSystemInfoSync {
type Return = {
/**
* 手机品牌
*
* @since 1.5.0
*/
brand: string
/**
* 手机型号
*/
model: string
/**
* 设备像素比
*/
pixelRatio: number
/**
* 屏幕宽度
*
* @since 1.1.0
*/
screenWidth: number
/**
* 屏幕高度
*
* @since 1.1.0
*/
screenHeight: number
/**
* 可使用窗口宽度
*/
windowWidth: number
/**
* 可使用窗口高度
*/
windowHeight: number
/**
* 状态栏的高度
*
* @since 1.9.0
*/
statusBarHeight: number
/**
* 微信设置的语言
*/
language: string
/**
* 微信版本号
*/
version: string
/**
* 操作系统版本
*/
system: string
/**
* 客户端平台
*/
platform: string
/**
* 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px
*
* @since 1.5.0
*/
fontSizeSetting: number
/**
* 客户端基础库版本
*
* @since 1.1.0
*/
SDKVersion: string
}
}
/**
* 获取系统信息同步接口
*
* **示例代码:**
*
```javascript
try {
var res = Taro.getSystemInfoSync()
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
} catch (e) {
// Do something when catch error
}
```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfoSync.html
*/
function getSystemInfoSync(): getSystemInfoSync.Return

namespace getSystemInfo {
type Promised = {
/**
* 手机品牌
*
* @since 1.5.0
*/
brand: string
/**
* 手机型号
*/
model: string
/**
* 设备像素比
*/
pixelRatio: string
/**
* 屏幕宽度
*
* @since 1.1.0
*/
screenWidth: number
/**
* 屏幕高度
*
* @since 1.1.0
*/
screenHeight: number
/**
* 可使用窗口宽度
*/
windowWidth: number
/**
* 可使用窗口高度
*/
windowHeight: number
/**
* 状态栏的高度
*
* @since 1.9.0
*/
statusBarHeight: number
/**
* 微信设置的语言
*/
language: string
/**
* 微信版本号
*/
version: string
/**
* 操作系统版本
*/
system: string
/**
* 客户端平台
*/
platform: string
/**
* 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px
*
* @since 1.5.0
*/
fontSizeSetting: number
/**
* 客户端基础库版本
*
* @since 1.1.0
*/
SDKVersion: string
}
type Param = {}
}
/**
* 获取系统信息。
*
* **示例代码:**
*
```javascript
Taro.getSystemInfo({
success: function(res) {
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
}
})
```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfo.html
*/
function getSystemInfo(OBJECT?: getSystemInfo.Param): Promise<getSystemInfo.Promised>
}
Loading