@tarojs/taro 3.7.0-beta.3 → 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 +5 -5
- package/types/api/data-analysis/index.d.ts +51 -1
- package/types/api/device/battery.d.ts +1 -1
- package/types/api/device/clipboard.d.ts +17 -17
- package/types/api/device/screen.d.ts +1 -1
- 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 +1 -4
- package/types/api/navigate/index.d.ts +2 -0
- package/types/api/storage/background-fetch.d.ts +63 -11
- package/types/api/storage/cache-manager.d.ts +51 -0
- package/types/api/storage/index.d.ts +125 -10
- package/types/api/wxml/index.d.ts +2 -2
- package/types/compile/config/h5.d.ts +4 -1
- package/types/compile/config/mini.d.ts +11 -8
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/util.d.ts +2 -0
- package/types/compile/viteCompilerContext.d.ts +4 -4
- package/types/taro.config.d.ts +6 -0
|
@@ -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
|
}
|
|
@@ -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
|
*/
|
|
@@ -4,7 +4,7 @@ import type webpackDevServer from 'webpack-dev-server'
|
|
|
4
4
|
import type HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
5
5
|
import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
6
6
|
import type { OutputOptions as RollupOutputOptions } from 'rollup'
|
|
7
|
-
import type { CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
7
|
+
import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
8
8
|
|
|
9
9
|
export interface IH5RouterConfig {
|
|
10
10
|
/** 配置路由模式 */
|
|
@@ -120,4 +120,7 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
|
|
|
120
120
|
}
|
|
121
121
|
/** 生成的代码是否要兼容旧版浏览器,值为 true 时,会去读取 package.json 的 browserslist 字段。只在 vite 编译模式下有效 */
|
|
122
122
|
legacy?: T extends 'vite' ? boolean : undefined
|
|
123
|
+
|
|
124
|
+
/** 使用的编译工具。可选值:webpack4、webpack5、vite */
|
|
125
|
+
compiler?: Compiler<T>
|
|
123
126
|
}
|
|
@@ -2,16 +2,16 @@ import type Webpack from 'webpack'
|
|
|
2
2
|
import type Chain from 'webpack-chain'
|
|
3
3
|
import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
4
4
|
import type { OutputOptions as RollupOutputOptions } from 'rollup'
|
|
5
|
-
import type { CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
5
|
+
import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
6
6
|
|
|
7
7
|
interface Runtime {
|
|
8
|
-
enableInnerHTML
|
|
9
|
-
enableSizeAPIs
|
|
10
|
-
enableAdjacentHTML
|
|
11
|
-
enableTemplateContent
|
|
12
|
-
enableCloneNode
|
|
13
|
-
enableContains
|
|
14
|
-
enableMutationObserver
|
|
8
|
+
enableInnerHTML?: boolean
|
|
9
|
+
enableSizeAPIs?: boolean
|
|
10
|
+
enableAdjacentHTML?: boolean
|
|
11
|
+
enableTemplateContent?: boolean
|
|
12
|
+
enableCloneNode?: boolean
|
|
13
|
+
enableContains?: boolean
|
|
14
|
+
enableMutationObserver?: boolean
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
interface OutputExt {
|
|
@@ -112,6 +112,9 @@ export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes>
|
|
|
112
112
|
|
|
113
113
|
/** 插件内部使用 */
|
|
114
114
|
runtime?: Runtime
|
|
115
|
+
|
|
116
|
+
/** 使用的编译工具。可选值:webpack4、webpack5、vite */
|
|
117
|
+
compiler?: Compiler<T>
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
export interface IMiniFilesConfig {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CustomPluginOptions, ResolvedId, ResolveIdResult } from 'rollup'
|
|
2
|
+
|
|
3
|
+
interface IRollupPluginResolveIdOptions {
|
|
4
|
+
assertions?: Record<string, string>
|
|
5
|
+
custom?: CustomPluginOptions
|
|
6
|
+
isEntry?: boolean
|
|
7
|
+
skipSelf?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type TRollupResolveMethod = (
|
|
11
|
+
source: string,
|
|
12
|
+
importer?: string,
|
|
13
|
+
options?: IRollupPluginResolveIdOptions
|
|
14
|
+
) => Promise<ResolvedId | null>
|
|
15
|
+
|
|
16
|
+
export interface ILoaderMeta {
|
|
17
|
+
importFrameworkStatement: string
|
|
18
|
+
importFrameworkName: string
|
|
19
|
+
creator: string
|
|
20
|
+
creatorLocation: string
|
|
21
|
+
extraImportForWeb: string
|
|
22
|
+
execBeforeCreateWebApp: string
|
|
23
|
+
frameworkArgs: string
|
|
24
|
+
isNeedRawLoader?: boolean
|
|
25
|
+
mockAppStatement: string
|
|
26
|
+
modifyConfig?: (config: Record<string, any>, source: string) => void
|
|
27
|
+
modifyResolveId?: (res: {
|
|
28
|
+
source?: string
|
|
29
|
+
importer?: string
|
|
30
|
+
options?: IRollupPluginResolveIdOptions
|
|
31
|
+
name?: string
|
|
32
|
+
resolve: TRollupResolveMethod
|
|
33
|
+
}) => Promise<ResolveIdResult> | ResolveIdResult
|
|
34
|
+
}
|
|
@@ -94,6 +94,8 @@ export type IPostcssOption<T = 'h5' | 'mini'> = T extends 'h5'
|
|
|
94
94
|
? IBasePostcssOption & { url?: PostcssOption.url }
|
|
95
95
|
: IBasePostcssOption
|
|
96
96
|
|
|
97
|
+
export type Config = ViteConfig | WebpackConfig
|
|
98
|
+
|
|
97
99
|
export interface ICopyOptions {
|
|
98
100
|
patterns: {
|
|
99
101
|
from: string
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import type { RecursiveTemplate, UnRecursiveTemplate } from '@tarojs/shared/dist/template'
|
|
2
|
+
import type { PluginContext } from 'rollup'
|
|
1
3
|
import type { AppConfig, PageConfig } from '../index'
|
|
2
4
|
import type { IMiniFilesConfig, IH5Config, IMiniAppConfig } from './config'
|
|
3
5
|
import type { IProjectConfig } from './config/project'
|
|
4
|
-
import type {
|
|
5
|
-
import { IComponentConfig } from "./hooks"
|
|
6
|
-
|
|
7
|
-
import type { RecursiveTemplate, UnRecursiveTemplate } from '@tarojs/shared/dist/template'
|
|
6
|
+
import type { IComponentConfig } from './hooks'
|
|
8
7
|
|
|
9
8
|
export interface ViteNativeCompMeta {
|
|
10
9
|
name: string
|
|
@@ -91,6 +90,7 @@ export interface ViteCompilerContext<T> {
|
|
|
91
90
|
frameworkExts: string[]
|
|
92
91
|
app: ViteAppMeta
|
|
93
92
|
pages: VitePageMeta[]
|
|
93
|
+
components?: VitePageMeta[]
|
|
94
94
|
loaderMeta: any
|
|
95
95
|
logger
|
|
96
96
|
filesConfig: IMiniFilesConfig
|
package/types/taro.config.d.ts
CHANGED
|
@@ -175,6 +175,12 @@ declare module './index' {
|
|
|
175
175
|
* @default false
|
|
176
176
|
*/
|
|
177
177
|
enableShareTimeline?: boolean
|
|
178
|
+
/**
|
|
179
|
+
* 页面是否需要使用 \<page-meta\> 和 \<navigation-bar\> 组件
|
|
180
|
+
* @default false
|
|
181
|
+
* @support weapp, alipay
|
|
182
|
+
*/
|
|
183
|
+
enablePageMeta?: boolean
|
|
178
184
|
/** 页面自定义组件配置
|
|
179
185
|
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/
|
|
180
186
|
*/
|