@tarojs/taro-rn 3.5.0-theta.1 → 3.5.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/package.json +5 -2
- package/src/__tests__/__snapshots__/{scanCode.test.js.snap → scanCode.test.tsx.snap} +0 -0
- package/src/__tests__/{clipboard.test.js → clipboard.test.ts} +1 -0
- package/src/__tests__/{deviceMotion.test.js → deviceMotion.test.ts} +0 -0
- package/src/__tests__/{geolocation.test.js → geolocation.test.ts} +10 -11
- package/src/__tests__/{interactive.test.js → interactive.test.tsx} +0 -0
- package/src/__tests__/{keyboard.test.js → keyboard.test.ts} +0 -0
- package/src/__tests__/{media.test.js → media.test.ts} +2 -0
- package/src/__tests__/{network.test.js → network.test.ts} +0 -2
- package/src/__tests__/{others.test.js → others.test.ts} +0 -0
- package/src/__tests__/{phone.test.js → phone.test.ts} +0 -0
- package/src/__tests__/{request.test.js → request.test.ts} +6 -1
- package/src/__tests__/{scanCode.test.js → scanCode.test.tsx} +1 -0
- package/src/__tests__/{storage.test.js → storage.test.ts} +9 -5
- package/src/__tests__/{system.test.js → system.test.ts} +0 -0
- package/src/__tests__/{vibrate.test.js → vibrate.test.ts} +0 -0
- package/src/__tests__/{websocket.test.js → websocket.test.ts} +8 -6
- package/types/overlay.d.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro-rn",
|
|
3
|
-
"version": "3.5.0
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Taro RN framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "types/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@react-native-community/clipboard": "~1.5.1",
|
|
27
27
|
"@react-native-community/geolocation": "~2.0.2",
|
|
28
28
|
"@react-native-community/netinfo": "~7.1.2",
|
|
29
|
-
"@tarojs/runtime-rn": "3.5.0
|
|
29
|
+
"@tarojs/runtime-rn": "3.5.0",
|
|
30
30
|
"babel-preset-expo": "~9.0.2",
|
|
31
31
|
"base64-js": "^1.3.0",
|
|
32
32
|
"deprecated-react-native-prop-types": "^2.3.0",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"expo-modules-core": "~0.9.2",
|
|
42
42
|
"expo-sensors": "~11.2.0",
|
|
43
43
|
"nullthrows": "^1.1.1",
|
|
44
|
+
"prop-types": "^15.8.1",
|
|
44
45
|
"react-native-device-info": "~8.4.8",
|
|
45
46
|
"react-native-image-resizer": "~1.4.5",
|
|
46
47
|
"react-native-image-zoom-viewer": "^3.0.1",
|
|
@@ -51,9 +52,11 @@
|
|
|
51
52
|
"react-native-syan-image-picker": "0.5.3"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
55
|
+
"@types/jest": "^27.4.1",
|
|
54
56
|
"@types/react": "^17.0.0",
|
|
55
57
|
"@types/react-native": "^0.67.7",
|
|
56
58
|
"fbjs-scripts": "^3.0.1",
|
|
59
|
+
"metro-react-native-babel-preset": "^0.67.0",
|
|
57
60
|
"react-native": "^0.68.2"
|
|
58
61
|
},
|
|
59
62
|
"peerDependencies": {
|
|
File without changes
|
|
File without changes
|
|
@@ -38,22 +38,21 @@ describe('location', () => {
|
|
|
38
38
|
const fail = jest.fn()
|
|
39
39
|
const complete = jest.fn()
|
|
40
40
|
|
|
41
|
-
const expectData = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
41
|
+
// const expectData = {
|
|
42
|
+
// latitude: expect.any(Number),
|
|
43
|
+
// longitude: expect.any(Number),
|
|
44
|
+
// speed: expect.any(Number),
|
|
45
|
+
// accuracy: expect.any(Number),
|
|
46
|
+
// altitude: expect.any(Number),
|
|
47
|
+
// verticalAccuracy: expect.any(Number),
|
|
48
|
+
// horizontalAccuracy: expect.any(Number),
|
|
49
|
+
// }
|
|
50
50
|
|
|
51
51
|
Taro.getLocation({
|
|
52
52
|
success,
|
|
53
53
|
fail,
|
|
54
54
|
complete
|
|
55
|
-
})
|
|
56
|
-
setTimeout(() => {
|
|
55
|
+
}).then(() => {
|
|
57
56
|
expect(mockGetCurrentPosition.mock.calls.length).toBe(1)
|
|
58
57
|
})
|
|
59
58
|
})
|
|
File without changes
|
|
File without changes
|
|
@@ -68,6 +68,7 @@ describe('media', () => {
|
|
|
68
68
|
expect(fail.mock.calls.length).toBe(0)
|
|
69
69
|
expect(complete.mock.calls.length).toBe(1)
|
|
70
70
|
expect(complete.mock.calls[0][0]).toEqual({ errMsg: expectMsg, path })
|
|
71
|
+
// @ts-ignore
|
|
71
72
|
expect(res.path).toEqual(path)
|
|
72
73
|
})
|
|
73
74
|
})
|
|
@@ -95,6 +96,7 @@ describe('media', () => {
|
|
|
95
96
|
expect(fail.mock.calls.length).toBe(0)
|
|
96
97
|
expect(complete.mock.calls.length).toBe(1)
|
|
97
98
|
expect(complete.mock.calls[0][0]).toEqual({ errMsg: expectMsg, path })
|
|
99
|
+
// @ts-ignore
|
|
98
100
|
expect(res.path).toEqual(path)
|
|
99
101
|
})
|
|
100
102
|
})
|
|
File without changes
|
|
File without changes
|
|
@@ -19,6 +19,7 @@ describe('request', () => {
|
|
|
19
19
|
})
|
|
20
20
|
})
|
|
21
21
|
})
|
|
22
|
+
// @ts-ignore
|
|
22
23
|
global.fetch = fetch
|
|
23
24
|
})
|
|
24
25
|
|
|
@@ -54,6 +55,7 @@ describe('request', () => {
|
|
|
54
55
|
url,
|
|
55
56
|
responseType: 'text'
|
|
56
57
|
}
|
|
58
|
+
// @ts-ignore
|
|
57
59
|
const res = await Taro.request(options)
|
|
58
60
|
expect(res.data).toEqual(expectData)
|
|
59
61
|
})
|
|
@@ -89,7 +91,7 @@ describe('request', () => {
|
|
|
89
91
|
})
|
|
90
92
|
})
|
|
91
93
|
})
|
|
92
|
-
|
|
94
|
+
// @ts-ignore
|
|
93
95
|
global.fetch = fetch
|
|
94
96
|
|
|
95
97
|
const url = 'https://test.taro.com/v1'
|
|
@@ -102,6 +104,7 @@ describe('request', () => {
|
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
const expectUrl = `https://test.taro.com/v1?${encodeURIComponent('a')}=${encodeURIComponent(1)}`
|
|
107
|
+
// @ts-ignore
|
|
105
108
|
const res = await Taro.request(optionsOne)
|
|
106
109
|
expect(res.data.url).toMatch(expectUrl)
|
|
107
110
|
|
|
@@ -118,6 +121,7 @@ describe('request', () => {
|
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
const expectBodyOne = JSON.stringify({ a: 1 })
|
|
124
|
+
// @ts-ignore
|
|
121
125
|
const resTwo = await Taro.request(optionsTwo)
|
|
122
126
|
expect(resTwo.data.params.body).toMatch(expectBodyOne)
|
|
123
127
|
|
|
@@ -134,6 +138,7 @@ describe('request', () => {
|
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
const expectBodyTwo = `${encodeURIComponent('a')}=${encodeURIComponent(1)}`
|
|
141
|
+
// @ts-ignore
|
|
137
142
|
const resThree = await Taro.request(optionsThree)
|
|
138
143
|
expect(resThree.data.params.body).toMatch(expectBodyTwo)
|
|
139
144
|
})
|
|
@@ -5,6 +5,7 @@ import { scanCode } from '../lib/scanCode'
|
|
|
5
5
|
|
|
6
6
|
describe('scanCode', () => {
|
|
7
7
|
it('should render scanCode success', async () => {
|
|
8
|
+
// @ts-ignore
|
|
8
9
|
const { toJSON, getByLabelText } = render(<RootSiblingParent />)
|
|
9
10
|
scanCode()
|
|
10
11
|
await waitFor(() => getByLabelText('Close'));
|
|
@@ -42,7 +42,7 @@ describe('storage', () => {
|
|
|
42
42
|
expect(complete.mock.calls[0][0]).toEqual({ errMsg: expectMsg })
|
|
43
43
|
expect(res.errMsg).toMatch(expectMsg)
|
|
44
44
|
|
|
45
|
-
const getData = await AsyncStorage.getItem(key)
|
|
45
|
+
const getData = await AsyncStorage.getItem(key) || ''
|
|
46
46
|
expect(JSON.parse(getData)).toBe(data)
|
|
47
47
|
})
|
|
48
48
|
|
|
@@ -56,7 +56,7 @@ describe('storage', () => {
|
|
|
56
56
|
const complete = jest.fn()
|
|
57
57
|
|
|
58
58
|
expect.assertions(4)
|
|
59
|
-
|
|
59
|
+
// @ts-ignore
|
|
60
60
|
return Taro.setStorage({
|
|
61
61
|
data,
|
|
62
62
|
success,
|
|
@@ -112,7 +112,7 @@ describe('storage', () => {
|
|
|
112
112
|
const complete = jest.fn()
|
|
113
113
|
|
|
114
114
|
await AsyncStorage.setItem(key, JSON.stringify(data))
|
|
115
|
-
const getData = await AsyncStorage.getItem(key)
|
|
115
|
+
const getData = await AsyncStorage.getItem(key) || ''
|
|
116
116
|
|
|
117
117
|
expect(JSON.parse(getData)).toBe(data)
|
|
118
118
|
|
|
@@ -132,6 +132,7 @@ describe('storage', () => {
|
|
|
132
132
|
expect(complete.mock.calls.length).toBe(1)
|
|
133
133
|
expect(complete.mock.calls[0][0]).toEqual(res)
|
|
134
134
|
expect(res.errMsg).toMatch(expectMsg)
|
|
135
|
+
// @ts-ignore
|
|
135
136
|
expect(res.data).toBeUndefined()
|
|
136
137
|
})
|
|
137
138
|
})
|
|
@@ -164,8 +165,11 @@ describe('storage', () => {
|
|
|
164
165
|
expect(complete.mock.calls.length).toBe(1)
|
|
165
166
|
expect(complete.mock.calls[0][0]).toEqual(res)
|
|
166
167
|
expect(res.errMsg).toMatch(expectMsg)
|
|
168
|
+
// @ts-ignore
|
|
167
169
|
expect(res.keys).toEqual([key1, key2])
|
|
170
|
+
// @ts-ignore
|
|
168
171
|
expect(res.currentSize).toBe(+(12 / 1024).toFixed(2))
|
|
172
|
+
// @ts-ignore
|
|
169
173
|
expect(res.limitSize).toBe(Infinity)
|
|
170
174
|
})
|
|
171
175
|
})
|
|
@@ -180,8 +184,8 @@ describe('storage', () => {
|
|
|
180
184
|
await AsyncStorage.setItem(key1, JSON.stringify(data))
|
|
181
185
|
await AsyncStorage.setItem(key2, JSON.stringify(data))
|
|
182
186
|
|
|
183
|
-
const getData1 = await AsyncStorage.getItem(key1)
|
|
184
|
-
const getData2 = await AsyncStorage.getItem(key2)
|
|
187
|
+
const getData1 = await AsyncStorage.getItem(key1) || ''
|
|
188
|
+
const getData2 = await AsyncStorage.getItem(key2) || ''
|
|
185
189
|
|
|
186
190
|
expect(JSON.parse(getData1)).toBe(data)
|
|
187
191
|
expect(JSON.parse(getData2)).toBe(data)
|
|
File without changes
|
|
File without changes
|
|
@@ -5,6 +5,7 @@ const Taro = Object.assign({}, connectSocket)
|
|
|
5
5
|
|
|
6
6
|
describe('websocket', () => {
|
|
7
7
|
beforeEach(() => {
|
|
8
|
+
// @ts-ignore
|
|
8
9
|
global.WebSocket = WebSocket
|
|
9
10
|
})
|
|
10
11
|
|
|
@@ -16,6 +17,7 @@ describe('websocket', () => {
|
|
|
16
17
|
expect.assertions(6)
|
|
17
18
|
|
|
18
19
|
return Taro.connectSocket({
|
|
20
|
+
// @ts-ignore
|
|
19
21
|
url: {},
|
|
20
22
|
success,
|
|
21
23
|
fail,
|
|
@@ -61,8 +63,8 @@ describe('websocket', () => {
|
|
|
61
63
|
expect(err.errMsg).toMatch(expectErrMsg)
|
|
62
64
|
})
|
|
63
65
|
|
|
64
|
-
socketTaskOne.close()
|
|
65
|
-
socketTaskTwo.close()
|
|
66
|
+
socketTaskOne.close({})
|
|
67
|
+
socketTaskTwo.close({})
|
|
66
68
|
})
|
|
67
69
|
|
|
68
70
|
test('connection关闭的时候会重置总的socketTask数量', async () => {
|
|
@@ -74,7 +76,7 @@ describe('websocket', () => {
|
|
|
74
76
|
|
|
75
77
|
const socketTaskOne = await Taro.connectSocket({ url: 'wss://localhost:8080', success })
|
|
76
78
|
expect(success.mock.calls.length).toBe(1)
|
|
77
|
-
socketTaskOne.close()
|
|
79
|
+
socketTaskOne.close({})
|
|
78
80
|
|
|
79
81
|
const socketTaskTwo = await Taro.connectSocket({ url: 'wss://localhost:8090', success })
|
|
80
82
|
expect(success.mock.calls.length).toBe(2)
|
|
@@ -99,10 +101,10 @@ describe('websocket', () => {
|
|
|
99
101
|
errMsg: 'connectSocket:ok'
|
|
100
102
|
}))
|
|
101
103
|
|
|
102
|
-
socketTaskTwo.close()
|
|
103
|
-
socketTaskThree.close()
|
|
104
|
+
socketTaskTwo.close({})
|
|
105
|
+
socketTaskThree.close({})
|
|
104
106
|
})
|
|
105
|
-
//
|
|
107
|
+
// @ts-ignore
|
|
106
108
|
test('should work basically', async (done) => {
|
|
107
109
|
const fakeURL = 'wss://localhost:8080'
|
|
108
110
|
const mockServer = new Server(fakeURL)
|