@tarojs/taro-rn 4.0.0-beta.74 → 4.0.0-beta.76

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 (182) hide show
  1. package/LICENSE +1 -8
  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 +3 -3
  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/chooseMedia/index.js.map +1 -1
  14. package/dist/lib/clearStorage/index.js +2 -2
  15. package/dist/lib/clearStorage/index.js.map +1 -1
  16. package/dist/lib/compressImage/index.js +1 -1
  17. package/dist/lib/compressImage/index.js.map +1 -1
  18. package/dist/lib/connectSocket/index.js.map +1 -1
  19. package/dist/lib/connectSocket/socketTask.js +1 -1
  20. package/dist/lib/connectSocket/socketTask.js.map +1 -1
  21. package/dist/lib/createCameraContext/index.js +3 -3
  22. package/dist/lib/createCameraContext/index.js.map +1 -1
  23. package/dist/lib/createInnerAudioContext/index.js +2 -2
  24. package/dist/lib/createInnerAudioContext/index.js.map +1 -1
  25. package/dist/lib/createVideoContext/index.js +7 -7
  26. package/dist/lib/createVideoContext/index.js.map +1 -1
  27. package/dist/lib/deviceMotion.js +2 -2
  28. package/dist/lib/deviceMotion.js.map +1 -1
  29. package/dist/lib/file.js +4 -4
  30. package/dist/lib/file.js.map +1 -1
  31. package/dist/lib/getAppBaseInfo/index.js +2 -2
  32. package/dist/lib/getAppBaseInfo/index.js.map +1 -1
  33. package/dist/lib/getClipboardData/index.js.map +1 -1
  34. package/dist/lib/getImageInfo/index.js +2 -2
  35. package/dist/lib/getImageInfo/index.js.map +1 -1
  36. package/dist/lib/getLocation/index.js +2 -2
  37. package/dist/lib/getLocation/index.js.map +1 -1
  38. package/dist/lib/getRecorderManager/index.js +5 -5
  39. package/dist/lib/getRecorderManager/index.js.map +1 -1
  40. package/dist/lib/getStorage/index.js.map +1 -1
  41. package/dist/lib/getStorageInfo/index.js +2 -2
  42. package/dist/lib/getStorageInfo/index.js.map +1 -1
  43. package/dist/lib/getSystemInfo/index.js +1 -1
  44. package/dist/lib/getSystemInfo/index.js.map +1 -1
  45. package/dist/lib/getSystemInfoSync/index.js +2 -2
  46. package/dist/lib/getSystemInfoSync/index.js.map +1 -1
  47. package/dist/lib/gyroscope.js +1 -1
  48. package/dist/lib/gyroscope.js.map +1 -1
  49. package/dist/lib/keyboard.js +3 -3
  50. package/dist/lib/keyboard.js.map +1 -1
  51. package/dist/lib/location.js.map +1 -1
  52. package/dist/lib/makePhoneCall/index.js +1 -1
  53. package/dist/lib/makePhoneCall/index.js.map +1 -1
  54. package/dist/lib/media.js +15 -13
  55. package/dist/lib/media.js.map +1 -1
  56. package/dist/lib/network.js +1 -1
  57. package/dist/lib/network.js.map +1 -1
  58. package/dist/lib/offWindowResize/index.js.map +1 -1
  59. package/dist/lib/onWindowResize/index.js +1 -1
  60. package/dist/lib/onWindowResize/index.js.map +1 -1
  61. package/dist/lib/openUrl/index.js +1 -1
  62. package/dist/lib/openUrl/index.js.map +1 -1
  63. package/dist/lib/permission.js +6 -5
  64. package/dist/lib/permission.js.map +1 -1
  65. package/dist/lib/previewImage/index.js +3 -3
  66. package/dist/lib/previewImage/index.js.map +1 -1
  67. package/dist/lib/request/index.js +1 -1
  68. package/dist/lib/request/index.js.map +1 -1
  69. package/dist/lib/scanCode/index.js +22 -22
  70. package/dist/lib/scanCode/index.js.map +1 -1
  71. package/dist/lib/screen.js +2 -2
  72. package/dist/lib/screen.js.map +1 -1
  73. package/dist/lib/setClipboardData/index.js +2 -2
  74. package/dist/lib/setClipboardData/index.js.map +1 -1
  75. package/dist/lib/setKeepScreenOn/index.js +1 -1
  76. package/dist/lib/setKeepScreenOn/index.js.map +1 -1
  77. package/dist/lib/setStorage/index.js.map +1 -1
  78. package/dist/lib/showActionSheet/ActionSheet.js +3 -3
  79. package/dist/lib/showActionSheet/ActionSheet.js.map +1 -1
  80. package/dist/lib/showActionSheet/index.js.map +1 -1
  81. package/dist/lib/showModal/Dialog.js +3 -3
  82. package/dist/lib/showModal/Dialog.js.map +1 -1
  83. package/dist/lib/showModal/index.js.map +1 -1
  84. package/dist/lib/showModal/toast.js +6 -6
  85. package/dist/lib/showModal/toast.js.map +1 -1
  86. package/dist/lib/unsupportedApi.js +2 -4
  87. package/dist/lib/unsupportedApi.js.map +1 -1
  88. package/dist/lib/variable.js +1 -1
  89. package/dist/lib/variable.js.map +1 -1
  90. package/dist/lib/vibrate.js +1 -1
  91. package/dist/lib/vibrate.js.map +1 -1
  92. package/dist/lib/window.js.map +1 -1
  93. package/dist/utils/callbackManager.js.map +1 -1
  94. package/dist/utils/index.js.map +1 -1
  95. package/package.json +65 -60
  96. package/src/api/index.ts +31 -31
  97. package/src/lib/ENV_TYPE/index.ts +1 -1
  98. package/src/lib/Mask.tsx +2 -2
  99. package/src/lib/Popup.tsx +8 -6
  100. package/src/lib/StyleSheet.ts +1 -1
  101. package/src/lib/accelerometer.ts +2 -1
  102. package/src/lib/arrayBufferToBase64/index.ts +1 -1
  103. package/src/lib/base64ToArrayBuffer/index.ts +1 -1
  104. package/src/lib/chooseMedia/index.ts +1 -1
  105. package/src/lib/clearStorage/index.ts +1 -0
  106. package/src/lib/clearStorageSync/index.ts +1 -1
  107. package/src/lib/compressImage/index.ts +1 -0
  108. package/src/lib/connectSocket/socketTask.ts +7 -9
  109. package/src/lib/createCameraContext/index.ts +6 -4
  110. package/src/lib/createInnerAudioContext/index.ts +1 -0
  111. package/src/lib/createSelectorQuery/index.ts +1 -1
  112. package/src/lib/deviceMotion.ts +4 -3
  113. package/src/lib/file.ts +9 -8
  114. package/src/lib/getClipboardData/index.ts +1 -0
  115. package/src/lib/getEnv/index.ts +1 -1
  116. package/src/lib/getFileSystemManager/index.ts +1 -1
  117. package/src/lib/getLocation/index.ts +4 -3
  118. package/src/lib/getRecorderManager/index.ts +1 -1
  119. package/src/lib/getStorage/index.ts +1 -0
  120. package/src/lib/getStorageInfo/index.ts +1 -0
  121. package/src/lib/getStorageInfoSync/index.ts +1 -1
  122. package/src/lib/getStorageSync/index.ts +1 -1
  123. package/src/lib/getSystemInfo/index.ts +2 -2
  124. package/src/lib/getSystemInfoSync/index.ts +3 -3
  125. package/src/lib/gyroscope.ts +47 -46
  126. package/src/lib/keyboard.ts +5 -4
  127. package/src/lib/location.ts +6 -5
  128. package/src/lib/makePhoneCall/index.ts +2 -1
  129. package/src/lib/media.ts +21 -18
  130. package/src/lib/network.ts +5 -5
  131. package/src/lib/offLocationChange/index.ts +1 -1
  132. package/src/lib/offUserCaptureScreen/index.ts +1 -1
  133. package/src/lib/onLocationChange/index.ts +1 -1
  134. package/src/lib/onUserCaptureScreen/index.ts +1 -1
  135. package/src/lib/onWindowResize/index.ts +2 -2
  136. package/src/lib/openUrl/index.d.ts +23 -22
  137. package/src/lib/openUrl/index.ts +2 -1
  138. package/src/lib/permission.ts +33 -25
  139. package/src/lib/previewImage/index.tsx +4 -3
  140. package/src/lib/removeStorageSync/index.ts +1 -1
  141. package/src/lib/request/index.ts +2 -2
  142. package/src/lib/scanCode/index.tsx +17 -15
  143. package/src/lib/screen.ts +1 -0
  144. package/src/lib/setClipboardData/index.ts +3 -2
  145. package/src/lib/setKeepScreenOn/index.ts +2 -1
  146. package/src/lib/setStorage/index.ts +1 -0
  147. package/src/lib/setStorageSync/index.ts +1 -1
  148. package/src/lib/showActionSheet/ActionSheet.tsx +7 -6
  149. package/src/lib/showActionSheet/index.tsx +1 -0
  150. package/src/lib/showModal/Dialog.tsx +7 -6
  151. package/src/lib/showModal/index.tsx +1 -0
  152. package/src/lib/showModal/toast.tsx +12 -11
  153. package/src/lib/startGyroscope/index.ts +1 -1
  154. package/src/lib/startLocationUpdate/index.ts +1 -1
  155. package/src/lib/unsupportedApi.ts +3 -5
  156. package/src/lib/vibrate.ts +11 -10
  157. package/src/lib/window.ts +3 -2
  158. package/src/utils/callbackManager.ts +5 -5
  159. package/src/utils/index.ts +4 -4
  160. package/{src/types → types}/vue/index.d.ts +2 -3
  161. package/dist/setup.js +0 -58
  162. package/dist/setup.js.map +0 -1
  163. package/src/__tests__/__mock__/mockRNCCameraRoll.js +0 -7
  164. package/src/__tests__/__mock__/mockRNCGeolocation.js +0 -13
  165. package/src/__tests__/__snapshots__/scanCode.test.tsx.snap +0 -154
  166. package/src/__tests__/clipboard.test.ts +0 -88
  167. package/src/__tests__/deviceMotion.test.ts +0 -37
  168. package/src/__tests__/geolocation.test.ts +0 -60
  169. package/src/__tests__/interactive.test.tsx +0 -101
  170. package/src/__tests__/keyboard.test.ts +0 -46
  171. package/src/__tests__/media.test.ts +0 -104
  172. package/src/__tests__/network.test.ts +0 -57
  173. package/src/__tests__/others.test.ts +0 -25
  174. package/src/__tests__/phone.test.ts +0 -31
  175. package/src/__tests__/request.test.ts +0 -146
  176. package/src/__tests__/scanCode.test.tsx +0 -14
  177. package/src/__tests__/storage.test.ts +0 -202
  178. package/src/__tests__/system.test.ts +0 -69
  179. package/src/__tests__/vibrate.test.ts +0 -27
  180. package/src/__tests__/websocket.test.ts +0 -170
  181. package/src/setup.ts +0 -64
  182. /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-beta.74",
