@tarojs/taro 3.3.14 → 3.5.0-canary.0

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.3.14",
3
+ "version": "3.5.0-canary.0",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -26,9 +26,9 @@
26
26
  "author": "O2Team",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@tarojs/api": "3.3.14",
30
- "@tarojs/runtime": "3.3.14",
31
- "@tarojs/taro-h5": "3.3.14"
29
+ "@tarojs/api": "3.5.0-canary.0",
30
+ "@tarojs/runtime": "3.5.0-canary.0",
31
+ "@tarojs/taro-h5": "3.5.0-canary.0"
32
32
  },
33
- "gitHead": "ffd2b33c2a760094372a9ec69735ab9c4d1877e5"
33
+ "gitHead": "a0222bc41bc05b0e34413d6db3de963d777a5015"
34
34
  }
@@ -41,6 +41,8 @@ declare module '../../index' {
41
41
  '3g'
42
42
  /** 4g 网络 */
43
43
  '4g'
44
+ /** 5g 网络 */
45
+ '5g'
44
46
  /** Android 下不常见的网络类型 */
45
47
  'unknown'
46
48
  /** 无网络 */
@@ -48,6 +50,23 @@ declare module '../../index' {
48
50
  }
49
51
  }
50
52
 
53
+ namespace getLocalIPAddress {
54
+ interface Option {
55
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
56
+ complete?: (res: TaroGeneral.CallbackResult) => void
57
+ /** 接口调用失败的回调函数 */
58
+ fail?: (res: TaroGeneral.CallbackResult) => void
59
+ /** 接口调用成功的回调函数 */
60
+ success?: (result: SuccessCallbackResult) => void
61
+ }
62
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
63
+ /** 本机局域网IP地址 */
64
+ localip: string
65
+ /** 调用结果 */
66
+ errMsg: string
67
+ }
68
+ }
69
+
51
70
  interface TaroStatic {
52
71
  /** 监听网络状态变化。
53
72
  * @supported weapp, h5, rn
@@ -89,5 +108,18 @@ declare module '../../index' {
89
108
  /** 取消监听网络状态变化事件,参数为空,则取消所有的事件监听 */
90
109
  callback?: (...args: any[]) => any,
91
110
  ): void
111
+
112
+ /** 获取局域网IP地址。
113
+ * @supported weapp
114
+ * @example
115
+ * ```tsx
116
+ * Taro.getLocalIPAddress()
117
+ * .then(res => {
118
+ * const localip = res.localip
119
+ * })
120
+ * ```
121
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.getLocalIPAddress.html
122
+ */
123
+ getLocalIPAddress(option?: getLocalIPAddress.Option): Promise<getLocalIPAddress.SuccessCallbackResult>
92
124
  }
93
125
  }
@@ -39,5 +39,15 @@ declare module '../../index' {
39
39
  /** 内存不足告警事件的回调函数 */
40
40
  callback: onMemoryWarning.Callback,
41
41
  ): void
42
+
43
+ /** 取消监听内存不足告警事件。
44
+ * @supported weapp
45
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/memory/wx.offMemoryWarning.html
46
+ */
47
+ offMemoryWarning(
48
+ /** 取消监听内存不足告警事件 */
49
+ callback: (...args: any[]) => any,
50
+ ): void
51
+
42
52
  }
43
53
  }
