@tarojs/taro 3.7.0-beta.1 → 3.7.0-beta.4
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/html.css +9 -0
- package/package.json +11 -4
- package/types/api/ai/visionkit.d.ts +625 -54
- package/types/api/base/performance.d.ts +5 -5
- package/types/api/canvas/index.d.ts +67 -54
- package/types/api/data-analysis/index.d.ts +51 -1
- package/types/api/device/accelerometer.d.ts +8 -6
- package/types/api/device/accessibility.d.ts +1 -1
- package/types/api/device/battery.d.ts +3 -3
- package/types/api/device/bluetooth-ble.d.ts +40 -17
- package/types/api/device/bluetooth-peripheral.d.ts +26 -26
- package/types/api/device/bluetooth.d.ts +37 -13
- package/types/api/device/calendar.d.ts +11 -1
- package/types/api/device/clipboard.d.ts +17 -17
- package/types/api/device/compass.d.ts +5 -5
- package/types/api/device/gyroscope.d.ts +4 -4
- package/types/api/device/iBeacon.d.ts +10 -8
- package/types/api/device/keyboard.d.ts +7 -5
- package/types/api/device/memory.d.ts +3 -4
- package/types/api/device/motion.d.ts +8 -6
- package/types/api/device/network.d.ts +12 -6
- package/types/api/device/nfc.d.ts +13 -13
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/scan.d.ts +5 -3
- package/types/api/device/screen.d.ts +28 -12
- package/types/api/device/sms.d.ts +1 -1
- package/types/api/device/vibrate.d.ts +5 -5
- package/types/api/device/wifi.d.ts +25 -13
- package/types/api/files/index.d.ts +71 -41
- package/types/api/location/index.d.ts +166 -18
- package/types/api/media/camera.d.ts +6 -3
- package/types/api/navigate/index.d.ts +2 -0
- package/types/api/open-api/device-voip.d.ts +2 -2
- package/types/api/open-api/login.d.ts +1 -1
- package/types/api/open-api/my-miniprogram.d.ts +2 -2
- package/types/api/open-api/privacy.d.ts +99 -0
- package/types/api/route/index.d.ts +1 -0
- package/types/api/skyline/index.d.ts +59 -0
- package/types/api/storage/background-fetch.d.ts +63 -11
- package/types/api/storage/cache-manager.d.ts +61 -10
- package/types/api/storage/index.d.ts +125 -10
- package/types/api/taro.extend.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +4 -3
- package/types/api/wxml/index.d.ts +2 -2
- package/types/compile/compiler.d.ts +7 -5
- package/types/compile/config/h5.d.ts +23 -10
- package/types/compile/config/mini.d.ts +46 -31
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +8 -8
- package/types/compile/config/util.d.ts +20 -8
- package/types/compile/viteCompilerContext.d.ts +130 -0
- package/types/global.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/taro.api.d.ts +3 -0
- package/types/taro.component.d.ts +1 -1
- package/types/taro.config.d.ts +41 -4
|
@@ -25,6 +25,25 @@ declare module '../../index' {
|
|
|
25
25
|
/** 接口调用成功的回调函数 */
|
|
26
26
|
success?: (res: TaroGeneral.CallbackResult) => void
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
type Callback = (
|
|
30
|
+
result: CallbackResult,
|
|
31
|
+
) => void
|
|
32
|
+
|
|
33
|
+
interface CallbackResult {
|
|
34
|
+
/** 缓存数据类别,取值为 periodic 或 pre */
|
|
35
|
+
fetchType: string
|
|
36
|
+
/** 缓存数据 */
|
|
37
|
+
fetchedData: string
|
|
38
|
+
/** 客户端拿到缓存数据的时间戳 */
|
|
39
|
+
timeStamp: number
|
|
40
|
+
/** 小程序页面路径 */
|
|
41
|
+
path: string
|
|
42
|
+
/** 传给页面的 query 参数 */
|
|
43
|
+
query: string
|
|
44
|
+
/** 进入小程序的场景值 */
|
|
45
|
+
scene: number
|
|
46
|
+
}
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
namespace getBackgroundFetchToken {
|
|
@@ -34,46 +53,79 @@ declare module '../../index' {
|
|
|
34
53
|
/** 接口调用失败的回调函数 */
|
|
35
54
|
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
36
55
|
/** 接口调用成功的回调函数 */
|
|
37
|
-
success?: (res:
|
|
56
|
+
success?: (res: SuccessCallbackResult) => void
|
|
57
|
+
}
|
|
58
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
59
|
+
/** 自定义的登录态 */
|
|
60
|
+
token: string
|
|
61
|
+
/** 接口调用结果 */
|
|
62
|
+
errMsg: string
|
|
38
63
|
}
|
|
39
64
|
}
|
|
40
65
|
|
|
41
66
|
namespace getBackgroundFetchData {
|
|
42
67
|
interface Option {
|
|
43
|
-
/**
|
|
68
|
+
/** 缓存数据类别
|
|
69
|
+
* @weapp 取值为 periodic
|
|
70
|
+
* @qq 取值为 periodic
|
|
71
|
+
* @alipay 取值为 pre: 数据预拉取; jsapiPre: API 预调用(目前仅支持地理位置预拉取)
|
|
72
|
+
*/
|
|
44
73
|
fetchType: string
|
|
45
74
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
46
75
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
47
76
|
/** 接口调用失败的回调函数 */
|
|
48
77
|
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
49
78
|
/** 接口调用成功的回调函数 */
|
|
50
|
-
success?: (res:
|
|
79
|
+
success?: (res: SuccessCallbackResult) => void
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
83
|
+
/** 缓存数据
|
|
84
|
+
* @alipay Object
|
|
85
|
+
*/
|
|
86
|
+
fetchedData: string | Object
|
|
87
|
+
/** 客户端拿到缓存数据的时间戳 ms。(iOS 时间戳存在异常,8.0.27 修复) */
|
|
88
|
+
timeStamp: number
|
|
89
|
+
/** 小程序页面路径 */
|
|
90
|
+
path: string
|
|
91
|
+
/** 传给页面的 query 参数 */
|
|
92
|
+
query: string
|
|
93
|
+
/** 进入小程序的场景值 */
|
|
94
|
+
scene: number
|
|
95
|
+
/** 缓存数据类型,与入参 fetchType 一致
|
|
96
|
+
* @supported alipay
|
|
97
|
+
*/
|
|
98
|
+
fetchType?: string
|
|
99
|
+
/** 缓存数据的时间戳。单位:ms。
|
|
100
|
+
* @supported alipay
|
|
101
|
+
*/
|
|
102
|
+
timestamp?: number
|
|
51
103
|
}
|
|
52
104
|
}
|
|
53
105
|
|
|
54
106
|
interface TaroStatic {
|
|
55
107
|
/** 设置自定义登录态,在周期性拉取数据时带上,便于第三方服务器验证请求合法性
|
|
56
|
-
* @supported weapp
|
|
108
|
+
* @supported weapp, qq
|
|
57
109
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.setBackgroundFetchToken.html
|
|
58
110
|
*/
|
|
59
|
-
setBackgroundFetchToken(option: setBackgroundFetchToken.Option):
|
|
111
|
+
setBackgroundFetchToken(option: setBackgroundFetchToken.Option): Promise<TaroGeneral.CallbackResult>
|
|
60
112
|
|
|
61
113
|
/** 收到 backgroundFetch 数据时的回调
|
|
62
|
-
* @supported weapp
|
|
114
|
+
* @supported weapp, qq
|
|
63
115
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.onBackgroundFetchData.html
|
|
64
116
|
*/
|
|
65
|
-
onBackgroundFetchData(option?: onBackgroundFetchData.Option): void
|
|
117
|
+
onBackgroundFetchData(option?: onBackgroundFetchData.Option | onBackgroundFetchData.Callback): void
|
|
66
118
|
|
|
67
119
|
/** 获取设置过的自定义登录态。若无,则返回 fail。
|
|
68
|
-
* @supported weapp
|
|
120
|
+
* @supported weapp, qq
|
|
69
121
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchToken.html
|
|
70
122
|
*/
|
|
71
|
-
getBackgroundFetchToken(option?: getBackgroundFetchToken.Option):
|
|
123
|
+
getBackgroundFetchToken(option?: getBackgroundFetchToken.Option): Promise<TaroGeneral.CallbackResult>
|
|
72
124
|
|
|
73
125
|
/** 拉取 backgroundFetch 客户端缓存数据
|
|
74
|
-
* @supported weapp
|
|
126
|
+
* @supported weapp, alipay, qq
|
|
75
127
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchData.html
|
|
76
128
|
*/
|
|
77
|
-
getBackgroundFetchData(option: getBackgroundFetchData.Option):
|
|
129
|
+
getBackgroundFetchData(option: getBackgroundFetchData.Option): Promise<getBackgroundFetchData.SuccessCallbackResult>
|
|
78
130
|
}
|
|
79
131
|
}
|
|
@@ -2,8 +2,42 @@ import Taro from '../../index'
|
|
|
2
2
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
interface CacheManager {
|
|
5
|
+
/** 当前缓存模式 */
|
|
6
|
+
mode: keyof CacheManager.Mode
|
|
7
|
+
/** 全局 origin */
|
|
8
|
+
origin: string
|
|
9
|
+
/** 全局缓存有效时间 */
|
|
10
|
+
maxAge: number
|
|
11
|
+
/** 当前缓存管理器状态 */
|
|
12
|
+
state: keyof CacheManager.State
|
|
5
13
|
/** 添加规则
|
|
6
14
|
* @supported weapp
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const ruleId = cacheManager.addRule({
|
|
18
|
+
* id: 'haha-rule',
|
|
19
|
+
* method: 'GET',
|
|
20
|
+
* url: '/haha',
|
|
21
|
+
* maxAge: 123455,
|
|
22
|
+
* dataSchema: [
|
|
23
|
+
* // data 字段的匹配,默认为空,表示不匹配
|
|
24
|
+
* // 类型可以是:string、number、boolean、null、object、any(表示任意类型均可),以及这些类型的数组表示方式
|
|
25
|
+
* {name: 'aaa', schema: {type: 'string'}}, // 类型为 string
|
|
26
|
+
* {name: 'bbb', schema: [{type: 'number'}, {type: 'string'}]}, // 类型为 number, string
|
|
27
|
+
* {name: 'ccc', schema: {type: 'string', value: 'abc'}}, // 值为 abc
|
|
28
|
+
* {name: 'ddd', schema: {type: 'string', value: /(abc|cba)/ig}}, // 值符合该正则匹配,如果该值不是字符串类型,则会被尝试转成字符串后再进行比较
|
|
29
|
+
* {name: 'ddd', schema: {type: 'string', value: val => val === '123'}}, // 传入函数来校验值
|
|
30
|
+
* {name: 'eee', schema: {type: 'object', value: [{ // 类型为对象,则通过嵌套的方式来逐层校验
|
|
31
|
+
* name: 'aaa', schema: {type: 'string'},
|
|
32
|
+
* // ...
|
|
33
|
+
* // 嵌套 dataSchema,同上面的方式一样来匹配嵌套的对象
|
|
34
|
+
* }]}},
|
|
35
|
+
* {name: 'fff', schema: {type: 'string[]'}}, // 类型为 string 数组
|
|
36
|
+
* {name: 'ggg', schema: {type: 'any'}}, // 类型为任意类型
|
|
37
|
+
* {name: 'hhh', schema: {type: 'any[]'}}, // 类型为任意类型的数组
|
|
38
|
+
* ]
|
|
39
|
+
* })
|
|
40
|
+
* ```
|
|
7
41
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRule.html
|
|
8
42
|
*/
|
|
9
43
|
addRule(option: CacheManager.AddRuleOption): string
|
|
@@ -26,7 +60,7 @@ declare module '../../index' {
|
|
|
26
60
|
* @supported weapp
|
|
27
61
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteCache.html
|
|
28
62
|
*/
|
|
29
|
-
deleteCache(
|
|
63
|
+
deleteCache(
|
|
30
64
|
/** 缓存 id */
|
|
31
65
|
id: string
|
|
32
66
|
): void
|
|
@@ -40,7 +74,7 @@ declare module '../../index' {
|
|
|
40
74
|
): void
|
|
41
75
|
/** 删除规则,同时会删除对应规则下所有缓存
|
|
42
76
|
* @supported weapp
|
|
43
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteRule.html
|
|
77
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteRule.html
|
|
44
78
|
*/
|
|
45
79
|
deleteRule(
|
|
46
80
|
/** 规则 id */
|
|
@@ -67,17 +101,17 @@ declare module '../../index' {
|
|
|
67
101
|
/** 事件名称 */
|
|
68
102
|
eventName: string,
|
|
69
103
|
/** 事件监听函数 */
|
|
70
|
-
handler:
|
|
104
|
+
handler: TaroGeneral.EventCallback
|
|
71
105
|
): void
|
|
72
106
|
/** 监听事件
|
|
73
107
|
* @supported weapp
|
|
74
108
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.on.html
|
|
75
109
|
*/
|
|
76
|
-
on(
|
|
110
|
+
on(
|
|
77
111
|
/** 事件名称 */
|
|
78
112
|
eventName: keyof CacheManager.OnEventName,
|
|
79
113
|
/** 事件监听函数 */
|
|
80
|
-
handler:
|
|
114
|
+
handler: TaroGeneral.EventCallback
|
|
81
115
|
): void
|
|
82
116
|
/** 开启缓存,仅在 mode 为 none 时生效,调用后缓存管理器的 state 会置为 1
|
|
83
117
|
* @supported weapp
|
|
@@ -92,6 +126,22 @@ declare module '../../index' {
|
|
|
92
126
|
}
|
|
93
127
|
|
|
94
128
|
namespace CacheManager {
|
|
129
|
+
interface Mode {
|
|
130
|
+
/** 默认值,弱网/离线使用缓存返回 */
|
|
131
|
+
weakNetwork
|
|
132
|
+
/** 总是使用缓存返回 */
|
|
133
|
+
always
|
|
134
|
+
/** 不开启,后续可手动开启/停止使用缓存返回 */
|
|
135
|
+
none
|
|
136
|
+
}
|
|
137
|
+
interface State {
|
|
138
|
+
/** 不使用缓存返回 */
|
|
139
|
+
0
|
|
140
|
+
/** 使用缓存返回 */
|
|
141
|
+
1
|
|
142
|
+
/** 未知 */
|
|
143
|
+
2
|
|
144
|
+
}
|
|
95
145
|
interface DataSchema {
|
|
96
146
|
/** 需要匹配的 data 对象的参数类型
|
|
97
147
|
* string、number、boolean、null、object、any(表示任意类型),
|
|
@@ -117,7 +167,7 @@ declare module '../../index' {
|
|
|
117
167
|
method: string
|
|
118
168
|
/** uri 匹配规则,可参考规则字符串写法和正则写法 */
|
|
119
169
|
url: any
|
|
120
|
-
/**
|
|
170
|
+
/**
|
|
121
171
|
* 缓存有效时间,单位为 ms,不填则默认取缓存管理器全局的缓存有效时间
|
|
122
172
|
* @default 7 * 24 * 60 * 60 * 1000
|
|
123
173
|
*/
|
|
@@ -135,6 +185,7 @@ declare module '../../index' {
|
|
|
135
185
|
rule: Rule
|
|
136
186
|
}
|
|
137
187
|
interface AddRulesOption {
|
|
188
|
+
/** 规则列表 */
|
|
138
189
|
rules: Rule[]
|
|
139
190
|
}
|
|
140
191
|
interface MatchOption {
|
|
@@ -189,10 +240,10 @@ declare module '../../index' {
|
|
|
189
240
|
}
|
|
190
241
|
|
|
191
242
|
interface TaroStatic {
|
|
192
|
-
/**
|
|
193
|
-
* @supported
|
|
194
|
-
* @see
|
|
243
|
+
/** 创建缓存管理器
|
|
244
|
+
* @supported weapp
|
|
245
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/wx.createCacheManager.html
|
|
195
246
|
*/
|
|
196
247
|
createCacheManager(option: createCacheManager.Option): CacheManager
|
|
197
248
|
}
|
|
198
|
-
}
|
|
249
|
+
}
|
|
@@ -49,6 +49,10 @@ declare module '../../index' {
|
|
|
49
49
|
keys: string[]
|
|
50
50
|
/** 限制的空间大小,单位 KB */
|
|
51
51
|
limitSize: number
|
|
52
|
+
/** 是否执行成功
|
|
53
|
+
* @supported alipay
|
|
54
|
+
*/
|
|
55
|
+
success?: boolean
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -102,9 +106,54 @@ declare module '../../index' {
|
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
|
|
109
|
+
namespace batchSetStorageSync {
|
|
110
|
+
interface Option {
|
|
111
|
+
/** [{ key, value }] */
|
|
112
|
+
kvList: kv[]
|
|
113
|
+
}
|
|
114
|
+
interface kv {
|
|
115
|
+
/** key 本地缓存中指定的 key */
|
|
116
|
+
key: string
|
|
117
|
+
/** data 需要存储的内容。只支持原生类型、Date、及能够通过JSON.stringify序列化的对象。*/
|
|
118
|
+
value: any
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
namespace batchSetStorage {
|
|
123
|
+
interface Option {
|
|
124
|
+
/** [{ key, value }] */
|
|
125
|
+
kvList: kv[]
|
|
126
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
127
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
128
|
+
/** 接口调用失败的回调函数 */
|
|
129
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
130
|
+
/** 接口调用成功的回调函数 */
|
|
131
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
132
|
+
}
|
|
133
|
+
interface kv {
|
|
134
|
+
/** key 本地缓存中指定的 key */
|
|
135
|
+
key: string
|
|
136
|
+
/** data 需要存储的内容。只支持原生类型、Date、及能够通过JSON.stringify序列化的对象。*/
|
|
137
|
+
value: any
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
namespace batchGetStorage {
|
|
142
|
+
interface Option {
|
|
143
|
+
/** 本地缓存中指定的 keyList */
|
|
144
|
+
keyList: string[]
|
|
145
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
146
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
147
|
+
/** 接口调用失败的回调函数 */
|
|
148
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
149
|
+
/** 接口调用成功的回调函数 */
|
|
150
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
105
154
|
interface TaroStatic {
|
|
106
155
|
/** Taro.setStorage 的同步版本
|
|
107
|
-
* @supported weapp,
|
|
156
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
108
157
|
* @example
|
|
109
158
|
* ```tsx
|
|
110
159
|
* Taro.setStorage({
|
|
@@ -128,7 +177,7 @@ declare module '../../index' {
|
|
|
128
177
|
): void
|
|
129
178
|
|
|
130
179
|
/** 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
|
|
131
|
-
* @supported weapp,
|
|
180
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn
|
|
132
181
|
* @example
|
|
133
182
|
* ```tsx
|
|
134
183
|
* Taro.setStorage({
|
|
@@ -155,7 +204,7 @@ declare module '../../index' {
|
|
|
155
204
|
): void
|
|
156
205
|
|
|
157
206
|
/** Taro.removeStorage 的同步版本
|
|
158
|
-
* @supported weapp,
|
|
207
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
159
208
|
* @example
|
|
160
209
|
* ```tsx
|
|
161
210
|
* try {
|
|
@@ -172,7 +221,7 @@ declare module '../../index' {
|
|
|
172
221
|
): void
|
|
173
222
|
|
|
174
223
|
/** 从本地缓存中移除指定 key
|
|
175
|
-
* @supported weapp,
|
|
224
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn
|
|
176
225
|
* @example
|
|
177
226
|
* ```tsx
|
|
178
227
|
* Taro.removeStorage({
|
|
@@ -187,7 +236,7 @@ declare module '../../index' {
|
|
|
187
236
|
removeStorage(option: removeStorage.Option): Promise<TaroGeneral.CallbackResult>
|
|
188
237
|
|
|
189
238
|
/** Taro.getStorage 的同步版本
|
|
190
|
-
* @supported weapp,
|
|
239
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
191
240
|
* @example
|
|
192
241
|
* ```tsx
|
|
193
242
|
* try {
|
|
@@ -207,7 +256,7 @@ declare module '../../index' {
|
|
|
207
256
|
): T
|
|
208
257
|
|
|
209
258
|
/** Taro.getStorageInfo 的同步版本
|
|
210
|
-
* @supported weapp,
|
|
259
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn
|
|
211
260
|
* @example
|
|
212
261
|
* ```tsx
|
|
213
262
|
* try {
|
|
@@ -224,7 +273,7 @@ declare module '../../index' {
|
|
|
224
273
|
getStorageInfoSync(): getStorageInfoSync.Option
|
|
225
274
|
|
|
226
275
|
/** 异步获取当前storage的相关信息
|
|
227
|
-
* @supported weapp,
|
|
276
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn
|
|
228
277
|
* @example
|
|
229
278
|
* ```tsx
|
|
230
279
|
* Taro.getStorageInfo({
|
|
@@ -240,7 +289,7 @@ declare module '../../index' {
|
|
|
240
289
|
getStorageInfo(option?: getStorageInfo.Option): Promise<TaroGeneral.CallbackResult>
|
|
241
290
|
|
|
242
291
|
/** 从本地缓存中异步获取指定 key 的内容
|
|
243
|
-
* @supported weapp,
|
|
292
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn
|
|
244
293
|
* @example
|
|
245
294
|
* ```tsx
|
|
246
295
|
* Taro.getStorage({
|
|
@@ -264,7 +313,7 @@ declare module '../../index' {
|
|
|
264
313
|
): void
|
|
265
314
|
|
|
266
315
|
/** Taro.clearStorage 的同步版本
|
|
267
|
-
* @supported weapp,
|
|
316
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5
|
|
268
317
|
* @example
|
|
269
318
|
* ```tsx
|
|
270
319
|
* try {
|
|
@@ -278,7 +327,7 @@ declare module '../../index' {
|
|
|
278
327
|
clearStorageSync(): void
|
|
279
328
|
|
|
280
329
|
/** 清理本地数据缓存
|
|
281
|
-
* @supported weapp,
|
|
330
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn
|
|
282
331
|
* @example
|
|
283
332
|
* ```tsx
|
|
284
333
|
* Taro.clearStorage()
|
|
@@ -286,5 +335,71 @@ declare module '../../index' {
|
|
|
286
335
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.clearStorage.html
|
|
287
336
|
*/
|
|
288
337
|
clearStorage(option?: clearStorage.Option): Promise<TaroGeneral.CallbackResult>
|
|
338
|
+
|
|
339
|
+
/** 将数据批量存储在本地缓存中指定的 key 中。
|
|
340
|
+
* 会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。
|
|
341
|
+
* 单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
|
|
342
|
+
* @supported weapp
|
|
343
|
+
* @example
|
|
344
|
+
* ```tsx
|
|
345
|
+
* try {
|
|
346
|
+
* Taro.batchSetStorageSync([{key: 'key', value: 'value'}])
|
|
347
|
+
* } catch (e) { }
|
|
348
|
+
* ```
|
|
349
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorageSync.html
|
|
350
|
+
*/
|
|
351
|
+
batchSetStorageSync(option: batchSetStorageSync.Option): void
|
|
352
|
+
|
|
353
|
+
/** 将数据批量存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。
|
|
354
|
+
* 除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。
|
|
355
|
+
* 单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
|
|
356
|
+
* @supported weapp
|
|
357
|
+
* @example
|
|
358
|
+
* ```tsx
|
|
359
|
+
* Taro.batchGetStorage({
|
|
360
|
+
* keyList: ['key']
|
|
361
|
+
* success(res) {
|
|
362
|
+
* console.log(res)
|
|
363
|
+
* }
|
|
364
|
+
* })
|
|
365
|
+
* ```
|
|
366
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorage.html
|
|
367
|
+
*/
|
|
368
|
+
batchSetStorage(option: batchSetStorage.Option): Promise<TaroGeneral.CallbackResult>
|
|
369
|
+
|
|
370
|
+
/** 从本地缓存中同步批量获取指定 key 的内容。
|
|
371
|
+
* @supported weapp
|
|
372
|
+
* @example
|
|
373
|
+
* ```tsx
|
|
374
|
+
* try {
|
|
375
|
+
* var valueList = Taro.batchGetStorageSync(['key'])
|
|
376
|
+
* if (valueList) {
|
|
377
|
+
* // Do something with return value
|
|
378
|
+
* }
|
|
379
|
+
* } catch (e) {
|
|
380
|
+
* // Do something when catch error
|
|
381
|
+
* }
|
|
382
|
+
* ```
|
|
383
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorageSync.html
|
|
384
|
+
*/
|
|
385
|
+
batchGetStorageSync<T = any>(
|
|
386
|
+
/** 本地缓存中指定的 key 数组 */
|
|
387
|
+
keyList: string[]
|
|
388
|
+
): T[]
|
|
389
|
+
|
|
390
|
+
/** 从本地缓存中异步批量获取指定 key 的内容。
|
|
391
|
+
* @supported weapp
|
|
392
|
+
* @example
|
|
393
|
+
* ```tsx
|
|
394
|
+
* Taro.batchGetStorage({
|
|
395
|
+
* keyList: ['key'],
|
|
396
|
+
* success(res) {
|
|
397
|
+
* console.log(res)
|
|
398
|
+
* }
|
|
399
|
+
* })
|
|
400
|
+
* ```
|
|
401
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorage.html
|
|
402
|
+
*/
|
|
403
|
+
batchGetStorage(option: batchGetStorage.Option): Promise<TaroGeneral.CallbackResult>
|
|
289
404
|
}
|
|
290
405
|
}
|
package/types/api/ui/fonts.d.ts
CHANGED
|
@@ -54,13 +54,14 @@ declare module '../../index' {
|
|
|
54
54
|
/** 动态加载网络字体。文件地址需为下载类型。iOS 仅支持 https 格式文件地址。
|
|
55
55
|
*
|
|
56
56
|
* 注意:
|
|
57
|
-
* 1. 字体文件返回的
|
|
57
|
+
* 1. 字体文件返回的 context-type 参考 [font](https://www.iana.org/assignments/media-types/media-types.xhtml#font),格式不正确时会解析失败。
|
|
58
58
|
* 2. 字体链接必须是https(ios不支持http)
|
|
59
59
|
* 3. 字体链接必须是同源下的,或开启了cors支持,小程序的域名是`servicewechat.com`
|
|
60
60
|
* 4. canvas等原生组件不支持使用接口添加的字体
|
|
61
|
-
* 5. 工具里提示
|
|
62
|
-
* @supported weapp, h5
|
|
61
|
+
* 5. 工具里提示 Failed to load font 可以忽略
|
|
62
|
+
* @supported weapp, alipay, h5
|
|
63
63
|
* @h5 不支持 global (默认全局加载)
|
|
64
|
+
* @alipay source 地址格式为 `url('https://...')`,而不是单纯 URL 地址
|
|
64
65
|
* @example
|
|
65
66
|
* ```tsx
|
|
66
67
|
* Taro.loadFontFace({
|
|
@@ -503,7 +503,7 @@ declare module '../../index' {
|
|
|
503
503
|
* @supported weapp, h5, tt
|
|
504
504
|
* @example
|
|
505
505
|
* ```tsx
|
|
506
|
-
* const
|
|
506
|
+
* const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })
|
|
507
507
|
* ```
|
|
508
508
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createIntersectionObserver.html
|
|
509
509
|
*/
|
|
@@ -525,7 +525,7 @@ declare module '../../index' {
|
|
|
525
525
|
* } else if (process.env.TARO_ENV === 'h5') {
|
|
526
526
|
* createMediaQueryObserver= Taro.createMediaQueryObserver
|
|
527
527
|
* }
|
|
528
|
-
* const mediaQueryObserver = createMediaQueryObserver()
|
|
528
|
+
* const mediaQueryObserver = createMediaQueryObserver()
|
|
529
529
|
* ```
|
|
530
530
|
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html#Media%20Query
|
|
531
531
|
*/
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { swc } from '@tarojs/helper'
|
|
2
2
|
import type Webpack from 'webpack'
|
|
3
3
|
|
|
4
|
-
type CompilerTypes =
|
|
4
|
+
export type CompilerTypes = CompilerWebpackTypes | 'vite'
|
|
5
|
+
|
|
6
|
+
export type CompilerWebpackTypes = 'webpack5' | 'webpack4'
|
|
5
7
|
|
|
6
8
|
interface IPrebundle {
|
|
7
9
|
enable?: boolean
|
|
@@ -17,10 +19,10 @@ interface IPrebundle {
|
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
interface ICompiler {
|
|
21
|
-
type:
|
|
22
|
+
interface ICompiler<T> {
|
|
23
|
+
type: T
|
|
22
24
|
prebundle?: IPrebundle
|
|
23
|
-
vitePlugins?: any
|
|
25
|
+
vitePlugins?: any
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
export type Compiler
|
|
28
|
+
export type Compiler<T extends CompilerTypes = CompilerWebpackTypes> = T | ICompiler<T>
|
|
@@ -2,7 +2,9 @@ import type Webpack from 'webpack'
|
|
|
2
2
|
import type Chain from 'webpack-chain'
|
|
3
3
|
import type webpackDevServer from 'webpack-dev-server'
|
|
4
4
|
import type HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
5
|
-
import type { IOption, IPostcssOption } from './util'
|
|
5
|
+
import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
6
|
+
import type { OutputOptions as RollupOutputOptions } from 'rollup'
|
|
7
|
+
import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
6
8
|
|
|
7
9
|
export interface IH5RouterConfig {
|
|
8
10
|
/** 配置路由模式 */
|
|
@@ -16,7 +18,7 @@ export interface IH5RouterConfig {
|
|
|
16
18
|
forcePath?: string
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export interface IH5Config {
|
|
21
|
+
export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
|
|
20
22
|
/** 设置输出解析文件的目录(默认值:'/')*/
|
|
21
23
|
publicPath?: string
|
|
22
24
|
|
|
@@ -35,8 +37,10 @@ export interface IH5Config {
|
|
|
35
37
|
*/
|
|
36
38
|
webpackChain?: (chain: Chain, webpack: typeof Webpack) => void
|
|
37
39
|
|
|
38
|
-
/**
|
|
39
|
-
output
|
|
40
|
+
/** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
|
|
41
|
+
* vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
|
|
42
|
+
*/
|
|
43
|
+
output?: T extends 'vite' ? Pick<RollupOutputOptions, 'chunkFileNames' | 'assetFileNames' > : Webpack.Configuration['output']
|
|
40
44
|
|
|
41
45
|
/** 路由相关的配置 */
|
|
42
46
|
router?: IH5RouterConfig
|
|
@@ -44,6 +48,9 @@ export interface IH5Config {
|
|
|
44
48
|
/** 预览服务的配置,可以更改端口等参数。具体配置参考 [webpack-dev-server](https://webpack.js.org/configuration/dev-server) */
|
|
45
49
|
devServer?: webpackDevServer.Configuration
|
|
46
50
|
|
|
51
|
+
/** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
|
|
52
|
+
enableSourceMap?: boolean
|
|
53
|
+
|
|
47
54
|
/** 具体配置请参考 [Webpack devtool](https://webpack.js.org/configuration/devtool/#devtool) 配置 (默认值:'cheap-module-eval-source-map')*/
|
|
48
55
|
sourceMapType?:
|
|
49
56
|
| 'none'
|
|
@@ -79,13 +86,13 @@ export interface IH5Config {
|
|
|
79
86
|
stylusLoaderOption?: IOption
|
|
80
87
|
|
|
81
88
|
/** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
82
|
-
mediaUrlLoaderOption?:
|
|
89
|
+
mediaUrlLoaderOption?: IUrlLoaderOption
|
|
83
90
|
|
|
84
91
|
/** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
85
|
-
fontUrlLoaderOption?:
|
|
92
|
+
fontUrlLoaderOption?: IUrlLoaderOption
|
|
86
93
|
|
|
87
94
|
/** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
88
|
-
imageUrlLoaderOption?:
|
|
95
|
+
imageUrlLoaderOption?: IUrlLoaderOption
|
|
89
96
|
|
|
90
97
|
/** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
|
|
91
98
|
miniCssExtractPluginOption?: IOption
|
|
@@ -100,14 +107,20 @@ export interface IH5Config {
|
|
|
100
107
|
useDeprecatedAdapterComponent?: boolean
|
|
101
108
|
|
|
102
109
|
/** 配置 postcss 相关插件 */
|
|
103
|
-
postcss?: IPostcssOption
|
|
110
|
+
postcss?: IPostcssOption<'h5'>
|
|
104
111
|
|
|
105
112
|
/** html-webpack-plugin 的具体配置 */
|
|
106
113
|
htmlPluginOption?: HtmlWebpackPlugin.Options
|
|
107
114
|
|
|
108
115
|
/** Web 编译过程的相关配置 */
|
|
109
116
|
compile?: {
|
|
110
|
-
exclude?:
|
|
111
|
-
include?:
|
|
117
|
+
exclude?: (string | RegExp)[]
|
|
118
|
+
include?: (string | RegExp)[]
|
|
119
|
+
filter?: (filename: string) => boolean
|
|
112
120
|
}
|
|
121
|
+
/** 生成的代码是否要兼容旧版浏览器,值为 true 时,会去读取 package.json 的 browserslist 字段。只在 vite 编译模式下有效 */
|
|
122
|
+
legacy?: T extends 'vite' ? boolean : undefined
|
|
123
|
+
|
|
124
|
+
/** 使用的编译工具。可选值:webpack4、webpack5、vite */
|
|
125
|
+
compiler?: Compiler<T>
|
|
113
126
|
}
|