@spcsn/taro 0.1.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.
Files changed (140) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +147 -0
  3. package/dist/index.js.map +1 -0
  4. package/index.js +9 -0
  5. package/package.json +86 -0
  6. package/types/api/ad/index.d.ts +197 -0
  7. package/types/api/ai/face.d.ts +133 -0
  8. package/types/api/ai/inference.d.ts +129 -0
  9. package/types/api/ai/visionkit.d.ts +874 -0
  10. package/types/api/alipay/index.d.ts +69 -0
  11. package/types/api/base/crypto.d.ts +104 -0
  12. package/types/api/base/debug.d.ts +329 -0
  13. package/types/api/base/env.d.ts +19 -0
  14. package/types/api/base/index.d.ts +102 -0
  15. package/types/api/base/performance.d.ts +258 -0
  16. package/types/api/base/system.d.ts +742 -0
  17. package/types/api/base/update.d.ts +130 -0
  18. package/types/api/base/weapp/app-event.d.ts +265 -0
  19. package/types/api/base/weapp/life-cycle.d.ts +155 -0
  20. package/types/api/canvas/index.d.ts +2162 -0
  21. package/types/api/cloud/index.d.ts +2622 -0
  22. package/types/api/data-analysis/index.d.ts +122 -0
  23. package/types/api/device/accelerometer.d.ts +102 -0
  24. package/types/api/device/accessibility.d.ts +26 -0
  25. package/types/api/device/battery.d.ts +46 -0
  26. package/types/api/device/bluetooth-ble.d.ts +601 -0
  27. package/types/api/device/bluetooth-peripheral.d.ts +430 -0
  28. package/types/api/device/bluetooth.d.ts +463 -0
  29. package/types/api/device/calendar.d.ts +98 -0
  30. package/types/api/device/clipboard.d.ts +81 -0
  31. package/types/api/device/compass.d.ts +105 -0
  32. package/types/api/device/contact.d.ts +110 -0
  33. package/types/api/device/gyroscope.d.ts +85 -0
  34. package/types/api/device/iBeacon.d.ts +168 -0
  35. package/types/api/device/keyboard.d.ts +97 -0
  36. package/types/api/device/memory.d.ts +52 -0
  37. package/types/api/device/motion.d.ts +88 -0
  38. package/types/api/device/network.d.ts +172 -0
  39. package/types/api/device/nfc.d.ts +1238 -0
  40. package/types/api/device/phone.d.ts +30 -0
  41. package/types/api/device/scan.d.ts +111 -0
  42. package/types/api/device/screen.d.ts +217 -0
  43. package/types/api/device/sms.d.ts +26 -0
  44. package/types/api/device/vibrate.d.ts +51 -0
  45. package/types/api/device/wifi.d.ts +301 -0
  46. package/types/api/ext/index.d.ts +64 -0
  47. package/types/api/files/index.d.ts +1472 -0
  48. package/types/api/framework/index.d.ts +51 -0
  49. package/types/api/location/index.d.ts +517 -0
  50. package/types/api/media/audio.d.ts +1013 -0
  51. package/types/api/media/background-audio.d.ts +291 -0
  52. package/types/api/media/camera.d.ts +207 -0
  53. package/types/api/media/editor.d.ts +239 -0
  54. package/types/api/media/image.d.ts +469 -0
  55. package/types/api/media/live.d.ts +461 -0
  56. package/types/api/media/map.d.ts +638 -0
  57. package/types/api/media/media-recorder.d.ts +117 -0
  58. package/types/api/media/recorder.d.ts +317 -0
  59. package/types/api/media/video-decoder.d.ts +117 -0
  60. package/types/api/media/video-processing.d.ts +84 -0
  61. package/types/api/media/video.d.ts +527 -0
  62. package/types/api/media/voip.d.ts +393 -0
  63. package/types/api/navigate/index.d.ts +327 -0
  64. package/types/api/network/download.d.ts +173 -0
  65. package/types/api/network/mdns.d.ts +191 -0
  66. package/types/api/network/request.d.ts +480 -0
  67. package/types/api/network/tcp.d.ts +181 -0
  68. package/types/api/network/udp.d.ts +218 -0
  69. package/types/api/network/upload.d.ts +201 -0
  70. package/types/api/network/websocket.d.ts +383 -0
  71. package/types/api/open-api/account.d.ts +51 -0
  72. package/types/api/open-api/address.d.ts +68 -0
  73. package/types/api/open-api/authorize.d.ts +80 -0
  74. package/types/api/open-api/card.d.ts +110 -0
  75. package/types/api/open-api/channels.d.ts +225 -0
  76. package/types/api/open-api/customer-service.d.ts +45 -0
  77. package/types/api/open-api/device-voip.d.ts +103 -0
  78. package/types/api/open-api/facial.d.ts +98 -0
  79. package/types/api/open-api/favorites.d.ts +101 -0
  80. package/types/api/open-api/group.d.ts +59 -0
  81. package/types/api/open-api/invoice.d.ts +87 -0
  82. package/types/api/open-api/license-plate.d.ts +27 -0
  83. package/types/api/open-api/login.d.ts +115 -0
  84. package/types/api/open-api/my-miniprogram.d.ts +28 -0
  85. package/types/api/open-api/privacy.d.ts +107 -0
  86. package/types/api/open-api/redpackage.d.ts +24 -0
  87. package/types/api/open-api/settings.d.ts +174 -0
  88. package/types/api/open-api/soter.d.ts +184 -0
  89. package/types/api/open-api/sticker.d.ts +83 -0
  90. package/types/api/open-api/subscribe-message.d.ts +305 -0
  91. package/types/api/open-api/user-info.d.ts +182 -0
  92. package/types/api/open-api/werun.d.ts +101 -0
  93. package/types/api/payment/index.d.ts +119 -0
  94. package/types/api/qq/index.d.ts +354 -0
  95. package/types/api/route/index.d.ts +324 -0
  96. package/types/api/share/index.d.ts +354 -0
  97. package/types/api/skyline/index.d.ts +345 -0
  98. package/types/api/storage/background-fetch.d.ts +131 -0
  99. package/types/api/storage/cache-manager.d.ts +249 -0
  100. package/types/api/storage/index.d.ts +405 -0
  101. package/types/api/swan/bookshelf.d.ts +307 -0
  102. package/types/api/swan/download-package.d.ts +80 -0
  103. package/types/api/swan/index.d.ts +251 -0
  104. package/types/api/swan/pay.d.ts +139 -0
  105. package/types/api/taro.extend.d.ts +233 -0
  106. package/types/api/taro.hooks.d.ts +148 -0
  107. package/types/api/ui/animation.d.ts +427 -0
  108. package/types/api/ui/background.d.ts +69 -0
  109. package/types/api/ui/custom-component.d.ts +23 -0
  110. package/types/api/ui/fonts.d.ts +77 -0
  111. package/types/api/ui/interaction.d.ts +281 -0
  112. package/types/api/ui/menu.d.ts +29 -0
  113. package/types/api/ui/navigation-bar.d.ts +130 -0
  114. package/types/api/ui/pull-down-refresh.d.ts +50 -0
  115. package/types/api/ui/scroll.d.ts +114 -0
  116. package/types/api/ui/sticky.d.ts +32 -0
  117. package/types/api/ui/tab-bar.d.ts +196 -0
  118. package/types/api/ui/window.d.ts +71 -0
  119. package/types/api/worker/index.d.ts +83 -0
  120. package/types/api/wxml/index.d.ts +540 -0
  121. package/types/compile/compiler.d.ts +32 -0
  122. package/types/compile/config/h5.d.ts +134 -0
  123. package/types/compile/config/harmony.d.ts +118 -0
  124. package/types/compile/config/index.d.ts +8 -0
  125. package/types/compile/config/manifest.d.ts +155 -0
  126. package/types/compile/config/mini.d.ts +118 -0
  127. package/types/compile/config/plugin.d.ts +34 -0
  128. package/types/compile/config/project.d.ts +338 -0
  129. package/types/compile/config/rn.d.ts +85 -0
  130. package/types/compile/config/util.d.ts +179 -0
  131. package/types/compile/hooks.d.ts +13 -0
  132. package/types/compile/index.d.ts +11 -0
  133. package/types/compile/viteCompilerContext.d.ts +167 -0
  134. package/types/global.d.ts +428 -0
  135. package/types/index.d.ts +190 -0
  136. package/types/taro.api.d.ts +130 -0
  137. package/types/taro.component.d.ts +168 -0
  138. package/types/taro.config.d.ts +712 -0
  139. package/types/taro.lifecycle.d.ts +220 -0
  140. package/types/taro.runtime.d.ts +9 -0
