@tarojs/taro 3.6.5 → 3.6.6-alpha.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.6.5",
3
+ "version": "3.6.6-alpha.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,8 +21,8 @@
21
21
  "author": "O2Team",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@tarojs/api": "3.6.5",
25
- "@tarojs/runtime": "3.6.5"
24
+ "@tarojs/api": "3.6.6-alpha.1",
25
+ "@tarojs/runtime": "3.6.6-alpha.1"
26
26
  },
27
27
  "peerDependenciesMeta": {
28
28
  "@types/react": {
@@ -26,7 +26,7 @@ declare module '../../index' {
26
26
  * @supported weapp
27
27
  * @example
28
28
  * ```tsx
29
- * Taro.getRandomValues({
29
+ * Taro.getUserCryptoManager().getRandomValues({
30
30
  * length: 6 // 生成 6 个字节长度的随机数,
31
31
  * success: res => {
32
32
  * console.log(Taro.arrayBufferToBase64(res.randomValues)) // 转换为 base64 字符串后打印
@@ -35,7 +35,7 @@ declare module '../../index' {
35
35
  * ```
36
36
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/crypto/UserCryptoManager.getRandomValues.html
37
37
  */
38
- getRandomValues(option: UserCryptoManager.getRandomValues.Option): Promise<UserCryptoManager.getRandomValues.SuccessCallbackResult>
38
+ getRandomValues(option: UserCryptoManager.getRandomValues.Option): void
39
39
  }
40
40
 
41
41
  namespace UserCryptoManager {
@@ -66,7 +66,7 @@ declare module '../../index' {
66
66
  /** 整数,生成随机数的字节数,最大 1048576 */
67
67
  length: number
68
68
  /** 接口调用成功的回调函数 */
69
- success?: (res: TaroGeneral.CallbackResult) => void
69
+ success?: (res: SuccessCallbackResult) => void
70
70
  /** 接口调用失败的回调函数 */
71
71
  fail?: (res: TaroGeneral.CallbackResult) => void
72
72
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
@@ -86,5 +86,19 @@ declare module '../../index' {
86
86
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/crypto/wx.getUserCryptoManager.html
87
87
  */
88
88
  getUserCryptoManager(): UserCryptoManager
89
+
90
+ /** 获取密码学安全随机数
91
+ * @supported weapp
92
+ * @example
93
+ * ```tsx
94
+ * Taro.getRandomValues({
95
+ * length: 6 // 生成 6 个字节长度的随机数
96
+ * }).then(res => {
97
+ * console.log(Taro.arrayBufferToBase64(res.randomValues)) // 转换为 base64 字符串后打印
98
+ * })
99
+ * ```
100
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/crypto/UserCryptoManager.getRandomValues.html
101
+ */
102
+ getRandomValues(option: UserCryptoManager.getRandomValues.Option): Promise<UserCryptoManager.getRandomValues.SuccessCallbackResult>
89
103
  }
90
104
  }
@@ -1730,28 +1730,31 @@ declare module '../../index' {
1730
1730
 
1731
1731
  /** 创建 canvas 的绘图上下文 [CanvasContext](/docs/apis/canvas/CanvasContext) 对象
1732
1732
  *
1733
- * **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 `<canvas/>`
1733
+ * **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 `<canvas/>`;另外,Web 端需要在 `useReady` 回调中执行它,否则会因为底层 canvas 渲染出来之前而去获取 CanvasContext,导致其底层的 context 为 `undefined`,从而不能正常绘图。
1734
1734
  * @supported weapp, h5
1735
1735
  * @example
1736
1736
  * ```tsx
1737
- * const context = Taro.createCanvasContext('canvas')
1737
+ * import { useReady } from '@tarojs/taro'
1738
1738
  *
1739
- * context.setStrokeStyle("#00ff00")
1740
- * context.setLineWidth(5)
1741
- * context.rect(0, 0, 200, 200)
1742
- * context.stroke()
1743
- * context.setStrokeStyle("#ff0000")
1744
- * context.setLineWidth(2)
1745
- * context.moveTo(160, 100)
1746
- * context.arc(100, 100, 60, 0, 2 * Math.PI, true)
1747
- * context.moveTo(140, 100)
1748
- * context.arc(100, 100, 40, 0, Math.PI, false)
1749
- * context.moveTo(85, 80)
1750
- * context.arc(80, 80, 5, 0, 2 * Math.PI, true)
1751
- * context.moveTo(125, 80)
1752
- * context.arc(120, 80, 5, 0, 2 * Math.PI, true)
1753
- * context.stroke()
1754
- * context.draw()
1739
+ * useReady(() => {
1740
+ * const context = Taro.createCanvasContext('canvas')
1741
+ * context.setStrokeStyle("#00ff00")
1742
+ * context.setLineWidth(5)
1743
+ * context.rect(0, 0, 200, 200)
1744
+ * context.stroke()
1745
+ * context.setStrokeStyle("#ff0000")
1746
+ * context.setLineWidth(2)
1747
+ * context.moveTo(160, 100)
1748
+ * context.arc(100, 100, 60, 0, 2 * Math.PI, true)
1749
+ * context.moveTo(140, 100)
1750
+ * context.arc(100, 100, 40, 0, Math.PI, false)
1751
+ * context.moveTo(85, 80)
1752
+ * context.arc(80, 80, 5, 0, 2 * Math.PI, true)
1753
+ * context.moveTo(125, 80)
1754
+ * context.arc(120, 80, 5, 0, 2 * Math.PI, true)
1755
+ * context.stroke()
1756
+ * context.draw()
1757
+ * })
1755
1758
  * ```
1756
1759
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createCanvasContext.html
1757
1760
  */
@@ -496,6 +496,7 @@ declare module '../../index' {
496
496
  callContainer < R = any, P = any >(params: cloud.CallContainerParam<P>): Promise<cloud.CallContainerResult<R>>
497
497
  }
498
498
 
499
+ /** @ignore */
499
500
  interface Cloud {
500
501
  /** 在调用云开发各 API 前,需先调用初始化方法 init 一次(全局只需一次,多次调用时只有第一次生效)
501
502
  * @supported weapp
@@ -284,7 +284,7 @@ declare module '../../index' {
284
284
  /** Transfer-Encoding Chunk Received 事件的回调函数 */
285
285
  callback: RequestTask.onChunkReceived.Callback,
286
286
  ): void
287
- /** 监听 Transfer-Encoding Chunk Received 事件。当接收到新的chunk时触发。
287
+ /** 移除 Transfer-Encoding Chunk Received 事件的监听函数
288
288
  * @supported weapp
289
289
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/request/RequestTask.offChunkReceived.html
290
290
  */
@@ -401,6 +401,15 @@ declare module '../../index' {
401
401
  */
402
402
  addInterceptor(interceptor: interceptor): any
403
403
 
404
+ /** 清除所有拦截器
405
+ * @example
406
+ * ```tsx
407
+ * Taro.cleanInterceptors()
408
+ * ```
409
+ * @supported weapp, h5, alipay, swan, tt, qq
410
+ */
411
+ cleanInterceptors(): void
412
+
404
413
  interceptors: interceptors
405
414
  }
406
415
  }
@@ -31,22 +31,6 @@ declare module '../../index' {
31
31
  }
32
32
  }
33
33
 
34
- namespace checkIsAddedToMyMiniProgram {
35
- interface Option {
36
- /** 接口调用结束的回调函数(调用成功、失败都会执行) */
37
- complete?: (res: TaroGeneral.CallbackResult) => void
38
- /** 接口调用失败的回调函数 */
39
- fail?: (res: TaroGeneral.CallbackResult) => void
40
- /** 接口调用成功的回调函数 */
41
- success?: (res: TaroGeneral.CallbackResult) => void
42
- }
43
-
44
- interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
45
- /**是否被添加至 「我的小程序」 */
46
- added: boolean
47
- }
48
- }
49
-
50
34
  interface TaroStatic {
51
35
  /** 收藏视频
52
36
  * @supported weapp
@@ -80,7 +64,8 @@ declare module '../../index' {
80
64
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/favorites/wx.addVideoToFavorites.html
81
65
  */
82
66
  addVideoToFavorites(option?: addVideoToFavorites.Option): Promise<TaroGeneral.CallbackResult>
83
- /** 预约视频号直播
67
+
68
+ /** 收藏文件
84
69
  * @supported weapp
85
70
  * @example
86
71
  * ```tsx
@@ -112,11 +97,5 @@ declare module '../../index' {
112
97
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/favorites/wx.addFileToFavorites.html
113
98
  */
114
99
  addFileToFavorites(option?: addFileToFavorites.Option): Promise<TaroGeneral.CallbackResult>
115
- /**
116
- * 检查小程序是否被添加至 「我的小程序」
117
- * @supported weapp
118
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/my-miniprogram/wx.checkIsAddedToMyMiniProgram.html
119
- */
120
- checkIsAddedToMyMiniProgram(option?: checkIsAddedToMyMiniProgram.Option):Promise<checkIsAddedToMyMiniProgram.SuccessCallbackResult>
121
100
  }
122
101
  }
