@tarojs/taro 3.7.0-alpha.7 → 3.7.0-beta.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/taro",
3
- "version": "3.7.0-alpha.7",
3
+ "version": "3.7.0-beta.1",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -21,11 +21,11 @@
21
21
  "author": "O2Team",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@tarojs/api": "3.7.0-alpha.7",
25
- "@tarojs/runtime": "3.7.0-alpha.7"
24
+ "@tarojs/api": "3.7.0-beta.1",
25
+ "@tarojs/runtime": "3.7.0-beta.1"
26
26
  },
27
27
  "devDependencies": {
28
- "@tarojs/helper": "3.7.0-alpha.7"
28
+ "@tarojs/helper": "3.7.0-beta.1"
29
29
  },
30
30
  "peerDependenciesMeta": {
31
31
  "@types/react": {
@@ -41,17 +41,17 @@ declare module '../../index' {
41
41
  * @supported weapp
42
42
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.offClose.html
43
43
  */
44
- offClose(callback: InterstitialAd.OffCloseCallback): void
44
+ offClose(callback: InterstitialAd.OnCloseCallback): void
45
45
  /** 取消监听插屏错误事件
46
46
  * @supported weapp
47
47
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.offError.html
48
48
  */
49
- offError(callback: InterstitialAd.OffErrorCallback): void
49
+ offError(callback: InterstitialAd.OnErrorCallback): void
50
50
  /** 取消监听插屏广告加载事件
51
51
  * @supported weapp
52
52
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.offLoad.html
53
53
  */
54
- offLoad(callback: InterstitialAd.OffLoadCallback): void
54
+ offLoad(callback: InterstitialAd.OnLoadCallback): void
55
55
  /** 监听插屏广告关闭事件。
56
56
  * @supported weapp
57
57
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.onClose.html
@@ -91,12 +91,6 @@ declare module '../../index' {
91
91
  show(): Promise<any>
92
92
  }
93
93
  namespace InterstitialAd {
94
- /** 插屏广告关闭事件的回调函数 */
95
- type OffCloseCallback = (res: TaroGeneral.CallbackResult) => void
96
- /** 插屏错误事件的回调函数 */
97
- type OffErrorCallback = (res: TaroGeneral.CallbackResult) => void
98
- /** 插屏广告加载事件的回调函数 */
99
- type OffLoadCallback = (res: TaroGeneral.CallbackResult) => void
100
94
  /** 插屏广告关闭事件的回调函数 */
101
95
  type OnCloseCallback = (res: TaroGeneral.CallbackResult) => void
102
96
  /** 插屏错误事件的回调函数 */
@@ -137,17 +131,17 @@ declare module '../../index' {
137
131
  * @supported weapp
138
132
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/RewardedVideoAd.offClose.html
139
133
  */
140
- offClose(callback: RewardedVideoAd.OffCloseCallback): void
134
+ offClose(callback: RewardedVideoAd.OnCloseCallback): void
141
135
  /** 取消监听激励视频错误事件
142
136
  * @supported weapp
143
137
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/RewardedVideoAd.offError.html
144
138
  */
145
- offError(callback: RewardedVideoAd.OffErrorCallback): void
139
+ offError(callback: RewardedVideoAd.OnErrorCallback): void
146
140
  /** 取消监听激励视频广告加载事件
147
141
  * @supported weapp
148
142
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/RewardedVideoAd.offLoad.html
149
143
  */
150
- offLoad(callback: RewardedVideoAd.OffLoadCallback): void
144
+ offLoad(callback: RewardedVideoAd.OnLoadCallback): void
151
145
  /** 监听用户点击 `关闭广告` 按钮的事件。
152
146
  * @supported weapp
153
147
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/RewardedVideoAd.onClose.html
@@ -179,12 +173,6 @@ declare module '../../index' {
179
173
  isEnded: boolean
180
174
  }
181
175
  /** 用户点击 `关闭广告` 按钮的事件的回调函数 */
182
- type OffCloseCallback = (res: TaroGeneral.CallbackResult) => void
183
- /** 激励视频错误事件的回调函数 */
184
- type OffErrorCallback = (res: TaroGeneral.CallbackResult) => void
185
- /** 激励视频广告加载事件的回调函数 */
186
- type OffLoadCallback = (res: TaroGeneral.CallbackResult) => void
187
- /** 用户点击 `关闭广告` 按钮的事件的回调函数 */
188
176
  type OnCloseCallback = (result: OnCloseCallbackResult) => void
189
177
  /** 激励视频错误事件的回调函数 */
190
178
  type OnErrorCallback = (result: OnErrorCallbackResult) => void
@@ -57,17 +57,17 @@ declare module '../../index' {
57
57
  * @supported weapp
58
58
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.offError.html
59
59
  */
60
- offError(callback?: InferenceSession.OffErrorCallback): void
60
+ offError(callback?: InferenceSession.OnErrorCallback): void
61
61
  /** 取消监听模型加载完成事件
62
62
  * @supported weapp
63
63
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.offLoad.html
64
64
  */
65
- offLoad(callback?: InferenceSession.OffLoadCallback): void
65
+ offLoad(callback?: InferenceSession.OnLoadCallback): void
66
66
  /** 监听模型加载失败事件
67
67
  * @supported weapp
68
68
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.onError.html
69
69
  */
70
- onError(callback: InferenceSession.OnLoadCallback): void
70
+ onError(callback: InferenceSession.OnErrorCallback): void
71
71
  /** 监听模型加载完成事件
72
72
  * @supported weapp
73
73
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/inference/InferenceSession.onLoad.html
@@ -103,12 +103,8 @@ declare module '../../index' {
103
103
  [key: string]: Tensor
104
104
  }
105
105
 
106
- /** 模型加载失败回调函数。*/
107
- type OffErrorCallback = (res: TaroGeneral.CallbackResult) => void
108
- /** 模型加载完成回调函数 */
109
- type OffLoadCallback = (res: TaroGeneral.CallbackResult) => void
110
106
  /** 模型加载失败回调函数 */
111
- type OnLoadCallback = (res: TaroGeneral.CallbackResult) => void
107
+ type OnErrorCallback = (res: TaroGeneral.CallbackResult) => void
112
108
  /** 模型加载完成回调函数 */
113
109
  type OnLoadCallback = (res: TaroGeneral.CallbackResult) => void
114
110
  }
@@ -42,7 +42,7 @@ declare module '../../index' {
42
42
  namespace getLatestUserKey {
43
43
  interface Option {
44
44
  /** 接口调用成功的回调函数 */
45
- success?: (res: TaroGeneral.CallbackResult) => void
45
+ success?: (res: SuccessCallbackResult) => void
46
46
  /** 接口调用失败的回调函数 */
47
47
  fail?: (res: TaroGeneral.CallbackResult) => void
48
48
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
@@ -292,83 +292,83 @@ declare module '../../index' {
292
292
  /** 音频进入可以播放状态,但不保证后面可以流畅播放
293
293
  * @supported weapp, h5, rn
294
294
  */
295
- onCanplay(callback?: () => void): void
295
+ onCanplay(callback?: InnerAudioContext.OnCanplayCallback): void
296
296
  /** 音频播放事件
297
297
  * @supported weapp, h5, rn
298
298
  */
299
- onPlay(callback?: () => void): void
299
+ onPlay(callback?: InnerAudioContext.OnPlayCallback): void
300
300
  /** 音频暂停事件
301
301
  * @supported weapp, h5, rn
302
302
  */
303
- onPause(callback?: () => void): void
303
+ onPause(callback?: InnerAudioContext.OnPauseCallback): void
304
304
  /** 音频停止事件
305
305
  * @supported weapp, h5, rn
306
306
  */
307
- onStop(callback?: () => void): void
307
+ onStop(callback?: InnerAudioContext.OnStopCallback): void
308
308
  /** 音频自然播放结束事件
309
309
  * @supported weapp, h5, rn
310
310
  */
311
- onEnded(callback?: () => void): void
311
+ onEnded(callback?: InnerAudioContext.OnEndedCallback): void
312
312
  /** 音频播放进度更新事件
313
313
  * @supported weapp, h5, rn
314
314
  */
315
- onTimeUpdate(callback?: () => void): void
315
+ onTimeUpdate(callback?: InnerAudioContext.OnTimeUpdateCallback): void
316
316
  /** 音频播放错误事件
317
317
  * @supported weapp, h5, rn
318
318
  */
319
- onError(callback?: (res: InnerAudioContext.onErrorDetail) => void): void
319
+ onError(callback?: InnerAudioContext.OnErrorCallback): void
320
320
  /** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发
321
321
  * @supported weapp, h5, rn
322
322
  */
323
- onWaiting(callback?: () => void): void
323
+ onWaiting(callback?: InnerAudioContext.OnWaitingCallback): void
324
324
  /** 音频进行 seek 操作事件
325
325
  * @supported weapp, h5, rn
326
326
  */
327
- onSeeking(callback?: () => void): void
327
+ onSeeking(callback?: InnerAudioContext.OnSeekingCallback): void
328
328
  /** 音频完成 seek 操作事件
329
329
  * @supported weapp, h5, rn
330
330
  */
331
- onSeeked(callback?: () => void): void
332
- /** 取消监听 onCanplay 事件
331
+ onSeeked(callback?: InnerAudioContext.OnSeekedCallback): void
332
+ /** 取消监听 canplay 事件
333
333
  * @supported weapp, h5, rn
334
334
  */
335
- offCanplay(callback?: () => void): void
336
- /** 取消监听 onPlay 事件
335
+ offCanplay(callback?: InnerAudioContext.OnCanplayCallback): void
336
+ /** 取消监听 play 事件
337
337
  * @supported weapp, h5, rn
338
338
  */
339
- offPlay(callback?: () => void): void
340
- /** 取消监听 onPause 事件
339
+ offPlay(callback?: InnerAudioContext.OnPlayCallback): void
340
+ /** 取消监听 pause 事件
341
341
  * @supported weapp, h5, rn
342
342
  */
343
- offPause(callback?: () => void): void
344
- /** 取消监听 onStop 事件
343
+ offPause(callback?: InnerAudioContext.OnPauseCallback): void
344
+ /** 取消监听 stop 事件
345
345
  * @supported weapp, h5, rn
346
346
  */
347
- offStop(callback?: () => void): void
348
- /** 取消监听 onEnded 事件
347
+ offStop(callback?: InnerAudioContext.OnStopCallback): void
348
+ /** 取消监听 ended 事件
349
349
  * @supported weapp, h5, rn
350
350
  */
351
- offEnded(callback?: () => void): void
352
- /** 取消监听 onTimeUpdate 事件
351
+ offEnded(callback?: InnerAudioContext.OnEndedCallback): void
352
+ /** 取消监听 timeUpdate 事件
353
353
  * @supported weapp, h5, rn
354
354
  */
355
- offTimeUpdate(callback?: () => void): void
356
- /** 取消监听 onError 事件
355
+ offTimeUpdate(callback?: InnerAudioContext.OnTimeUpdateCallback): void
356
+ /** 取消监听 error 事件
357
357
  * @supported weapp, h5, rn
358
358
  */
359
- offError(callback?: () => void): void
360
- /** 取消监听 onWaiting 事件
359
+ offError(callback?: InnerAudioContext.OnErrorCallback): void
360
+ /** 取消监听 waiting 事件
361
361
  * @supported weapp, h5, rn
362
362
  */
363
- offWaiting(callback?: () => void): void
364
- /** 取消监听 onSeeking 事件
363
+ offWaiting(callback?: InnerAudioContext.OnWaitingCallback): void
364
+ /** 取消监听 seeking 事件
365
365
  * @supported weapp, h5, rn
366
366
  */
367
- offSeeking(callback?: () => void): void
368
- /** 取消监听 onSeeked 事件
367
+ offSeeking(callback?: InnerAudioContext.OnSeekingCallback): void
368
+ /** 取消监听 seeked 事件
369
369
  * @supported weapp, h5, rn
370
370
  */
371
- offSeeked(callback?: () => void): void
371
+ offSeeked(callback?: InnerAudioContext.OnSeekedCallback): void
372
372
  }
373
373
 
374
374
  namespace InnerAudioContext {
@@ -391,6 +391,26 @@ declare module '../../index' {
391
391
  /** 未知错误 */
392
392
  '-1'
393
393
  }
394
+ /** 音频进入可以播放状态事件的回调函数 */
395
+ type OnCanplayCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
396
+ /** 音频播放事件的回调函数 */
397
+ type OnPlayCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
398
+ /** 音频暂停事件的回调函数 */
399
+ type OnPauseCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
400
+ /** 音频停止事件的回调函数 */
401
+ type OnStopCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
402
+ /** 音频自然播放结束事件的回调函数 */
403
+ type OnEndedCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
404
+ /** 音频播放进度更新事件的回调函数 */
405
+ type OnTimeUpdateCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
406
+ /** 音频播放错误事件的回调函数 */
407
+ type OnErrorCallback = (res: onErrorDetail) => void
408
+ /** 音频加载中事件的回调函数 */
409
+ type OnWaitingCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
410
+ /** 音频进行 seek 操作事件的回调函数 */
411
+ type OnSeekingCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
412
+ /** 音频完成 seek 操作事件的回调函数 */
413
+ type OnSeekedCallback = (res: Partial<TaroGeneral.CallbackResult>) => void
394
414
  }
395
415
 
396
416
  /** MediaAudioPlayer 实例,可通过 [Taro.createMediaAudioPlayer](./createMediaAudioPlayer) 接口获取实例。
@@ -57,14 +57,6 @@ declare module '../../index' {
57
57
  }
58
58
 
59
59
  namespace DownloadTask {
60
- /** HTTP Response Header 事件的回调函数 */
61
- type OffHeadersReceivedCallback = (
62
- res: TaroGeneral.CallbackResult,
63
- ) => void
64
- /** 下载进度变化事件的回调函数 */
65
- type OffProgressUpdateCallback = (
66
- res: TaroGeneral.CallbackResult,
67
- ) => void
68
60
  /** HTTP Response Header 事件的回调函数 */
69
61
  type OnHeadersReceivedCallback = (
70
62
  result: OnHeadersReceivedCallbackResult,
@@ -135,7 +127,7 @@ declare module '../../index' {
135
127
  */
136
128
  offProgressUpdate(
137
129
  /** 下载进度变化事件的回调函数 */
138
- callback: DownloadTask.OffProgressUpdateCallback,
130
+ callback: DownloadTask.OnProgressUpdateCallback,
139
131
  ): void
140
132
  /** 监听 HTTP Response Header 事件。会比请求完成事件更早
141
133
  * @supported weapp, h5
@@ -151,7 +143,7 @@ declare module '../../index' {
151
143
  */
152
144
  offHeadersReceived(
153
145
  /** HTTP Response Header 事件的回调函数 */
154
- callback: DownloadTask.OffHeadersReceivedCallback,
146
+ callback: DownloadTask.OnHeadersReceivedCallback,
155
147
  ): void
156
148
  }
157
149
 
@@ -2,7 +2,7 @@ import Taro from '../../index'
2
2
 
3
3
  declare module '../../index' {
4
4
  namespace request {
5
- interface Option <T = any, U extends string | TaroGeneral.IAnyObject | ArrayBuffer = any | any > {
5
+ interface Option<T = any, U extends string | TaroGeneral.IAnyObject | ArrayBuffer = any | any> {
6
6
  /** 开发者服务器接口地址 */
7
7
  url: string
8
8
  /** 请求的参数 */
@@ -14,11 +14,11 @@ declare module '../../index' {
14
14
  header?: TaroGeneral.IAnyObject
15
15
  /** 超时时间,单位为毫秒
16
16
  * @default 2000
17
- * @supported weapp, h5, tt
17
+ * @supported weapp, h5, tt, alipay
18
18
  */
19
19
  timeout?: number
20
20
  /** HTTP 请求方法
21
- * @default GET
21
+ * @default "GET"
22
22
  */
23
23
  method?: keyof Method
24
24
  /** 返回的数据格式 */
@@ -54,6 +54,25 @@ declare module '../../index' {
54
54
  * @supported weapp
55
55
  */
56
56
  enableChunked?: boolean
57
+ /**
58
+ * wifi下使用移动网络发送请求
59
+ * @default false
60
+ * @supported weapp
61
+ */
62
+ forceCellularNetwork?: boolean
63
+ /**
64
+ * headers 中设置 cookie 字段是否生效。如果为 false,则 headers 中的 cookie 字段将被忽略,请求头中将包含服务端上一次返回的 cookie(如果有)。
65
+ * @default false
66
+ * @supported alipay 支付宝: 10.2.33+
67
+ */
68
+ enableCookie?: boolean
69
+ /**
70
+ * referer 策略,用于控制当前请求 header 对象中 referer 字段格式。该参数默认值可通过 app.json 中的配置进行修改。
71
+ * @default "querystring"
72
+ * @supported alipay 支付宝: 10.3.50+ APPX: 2.8.7 开发者工具: 3.5.1
73
+ * @see https://opendocs.alipay.com/mini/api/owycmh#referrerStrategy%20%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E
74
+ */
75
+ referrerStrategy?: keyof ReferrerStrategy
57
76
  /** 接口调用成功的回调函数 */
58
77
  success?: (result: SuccessCallbackResult<T>) => void
59
78
  /** 接口调用失败的回调函数 */
@@ -87,10 +106,12 @@ declare module '../../index' {
87
106
  /** 设置请求重试次数
88
107
  * @default 2
89
108
  * @supported h5
109
+ * @h5 仅在 jsonp 模式下生效
90
110
  */
91
111
  retryTimes?: number
92
112
  /** 设置请求的兜底接口
93
113
  * @supported h5
114
+ * @h5 仅在 jsonp 模式下生效
94
115
  */
95
116
  backup?: string | string[]
96
117
  /** 设置请求中止信号
@@ -99,19 +120,23 @@ declare module '../../index' {
99
120
  signal?: AbortSignal
100
121
  /** 设置请求响应的数据校验函数,若返回 false,则请求兜底接口,若无兜底接口,则报请求失败
101
122
  * @supported h5
123
+ * @h5 仅在 jsonp 模式下生效
102
124
  */
103
125
  dataCheck?(): boolean
104
126
  /** 设置请求是否使用缓存
105
127
  * @default false
106
128
  * @supported h5
129
+ * @h5 仅在 jsonp 模式下生效
107
130
  */
108
131
  useStore?: boolean
109
132
  /** 设置请求缓存校验的 key
110
133
  * @supported h5
134
+ * @h5 仅在 jsonp 模式下生效
111
135
  */
112
136
  storeCheckKey?: string
113
137
  /** 设置请求缓存签名
114
138
  * @supported h5
139
+ * @h5 仅在 jsonp 模式下生效
115
140
  */
116
141
  storeSign?: string
117
142
  /** 设置请求校验函数,一般不需要设置
@@ -120,7 +145,8 @@ declare module '../../index' {
120
145
  storeCheck?(): boolean
121
146
  }
122
147
 
123
- interface SuccessCallbackResult < T extends string | TaroGeneral.IAnyObject | ArrayBuffer = any | any > extends TaroGeneral.CallbackResult {
148
+ interface SuccessCallbackResult<T extends string | TaroGeneral.IAnyObject | ArrayBuffer = any | any>
149
+ extends TaroGeneral.CallbackResult {
124
150
  /** 开发者服务器返回的数据 */
125
151
  data: T
126
152
  /** 开发者服务器返回的 HTTP Response Header */
@@ -135,10 +161,26 @@ declare module '../../index' {
135
161
 
136
162
  /** 返回的数据格式 */
137
163
  interface DataType {
138
- /** 返回的数据为 JSON,返回后会对返回的数据进行一次 JSON.parse
164
+ /**
165
+ * 返回的数据为 JSON,返回后会对返回的数据进行一次 JSON.parse
139
166
  * 其他: 不对返回的内容进行 JSON.parse
140
167
  */
141
168
  json
169
+ /**
170
+ * 返回的数据为文本字符串
171
+ * @supported alipay
172
+ */
173
+ text
174
+ /**
175
+ * 返回的数据将转换为 base64 格式字符串
176
+ * @supported alipay
177
+ */
178
+ base64
179
+ /**
180
+ * 返回的数据将保持 ArrayBuffer 数据
181
+ * @supported alipay 支付宝: 10.1.70+
182
+ */
183
+ arraybuffer
142
184
  }
143
185
 
144
186
  /** HTTP 请求方法 */
@@ -202,6 +244,21 @@ declare module '../../index' {
202
244
  /** 浏览器在其HTTP缓存中寻找匹配的请求 */
203
245
  'only-if-cached'
204
246
  }
247
+ /** referer 策略 */
248
+ interface ReferrerStrategy {
249
+ /**
250
+ * referer 值为 https://{appid}.hybrid.alipay-eco.com/{appid}/{version}/index.html
251
+ */
252
+ index
253
+ /**
254
+ * 保留 page(pages/xxx/yyy),referer 值为 https://{appid}.hybrid.alipay-eco.com/{appid}/{version}/index.html#{page}
255
+ */
256
+ page
257
+ /**
258
+ * 默认值。会将发起请求时所在页面的 URL 作为 referer 值,会保留 page(pages/xxx/yyy)和 querystring(x=1&y=2)并可能有框架添加的其他参数,referer 值为 https://{appid}.hybrid.alipay-eco.com/{appid}/{version}/index.html#{page}?{querysrtring}{框架其他参数}
259
+ */
260
+ querystring
261
+ }
205
262
  }
206
263
 
207
264
  /** 网络请求任务对象
@@ -269,7 +326,7 @@ declare module '../../index' {
269
326
  */
270
327
  onHeadersReceived(
271
328
  /** HTTP Response Header 事件的回调函数 */
272
- callback: RequestTask.onHeadersReceived.Callback,
329
+ callback: RequestTask.onHeadersReceived.Callback
273
330
  ): void
274
331
  /** 取消监听 HTTP Response Header 事件
275
332
  * @supported weapp
@@ -277,7 +334,7 @@ declare module '../../index' {
277
334
  */
278
335
  offHeadersReceived(
279
336
  /** HTTP Response Header 事件的回调函数 */
280
- callback: RequestTask.onHeadersReceived.Callback,
337
+ callback: RequestTask.onHeadersReceived.Callback
281
338
  ): void
282
339
  /** 监听 Transfer-Encoding Chunk Received 事件。当接收到新的chunk时触发。
283
340
  * @supported weapp
@@ -285,7 +342,7 @@ declare module '../../index' {
285
342
  */
286
343
  onChunkReceived(
287
344
  /** Transfer-Encoding Chunk Received 事件的回调函数 */
288
- callback: RequestTask.onChunkReceived.Callback,
345
+ callback: RequestTask.onChunkReceived.Callback
289
346
  ): void
290
347
  /** 移除 Transfer-Encoding Chunk Received 事件的监听函数
291
348
  * @supported weapp
@@ -293,7 +350,7 @@ declare module '../../index' {
293
350
  */
294
351
  offChunkReceived(
295
352
  /** Transfer-Encoding Chunk Received 事件的回调函数 */
296
- callback: RequestTask.onChunkReceived.Callback,
353
+ callback: RequestTask.onChunkReceived.Callback
297
354
  ): void
298
355
  }
299
356
 
@@ -56,14 +56,6 @@ declare module '../../index' {
56
56
  }
57
57
 
58
58
  namespace UploadTask {
59
- /** HTTP Response Header 事件的回调函数 */
60
- type OffHeadersReceivedCallback = (
61
- res: TaroGeneral.CallbackResult,
62
- ) => void
63
- /** 上传进度变化事件的回调函数 */
64
- type OffProgressUpdateCallback = (
65
- res: TaroGeneral.CallbackResult,
66
- ) => void
67
59
  /** HTTP Response Header 事件的回调函数 */
68
60
  type OnHeadersReceivedCallback = (
69
61
  result: OnHeadersReceivedCallbackResult,
@@ -138,7 +130,7 @@ declare module '../../index' {
138
130
  */
139
131
  offProgressUpdate(
140
132
  /** 上传进度变化事件的回调函数 */
141
- callback: UploadTask.OffProgressUpdateCallback,
133
+ callback: UploadTask.OnProgressUpdateCallback,
142
134
  ): void
143
135
  /** 监听 HTTP Response Header 事件。会比请求完成事件更早
144
136
  * @supported weapp, h5
@@ -154,7 +146,7 @@ declare module '../../index' {
154
146
  */
155
147
  offHeadersReceived(
156
148
  /** HTTP Response Header 事件的回调函数 */
157
- callback: UploadTask.OffHeadersReceivedCallback,
149
+ callback: UploadTask.OnHeadersReceivedCallback,
158
150
  ): void
159
151
  }
160
152
 
@@ -4,32 +4,34 @@ declare module '../../index' {
4
4
  namespace chooseAddress {
5
5
  interface Option {
6
6
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
- complete?: (res: TaroGeneral.CallbackResult) => void
7
+ complete?: (res: SuccessCallbackResult) => void
8
8
  /** 接口调用失败的回调函数 */
9
9
  fail?: (res: TaroGeneral.CallbackResult) => void
10
10
  /** 接口调用成功的回调函数 */
11
11
  success?: (result: SuccessCallbackResult) => void
12
12
  }
13
13
 
14
- interface SuccessCallbackResult {
14
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
15
+ /** 收货人姓名 */
16
+ userName: string
17
+ /** 邮编 */
18
+ postalCode: string
19
+ /** 国标收货地址第一级地址 */
20
+ provinceName: string
15
21
  /** 国标收货地址第二级地址 */
16
22
  cityName: string
17
23
  /** 国标收货地址第三级地址 */
18
24
  countyName: string
25
+ /** 国标收货地址第四级地址 */
26
+ streetName: string
19
27
  /** 详细收货地址信息 */
20
28
  detailInfo: string
21
- /** 错误信息 */
22
- errMsg: string
29
+ /** 新选择器详细收货地址信息 */
30
+ detailInfoNew: string
23
31
  /** 收货地址国家码 */
24
32
  nationalCode: string
25
- /** 邮编 */
26
- postalCode: string
27
- /** 国标收货地址第一级地址 */
28
- provinceName: string
29
33
  /** 收货人手机号码 */
30
34
  telNumber: string
31
- /** 收货人姓名 */
32
- userName: string
33
35
  }
34
36
  }
35
37
 
@@ -156,6 +156,7 @@ declare module '../../index' {
156
156
 
157
157
  /** 关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。
158
158
  * @supported weapp, h5, rn, tt
159
+ * @h5 未针对 tabbar 页面做限制处理
159
160
  * @example
160
161
  * ```tsx
161
162
  * Taro.redirectTo({
@@ -168,6 +169,7 @@ declare module '../../index' {
168
169
 
169
170
  /** 保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 Taro.navigateBack 可以返回到原页面。小程序中页面栈最多十层。
170
171
  * @supported weapp, h5, rn, tt
172
+ * @h5 未针对 tabbar 页面做限制处理
171
173
  * @example
172
174
  * ```tsx
173
175
  * Taro.navigateTo({
@@ -200,7 +200,7 @@ declare module '../../index' {
200
200
  * Taro.downloadFile({
201
201
  * url: 'https://res.wx.qq.com/wxdoc/dist/assets/img/demo.ef5c5bef.jpg',
202
202
  * success: (res) => {
203
- * wx.showShareImageMenu({
203
+ * Taro.showShareImageMenu({
204
204
  * path: res.tempFilePath
205
205
  * })
206
206
  * }
@@ -31,11 +31,11 @@ declare module '../index' {
31
31
  namespace setGlobalDataPlugin {
32
32
  /** Vue3 插件,用于设置 `getApp()` 中的全局变量 */
33
33
  interface Plugin {
34
- install (app: any, data: any): void
34
+ install(app: any, data: any): void
35
35
  }
36
36
  }
37
37
 
38
- /** @ignore */
38
+ /** @ignore */
39
39
  interface TARO_ENV_TYPE {
40
40
  [TaroGeneral.ENV_TYPE.WEAPP]: TaroGeneral.ENV_TYPE.WEAPP
41
41
  [TaroGeneral.ENV_TYPE.WEB]: TaroGeneral.ENV_TYPE.WEB
@@ -56,7 +56,7 @@ declare module '../index' {
56
56
  type InterceptorifyInterceptor<T, R> = (chain: InterceptorifyChain<T, R>) => Promise<R>
57
57
  interface Interceptorify<T, R> {
58
58
  request(requestParams: T): Promise<R>
59
- addInterceptor( interceptor: InterceptorifyInterceptor<T, R>): void
59
+ addInterceptor(interceptor: InterceptorifyInterceptor<T, R>): void
60
60
  cleanInterceptors(): void
61
61
  }
62
62
  }
@@ -101,6 +101,29 @@ declare module '../index' {
101
101
  */
102
102
  getAppInfo(): getAppInfo.AppInfo
103
103
 
104
+ getEnvInfoSync(): {
105
+ /** 小程序信息 */
106
+ microapp: {
107
+ /** 小程序版本号 */
108
+ mpVersion: string
109
+ /** 小程序环境 */
110
+ envType: string
111
+ /** 小程序appId */
112
+ appId: string
113
+ }
114
+ /** 插件信息 */
115
+ plugin: Record<string, unknown>
116
+ /** 通用参数 */
117
+ common: {
118
+ /** 用户数据存储的路径 */
119
+ USER_DATA_PATH: string
120
+ /** 校验白名单属性中的appInfoLaunchFrom后返回额外信息 */
121
+ location: string | undefined
122
+ launchFrom: string | undefined
123
+ schema: string | undefined
124
+ }
125
+ }
126
+
104
127
  /** 小程序引用插件 JS 接口
105
128
  * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
106
129
  */
@@ -130,7 +153,7 @@ declare module '../index' {
130
153
  setGlobalDataPlugin: setGlobalDataPlugin.Plugin
131
154
 
132
155
  /** 获取自定义 TabBar 对应的 React 或 Vue 组件实例
133
- * @supported weapp
156
+ * @supported weapp, jd
134
157
  * @param page 小程序页面对象,可以通过 Taro.getCurrentInstance().page 获取
135
158
  */
136
159
  getTabBar<T>(page: getCurrentInstance.Current['page']): T | undefined
@@ -85,7 +85,7 @@ declare module '../../index' {
85
85
  showNavigationBarLoading(option?: showNavigationBarLoading.Option): void
86
86
 
87
87
  /** 动态设置当前页面的标题
88
- * @supported weapp, h5, rn, tt
88
+ * @supported weapp, alipay, h5, rn, tt
89
89
  * @example
90
90
  * ```tsx
91
91
  * Taro.setNavigationBarTitle({
@@ -19,6 +19,9 @@ export interface IMiniAppConfig {
19
19
  /** 指定 React 框架相关的代码是否使用开发环境(未压缩)代码,默认使用生产环境(压缩后)代码 */
20
20
  debugReact?: boolean
21
21
 
22
+ /** 是否跳过第三方依赖 usingComponent 的处理,默认为自动处理第三方依赖的自定义组件 */
23
+ skipProcessUsingComponents?: boolean
24
+
22
25
  /** 压缩小程序 xml 文件的相关配置 */
23
26
  minifyXML?: {
24
27
  /** 是否合并 xml 文件中的空格 (默认false) */
@@ -39,7 +42,7 @@ export interface IMiniAppConfig {
39
42
  /**
40
43
  * 编译前清空输出目录
41
44
  * @since Taro v3.6.9
42
- * @description
45
+ * @description
43
46
  * - 默认清空输出目录,可设置 clean: false 不清空
44
47
  * - 可设置 clean: { keep: ['project.config.json'] } 保留指定文件
45
48
  * - 注意 clean.keep 不支持函数
@@ -98,3 +101,10 @@ export interface IMiniAppConfig {
98
101
  /** 插件内部使用 */
99
102
  runtime?: Runtime
100
103
  }
104
+
105
+ export interface IMiniFilesConfig {
106
+ [configName: string]: {
107
+ content: Config
108
+ path: string
109
+ }
110
+ }
@@ -2,13 +2,13 @@ import type Webpack from 'webpack'
2
2
  import type Chain from 'webpack-chain'
3
3
  import { type Input } from 'postcss'
4
4
  import type { Compiler } from '../compiler'
5
- import type { IModifyWebpackChain } from '../hooks'
5
+ import type { IModifyChainData } from '../hooks'
6
6
  import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from './util'
7
7
  import type { IH5Config } from './h5'
8
- import type { IMiniAppConfig } from './mini'
9
- import { IRNConfig } from './rn'
8
+ import type { IMiniAppConfig, IMiniFilesConfig } from './mini'
9
+ import type { IRNConfig } from './rn'
10
10
 
11
- export type PluginItem = string | [string, object] | [string, () => object | Promise<object>]
11
+ export type PluginItem<T = object> = string | [string, T] | [string, () => T | Promise<T>]
12
12
 
13
13
  interface ICache {
14
14
  /**
@@ -179,21 +179,27 @@ export interface IProjectBaseConfig {
179
179
  /**
180
180
  * 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail#miniwebpackchain)
181
181
  */
182
- modifyWebpackChain?: (chain: Chain, webpack: typeof Webpack, data: IModifyWebpackChain) => Promise<any>
182
+ modifyWebpackChain?: (chain: Chain, webpack: typeof Webpack, data: IModifyChainData) => Promise<any>
183
183
 
184
184
  /**
185
185
  * 编译中修改 vite 配置
186
186
  */
187
- modifyViteConfig?: (viteConfig: any, componentConfig: IModifyWebpackChain['componentConfig']) => void
187
+ modifyViteConfig?: (viteConfig: any, data: IModifyChainData) => void
188
+
189
+ /**
190
+ * 修改编译后的结果
191
+ */
192
+ modifyBuildAssets?: (assets: any, miniPlugin?: any) => Promise<any>
193
+
188
194
  /**
189
195
  * 修改编译过程中的页面组件配置
190
196
  */
191
- modifyMiniConfigs?: (configMap: any) => Promise<any>
197
+ modifyMiniConfigs?: (configMap: IMiniFilesConfig) => Promise<any>
192
198
 
193
199
  /**
194
- * 修改编译后的结果
200
+ * 修改 Taro 编译配置
195
201
  */
196
- modifyBuildAssets?: (assets: any, miniPlugin?: any) => Promise<any>
202
+ modifyRunnerOpts?: (opts: any) => Promise<any>
197
203
  }
198
204
 
199
205
  /** 暴露出来给 config/index 使用的配置类型,参考 https://github.com/NervJS/taro-doctor/blob/main/assets/config_schema.json */
@@ -6,7 +6,7 @@ import type { IOption, IPostcssOption } from './util'
6
6
 
7
7
  export interface IRNConfig {
8
8
  /** 设置 RN bundle 中注册应用的名称 */
9
- appName: string
9
+ appName?: string
10
10
 
11
11
  /** entry 利用模块查找规则{name}.{platform}.{ext}自动区分平台 */
12
12
  entry?: string
@@ -53,4 +53,12 @@ export interface IRNConfig {
53
53
 
54
54
  /** 将 svg 文件转换为组件引入。默认值 false,不开启 */
55
55
  enableSvgTransform?: boolean
56
+
57
+ alias?: IOption
58
+
59
+ /** 设计稿尺寸 */
60
+ designWidth?: number | ((size?: string | number | Input) => number)
61
+
62
+ /** 设计稿尺寸换算规则 */
63
+ deviceRatio?: TaroGeneral.TDeviceRatio
56
64
  }
@@ -8,6 +8,6 @@ export interface IComponentConfig {
8
8
  includeAll: boolean
9
9
  }
10
10
 
11
- export interface IModifyWebpackChain {
11
+ export interface IModifyChainData {
12
12
  componentConfig?: IComponentConfig
13
13
  }
@@ -215,6 +215,22 @@ declare module './index' {
215
215
  * @default "webview"
216
216
  */
217
217
  renderer?: 'webview' | 'skyline'
218
+ /**
219
+ * 组件框架
220
+ * @default "exparser"
221
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/glass-easel/migration.html
222
+ */
223
+ componentFramework?: 'exparser' | 'glass-easel'
224
+ /**
225
+ * 指定特殊的样式隔离选项
226
+ *
227
+ * isolated 表示启用样式隔离,在自定义组件内外,使用 class 指定的样式将不会相互影响(一般情况下的默认值)
228
+ *
229
+ * apply-shared 表示页面 wxss 样式将影响到自定义组件,但自定义组件 wxss 中指定的样式不会影响页面
230
+ *
231
+ * shared 表示页面 wxss 样式将影响到自定义组件,自定义组件 wxss 中指定的样式也会影响页面和其他设置了 apply-shared 或 shared 的自定义组件。(这个选项在插件中不可用。)
232
+ */
233
+ styleIsolation?: 'isolated' | 'apply-shared' | 'shared'
218
234
  /**
219
235
  * 设置导航栏额外图标,目前支持设置属性 icon,值为图标 url(以 https/http 开头)或 base64 字符串,大小建议 30*30 px
220
236
  *
@@ -345,6 +361,34 @@ declare module './index' {
345
361
  delay?: number
346
362
  }
347
363
 
364
+ interface RenderOptions {
365
+ skyline: {
366
+ /**
367
+ * 开启默认Block布局
368
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/wxss.html#%E5%BC%80%E5%90%AF%E9%BB%98%E8%AE%A4Block%E5%B8%83%E5%B1%80
369
+ */
370
+ defaultDisplayBlock?: boolean
371
+ /**
372
+ * 关闭 Skyline AB 实验
373
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/migration/release.html#%E5%8F%91%E5%B8%83%E4%B8%8A%E7%BA%BF
374
+ */
375
+ disableABTest?: boolean
376
+ }
377
+ }
378
+
379
+ interface Behavior {
380
+ /**
381
+ * 使用小程序默认分享功能时(即不显式设置 Page.onShareAppMessage),当设置此字段后,会使客户端生成的用于分享的 scheme 带上当前用户打开的页面所携带的 query 参数。
382
+ * @supported alipay 基础库 2.7.10 及以上开始支持,同时需使用 IDE 2.7.0 及以上版本进行构建。
383
+ */
384
+ shareAppMessage?: 'appendQuery'
385
+ /**
386
+ * 小程序在解析全局参数、页面参数时默认会对键/值做 encodeURIComponent。当设置为 disable 后,则不再对键/值做encodeURIComponent
387
+ * @supported alipay 基础库 2.7.19 及以上开始支持,同时需使用 IDE 3.0.0 及以上版本进行构建。
388
+ */
389
+ decodeQuery?: 'disable'
390
+ }
391
+
348
392
  interface AppConfig {
349
393
  /** 小程序默认启动首页,未指定 entryPagePath 时,数组的第一项代表小程序的初始页面(首页)。 */
350
394
  entryPagePath?: string
@@ -365,9 +409,11 @@ declare module './index' {
365
409
  * @default false
366
410
  * @since 2.1.0
367
411
  */
368
- functionalPages?: boolean | {
369
- independent?: boolean
370
- }
412
+ functionalPages?:
413
+ | boolean
414
+ | {
415
+ independent?: boolean
416
+ }
371
417
  /** 分包结构配置
372
418
  * @example
373
419
  * ```json
@@ -388,7 +434,7 @@ declare module './index' {
388
434
  * 使用 Worker 处理多线程任务时,设置 Worker 代码放置的目录
389
435
  * @since 1.9.90
390
436
  */
391
- workers?: string
437
+ workers?: string | string[]
392
438
  /** 申明需要后台运行的能力,类型为数组。目前支持以下项目:
393
439
  * - audio: 后台音乐播放
394
440
  * - location: 后台定位
@@ -555,6 +601,42 @@ declare module './index' {
555
601
  * @default "webview"
556
602
  */
557
603
  renderer?: 'webview' | 'skyline'
604
+ /**
605
+ * 渲染后端选项
606
+ * @see https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#rendererOptions
607
+ */
608
+ rendererOptions?: RenderOptions
609
+ /**
610
+ * 指定小程序使用的组件框架
611
+ * @default "exparser"
612
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/glass-easel/migration.html
613
+ */
614
+ componentFramework?: 'exparser' | 'glass-easel'
615
+ /**
616
+ * 多端模式场景接入身份管理服务时开启小程序授权页相关配置
617
+ * @see https://dev.weixin.qq.com/docs/framework/getting_started/auth.html#%E6%96%B0%E6%89%8B%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B
618
+ */
619
+ miniApp?: {
620
+ /**
621
+ * 用于 wx.weixinMinProgramLogin 在小程序中插入「小程序授权 Page」
622
+ */
623
+ useAuthorizePage: boolean
624
+ }
625
+ /**
626
+ * 正常情况下默认所有资源文件都被打包发布到所有平台,可以通过 static 字段配置特定每个目录/文件只能发布到特定的平台(多端场景)
627
+ * @see https://dev.weixin.qq.com/docs/framework/guideline/devtools/condition-compile.html#%E8%B5%84%E6%BA%90
628
+ */
629
+ static?: { pattern: string; platforms: string[] }[]
630
+ /**
631
+ * 动态插件配置规则,声明小程序需要使用动态插件
632
+ * @supported alipay
633
+ */
634
+ useDynamicPlugins?: boolean
635
+ /**
636
+ * 用于改变小程序若干运行行为
637
+ * @supported alipay
638
+ */
639
+ behavior?: Behavior
558
640
  }
559
641
 
560
642
  interface Config extends PageConfig, AppConfig {