@@ -0,0 +1,345 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ /**
5
+ * Snapshot 实例,可通过 SelectorQuery 获取。
6
+ *
7
+ * Snapshot 通过 id 跟一个 snapshot 组件绑定,操作对应的 snapshot 组件。
8
+ * @supported weapp
9
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/skyline/Snapshot.html
10
+ */
11
+ interface Snapshot {
12
+ /**
13
+ * 画布宽度
14
+ */
15
+ width: number
16
+ /**
17
+ * 画布高度
18
+ */
19
+ height: number
20
+ /**
21
+ * 对 snapshot 组件子树进行截图
22
+ * @param option
23
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/skyline/Snapshot.takeSnapshot.html
24
+ */
25
+ takeSnapshot(option: Snapshot.TakeSnapshot.Option): Promise<TaroGeneral.CallbackResult>
26
+ }
27
+
28
+ namespace Snapshot {
29
+ namespace TakeSnapshot {
30
+ interface Option {
31
+ /**
32
+ * 截图导出类型,'file' 保存到临时文件目录或 'arraybuffer' 返回图片二进制数据,默认值为 'file'
33
+ */
34
+ type: string
35
+ /**
36
+ * 截图文件格式,'rgba' 或 'png',默认值为 'png'
37
+ */
38
+ format: string
39
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
40
+ complete?: (res: TaroGeneral.CallbackResult) => void
41
+ /** 接口调用失败的回调函数 */
42
+ fail?: (res: TaroGeneral.CallbackResult) => void
43
+ /** 接口调用成功的回调函数 */
44
+ success?: (res: SuccessCallbackResult) => void
45
+ }
46
+
47
+ interface SuccessCallbackResult {
48
+ /**
49
+ * 截图保存的临时文件路径,当 type 为 file 该字段生效
50
+ */
51
+ tempFilePath: string
52
+ /**
53
+ * 截图对应的二进制数据,当 type 为 arraybuffer 该字段生效
54
+ */
55
+ data: string
56
+ }
57
+ }
58
+ }
59
+
60
+ /**
61
+ * DraggableSheet 实例,可通过 Taro.createSelectorQuery 的 NodesRef.node 方法获取。
62
+ *
63
+ * @supported weapp
64
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/skyline/DraggableSheetContext.html
65
+ */
66
+ interface DraggableSheetContext {
67
+ /**
68
+ * 滚动到指定位置。size 取值 [0, 1],size = 1 时表示撑满 draggable-sheet 组件。size 和 pixels 同时传入时,仅 size 生效。
69
+ * @param option
70
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/skyline/DraggableSheetContext.scrollTo.html
71
+ */
72
+ scrollTo(option: DraggableSheetContext.scrollTo.Option): void
73
+ }
74
+
75
+ namespace DraggableSheetContext {
76
+ namespace scrollTo {
77
+ interface Option {
78
+ /** 相对目标位置 */
79
+ size?: number
80
+ /** 绝对目标位置 */
81
+ pixels?: number
82
+ /**
83
+ * 是否启用滚动动画
84
+ * @default true
85
+ */
86
+ animated?: boolean
87
+ /**
88
+ * 滚动动画时长(ms)
89
+ * @default 300
90
+ */
91
+ duration?: number
92
+ /**
93
+ * 缓动函数
94
+ * @default ease
95
+ */
96
+ easingFunction?: string
97
+ }
98
+ }
99
+ }
100
+
101
+ /**
102
+ * worklet 对象,可以通过 wx.worklet 获取
103
+ *
104
+ * @supported weapp
105
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/wx.worklet.html
106
+ */
107
+ interface worklet {
108
+ /**
109
+ * 取消由 SharedValue 驱动的动画
110
+ * @param SharedValue
111
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.cancelAnimation.html
112
+ */
113
+ cancelAnimation(SharedValue: worklet.SharedValue): void
114
+ /**
115
+ * 衍生值 DerivedValue,可基于已有的 SharedValue 生成其它共享变量。
116
+ * @param updaterWorklet
117
+ * @returns 返回 DerivedValue 类型值,可被 worklet 函数捕获。DerivedValue 也是 SharedValue 类型。
118
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.derived.html
119
+ */
120
+ derived(updaterWorklet: worklet.WorkletFunction): worklet.DerivedValue
121
+ /**
122
+ * ScrollView 实例,可在 worklet 函数内操作 scroll-view 组件。
123
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.scrollViewContext.html
124
+ */
125
+ scrollViewContext: {
126
+ /**
127
+ * 滚动至指定位置
128
+ * @param object
129
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.scrollViewContext.scrollTo.html
130
+ */
131
+ scrollTo(NodesRef: TaroGeneral.IAnyObject, object: worklet.scrollViewContext.Option): void
132
+ }
133
+ /**
134
+ * 创建共享变量 SharedValue,用于跨线程共享数据和驱动动画。
135
+ * @param initialValue
136
+ * @returns 返回 SharedValue 类型值,可被 worklet 函数捕获。
137
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.shared.html
138
+ */
139
+ shared(initialValue: number | string | bool | null | undefined | Object | Array | Function): worklet.SharedValue
140
+ /**
141
+ * 基于滚动衰减的动画。
142
+ * @param options 动画配置
143
+ * @param callback 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。
144
+ * @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
145
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.decay.html
146
+ */
147
+ decay(options?: worklet.decay.Option, callback?: (flag: boolean) => void): worklet.AnimationObject
148
+ Easing: worklet.Easing
149
+ /**
150
+ * 基于物理的动画。
151
+ * @param toValue 目标值
152
+ * @param options 动画配置
153
+ * @param callback 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。
154
+ * @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
155
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.spring.html
156
+ */
157
+ spring(toValue: number | string, options?: worklet.spring.Option, callback?: (flag: boolean) => void): worklet.AnimationObject
158
+ /**
159
+ * 基于时间的动画。
160
+ * @param toValue 目标值
161
+ * @param options 动画配置
162
+ * @param callback 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。
163
+ * @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
164
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.timing.html
165
+ */
166
+ timing(toValue: number | string, options?: worklet.timing.Option, callback?: (flag: boolean) => void): worklet.AnimationObject
167
+ /**
168
+ * 延迟执行动画。
169
+ * @param delayMS 动画开始前等待的时间,单位:毫秒
170
+ * @param delayedAnimation 动画对象
171
+ * @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
172
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.delay.html
173
+ */
174
+ delay(delayMS: number, delayedAnimation: worklet.AnimationObject): worklet.AnimationObject
175
+ /**
176
+ * 重复执行动画。
177
+ * @param animation 动画对象
178
+ * @param numberOfReps 重复次数。为负值时一直循环,直到被取消动画。
179
+ * @param reverse 反向运行动画,每周期结束动画由尾到头运行。该字段仅对 timing 和 spring 返回的动画对象生效。
180
+ * @param callback 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。
181
+ * @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
182
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.repeat.html
183
+ */
184
+ repeat(delayedAnimation: worklet.AnimationObject, numberOfReps: number, reverse?: boolean, callback?: (flag: boolean) => void): worklet.AnimationObject
185
+ /**
186
+ * 组合动画序列,依次执行传入的动画。
187
+ * @param animation 动画对象
188
+ * @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
189
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.sequence.html
190
+ */
191
+ sequence(...delayedAnimation: worklet.AnimationObject): worklet.AnimationObject
192
+ /**
193
+ * worklet 函数运行在 UI 线程时,捕获的外部函数可能为 worklet 类型或普通函数,为了更明显的对其区分,要求必须使用 runOnJS 调回 JS 线程的普通函数。 有这样的要求是因为,调用其它 worklet 函数时是同步调用,但在 UI 线程执行 JS 线程的函数只能是异步,开发者容易混淆,试图同步获取 JS 线程的返回值。
194
+ * @param fn worklet 类型函数
195
+ * @returns runOnJS 为高阶函数,返回一个函数,执行时运行在 JS 线程
196
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/tool-function/worklet.runOnJS.html
197
+ */
198
+ runOnJS(fn: TaroGeneral.TFunc): TaroGeneral.TFunc
199
+ /**
200
+ * 在 UI 线程执行 worklet 函数
201
+ * @param fn worklet 类型函数
202
+ * @returns runOnUI 为高阶函数,返回一个函数,执行时运行在 UI 线程
203
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/tool-function/worklet.runOnUI.html
204
+ */
205
+ runOnUI(fn: TaroGeneral.TFunc): TaroGeneral.TFunc
206
+ }
207
+
208
+ namespace worklet {
209
+ type SharedValue = TaroGeneral.IAnyObject
210
+ type DerivedValue = worklet.SharedValue
211
+ type AnimationObject = TaroGeneral.IAnyObject
212
+ type WorkletFunction = TaroGeneral.TFunc
213
+
214
+ namespace scrollViewContext {
215
+ interface Option {
216
+ /** 顶部距离 */
217
+ top?: number
218
+ /** 左边界距离 */
219
+ left?: number
220
+ /** 滚动动画时长 */
221
+ duration?: number
222
+ /** 是否启用滚动动画 */
223
+ animated?: boolean
224
+ /** 动画曲线 */
225
+ easingFunction?: string
226
+ }
227
+ }
228
+
229
+ namespace decay {
230
+ interface Option {
231
+ /** 初速度 */
232
+ velocity?: number
233
+ /** 衰减速率 */
234
+ deceleration?: number
235
+ /** 边界值,长度为 2 的数组 */
236
+ clamp?: Array<number>
237
+ }
238
+ }
239
+
240
+ interface Easing {
241
+ /**
242
+ * 简单的反弹效果
243
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
244
+ */
245
+ bounce(t: number): any;
246
+ /**
247
+ * 简单的惯性动画
248
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
249
+ */
250
+ ease(t: number): any;
251
+ /**
252
+ * 简单的弹性动画,类似弹簧来回摆动,高阶函数。默认弹性为 1,会稍微超出一次。弹性为 0 时 不会过冲
253
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
254
+ */
255
+ elastic(bounciness?: number): any;
256
+ /**
257
+ * 线性函数
258
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
259
+ */
260
+ linear(t: number): any;
261
+ /**
262
+ * 二次方函数
263
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
264
+ */
265
+ quad(t: number): any;
266
+ /**
267
+ * 立方函数
268
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
269
+ */
270
+ cubic(t: number): any;
271
+ /**
272
+ * 高阶函数,返回幂函数
273
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
274
+ */
275
+ poly(n: number): any;
276
+ /**
277
+ * 三次贝塞尔曲线,效果同 css transition-timing-function
278
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
279
+ */
280
+ bezier(x1: number, y1: number, x2: number, y2: number): any;
281
+ /**
282
+ * 圆形曲线
283
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
284
+ */
285
+ circle(t: number): any;
286
+ /**
287
+ * 正弦函数
288
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
289
+ */
290
+ sin(t: number): any;
291
+ /**
292
+ * 指数函数
293
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
294
+ */
295
+ exp(t: number): any;
296
+ /**
297
+ * 正向运行 easing function,高阶函数。
298
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
299
+ */
300
+ in(easing: (t: number) => any): any;
301
+ /**
302
+ * 反向运行 easing function,高阶函数。
303
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
304
+ */
305
+ out(easing: (t: number) => any): any;
306
+ /**
307
+ * 前半程正向,后半程反向,高阶函数。
308
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
309
+ */
310
+ inOut(easing: (t: number) => any): any;
311
+ }
312
+
313
+ namespace spring {
314
+ interface Option {
315
+ /** 阻尼系数 */
316
+ damping?: number
317
+ /** 重量系数,值越大移动越慢 */
318
+ mass?: number
319
+ /** 弹性系数 */
320
+ stiffness?: number
321
+ /** 动画是否可以在指定值上反弹 */
322
+ overshootClamping?: boolean
323
+ /** 弹簧静止时的位移 */
324
+ restDisplacementThreshold?: number
325
+ /** 弹簧静止的速度 */
326
+ restSpeedThreshold?: number
327
+ /** 速度 */
328
+ velocity?: number
329
+ }
330
+ }
331
+
332
+ namespace timing {
333
+ interface Option {
334
+ /** 动画时长 */
335
+ duration?: number
336
+ /** 动画曲线 */
337
+ easing?: (t: number) => number
338
+ }
339
+ }
340
+ }
341
+
342
+ interface TaroStatic {
343
+ worklet: worklet
344
+ }
345
+ }
@@ -0,0 +1,131 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ // 周期性更新
5
+
6
+ namespace setBackgroundFetchToken {
7
+ interface Option {
8
+ /** 自定义的登录态 */
9
+ token: string
10
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
11
+ complete?: (res: TaroGeneral.CallbackResult) => void
12
+ /** 接口调用失败的回调函数 */
13
+ fail?: (res: TaroGeneral.CallbackResult) => void
14
+ /** 接口调用成功的回调函数 */
15
+ success?: (res: TaroGeneral.CallbackResult) => void
16
+ }
17
+ }
18
+
19
+ namespace onBackgroundFetchData {
20
+ interface Option {
21
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
22
+ complete?: (res: TaroGeneral.CallbackResult) => void
23
+ /** 接口调用失败的回调函数 */
24
+ fail?: (res: TaroGeneral.CallbackResult) => void
25
+ /** 接口调用成功的回调函数 */
26
+ success?: (res: TaroGeneral.CallbackResult) => void
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
+ }
47
+ }
48
+
49
+ namespace getBackgroundFetchToken {
50
+ interface Option {
51
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
52
+ complete?: (res: TaroGeneral.CallbackResult) => void
53
+ /** 接口调用失败的回调函数 */
54
+ fail?: (res: TaroGeneral.CallbackResult) => void
55
+ /** 接口调用成功的回调函数 */
56
+ success?: (res: SuccessCallbackResult) => void
57
+ }
58
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
59
+ /** 自定义的登录态 */
60
+ token: string
61
+ /** 接口调用结果 */
62
+ errMsg: string
63
+ }
64
+ }
65
+
66
+ namespace getBackgroundFetchData {
67
+ interface Option {
68
+ /** 缓存数据类别
69
+ * @weapp 取值为 periodic
70
+ * @qq 取值为 periodic
71
+ * @alipay 取值为 pre: 数据预拉取; jsapiPre: API 预调用(目前仅支持地理位置预拉取)
72
+ */
73
+ fetchType: string
74
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
75
+ complete?: (res: TaroGeneral.CallbackResult) => void
76
+ /** 接口调用失败的回调函数 */
77
+ fail?: (res: TaroGeneral.CallbackResult) => void
78
+ /** 接口调用成功的回调函数 */
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
103
+ }
104
+ }
105
+
106
+ interface TaroStatic {
107
+ /** 设置自定义登录态,在周期性拉取数据时带上,便于第三方服务器验证请求合法性
108
+ * @supported weapp, qq
109
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.setBackgroundFetchToken.html
110
+ */
111
+ setBackgroundFetchToken(option: setBackgroundFetchToken.Option): Promise<TaroGeneral.CallbackResult>
112
+
113
+ /** 收到 backgroundFetch 数据时的回调
114
+ * @supported weapp, qq
115
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.onBackgroundFetchData.html
116
+ */
117
+ onBackgroundFetchData(option?: onBackgroundFetchData.Option | onBackgroundFetchData.Callback): void
118
+
119
+ /** 获取设置过的自定义登录态。若无,则返回 fail。
120
+ * @supported weapp, qq
121
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchToken.html
122
+ */
123
+ getBackgroundFetchToken(option?: getBackgroundFetchToken.Option): Promise<TaroGeneral.CallbackResult>
124
+
125
+ /** 拉取 backgroundFetch 客户端缓存数据
126
+ * @supported weapp, alipay, qq
127
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchData.html
128
+ */
129
+ getBackgroundFetchData(option: getBackgroundFetchData.Option): Promise<getBackgroundFetchData.SuccessCallbackResult>
130
+ }
131
+ }