From 6e186bb81a5d76c02f67fba64f77ba95e86ef932 Mon Sep 17 00:00:00 2001 From: tony chen Date: Wed, 20 Mar 2024 14:14:44 +0800 Subject: [PATCH 1/2] feat(rn): remove unused masked-view --- packages/taro-router-rn/package.json | 2 -- pnpm-lock.yaml | 48 +++++++++------------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/packages/taro-router-rn/package.json b/packages/taro-router-rn/package.json index 95149cba9472..2516501e7b39 100644 --- a/packages/taro-router-rn/package.json +++ b/packages/taro-router-rn/package.json @@ -25,7 +25,6 @@ "author": "yechunxi", "license": "MIT", "dependencies": { - "@react-native-masked-view/masked-view": "~0.3.1", "@react-navigation/bottom-tabs": "^6.5.5", "@react-navigation/native": "^6.1.4", "@react-navigation/native-stack": "^6.9.10", @@ -44,7 +43,6 @@ "react-native": "^0.73.1" }, "peerDependencies": { - "@react-native-masked-view/masked-view": "~0.3.1", "react-native-gesture-handler": "~2.14.0", "react-native-safe-area-context": "~4.8.0", "react-native-screens": "^3.29.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 50a604a4d5d7..8b8b60e85585 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3198,9 +3198,6 @@ importers: packages/taro-router-rn: dependencies: - '@react-native-masked-view/masked-view': - specifier: ~0.3.1 - version: registry.npmjs.org/@react-native-masked-view/masked-view@0.3.1(react-native@0.73.2)(react@18.2.0) '@react-navigation/bottom-tabs': specifier: ^6.5.5 version: registry.npmjs.org/@react-navigation/bottom-tabs@6.5.7(@react-navigation/native@6.1.6)(react-native-safe-area-context@4.8.2)(react-native-screens@3.29.0)(react-native@0.73.2)(react@18.2.0) @@ -6690,6 +6687,17 @@ packages: /glob-to-regexp@0.4.1: resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==, tarball: https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz} + /glob@6.0.4: + resolution: {integrity: sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==, tarball: https://registry.npmjs.org/glob/-/glob-6.0.4.tgz} + requiresBuild: true + dependencies: + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 3.1.2 + once: 1.4.0 + path-is-absolute: 1.0.1 + optional: true + /glob@7.1.6: resolution: {integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==, tarball: https://registry.npmjs.org/glob/-/glob-7.1.6.tgz} dependencies: @@ -7409,8 +7417,8 @@ packages: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==, tarball: https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz} dev: true - /miniprogram-compiler@0.2.2: - resolution: {integrity: sha512-fiJXv/15jCcRAU8YKcO7S7fkPKLa5ZBgpLN+d6B3r3KMktM5tAkDEQ+zm6aTfNoHurYOHcRyPyGf26gqQXlFXg==, tarball: https://registry.npmjs.org/miniprogram-compiler/-/miniprogram-compiler-0.2.2.tgz} + /miniprogram-compiler@0.2.3: + resolution: {integrity: sha512-/MfFiXTBUwYxnrTbj1hgwk1+qGkMCTL1zi8IReOq/0SPVkUxpx19E89w+ohYCELFXkMfVbD+6ejrHh3Y1u5sVg==, tarball: https://registry.npmjs.org/miniprogram-compiler/-/miniprogram-compiler-0.2.3.tgz} dependencies: glob: 7.2.3 unescape-js: 1.1.4 @@ -16655,19 +16663,6 @@ packages: version: 4.4.4 dev: false - registry.npmjs.org/@react-native-masked-view/masked-view@0.3.1(react-native@0.73.2)(react@18.2.0): - resolution: {integrity: sha512-uVm8U6nwFIlUd1iDIB5cS+lDadApKR+l8k4k84d9hn+GN4lzAIJhUZ9syYX7c022MxNgAlbxoFLt0pqKoyaAGg==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/@react-native-masked-view/masked-view/-/masked-view-0.3.1.tgz} - id: registry.npmjs.org/@react-native-masked-view/masked-view/0.3.1 - name: '@react-native-masked-view/masked-view' - version: 0.3.1 - peerDependencies: - react: '>=16' - react-native: '>=0.57' - dependencies: - react: registry.npmjs.org/react@18.2.0 - react-native: registry.npmjs.org/react-native@0.73.2(@babel/core@7.21.8)(@babel/preset-env@7.21.5)(react@18.2.0) - dev: false - registry.npmjs.org/@react-native-picker/picker@2.6.1(react-native@0.73.2)(react@18.2.0): resolution: {integrity: sha512-oJftvmLOj6Y6/bF4kPcK6L83yNBALGmqNYugf94BzP0FQGpHBwimVN2ygqkQ2Sn2ZU3pGUZMs0jV6+Gku2GyYg==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/@react-native-picker/picker/-/picker-2.6.1.tgz} id: registry.npmjs.org/@react-native-picker/picker/2.6.1 @@ -29291,19 +29286,6 @@ packages: path-scurry: registry.npmjs.org/path-scurry@1.7.0 dev: false - registry.npmjs.org/glob@6.0.4: - resolution: {integrity: sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/glob/-/glob-6.0.4.tgz} - name: glob - version: 6.0.4 - requiresBuild: true - dependencies: - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - optional: true - registry.npmjs.org/glob@7.1.2: resolution: {integrity: sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==, registry: https://registry.yarnpkg.com/, tarball: https://registry.npmjs.org/glob/-/glob-7.1.2.tgz} name: glob @@ -35608,7 +35590,7 @@ packages: csso: registry.npmjs.org/csso@3.5.1 j-component: registry.npmjs.org/j-component@1.4.9 less: registry.npmjs.org/less@3.13.1 - miniprogram-compiler: 0.2.2 + miniprogram-compiler: 0.2.3 postcss: registry.npmjs.org/postcss@7.0.39 dev: false @@ -40658,7 +40640,7 @@ packages: hasBin: true requiresBuild: true dependencies: - glob: registry.npmjs.org/glob@6.0.4 + glob: 6.0.4 optional: true registry.npmjs.org/rimraf@2.6.3: From 8804a697a441dcb6369056f5d639aa17a3a4affc Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 22 Mar 2024 10:34:57 +0800 Subject: [PATCH 2/2] feat: getLocation's Authorization changeto @react-native-community/geolocation (#266) --- packages/taro-components-rn/dep.js | 49 +++++++++++++++++++ packages/taro-components-rn/package.json | 3 +- packages/taro-rn/dep.js | 49 +++++++++++++++++++ packages/taro-rn/package.json | 1 + packages/taro-rn/src/lib/getLocation/index.ts | 10 ++-- 5 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 packages/taro-components-rn/dep.js create mode 100644 packages/taro-rn/dep.js diff --git a/packages/taro-components-rn/dep.js b/packages/taro-components-rn/dep.js new file mode 100644 index 000000000000..6bba4b471951 --- /dev/null +++ b/packages/taro-components-rn/dep.js @@ -0,0 +1,49 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const { parseDependencyTree } = require('dpdm') +const { peerDependencies } = require('./package.json') + +const hiddenDependenciesMap = { + '@ant-design/react-native/lib/picker': ['@react-native-picker/picker'] +} + +const componentReg = /^src\/components\/(\w+)\/index.tsx$/ + +function parseDependencyCircular(dep = [], tree = {}) { + dep.forEach(d => { + const item = tree[d.id] + if (item) { + dep = dep.concat(parseDependencyCircular(item, tree)) + } + }) + return dep +} + +parseDependencyTree('./src/index.ts', {}).then((tree) => { + const result = {} + Object.keys(tree).map(key => { + const match = key.match(componentReg) + if (match) { + const name = match[1] + parseDependencyCircular(tree[key], tree).map(dependency => { + const dep = dependency.id + if (dep) { + [...Object.keys(peerDependencies), ...Object.keys(hiddenDependenciesMap)].forEach(value => { + if (dep.match(`node_modules/${value}`)) { + result[name] = result[name] || new Set() + if (hiddenDependenciesMap[value]) { + hiddenDependenciesMap[value].forEach(value => { + const showName = peerDependencies[value] ? `${value}@${peerDependencies[value]}` : value + result[name].add(showName) + }) + } else { + const showName = peerDependencies[value] ? `${value}@${peerDependencies[value]}` : value + result[name].add(showName) + } + } + }) + } + }) + } + }) + console.log(result) +}) diff --git a/packages/taro-components-rn/package.json b/packages/taro-components-rn/package.json index 81f69f886a77..5199ccac6bb5 100644 --- a/packages/taro-components-rn/package.json +++ b/packages/taro-components-rn/package.json @@ -41,11 +41,12 @@ "devDependencies": { "@babel/core": "^7.14.5", "@babel/preset-env": "^7.14.5", - "@react-native/babel-preset": "^0.73.18", "@react-native-camera-roll/camera-roll": "~7.2.0", "@react-native-community/segmented-control": "^2.2.2", + "@react-native/babel-preset": "^0.73.18", "@testing-library/jest-native": "^5.4.2", "@testing-library/react-native": "^12.4.1", + "dpdm": "^3.14.0", "expo": "~50.0.2", "jest": "^29.3.1", "jest-cli": "^29.3.1", diff --git a/packages/taro-rn/dep.js b/packages/taro-rn/dep.js new file mode 100644 index 000000000000..5b056e3d22bd --- /dev/null +++ b/packages/taro-rn/dep.js @@ -0,0 +1,49 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const { parseDependencyTree } = require('dpdm') +const { peerDependencies } = require('./package.json') + +const hiddenDependenciesMap = { + '@ant-design/react-native/lib/picker': ['@react-native-picker/picker'] +} + +const componentReg = /^src\/lib\/(\w+)\/index.tsx?$/ + +function parseDependencyCircular(dep = [], tree = {}) { + dep.forEach(d => { + const item = tree[d.id] + if (item) { + dep = dep.concat(parseDependencyCircular(item, tree)) + } + }) + return dep +} + +parseDependencyTree('./src/lib/index.ts', {}).then((tree) => { + const result = {} + Object.keys(tree).map(key => { + const match = key.match(componentReg) + if (match) { + const name = match[1] + parseDependencyCircular(tree[key], tree).map(dependency => { + const dep = dependency.id + if (dep) { + [...Object.keys(peerDependencies), ...Object.keys(hiddenDependenciesMap)].forEach(value => { + if (dep.match(`node_modules/${value}`)) { + result[name] = result[name] || new Set() + if (hiddenDependenciesMap[value]) { + hiddenDependenciesMap[value].forEach(value => { + const showName = peerDependencies[value] ? `${value}@${peerDependencies[value]}` : value + result[name].add(showName) + }) + } else { + const showName = peerDependencies[value] ? `${value}@${peerDependencies[value]}` : value + result[name].add(showName) + } + } + }) + } + }) + } + }) + console.log(result) +}) diff --git a/packages/taro-rn/package.json b/packages/taro-rn/package.json index f739c251ba12..f50f5422d34c 100644 --- a/packages/taro-rn/package.json +++ b/packages/taro-rn/package.json @@ -67,6 +67,7 @@ "@testing-library/jest-native": "^5.4.2", "@testing-library/react-native": "^12.4.1", "@types/jest": "^27.4.1", + "dpdm": "^3.14.0", "expo": "~50.0.2", "fbjs-scripts": "^3.0.1", "jest": "^29.3.1", diff --git a/packages/taro-rn/src/lib/getLocation/index.ts b/packages/taro-rn/src/lib/getLocation/index.ts index bd088f3ac9d6..042421bd6ef2 100644 --- a/packages/taro-rn/src/lib/getLocation/index.ts +++ b/packages/taro-rn/src/lib/getLocation/index.ts @@ -1,14 +1,18 @@ import Geolocation from '@react-native-community/geolocation' -import { requestForegroundPermissionsAsync } from 'expo-location' import { errorHandler } from '../../utils' export async function getLocation(opts: Taro.getLocation.Option = {}): Promise { const { isHighAccuracy = false, highAccuracyExpireTime = 3000, success, fail, complete } = opts - + const requestAuthorization = () => { + return new Promise((resolve, reject) => { + Geolocation.requestAuthorization(()=>resolve({granted: true}), (err)=>reject(err)) + }) + } + try { // @ts-ignore // todo: fix types - const { granted } = await requestForegroundPermissionsAsync() + const {granted} = await requestAuthorization() if (!granted) { const res = { errMsg: 'Permissions denied!' } return errorHandler(fail, complete)(res)