@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,258 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ /** EntryList 对象
5
+ * @supported weapp
6
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.html
7
+ */
8
+ interface EntryList {
9
+ /** 该方法返回当前列表中的所有性能数据
10
+ * @supported weapp
11
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntries.html
12
+ */
13
+ getEntries(): PerformanceEntry[]
14
+ /** 获取当前列表中所有名称为 [name] 且类型为 [entryType] 的性能数据
15
+ * @supported weapp
16
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntriesByName.html
17
+ */
18
+ getEntriesByName(name: string, entryType: string): PerformanceEntry[]
19
+ /** 获取当前列表中所有类型为 [entryType] 的性能数据
20
+ * @supported weapp
21
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntriesByType.html
22
+ */
23
+ getEntriesByType(entryType: string): PerformanceEntry[]
24
+ }
25
+
26
+ /** Performance 对象,用于获取性能数据及创建性能监听器
27
+ * @supported weapp, tt
28
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.html
29
+ */
30
+ interface Performance {
31
+ /** 创建全局性能事件监听器
32
+ * @supported weapp
33
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.createObserver.html
34
+ */
35
+ createObserver(callback: TaroGeneral.TFunc): PerformanceObserver
36
+ /** 该方法返回当前缓冲区中的所有性能数据
37
+ * @supported weapp, tt
38
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntries.html
39
+ */
40
+ getEntries(): PerformanceEntry[]
41
+ /** 获取当前缓冲区中所有名称为 [name] 且类型为 [entryType] 的性能数据
42
+ * @supported weapp, tt
43
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntriesByName.html
44
+ */
45
+ getEntriesByName(name: string, entryType: string): PerformanceEntry[]
46
+ /** 获取当前缓冲区中所有类型为 [entryType] 的性能数据
47
+ * @supported weapp, tt
48
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntriesByType.html
49
+ */
50
+ getEntriesByType(entryType: string): PerformanceEntry[]
51
+ /** 设置缓冲区大小,默认缓冲 30 条性能数据
52
+ * @supported weapp
53
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.setBufferSize.html
54
+ */
55
+ setBufferSize(size: number): void
56
+ }
57
+
58
+ /** 单条性能数据
59
+ * @supported weapp
60
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceEntry.html
61
+ */
62
+ interface PerformanceEntry {
63
+ /** 指标类型 */
64
+ entryType: keyof PerformanceEntry.EntryType
65
+ /** 指标名称 */
66
+ name: keyof PerformanceEntry.EntryName
67
+ /** 开始时间,不同指标的具体含义会有差异 */
68
+ startTime: number
69
+ /** 耗时 ms。仅对于表示阶段的指标有效。 */
70
+ duration: number
71
+ /** 页面路径。仅 render 和 navigation 类型指标有效。 */
72
+ path: string
73
+ /** 路由真正响应开始时间。仅 navigation 类型指标有效。 */
74
+ navigationStart: number
75
+ /** 路由详细类型,与小程序路由方法对应。仅 navigation 类型指标有效。 */
76
+ navigationType: string
77
+ /** 分包名,主包表示为 APP。仅 evaluateScript 指标有效。 */
78
+ moduleName: string
79
+ /** 注入文件列表。仅 evaluateScript 指标有效。 */
80
+ fileList: string[]
81
+ /** 渲染层代码注入完成时间。仅 firstRender 指标有效。 */
82
+ viewLayerReadyTime: number
83
+ /** 首次渲染参数从逻辑层发出的时间。仅 firstRender 指标有效。 */
84
+ initDataSendTime: number
85
+ /** 首次渲染参数在渲染层收到的时间。仅 firstRender 指标有效。 */
86
+ initDataRecvTime: number
87
+ /** 渲染层执行渲染开始时间。仅 firstRender 指标有效。 */
88
+ viewLayerRenderStartTime: number
89
+ /** 渲染层执行渲染结束时间。仅 firstRender 指标有效。 */
90
+ viewLayerRenderEndTime: number
91
+ }
92
+
93
+ /** PerformanceObserver 对象,用于监听性能相关事件
94
+ * @supported weapp
95
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.html
96
+ */
97
+ interface PerformanceObserver {
98
+ /** 获取当前支持的所有性能指标类型 */
99
+ supportedEntryTypes: PerformanceEntry[]
100
+ /** 停止监听
101
+ * @supported weapp
102
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.disconnect.html
103
+ */
104
+ disconnect(): void
105
+ /** 开始监听
106
+ * @supported weapp
107
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.observe.html
108
+ */
109
+ observe(option: PerformanceObserver.observe.Option): void
110
+ }
111
+
112
+ namespace PerformanceEntry {
113
+ /** entryType 的合法值 */
114
+ interface EntryType {
115
+ /** 路由 */
116
+ navigation
117
+ /** 渲染 */
118
+ render
119
+ /** 脚本 */
120
+ script
121
+ }
122
+ /** name 的合法值 */
123
+ interface EntryName {
124
+ /** 小程序启动耗时。起点为用户点击小程序图标,或小程序被拉起的时间;终点为首页 onReady。(entryType: navigation) */
125
+ appLaunch
126
+ /** 路由处理耗时。(entryType: navigation) */
127
+ route
128
+ /** 页面首次渲染耗时。起点为逻辑层收到路由事件,包括逻辑层页面与组件初始化、VD 同步、渲染层执行渲染的时间;终点为首页 onReady。(entryType: render) */
129
+ firstRender
130
+ /** [页面首次绘制](https://developer.mozilla.org/en-US/docs/Glossary/First_paint)。第一个像素渲染到屏幕上所用的时间。(entryType: render) */
131
+ firstPaint
132
+ /** [页面首次内容绘制](https://developer.mozilla.org/en-US/docs/Glossary/First_contentful_paint)。第一块内容渲染到屏幕上所用的时间。(entryType: render) */
133
+ firstContentfulPaint
134
+ /** 逻辑层 JS 代码注入耗时。(entryType: script) */
135
+ evaluateScript
136
+ }
137
+ }
138
+
139
+ namespace PerformanceObserver {
140
+ namespace observe {
141
+ interface Option {
142
+ /** 指标类型。不能和 entryTypes 同时使用 */
143
+ type: keyof EntryType
144
+ /** 指标类型列表。不能和 type 同时使用。 */
145
+ entryTypes: (keyof EntryType)[]
146
+ }
147
+ interface EntryType {
148
+ /** 路由 */
149
+ navigation
150
+ /** 渲染 */
151
+ render
152
+ /** 脚本 */
153
+ script
154
+ }
155
+ }
156
+ }
157
+
158
+ namespace preloadWebview {
159
+ interface Option {
160
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
161
+ complete?: (res: TaroGeneral.CallbackResult) => void
162
+ /** 接口调用失败的回调函数 */
163
+ fail?: (res: TaroGeneral.CallbackResult) => void
164
+ /** 接口调用成功的回调函数 */
165
+ success?: (res: TaroGeneral.CallbackResult) => void
166
+ }
167
+ }
168
+
169
+ namespace preloadSkylineView {
170
+ interface Option {
171
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
172
+ complete?: (res: TaroGeneral.CallbackResult) => void
173
+ /** 接口调用失败的回调函数 */
174
+ fail?: (res: TaroGeneral.CallbackResult) => void
175
+ /** 接口调用成功的回调函数 */
176
+ success?: (res: TaroGeneral.CallbackResult) => void
177
+ }
178
+ }
179
+
180
+ namespace preloadAssets {
181
+ interface AssetsObjectType {
182
+ /** 字体 */
183
+ font
184
+ /** 图片 */
185
+ image
186
+ }
187
+ interface AssetsObject {
188
+ /** 类型 */
189
+ type: keyof AssetsObjectType
190
+ /** 资源地址 */
191
+ src: string
192
+ }
193
+ interface Option {
194
+ data: AssetsObject[]
195
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
196
+ complete?: (res: TaroGeneral.CallbackResult) => void
197
+ /** 接口调用失败的回调函数 */
198
+ fail?: (res: TaroGeneral.CallbackResult) => void
199
+ /** 接口调用成功的回调函数 */
200
+ success?: (res: TaroGeneral.CallbackResult) => void
201
+ }
202
+ }
203
+
204
+ interface TaroStatic {
205
+ /** 小程序测速上报。使用前,需要在小程序管理后台配置。 详情参见[小程序测速](https://developers.weixin.qq.com/miniprogram/dev/framework/performanceReport/index.html)指南。
206
+ * @supported weapp
207
+ * @example
208
+ * ```tsx
209
+ * Taro.reportPerformance(1101, 680)
210
+ * Taro.reportPerformance(1101, 680, 'custom')
211
+ * ```
212
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.reportPerformance.html
213
+ */
214
+ reportPerformance(
215
+ /** 指标 id */
216
+ id: number,
217
+ /** 需要上报的数值 */
218
+ value: number,
219
+ /** 自定义维度 */
220
+ dimensions?: string | string[],
221
+ ): void
222
+
223
+ /** 预加载下个页面的 WebView
224
+ * @supported weapp
225
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadWebview.html
226
+ */
227
+ preloadWebview(option: preloadWebview.Option): Promise<TaroGeneral.CallbackResult>
228
+
229
+ /**预加载下个页面所需要的 Skyline 运行环境
230
+ * @supported weapp
231
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadSkylineView.html
232
+ */
233
+ preloadSkylineView(option: preloadSkylineView.Option): Promise<TaroGeneral.CallbackResult>
234
+
235
+ /** 为视图层预加载媒体资源文件, 目前支持:font,image
236
+ * @supported weapp
237
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadAssets.html
238
+ */
239
+ preloadAssets(option: preloadAssets.Option): Promise<TaroGeneral.CallbackResult>
240
+ /** 小程序测速上报。使用前,需要在小程序管理后台配置。 详情参见[小程序测速](https://developers.weixin.qq.com/miniprogram/dev/framework/performanceReport/index.html)指南。
241
+ *
242
+ * **注意**
243
+ * - 目前,当开启代码 [按需注入](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/lazyload.html) `时,evaluateScript` 将仅包含公有部分代码,页面和组件的代码注入的时间会包含在 `firstRender` 中(因为页面和组件的代码注入过程成为了首次渲染过程的一部分)。因此开启按需注入后,脚本耗时降低,渲染时间提高属于正常现象,优化效果可以关注整体启动耗时(`appLaunch`)来评估。
244
+ * - `firstPaint` 和 `firstContentfulPaint` 指标在开启 `vconsole` 的情况下,由于绘制 `vconsoel` 的面板,会导致数据提前。
245
+ * @supported weapp, tt
246
+ * @example
247
+ * ```tsx
248
+ * const performance = Taro.getPerformance()
249
+ * const observer = performance.createObserver((entryList) => {
250
+ * console.log(entryList.getEntries())
251
+ * })
252
+ * observer.observe({ entryTypes: ['render', 'script', 'navigation'] })
253
+ * ```
254
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.getPerformance.html
255
+ */
256
+ getPerformance(): Performance
257
+ }
258
+ }