1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm 2024-07-29 22:40:55 +08:00
parent b2305cff3f
commit 7531e8ca3a
No known key found for this signature in database
3 changed files with 15 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "10.11.2", "version": "10.11.3",
"description": "react-native hot update", "description": "react-native hot update",
"main": "src/index", "main": "src/index",
"scripts": { "scripts": {

View File

@ -293,7 +293,7 @@ export class Pushy {
}, },
); );
} }
let succeeded = false; let succeeded = '';
this.report({ type: 'downloading' }); this.report({ type: 'downloading' });
let lastError: any; let lastError: any;
const diffUrl = (await testUrls(diffUrls)) || _diffUrl; const diffUrl = (await testUrls(diffUrls)) || _diffUrl;
@ -305,11 +305,11 @@ export class Pushy {
hash, hash,
originHash: currentVersion, originHash: currentVersion,
}); });
succeeded = true; succeeded = 'diff';
} catch (e: any) { } catch (e: any) {
lastError = e; lastError = e;
if (__DEV__) { if (__DEV__) {
succeeded = true; succeeded = 'diff';
} else { } else {
log(`diff error: ${e.message}, try pdiff`); log(`diff error: ${e.message}, try pdiff`);
} }
@ -323,11 +323,11 @@ export class Pushy {
updateUrl: pdiffUrl, updateUrl: pdiffUrl,
hash, hash,
}); });
succeeded = true; succeeded = 'pdiff';
} catch (e: any) { } catch (e: any) {
lastError = e; lastError = e;
if (__DEV__) { if (__DEV__) {
succeeded = true; succeeded = 'pdiff';
} else { } else {
log(`pdiff error: ${e.message}, try full patch`); log(`pdiff error: ${e.message}, try full patch`);
} }
@ -341,11 +341,11 @@ export class Pushy {
updateUrl: updateUrl, updateUrl: updateUrl,
hash, hash,
}); });
succeeded = true; succeeded = 'full';
} catch (e: any) { } catch (e: any) {
lastError = e; lastError = e;
if (__DEV__) { if (__DEV__) {
succeeded = true; succeeded = 'full';
} else { } else {
log(`full patch error: ${e.message}`); log(`full patch error: ${e.message}`);
} }
@ -367,8 +367,13 @@ export class Pushy {
throw lastError; throw lastError;
} }
return; return;
} else {
this.report({
type: 'downloadSuccess',
data: { newVersion: hash, diff: succeeded },
});
} }
log('downloaded hash:', hash); log(`downloaded ${succeeded} hash:`, hash);
setLocalHashInfo(hash, { setLocalHashInfo(hash, {
name, name,
description, description,

View File

@ -28,6 +28,7 @@ export type EventType =
| 'errorChecking' | 'errorChecking'
| 'checking' | 'checking'
| 'downloading' | 'downloading'
| 'downloadSuccess'
| 'errorUpdate' | 'errorUpdate'
| 'markSuccess' | 'markSuccess'
| 'downloadingApk' | 'downloadingApk'