3
+ "version": "4.0.0-beta.76",
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,80 +20,83 @@
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-beta.74"
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-beta.76",
50
+ "@tarojs/taro": "4.0.0-beta.76"
51
51
  },
52
52
  "devDependencies": {
53
- "@babel/core": "^7.23.0",
54
- "@babel/preset-env": "^7.20.0",
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",
60
+ "cpy-cli": "^5.0.0",
59
61
  "dpdm": "^3.14.0",
60
- "expo": "~50.0.2",
61
- "fbjs-scripts": "^3.0.1",
62
- "jest": "^29.3.1",
63
- "jest-cli": "^29.3.1",
64
- "jest-environment-node": "^29.5.0",
65
- "jest-expo": "^50.0.0",
62
+ "expo": "~51.0.5",
63
+ "jest-expo": "^51.0.1",
66
64
  "mock-socket": "^7.1.0",
67
- "react": "18.2.0",
68
- "react-native": "^0.73.1",
69
- "react-test-renderer": "18.2.0"
65
+ "react": "^18.2.0",
66
+ "react-native": "^0.72.3"
70
67
  },
71
68
  "peerDependencies": {
72
- "@bam.tech/react-native-image-resizer": "~3.0.5",
73
- "@react-native-async-storage/async-storage": "~1.21.0",
74
- "@react-native-camera-roll/camera-roll": "~7.2.0",
75
- "@react-native-clipboard/clipboard": "~1.13.0",
76
- "@react-native-community/geolocation": "~3.1.0",
77
- "@react-native-community/netinfo": "~11.2.0",
78
- "expo-av": "~13.10.0",
79
- "expo-barcode-scanner": "~12.9.0",
80
- "expo-brightness": "~11.8.0",
81
- "expo-camera": "~14.0.0",
82
- "expo-file-system": "~16.0.0",
83
- "expo-image-picker": "~14.7.0",
84
- "expo-keep-awake": "~12.8.0",
85
- "expo-location": "~16.5.1",
86
- "expo-sensors": "~12.9.0",
87
- "react-native-device-info": "~10.12.0",
88
- "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"
89
91
  },
