@tarojs/taro-rn 3.5.0-theta.0 → 3.5.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/apiList.js CHANGED
@@ -4,6 +4,7 @@ module.exports = [
4
4
  'getCurrentInstance',
5
5
  'useDidShow',
6
6
  'useDidHide',
7
+ 'useReady',
7
8
  'useRouter',
8
9
  'usePullDownRefresh',
9
10
  'useReachBottom',
package/dist/api/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { Current, getCurrentInstance, useDidShow, useDidHide, useRouter, usePullDownRefresh, useReachBottom, usePageScroll, useTabItemTap, useResize, eventCenter, Events, navigateTo, redirectTo, navigateBack, switchTab, reLaunch, showTabBar, hideTabBar, showTabBarRedDot, hideTabBarRedDot, setTabBarBadge, removeTabBarBadge, setTabBarItem, setNavigationBarTitle, setNavigationBarColor, showNavigationBarLoading, hideNavigationBarLoading, setTabBarStyle, getApp, pxTransform, startPullDownRefresh, stopPullDownRefresh, pageScrollTo, setBackgroundColor, setBackgroundTextStyle, getCurrentPages } from '@tarojs/runtime-rn';
1
+ export { Current, getCurrentInstance, useDidShow, useDidHide, useReady, useRouter, usePullDownRefresh, useReachBottom, usePageScroll, useTabItemTap, useResize, eventCenter, Events, navigateTo, redirectTo, navigateBack, switchTab, reLaunch, showTabBar, hideTabBar, showTabBarRedDot, hideTabBarRedDot, setTabBarBadge, removeTabBarBadge, setTabBarItem, setNavigationBarTitle, setNavigationBarColor, showNavigationBarLoading, hideNavigationBarLoading, setTabBarStyle, getApp, pxTransform, startPullDownRefresh, stopPullDownRefresh, pageScrollTo, setBackgroundColor, setBackgroundTextStyle, getCurrentPages } from '@tarojs/runtime-rn';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,aAAa,EACb,SAAS,EACT,WAAW,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,EACd,MAAM,EACN,WAAW,EACX,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EAChB,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,aAAa,EACb,SAAS,EACT,WAAW,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,EACd,MAAM,EACN,WAAW,EACX,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EAChB,MAAM,oBAAoB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/taro-rn",
3
- "version": "3.5.0-theta.0",
3
+ "version": "3.5.1",
4
4
  "description": "Taro RN framework",
5
5
  "main": "dist/index.js",
6
6
  "typings": "types/index.d.ts",
@@ -11,17 +11,6 @@
11
11
  "apiList.js",
12
12
  "libList.js"
13
13
  ],
14
- "scripts": {
15
- "assets": "cpy 'src/**/*.png' '!src/__tests__/*' dist",
16
- "build": "rimraf ./dist && tsc && pnpm run assets && pnpm run script",
17
- "dev": "pnpm run assets && tsc --watch",
18
- "lint": "eslint .",
19
- "test": "jest --silent",
20
- "test:dev": "jest --watch",
21
- "test:ci": "jest -i --silent --coverage false",
22
- "test:coverage": "jest --coverage",
23
- "script": "node ./script"
24
- },
25
14
  "repository": {
26
15
  "type": "git",
27
16
  "url": "git+https://github.com/NervJS/taro.git"
@@ -37,7 +26,7 @@
37
26
  "@react-native-community/clipboard": "~1.5.1",
38
27
  "@react-native-community/geolocation": "~2.0.2",
39
28
  "@react-native-community/netinfo": "~7.1.2",
40
- "@tarojs/runtime-rn": "workspace:*",
29
+ "@tarojs/runtime-rn": "3.5.1",
41
30
  "babel-preset-expo": "~9.0.2",
42
31
  "base64-js": "^1.3.0",
43
32
  "deprecated-react-native-prop-types": "^2.3.0",
@@ -52,6 +41,7 @@
52
41
  "expo-modules-core": "~0.9.2",
53
42
  "expo-sensors": "~11.2.0",
54
43
  "nullthrows": "^1.1.1",
44
+ "prop-types": "^15.8.1",
55
45
  "react-native-device-info": "~8.4.8",
56
46
  "react-native-image-resizer": "~1.4.5",
57
47
  "react-native-image-zoom-viewer": "^3.0.1",
@@ -62,9 +52,11 @@
62
52
  "react-native-syan-image-picker": "0.5.3"
63
53
  },
64
54
  "devDependencies": {
55
+ "@types/jest": "^27.4.1",
65
56
  "@types/react": "^17.0.0",
66
57
  "@types/react-native": "^0.67.7",
67
58
  "fbjs-scripts": "^3.0.1",
59
+ "metro-react-native-babel-preset": "^0.67.0",
68
60
  "react-native": "^0.68.2"
69
61
  },
70
62
  "peerDependencies": {
@@ -87,5 +79,16 @@
87
79
  "react-native-image-resizer": "~1.4.5",
88
80
  "react-native-safe-area-context": "~3.4.1",
89
81
  "react-native-syan-image-picker": "0.5.3"
82
+ },
83
+ "scripts": {
84
+ "assets": "cpy 'src/**/*.png' '!src/__tests__/*' dist",
85
+ "build": "rimraf ./dist && tsc && pnpm run assets && pnpm run script",
86
+ "dev": "pnpm run assets && tsc --watch",
87
+ "lint": "eslint .",
88
+ "test": "jest --silent",
89
+ "test:dev": "jest --watch",
90
+ "test:ci": "jest --ci -i --silent --coverage false",
91
+ "test:coverage": "jest --coverage",
92
+ "script": "node ./script"
90
93
  }
91
- }
94
+ }
@@ -44,6 +44,7 @@ describe('clipboard', () => {
44
44
 
45
45
  // expect.assertions(6)
46
46
  return Taro.setClipboardData({
47
+ // @ts-ignore
47
48
  data,
48
49
  success,
49
50
  fail,
@@ -38,22 +38,21 @@ describe('location', () => {
38
38
  const fail = jest.fn()
39
39
  const complete = jest.fn()
40
40
 
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
- }
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
  })
@@ -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
  })
@@ -1,6 +1,4 @@
1
1
  import * as network from '../lib/network'
2
-
3
- // react_native_1.NativeModules.RNCNetInfo setup mock
4
2
  const Taro = Object.assign({}, network)
5
3
 
6
4
  describe('network', () => {
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
@@ -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
- // eslint-disable-next-line
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)
package/src/api/index.ts CHANGED
@@ -3,6 +3,7 @@ export {
3
3
  getCurrentInstance,
4
4
  useDidShow,
5
5
  useDidHide,
6
+ useReady,
6
7
  useRouter,
7
8
  usePullDownRefresh,
8
9
  useReachBottom,
@@ -0,0 +1,9 @@
1
+ import Taro from '@tarojs/taro'
2
+
3
+ declare module '@tarojs/taro' {
4
+ namespace vibrateShort {
5
+ interface Option {
6
+ type?: 'heavy' | 'medium' | 'light'
7
+ }
8
+ }
9
+ }