From c3d749d42753fc5ea4c39f072970576c1f853c25 Mon Sep 17 00:00:00 2001 From: tony chen <329604487@qq.com> Date: Thu, 7 Nov 2024 10:57:51 +0800 Subject: [PATCH] Feat/rn73 (#16807) * feat: native libs version check * feat: rimraf * fix: build & test error * fix: stylelint version * upgrade linaria to latest version (#16747) * upgrade linaria to latest version * use className instead style * format * restore * use space instead of tab * tweak for submit fail * t --------- Co-authored-by: Administrator * fix(rn): undefinde error --------- Co-authored-by: f Co-authored-by: Administrator --- .../package.json | 2 +- .../package.json | 2 +- packages/babel-preset-taro/package.json | 1 - packages/babel-preset-taro/rn/index.js | 4 - packages/create-app/package.json | 2 +- packages/css-to-react-native/package.json | 2 +- packages/jest-helper/package.json | 2 +- packages/postcss-html-transform/package.json | 2 +- packages/rollup-plugin-copy/package.json | 2 +- packages/shared/package.json | 2 +- packages/stylelint-taro-rn/package.json | 5 +- packages/stylelint-taro/package.json | 2 +- packages/taro-cli-convertor/package.json | 2 +- packages/taro-cli/package.json | 2 +- .../taro-components-advanced/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../taro-components-library-vue3/package.json | 2 +- packages/taro-components-rn/package.json | 45 +- .../src/components/Camera/index.tsx | 32 +- packages/taro-framework-react/package.json | 2 +- packages/taro-framework-solid/package.json | 2 +- packages/taro-h5/package.json | 2 +- packages/taro-helper/package.json | 2 +- packages/taro-platform-h5/package.json | 2 +- packages/taro-rn-runner/package.json | 14 +- .../taro-rn-style-transformer/package.json | 2 +- packages/taro-rn-supporter/package.json | 4 +- packages/taro-rn-transformer/package.json | 2 +- packages/taro-rn-transformer/src/component.ts | 2 +- packages/taro-rn-transformer/src/utils.ts | 45 +- .../__snapshots__/scanCode.test.tsx.snap | 18 +- packages/taro-rn/package.json | 92 +- packages/taro-rn/src/lib/openUrl/index.d.ts | 25 - packages/taro-rn/src/lib/openUrl/index.ts | 17 +- packages/taro-rn/src/lib/scanCode/index.tsx | 16 +- packages/taro-rn/types/index.d.ts | 1 - packages/taro-router-rn/package.json | 22 +- packages/taro-router/package.json | 2 +- packages/taro-runtime-rn/package.json | 4 +- packages/taro-runtime-rn/src/app.tsx | 2 +- packages/taro-runtime/package.json | 2 +- packages/taro-service/package.json | 2 +- packages/taro-webpack5-prebundle/package.json | 2 +- packages/taro-webpack5-runner/package.json | 2 +- pnpm-lock.yaml | 2017 ++++++++--------- 46 files changed, 1122 insertions(+), 1298 deletions(-) delete mode 100644 packages/taro-rn/src/lib/openUrl/index.d.ts diff --git a/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json b/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json index 368312f6ba79..22ed5420235f 100644 --- a/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json +++ b/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json @@ -8,7 +8,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "test": "jest", "test:ci": "jest --ci -i --coverage --silent", "dev": "tsc -w", diff --git a/packages/babel-plugin-transform-taroapi/package.json b/packages/babel-plugin-transform-taroapi/package.json index d1ba60a4b45e..1a87d76d2b66 100644 --- a/packages/babel-plugin-transform-taroapi/package.json +++ b/packages/babel-plugin-transform-taroapi/package.json @@ -7,7 +7,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "tsc", "test": "cross-env NODE_ENV=jest jest", "test:ci": "cross-env NODE_ENV=jest jest --ci -i --coverage --silent", diff --git a/packages/babel-preset-taro/package.json b/packages/babel-preset-taro/package.json index d03e29110944..e2ac88d2ddf1 100644 --- a/packages/babel-preset-taro/package.json +++ b/packages/babel-preset-taro/package.json @@ -36,7 +36,6 @@ "@rnx-kit/babel-preset-metro-react-native": "^1.1.8", "@tarojs/helper": "workspace:*", "babel-plugin-dynamic-import-node": "^2.3.3", - "babel-plugin-minify-dead-code-elimination": "^0.5.2", "babel-plugin-transform-imports-api": "1.0.0", "babel-plugin-transform-solid-jsx": "workspace:*", "core-js": "^3.36.1" diff --git a/packages/babel-preset-taro/rn/index.js b/packages/babel-preset-taro/rn/index.js index 6c27266d05e6..aa0652871ee5 100644 --- a/packages/babel-preset-taro/rn/index.js +++ b/packages/babel-preset-taro/rn/index.js @@ -55,10 +55,6 @@ module.exports = (_, options = {}) => { plugins.push(require('../remove-define-config')) - plugins.push( - [require('babel-plugin-minify-dead-code-elimination'), {}] - ) - return { presets, plugins diff --git a/packages/create-app/package.json b/packages/create-app/package.json index 003edee8ce4f..c0ba3dd3733c 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -8,7 +8,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "dev": "tsc -w", "build": "tsc" }, diff --git a/packages/css-to-react-native/package.json b/packages/css-to-react-native/package.json index a34028fb82a1..1e16e4cd0727 100644 --- a/packages/css-to-react-native/package.json +++ b/packages/css-to-react-native/package.json @@ -14,7 +14,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "babel src --ignore *.spec.js --out-dir ./dist", "test": "jest" }, diff --git a/packages/jest-helper/package.json b/packages/jest-helper/package.json index a4029482ab0b..dc8f29459cd5 100644 --- a/packages/jest-helper/package.json +++ b/packages/jest-helper/package.json @@ -12,7 +12,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./lib", + "clean": "rimraf ./lib", "build": "tsc", "dev": "tsc -w" }, diff --git a/packages/postcss-html-transform/package.json b/packages/postcss-html-transform/package.json index 941b2688a68d..47709435d527 100644 --- a/packages/postcss-html-transform/package.json +++ b/packages/postcss-html-transform/package.json @@ -16,7 +16,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "tsc", "dev": "tsc -w" }, diff --git a/packages/rollup-plugin-copy/package.json b/packages/rollup-plugin-copy/package.json index f401ca17a99b..8e3c3a1d68d6 100644 --- a/packages/rollup-plugin-copy/package.json +++ b/packages/rollup-plugin-copy/package.json @@ -12,7 +12,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./lib", + "clean": "rimraf ./lib", "build": "tsc", "dev": "tsc -w" }, diff --git a/packages/shared/package.json b/packages/shared/package.json index 8fb546402415..4c174f468b07 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -20,7 +20,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "pnpm run rollup --environment NODE_ENV:production", "dev": "pnpm run rollup --environment NODE_ENV:development -w", "rollup": "rollup --config rollup.config.ts --configPlugin typescript", diff --git a/packages/stylelint-taro-rn/package.json b/packages/stylelint-taro-rn/package.json index 0bd8eb7e22b4..7d4a4cccbe06 100644 --- a/packages/stylelint-taro-rn/package.json +++ b/packages/stylelint-taro-rn/package.json @@ -27,7 +27,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "pnpm run rollup --environment NODE_ENV:production", "dev": "pnpm run rollup --environment NODE_ENV:development -w", "rollup": "rollup --config rollup.config.ts --configPlugin typescript", @@ -45,7 +45,8 @@ "react-native-known-styling-properties": "^1.3.0" }, "devDependencies": { - "lodash": "^4.17.21" + "lodash": "^4.17.21", + "stylelint": "^16.4.0" }, "peerDependencies": { "stylelint": "^16" diff --git a/packages/stylelint-taro/package.json b/packages/stylelint-taro/package.json index 688beac41a32..b59f41621faa 100644 --- a/packages/stylelint-taro/package.json +++ b/packages/stylelint-taro/package.json @@ -16,7 +16,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "pnpm run rollup --environment NODE_ENV:production", "dev": "pnpm run rollup --environment NODE_ENV:development -w", "rollup": "rollup --config rollup.config.ts --configPlugin typescript", diff --git a/packages/taro-cli-convertor/package.json b/packages/taro-cli-convertor/package.json index d9c036cbaaf3..6a94af2d7898 100644 --- a/packages/taro-cli-convertor/package.json +++ b/packages/taro-cli-convertor/package.json @@ -10,7 +10,7 @@ "prebuild": "pnpm run clean", "build": "tsc", "dev": "tsc -w", - "clean": "rimraf --impl=move-remove dist", + "clean": "rimraf dist", "lint": "eslint src --ext .js,.jsx,.ts,.tsx", "format": "prettier --write \"{src, __tests__}/**/*.{ts,tsx,js,jsx}\" && eslint src __tests__ --ext .js --ext .jsx --ext .ts --ext .tsx --fix", "test": "jest", diff --git a/packages/taro-cli/package.json b/packages/taro-cli/package.json index faa7996e8711..24c6e075e2d6 100644 --- a/packages/taro-cli/package.json +++ b/packages/taro-cli/package.json @@ -16,7 +16,7 @@ "prebuild": "pnpm run clean", "build": "tsc", "dev": "tsc -w", - "clean": "rimraf --impl=move-remove dist" + "clean": "rimraf dist" }, "files": [ "bin", diff --git a/packages/taro-components-advanced/package.json b/packages/taro-components-advanced/package.json index 39f7c4b85222..febf09f4a0fa 100644 --- a/packages/taro-components-advanced/package.json +++ b/packages/taro-components-advanced/package.json @@ -18,7 +18,7 @@ "prod": "pnpm run build", "prebuild": "pnpm run clean", "build": "rollup -c", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "dev": "pnpm run build -w" }, "keywords": [], diff --git a/packages/taro-components-library-react/package.json b/packages/taro-components-library-react/package.json index 42f719f19add..d94c3e0870fa 100644 --- a/packages/taro-components-library-react/package.json +++ b/packages/taro-components-library-react/package.json @@ -9,7 +9,7 @@ "scripts": { "prebuild": "pnpm run clean && node ./scripts/fix.js", "build": "rollup -c", - "clean": "rimraf --impl=move-remove ../taro-components/lib/react", + "clean": "rimraf ../taro-components/lib/react", "dev": "pnpm run build -w", "prod": "pnpm run build" }, diff --git a/packages/taro-components-library-solid/package.json b/packages/taro-components-library-solid/package.json index f12f70a9ce73..0a4cd2d19d23 100644 --- a/packages/taro-components-library-solid/package.json +++ b/packages/taro-components-library-solid/package.json @@ -7,7 +7,7 @@ "scripts": { "prebuild": "pnpm run clean && node ./scripts/fix.js", "build": "rollup -c", - "clean": "rimraf --impl=move-remove ../taro-components/lib/solid", + "clean": "rimraf ../taro-components/lib/solid", "dev": "pnpm run build -w", "prod": "pnpm run build" }, diff --git a/packages/taro-components-library-vue3/package.json b/packages/taro-components-library-vue3/package.json index 13427d5fdb58..3494edf9c67d 100644 --- a/packages/taro-components-library-vue3/package.json +++ b/packages/taro-components-library-vue3/package.json @@ -10,7 +10,7 @@ "prod": "pnpm run build", "prebuild": "pnpm run clean && node ./scripts/fix.js", "build": "rollup -c", - "clean": "rimraf --impl=move-remove ../taro-components/lib/vue3", + "clean": "rimraf ../taro-components/lib/vue3", "dev": "pnpm run build -w" }, "keywords": [], diff --git a/packages/taro-components-rn/package.json b/packages/taro-components-rn/package.json index f01a2a0b08b9..3f1d25bc08e8 100644 --- a/packages/taro-components-rn/package.json +++ b/packages/taro-components-rn/package.json @@ -9,7 +9,7 @@ "prod": "pnpm run build", "assets": "cpy 'src/**/*.png' '!src/__tests__/*' dist", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "tsc && pnpm run assets", "dev": "pnpm run assets && tsc --watch", "lint": "eslint src --ext .js,.jsx,.ts,.tsx", @@ -33,18 +33,14 @@ }, "dependencies": { "@ant-design/react-native": "5.0.0", - "@react-native-community/slider": "4.5.2", - "@react-native-picker/picker": "2.7.5", "@tarojs/components": "workspace:*", "@tarojs/router-rn": "workspace:*", - "expo-av": "~13.10.0", - "expo-camera": "~15.0.8", "prop-types": "^15.8.1", - "react-native-maps": "1.3.2", - "react-native-pager-view": "6.2.3", - "react-native-webview": "13.3.1" + "react-native-maps": "1.3.2" }, "devDependencies": { + "@react-native-community/slider": "4.4.2", + "@react-native-picker/picker": "2.6.1", "@babel/core": "^7.24.4", "@babel/preset-env": "^7.24.4", "@react-native/babel-preset": "^0.73.18", @@ -52,24 +48,27 @@ "@testing-library/react-native": "^12.4.1", "cpy-cli": "^5.0.0", "dpdm": "^3.14.0", - "expo": "~51.0.5", + "expo": "~50.0.0", + "expo-av": "~13.10.6", + "expo-camera": "~14.1.3", "expo-module-scripts": "^3.5.1", - "jest-expo": "^51.0.1", + "jest-expo": "~50.0.3", "react": "^18.2.0", - "react-native": "^0.72.3", - "react-native-svg": "14.1.0" + "react-native": "^0.73.1", + "react-native-pager-view": "6.2.3", + "react-native-svg": "14.1.0", + "react-native-webview": "13.6.4" }, "peerDependencies": { - "@react-native-community/slider": ">= 4.5", - "@react-native-picker/picker": ">= 2.6", - "expo": ">= 51", - "expo-av": ">= 13.10.0", - "expo-barcode-scanner": ">= 13", - "expo-camera": ">= 15", - "react": ">= 18", - "react-native": ">= 0.63.0", - "react-native-pager-view": "~ 6.2", - "react-native-svg": ">= 14.1.0", - "react-native-webview": ">= 13" + "@react-native-community/slider": "4.4.2", + "@react-native-picker/picker": "2.6.1", + "expo": "~50.0.0", + "expo-av": "~13.10.6", + "expo-camera": "~14.1.3", + "react": "^18.2.0", + "react-native": "^0.73.1", + "react-native-pager-view": "6.2.3", + "react-native-svg": "14.1.0", + "react-native-webview": "13.6.4" } } diff --git a/packages/taro-components-rn/src/components/Camera/index.tsx b/packages/taro-components-rn/src/components/Camera/index.tsx index eb8976f5eb51..5759d5afdad8 100644 --- a/packages/taro-components-rn/src/components/Camera/index.tsx +++ b/packages/taro-components-rn/src/components/Camera/index.tsx @@ -1,5 +1,4 @@ -import { BarcodeScanningResult, BarcodeType, Camera, CameraMountError, CameraView, PermissionStatus } from 'expo-camera' -import { CameraType } from 'expo-camera/build/legacy/Camera.types' +import { BarCodeScanningResult, Camera, CameraMountError, CameraType, PermissionStatus } from 'expo-camera' import React, { Component } from 'react' import Text from '../Text' @@ -15,12 +14,12 @@ export class _Camera extends Component { } } - expoCameraRef = React.createRef() + expoCameraRef = React.createRef() async componentDidMount(): Promise { const permission = await Camera.requestCameraPermissionsAsync() this.setState({ - hasPermission: permission?.status === PermissionStatus.GRANTED + hasPermission: permission?.status === PermissionStatus.GRANTED, }) } @@ -34,14 +33,15 @@ export class _Camera extends Component { this.props.onInitDone && this.props.onInitDone(event) } - onScanCode = (event: BarcodeScanningResult): void => { + onScanCode = (event: BarCodeScanningResult): void => { const { data } = event - this.props.onScanCode && this.props.onScanCode({ - detail: { - result: data - }, - ...event - } as any) + this.props.onScanCode && + this.props.onScanCode({ + detail: { + result: data, + }, + ...event, + } as any) } render(): JSX.Element { @@ -59,16 +59,16 @@ export class _Camera extends Component { mode === 'scanCode' ? { barCodeScannerSettings: { - barCodeTypes: ['qr'] as BarcodeType[] + barCodeTypes: ['qr'], }, - onBarCodeScanned: this.onScanCode + onBarCodeScanned: this.onScanCode, } : {} return ( - = 51", - "react": ">= 18", - "react-native": ">= 0.63.0" + "expo": "~50.0.0", + "react": "^18.2.0", + "react-native": "^0.73.1" } } diff --git a/packages/taro-rn-style-transformer/package.json b/packages/taro-rn-style-transformer/package.json index 46d310435e5e..fd8d13f54eca 100644 --- a/packages/taro-rn-style-transformer/package.json +++ b/packages/taro-rn-style-transformer/package.json @@ -12,7 +12,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "tsc", "dev": "tsc -w", "lint": "eslint src __tests__ --ext .js,.ts", diff --git a/packages/taro-rn-supporter/package.json b/packages/taro-rn-supporter/package.json index c2d398af9d0a..4975cddb1b0d 100644 --- a/packages/taro-rn-supporter/package.json +++ b/packages/taro-rn-supporter/package.json @@ -13,7 +13,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "tsc", "dev": "tsc -w", "lint": "eslint src --ext .js,.ts" @@ -55,7 +55,7 @@ "@babel/preset-env": "^7.24.4", "@types/lodash": "^4.17.0", "react": "^18.2.0", - "react-native": "^0.72.3", + "react-native": "^0.73.1", "react-native-svg": "~14.1.0" }, "peerDependencies": { diff --git a/packages/taro-rn-transformer/package.json b/packages/taro-rn-transformer/package.json index 55a0775ceb97..758ed7186aff 100644 --- a/packages/taro-rn-transformer/package.json +++ b/packages/taro-rn-transformer/package.json @@ -13,7 +13,7 @@ "scripts": { "prod": "pnpm run build", "prebuild": "pnpm run clean", - "clean": "rimraf --impl=move-remove ./dist", + "clean": "rimraf ./dist", "build": "tsc", "dev": "tsc -w", "test": "jest", diff --git a/packages/taro-rn-transformer/src/component.ts b/packages/taro-rn-transformer/src/component.ts index 0b4da3d6172e..21a40bd71d34 100644 --- a/packages/taro-rn-transformer/src/component.ts +++ b/packages/taro-rn-transformer/src/component.ts @@ -33,7 +33,7 @@ export default function componentLoader ({ sourceCode, filename, projectRoot, so // linaria transform let linaria try { - linaria = require('linaria') + linaria = require('@wyw-in-js/transform') } catch (e) {} // eslint-disable-line no-empty if (linaria) { diff --git a/packages/taro-rn-transformer/src/utils.ts b/packages/taro-rn-transformer/src/utils.ts index fc9161383cd3..b64f96ace24d 100644 --- a/packages/taro-rn-transformer/src/utils.ts +++ b/packages/taro-rn-transformer/src/utils.ts @@ -168,7 +168,6 @@ export function parseBase64Image (iconPath: string, baseRoot: string) { export function transformLinaria ({ sourcePath, sourceCode }: TransformLinariaOption) { // TODO:配置 option, 小程序和 h5 可配置 webpack loader 更改配置,RN没有loader,所以默认不可配置,后续可考虑加配置 const cacheDirectory = '.linaria-cache' - const preprocessor = undefined const extension = '.linaria.css' const root = process.cwd() @@ -187,12 +186,17 @@ export function transformLinaria ({ sourcePath, sourceCode }: TransformLinariaOp const filename = nodePath.relative(process.cwd(), sourcePath) // linaria代码转换 - const result = require('linaria/lib/node').transform(sourceCode, { - filename, - // inputSourceMap: inputSourceMap ?? undefined, - outputFilename, - preprocessor - }) + const pluginOptions = { + babelOptions: { + babelrc: false + } + } + + const services = { + options: { root, filename, pluginOptions }, + } + + const result = require('@wyw-in-js/transform/lib/transform').transformSync(services, sourceCode) // 生成样式文件 if (result.cssText) { @@ -284,32 +288,7 @@ export function transformLinaria ({ sourcePath, sourceCode }: TransformLinariaOp attribute = null as any } - if (attribute) { - if (types.isJSXAttribute(attribute) && types.isJSXExpressionContainer(attribute.value)) { - const expression = attribute.value.expression - let elements - if (types.isArrayExpression(expression)) { - elements = expression.elements - } else { - elements = expression - } - // 合并 style 对象 - // style = Object.assign({}, linariaStyle, { color: 'red' }) - const mergeStyleExpression = types.callExpression( - types.identifier('Object.assign'), - // @ts-ignore - [types.objectExpression([])].concat(linariaExpression, elements) - ) - attribute.value = types.jSXExpressionContainer(mergeStyleExpression) - } - } else { - attributes.push( - types.jsxAttribute( - types.jsxIdentifier('style'), - types.jsxExpressionContainer(linariaExpression) - ) - ) - } + attributes.push(types.jsxAttribute(types.jsxIdentifier('className'), types.jsxExpressionContainer(linariaExpression))) } } }) diff --git a/packages/taro-rn/__tests__/__snapshots__/scanCode.test.tsx.snap b/packages/taro-rn/__tests__/__snapshots__/scanCode.test.tsx.snap index bd028355ced9..fbb1ab2f5b6e 100644 --- a/packages/taro-rn/__tests__/__snapshots__/scanCode.test.tsx.snap +++ b/packages/taro-rn/__tests__/__snapshots__/scanCode.test.tsx.snap @@ -16,21 +16,17 @@ exports[`scanCode should render scanCode success 1`] = ` } > = 18" }, "dependencies": { - "@bam.tech/react-native-image-resizer": "3.0.9", - "@react-native-async-storage/async-storage": "1.23.1", - "@react-native-camera-roll/camera-roll": "7.7.0", - "@react-native-clipboard/clipboard": "1.14.1", - "@react-native-community/geolocation": "3.2.1", - "@react-native-community/netinfo": "11.3.2", "@tarojs/runtime-rn": "workspace:*", "@tarojs/taro": "workspace:*", "base64-js": "^1.5.1", "deprecated-react-native-prop-types": "^5.0.0", - "expo-av": "~13.10.0", - "expo-barcode-scanner": "~13.0.1", - "expo-brightness": "~12.0.1", - "expo-camera": "~15.0.8", - "expo-file-system": "~17.0.1", - "expo-image-picker": "~15.0.4", - "expo-keep-awake": "~13.0.1", - "expo-location": "~17.0.1", - "expo-sensors": "~13.0.6", - "prop-types": "^15.8.1", - "react-native-device-info": "11.1.0", - "react-native-image-zoom-viewer": "3.0.1", - "react-native-root-siblings": "5.0.1", - "react-native-safe-area-context": "4.10.1" + "prop-types": "^15.8.1" }, "devDependencies": { "@babel/core": "^7.24.4", @@ -71,36 +52,55 @@ "@react-native/babel-preset": "^0.73.18", "@testing-library/jest-native": "^5.4.2", "@testing-library/react-native": "^12.4.1", + "@bam.tech/react-native-image-resizer": "^3.0.10", + "@react-native-async-storage/async-storage": "1.21.0", + "@react-native-camera-roll/camera-roll": "^7.8.3", + "@react-native-clipboard/clipboard": "^1.14.3", + "@react-native-community/geolocation": "^3.4.0", + "@react-native-community/netinfo": "11.1.0", "cpy-cli": "^5.0.0", "dpdm": "^3.14.0", - "expo": "~51.0.5", - "jest-expo": "^51.0.1", + "expo": "~50.0.0", + "expo-av": "~13.10.6", + "expo-barcode-scanner": "~12.9.3", + "expo-brightness": "~11.8.0", + "expo-camera": "~14.1.3", + "expo-file-system": "~16.0.9", + "expo-image-picker": "~14.7.1", + "expo-keep-awake": "~12.8.2", + "expo-location": "~16.5.5", + "expo-sensors": "~12.9.1", + "jest-expo": "~50.0.3", "mock-socket": "^7.1.0", "react": "^18.2.0", - "react-native": "^0.72.3" + "react-native": "^0.73.1", + "react-native-device-info": "^14.0.0", + "react-native-image-zoom-viewer": "^3.0.1", + "react-native-root-siblings": "^5.0.1", + "react-native-safe-area-context": "4.8.2" }, "peerDependencies": { - "@bam.tech/react-native-image-resizer": ">= 3.0.0", - "@react-native-async-storage/async-storage": ">= 1.21.0", - "@react-native-camera-roll/camera-roll": ">= 7.2.0", - "@react-native-clipboard/clipboard": ">= 1.13.0", - "@react-native-community/geolocation": ">= 3.2.0", - "@react-native-community/netinfo": ">= 11.2.0", - "expo": ">= 51", - "expo-av": ">= 13.10.0", - "expo-barcode-scanner": ">= 13", - "expo-brightness": ">= 12", - "expo-camera": ">= 15", - "expo-file-system": ">= 17", - "expo-image-picker": ">= 15", - "expo-keep-awake": ">= 13", - "expo-location": ">= 17", - "expo-sensors": ">= 13", - "react": ">= 18", - "react-native": ">= 0.63.0", - "react-native-device-info": ">= 11", - "react-native-image-zoom-viewer": ">= 3", - "react-native-root-siblings": ">= 5", - "react-native-safe-area-context": ">= 4.8.0" + "@bam.tech/react-native-image-resizer": "^3.0.10", + "@react-native-async-storage/async-storage": "1.21.0", + "@react-native-camera-roll/camera-roll": "^7.8.3", + "@react-native-clipboard/clipboard": "^1.14.3", + "@react-native-community/geolocation": "^3.4.0", + "@react-native-community/netinfo": "11.1.0", + "expo": "~50.0.0", + "expo-av": "~13.10.6", + "expo-barcode-scanner": "~12.9.3", + "expo-brightness": "~11.8.0", + "expo-camera": "~14.1.3", + "expo-file-system": "~16.0.9", + "expo-image-picker": "~14.7.1", + "expo-keep-awake": "~12.8.2", + "expo-location": "~16.5.5", + "expo-sensors": "~12.9.1", + "react": "^18.2.0", + "react-native": "^0.73.1", + "react-native-device-info": "^14.0.0", + "react-native-image-zoom-viewer": "^3.0.1", + "react-native-root-siblings": "^5.0.1", + "react-native-safe-area-context": "4.8.2" } } diff --git a/packages/taro-rn/src/lib/openUrl/index.d.ts b/packages/taro-rn/src/lib/openUrl/index.d.ts deleted file mode 100644 index 80f2a80333f9..000000000000 --- a/packages/taro-rn/src/lib/openUrl/index.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -declare namespace Taro { - namespace OpenUrl { - interface Option { - /** 跳转链接 */ - url: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: (res: TaroGeneral.CallbackResult) => void - /** 接口调用失败的回调函数 */ - fail?: (res: TaroGeneral.CallbackResult) => void - /** 接口调用成功的回调函数 */ - success?: (res: TaroGeneral.CallbackResult) => void - } - } - - /** - * 由于 Expo 不支持原生的 SDK,所以无法通过集成原生的 SDK 的方式使用微信/支付宝支付。 - * 所以 RN 端提供了 `Taro.openUrl({url:''})`的 API 打开手机浏览器,然后走 [手机网站支付](https://docs.open.alipay.com/203/105288/) 的流程。 - * @param {Object} opts - * @param {string} [opts.url] 跳转链接 - * @param {function} [opts.success] 接口调用成功的回调函数 - * @param {function} [opts.fail] 接口调用失败的回调函数 - * @param {function} [opts.complete] 接口调用结束的回调函数(调用成功、失败都会执行) - */ - function openUrl(opts: Taro.OpenUrl.Option): Promise -} diff --git a/packages/taro-rn/src/lib/openUrl/index.ts b/packages/taro-rn/src/lib/openUrl/index.ts index cd37c9319f79..4f783002a98b 100644 --- a/packages/taro-rn/src/lib/openUrl/index.ts +++ b/packages/taro-rn/src/lib/openUrl/index.ts @@ -2,8 +2,19 @@ import { Linking } from 'react-native' import { errorHandler, successHandler } from '../../utils' -export async function openUrl (opts: Taro.OpenUrl.Option): Promise { - const { url, success, fail, complete } = opts || {} as Taro.OpenUrl.Option +interface Option { + /** 跳转链接 */ + url: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void +} + +export async function openUrl(opts: Option): Promise { + const { url, success, fail, complete } = opts || {} const res: any = { errMsg: 'openUrl:ok' } const isSupport = await Linking.canOpenURL(url) @@ -17,5 +28,5 @@ export async function openUrl (opts: Taro.OpenUrl.Option): Promise { } export default { - openUrl + openUrl, } diff --git a/packages/taro-rn/src/lib/scanCode/index.tsx b/packages/taro-rn/src/lib/scanCode/index.tsx index e6d700652147..c846ff86394e 100644 --- a/packages/taro-rn/src/lib/scanCode/index.tsx +++ b/packages/taro-rn/src/lib/scanCode/index.tsx @@ -1,5 +1,5 @@ import { BarCodeScanner, requestPermissionsAsync } from 'expo-barcode-scanner' -import { BarcodeType, CameraView } from 'expo-camera' +import { Camera } from 'expo-camera' import React from 'react' import { BackHandler, Dimensions, Image, Platform, StatusBar, StyleSheet, TouchableOpacity, View } from 'react-native' import RootSiblings from 'react-native-root-siblings' @@ -48,8 +48,8 @@ function findKey (value:string, data, compare = (a, b) => a === b):string { const { width, height } = Dimensions.get('screen') -function getBarCodeTypes(types:string[]): BarcodeType[] { - const result: BarcodeType[] = [] +function getBarCodeTypes(types:string[]): string[] { + const result: string[] = [] for (const t of types) { result.push(...typeMap[t].map(type => { @@ -158,13 +158,13 @@ export async function scanCode(option: Taro.scanCode.Option = {}): Promise { scannerView = new RootSiblings( (