From af932665feae55699795bbb58353223af9fc8ef2 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Wed, 14 May 2025 12:26:52 +0800 Subject: [PATCH] v8.5.6 --- .gitignore | 1 + lib/endpoint.ts | 2 +- lib/main.ts | 10 +++++----- lib/simpleUpdate.tsx | 6 +++--- package.json | 11 +++++++---- tsconfig.json | 18 ++++++++++++++++++ 6 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index a9a2055..a3ea7b8 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ npm-debug.log Example/**/update.json yarn-error.log Example/testHotUpdate/.pushy +dist/ diff --git a/lib/endpoint.ts b/lib/endpoint.ts index 3792e4c..353368c 100644 --- a/lib/endpoint.ts +++ b/lib/endpoint.ts @@ -24,7 +24,7 @@ export async function updateBackupEndpoints() { logger('fetch remote endpoints:', remoteEndpoints); logger('merged backup endpoints:', backupEndpoints); } - } catch (e) { + } catch (e: any) { logger('fetch remote endpoints failed'); } } diff --git a/lib/main.ts b/lib/main.ts index 1528e3d..fbd600a 100644 --- a/lib/main.ts +++ b/lib/main.ts @@ -154,7 +154,7 @@ export async function checkUpdate(APPKEY: string) { let resp; try { resp = await fetch(getCheckUrl(APPKEY), fetchPayload); - } catch (e) { + } catch (e: any) { report({ type: 'errorChecking', message: '无法连接主更新服务器,尝试备用节点', @@ -265,7 +265,7 @@ export async function downloadUpdate( originHash: currentVersion, }); succeeded = true; - } catch (e) { + } catch (e: any) { logger(`diff error: ${e.message}, try pdiff`); } } @@ -279,7 +279,7 @@ export async function downloadUpdate( hash: options.hash, }); succeeded = true; - } catch (e) { + } catch (e: any) { logger(`pdiff error: ${e.message}, try full patch`); } } @@ -294,7 +294,7 @@ export async function downloadUpdate( hash: options.hash, }); succeeded = true; - } catch (e) { + } catch (e: any) { logger(`full patch error: ${e.message}`); } } @@ -371,7 +371,7 @@ export async function downloadAndInstallApk({ if (granted !== PermissionsAndroid.RESULTS.GRANTED) { return report({ type: 'rejectStoragePermission' }); } - } catch (err) { + } catch (err: any) { return report({ type: 'errorStoragePermission' }); } } diff --git a/lib/simpleUpdate.tsx b/lib/simpleUpdate.tsx index 37cc104..480daf4 100644 --- a/lib/simpleUpdate.tsx +++ b/lib/simpleUpdate.tsx @@ -34,7 +34,7 @@ export function simpleUpdate( return __DEV__ ? WrappedComponent : class AppUpdate extends PureComponent { - stateListener: NativeEventSubscription; + stateListener: NativeEventSubscription | null = null; componentDidMount() { if (isRolledBack) { Alert.alert('抱歉', '刚刚更新遭遇错误,已为您恢复到更新前版本'); @@ -77,7 +77,7 @@ export function simpleUpdate( }, }, ]); - } catch (err) { + } catch (err: any) { Alert.alert('更新失败', err.message); } }; @@ -86,7 +86,7 @@ export function simpleUpdate( let info; try { info = await checkUpdate(appKey!); - } catch (err) { + } catch (err: any) { Alert.alert('更新检查失败', err.message); return; } diff --git a/package.json b/package.json index 487a96a..485252c 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { "name": "react-native-update", - "version": "8.5.4", + "version": "8.5.6", "description": "react-native hot update", - "main": "lib/index.ts", + "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { - "prepublish": "yarn submodule", + "prepublishOnly": "yarn submodule && yarn build", + "build": "yarn clean && tsc", + "clean": "rm -rf dist", "submodule": "git submodule update --init --recursive", "test": "echo \"Error: no test specified\" && exit 1", "build-lib": "yarn submodule && $ANDROID_HOME/ndk/20.1.5948944/ndk-build NDK_PROJECT_PATH=android APP_BUILD_SCRIPT=android/jni/Android.mk NDK_APPLICATION_MK=android/jni/Application.mk NDK_LIBS_OUT=android/lib" @@ -25,7 +28,7 @@ "url": "https://github.com/reactnativecn/react-native-pushy/issues" }, "peerDependencies": { - "react-native": ">=0.57.0" + "react-native": "*" }, "homepage": "https://github.com/reactnativecn/react-native-pushy#readme", "dependencies": { diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ed395cf --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "commonjs", + "declaration": true, + "outDir": "./dist", + "strict": true, + "noImplicitAny": false, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react-native", + "lib": ["es2016", "dom"], + "moduleResolution": "node" + }, + "include": ["lib/**/*"], + "exclude": ["node_modules", "dist", "Example"] +}