@tarojs/taro 3.6.6-alpha.1 → 3.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -3
- package/types/api/base/weapp/app-event.d.ts +18 -18
- package/types/api/taro.extend.d.ts +203 -0
- package/types/{taro.hooks.d.ts → api/taro.hooks.d.ts} +4 -4
- package/types/compile/compiler.d.ts +1 -1
- package/types/compile/config/project.d.ts +1 -1
- package/types/index.d.ts +5 -7
- package/types/taro.api.d.ts +4 -1
- package/types/taro.component.d.ts +1 -1
- package/types/taro.extend.d.ts +0 -126
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro",
|
|
3
|
-
"version": "3.6.6
|
|
3
|
+
"version": "3.6.6",
|
|
4
4
|
"description": "Taro framework",
|
|
5
5
|
"homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -21,8 +21,11 @@
|
|
|
21
21
|
"author": "O2Team",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tarojs/api": "3.6.6
|
|
25
|
-
"@tarojs/runtime": "3.6.6
|
|
24
|
+
"@tarojs/api": "3.6.6",
|
|
25
|
+
"@tarojs/runtime": "3.6.6"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@tarojs/helper": "3.6.6"
|
|
26
29
|
},
|
|
27
30
|
"peerDependenciesMeta": {
|
|
28
31
|
"@types/react": {
|
|
@@ -18,7 +18,7 @@ declare module '../../../index' {
|
|
|
18
18
|
/** 小程序错误事件的回调函数 */
|
|
19
19
|
type Callback = (
|
|
20
20
|
/** 错误信息,包含堆栈 */
|
|
21
|
-
error: string,
|
|
21
|
+
error: string | ErrorEvent | Error,
|
|
22
22
|
) => void
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -113,13 +113,13 @@ declare module '../../../index' {
|
|
|
113
113
|
*
|
|
114
114
|
* **注意**
|
|
115
115
|
* - 所有的 unhandledRejection 都可以被这一监听捕获,但只有 Error 类型的才会在小程序后台触发报警。
|
|
116
|
-
* @supported weapp, tt
|
|
116
|
+
* @supported weapp, tt, h5
|
|
117
117
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html
|
|
118
118
|
*/
|
|
119
119
|
onUnhandledRejection<T = any>(callback: onUnhandledRejection.Callback<T>): void
|
|
120
120
|
|
|
121
121
|
/** 监听系统主题改变事件。该事件与 [`App.onThemeChange`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onThemeChange-Object-object) 的回调时机一致。
|
|
122
|
-
* @supported weapp
|
|
122
|
+
* @supported weapp, h5
|
|
123
123
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onThemeChange.html
|
|
124
124
|
*/
|
|
125
125
|
onThemeChange(callback: onThemeChange.Callback): void
|
|
@@ -131,13 +131,13 @@ declare module '../../../index' {
|
|
|
131
131
|
* - 开发者可以在回调中进行页面重定向,但必须在回调中**同步**处理,异步处理(例如 `setTimeout` 异步执行)无效。
|
|
132
132
|
* - 若开发者没有调用 [Taro.onPageNotFound](/docs/apis/base/weapp/app-event/onPageNotFound) 绑定监听,也没有声明 `App.onPageNotFound`,当跳转页面不存在时,将推入微信客户端原生的页面不存在提示页面。
|
|
133
133
|
* - 如果回调中又重定向到另一个不存在的页面,将推入微信客户端原生的页面不存在提示页面,并且不再第二次回调。
|
|
134
|
-
* @supported weapp,
|
|
134
|
+
* @supported weapp, tt, h5
|
|
135
135
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html
|
|
136
136
|
*/
|
|
137
137
|
onPageNotFound(callback: onPageNotFound.Callback): void
|
|
138
138
|
|
|
139
139
|
/** 监听小程序错误事件。如脚本错误或 API 调用报错等。该事件与 [`App.onError`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onerrorstring-error) 的回调时机与参数一致。
|
|
140
|
-
* @supported weapp, tt
|
|
140
|
+
* @supported weapp, tt, h5
|
|
141
141
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html
|
|
142
142
|
*/
|
|
143
143
|
onError(callback: onError.Callback): void
|
|
@@ -178,16 +178,16 @@ declare module '../../../index' {
|
|
|
178
178
|
* **注意**
|
|
179
179
|
*
|
|
180
180
|
* 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。
|
|
181
|
-
* @supported weapp,
|
|
181
|
+
* @supported weapp, tt, h5
|
|
182
182
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppShow.html
|
|
183
183
|
*/
|
|
184
184
|
onAppShow(
|
|
185
185
|
/** 小程序切前台事件的回调函数 */
|
|
186
|
-
callback: (
|
|
186
|
+
callback: (res: onAppShow.CallbackResult) => void,
|
|
187
187
|
): void
|
|
188
188
|
|
|
189
189
|
/** 监听小程序切后台事件。该事件与 [`App.onHide`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onhide) 的回调时机一致。
|
|
190
|
-
* @supported weapp,
|
|
190
|
+
* @supported weapp, tt, h5
|
|
191
191
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppHide.html
|
|
192
192
|
*/
|
|
193
193
|
onAppHide(
|
|
@@ -196,34 +196,34 @@ declare module '../../../index' {
|
|
|
196
196
|
): void
|
|
197
197
|
|
|
198
198
|
/** 取消监听未处理的 Promise 拒绝事件
|
|
199
|
-
* @supported weapp, tt
|
|
199
|
+
* @supported weapp, tt, h5
|
|
200
200
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offUnhandledRejection.html
|
|
201
201
|
*/
|
|
202
202
|
offUnhandledRejection<T = any>(callback: onUnhandledRejection.Callback<T>): void
|
|
203
203
|
|
|
204
204
|
/** 取消监听系统主题改变事件
|
|
205
|
-
* @supported weapp
|
|
205
|
+
* @supported weapp, h5
|
|
206
206
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offThemeChange.html
|
|
207
207
|
*/
|
|
208
208
|
offThemeChange(callback: onThemeChange.Callback): void
|
|
209
209
|
|
|
210
210
|
/** 取消监听小程序要打开的页面不存在事件
|
|
211
|
-
* @supported weapp, tt
|
|
211
|
+
* @supported weapp, tt, h5
|
|
212
212
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offPageNotFound.html
|
|
213
213
|
*/
|
|
214
214
|
offPageNotFound(
|
|
215
215
|
/** 小程序要打开的页面不存在事件的回调函数 */
|
|
216
|
-
callback:
|
|
216
|
+
callback: onPageNotFound.Callback,
|
|
217
217
|
): void
|
|
218
218
|
|
|
219
219
|
/** 取消监听音频播放错误事件
|
|
220
|
-
* @supported weapp, tt
|
|
220
|
+
* @supported weapp, tt, h5
|
|
221
221
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offError.html
|
|
222
222
|
*/
|
|
223
223
|
|
|
224
224
|
offError(
|
|
225
225
|
/** 音频播放错误事件的回调函数 */
|
|
226
|
-
callback:
|
|
226
|
+
callback: onError.Callback,
|
|
227
227
|
): void
|
|
228
228
|
|
|
229
229
|
/** 取消监听音频中断结束事件
|
|
@@ -245,21 +245,21 @@ declare module '../../../index' {
|
|
|
245
245
|
): void
|
|
246
246
|
|
|
247
247
|
/** 取消监听小程序切前台事件
|
|
248
|
-
* @supported weapp,
|
|
248
|
+
* @supported weapp, tt, h5
|
|
249
249
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppShow.html
|
|
250
250
|
*/
|
|
251
251
|
offAppShow(
|
|
252
252
|
/** 小程序切前台事件的回调函数 */
|
|
253
|
-
callback: (res:
|
|
253
|
+
callback: (res: onAppShow.CallbackResult) => void,
|
|
254
254
|
): void
|
|
255
255
|
|
|
256
256
|
/** 取消监听小程序切后台事件
|
|
257
|
-
* @supported weapp,
|
|
257
|
+
* @supported weapp, tt, h5
|
|
258
258
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppHide.html
|
|
259
259
|
*/
|
|
260
260
|
offAppHide(
|
|
261
261
|
/** 小程序切后台事件的回调函数 */
|
|
262
|
-
callback: (res:
|
|
262
|
+
callback: (res: onAppHide.CallbackResult) => void,
|
|
263
263
|
): void
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import Taro from '../index'
|
|
4
|
+
|
|
5
|
+
declare module '../index' {
|
|
6
|
+
namespace getAppInfo {
|
|
7
|
+
/** 应用信息 */
|
|
8
|
+
interface AppInfo {
|
|
9
|
+
platform: string
|
|
10
|
+
taroVersion: string
|
|
11
|
+
designWidth: number | ((size?: string | number) => number)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
namespace getCurrentInstance {
|
|
16
|
+
interface Current {
|
|
17
|
+
app: AppInstance | null
|
|
18
|
+
router: RouterInfo | null
|
|
19
|
+
page: PageInstance | null
|
|
20
|
+
onReady: string
|
|
21
|
+
onHide: string
|
|
22
|
+
onShow: string
|
|
23
|
+
preloadData?: Record<any, any>
|
|
24
|
+
/**
|
|
25
|
+
* RN 私有对象navigationRef,用于使用底层接口控制路由
|
|
26
|
+
*/
|
|
27
|
+
rnNavigationRef?: React.RefObject<any>
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
namespace setGlobalDataPlugin {
|
|
32
|
+
/** Vue3 插件,用于设置 `getApp()` 中的全局变量 */
|
|
33
|
+
interface Plugin {
|
|
34
|
+
install (app: any, data: any): void
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @ignore */
|
|
39
|
+
interface TARO_ENV_TYPE {
|
|
40
|
+
[TaroGeneral.ENV_TYPE.WEAPP]: TaroGeneral.ENV_TYPE.WEAPP
|
|
41
|
+
[TaroGeneral.ENV_TYPE.WEB]: TaroGeneral.ENV_TYPE.WEB
|
|
42
|
+
[TaroGeneral.ENV_TYPE.RN]: TaroGeneral.ENV_TYPE.RN
|
|
43
|
+
[TaroGeneral.ENV_TYPE.SWAN]: TaroGeneral.ENV_TYPE.SWAN
|
|
44
|
+
[TaroGeneral.ENV_TYPE.ALIPAY]: TaroGeneral.ENV_TYPE.ALIPAY
|
|
45
|
+
[TaroGeneral.ENV_TYPE.TT]: TaroGeneral.ENV_TYPE.TT
|
|
46
|
+
[TaroGeneral.ENV_TYPE.QQ]: TaroGeneral.ENV_TYPE.QQ
|
|
47
|
+
[TaroGeneral.ENV_TYPE.JD]: TaroGeneral.ENV_TYPE.JD
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
namespace interceptorify {
|
|
51
|
+
type promiseifyApi<T, R> = (requestParams: T) => Promise<R>
|
|
52
|
+
interface InterceptorifyChain<T, R> {
|
|
53
|
+
requestParams: T
|
|
54
|
+
proceed: promiseifyApi<T, R>
|
|
55
|
+
}
|
|
56
|
+
type InterceptorifyInterceptor<T, R> = (chain: InterceptorifyChain<T, R>) => Promise<R>
|
|
57
|
+
interface Interceptorify<T, R> {
|
|
58
|
+
request(requestParams: T): Promise<R>
|
|
59
|
+
addInterceptor( interceptor: InterceptorifyInterceptor<T, R>): void
|
|
60
|
+
cleanInterceptors(): void
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface TaroStatic {
|
|
65
|
+
/** @ignore */
|
|
66
|
+
Events: {
|
|
67
|
+
new (): TaroGeneral.Events
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** 事件中心
|
|
71
|
+
* @supported global
|
|
72
|
+
*/
|
|
73
|
+
eventCenter: TaroGeneral.Events
|
|
74
|
+
|
|
75
|
+
/** @ignore */
|
|
76
|
+
ENV_TYPE: TARO_ENV_TYPE
|
|
77
|
+
|
|
78
|
+
/** 获取环境变量
|
|
79
|
+
* @supported global
|
|
80
|
+
*/
|
|
81
|
+
getEnv(): TaroGeneral.ENV_TYPE
|
|
82
|
+
|
|
83
|
+
/** 尺寸转换
|
|
84
|
+
* @supported global
|
|
85
|
+
*/
|
|
86
|
+
pxTransform(size: number, designWidth?: number): string
|
|
87
|
+
|
|
88
|
+
/** 尺寸转换初始化
|
|
89
|
+
* @supported global
|
|
90
|
+
*/
|
|
91
|
+
initPxTransform(config: {
|
|
92
|
+
baseFontSize?: number
|
|
93
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
94
|
+
designWidth?: number | ((size?: string | number) => number)
|
|
95
|
+
targetUnit?: string
|
|
96
|
+
unitPrecision?: number
|
|
97
|
+
}): void
|
|
98
|
+
|
|
99
|
+
/** @ignore */
|
|
100
|
+
initAppInfo(appInfo: getAppInfo.AppInfo): void
|
|
101
|
+
|
|
102
|
+
/** 小程序获取和 Taro 相关的 App 信息
|
|
103
|
+
* @supported weapp, alipay, jd, qq, swan, tt, h5
|
|
104
|
+
*/
|
|
105
|
+
getAppInfo(): getAppInfo.AppInfo
|
|
106
|
+
|
|
107
|
+
/** 小程序引用插件 JS 接口
|
|
108
|
+
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
109
|
+
*/
|
|
110
|
+
requirePlugin(pluginName: string): any
|
|
111
|
+
|
|
112
|
+
/** 获取当前页面实例
|
|
113
|
+
* @supported global
|
|
114
|
+
*/
|
|
115
|
+
getCurrentInstance(): getCurrentInstance.Current
|
|
116
|
+
|
|
117
|
+
/** @ignore */
|
|
118
|
+
Current: getCurrentInstance.Current
|
|
119
|
+
|
|
120
|
+
/** Vue3 插件,用于设置 `getApp()` 中的全局变量
|
|
121
|
+
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
122
|
+
* @example
|
|
123
|
+
* ```js
|
|
124
|
+
* // 使用插件
|
|
125
|
+
* const App = createApp(...)
|
|
126
|
+
* App.use(setGlobalDataPlugin, {
|
|
127
|
+
* xxx: 999
|
|
128
|
+
* })
|
|
129
|
+
* // 获取全局变量
|
|
130
|
+
* Taro.getApp().xxx
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
setGlobalDataPlugin: setGlobalDataPlugin.Plugin
|
|
134
|
+
|
|
135
|
+
/** 获取自定义 TabBar 对应的 React 或 Vue 组件实例
|
|
136
|
+
* @supported weapp
|
|
137
|
+
* @param page 小程序页面对象,可以通过 Taro.getCurrentInstance().page 获取
|
|
138
|
+
*/
|
|
139
|
+
getTabBar<T>(page: getCurrentInstance.Current['page']): T | undefined
|
|
140
|
+
|
|
141
|
+
/** 获取当前页面渲染引擎类型
|
|
142
|
+
* @supported weapp
|
|
143
|
+
*/
|
|
144
|
+
getRenderer(): 'webview' | 'skyline'
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 包裹 promiseify api 的洋葱圈模型
|
|
148
|
+
* @supported global
|
|
149
|
+
* @param promiseifyApi
|
|
150
|
+
* @example
|
|
151
|
+
* ```tsx
|
|
152
|
+
* // 创建实例
|
|
153
|
+
* const modalInterceptorify = interceptorify(taro.showModal)
|
|
154
|
+
* // 添加拦截器
|
|
155
|
+
* modalInterceptorify.addInterceptor(async function (chain) {
|
|
156
|
+
* const res = await chain.proceed({
|
|
157
|
+
* ...chain.requestParams,
|
|
158
|
+
* title: 'interceptor1'
|
|
159
|
+
* })
|
|
160
|
+
* return res
|
|
161
|
+
* })
|
|
162
|
+
* modalInterceptorify.addInterceptor(async function (chain) {
|
|
163
|
+
* const res = await chain.proceed({
|
|
164
|
+
* ...chain.requestParams,
|
|
165
|
+
* content: 'interceptor2'
|
|
166
|
+
* })
|
|
167
|
+
* return res
|
|
168
|
+
* })
|
|
169
|
+
* // 使用
|
|
170
|
+
* modalInterceptorify.request({})
|
|
171
|
+
* ```
|
|
172
|
+
* @example
|
|
173
|
+
* ```tsx
|
|
174
|
+
* // 创建实例
|
|
175
|
+
* const fetchDataInterceptorify = interceptorify(taro.request)
|
|
176
|
+
* // 添加拦截器
|
|
177
|
+
* fetchDataInterceptorify.addInterceptor(async function (chain) {
|
|
178
|
+
* taro.showLoading({
|
|
179
|
+
* title: 'Loading...'
|
|
180
|
+
* })
|
|
181
|
+
* const res = await chain.proceed(chain.requestParams)
|
|
182
|
+
* taro.hideLoading()
|
|
183
|
+
* return res
|
|
184
|
+
* })
|
|
185
|
+
* fetchDataInterceptorify.addInterceptor(async function (chain) {
|
|
186
|
+
* const params = chain.requestParams
|
|
187
|
+
* const res = await chain.proceed({
|
|
188
|
+
* url: 'http://httpbin.org' + params.url,
|
|
189
|
+
* })
|
|
190
|
+
* return res.data
|
|
191
|
+
* })
|
|
192
|
+
* // 使用
|
|
193
|
+
* fetchDataInterceptorify.request({
|
|
194
|
+
* url: '/ip'
|
|
195
|
+
* }).then((res) => {
|
|
196
|
+
* // log my ip
|
|
197
|
+
* console.log(res.origin)
|
|
198
|
+
* })
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
interceptorify<T, R>(promiseifyApi: interceptorify.promiseifyApi<T, R>): interceptorify.Interceptorify<T, R>
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Taro from '
|
|
1
|
+
import Taro from '../index'
|
|
2
2
|
|
|
3
|
-
declare module '
|
|
3
|
+
declare module '../index' {
|
|
4
4
|
interface TaroStatic {
|
|
5
5
|
/**
|
|
6
6
|
* 页面展示时的回调。
|
|
@@ -46,7 +46,7 @@ declare module './index' {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* 当前是 tab 页时,tab 被点击时的回调。
|
|
49
|
-
* @supported weapp, rn
|
|
49
|
+
* @supported weapp, h5, rn
|
|
50
50
|
*/
|
|
51
51
|
useTabItemTap(callback: (payload: TabItemTapObject) => void): void
|
|
52
52
|
|
|
@@ -85,7 +85,7 @@ declare module './index' {
|
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* 小程序有未处理的 Promise reject 时触发。也可以使用 Taro.onUnhandledRejection 绑定监听。
|
|
88
|
-
* @supported weapp, alipay
|
|
88
|
+
* @supported weapp, alipay, h5
|
|
89
89
|
*/
|
|
90
90
|
useUnhandledRejection(callback: (error: { reason: Error, promise: Promise<Error> }) => void): void
|
|
91
91
|
|
|
@@ -24,7 +24,7 @@ export interface IProjectBaseConfig {
|
|
|
24
24
|
port?: number
|
|
25
25
|
projectName?: string
|
|
26
26
|
date?: string
|
|
27
|
-
designWidth?: number | ((size
|
|
27
|
+
designWidth?: number | ((size?: string | number) => number)
|
|
28
28
|
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
29
29
|
watcher?: any[]
|
|
30
30
|
sourceRoot?: string
|
package/types/index.d.ts
CHANGED
|
@@ -108,13 +108,13 @@
|
|
|
108
108
|
* │ │ └── interaction.d.ts 界面 -> 交互 API
|
|
109
109
|
* │ ├── worker
|
|
110
110
|
* │ │ └── index.d.ts Worker API
|
|
111
|
-
* │
|
|
112
|
-
* │
|
|
111
|
+
* │ ├── wxml
|
|
112
|
+
* │ │ └── index.d.ts WXML API
|
|
113
|
+
* │ ├── taro.extend.d.ts Taro 扩展 API 类型定义
|
|
114
|
+
* │ └── taro.hooks.d.ts Taro Hooks 类型定义
|
|
113
115
|
* ├── index.d.ts 此文件
|
|
114
116
|
* ├── taro.component.d.ts Taro Component 类型定义
|
|
115
|
-
* ├── taro.config.d.ts
|
|
116
|
-
* ├── taro.extend.d.ts Taro 扩展 API 类型定义
|
|
117
|
-
* ├── taro.hooks.d.ts Taro Hooks 类型定义
|
|
117
|
+
* ├── taro.config.d.ts Taro 小程序 App 与 Window 设置类型定义
|
|
118
118
|
* └── taro.lifecycle.d.ts Taro 生命周期类型定义
|
|
119
119
|
*/
|
|
120
120
|
|
|
@@ -123,8 +123,6 @@
|
|
|
123
123
|
/// <reference path="taro.api.d.ts" />
|
|
124
124
|
/// <reference path="taro.component.d.ts" />
|
|
125
125
|
/// <reference path="taro.config.d.ts" />
|
|
126
|
-
/// <reference path="taro.extend.d.ts" />
|
|
127
|
-
/// <reference path="taro.hooks.d.ts" />
|
|
128
126
|
/// <reference path="taro.lifecycle.d.ts" />
|
|
129
127
|
|
|
130
128
|
/// <reference types="@tarojs/plugin-platform-alipay/types/shims-alipay" />
|
package/types/taro.api.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
*
|
|
3
3
|
* 微信端能力
|
|
4
4
|
* original code from: https://github.com/wx-minapp/minapp-wx/blob/master/typing/wx.d.ts
|
|
5
|
-
*
|
|
5
|
+
* Licensed under MIT license: https://github.com/qiu8310/minapp/issues/69
|
|
6
6
|
* thanks for the great work by @qiu8310 👍👍👍
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
@@ -110,3 +110,6 @@
|
|
|
110
110
|
/// <reference path="api/alipay/index.d.ts" />
|
|
111
111
|
/// <reference path="api/qq/index.d.ts" />
|
|
112
112
|
/// <reference path="api/swan/index.d.ts" />
|
|
113
|
+
|
|
114
|
+
/// <reference path="api/taro.extend.d.ts" />
|
|
115
|
+
/// <reference path="api/taro.hooks.d.ts" />
|
package/types/taro.extend.d.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import Taro from './index'
|
|
4
|
-
|
|
5
|
-
declare module './index' {
|
|
6
|
-
type MessageType = 'info' | 'success' | 'error' | 'warning'
|
|
7
|
-
|
|
8
|
-
interface AtMessageOptions {
|
|
9
|
-
message: string
|
|
10
|
-
type?: MessageType
|
|
11
|
-
duration?: number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface AppInfo {
|
|
15
|
-
platform: string,
|
|
16
|
-
taroVersion: string
|
|
17
|
-
designWidth: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface RequestParams<T=any> extends request.Option<T, any> {
|
|
21
|
-
[propName: string]: any
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface Current {
|
|
25
|
-
app: AppInstance | null
|
|
26
|
-
router: RouterInfo | null
|
|
27
|
-
page: PageInstance | null
|
|
28
|
-
onReady: string
|
|
29
|
-
onHide: string
|
|
30
|
-
onShow: string
|
|
31
|
-
preloadData?: Record<any, any>
|
|
32
|
-
/**
|
|
33
|
-
* RN 私有对象navigationRef,用于使用底层接口控制路由
|
|
34
|
-
*/
|
|
35
|
-
rnNavigationRef?: React.RefObject<any>
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface SetGlobalDataPlugin {
|
|
39
|
-
install (app: any, data: any): void
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface TARO_ENV_TYPE {
|
|
43
|
-
[TaroGeneral.ENV_TYPE.WEAPP]: TaroGeneral.ENV_TYPE.WEAPP
|
|
44
|
-
[TaroGeneral.ENV_TYPE.WEB]: TaroGeneral.ENV_TYPE.WEB
|
|
45
|
-
[TaroGeneral.ENV_TYPE.RN]: TaroGeneral.ENV_TYPE.RN
|
|
46
|
-
[TaroGeneral.ENV_TYPE.SWAN]: TaroGeneral.ENV_TYPE.SWAN
|
|
47
|
-
[TaroGeneral.ENV_TYPE.ALIPAY]: TaroGeneral.ENV_TYPE.ALIPAY
|
|
48
|
-
[TaroGeneral.ENV_TYPE.TT]: TaroGeneral.ENV_TYPE.TT
|
|
49
|
-
[TaroGeneral.ENV_TYPE.QQ]: TaroGeneral.ENV_TYPE.QQ
|
|
50
|
-
[TaroGeneral.ENV_TYPE.JD]: TaroGeneral.ENV_TYPE.JD
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface TaroStatic {
|
|
54
|
-
Events: {
|
|
55
|
-
new (): TaroGeneral.Events
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** 事件中心
|
|
59
|
-
* @supported global
|
|
60
|
-
*/
|
|
61
|
-
eventCenter: TaroGeneral.Events
|
|
62
|
-
|
|
63
|
-
ENV_TYPE: TARO_ENV_TYPE
|
|
64
|
-
|
|
65
|
-
/** 获取环境变量
|
|
66
|
-
* @supported global
|
|
67
|
-
*/
|
|
68
|
-
getEnv(): TaroGeneral.ENV_TYPE
|
|
69
|
-
|
|
70
|
-
/** 尺寸转换
|
|
71
|
-
* @supported global
|
|
72
|
-
*/
|
|
73
|
-
pxTransform(size: number, designWidth?: number): string
|
|
74
|
-
|
|
75
|
-
/** 尺寸转换初始化
|
|
76
|
-
* @supported global
|
|
77
|
-
*/
|
|
78
|
-
initPxTransform(config: {
|
|
79
|
-
baseFontSize?: number
|
|
80
|
-
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
81
|
-
designWidth?: number
|
|
82
|
-
targetUnit?: string
|
|
83
|
-
unitPrecision?: number
|
|
84
|
-
}): void
|
|
85
|
-
|
|
86
|
-
/** @ignore */
|
|
87
|
-
initAppInfo(appInfo: AppInfo): void
|
|
88
|
-
|
|
89
|
-
/** 小程序获取和 Taro 相关的 App 信息
|
|
90
|
-
* @supported weapp, alipay, jd, qq, swan, tt
|
|
91
|
-
*/
|
|
92
|
-
getAppInfo(): AppInfo
|
|
93
|
-
|
|
94
|
-
/** 小程序引用插件 JS 接口
|
|
95
|
-
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
96
|
-
*/
|
|
97
|
-
requirePlugin(pluginName: string): any
|
|
98
|
-
|
|
99
|
-
/** 获取当前页面实例
|
|
100
|
-
* @supported global
|
|
101
|
-
*/
|
|
102
|
-
getCurrentInstance(): Current
|
|
103
|
-
Current: Current
|
|
104
|
-
|
|
105
|
-
/** Vue3 插件,用于设置 `getApp()` 中的全局变量
|
|
106
|
-
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
107
|
-
* @example
|
|
108
|
-
* ```js
|
|
109
|
-
* // 使用插件
|
|
110
|
-
* const App = createApp(...)
|
|
111
|
-
* App.use(setGlobalDataPlugin, {
|
|
112
|
-
* xxx: 999
|
|
113
|
-
* })
|
|
114
|
-
* // 获取全局变量
|
|
115
|
-
* Taro.getApp().xxx
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
setGlobalDataPlugin: SetGlobalDataPlugin
|
|
119
|
-
|
|
120
|
-
/** 获取自定义 TabBar 对应的 React 或 Vue 组件实例
|
|
121
|
-
* @supported weapp
|
|
122
|
-
* @param page 小程序页面对象,可以通过 Taro.getCurrentInstance().page 获取
|
|
123
|
-
*/
|
|
124
|
-
getTabBar<T>(page: Current['page']): T | undefined
|
|
125
|
-
}
|
|
126
|
-
}
|