1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 12:51:44 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Compare commits

...

6 Commits

Author SHA1 Message Date
sunnylqm
c63e1501fe v10.1.3 2024-02-25 22:24:35 +08:00
sunnylqm
45bfa2560e feat: add getCurrentVersionInfo 2024-02-25 22:23:46 +08:00
sunnylqm
ab9c40bf2e v10.1.2 2024-02-25 00:05:14 +08:00
sunnylqm
d184beabaf fix: type 2024-02-25 00:04:55 +08:00
sunnylqm
68a6235145 v10.1.1 2024-02-25 00:03:58 +08:00
sunnylqm
a98a48d665 fix: type 2024-02-25 00:03:35 +08:00
3 changed files with 23 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "10.1.0",
"version": "10.1.3",
"description": "react-native hot update",
"main": "src/index.ts",
"scripts": {

View File

@@ -2,29 +2,35 @@ import { createContext, useContext } from 'react';
import { CheckResult, ProgressData } from './type';
import { Pushy } from './client';
const empty = {};
const noop = () => {};
const asyncNoop = () => Promise.resolve();
export const defaultContext = {
checkUpdate: () => Promise.resolve(empty),
checkUpdate: asyncNoop,
switchVersion: noop,
switchVersionLater: noop,
markSuccess: noop,
dismissError: noop,
downloadUpdate: noop,
downloadAndInstallApk: noop,
downloadUpdate: asyncNoop,
downloadAndInstallApk: asyncNoop,
getCurrentVersionInfo: () => Promise.resolve({}),
currentHash: '',
packageVersion: '',
};
export const PushyContext = createContext<{
checkUpdate: () => void;
checkUpdate: () => Promise<void>;
switchVersion: () => void;
switchVersionLater: () => void;
markSuccess: () => void;
dismissError: () => void;
downloadUpdate: () => void;
downloadAndInstallApk: (url: string) => void;
downloadUpdate: () => Promise<void>;
downloadAndInstallApk: (url: string) => Promise<void>;
getCurrentVersionInfo: () => Promise<{
name?: string;
description?: string;
metaInfo?: string;
}>;
currentHash: string;
packageVersion: string;
client?: Pushy;

View File

@@ -13,7 +13,12 @@ import {
Linking,
} from 'react-native';
import { Pushy } from './client';
import { currentVersion, isFirstTime, packageVersion } from './core';
import {
currentVersion,
isFirstTime,
packageVersion,
getCurrentVersionInfo,
} from './core';
import { CheckResult, ProgressData } from './type';
import { PushyContext } from './context';
@@ -88,9 +93,9 @@ export const PushyProvider = ({
}, [client, showAlert, updateInfo]);
const downloadAndInstallApk = useCallback(
(downloadUrl: string) => {
async (downloadUrl: string) => {
if (Platform.OS === 'android' && downloadUrl) {
client.downloadAndInstallApk(downloadUrl, setProgress);
await client.downloadAndInstallApk(downloadUrl, setProgress);
}
},
[client],
@@ -188,6 +193,7 @@ export const PushyProvider = ({
currentHash: currentVersion,
progress,
downloadAndInstallApk,
getCurrentVersionInfo,
}}
>
{children}