v10.10.0
This commit is contained in:
parent
0fdb33ab10
commit
28b8e122af
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.9.0",
|
||||
"version": "10.10.0",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
|
@ -14,6 +14,7 @@ export const defaultContext = {
|
||||
downloadUpdate: asyncNoop,
|
||||
downloadAndInstallApk: asyncNoop,
|
||||
getCurrentVersionInfo: () => Promise.resolve({}),
|
||||
parseTestPayload: () => Promise.resolve(false),
|
||||
currentHash: '',
|
||||
packageVersion: '',
|
||||
};
|
||||
@ -31,6 +32,7 @@ export const PushyContext = createContext<{
|
||||
description?: string;
|
||||
metaInfo?: string;
|
||||
}>;
|
||||
parseTestPayload: (code: string) => Promise<boolean>;
|
||||
currentHash: string;
|
||||
packageVersion: string;
|
||||
client?: Pushy;
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
packageVersion,
|
||||
getCurrentVersionInfo,
|
||||
} from './core';
|
||||
import { CheckResult, ProgressData } from './type';
|
||||
import { CheckResult, ProgressData, PushyTestPayload } from './type';
|
||||
import { PushyContext } from './context';
|
||||
|
||||
export const PushyProvider = ({
|
||||
@ -262,6 +262,25 @@ export const PushyProvider = ({
|
||||
};
|
||||
}, [checkUpdate, options, dismissError, markSuccess]);
|
||||
|
||||
const parseTestPayload = useCallback(
|
||||
async (code: string) => {
|
||||
let payload: PushyTestPayload;
|
||||
try {
|
||||
payload = JSON.parse(code);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
if (payload && payload.type) {
|
||||
if (payload.type === '__rnPushyVersionHash') {
|
||||
await checkUpdate({ toHash: payload.data });
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
[checkUpdate],
|
||||
);
|
||||
|
||||
return (
|
||||
<PushyContext.Provider
|
||||
value={{
|
||||
@ -279,6 +298,7 @@ export const PushyProvider = ({
|
||||
progress,
|
||||
downloadAndInstallApk,
|
||||
getCurrentVersionInfo,
|
||||
parseTestPayload,
|
||||
}}>
|
||||
{children}
|
||||
</PushyContext.Provider>
|
||||
|
@ -81,3 +81,8 @@ export interface PushyOptions {
|
||||
debug?: boolean;
|
||||
throwError?: boolean;
|
||||
}
|
||||
|
||||
export interface PushyTestPayload {
|
||||
type: '__rnPushyVersionHash';
|
||||
data: any;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user