mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-17 23:36:11 +08:00
Compare commits
22 Commits
v10.0.0-be
...
v10.1.3
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c63e1501fe | ||
![]() |
45bfa2560e | ||
![]() |
ab9c40bf2e | ||
![]() |
d184beabaf | ||
![]() |
68a6235145 | ||
![]() |
a98a48d665 | ||
![]() |
4bf004a274 | ||
![]() |
f01716bcb2 | ||
![]() |
4f9e1495c8 | ||
![]() |
9c06bac91b | ||
![]() |
4923aff184 | ||
![]() |
f6a38c1f48 | ||
![]() |
92cfbb3fdf | ||
![]() |
64ef8e129d | ||
![]() |
ce51b2ca81 | ||
![]() |
6c1662fce1 | ||
![]() |
d9e4575964 | ||
![]() |
190103687c | ||
![]() |
f6f055be64 | ||
![]() |
05e5c5a1a7 | ||
![]() |
296498e20a | ||
![]() |
2a3b8e5707 |
@@ -284,17 +284,19 @@ PODS:
|
|||||||
- React-jsinspector (0.69.8)
|
- React-jsinspector (0.69.8)
|
||||||
- React-logger (0.69.8):
|
- React-logger (0.69.8):
|
||||||
- glog
|
- glog
|
||||||
- react-native-update (9.0.0):
|
- react-native-safe-area-context (4.8.2):
|
||||||
|
- React-Core
|
||||||
|
- react-native-update (10.0.0-beta.1):
|
||||||
- React
|
- React
|
||||||
- React-Core
|
- React-Core
|
||||||
- react-native-update/HDiffPatch (= 9.0.0)
|
- react-native-update/HDiffPatch (= 10.0.0-beta.1)
|
||||||
- react-native-update/RCTPushy (= 9.0.0)
|
- react-native-update/RCTPushy (= 10.0.0-beta.1)
|
||||||
- SSZipArchive
|
- SSZipArchive
|
||||||
- react-native-update/HDiffPatch (9.0.0):
|
- react-native-update/HDiffPatch (10.0.0-beta.1):
|
||||||
- React
|
- React
|
||||||
- React-Core
|
- React-Core
|
||||||
- SSZipArchive
|
- SSZipArchive
|
||||||
- react-native-update/RCTPushy (9.0.0):
|
- react-native-update/RCTPushy (10.0.0-beta.1):
|
||||||
- React
|
- React
|
||||||
- React-Core
|
- React-Core
|
||||||
- SSZipArchive
|
- SSZipArchive
|
||||||
@@ -364,6 +366,8 @@ PODS:
|
|||||||
- React-jsi (= 0.69.8)
|
- React-jsi (= 0.69.8)
|
||||||
- React-logger (= 0.69.8)
|
- React-logger (= 0.69.8)
|
||||||
- React-perflogger (= 0.69.8)
|
- React-perflogger (= 0.69.8)
|
||||||
|
- RNVectorIcons (10.0.3):
|
||||||
|
- React-Core
|
||||||
- SocketRocket (0.6.0)
|
- SocketRocket (0.6.0)
|
||||||
- SSZipArchive (2.4.3)
|
- SSZipArchive (2.4.3)
|
||||||
- Yoga (1.14.0)
|
- Yoga (1.14.0)
|
||||||
@@ -414,6 +418,7 @@ DEPENDENCIES:
|
|||||||
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
|
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
|
||||||
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
|
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
|
||||||
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
|
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
|
||||||
|
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
|
||||||
- react-native-update (from `../node_modules/react-native-update`)
|
- react-native-update (from `../node_modules/react-native-update`)
|
||||||
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
|
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
|
||||||
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
|
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
|
||||||
@@ -427,6 +432,7 @@ DEPENDENCIES:
|
|||||||
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
|
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
|
||||||
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
|
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
|
||||||
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
|
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
|
||||||
|
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
|
||||||
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
|
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
|
||||||
|
|
||||||
SPEC REPOS:
|
SPEC REPOS:
|
||||||
@@ -487,6 +493,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: "../node_modules/react-native/ReactCommon/jsinspector"
|
:path: "../node_modules/react-native/ReactCommon/jsinspector"
|
||||||
React-logger:
|
React-logger:
|
||||||
:path: "../node_modules/react-native/ReactCommon/logger"
|
:path: "../node_modules/react-native/ReactCommon/logger"
|
||||||
|
react-native-safe-area-context:
|
||||||
|
:path: "../node_modules/react-native-safe-area-context"
|
||||||
react-native-update:
|
react-native-update:
|
||||||
:path: "../node_modules/react-native-update"
|
:path: "../node_modules/react-native-update"
|
||||||
React-perflogger:
|
React-perflogger:
|
||||||
@@ -513,6 +521,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
|
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
|
||||||
ReactCommon:
|
ReactCommon:
|
||||||
:path: "../node_modules/react-native/ReactCommon"
|
:path: "../node_modules/react-native/ReactCommon"
|
||||||
|
RNVectorIcons:
|
||||||
|
:path: "../node_modules/react-native-vector-icons"
|
||||||
Yoga:
|
Yoga:
|
||||||
:path: "../node_modules/react-native/ReactCommon/yoga"
|
:path: "../node_modules/react-native/ReactCommon/yoga"
|
||||||
|
|
||||||
@@ -549,7 +559,8 @@ SPEC CHECKSUMS:
|
|||||||
React-jsiexecutor: 2cf8ea3753afb81dfcc386613dbbb0b5d155fb34
|
React-jsiexecutor: 2cf8ea3753afb81dfcc386613dbbb0b5d155fb34
|
||||||
React-jsinspector: 0eda09e9cf22bbb5dbb1d23143b03a31acf37d67
|
React-jsinspector: 0eda09e9cf22bbb5dbb1d23143b03a31acf37d67
|
||||||
React-logger: 5997ab008583826c10ffe4e1ff990363e975639d
|
React-logger: 5997ab008583826c10ffe4e1ff990363e975639d
|
||||||
react-native-update: 2b5ef06bfeaa668614c8deb7ec4d20dcf56f9278
|
react-native-safe-area-context: 0ee144a6170530ccc37a0fd9388e28d06f516a89
|
||||||
|
react-native-update: 767449a2cf592387b9aecb97980ec0536d72c890
|
||||||
React-perflogger: ad1416a715d86b32f456e5d0aed99c3b52f1de37
|
React-perflogger: ad1416a715d86b32f456e5d0aed99c3b52f1de37
|
||||||
React-RCTActionSheet: cbf7c6a953982562418ee72a1084ff7b9447b558
|
React-RCTActionSheet: cbf7c6a953982562418ee72a1084ff7b9447b558
|
||||||
React-RCTAnimation: 33df3e25824dd7313edec28dded2745542f9352b
|
React-RCTAnimation: 33df3e25824dd7313edec28dded2745542f9352b
|
||||||
@@ -562,6 +573,7 @@ SPEC CHECKSUMS:
|
|||||||
React-RCTVibration: 5462287ee85304ba1a00474665ab292e63a41663
|
React-RCTVibration: 5462287ee85304ba1a00474665ab292e63a41663
|
||||||
React-runtimeexecutor: 9df680f18497367bcf5c15b6b6406c0f2dfa2b6a
|
React-runtimeexecutor: 9df680f18497367bcf5c15b6b6406c0f2dfa2b6a
|
||||||
ReactCommon: c10f046f3ef8561e7c8e7e9b9dae2ecc9ffc48ef
|
ReactCommon: c10f046f3ef8561e7c8e7e9b9dae2ecc9ffc48ef
|
||||||
|
RNVectorIcons: bc7ee28cadf39c77a49232a14738dfce690f66cd
|
||||||
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
|
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
|
||||||
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
|
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
|
||||||
Yoga: d3820731e0ca3a4933f061ad29defaf7726e3251
|
Yoga: d3820731e0ca3a4933f061ad29defaf7726e3251
|
||||||
@@ -569,4 +581,4 @@ SPEC CHECKSUMS:
|
|||||||
|
|
||||||
PODFILE CHECKSUM: 618d17df10f335f1d113daac849a7997894646b2
|
PODFILE CHECKSUM: 618d17df10f335f1d113daac849a7997894646b2
|
||||||
|
|
||||||
COCOAPODS: 1.11.3
|
COCOAPODS: 1.14.3
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const extraNodeModules = {
|
// const extraNodeModules = {
|
||||||
react: path.resolve(__dirname, 'node_modules/react'),
|
// react: path.resolve(__dirname, 'node_modules/react'),
|
||||||
'react-native': path.resolve(__dirname, 'node_modules/react-native'),
|
// 'react-native': path.resolve(__dirname, 'node_modules/react-native'),
|
||||||
'react-native-update': path.resolve(__dirname, '../..'),
|
// 'react-native-update': path.resolve(__dirname, '../..'),
|
||||||
'@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'),
|
// '@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'),
|
||||||
};
|
// };
|
||||||
const watchFolders = [path.resolve(__dirname, '../..')];
|
// const watchFolders = [path.resolve(__dirname, '../..')];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
transformer: {
|
transformer: {
|
||||||
@@ -17,8 +17,8 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolver: {
|
// resolver: {
|
||||||
extraNodeModules,
|
// extraNodeModules,
|
||||||
},
|
// },
|
||||||
watchFolders,
|
// watchFolders,
|
||||||
};
|
};
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
"react-native": "0.69.8",
|
"react-native": "0.69.8",
|
||||||
"react-native-paper": "^5.12.1",
|
"react-native-paper": "^5.12.1",
|
||||||
"react-native-safe-area-context": "^4.8.2",
|
"react-native-safe-area-context": "^4.8.2",
|
||||||
"react-native-update": "link:../..",
|
"react-native-update": "^10.0.2",
|
||||||
"react-native-vector-icons": "^10.0.3"
|
"react-native-vector-icons": "^10.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@@ -24,29 +24,35 @@ function App() {
|
|||||||
switchVersionLater,
|
switchVersionLater,
|
||||||
switchVersion,
|
switchVersion,
|
||||||
updateInfo,
|
updateInfo,
|
||||||
|
packageVersion,
|
||||||
|
currentHash,
|
||||||
progress: {received, total} = {},
|
progress: {received, total} = {},
|
||||||
} = usePushy();
|
} = usePushy();
|
||||||
const [useDefaultAlert, setUseDefaultAlert] = useState(true);
|
const [useDefaultAlert, setUseDefaultAlert] = useState(true);
|
||||||
|
const [showTestConsole, setShowTestConsole] = useState(false);
|
||||||
const [showUpdateBanner, setShowUpdateBanner] = useState(false);
|
const [showUpdateBanner, setShowUpdateBanner] = useState(false);
|
||||||
const [showUpdateSnackbar, setShowUpdateSnackbar] = useState(false);
|
const [showUpdateSnackbar, setShowUpdateSnackbar] = useState(false);
|
||||||
const snackbarVisible =
|
const snackbarVisible =
|
||||||
showUpdateSnackbar &&
|
!useDefaultAlert && showUpdateSnackbar && updateInfo?.update;
|
||||||
updateInfo &&
|
|
||||||
updateInfo.updateAvailable &&
|
|
||||||
!useDefaultAlert;
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.welcome}>欢迎使用Pushy热更新服务</Text>
|
<Text style={styles.welcome}>欢迎使用Pushy热更新服务</Text>
|
||||||
<Switch
|
<View style={{flexDirection: 'row'}}>
|
||||||
value={useCustomUi}
|
<Text>
|
||||||
onValueChange={v => {
|
{useDefaultAlert ? '当前使用' : '当前不使用'}默认的alert更新提示
|
||||||
setUseDefaultAlert(v);
|
</Text>
|
||||||
client.setOptions({
|
<Switch
|
||||||
showAlert: v,
|
value={useDefaultAlert}
|
||||||
});
|
onValueChange={v => {
|
||||||
}}>
|
setUseDefaultAlert(v);
|
||||||
{useDefaultAlert ? '当前使用' : '当前不使用'}默认的alert更新提示
|
client?.setOptions({
|
||||||
</Switch>
|
useAlert: v,
|
||||||
|
});
|
||||||
|
setShowUpdateSnackbar(!v);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<Image
|
<Image
|
||||||
resizeMode={'contain'}
|
resizeMode={'contain'}
|
||||||
source={require('./assets/shezhi.png')}
|
source={require('./assets/shezhi.png')}
|
||||||
@@ -56,13 +62,17 @@ function App() {
|
|||||||
这是版本一 {'\n'}
|
这是版本一 {'\n'}
|
||||||
当前原生包版本号: {packageVersion}
|
当前原生包版本号: {packageVersion}
|
||||||
{'\n'}
|
{'\n'}
|
||||||
当前热更新版本Hash: {currentVersion || '(空)'}
|
当前热更新版本Hash: {currentHash || '(空)'}
|
||||||
{'\n'}
|
{'\n'}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>
|
<Text>
|
||||||
下载进度:{received} / {total}
|
下载进度:{received} / {total}
|
||||||
</Text>
|
</Text>
|
||||||
<TouchableOpacity onPress={checkUpdate}>
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
checkUpdate();
|
||||||
|
setShowUpdateSnackbar(true);
|
||||||
|
}}>
|
||||||
<Text style={styles.instructions}>点击这里检查更新</Text>
|
<Text style={styles.instructions}>点击这里检查更新</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
@@ -70,29 +80,34 @@ function App() {
|
|||||||
testID="testcase"
|
testID="testcase"
|
||||||
style={{marginTop: 15}}
|
style={{marginTop: 15}}
|
||||||
onLongPress={() => {
|
onLongPress={() => {
|
||||||
this.setState({showTestConsole: true});
|
setShowTestConsole(true);
|
||||||
}}>
|
}}>
|
||||||
<Text style={styles.instructions}>
|
<Text style={styles.instructions}>
|
||||||
react-native-update版本:{client.version}
|
react-native-update版本:{client?.version}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TestConsole visible={showTestConsole} />
|
<TestConsole visible={showTestConsole} />
|
||||||
<Snackbar
|
{snackbarVisible && (
|
||||||
visible={snackbarVisible}
|
<Snackbar
|
||||||
onDismiss={() => {
|
visible={snackbarVisible}
|
||||||
setShowUpdateSnackbar(false);
|
onDismiss={() => {
|
||||||
}}
|
|
||||||
action={{
|
|
||||||
label: '更新',
|
|
||||||
onPress: async () => {
|
|
||||||
setShowUpdateSnackbar(false);
|
setShowUpdateSnackbar(false);
|
||||||
await downloadUpdate();
|
}}
|
||||||
setShowUpdateBanner(true);
|
action={{
|
||||||
},
|
label: '更新',
|
||||||
}}>
|
onPress: async () => {
|
||||||
有新版本({updateInfo.version})可用,是否更新?
|
setShowUpdateSnackbar(false);
|
||||||
</Snackbar>
|
await downloadUpdate();
|
||||||
|
setShowUpdateBanner(true);
|
||||||
|
},
|
||||||
|
}}>
|
||||||
|
<Text style={{color: 'white'}}>
|
||||||
|
有新版本({updateInfo.name})可用,是否更新?
|
||||||
|
</Text>
|
||||||
|
</Snackbar>
|
||||||
|
)}
|
||||||
<Banner
|
<Banner
|
||||||
|
style={{width: '100%', position: 'absolute', top: 0}}
|
||||||
visible={showUpdateBanner}
|
visible={showUpdateBanner}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
@@ -138,7 +153,6 @@ const styles = StyleSheet.create({
|
|||||||
|
|
||||||
const pushyClient = new Pushy({
|
const pushyClient = new Pushy({
|
||||||
appKey,
|
appKey,
|
||||||
showAlert: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function Root() {
|
export default function Root() {
|
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"ios": {
|
"ios": {
|
||||||
"appId": 10976,
|
"appId": 24794,
|
||||||
"appKey": "p5q_rPYNOE0WdCf-i9ZCGPw-DUGUCMvY"
|
"appKey": "SqShg4Klnj2hG6LAFMW2PdcgSSuniz0T"
|
||||||
},
|
},
|
||||||
"android": {
|
"android": {
|
||||||
"appId": 10977,
|
"appId": 27509,
|
||||||
"appKey": "bUYKfZgtC9VirZsQbAt8qken2Gq2uxe3"
|
"appKey": "aQz3Uc2pA7gt_prDaQ4rbWRY"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6231,9 +6231,12 @@ react-native-safe-area-context@^4.8.2:
|
|||||||
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65"
|
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65"
|
||||||
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==
|
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==
|
||||||
|
|
||||||
"react-native-update@link:../..":
|
react-native-update@^10.0.2:
|
||||||
version "0.0.0"
|
version "10.0.2"
|
||||||
uid ""
|
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.0.2.tgz#2bb01ab6e41e72bbbb535cebd34083b1fed69eb0"
|
||||||
|
integrity sha512-XkEPmTC3X6FV1eXq6uDyjfhXpAaug0HI48Mm+PkbMlXcgFjTrOmtuq7yuvemS2nPG2pwnrYQuGs0A6tE2aoRBA==
|
||||||
|
dependencies:
|
||||||
|
nanoid "^3.3.3"
|
||||||
|
|
||||||
react-native-vector-icons@^10.0.3:
|
react-native-vector-icons@^10.0.3:
|
||||||
version "10.0.3"
|
version "10.0.3"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "10.0.0-beta.1",
|
"version": "10.1.3",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": ">=16.8.0",
|
"react": ">=16.8.0",
|
||||||
"react-native": ">=0.57.0"
|
"react-native": ">=0.59.0"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/reactnativecn/react-native-pushy#readme",
|
"homepage": "https://github.com/reactnativecn/react-native-pushy#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { CheckResult, PushyOptions, ProgressData } from './type';
|
import { CheckResult, PushyOptions, ProgressData, EventType } from './type';
|
||||||
import { assertRelease, log } from './utils';
|
import { assertRelease, log } from './utils';
|
||||||
import {
|
import {
|
||||||
EmitterSubscription,
|
EmitterSubscription,
|
||||||
@@ -12,9 +12,9 @@ import {
|
|||||||
pushyNativeEventEmitter,
|
pushyNativeEventEmitter,
|
||||||
currentVersion,
|
currentVersion,
|
||||||
packageVersion,
|
packageVersion,
|
||||||
report,
|
|
||||||
rolledBackVersion,
|
rolledBackVersion,
|
||||||
setLocalHashInfo,
|
setLocalHashInfo,
|
||||||
|
isRolledBack,
|
||||||
} from './core';
|
} from './core';
|
||||||
|
|
||||||
const defaultServer = {
|
const defaultServer = {
|
||||||
@@ -25,12 +25,16 @@ const defaultServer = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const empty = {};
|
const empty = {};
|
||||||
|
const noop = () => {};
|
||||||
|
|
||||||
export class Pushy {
|
export class Pushy {
|
||||||
options: PushyOptions = {
|
options: PushyOptions = {
|
||||||
appKey: '',
|
appKey: '',
|
||||||
server: defaultServer,
|
server: defaultServer,
|
||||||
autoMarkSuccess: true,
|
autoMarkSuccess: true,
|
||||||
useAlert: true,
|
useAlert: true,
|
||||||
|
strategy: 'both',
|
||||||
|
logger: noop,
|
||||||
};
|
};
|
||||||
|
|
||||||
lastChecking: number;
|
lastChecking: number;
|
||||||
@@ -54,10 +58,45 @@ export class Pushy {
|
|||||||
for (const [key, value] of Object.entries(options)) {
|
for (const [key, value] of Object.entries(options)) {
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
this.options[key] = value;
|
this.options[key] = value;
|
||||||
|
if (key === 'logger') {
|
||||||
|
if (isRolledBack) {
|
||||||
|
this.report({
|
||||||
|
type: 'rollback',
|
||||||
|
data: {
|
||||||
|
rolledBackVersion,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
report = ({
|
||||||
|
type,
|
||||||
|
message = '',
|
||||||
|
data = {},
|
||||||
|
}: {
|
||||||
|
type: EventType;
|
||||||
|
message?: string;
|
||||||
|
data?: Record<string, string | number>;
|
||||||
|
}) => {
|
||||||
|
log(type + ' ' + message);
|
||||||
|
const { logger = noop, appKey } = this.options;
|
||||||
|
logger({
|
||||||
|
type,
|
||||||
|
data: {
|
||||||
|
appKey,
|
||||||
|
currentVersion,
|
||||||
|
cInfo,
|
||||||
|
packageVersion,
|
||||||
|
buildTime,
|
||||||
|
message,
|
||||||
|
...data,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
getCheckUrl = (endpoint: string = this.options.server!.main) => {
|
getCheckUrl = (endpoint: string = this.options.server!.main) => {
|
||||||
return `${endpoint}/checkUpdate/${this.options.appKey}`;
|
return `${endpoint}/checkUpdate/${this.options.appKey}`;
|
||||||
};
|
};
|
||||||
@@ -78,7 +117,7 @@ export class Pushy {
|
|||||||
}
|
}
|
||||||
this.marked = true;
|
this.marked = true;
|
||||||
PushyModule.markSuccess();
|
PushyModule.markSuccess();
|
||||||
report({ type: 'markSuccess' });
|
this.report({ type: 'markSuccess' });
|
||||||
};
|
};
|
||||||
switchVersion = (hash: string) => {
|
switchVersion = (hash: string) => {
|
||||||
assertRelease();
|
assertRelease();
|
||||||
@@ -107,7 +146,7 @@ export class Pushy {
|
|||||||
return this.lastResult;
|
return this.lastResult;
|
||||||
}
|
}
|
||||||
this.lastChecking = now;
|
this.lastChecking = now;
|
||||||
report({ type: 'checking' });
|
this.report({ type: 'checking' });
|
||||||
const fetchPayload = {
|
const fetchPayload = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -125,7 +164,7 @@ export class Pushy {
|
|||||||
try {
|
try {
|
||||||
resp = await fetch(this.getCheckUrl(), fetchPayload);
|
resp = await fetch(this.getCheckUrl(), fetchPayload);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
report({
|
this.report({
|
||||||
type: 'errorChecking',
|
type: 'errorChecking',
|
||||||
message: 'Can not connect to update server. Trying backup endpoints.',
|
message: 'Can not connect to update server. Trying backup endpoints.',
|
||||||
});
|
});
|
||||||
@@ -141,7 +180,7 @@ export class Pushy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
report({
|
this.report({
|
||||||
type: 'errorChecking',
|
type: 'errorChecking',
|
||||||
message: 'Can not connect to update server. Please check your network.',
|
message: 'Can not connect to update server. Please check your network.',
|
||||||
});
|
});
|
||||||
@@ -152,9 +191,8 @@ export class Pushy {
|
|||||||
this.lastResult = result;
|
this.lastResult = result;
|
||||||
|
|
||||||
if (resp.status !== 200) {
|
if (resp.status !== 200) {
|
||||||
report({
|
this.report({
|
||||||
type: 'errorChecking',
|
type: 'errorChecking',
|
||||||
//@ts-ignore
|
|
||||||
message: result.message,
|
message: result.message,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -187,11 +225,11 @@ export class Pushy {
|
|||||||
onDownloadProgress?: (data: ProgressData) => void,
|
onDownloadProgress?: (data: ProgressData) => void,
|
||||||
) => {
|
) => {
|
||||||
assertRelease();
|
assertRelease();
|
||||||
if (!('update' in info)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const { hash, diffUrl, pdiffUrl, updateUrl, name, description, metaInfo } =
|
const { hash, diffUrl, pdiffUrl, updateUrl, name, description, metaInfo } =
|
||||||
info;
|
info;
|
||||||
|
if (!info.update || !hash) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (rolledBackVersion === hash) {
|
if (rolledBackVersion === hash) {
|
||||||
log(`rolledback hash ${rolledBackVersion}, ignored`);
|
log(`rolledback hash ${rolledBackVersion}, ignored`);
|
||||||
return;
|
return;
|
||||||
@@ -214,7 +252,7 @@ export class Pushy {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let succeeded = false;
|
let succeeded = false;
|
||||||
report({ type: 'downloading' });
|
this.report({ type: 'downloading' });
|
||||||
if (diffUrl) {
|
if (diffUrl) {
|
||||||
log('downloading diff');
|
log('downloading diff');
|
||||||
try {
|
try {
|
||||||
@@ -257,11 +295,12 @@ export class Pushy {
|
|||||||
delete this.progressHandlers[hash];
|
delete this.progressHandlers[hash];
|
||||||
}
|
}
|
||||||
if (!succeeded) {
|
if (!succeeded) {
|
||||||
return report({
|
return this.report({
|
||||||
type: 'errorUpdate',
|
type: 'errorUpdate',
|
||||||
data: { newVersion: hash },
|
data: { newVersion: hash },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
log('downloaded hash:', hash);
|
||||||
setLocalHashInfo(hash, {
|
setLocalHashInfo(hash, {
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
@@ -277,17 +316,17 @@ export class Pushy {
|
|||||||
if (Platform.OS !== 'android') {
|
if (Platform.OS !== 'android') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
report({ type: 'downloadingApk' });
|
this.report({ type: 'downloadingApk' });
|
||||||
if (Platform.Version <= 23) {
|
if (Platform.Version <= 23) {
|
||||||
try {
|
try {
|
||||||
const granted = await PermissionsAndroid.request(
|
const granted = await PermissionsAndroid.request(
|
||||||
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
||||||
);
|
);
|
||||||
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
|
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
|
||||||
return report({ type: 'rejectStoragePermission' });
|
return this.report({ type: 'rejectStoragePermission' });
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return report({ type: 'errorStoragePermission' });
|
return this.report({ type: 'errorStoragePermission' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const progressKey = 'downloadingApk';
|
const progressKey = 'downloadingApk';
|
||||||
@@ -306,7 +345,7 @@ export class Pushy {
|
|||||||
target: 'update.apk',
|
target: 'update.apk',
|
||||||
hash: progressKey,
|
hash: progressKey,
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
report({ type: 'errowDownloadAndInstallApk' });
|
this.report({ type: 'errowDownloadAndInstallApk' });
|
||||||
});
|
});
|
||||||
if (this.progressHandlers[progressKey]) {
|
if (this.progressHandlers[progressKey]) {
|
||||||
this.progressHandlers[progressKey].remove();
|
this.progressHandlers[progressKey].remove();
|
||||||
|
13
src/client.web.js
Normal file
13
src/client.web.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const noop = () => {};
|
||||||
|
export class Pushy {
|
||||||
|
constructor() {
|
||||||
|
console.warn(
|
||||||
|
'react-native-update is not supported and will do nothing on web.',
|
||||||
|
);
|
||||||
|
return new Proxy(this, {
|
||||||
|
get() {
|
||||||
|
return noop;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@@ -2,27 +2,35 @@ import { createContext, useContext } from 'react';
|
|||||||
import { CheckResult, ProgressData } from './type';
|
import { CheckResult, ProgressData } from './type';
|
||||||
import { Pushy } from './client';
|
import { Pushy } from './client';
|
||||||
|
|
||||||
const empty = {};
|
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
|
const asyncNoop = () => Promise.resolve();
|
||||||
|
|
||||||
export const defaultContext = {
|
export const defaultContext = {
|
||||||
checkUpdate: () => Promise.resolve(empty),
|
checkUpdate: asyncNoop,
|
||||||
switchVersion: noop,
|
switchVersion: noop,
|
||||||
switchVersionLater: noop,
|
switchVersionLater: noop,
|
||||||
markSuccess: noop,
|
markSuccess: noop,
|
||||||
dismissError: noop,
|
dismissError: noop,
|
||||||
downloadUpdate: noop,
|
downloadUpdate: asyncNoop,
|
||||||
|
downloadAndInstallApk: asyncNoop,
|
||||||
|
getCurrentVersionInfo: () => Promise.resolve({}),
|
||||||
currentHash: '',
|
currentHash: '',
|
||||||
packageVersion: '',
|
packageVersion: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PushyContext = createContext<{
|
export const PushyContext = createContext<{
|
||||||
checkUpdate: () => void;
|
checkUpdate: () => Promise<void>;
|
||||||
switchVersion: () => void;
|
switchVersion: () => void;
|
||||||
switchVersionLater: () => void;
|
switchVersionLater: () => void;
|
||||||
markSuccess: () => void;
|
markSuccess: () => void;
|
||||||
dismissError: () => void;
|
dismissError: () => void;
|
||||||
downloadUpdate: () => void;
|
downloadUpdate: () => Promise<void>;
|
||||||
|
downloadAndInstallApk: (url: string) => Promise<void>;
|
||||||
|
getCurrentVersionInfo: () => Promise<{
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
metaInfo?: string;
|
||||||
|
}>;
|
||||||
currentHash: string;
|
currentHash: string;
|
||||||
packageVersion: string;
|
packageVersion: string;
|
||||||
client?: Pushy;
|
client?: Pushy;
|
||||||
|
39
src/core.ts
39
src/core.ts
@@ -1,5 +1,4 @@
|
|||||||
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
||||||
import { EventType, UpdateEventsLogger } from './type';
|
|
||||||
import { log } from './utils';
|
import { log } from './utils';
|
||||||
const {
|
const {
|
||||||
version: v,
|
version: v,
|
||||||
@@ -58,44 +57,6 @@ if (!uuid) {
|
|||||||
PushyModule.setUuid(uuid);
|
PushyModule.setUuid(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
const noop = () => {};
|
|
||||||
let reporter: UpdateEventsLogger = noop;
|
|
||||||
|
|
||||||
export function onPushyEvents(customReporter: UpdateEventsLogger) {
|
|
||||||
reporter = customReporter;
|
|
||||||
if (isRolledBack) {
|
|
||||||
report({
|
|
||||||
type: 'rollback',
|
|
||||||
data: {
|
|
||||||
rolledBackVersion,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function report({
|
|
||||||
type,
|
|
||||||
message = '',
|
|
||||||
data = {},
|
|
||||||
}: {
|
|
||||||
type: EventType;
|
|
||||||
message?: string;
|
|
||||||
data?: Record<string, string | number>;
|
|
||||||
}) {
|
|
||||||
log(type + ' ' + message);
|
|
||||||
reporter({
|
|
||||||
type,
|
|
||||||
data: {
|
|
||||||
currentVersion,
|
|
||||||
cInfo,
|
|
||||||
packageVersion,
|
|
||||||
buildTime,
|
|
||||||
message,
|
|
||||||
...data,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
log('uuid: ' + uuid);
|
log('uuid: ' + uuid);
|
||||||
|
|
||||||
export const cInfo = {
|
export const cInfo = {
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
import { Fragment } from 'react';
|
|
||||||
|
|
||||||
const noop = () => {};
|
|
||||||
export class Pushy {
|
|
||||||
constructor() {
|
|
||||||
console.warn('react-native-update is not supported and will do nothing on web.');
|
|
||||||
return new Proxy(this, {
|
|
||||||
get() {
|
|
||||||
return noop;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { PushyContext, usePushy } from './context';
|
|
||||||
|
|
||||||
export const PushyProvider = Fragment;
|
|
@@ -13,8 +13,13 @@ import {
|
|||||||
Linking,
|
Linking,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { Pushy } from './client';
|
import { Pushy } from './client';
|
||||||
import { currentVersion, isFirstTime, packageVersion } from './core';
|
import {
|
||||||
import { CheckResult } from './type';
|
currentVersion,
|
||||||
|
isFirstTime,
|
||||||
|
packageVersion,
|
||||||
|
getCurrentVersionInfo,
|
||||||
|
} from './core';
|
||||||
|
import { CheckResult, ProgressData } from './type';
|
||||||
import { PushyContext } from './context';
|
import { PushyContext } from './context';
|
||||||
|
|
||||||
export const PushyProvider = ({
|
export const PushyProvider = ({
|
||||||
@@ -24,44 +29,43 @@ export const PushyProvider = ({
|
|||||||
client: Pushy;
|
client: Pushy;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}) => {
|
}) => {
|
||||||
const { strategy, useAlert } = client.options;
|
const { options } = client;
|
||||||
const stateListener = useRef<NativeEventSubscription>();
|
const stateListener = useRef<NativeEventSubscription>();
|
||||||
const [updateInfo, setUpdateInfo] = useState<CheckResult>();
|
const [updateInfo, setUpdateInfo] = useState<CheckResult>();
|
||||||
|
const [progress, setProgress] = useState<ProgressData>();
|
||||||
const [lastError, setLastError] = useState<Error>();
|
const [lastError, setLastError] = useState<Error>();
|
||||||
|
|
||||||
const dismissError = useCallback(() => {
|
const dismissError = useCallback(() => {
|
||||||
if (lastError) {
|
setLastError(undefined);
|
||||||
setLastError(undefined);
|
}, []);
|
||||||
}
|
|
||||||
}, [lastError]);
|
|
||||||
|
|
||||||
const showAlert = useCallback(
|
const showAlert = useCallback(
|
||||||
(...args: Parameters<typeof Alert.alert>) => {
|
(...args: Parameters<typeof Alert.alert>) => {
|
||||||
if (useAlert) {
|
if (options.useAlert) {
|
||||||
Alert.alert(...args);
|
Alert.alert(...args);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[useAlert],
|
[options],
|
||||||
);
|
);
|
||||||
|
|
||||||
const switchVersion = useCallback(() => {
|
const switchVersion = useCallback(() => {
|
||||||
if (updateInfo && 'hash' in updateInfo) {
|
if (updateInfo && updateInfo.hash) {
|
||||||
client.switchVersion(updateInfo.hash);
|
client.switchVersion(updateInfo.hash);
|
||||||
}
|
}
|
||||||
}, [client, updateInfo]);
|
}, [client, updateInfo]);
|
||||||
|
|
||||||
const switchVersionLater = useCallback(() => {
|
const switchVersionLater = useCallback(() => {
|
||||||
if (updateInfo && 'hash' in updateInfo) {
|
if (updateInfo && updateInfo.hash) {
|
||||||
client.switchVersionLater(updateInfo.hash);
|
client.switchVersionLater(updateInfo.hash);
|
||||||
}
|
}
|
||||||
}, [client, updateInfo]);
|
}, [client, updateInfo]);
|
||||||
|
|
||||||
const downloadUpdate = useCallback(async () => {
|
const downloadUpdate = useCallback(async () => {
|
||||||
if (!updateInfo || !('update' in updateInfo)) {
|
if (!updateInfo || !updateInfo.update) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const hash = await client.downloadUpdate(updateInfo);
|
const hash = await client.downloadUpdate(updateInfo, setProgress);
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -88,6 +92,15 @@ export const PushyProvider = ({
|
|||||||
}
|
}
|
||||||
}, [client, showAlert, updateInfo]);
|
}, [client, showAlert, updateInfo]);
|
||||||
|
|
||||||
|
const downloadAndInstallApk = useCallback(
|
||||||
|
async (downloadUrl: string) => {
|
||||||
|
if (Platform.OS === 'android' && downloadUrl) {
|
||||||
|
await client.downloadAndInstallApk(downloadUrl, setProgress);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[client],
|
||||||
|
);
|
||||||
|
|
||||||
const checkUpdate = useCallback(async () => {
|
const checkUpdate = useCallback(async () => {
|
||||||
let info: CheckResult;
|
let info: CheckResult;
|
||||||
try {
|
try {
|
||||||
@@ -98,7 +111,7 @@ export const PushyProvider = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setUpdateInfo(info);
|
setUpdateInfo(info);
|
||||||
if ('expired' in info) {
|
if (info.expired) {
|
||||||
const { downloadUrl } = info;
|
const { downloadUrl } = info;
|
||||||
showAlert('提示', '您的应用版本已更新,点击更新下载安装新版本', [
|
showAlert('提示', '您的应用版本已更新,点击更新下载安装新版本', [
|
||||||
{
|
{
|
||||||
@@ -106,7 +119,7 @@ export const PushyProvider = ({
|
|||||||
onPress: () => {
|
onPress: () => {
|
||||||
if (downloadUrl) {
|
if (downloadUrl) {
|
||||||
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
|
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
|
||||||
client.downloadAndInstallApk(downloadUrl);
|
downloadAndInstallApk(downloadUrl);
|
||||||
} else {
|
} else {
|
||||||
Linking.openURL(downloadUrl);
|
Linking.openURL(downloadUrl);
|
||||||
}
|
}
|
||||||
@@ -114,7 +127,7 @@ export const PushyProvider = ({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
} else if ('update' in info) {
|
} else if (info.update) {
|
||||||
showAlert(
|
showAlert(
|
||||||
'提示',
|
'提示',
|
||||||
'检查到新的版本' + info.name + ',是否下载?\n' + info.description,
|
'检查到新的版本' + info.name + ',是否下载?\n' + info.description,
|
||||||
@@ -130,12 +143,13 @@ export const PushyProvider = ({
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [client, downloadUpdate, showAlert]);
|
}, [client, downloadAndInstallApk, downloadUpdate, showAlert]);
|
||||||
|
|
||||||
const markSuccess = client.markSuccess;
|
const markSuccess = client.markSuccess;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isFirstTime) {
|
const { strategy, dismissErrorAfter, autoMarkSuccess } = options;
|
||||||
|
if (isFirstTime && autoMarkSuccess) {
|
||||||
markSuccess();
|
markSuccess();
|
||||||
}
|
}
|
||||||
if (strategy === 'both' || strategy === 'onAppResume') {
|
if (strategy === 'both' || strategy === 'onAppResume') {
|
||||||
@@ -152,7 +166,6 @@ export const PushyProvider = ({
|
|||||||
checkUpdate();
|
checkUpdate();
|
||||||
}
|
}
|
||||||
let dismissErrorTimer: ReturnType<typeof setTimeout>;
|
let dismissErrorTimer: ReturnType<typeof setTimeout>;
|
||||||
const { dismissErrorAfter } = client.options;
|
|
||||||
if (typeof dismissErrorAfter === 'number' && dismissErrorAfter > 0) {
|
if (typeof dismissErrorAfter === 'number' && dismissErrorAfter > 0) {
|
||||||
dismissErrorTimer = setTimeout(() => {
|
dismissErrorTimer = setTimeout(() => {
|
||||||
dismissError();
|
dismissError();
|
||||||
@@ -162,7 +175,7 @@ export const PushyProvider = ({
|
|||||||
stateListener.current && stateListener.current.remove();
|
stateListener.current && stateListener.current.remove();
|
||||||
clearTimeout(dismissErrorTimer);
|
clearTimeout(dismissErrorTimer);
|
||||||
};
|
};
|
||||||
}, [checkUpdate, client.options, dismissError, markSuccess, strategy]);
|
}, [checkUpdate, options, dismissError, markSuccess]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PushyContext.Provider
|
<PushyContext.Provider
|
||||||
@@ -178,6 +191,9 @@ export const PushyProvider = ({
|
|||||||
downloadUpdate,
|
downloadUpdate,
|
||||||
packageVersion,
|
packageVersion,
|
||||||
currentHash: currentVersion,
|
currentHash: currentVersion,
|
||||||
|
progress,
|
||||||
|
downloadAndInstallApk,
|
||||||
|
getCurrentVersionInfo,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
2
src/provider.web.js
Normal file
2
src/provider.web.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import { Fragment } from 'react';
|
||||||
|
export const PushyProvider = Fragment;
|
38
src/type.ts
38
src/type.ts
@@ -1,31 +1,19 @@
|
|||||||
export interface ExpiredResult {
|
export interface CheckResult {
|
||||||
expired: true;
|
upToDate?: true;
|
||||||
downloadUrl: string;
|
expired?: true;
|
||||||
}
|
downloadUrl?: string;
|
||||||
|
update?: true;
|
||||||
export interface UpTodateResult {
|
name?: string; // version name
|
||||||
upToDate: true;
|
hash?: string;
|
||||||
paused?: 'app' | 'package';
|
description?: string;
|
||||||
}
|
metaInfo?: string;
|
||||||
|
pdiffUrl?: string;
|
||||||
export interface UpdateAvailableResult {
|
|
||||||
upToDate: false;
|
|
||||||
update: true;
|
|
||||||
name: string; // version name
|
|
||||||
hash: string;
|
|
||||||
description: string;
|
|
||||||
metaInfo: string;
|
|
||||||
pdiffUrl: string;
|
|
||||||
diffUrl?: string;
|
diffUrl?: string;
|
||||||
updateUrl?: string;
|
updateUrl?: string;
|
||||||
|
paused?: 'app' | 'package';
|
||||||
|
message?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CheckResult =
|
|
||||||
| ExpiredResult
|
|
||||||
| UpTodateResult
|
|
||||||
| UpdateAvailableResult
|
|
||||||
| {};
|
|
||||||
|
|
||||||
export interface ProgressData {
|
export interface ProgressData {
|
||||||
hash: string;
|
hash: string;
|
||||||
received: number;
|
received: number;
|
||||||
@@ -59,6 +47,7 @@ export interface EventData {
|
|||||||
newVersion?: string;
|
newVersion?: string;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateEventsLogger = ({
|
export type UpdateEventsLogger = ({
|
||||||
type,
|
type,
|
||||||
data,
|
data,
|
||||||
@@ -72,6 +61,7 @@ export interface PushyServerConfig {
|
|||||||
backups?: string[];
|
backups?: string[];
|
||||||
queryUrl?: string;
|
queryUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PushyOptions {
|
export interface PushyOptions {
|
||||||
appKey: string;
|
appKey: string;
|
||||||
server?: PushyServerConfig;
|
server?: PushyServerConfig;
|
||||||
|
Reference in New Issue
Block a user