@@ -0,0 +1,28 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace checkIsAddedToMyMiniProgram {
5
+ interface Option {
6
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
+ complete?: (res: TaroGeneral.CallbackResult) => void
8
+ /** 接口调用失败的回调函数 */
9
+ fail?: (res: TaroGeneral.CallbackResult) => void
10
+ /** 接口调用成功的回调函数 */
11
+ success?: (res: TaroGeneral.CallbackResult) => void
12
+ }
13
+
14
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
15
+ /**是否被添加至 「我的小程序」 */
16
+ added: boolean
17
+ }
18
+ }
19
+
20
+ interface TaroStatic {
21
+ /**
22
+ * 检查小程序是否被添加至 「我的小程序」
23
+ * @supported weapp
24
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/my-miniprogram/wx.checkIsAddedToMyMiniProgram.html
25
+ */
26
+ checkIsAddedToMyMiniProgram(option?: checkIsAddedToMyMiniProgram.Option):Promise<checkIsAddedToMyMiniProgram.SuccessCallbackResult>
27
+ }
28
+ }
@@ -3,8 +3,8 @@ import type Chain from 'webpack-chain'
3
3
  import type { Compiler } from '../compiler'
4
4
  import type { IModifyWebpackChain } from '../hooks'
5
5
  import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from "./util"
