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