@tarojs/taro-rn 4.0.0-canary.8 → 4.0.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 (194) hide show
  1. package/LICENSE +17 -3
  2. package/apiList.js +31 -31
  3. package/dist/api/index.js +1 -1
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/lib/Mask.js +2 -2
  6. package/dist/lib/Mask.js.map +1 -1
  7. package/dist/lib/Popup.js +20 -13
  8. package/dist/lib/Popup.js.map +1 -1
  9. package/dist/lib/StyleSheet.js +1 -1
  10. package/dist/lib/StyleSheet.js.map +1 -1
  11. package/dist/lib/accelerometer.js +1 -1
  12. package/dist/lib/accelerometer.js.map +1 -1
  13. package/dist/lib/chooseImage/index.js +1 -39
  14. package/dist/lib/chooseImage/index.js.map +1 -1
  15. package/dist/lib/chooseMedia/index.js +19 -0
  16. package/dist/lib/chooseMedia/index.js.map +1 -0
  17. package/dist/lib/chooseVideo/index.js +1 -40
  18. package/dist/lib/chooseVideo/index.js.map +1 -1
  19. package/dist/lib/clearStorage/index.js +2 -2
  20. package/dist/lib/clearStorage/index.js.map +1 -1
  21. package/dist/lib/compressImage/index.js +1 -1
  22. package/dist/lib/compressImage/index.js.map +1 -1
  23. package/dist/lib/connectSocket/index.js.map +1 -1
  24. package/dist/lib/connectSocket/socketTask.js +1 -1
  25. package/dist/lib/connectSocket/socketTask.js.map +1 -1
  26. package/dist/lib/createCameraContext/index.js +3 -3
  27. package/dist/lib/createCameraContext/index.js.map +1 -1
  28. package/dist/lib/createInnerAudioContext/index.js +2 -2
  29. package/dist/lib/createInnerAudioContext/index.js.map +1 -1
  30. package/dist/lib/createVideoContext/index.js +7 -7
  31. package/dist/lib/createVideoContext/index.js.map +1 -1
  32. package/dist/lib/deviceMotion.js +2 -2
  33. package/dist/lib/deviceMotion.js.map +1 -1
  34. package/dist/lib/file.js +4 -4
  35. package/dist/lib/file.js.map +1 -1
  36. package/dist/lib/getAppBaseInfo/index.js +2 -2
  37. package/dist/lib/getAppBaseInfo/index.js.map +1 -1
  38. package/dist/lib/getClipboardData/index.js.map +1 -1
  39. package/dist/lib/getImageInfo/index.js +2 -2
  40. package/dist/lib/getImageInfo/index.js.map +1 -1
  41. package/dist/lib/getLocation/index.js +8 -4
  42. package/dist/lib/getLocation/index.js.map +1 -1
  43. package/dist/lib/getRecorderManager/index.js +5 -5
  44. package/dist/lib/getRecorderManager/index.js.map +1 -1
  45. package/dist/lib/getStorage/index.js.map +1 -1
  46. package/dist/lib/getStorageInfo/index.js +2 -2
  47. package/dist/lib/getStorageInfo/index.js.map +1 -1
  48. package/dist/lib/getSystemInfo/index.js +1 -1
  49. package/dist/lib/getSystemInfo/index.js.map +1 -1
  50. package/dist/lib/getSystemInfoSync/index.js +2 -2
  51. package/dist/lib/getSystemInfoSync/index.js.map +1 -1
  52. package/dist/lib/gyroscope.js +1 -1
  53. package/dist/lib/gyroscope.js.map +1 -1
  54. package/dist/lib/index.js +1 -0
  55. package/dist/lib/index.js.map +1 -1
  56. package/dist/lib/keyboard.js +3 -3
  57. package/dist/lib/keyboard.js.map +1 -1
  58. package/dist/lib/location.js.map +1 -1
  59. package/dist/lib/makePhoneCall/index.js +1 -1
  60. package/dist/lib/makePhoneCall/index.js.map +1 -1
  61. package/dist/lib/media.js +57 -23
  62. package/dist/lib/media.js.map +1 -1
  63. package/dist/lib/network.js +1 -1
  64. package/dist/lib/network.js.map +1 -1
  65. package/dist/lib/offWindowResize/index.js.map +1 -1
  66. package/dist/lib/onWindowResize/index.js +1 -1
  67. package/dist/lib/onWindowResize/index.js.map +1 -1
  68. package/dist/lib/openUrl/index.js +1 -1
  69. package/dist/lib/openUrl/index.js.map +1 -1
  70. package/dist/lib/permission.js +6 -5
  71. package/dist/lib/permission.js.map +1 -1
  72. package/dist/lib/previewImage/index.js +3 -3
  73. package/dist/lib/previewImage/index.js.map +1 -1
  74. package/dist/lib/request/index.js +2 -2
  75. package/dist/lib/request/index.js.map +1 -1
  76. package/dist/lib/scanCode/index.js +23 -23
  77. package/dist/lib/scanCode/index.js.map +1 -1
  78. package/dist/lib/screen.js +2 -2
  79. package/dist/lib/screen.js.map +1 -1
  80. package/dist/lib/setClipboardData/index.js +2 -2
  81. package/dist/lib/setClipboardData/index.js.map +1 -1
  82. package/dist/lib/setKeepScreenOn/index.js +1 -1
  83. package/dist/lib/setKeepScreenOn/index.js.map +1 -1
  84. package/dist/lib/setStorage/index.js.map +1 -1
  85. package/dist/lib/showActionSheet/ActionSheet.js +11 -23
  86. package/dist/lib/showActionSheet/ActionSheet.js.map +1 -1
  87. package/dist/lib/showActionSheet/index.js.map +1 -1
  88. package/dist/lib/showModal/Dialog.js +22 -36
  89. package/dist/lib/showModal/Dialog.js.map +1 -1
  90. package/dist/lib/showModal/index.js.map +1 -1
  91. package/dist/lib/showModal/toast.js +6 -6
  92. package/dist/lib/showModal/toast.js.map +1 -1
  93. package/dist/lib/unsupportedApi.js +2 -4
  94. package/dist/lib/unsupportedApi.js.map +1 -1
  95. package/dist/lib/variable.js +1 -1
  96. package/dist/lib/variable.js.map +1 -1
  97. package/dist/lib/vibrate.js +1 -1
  98. package/dist/lib/vibrate.js.map +1 -1
  99. package/dist/lib/window.js.map +1 -1
  100. package/dist/utils/callbackManager.js.map +1 -1
  101. package/dist/utils/index.js.map +1 -1
  102. package/libList.js +1 -0
  103. package/package.json +67 -61
  104. package/src/api/index.ts +31 -31
  105. package/src/lib/ENV_TYPE/index.ts +1 -1
  106. package/src/lib/Mask.tsx +2 -2
  107. package/src/lib/Popup.tsx +26 -19
  108. package/src/lib/StyleSheet.ts +1 -1
  109. package/src/lib/accelerometer.ts +2 -1
  110. package/src/lib/arrayBufferToBase64/index.ts +1 -1
  111. package/src/lib/base64ToArrayBuffer/index.ts +1 -1
  112. package/src/lib/chooseImage/index.ts +1 -29
  113. package/src/lib/chooseMedia/index.ts +15 -0
  114. package/src/lib/chooseVideo/index.ts +1 -31
  115. package/src/lib/clearStorage/index.ts +1 -0
  116. package/src/lib/clearStorageSync/index.ts +1 -1
  117. package/src/lib/compressImage/index.ts +1 -0
  118. package/src/lib/connectSocket/socketTask.ts +7 -9
  119. package/src/lib/createCameraContext/index.ts +6 -4
  120. package/src/lib/createInnerAudioContext/index.ts +1 -0
  121. package/src/lib/createSelectorQuery/index.ts +1 -1
  122. package/src/lib/deviceMotion.ts +4 -3
  123. package/src/lib/file.ts +10 -9
  124. package/src/lib/getClipboardData/index.ts +1 -0
  125. package/src/lib/getEnv/index.ts +1 -1
  126. package/src/lib/getFileSystemManager/index.ts +1 -1
  127. package/src/lib/getLocation/index.ts +7 -2
  128. package/src/lib/getRecorderManager/index.ts +1 -1
  129. package/src/lib/getStorage/index.ts +1 -0
  130. package/src/lib/getStorageInfo/index.ts +1 -0
  131. package/src/lib/getStorageInfoSync/index.ts +1 -1
  132. package/src/lib/getStorageSync/index.ts +1 -1
  133. package/src/lib/getSystemInfo/index.ts +2 -2
  134. package/src/lib/getSystemInfoSync/index.ts +3 -3
  135. package/src/lib/gyroscope.ts +47 -46
  136. package/src/lib/index.ts +1 -0
  137. package/src/lib/keyboard.ts +5 -4
  138. package/src/lib/location.ts +6 -5
  139. package/src/lib/makePhoneCall/index.ts +2 -1
  140. package/src/lib/media.ts +71 -23
  141. package/src/lib/network.ts +5 -5
  142. package/src/lib/offLocationChange/index.ts +1 -1
  143. package/src/lib/offUserCaptureScreen/index.ts +1 -1
  144. package/src/lib/onLocationChange/index.ts +1 -1
  145. package/src/lib/onUserCaptureScreen/index.ts +1 -1
  146. package/src/lib/onWindowResize/index.ts +2 -2
  147. package/src/lib/openUrl/index.d.ts +23 -22
  148. package/src/lib/openUrl/index.ts +2 -1
  149. package/src/lib/permission.ts +33 -25
  150. package/src/lib/previewImage/index.tsx +4 -3
  151. package/src/lib/removeStorageSync/index.ts +1 -1
  152. package/src/lib/request/index.ts +3 -3
  153. package/src/lib/scanCode/index.tsx +18 -16
  154. package/src/lib/screen.ts +1 -0
  155. package/src/lib/setClipboardData/index.ts +3 -2
  156. package/src/lib/setKeepScreenOn/index.ts +2 -1
  157. package/src/lib/setStorage/index.ts +1 -0
  158. package/src/lib/setStorageSync/index.ts +1 -1
  159. package/src/lib/showActionSheet/ActionSheet.tsx +34 -43
  160. package/src/lib/showActionSheet/index.tsx +1 -0
  161. package/src/lib/showModal/Dialog.tsx +34 -39
  162. package/src/lib/showModal/index.tsx +1 -0
  163. package/src/lib/showModal/toast.tsx +14 -13
  164. package/src/lib/startGyroscope/index.ts +1 -1
  165. package/src/lib/startLocationUpdate/index.ts +1 -1
  166. package/src/lib/unsupportedApi.ts +3 -5
  167. package/src/lib/vibrate.ts +11 -10
  168. package/src/lib/window.ts +3 -2
  169. package/src/utils/callbackManager.ts +5 -5
  170. package/src/utils/index.ts +4 -4
  171. package/types/runtime.d.ts +3 -0
  172. package/{src/types → types}/vue/index.d.ts +2 -3
  173. package/dist/setup.js +0 -58
  174. package/dist/setup.js.map +0 -1
  175. package/src/__tests__/__mock__/mockRNCCameraRoll.js +0 -7
  176. package/src/__tests__/__mock__/mockRNCGeolocation.js +0 -13
  177. package/src/__tests__/__snapshots__/scanCode.test.tsx.snap +0 -154
  178. package/src/__tests__/clipboard.test.ts +0 -88
  179. package/src/__tests__/deviceMotion.test.ts +0 -37
  180. package/src/__tests__/geolocation.test.ts +0 -60
  181. package/src/__tests__/interactive.test.tsx +0 -101
  182. package/src/__tests__/keyboard.test.ts +0 -46
  183. package/src/__tests__/media.test.ts +0 -104
  184. package/src/__tests__/network.test.ts +0 -57
  185. package/src/__tests__/others.test.ts +0 -25
  186. package/src/__tests__/phone.test.ts +0 -31
  187. package/src/__tests__/request.test.ts +0 -146
  188. package/src/__tests__/scanCode.test.tsx +0 -14
  189. package/src/__tests__/storage.test.ts +0 -202
  190. package/src/__tests__/system.test.ts +0 -69
  191. package/src/__tests__/vibrate.test.ts +0 -27
  192. package/src/__tests__/websocket.test.ts +0 -170
  193. package/src/setup.ts +0 -64
  194. /package/{src/types → types}/definition.d.ts +0 -0
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@tarojs/taro-rn",
3
- "version": "4.0.0-canary.8",
3
+ "version": "4.0.0",
4
4
  "description": "Taro RN framework",