6
- import { IH5Config } from './h5'
7
- import { IMiniAppConfig } from './mini'
6
+ import type { IH5Config } from './h5'
7
+ import type { IMiniAppConfig } from './mini'
8
8
 
9
9
  export type PluginItem = string | [string, object]
10
10
 
@@ -67,7 +67,7 @@ export interface IProjectBaseConfig {
67
67
  onCompilerMake?: (compilation: Webpack.Compilation, compiler: Webpack.Compiler, plugin: any) => Promise<any>
68
68
  onWebpackChainReady?: (webpackChain: Chain) => Promise<any>
69
69
  /**
70
- * 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail.md#miniwebpackchain)
70
+ * 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail#miniwebpackchain)
71
71
  */
72
72
  modifyWebpackChain?: (chain: Chain, webpack: typeof Webpack, data: IModifyWebpackChain) => Promise<any>
73
73
  /**
@@ -11,6 +11,12 @@ declare module './index' {
11
11
  duration?: number
12
12
  }
13
13
 
14
+ interface AppInfo {
15
+ platform: string,
16
+ taroVersion: string
17
+ designWidth: number
18
+ }
19
+
14
20
  interface RequestParams<T=any> extends request.Option<T, any> {
15
21
  [propName: string]: any
16
22
  }
@@ -77,6 +83,14 @@ declare module './index' {
77
83
  unitPrecision?: number
78
84
  }): void
79
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
+
80
94
  /** 小程序引用插件 JS 接口
81
95
  * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
82
96
  */