@@ -15,9 +15,10 @@ declare module '../../index' {
15
15
  *
16
16
  * 可选值:
17
17
  * - 'success': 显示成功图标,此时 title 文本最多显示 7 个汉字长度;
18
+ * - 'error': 显示失败图标,此时 title 文本最多显示 7 个汉字长度;
18
19
  * - 'loading': 显示加载图标,此时 title 文本最多显示 7 个汉字长度;
19
20
  * - 'none': 不显示图标,此时 title 文本最多可显示两行 */
20
- icon?: 'success' | 'loading' | 'none'
21
+ icon?: 'success' | 'error' | 'loading' | 'none'
21
22
  /** 自定义图标的本地路径,image 的优先级高于 icon */
22
23
  image?: string
23
24
  /** 是否显示透明蒙层,防止触摸穿透 */
@@ -121,6 +122,8 @@ declare module '../../index' {
121
122
 
122
123
  namespace enableAlertBeforeUnload {
123
124
  interface Option {
125
+ /** 询问对话框内容 */
126
+ message: string
124
127
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
125
128
  complete?: (res: TaroGeneral.CallbackResult) => void
126
129
  /** 接口调用失败的回调函数 */
@@ -257,7 +260,7 @@ declare module '../../index' {
257
260
  * ```
258
261
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.enableAlertBeforeUnload.html
259
262
  */
260
- enableAlertBeforeUnload(option?: enableAlertBeforeUnload.Option): void
263
+ enableAlertBeforeUnload(option: enableAlertBeforeUnload.Option): void
261
264
 
262
265
  /** 关闭小程序页面返回询问对话框
263
266
  * @supported weapp
@@ -209,10 +209,6 @@ declare enum LogLevel {
209
209
  DEBUG = 'debug'
210
210
  }
211
211
 
212
- export interface IDeviceRatio {
213
- [key: string]: number
214
- }
215
-
216
212
  export type SystemConfig = {
217
213
  /**
218
214
  * 打印日志等级,分为 off,error,warn,info,log,debug
@@ -361,7 +357,7 @@ export interface IProjectBaseConfig {
361
357
  date?: string,
362
358
  designWidth?: number,
363
359
  watcher?: any[],
364
- deviceRatio?: IDeviceRatio,
360
+ deviceRatio?: TaroGeneral.TDeviceRatio,
365
361
  sourceRoot?: string,
366
362
  outputRoot?: string,
367
363
  env?: IOption,
package/types/global.d.ts CHANGED
@@ -347,4 +347,46 @@ declare namespace TaroGeneral {
347
347
  extraData: IAnyObject
348
348
  }
349
349
  }
350
+
351
+ // Events
352
+ class Events {
353
+ /**
354
+ * 监听一个事件,接受参数
355
+ */
356
+ on(eventName: string, listener: (...args: any[]) => void): this
357
+
358
+ /**
359
+ * 添加一个事件监听,并在事件触发完成之后移除Callbacks链
360
+ */
361
+ once(eventName: string, listener: (...args: any[]) => void): this
362
+
363
+ /**
364
+ * 取消监听一个事件
365
+ */
366
+ off(eventName: string, listener?: (...args: any[]) => void): this
367
+
368
+ /**
369
+ * 取消监听的所有事件
370
+ */
371
+ off(): this
372
+
373
+ /**
374
+ * 触发一个事件,传参
375
+ */
376
+ trigger(eventName: string, ...args: any[]): boolean
377
+ }
378
+
379
+ // ENV_TYPE
380
+ enum ENV_TYPE {
381
+ WEAPP = 'WEAPP',
382
+ WEB = 'WEB',
383
+ RN = 'RN',
384
+ SWAN = 'SWAN',
385
+ ALIPAY = 'ALIPAY',
386
+ TT = 'TT',
387
+ QQ = 'QQ',
388
+ JD = 'JD'
389
+ }
390
+
391
+ type TDeviceRatio = Record<string, number>
350
392
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  /// <reference types="vue" />
3
3
 
4
- import Taro, { ComponentOptions, Config, RouterInfo } from './index'
4
+ import Taro, { Config } from './index'
5
5
 
6
6
  declare module './index' {
7
7
  // Components
@@ -1,51 +1,6 @@
1
1
  import Taro, { Component } from './index'
2
2
 
3
- // Events
4
- export class TaroEvents {
5
- /**
6
- * 监听一个事件,接受参数
7
- */
8
- on(eventName: string, listener: (...args: any[]) => void): this
9
-
10
- /**
11
- * 添加一个事件监听,并在事件触发完成之后移除Callbacks链
12
- */
13
- once(eventName: string, listener: (...args: any[]) => void): this
14
-
15
- /**
16
- * 取消监听一个事件
17
- */
18
- off(eventName: string, listener?: (...args: any[]) => void): this
19
-
20
- /**
21
- * 取消监听的所有事件
22
- */
23
- off(): this
24
-
25
- /**
26
- * 触发一个事件,传参
27
- */
28
- trigger(eventName: string, ...args: any[]): boolean
29
- }
30
-
31
- // ENV_TYPE
32
-
33
- export enum TARO_ENV_TYPE {
34
- WEAPP = 'WEAPP',
35
- WEB = 'WEB',
36
- RN = 'RN',
37
- SWAN = 'SWAN',
38
- ALIPAY = 'ALIPAY',
39
- TT = 'TT',
40
- QQ = 'QQ',
41
- JD = 'JD'
42
- }
43
-
44
3
  declare module './index' {
45
- type Events = TaroEvents
46
-
47
- type ENV_TYPE = TARO_ENV_TYPE
48
-
49
4
  type MessageType = 'info' | 'success' | 'error' | 'warning'
50
5
 
51
6
  interface AtMessageOptions {
@@ -87,11 +42,28 @@ declare module './index' {
87
42
  rnNavigationRef?: React.RefObject<any>
88
43
  }
89
44
 
45
+ interface SetGlobalDataPlugin {
46
+ install (app: any, data: any): void
47
+ }
48
+
49
+ interface TARO_ENV_TYPE {
50
+ [TaroGeneral.ENV_TYPE.WEAPP]: TaroGeneral.ENV_TYPE.WEAPP
51
+ [TaroGeneral.ENV_TYPE.WEB]: TaroGeneral.ENV_TYPE.WEB
52
+ [TaroGeneral.ENV_TYPE.RN]: TaroGeneral.ENV_TYPE.RN
53
+ [TaroGeneral.ENV_TYPE.SWAN]: TaroGeneral.ENV_TYPE.SWAN
54
+ [TaroGeneral.ENV_TYPE.ALIPAY]: TaroGeneral.ENV_TYPE.ALIPAY
55
+ [TaroGeneral.ENV_TYPE.TT]: TaroGeneral.ENV_TYPE.TT
56
+ [TaroGeneral.ENV_TYPE.QQ]: TaroGeneral.ENV_TYPE.QQ
57
+ [TaroGeneral.ENV_TYPE.JD]: TaroGeneral.ENV_TYPE.JD
58
+ }
59
+
90
60
  interface TaroStatic {
91
61
  // eventCenter
92
- eventCenter: TaroEvents
62
+ eventCenter: TaroGeneral.Events
63
+
64
+ ENV_TYPE: TARO_ENV_TYPE
93
65
 
94
- getEnv(): ENV_TYPE
66
+ getEnv(): TaroGeneral.ENV_TYPE
95
67
 
96
68
  render(component: Component | JSX.Element, element: Element | null): any
97
69
 
@@ -101,7 +73,7 @@ declare module './index' {
101
73
  atMessage(options: AtMessageOptions): void
102
74
 
103
75
  pxTransform(size: number, designWidth?: number): string
104
- initPxTransform(config: { designWidth: number; deviceRatio: object }): void
76
+ initPxTransform(config: { designWidth: number; deviceRatio: TaroGeneral.TDeviceRatio }): void
105
77
 
106
78
  addInterceptor(interceptor: interceptor): any
107
79
 
@@ -115,5 +87,20 @@ declare module './index' {
115
87
  Current: Current
116
88
 
117
89
  getCurrentInstance(): Current
90
+
91
+ /**
92
+ * @desc Vue3 插件,用于设置 `getApp()` 中的全局变量
93
+ * @example
94
+ * ```js
95
+ * // 使用插件
96
+ * const App = createApp(...)
97
+ * App.use(setGlobalDataPlugin, {
98
+ * xxx: 999
99
+ * })
100
+ * // 获取全局变量
101
+ * Taro.getApp().xxx
102
+ * ```
103
+ */
104
+ setGlobalDataPlugin: SetGlobalDataPlugin
118
105
  }
119
106
  }