90
92
  "scripts": {
93
+ "prod": "pnpm run build",
91
94
  "assets": "cpy 'src/**/*.png' '!src/__tests__/*' dist",
92
- "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",
93
98
  "dev": "pnpm run assets && tsc --watch",
94
- "lint": "eslint .",
99
+ "lint": "eslint src script __tests__ --ext .js,.jsx.ts,.tsx",
95
100
  "test": "jest --silent",
96
101
  "test:ci": "jest --ci -i --coverage --silent",
97
102
  "test:coverage": "jest --coverage",
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> {
@@ -53,9 +53,11 @@ class Popup extends Component<any, any> {
53
53
  }).start(() => this.setState({ visible: false }))
54
54
  }
55
55
  }
56
+
56
57
  componentWillUnmount (): void {
57
- this.timer && clearTimeout(this.timer);
58
+ this.timer && clearTimeout(this.timer)
58
59
  }
60
+
59
61
  handleLayout (): void {
60
62
  this.timer = setTimeout(() => {
61
63
  this.popup?.measure((_x, _y, _w, h) => {
@@ -69,7 +71,7 @@ class Popup extends Component<any, any> {
69
71
  }).start()
70
72
  })
71
73
  })
72
- },); // 处理鸿蒙系统handleLayout 回调 this.popup为空的情况
74
+ },) // 处理鸿蒙系统handleLayout 回调 this.popup为空的情况
73
75
  }
