@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.
- package/README.md +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import Taro from './index'
|
|
2
|
+
|
|
3
|
+
type TaroGetDerivedStateFromProps<P, S> =
|
|
4
|
+
/**
|
|
5
|
+
* Returns an update to a component's state based on its new props and old state.
|
|
6
|
+
*
|
|
7
|
+
* Note: its presence prevents any of the deprecated lifecycle methods from being invoked
|
|
8
|
+
*/
|
|
9
|
+
(nextProps: Readonly<P>, prevState: S) => Partial<S> | null
|
|
10
|
+
|
|
11
|
+
interface TaroStaticLifecycle<P, S> {
|
|
12
|
+
getDerivedStateFromProps?: TaroGetDerivedStateFromProps<P, S>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface TaroNewLifecycle<P, S, SS> {
|
|
16
|
+
/**
|
|
17
|
+
* Runs before React applies the result of `render` to the document, and
|
|
18
|
+
* returns an object to be given to componentDidUpdate. Useful for saving
|
|
19
|
+
* things such as scroll position before `render` causes changes to it.
|
|
20
|
+
*
|
|
21
|
+
* Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated
|
|
22
|
+
* lifecycle events from running.
|
|
23
|
+
*/
|
|
24
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>): SS | null
|
|
25
|
+
/**
|
|
26
|
+
* Called immediately after updating occurs. Not called for the initial render.
|
|
27
|
+
*
|
|
28
|
+
* The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
|
|
29
|
+
*/
|
|
30
|
+
componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot?: SS): void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare module './index' {
|
|
34
|
+
interface PageNotFoundObject {
|
|
35
|
+
/**
|
|
36
|
+
* 不存在页面的路径
|
|
37
|
+
*/
|
|
38
|
+
path: string
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 打开不存在页面的 query
|
|
42
|
+
*/
|
|
43
|
+
query: Record<string, unknown>
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面)
|
|
47
|
+
*/
|
|
48
|
+
isEntryPage: boolean
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface PageScrollObject {
|
|
52
|
+
/**
|
|
53
|
+
* 页面在垂直方向已滚动的距离(单位px)
|
|
54
|
+
*/
|
|
55
|
+
scrollTop: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface PageResizeObject {
|
|
59
|
+
deviceOrientation?: 'portrait' | 'landscape'
|
|
60
|
+
size: {
|
|
61
|
+
windowWidth: number
|
|
62
|
+
windowHeight: number
|
|
63
|
+
screenWidth?: number
|
|
64
|
+
screenHeight?: number
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface ShareAppMessageObject {
|
|
69
|
+
/**
|
|
70
|
+
* 转发事件来源
|
|
71
|
+
* `button`:页面内转发按钮
|
|
72
|
+
* `menu`:右上角转发菜单
|
|
73
|
+
*/
|
|
74
|
+
from?: 'button' | 'menu' | string
|
|
75
|
+
/**
|
|
76
|
+
* 如果 `from` 值是 `button`,则 `target` 是触发这次转发事件的 `button`,否则为 `undefined`
|
|
77
|
+
*/
|
|
78
|
+
target?: object
|
|
79
|
+
/**
|
|
80
|
+
* 页面中包含 `<web-view>` 组件时,返回当前 `<web-view>` 的 url
|
|
81
|
+
*/
|
|
82
|
+
webViewUrl?: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface ShareAppMessageReturnObject {
|
|
86
|
+
/**
|
|
87
|
+
* 转发标题,默认为当前小程序名称
|
|
88
|
+
*/
|
|
89
|
+
title?: string
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 转发路径,必须是以 / 开头的完整路径,默认为当前页面 path
|
|
93
|
+
*/
|
|
94
|
+
path?: string
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径
|
|
98
|
+
* 支持PNG及JPG
|
|
99
|
+
* 显示图片长宽比是 5:4
|
|
100
|
+
* 默认使用截图
|
|
101
|
+
*/
|
|
102
|
+
imageUrl?: string
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface WeappShareAppMessageReturnObject extends ShareAppMessageReturnObject {
|
|
106
|
+
/**
|
|
107
|
+
* 如果该参数存在,则以 resolve 结果为准,如果三秒内不 resolve,分享会使用上面传入的默认参数
|
|
108
|
+
* @supported weapp
|
|
109
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#onShareAppMessage-Object-object
|
|
110
|
+
* @example
|
|
111
|
+
* ```tsx
|
|
112
|
+
* import { ShareAppMessageReturnObject, useShareAppMessage } from "@spcsn/taro";
|
|
113
|
+
* // ... else code
|
|
114
|
+
* useShareAppMessage(() => {
|
|
115
|
+
* const p = new Promise<ShareAppMessageReturnObject>(resolve => {
|
|
116
|
+
* setTimeout(() => {
|
|
117
|
+
* resolve({
|
|
118
|
+
* title: "",
|
|
119
|
+
* imageUrl: "",
|
|
120
|
+
* path: ""
|
|
121
|
+
* })
|
|
122
|
+
* }, 2000)
|
|
123
|
+
* })
|
|
124
|
+
* return {
|
|
125
|
+
* title: "",
|
|
126
|
+
* imageUrl: "",
|
|
127
|
+
* path: "",
|
|
128
|
+
* promise: p
|
|
129
|
+
* }
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
promise: Promise<ShareAppMessageReturnObject>
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type ShareAppMessageReturn = ShareAppMessageReturnObject | Promise<ShareAppMessageReturnObject> | WeappShareAppMessageReturnObject
|
|
138
|
+
|
|
139
|
+
interface TabItemTapObject {
|
|
140
|
+
/**
|
|
141
|
+
* 被点击tabItem的序号,从 0 开始
|
|
142
|
+
*/
|
|
143
|
+
index: string
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 被点击tabItem的页面路径
|
|
147
|
+
*/
|
|
148
|
+
pagePath: string
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 被点击tabItem的按钮文字
|
|
152
|
+
*/
|
|
153
|
+
text: string
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
interface AddToFavoritesObject {
|
|
157
|
+
/**
|
|
158
|
+
* 页面中包含web-view组件时,返回当前web-view的url
|
|
159
|
+
*/
|
|
160
|
+
webviewUrl: string
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
interface AddToFavoritesReturnObject {
|
|
164
|
+
/**
|
|
165
|
+
* 自定义标题
|
|
166
|
+
*/
|
|
167
|
+
title?: string
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 自定义图片,显示图片长宽比为 1:1
|
|
171
|
+
*/
|
|
172
|
+
imageUrl?: string
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 自定义query字段
|
|
176
|
+
*/
|
|
177
|
+
query?: string
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
interface ShareTimelineReturnObject {
|
|
181
|
+
/**
|
|
182
|
+
* 自定义标题
|
|
183
|
+
*/
|
|
184
|
+
title?: string
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 自定义页面路径中携带的参数
|
|
188
|
+
*/
|
|
189
|
+
query?: string
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 自定义图片路径,可以是本地文件或者网络图片。支持 PNG 及 JPG,显示图片长宽比是 1:1
|
|
193
|
+
*/
|
|
194
|
+
imageUrl?: string
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
interface ComponentLifecycle<P, S, SS = any> extends TaroNewLifecycle<P, S, SS> {
|
|
198
|
+
componentWillMount?(): void
|
|
199
|
+
componentDidMount?(): void
|
|
200
|
+
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void
|
|
201
|
+
shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): boolean
|
|
202
|
+
componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void
|
|
203
|
+
componentWillUnmount?(): void
|
|
204
|
+
componentDidCatch?(err: string): void
|
|
205
|
+
componentDidShow?(): void
|
|
206
|
+
componentDidHide?(): void
|
|
207
|
+
componentDidNotFound?(opt: PageNotFoundObject): void
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface TaroStatic {
|
|
211
|
+
PageNotFoundObject: PageNotFoundObject
|
|
212
|
+
PageScrollObject: PageScrollObject
|
|
213
|
+
ShareAppMessageObject: ShareAppMessageObject
|
|
214
|
+
ShareAppMessageReturn: ShareAppMessageReturn
|
|
215
|
+
TabItemTapObject: TabItemTapObject
|
|
216
|
+
AddToFavoritesObject: AddToFavoritesObject
|
|
217
|
+
AddToFavoritesReturnObject: AddToFavoritesReturnObject
|
|
218
|
+
ShareTimelineReturnObject: ShareTimelineReturnObject
|
|
219
|
+
}
|
|
220
|
+
}
|