@tarojs/taro-rn 3.4.2 → 3.4.5
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/dist/lib/Mask.js +1 -1
- package/dist/lib/Mask.js.map +1 -1
- package/dist/lib/Popup.js +3 -2
- package/dist/lib/Popup.js.map +1 -1
- package/dist/lib/chooseVideo/index.js +1 -1
- package/dist/lib/chooseVideo/index.js.map +1 -1
- package/dist/lib/connectSocket/index.js +0 -1
- package/dist/lib/connectSocket/index.js.map +1 -1
- package/dist/lib/connectSocket/socketTask.js +2 -2
- package/dist/lib/connectSocket/socketTask.js.map +1 -1
- package/dist/lib/createInnerAudioContext/index.js +10 -10
- package/dist/lib/createInnerAudioContext/index.js.map +1 -1
- package/dist/lib/file.js +2 -1
- package/dist/lib/file.js.map +1 -1
- package/dist/lib/getLocation/index.js +1 -1
- package/dist/lib/getLocation/index.js.map +1 -1
- package/dist/lib/location.js +1 -1
- package/dist/lib/location.js.map +1 -1
- package/dist/lib/permission.js +1 -1
- package/dist/lib/permission.js.map +1 -1
- package/dist/lib/request/index.js +4 -4
- package/dist/lib/request/index.js.map +1 -1
- package/dist/lib/scanCode/index.js +1 -1
- package/dist/lib/scanCode/index.js.map +1 -1
- package/dist/lib/showModal/toast.js +9 -8
- package/dist/lib/showModal/toast.js.map +1 -1
- package/dist/setup.js +64 -0
- package/dist/setup.js.map +1 -0
- package/package.json +12 -14
- package/src/__tests__/__mock__/mockAsyncStorage.js +0 -1
- package/src/__tests__/__mock__/mockExpoPermissions.js +1 -1
- package/src/__tests__/__snapshots__/scanCode.test.js.snap +113 -0
- package/src/__tests__/interactive.test.js +40 -66
- package/src/__tests__/keyboard.test.js +6 -6
- package/src/__tests__/request.test.js +1 -1
- package/src/__tests__/scanCode.test.js +14 -0
- package/src/__tests__/storage.test.js +1 -1
- package/src/__tests__/system.test.js +8 -8
- package/src/lib/Mask.tsx +1 -0
- package/src/lib/Popup.tsx +2 -2
- package/src/lib/chooseVideo/index.ts +1 -1
- package/src/lib/connectSocket/index.ts +0 -1
- package/src/lib/connectSocket/socketTask.ts +2 -2
- package/src/lib/createInnerAudioContext/index.ts +10 -10
- package/src/lib/file.ts +2 -1
- package/src/lib/getLocation/index.ts +1 -1
- package/src/lib/location.ts +1 -1
- package/src/lib/permission.ts +1 -1
- package/src/lib/request/index.ts +4 -4
- package/src/lib/scanCode/index.tsx +1 -1
- package/src/lib/showModal/toast.tsx +10 -8
- package/src/setup.ts +71 -0
- package/src/types/definition.d.ts +2 -0
- package/src/__tests__/__snapshots__/interactive.test.js.snap +0 -1690
- package/src/__tests__/scanCode.test_.js +0 -24
|
@@ -224,7 +224,7 @@ class InnerAudioContext {
|
|
|
224
224
|
* @param callback
|
|
225
225
|
*/
|
|
226
226
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
227
|
-
offCanplay (
|
|
227
|
+
offCanplay (_callback) {
|
|
228
228
|
this.onCanplayCallback = undefined
|
|
229
229
|
}
|
|
230
230
|
|
|
@@ -241,7 +241,7 @@ class InnerAudioContext {
|
|
|
241
241
|
* @param callback
|
|
242
242
|
*/
|
|
243
243
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
244
|
-
offPlay (
|
|
244
|
+
offPlay (_callback) {
|
|
245
245
|
this.onPlayCallback = undefined
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -258,7 +258,7 @@ class InnerAudioContext {
|
|
|
258
258
|
* @param callback
|
|
259
259
|
*/
|
|
260
260
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
261
|
-
offPause (
|
|
261
|
+
offPause (_callback) {
|
|
262
262
|
this.onPauseCallback = undefined
|
|
263
263
|
}
|
|
264
264
|
|
|
@@ -275,7 +275,7 @@ class InnerAudioContext {
|
|
|
275
275
|
* @param callback
|
|
276
276
|
*/
|
|
277
277
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
278
|
-
offStop (
|
|
278
|
+
offStop (_callback) {
|
|
279
279
|
this.onStopCallback = undefined
|
|
280
280
|
}
|
|
281
281
|
|
|
@@ -292,7 +292,7 @@ class InnerAudioContext {
|
|
|
292
292
|
* @param callback
|
|
293
293
|
*/
|
|
294
294
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
295
|
-
offEnded (
|
|
295
|
+
offEnded (_callback) {
|
|
296
296
|
this.onEndedCallback = undefined
|
|
297
297
|
}
|
|
298
298
|
|
|
@@ -309,7 +309,7 @@ class InnerAudioContext {
|
|
|
309
309
|
* @param callback
|
|
310
310
|
*/
|
|
311
311
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
312
|
-
offTimeUpdate (
|
|
312
|
+
offTimeUpdate (_callback) {
|
|
313
313
|
this.onTimeUpdateCallback = undefined
|
|
314
314
|
}
|
|
315
315
|
|
|
@@ -326,7 +326,7 @@ class InnerAudioContext {
|
|
|
326
326
|
* @param callback
|
|
327
327
|
*/
|
|
328
328
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
329
|
-
offError (
|
|
329
|
+
offError (_callback) {
|
|
330
330
|
this.onErrorCallback = undefined
|
|
331
331
|
}
|
|
332
332
|
|
|
@@ -343,7 +343,7 @@ class InnerAudioContext {
|
|
|
343
343
|
* @param callback
|
|
344
344
|
*/
|
|
345
345
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
346
|
-
offWaiting (
|
|
346
|
+
offWaiting (_callback) {
|
|
347
347
|
this.onWaitingCallback = undefined
|
|
348
348
|
}
|
|
349
349
|
|
|
@@ -360,7 +360,7 @@ class InnerAudioContext {
|
|
|
360
360
|
* @param callback
|
|
361
361
|
*/
|
|
362
362
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
363
|
-
offSeeking (
|
|
363
|
+
offSeeking (_callback) {
|
|
364
364
|
this.onSeekingCallback = undefined
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -377,7 +377,7 @@ class InnerAudioContext {
|
|
|
377
377
|
* @param callback
|
|
378
378
|
*/
|
|
379
379
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
380
|
-
offSeeked (
|
|
380
|
+
offSeeked (_callback) {
|
|
381
381
|
this.onSeekedCallback = undefined
|
|
382
382
|
}
|
|
383
383
|
}
|
package/src/lib/file.ts
CHANGED
|
@@ -16,7 +16,7 @@ let timer: any
|
|
|
16
16
|
|
|
17
17
|
const _fetch = (requestPromise, timeout) => {
|
|
18
18
|
let timeoutAction
|
|
19
|
-
const timerPromise = new Promise((
|
|
19
|
+
const timerPromise = new Promise((_resolve, reject) => {
|
|
20
20
|
timeoutAction = () => {
|
|
21
21
|
reject(new Error('网络请求超时'))
|
|
22
22
|
}
|
|
@@ -40,6 +40,7 @@ const createFormData = (filePath, body, name) => {
|
|
|
40
40
|
data.append(key, body[key])
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
+
// @ts-ignore
|
|
43
44
|
data.append(name, fileObj)
|
|
44
45
|
|
|
45
46
|
return data
|
|
@@ -20,7 +20,7 @@ export async function getLocation(opts: Taro.getLocation.Option = {}): Promise<T
|
|
|
20
20
|
return new Promise((resolve, reject) => {
|
|
21
21
|
Geolocation.getCurrentPosition(
|
|
22
22
|
({ coords }) => {
|
|
23
|
-
const { latitude, longitude, altitude, accuracy,
|
|
23
|
+
const { latitude, longitude, altitude, accuracy, speed } = coords
|
|
24
24
|
const res = {
|
|
25
25
|
latitude,
|
|
26
26
|
longitude,
|
package/src/lib/location.ts
CHANGED
|
@@ -32,7 +32,7 @@ export function startLocationUpdate(opts: Taro.startLocationUpdate.Option): Prom
|
|
|
32
32
|
throw new Error('startLocationUpdate:fail')
|
|
33
33
|
} else {
|
|
34
34
|
_watchID = Geolocation.watchPosition(({ coords }) => {
|
|
35
|
-
const { latitude, longitude, altitude, accuracy,
|
|
35
|
+
const { latitude, longitude, altitude, accuracy, speed } = coords
|
|
36
36
|
_cbManager.trigger({
|
|
37
37
|
accuracy,
|
|
38
38
|
altitude,
|
package/src/lib/permission.ts
CHANGED
|
@@ -33,7 +33,7 @@ const getAuthSetting = async () => {
|
|
|
33
33
|
return auths
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const handleAppStateChange = async (
|
|
36
|
+
const handleAppStateChange = async (_nextAppState, resolve, reject, opts) => {
|
|
37
37
|
const { success, fail, complete } = opts
|
|
38
38
|
const res: any = {}
|
|
39
39
|
|
package/src/lib/request/index.ts
CHANGED
|
@@ -34,9 +34,9 @@ function _request<T = any>(options: Taro.request.Option): Taro.RequestTask<T> {
|
|
|
34
34
|
} else {
|
|
35
35
|
if (typeof data === 'object') {
|
|
36
36
|
const contentType = options.header && (options.header['content-type'] || options.header['Content-Type'])
|
|
37
|
-
if (contentType
|
|
37
|
+
if (contentType.startsWith('application/json')) {
|
|
38
38
|
data = JSON.stringify(data)
|
|
39
|
-
} else if (contentType
|
|
39
|
+
} else if (contentType.startsWith('application/x-www-form-urlencoded')) {
|
|
40
40
|
data = serializeParams(data)
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -53,7 +53,7 @@ function _request<T = any>(options: Taro.request.Option): Taro.RequestTask<T> {
|
|
|
53
53
|
params.method = method
|
|
54
54
|
let controller
|
|
55
55
|
// eslint-disable-next-line no-undef
|
|
56
|
-
if (AbortController) {
|
|
56
|
+
if (typeof(AbortController) !== 'undefined' ) {
|
|
57
57
|
// eslint-disable-next-line no-undef
|
|
58
58
|
controller = new AbortController()
|
|
59
59
|
const signal = controller.signal
|
|
@@ -78,7 +78,7 @@ function _request<T = any>(options: Taro.request.Option): Taro.RequestTask<T> {
|
|
|
78
78
|
return response
|
|
79
79
|
})
|
|
80
80
|
|
|
81
|
-
const timeoutPromise = new Promise((
|
|
81
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
82
82
|
const timer = setTimeout(() => {
|
|
83
83
|
controller?.abort()
|
|
84
84
|
reject(Error('request:fail timeout'))
|
|
@@ -182,7 +182,7 @@ export async function scanCode(option: Taro.scanCode.Option = {}): Promise<Taro.
|
|
|
182
182
|
style={{ width, height }}
|
|
183
183
|
ratio='16:9'
|
|
184
184
|
/>
|
|
185
|
-
<TouchableOpacity style={styles.closeIcon} onPress={() => hide(scannerView)}>
|
|
185
|
+
<TouchableOpacity accessibilityLabel="Close" style={styles.closeIcon} onPress={() => hide(scannerView)}>
|
|
186
186
|
{safeViewWrapper(<Image source={iconClose} style={styles.closeImg}/>)}
|
|
187
187
|
</TouchableOpacity>
|
|
188
188
|
{!onlyFromCamera && (<TouchableOpacity style={styles.albumIcon} onPress={() => {
|
|
@@ -5,6 +5,8 @@ import RootSiblings from 'react-native-root-siblings'
|
|
|
5
5
|
import successPng from './success.png'
|
|
6
6
|
import { errorHandler, shouldBeObject, successHandler } from '../../utils'
|
|
7
7
|
|
|
8
|
+
const globalAny: any = global
|
|
9
|
+
|
|
8
10
|
const styles = StyleSheet.create({
|
|
9
11
|
toastView: {
|
|
10
12
|
width: 76,
|
|
@@ -156,15 +158,15 @@ function showToast (options: Taro.showToast.Option): Promise<TaroGeneral.Callbac
|
|
|
156
158
|
try {
|
|
157
159
|
// setTimeout fires incorrectly when using chrome debug #4470
|
|
158
160
|
// https://github.com/facebook/react-native/issues/4470
|
|
159
|
-
|
|
161
|
+
globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
|
|
160
162
|
|
|
161
|
-
|
|
163
|
+
globalAny.wxToastRootSiblings = new RootSiblings(ToastView)
|
|
162
164
|
setTimeout(() => {
|
|
163
|
-
|
|
165
|
+
globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.update(ToastView)
|
|
164
166
|
}, 100)
|
|
165
167
|
if (duration > 0) {
|
|
166
168
|
setTimeout(() => {
|
|
167
|
-
|
|
169
|
+
globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy()
|
|
168
170
|
}, duration)
|
|
169
171
|
}
|
|
170
172
|
return successHandler(success, complete)(res)
|
|
@@ -199,8 +201,8 @@ function hideToast (opts: Taro.hideToast.Option = {}): void {
|
|
|
199
201
|
const { success, fail, complete } = opts
|
|
200
202
|
|
|
201
203
|
try {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
|
|
205
|
+
globalAny.wxToastRootSiblings = undefined
|
|
204
206
|
const res = { errMsg: 'showToast:ok' }
|
|
205
207
|
success?.(res)
|
|
206
208
|
complete?.(res)
|
|
@@ -215,8 +217,8 @@ function hideLoading (opts: Taro.hideLoading.Option = {}): void {
|
|
|
215
217
|
const { success, fail, complete } = opts
|
|
216
218
|
|
|
217
219
|
try {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
|
|
221
|
+
globalAny.wxToastRootSiblings = undefined
|
|
220
222
|
const res = { errMsg: 'showLoading:ok' }
|
|
221
223
|
success?.(res)
|
|
222
224
|
complete?.(res)
|
package/src/setup.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jest } from '@jest/globals'
|
|
2
|
+
import '@testing-library/jest-native/extend-expect'
|
|
3
|
+
import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock.js'
|
|
4
|
+
import { NetInfoStateType } from '@react-native-community/netinfo'
|
|
5
|
+
import mockRNCAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock.js'
|
|
6
|
+
import mockRNCDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock'
|
|
7
|
+
|
|
8
|
+
jest.doMock('@react-native-community/netinfo', () => ({ ...mockRNCNetInfo, NetInfoStateType }))
|
|
9
|
+
jest.doMock('@react-native-async-storage/async-storage', () => mockRNCAsyncStorage)
|
|
10
|
+
jest.doMock('react-native-device-info', () => mockRNCDeviceInfo)
|
|
11
|
+
|
|
12
|
+
jest.doMock('react-native', () => {
|
|
13
|
+
const ReactNative = jest.requireActual('react-native') as any
|
|
14
|
+
|
|
15
|
+
// Vibration readonly so you need use defineProperty rewrite this property descriptor.
|
|
16
|
+
const Vibration = (jest.requireActual('./__tests__/__mock__/mockVibrate') as any).default
|
|
17
|
+
Object.defineProperty(ReactNative, 'Vibration', {
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: false,
|
|
20
|
+
writable: false,
|
|
21
|
+
value: Vibration
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// mockNativeModules: react-native/Libraries/BatchedBridge/NativeModules
|
|
25
|
+
const RNCCameraRoll = (jest.requireActual('./__tests__/__mock__/mockRNCCameraRoll') as any).default
|
|
26
|
+
const MockClipboard = (jest.requireActual('./__tests__/__mock__/mockClipboard') as any).default
|
|
27
|
+
const RNCGeolocation = (jest.requireActual('./__tests__/__mock__/mockRNCGeolocation') as any).default
|
|
28
|
+
ReactNative.NativeModules.RNCCameraRoll = RNCCameraRoll
|
|
29
|
+
ReactNative.NativeModules.RNCClipboard = new MockClipboard()
|
|
30
|
+
ReactNative.NativeModules.RNCGeolocation = RNCGeolocation
|
|
31
|
+
Object.defineProperty(ReactNative.NativeModules, 'ImageLoader', {
|
|
32
|
+
configurable: true,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: () => ({
|
|
35
|
+
prefetchImage: jest.fn(),
|
|
36
|
+
getSize: jest.fn((_uri, success: any) => {
|
|
37
|
+
process.nextTick(() => success && success(320, 240))
|
|
38
|
+
return Promise.resolve([320, 240])
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
})
|
|
42
|
+
return ReactNative
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
jest.doMock('@unimodules/core', () => {
|
|
46
|
+
const unimodules = jest.requireActual('@unimodules/core') as any
|
|
47
|
+
const permisson = jest.requireActual('./__tests__/__mock__/mockExpoPermissions')
|
|
48
|
+
const { NativeModulesProxy } = unimodules
|
|
49
|
+
|
|
50
|
+
NativeModulesProxy.ExpoLocation = {
|
|
51
|
+
getCurrentPositionAsync: jest.fn(() => Promise.resolve({
|
|
52
|
+
coords: {
|
|
53
|
+
latitude: 0,
|
|
54
|
+
longitude: 0,
|
|
55
|
+
speed: 0,
|
|
56
|
+
accuracy: 0,
|
|
57
|
+
altitude: 0
|
|
58
|
+
}
|
|
59
|
+
}))
|
|
60
|
+
}
|
|
61
|
+
NativeModulesProxy.ExpoPermissions = permisson
|
|
62
|
+
|
|
63
|
+
return unimodules
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
jest.doMock('react-native-unimodules', () => {
|
|
67
|
+
const unimodules = jest.requireActual('react-native-unimodules') as any
|
|
68
|
+
const permisson = jest.requireActual('./__tests__/__mock__/mockExpoPermissions')
|
|
69
|
+
unimodules.Permissions = permisson
|
|
70
|
+
return unimodules
|
|
71
|
+
})
|