5
+ "author": "O2Team",
6
+ "license": "MIT",
5
7
  "main": "dist/index.js",
6
- "typings": "types/index.d.ts",
8
+ "types": "types/index.d.ts",
7
9
  "files": [
8
10
  "dist",
9
11
  "src",
@@ -18,81 +20,85 @@
18
20
  "keywords": [
19
21
  "taro"
20
22
  ],
21
- "author": "O2Team",
22
- "license": "MIT",
23
+ "engines": {
24
+ "node": ">= 18"
25
+ },
23
26
  "dependencies": {
24
- "@bam.tech/react-native-image-resizer": "~3.0.5",
25
- "@react-native-async-storage/async-storage": "~1.21.0",
26
- "@react-native-camera-roll/camera-roll": "~7.2.0",
27
- "@react-native-clipboard/clipboard": "~1.13.0",
28
- "@react-native-community/geolocation": "~3.1.0",
29
- "@react-native-community/netinfo": "~11.2.0",
30
- "babel-preset-expo": "~10.0.0",
31
- "base64-js": "^1.3.0",
32
- "deprecated-react-native-prop-types": "^2.3.0",
27
+ "@bam.tech/react-native-image-resizer": "3.0.9",
28
+ "@react-native-async-storage/async-storage": "1.23.1",
29
+ "@react-native-camera-roll/camera-roll": "7.7.0",
30
+ "@react-native-clipboard/clipboard": "1.14.1",
31
+ "@react-native-community/geolocation": "3.2.1",
32
+ "@react-native-community/netinfo": "11.3.2",
33
+ "base64-js": "^1.5.1",
34
+ "deprecated-react-native-prop-types": "^5.0.0",
33
35
  "expo-av": "~13.10.0",
34
- "expo-barcode-scanner": "~12.9.0",
35
- "expo-brightness": "~11.8.0",
36
- "expo-camera": "~14.0.0",
37
- "expo-file-system": "~16.0.0",
38
- "expo-image-picker": "~14.7.0",
39
- "expo-keep-awake": "~12.8.0",
40
- "expo-location": "~16.5.1",
41
- "expo-sensors": "~12.9.0",
42
- "nullthrows": "^1.1.1",
36
+ "expo-barcode-scanner": "~13.0.1",
37
+ "expo-brightness": "~12.0.1",
38
+ "expo-camera": "~15.0.8",
39
+ "expo-file-system": "~17.0.1",
40
+ "expo-image-picker": "~15.0.4",
41
+ "expo-keep-awake": "~13.0.1",
42
+ "expo-location": "~17.0.1",
43
+ "expo-sensors": "~13.0.6",
43
44
  "prop-types": "^15.8.1",
44
- "react-native-device-info": "~10.12.0",
45
- "react-native-image-zoom-viewer": "^3.0.1",
46
- "react-native-root-siblings": "^5.0.1",
47
- "react-native-root-toast": "^3.5.1",
48
- "react-native-safe-area-context": "~4.8.0",
49
- "react-native-stylekit": "^1.0.0",
50
- "@tarojs/runtime-rn": "4.0.0-canary.8"
45
+ "react-native-device-info": "11.1.0",
46
+ "react-native-image-zoom-viewer": "3.0.1",
47
+ "react-native-root-siblings": "5.0.1",
48
+ "react-native-safe-area-context": "4.10.1",
49
+ "@tarojs/runtime-rn": "4.0.0",
50
+ "@tarojs/taro": "4.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@babel/core": "^7.14.5",
54
- "@babel/preset-env": "^7.14.5",
53
+ "@babel/core": "^7.24.4",
54
+ "@babel/parser": "^7.24.4",
55
+ "@babel/preset-env": "^7.24.4",
56
+ "@babel/traverse": "^7.24.4",
55
57
  "@react-native/babel-preset": "^0.73.18",
56
58
  "@testing-library/jest-native": "^5.4.2",
57
59
  "@testing-library/react-native": "^12.4.1",
58
- "@types/jest": "^27.4.1",
59
- "expo": "~50.0.0-preview.7",
60
- "fbjs-scripts": "^3.0.1",
61
- "jest": "^29.3.1",
62
- "jest-cli": "^29.3.1",
63
- "jest-environment-node": "^29.5.0",
64
- "jest-expo": "^50.0.0",
60
+ "cpy-cli": "^5.0.0",
61
+ "dpdm": "^3.14.0",
62
+ "expo": "~51.0.5",
63
+ "jest-expo": "^51.0.1",
65
64
  "mock-socket": "^7.1.0",
66
- "react": "18.2.0",
67
- "react-native": "^0.73.1",
68
- "react-test-renderer": "18.2.0"
65
+ "react": "^18.2.0",
66
+ "react-native": "^0.72.3"
69
67
  },
70
68
  "peerDependencies": {
71
- "@bam.tech/react-native-image-resizer": "~3.0.5",
72
- "@react-native-async-storage/async-storage": "~1.21.0",
73
- "@react-native-camera-roll/camera-roll": "~7.2.0",
74
- "@react-native-clipboard/clipboard": "~1.13.0",
75
- "@react-native-community/geolocation": "~3.1.0",
76
- "@react-native-community/netinfo": "~11.2.0",
77
- "expo-av": "~13.10.0",
78
- "expo-barcode-scanner": "~12.9.0",
79
- "expo-brightness": "~11.8.0",
80
- "expo-camera": "~14.0.0",
81
- "expo-file-system": "~16.0.0",
82
- "expo-image-picker": "~14.7.0",
83
- "expo-keep-awake": "~12.8.0",
84
- "expo-location": "~16.5.1",
85
- "expo-sensors": "~12.9.0",
86
- "react-native-device-info": "~10.12.0",
87
- "react-native-safe-area-context": "~4.8.0"
69
+ "@bam.tech/react-native-image-resizer": ">= 3.0.0",
70
+ "@react-native-async-storage/async-storage": ">= 1.21.0",
71
+ "@react-native-camera-roll/camera-roll": ">= 7.2.0",
72
+ "@react-native-clipboard/clipboard": ">= 1.13.0",
73
+ "@react-native-community/geolocation": ">= 3.2.0",
74
+ "@react-native-community/netinfo": ">= 11.2.0",
75
+ "expo": ">= 51",
76
+ "expo-av": ">= 13.10.0",
77
+ "expo-barcode-scanner": ">= 13",
78
+ "expo-brightness": ">= 12",
79
+ "expo-camera": ">= 15",
80
+ "expo-file-system": ">= 17",
81
+ "expo-image-picker": ">= 15",
82
+ "expo-keep-awake": ">= 13",
83
+ "expo-location": ">= 17",
84
+ "expo-sensors": ">= 13",
85
+ "react": ">= 18",
86
+ "react-native": ">= 0.63.0",
87
+ "react-native-device-info": ">= 11",
88
+ "react-native-image-zoom-viewer": ">= 3",
89
+ "react-native-root-siblings": ">= 5",
90
+ "react-native-safe-area-context": ">= 4.8.0"
88
91
  },
89
92
  "scripts": {
93
+ "prod": "pnpm run build",
90
94
  "assets": "cpy 'src/**/*.png' '!src/__tests__/*' dist",
91
- "build": "rimraf --impl=move-remove ./dist && tsc && pnpm run assets && pnpm run script",
95
+ "prebuild": "pnpm run clean",
96
+ "clean": "rimraf --impl=move-remove ./dist apiList.js libList.js",
97
+ "build": "tsc && pnpm run assets && pnpm run script",
92
98
  "dev": "pnpm run assets && tsc --watch",
93
- "lint": "eslint .",
99
+ "lint": "eslint src script __tests__ --ext .js,.jsx.ts,.tsx",
94
100
  "test": "jest --silent",
95
- "test:ci": "jest --ci -i --silent --coverage false",
101
+ "test:ci": "jest --ci -i --coverage --silent",
96
102
  "test:coverage": "jest --coverage",
97
103
  "test:dev": "jest --watch",
98
104
  "script": "node ./script"
package/src/api/index.ts CHANGED
@@ -1,44 +1,44 @@
1
1
  export {
2
2
  Current,
3
- getCurrentInstance,
4
- useDidShow,
5
- useDidHide,
6
- useLoad,
7
- useReady,
8
- useUnload,
9
- useLaunch,
10
- usePageNotFound,
11
- useRouter,
12
- usePullDownRefresh,
13
- useReachBottom,
14
- usePageScroll,
15
- useTabItemTap,
16
- useResize,
17
3
  eventCenter,
18
4
  Events,
5
+ getApp,
6
+ getCurrentInstance,
7
+ getCurrentPages,
8
+ hideNavigationBarLoading,
9
+ hideTabBar,
10
+ hideTabBarRedDot,
11
+ navigateBack,
19
12
  navigateTo,
13
+ pageScrollTo,
14
+ pxTransform,
20
15
  redirectTo,
21
- navigateBack,
22
- switchTab,
23
16
  reLaunch,
24
- showTabBar,
25
- hideTabBar,
26
- showTabBarRedDot,
27
- hideTabBarRedDot,
28
- setTabBarBadge,
29
17
  removeTabBarBadge,
30
- setTabBarItem,
31
- setNavigationBarTitle,
18
+ setBackgroundColor,
19
+ setBackgroundTextStyle,
32
20
  setNavigationBarColor,
33
- showNavigationBarLoading,
34
- hideNavigationBarLoading,
21
+ setNavigationBarTitle,
22
+ setTabBarBadge,
23
+ setTabBarItem,
35
24
  setTabBarStyle,
36
- getApp,
37
- pxTransform,
25
+ showNavigationBarLoading,
26
+ showTabBar,
27
+ showTabBarRedDot,
38
28
  startPullDownRefresh,
39
29
  stopPullDownRefresh,
40
- pageScrollTo,
41
- setBackgroundColor,
42
- setBackgroundTextStyle,
43
- getCurrentPages
30
+ switchTab,
31
+ useDidHide,
32
+ useDidShow,
33
+ useLaunch,
34
+ useLoad,
35
+ usePageNotFound,
36
+ usePageScroll,
37
+ usePullDownRefresh,
38
+ useReachBottom,
39
+ useReady,
40
+ useResize,
41
+ useRouter,
42
+ useTabItemTap,
43
+ useUnload
44
44
  } from '@tarojs/runtime-rn'
@@ -9,4 +9,4 @@ export const ENV_TYPE = {
9
9
  RN: 'RN',
10
10
  HARMONY: 'HARMONY',
11
11
  QUICKAPP: 'QUICKAPP'
12
- }
12
+ }
package/src/lib/Mask.tsx CHANGED
@@ -1,7 +1,7 @@
1
- import React from 'react'
1
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types'
2
2
  import PropTypes from 'prop-types'
3
+ import React from 'react'
3
4
  import { StyleSheet, TouchableWithoutFeedback, View } from 'react-native'
4
- import { ViewPropTypes } from 'deprecated-react-native-prop-types'
5
5
 
6
6
  const styles = StyleSheet.create({
7
7
  mask: {
package/src/lib/Popup.tsx CHANGED
@@ -1,8 +1,8 @@
1
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types'
2
+ import PropTypes from 'prop-types'
1
3
  import React, { Component } from 'react'
4
+ import { Animated, Dimensions, Easing, Modal, StyleSheet, View } from 'react-native'
2
5
 
3
- import PropTypes from 'prop-types'
4
- import { Modal, View, StyleSheet, Dimensions, Animated, Easing } from 'react-native'
5
- import { ViewPropTypes } from 'deprecated-react-native-prop-types'
6
6
  import { Mask } from './Mask'
7
7
 
8
8
  const { width, height } = Dimensions.get('window')
@@ -17,7 +17,7 @@ const styles = StyleSheet.create({
17
17
  })
18
18
 
19
19
  interface Props {
20
- visible?: boolean;
20
+ visible?: boolean
21
21
  }
22
22
 
23
23
  class Popup extends Component<any, any> {
@@ -32,14 +32,14 @@ class Popup extends Component<any, any> {
32
32
 
33
33
  height
34
34
  popup
35
-
36
- constructor (props:Props) {
35
+ timer
36
+ constructor(props: Props) {
37
37
  super(props)
38
38
  this.state = { visible: props.visible ?? false, translateY: new Animated.Value(height) }
39
39
  this.handleLayout = this.handleLayout.bind(this)
40
40
  }
41
41
 
42
- UNSAFE_componentWillReceiveProps (nextProp:Props):void {
42
+ UNSAFE_componentWillReceiveProps (nextProp: Props): void {
43
43
  if (this.props.visible !== nextProp.visible) {
44
44
  if (nextProp.visible) {
45
45
  this.setState({ visible: true })
@@ -54,20 +54,27 @@ class Popup extends Component<any, any> {
54
54
  }
55
55
  }
56
56
 
57
- handleLayout ():void {
58
- this.popup.measure((_x, _y, _w, h) => {
59
- this.height = h
60
- this.setState({ translateY: new Animated.Value(h) })
61
- Animated.timing(this.state.translateY, {
62
- toValue: 0,
63
- duration: 300,
64
- easing: (Easing as any).easeInOut,
65
- useNativeDriver: true
66
- }).start()
67
- })
57
+ componentWillUnmount (): void {
58
+ this.timer && clearTimeout(this.timer)
59
+ }
60
+
61
+ handleLayout (): void {
62
+ this.timer = setTimeout(() => {
63
+ this.popup?.measure((_x, _y, _w, h) => {
64
+ this.height = h
65
+ this.setState({ translateY: new Animated.Value(h) }, () => {
66
+ Animated.timing(this.state.translateY, {
67
+ toValue: 0,
68
+ duration: 300,
69
+ easing: (Easing as any).easeInOut,
70
+ useNativeDriver: true
71
+ }).start()
72
+ })
73
+ })
74
+ },) // 处理鸿蒙系统handleLayout 回调 this.popup为空的情况
68
75
  }
69
76
 
70
- render ():JSX.Element {
77
+ render (): JSX.Element {
71
78
  const {
72
79
  style,
73
80
  maskStyle,
@@ -1,4 +1,4 @@
1
- import { StyleSheet, Platform } from 'react-native'
1
+ import { Platform, StyleSheet } from 'react-native'
2
2
 
3
3
  interface Styles {
4
4
  [propName: string]: any
@@ -1,4 +1,5 @@
1
1
  import { Accelerometer } from 'expo-sensors'
2
+
2
3
  import { createCallbackManager, errorHandler, successHandler } from '../utils'
3
4
 
4
5
  const _cbManager = createCallbackManager()
@@ -68,8 +69,8 @@ function stopAccelerometer(opts: Taro.stopAccelerometer.Option = {}): Promise<Ta
68
69
  }
69
70
 
70
71
  export {
71
- onAccelerometerChange,
72
72
  offAccelerometerChange,
73
+ onAccelerometerChange,
73
74
  startAccelerometer,
74
75
  stopAccelerometer
75
76
  }
@@ -3,4 +3,4 @@ import { fromByteArray } from 'base64-js'
3
3
  export function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string {
4
4
  const buffer = new Uint8Array(arrayBuffer)
5
5
  return fromByteArray(buffer)
6
- }
6
+ }
@@ -2,4 +2,4 @@ import { toByteArray } from 'base64-js'
2
2
 
3
3
  export function base64ToArrayBuffer(base64: string): ArrayBuffer {
4
4
  return toByteArray(base64)
5
- }
5
+ }
@@ -1,33 +1,5 @@
1
1
  import { chooseMedia, MEDIA_TYPE } from '../media'
2
- import { showActionSheet } from '../showActionSheet'
3
2
 
4
3
  export function chooseImage(opts: Taro.chooseImage.Option): Promise<any> {
5
- const {
6
- sourceType = ['album', 'camera'],
7
- } = opts
8
- if(sourceType?.includes('camera') && sourceType?.includes('album')) {
9
- return showImagePicker(opts)
10
- } else if (sourceType?.includes('camera')) {
11
- return chooseMedia({...opts, sourceType: ['camera']}, MEDIA_TYPE.IMAGES)
12
- }
13
- return chooseMedia({...opts, sourceType: ['album']}, MEDIA_TYPE.IMAGES)
14
- }
15
-
16
- async function showImagePicker(options: Taro.chooseImage.Option):Promise<any> {
17
- const { fail, complete } = options
18
- try {
19
- const res = await showActionSheet({
20
- itemList: ['拍照', '从手机相册选择'],
21
- })
22
- if (res.tapIndex === 0) {
23
- return chooseMedia({...options, sourceType: ['camera']}, MEDIA_TYPE.IMAGES)
24
- }
25
- if (res.tapIndex === 1) {
26
- return chooseMedia({...options, sourceType: ['album']}, MEDIA_TYPE.IMAGES)
27
- }
28
- } catch (err) {
29
- const res = { errMsg: 'chooseImage: fail' }
30
- fail?.(res)
31
- complete?.(res)
32
- }
4
+ return chooseMedia(opts, MEDIA_TYPE.Images)
33
5
  }
@@ -0,0 +1,15 @@
1
+ import { chooseMedia as _chooseMedia, MEDIA_TYPE } from '../media'
2
+
3
+ export function chooseMedia (opts: Taro.chooseMedia.Option): Promise<any> {
4
+ if (opts.mediaType?.length === 1) {
5
+ if (opts.mediaType[0] === 'video') {
6
+ return _chooseMedia(opts, MEDIA_TYPE.Videos)
7
+ } else if (opts.mediaType[0] === 'image') {
8
+ return _chooseMedia(opts, MEDIA_TYPE.Images)
9
+ } else {
10
+ return _chooseMedia(opts, MEDIA_TYPE.All)
11
+ }
12
+ } else {
13
+ return _chooseMedia(opts, MEDIA_TYPE.All)
14
+ }
15
+ }
@@ -1,35 +1,5 @@
1
1
  import { chooseMedia, MEDIA_TYPE } from '../media'
2
- import { showActionSheet } from '../showActionSheet'
3
2
 
4
3
  export function chooseVideo(opts: Taro.chooseVideo.Option): Promise<any> {
5
- const {
6
- sourceType = ['album', 'camera'],
7
- compressed
8
- } = opts
9
- opts = Object.assign(opts, { sizeType: compressed ? ['compressed'] : [] })
10
- if(sourceType?.includes('camera') && sourceType?.includes('album')) {
11
- return showVideoPicker(opts)
12
- } else if (sourceType?.includes('camera')) {
13
- return chooseMedia({...opts, sourceType: ['camera']}, MEDIA_TYPE.VIDEOS)
14
- }
15
- return chooseMedia({...opts, sourceType: ['album']}, MEDIA_TYPE.VIDEOS)
16
- }
17
-
18
- async function showVideoPicker(options: Taro.chooseVideo.Option):Promise<any> {
19
- const { fail, complete } = options
20
- try {
21
- const res = await showActionSheet({
22
- itemList: ['拍摄', '从手机相册选择'],
23
- })
24
- if (res.tapIndex === 0) {
25
- return chooseMedia({...options, sourceType: ['camera']}, MEDIA_TYPE.VIDEOS)
26
- }
27
- if (res.tapIndex === 1) {
28
- return chooseMedia({...options, sourceType: ['album']}, MEDIA_TYPE.VIDEOS)
29
- }
30
- } catch (err) {
31
- const res = { errMsg: 'chooseVideo: fail' }
32
- fail?.(res)
33
- complete?.(res)
34
- }
4
+ return chooseMedia(opts, MEDIA_TYPE.Videos)
35
5
  }
@@ -1,4 +1,5 @@
1
1
  import AsyncStorage from '@react-native-async-storage/async-storage'
2
+
2
3
  import { errorHandler, successHandler } from '../../utils'
3
4
 
4
5
  export async function clearStorage(option: Taro.clearStorage.Option = {}): Promise<TaroGeneral.CallbackResult> {
@@ -1 +1 @@
1
- export { clearStorageSync } from '../unsupportedApi'
1
+ export { clearStorageSync } from '../unsupportedApi'
@@ -1,5 +1,6 @@
1
1
  import ImageResizer, { ResizeFormat } from '@bam.tech/react-native-image-resizer'
2
2
  import { Image } from 'react-native'
3
+
3
4
  import { errorHandler, successHandler } from '../../utils'
4
5
 
5
6
  /**
@@ -1,13 +1,11 @@
1
- interface SocketTask {
2
- ws: WebSocket;
3
- _destroyWhenClose: () => void;
1
+ class SocketTask {
2
+ ws: WebSocket
3
+ _destroyWhenClose: () => void
4
4
  closeDetail: {
5
- code: number;
6
- reason: string;
7
- };
8
- }
5
+ code: number
6
+ reason: string
7
+ }
9
8
 
10
- class SocketTask {
11
9
  constructor (url: string, protocols: string[] | undefined) {
12
10
  if (protocols) {
13
11
  // eslint-disable-next-line no-undef
@@ -105,7 +103,7 @@ class SocketTask {
105
103
  onError (func?: Taro.SocketTask.OnErrorCallback): void {
106
104
  this.ws.onerror = () => {
107
105
  func && func({
108
- errMsg: "There was an error with your websocket.",
106
+ errMsg: 'There was an error with your websocket.',
109
107
  })
110
108
  }
111
109
  }
@@ -1,5 +1,7 @@
1
+ import { Camera } from 'expo-camera'
2
+
1
3
  import { errorHandler, successHandler } from '../../utils'
2
- import { requestCameraPermissionsAsync, requestMicrophonePermissionsAsync } from 'expo-camera'
4
+
3
5
  const globalAny: any = global
4
6
 
5
7
  class CameraContext {
@@ -14,8 +16,8 @@ class CameraContext {
14
16
  * 开始录像
15
17
  */
16
18
  startRecord = (option: Taro.CameraContext.StartRecordOption) => {
17
- Promise.all([requestCameraPermissionsAsync(), requestMicrophonePermissionsAsync()]).then(([cameraPermission, microphonePermission]) => {
18
- if(cameraPermission.granted && microphonePermission.granted) {
19
+ Promise.all([Camera.requestCameraPermissionsAsync(), Camera.requestMicrophonePermissionsAsync()]).then(([cameraPermission, microphonePermission]) => {
20
+ if (cameraPermission.granted && microphonePermission.granted) {
19
21
  this.cameraRef?.recordAsync().then((res) => {
20
22
  const { uri } = res
21
23
  const result = {
@@ -76,7 +78,7 @@ class CameraContext {
76
78
  break
77
79
  }
78
80
  try {
79
- const { granted } = await requestCameraPermissionsAsync()
81
+ const { granted } = await Camera.requestCameraPermissionsAsync()
80
82
  if (granted) {
81
83
  if (this.cameraRef?.takePictureAsync) {
82
84
  const { uri } = await this.cameraRef.takePictureAsync({ quality: _quality })
@@ -1,4 +1,5 @@
1
1
  import { Audio } from 'expo-av'
2
+
2
3
  import { isUrl } from '../../utils'
3
4
 
4
5
  /**
@@ -1 +1 @@
1
- export { createSelectorQuery } from '../unsupportedApi'
1
+ export { createSelectorQuery } from '../unsupportedApi'
@@ -1,6 +1,7 @@
1
1
  import Taro from '@tarojs/taro'
2
2
  import { DeviceMotion } from 'expo-sensors'
3
- import { createCallbackManager, successHandler, errorHandler } from '../utils'
3
+
4
+ import { createCallbackManager, errorHandler, successHandler } from '../utils'
4
5
 
5
6
  const _cbManager = createCallbackManager()
6
7
  let _listener: any
@@ -44,7 +45,7 @@ function startDeviceMotionListening (object: Taro.startDeviceMotionListening.Opt
44
45
  _cbManager.trigger(rotation)
45
46
  })
46
47
  DeviceMotion.setUpdateInterval(intervalMap[interval] || intervalMap.normal)
47
-
48
+
48
49
  return successHandler(success, complete)(res)
49
50
  } catch (error) {
50
51
  res.errMsg = 'startDeviceMotionListening:fail'
@@ -71,8 +72,8 @@ function stopDeviceMotionListening (object: Taro.stopDeviceMotionListening.Optio
71
72
  }
72
73
 
73
74
  export {
74
- onDeviceMotionChange,
75
75
  offDeviceMotionChange,
76
+ onDeviceMotionChange,
76
77
  startDeviceMotionListening,
77
78
  stopDeviceMotionListening
78
79
  }
package/src/lib/file.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import * as FileSystem from 'expo-file-system'
2
2
  import { Platform } from 'react-native'
3
- import { shouldBeObject, successHandler, errorHandler } from '../utils'
4
3
 
5
- interface Func{
4
+ import { errorHandler, shouldBeObject, successHandler } from '../utils'
5
+
6
+ interface Func {
6
7
  (arg: any): void
7
8
  }
8
9
 
9
10
  interface ExtPromise<T> extends Promise<T> {
10
- onProgressUpdateCb?: Func,
11
- onProgressUpdate?: Func,
11
+ onProgressUpdateCb?: Func
12
+ onProgressUpdate?: Func
12
13
  abort?: Func
13
14
  }
14
15
 
@@ -339,10 +340,10 @@ async function getFileInfo (opts: Taro.getFileInfo.Option): Promise<Taro.getFile
339
340
 
340
341
  export {
341
342
  downloadFile,
342
- uploadFile,
343
- saveFile,
344
- removeSavedFile,
345
- getSavedFileList,
343
+ getFileInfo,
346
344
  getSavedFileInfo,
347
- getFileInfo
345
+ getSavedFileList,
346
+ removeSavedFile,
347
+ saveFile,
348
+ uploadFile
348
349
  }
@@ -1,4 +1,5 @@
1
1
  import Clipboard from '@react-native-clipboard/clipboard'
2
+
2
3
  import { errorHandler } from '../../utils'
3
4
 
4
5
  export function getClipboardData (opts: Taro.getClipboardData.Option = {}): Promise<Taro.getClipboardData.Promised> {
@@ -2,4 +2,4 @@ import { ENV_TYPE } from '../ENV_TYPE'
2
2
 
3
3
  export function getEnv(): string {
4
4
  return ENV_TYPE.RN
5
- }
5
+ }
@@ -1 +1 @@
1
- export { getFileSystemManager } from '../unsupportedApi'
1
+ export { getFileSystemManager } from '../unsupportedApi'
@@ -1,14 +1,19 @@
1
1
  import Geolocation from '@react-native-community/geolocation'
2
- import { requestForegroundPermissionsAsync } from 'expo-location'
2
+
3
3
  import { errorHandler } from '../../utils'
4
4
 
5
5
  export async function getLocation(opts: Taro.getLocation.Option = {}): Promise<Taro.getLocation.SuccessCallbackResult> {
6
6
  const { isHighAccuracy = false, highAccuracyExpireTime = 3000, success, fail, complete } = opts
7
+ const requestAuthorization = () => {
8
+ return new Promise((resolve, reject) => {
9
+ Geolocation.requestAuthorization(() => resolve({ granted: true }), (err) => reject(err))
10
+ })
11
+ }
7
12
 
8
13
  try {
9
14
  // @ts-ignore
10
15
  // todo: fix types
11
- const { granted } = await requestForegroundPermissionsAsync()
16
+ const { granted } = await requestAuthorization()
12
17
  if (!granted) {
13
18
  const res = { errMsg: 'Permissions denied!' }
14
19
  return errorHandler(fail, complete)(res)