react-native-update 10.9.0 → 10.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/context.ts +2 -0
- package/src/provider.tsx +21 -1
- package/src/type.ts +5 -0
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -14,6 +14,7 @@ export const defaultContext = {
|
|
|
14
14
|
downloadUpdate: asyncNoop,
|
|
15
15
|
downloadAndInstallApk: asyncNoop,
|
|
16
16
|
getCurrentVersionInfo: () => Promise.resolve({}),
|
|
17
|
+
parseTestPayload: () => Promise.resolve(false),
|
|
17
18
|
currentHash: '',
|
|
18
19
|
packageVersion: '',
|
|
19
20
|
};
|
|
@@ -31,6 +32,7 @@ export const PushyContext = createContext<{
|
|
|
31
32
|
description?: string;
|
|
32
33
|
metaInfo?: string;
|
|
33
34
|
}>;
|
|
35
|
+
parseTestPayload: (code: string) => Promise<boolean>;
|
|
34
36
|
currentHash: string;
|
|
35
37
|
packageVersion: string;
|
|
36
38
|
client?: Pushy;
|
package/src/provider.tsx
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
packageVersion,
|
|
20
20
|
getCurrentVersionInfo,
|
|
21
21
|
} from './core';
|
|
22
|
-
import { CheckResult, ProgressData } from './type';
|
|
22
|
+
import { CheckResult, ProgressData, PushyTestPayload } from './type';
|
|
23
23
|
import { PushyContext } from './context';
|
|
24
24
|
|
|
25
25
|
export const PushyProvider = ({
|
|
@@ -262,6 +262,25 @@ export const PushyProvider = ({
|
|
|
262
262
|
};
|
|
263
263
|
}, [checkUpdate, options, dismissError, markSuccess]);
|
|
264
264
|
|
|
265
|
+
const parseTestPayload = useCallback(
|
|
266
|
+
async (code: string) => {
|
|
267
|
+
let payload: PushyTestPayload;
|
|
268
|
+
try {
|
|
269
|
+
payload = JSON.parse(code);
|
|
270
|
+
} catch {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (payload && payload.type) {
|
|
274
|
+
if (payload.type === '__rnPushyVersionHash') {
|
|
275
|
+
await checkUpdate({ toHash: payload.data });
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return false;
|
|
280
|
+
},
|
|
281
|
+
[checkUpdate],
|
|
282
|
+
);
|
|
283
|
+
|
|
265
284
|
return (
|
|
266
285
|
<PushyContext.Provider
|
|
267
286
|
value={{
|
|
@@ -279,6 +298,7 @@ export const PushyProvider = ({
|
|
|
279
298
|
progress,
|
|
280
299
|
downloadAndInstallApk,
|
|
281
300
|
getCurrentVersionInfo,
|
|
301
|
+
parseTestPayload,
|
|
282
302
|
}}>
|
|
283
303
|
{children}
|
|
284
304
|
</PushyContext.Provider>
|