Skip to content

Commit a48c141

Browse files
author
jumiao
committed
Merge branch 'feat/react-native-oh' of https://github.com/wuba/taro-react-native into feat/react-native-oh
2 parents f37a2f3 + 8804a69 commit a48c141

File tree

7 files changed

+123
-39
lines changed

7 files changed

+123
-39
lines changed

packages/taro-components-rn/dep.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
const { parseDependencyTree } = require('dpdm')
3+
const { peerDependencies } = require('./package.json')
4+
5+
const hiddenDependenciesMap = {
6+
'@ant-design/react-native/lib/picker': ['@react-native-picker/picker']
7+
}
8+
9+
const componentReg = /^src\/components\/(\w+)\/index.tsx$/
10+
11+
function parseDependencyCircular(dep = [], tree = {}) {
12+
dep.forEach(d => {
13+
const item = tree[d.id]
14+
if (item) {
15+
dep = dep.concat(parseDependencyCircular(item, tree))
16+
}
17+
})
18+
return dep
19+
}
20+
21+
parseDependencyTree('./src/index.ts', {}).then((tree) => {
22+
const result = {}
23+
Object.keys(tree).map(key => {
24+
const match = key.match(componentReg)
25+
if (match) {
26+
const name = match[1]
27+
parseDependencyCircular(tree[key], tree).map(dependency => {
28+
const dep = dependency.id
29+
if (dep) {
30+
[...Object.keys(peerDependencies), ...Object.keys(hiddenDependenciesMap)].forEach(value => {
31+
if (dep.match(`node_modules/${value}`)) {
32+
result[name] = result[name] || new Set()
33+
if (hiddenDependenciesMap[value]) {
34+
hiddenDependenciesMap[value].forEach(value => {
35+
const showName = peerDependencies[value] ? `${value}@${peerDependencies[value]}` : value
36+
result[name].add(showName)
37+
})
38+
} else {
39+
const showName = peerDependencies[value] ? `${value}@${peerDependencies[value]}` : value
40+
result[name].add(showName)
41+
}
42+
}
43+
})
44+
}
45+
})
46+
}
47+
})
48+
console.log(result)
49+
})

packages/taro-components-rn/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
"devDependencies": {
4242
"@babel/core": "^7.14.5",
4343
"@babel/preset-env": "^7.14.5",
44-
"@react-native/babel-preset": "^0.73.18",
4544
"@react-native-camera-roll/camera-roll": "~7.2.0",
4645
"@react-native-community/segmented-control": "^2.2.2",
46+
"@react-native/babel-preset": "^0.73.18",
4747
"@testing-library/jest-native": "^5.4.2",
4848
"@testing-library/react-native": "^12.4.1",
49+
"dpdm": "^3.14.0",
4950
"expo": "~50.0.2",
5051
"jest": "^29.3.1",
5152
"jest-cli": "^29.3.1",

packages/taro-rn/dep.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
const { parseDependencyTree } = require('dpdm')
3+
const { peerDependencies } = require('./package.json')
4+
5+
const hiddenDependenciesMap = {
6+
'@ant-design/react-native/lib/picker': ['@react-native-picker/picker']
7+
}
8+
9+
const componentReg = /^src\/lib\/(\w+)\/index.tsx?$/
10+
11+
function parseDependencyCircular(dep = [], tree = {}) {
12+
dep.forEach(d => {
13+
const item = tree[d.id]
14+
if (item) {
15+
dep = dep.concat(parseDependencyCircular(item, tree))
16+
}
17+
})
18+
return dep
19+
}
20+
21+
parseDependencyTree('./src/lib/index.ts', {}).then((tree) => {
22+
const result = {}
23+
Object.keys(tree).map(key => {
24+
const match = key.match(componentReg)
25+
if (match) {
26+
const name = match[1]
27+
parseDependencyCircular(tree[key], tree).map(dependency => {
28+
const dep = dependency.id
29+
if (dep) {
30+
[...Object.keys(peerDependencies), ...Object.keys(hiddenDependenciesMap)].forEach(value => {
31+
if (dep.match(`node_modules/${value}`)) {
32+
result[name] = result[name] || new Set()
33+
if (hiddenDependenciesMap[value]) {
34+
hiddenDependenciesMap[value].forEach(value => {
35+
const showName = peerDependencies[value] ? `${value}@${peerDependencies[value]}` : value
36+
result[name].add(showName)
37+
})
38+
} else {
39+
const showName = peerDependencies[value] ? `${value}@${peerDependencies[value]}` : value
40+
result[name].add(showName)
41+
}
42+
}
43+
})
44+
}
45+
})
46+
}
47+
})
48+
console.log(result)
49+
})

packages/taro-rn/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"@testing-library/jest-native": "^5.4.2",
6868
"@testing-library/react-native": "^12.4.1",
6969
"@types/jest": "^27.4.1",
70+
"dpdm": "^3.14.0",
7071
"expo": "~50.0.2",
7172
"fbjs-scripts": "^3.0.1",
7273
"jest": "^29.3.1",

packages/taro-rn/src/lib/getLocation/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import Geolocation from '@react-native-community/geolocation'
2-
import { requestForegroundPermissionsAsync } from 'expo-location'
32
import { errorHandler } from '../../utils'
43

54
export async function getLocation(opts: Taro.getLocation.Option = {}): Promise<Taro.getLocation.SuccessCallbackResult> {
65
const { isHighAccuracy = false, highAccuracyExpireTime = 3000, success, fail, complete } = opts
7-
6+
const requestAuthorization = () => {
7+
return new Promise((resolve, reject) => {
8+
Geolocation.requestAuthorization(()=>resolve({granted: true}), (err)=>reject(err))
9+
})
10+
}
11+
812
try {
913
// @ts-ignore
1014
// todo: fix types
11-
const { granted } = await requestForegroundPermissionsAsync()
15+
const {granted} = await requestAuthorization()
1216
if (!granted) {
1317
const res = { errMsg: 'Permissions denied!' }
1418
return errorHandler(fail, complete)(res)

packages/taro-router-rn/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"author": "yechunxi",
2626
"license": "MIT",
2727
"dependencies": {
28-
"@react-native-masked-view/masked-view": "~0.3.1",
2928
"@react-navigation/bottom-tabs": "^6.5.5",
3029
"@react-navigation/native": "^6.1.4",
3130
"@react-navigation/native-stack": "^6.9.10",
@@ -44,7 +43,6 @@
4443
"react-native": "^0.73.1"
4544
},
4645
"peerDependencies": {
47-
"@react-native-masked-view/masked-view": "~0.3.1",
4846
"react-native-gesture-handler": "~2.14.0",
4947
"react-native-safe-area-context": "~4.8.0",
5048
"react-native-screens": "^3.29.0"

pnpm-lock.yaml

Lines changed: 15 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)