mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-12-21 21:23:57 +08:00
Update version to 10.37.0 in package.json and enhance hash handling in client and core logic
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "10.36.6",
|
"version": "10.37.0",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "src/index",
|
"main": "src/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ const defaultClientOptions: ClientOptions = {
|
|||||||
export const sharedState: {
|
export const sharedState: {
|
||||||
progressHandlers: Record<string, EmitterSubscription>;
|
progressHandlers: Record<string, EmitterSubscription>;
|
||||||
downloadedHash?: string;
|
downloadedHash?: string;
|
||||||
|
toHash?: string;
|
||||||
apkStatus: 'downloading' | 'downloaded' | null;
|
apkStatus: 'downloading' | 'downloaded' | null;
|
||||||
marked: boolean;
|
marked: boolean;
|
||||||
applyingUpdate: boolean;
|
applyingUpdate: boolean;
|
||||||
@@ -509,11 +510,15 @@ export class Pushy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
log(`downloaded ${succeeded} hash:`, hash);
|
log(`downloaded ${succeeded} hash:`, hash);
|
||||||
setLocalHashInfo(hash, {
|
const hashInfo: Record<string, any> = {
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
metaInfo,
|
metaInfo,
|
||||||
});
|
};
|
||||||
|
if (sharedState.toHash === hash) {
|
||||||
|
hashInfo.debugChannel = true;
|
||||||
|
}
|
||||||
|
setLocalHashInfo(hash, hashInfo);
|
||||||
sharedState.downloadedHash = hash;
|
sharedState.downloadedHash = hash;
|
||||||
return hash;
|
return hash;
|
||||||
};
|
};
|
||||||
|
|||||||
16
src/core.ts
16
src/core.ts
@@ -31,11 +31,21 @@ export const downloadRootDir: string = PushyConstants.downloadRootDir;
|
|||||||
export const packageVersion: string = PushyConstants.packageVersion;
|
export const packageVersion: string = PushyConstants.packageVersion;
|
||||||
export const currentVersion: string = PushyConstants.currentVersion;
|
export const currentVersion: string = PushyConstants.currentVersion;
|
||||||
|
|
||||||
|
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
|
||||||
|
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
|
||||||
|
}
|
||||||
|
|
||||||
const currentVersionInfoString: string = PushyConstants.currentVersionInfo;
|
const currentVersionInfoString: string = PushyConstants.currentVersionInfo;
|
||||||
let _currentVersionInfo = {};
|
let _currentVersionInfo: Record<string, any> = {};
|
||||||
|
let isDebugChannel = false;
|
||||||
if (currentVersionInfoString) {
|
if (currentVersionInfoString) {
|
||||||
try {
|
try {
|
||||||
_currentVersionInfo = JSON.parse(currentVersionInfoString);
|
_currentVersionInfo = JSON.parse(currentVersionInfoString);
|
||||||
|
if (_currentVersionInfo.debugChannel) {
|
||||||
|
isDebugChannel = true;
|
||||||
|
delete _currentVersionInfo.debugChannel;
|
||||||
|
setLocalHashInfo(currentVersion, _currentVersionInfo);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
console.error(
|
||||||
'Failed to parse currentVersionInfo:',
|
'Failed to parse currentVersionInfo:',
|
||||||
@@ -46,15 +56,13 @@ if (currentVersionInfoString) {
|
|||||||
export const currentVersionInfo = _currentVersionInfo;
|
export const currentVersionInfo = _currentVersionInfo;
|
||||||
|
|
||||||
export const isFirstTime: boolean = PushyConstants.isFirstTime;
|
export const isFirstTime: boolean = PushyConstants.isFirstTime;
|
||||||
|
export const isFirstTimeDebug: boolean = isFirstTime && isDebugChannel;
|
||||||
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
|
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
|
||||||
export const isRolledBack: boolean = !!rolledBackVersion;
|
export const isRolledBack: boolean = !!rolledBackVersion;
|
||||||
|
|
||||||
export const buildTime: string = PushyConstants.buildTime;
|
export const buildTime: string = PushyConstants.buildTime;
|
||||||
let uuid = PushyConstants.uuid;
|
let uuid = PushyConstants.uuid;
|
||||||
|
|
||||||
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
|
|
||||||
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getLocalHashInfo(hash: string) {
|
async function getLocalHashInfo(hash: string) {
|
||||||
return JSON.parse(await PushyModule.getLocalHashInfo(hash));
|
return JSON.parse(await PushyModule.getLocalHashInfo(hash));
|
||||||
|
|||||||
@@ -327,7 +327,9 @@ export const UpdateProvider = ({
|
|||||||
Alert.alert(type, JSON.stringify(data));
|
Alert.alert(type, JSON.stringify(data));
|
||||||
};
|
};
|
||||||
if (payload.type === '__rnPushyVersionHash') {
|
if (payload.type === '__rnPushyVersionHash') {
|
||||||
checkUpdate({ extra: { toHash: payload.data } }).then(() => {
|
const toHash = payload.data;
|
||||||
|
sharedState.toHash = toHash;
|
||||||
|
checkUpdate({ extra: { toHash } }).then(() => {
|
||||||
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
client.t('alert_info'),
|
client.t('alert_info'),
|
||||||
|
|||||||
Reference in New Issue
Block a user