74
76
 
75
77
  render (): JSX.Element {
@@ -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
+ }
@@ -12,4 +12,4 @@ export function chooseMedia (opts: Taro.chooseMedia.Option): Promise<any> {
12
12
  } else {
13
13
  return _chooseMedia(opts, MEDIA_TYPE.All)
14
14
  }
15
- }
15
+ }
@@ -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'
3
+
4
+ import { errorHandler, shouldBeObject, successHandler } from '../utils'
4
5
 
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,18 +1,19 @@
1
1
  import Geolocation from '@react-native-community/geolocation'
2
+
2
3
  import { errorHandler } from '../../utils'
3
4
 
4
5
  export async function getLocation(opts: Taro.getLocation.Option = {}): Promise<Taro.getLocation.SuccessCallbackResult> {
5
6
  const { isHighAccuracy = false, highAccuracyExpireTime = 3000, success, fail, complete } = opts
6
7
  const requestAuthorization = () => {
7
8
  return new Promise((resolve, reject) => {
8
- Geolocation.requestAuthorization(()=>resolve({granted: true}), (err)=>reject(err))
9
+ Geolocation.requestAuthorization(() => resolve({ granted: true }), (err) => reject(err))
9
10
  })
10
11
  }
11
-
12
+
12
13
  try {
13
14
  // @ts-ignore
14
15
  // todo: fix types
15
- const {granted} = await requestAuthorization()
16
+ const { granted } = await requestAuthorization()
16
17
  if (!granted) {
17
18
  const res = { errMsg: 'Permissions denied!' }
18
19
  return errorHandler(fail, complete)(res)
@@ -81,7 +81,7 @@ class RecorderManager {
81
81
  playsInSilentModeIOS: true,
82
82
  staysActiveInBackground: false,
83
83
  shouldDuckAndroid: true,
84
- interruptionModeAndroid: 1, //InterruptionModeAndroid.DoNotMix
84
+ interruptionModeAndroid: 1, // InterruptionModeAndroid.DoNotMix
85
85
  playThroughEarpieceAndroid: true
86
86
  } as any)
87
87
 
@@ -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 getStorage(option: Taro.getStorage.Option<any>): Promise<Taro.getStorage.SuccessCallbackResult<any>> {
@@ -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
  async function getStorageCurrentSize() {
@@ -1 +1 @@
1
- export { getStorageInfoSync } from '../unsupportedApi'
1
+ export { getStorageInfoSync } from '../unsupportedApi'
@@ -1 +1 @@
1
- export { getStorageSync } from '../unsupportedApi'
1
+ export { getStorageSync } from '../unsupportedApi'
@@ -1,7 +1,7 @@
1
+ import { errorHandler, successHandler } from '../../utils'
1
2
  import { getSystemInfoSync } from '../getSystemInfoSync'
2
- import { successHandler, errorHandler } from '../../utils'
3
3
 
4
- export function getSystemInfo(opts: Taro.getSystemInfo.Option = {}): Promise<Taro.getSystemInfo.Result> {
4
+ export function getSystemInfo(opts: Taro.getSystemInfo.Option = {}): Promise<Taro.getSystemInfo.Result> {
5
5
  const { success, fail, complete }: any = opts
6
6
  try {
7
7
  const res = {
@@ -1,11 +1,11 @@
1
1
  import {
2
- Platform,
3
2
  Dimensions,
4
3
  PixelRatio,
4
+ Platform,
5
5
  StatusBar
6
6
  } from 'react-native'
7
- import { initialWindowMetrics } from 'react-native-safe-area-context'
8
7
  import DeviceInfo from 'react-native-device-info'
8
+ import { initialWindowMetrics } from 'react-native-safe-area-context'
9
9
 
10
10
  export function getSystemInfoSync(): Taro.getSystemInfoSync.Result {
11
11
  const res: any = {}
@@ -28,7 +28,7 @@ export function getSystemInfoSync(): Taro.getSystemInfoSync.Result {
28
28
  let { top = 0, bottom = 0 } = initialWindowMetrics?.insets || {}
29
29
  // NOTE:android 在沉浸式切换时,有几率top值为0。
30
30
  // https://github.com/th3rdwave/react-native-safe-area-context/issues/364
31
- if(Platform.OS === 'android') { top = StatusBar.currentHeight || 0; }
31
+ if (Platform.OS === 'android') { top = StatusBar.currentHeight || 0 }
32
32
 
33
33
  try {
34
34
  const W = Math.min(screenWidth, screenHeight)