1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

v10.0.0-beta.2

This commit is contained in:
sunnylqm 2024-01-25 22:07:01 +08:00
parent 296498e20a
commit 05e5c5a1a7
No known key found for this signature in database
11 changed files with 67 additions and 72 deletions

View File

@ -284,17 +284,19 @@ PODS:
- React-jsinspector (0.69.8)
- React-logger (0.69.8):
- 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-Core
- react-native-update/HDiffPatch (= 9.0.0)
- react-native-update/RCTPushy (= 9.0.0)
- react-native-update/HDiffPatch (= 10.0.0-beta.1)
- react-native-update/RCTPushy (= 10.0.0-beta.1)
- SSZipArchive
- react-native-update/HDiffPatch (9.0.0):
- react-native-update/HDiffPatch (10.0.0-beta.1):
- React
- React-Core
- SSZipArchive
- react-native-update/RCTPushy (9.0.0):
- react-native-update/RCTPushy (10.0.0-beta.1):
- React
- React-Core
- SSZipArchive
@ -364,6 +366,8 @@ PODS:
- React-jsi (= 0.69.8)
- React-logger (= 0.69.8)
- React-perflogger (= 0.69.8)
- RNVectorIcons (10.0.3):
- React-Core
- SocketRocket (0.6.0)
- SSZipArchive (2.4.3)
- Yoga (1.14.0)
@ -414,6 +418,7 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- 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-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
@ -427,6 +432,7 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- 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`)
SPEC REPOS:
@ -487,6 +493,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
react-native-update:
:path: "../node_modules/react-native-update"
React-perflogger:
@ -513,6 +521,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNVectorIcons:
:path: "../node_modules/react-native-vector-icons"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"
@ -549,7 +559,8 @@ SPEC CHECKSUMS:
React-jsiexecutor: 2cf8ea3753afb81dfcc386613dbbb0b5d155fb34
React-jsinspector: 0eda09e9cf22bbb5dbb1d23143b03a31acf37d67
React-logger: 5997ab008583826c10ffe4e1ff990363e975639d
react-native-update: 2b5ef06bfeaa668614c8deb7ec4d20dcf56f9278
react-native-safe-area-context: 0ee144a6170530ccc37a0fd9388e28d06f516a89
react-native-update: 767449a2cf592387b9aecb97980ec0536d72c890
React-perflogger: ad1416a715d86b32f456e5d0aed99c3b52f1de37
React-RCTActionSheet: cbf7c6a953982562418ee72a1084ff7b9447b558
React-RCTAnimation: 33df3e25824dd7313edec28dded2745542f9352b
@ -562,6 +573,7 @@ SPEC CHECKSUMS:
React-RCTVibration: 5462287ee85304ba1a00474665ab292e63a41663
React-runtimeexecutor: 9df680f18497367bcf5c15b6b6406c0f2dfa2b6a
ReactCommon: c10f046f3ef8561e7c8e7e9b9dae2ecc9ffc48ef
RNVectorIcons: bc7ee28cadf39c77a49232a14738dfce690f66cd
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
Yoga: d3820731e0ca3a4933f061ad29defaf7726e3251
@ -569,4 +581,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 618d17df10f335f1d113daac849a7997894646b2
COCOAPODS: 1.11.3
COCOAPODS: 1.14.3

View File

@ -18,7 +18,7 @@
"react-native": "0.69.8",
"react-native-paper": "^5.12.1",
"react-native-safe-area-context": "^4.8.2",
"react-native-update": "10.0.0-beta.1",
"react-native-update": "^10.0.0-beta.2",
"react-native-vector-icons": "^10.0.3"
},
"devDependencies": {

View File

@ -33,10 +33,7 @@ function App() {
const [showUpdateBanner, setShowUpdateBanner] = useState(false);
const [showUpdateSnackbar, setShowUpdateSnackbar] = useState(false);
const snackbarVisible =
showUpdateSnackbar &&
updateInfo &&
updateInfo.updateAvailable &&
!useDefaultAlert;
showUpdateSnackbar && updateInfo?.update && !useDefaultAlert;
return (
<View style={styles.container}>
<Text style={styles.welcome}>使Pushy热更新服务</Text>
@ -48,8 +45,8 @@ function App() {
value={useDefaultAlert}
onValueChange={v => {
setUseDefaultAlert(v);
client.setOptions({
showAlert: v,
client?.setOptions({
useAlert: v,
});
}}
/>
@ -80,7 +77,7 @@ function App() {
setShowTestConsole(true);
}}>
<Text style={styles.instructions}>
react-native-update版本{client.version}
react-native-update版本{client?.version}
</Text>
</TouchableOpacity>
<TestConsole visible={showTestConsole} />
@ -98,7 +95,7 @@ function App() {
setShowUpdateBanner(true);
},
}}>
<Text>({updateInfo.version})</Text>
<Text>({updateInfo.name})</Text>
</Snackbar>
)}
<Banner
@ -147,7 +144,6 @@ const styles = StyleSheet.create({
const pushyClient = new Pushy({
appKey,
showAlert: false,
});
export default function Root() {

View File

@ -6231,10 +6231,10 @@ 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"
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==
react-native-update@10.0.0-beta.1:
version "10.0.0-beta.1"
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.0.0-beta.1.tgz#bc49a7197dd19c16ba798ea13324b4b292edd052"
integrity sha512-PFTsut8SL+vqAPtBUzPg9KKU9mFgCktKttifzM8B4puSoburlSN2UnD+eDWxLkXyIWQtoQAqAmXPE1/zA/e7dw==
react-native-update@^10.0.0-beta.2:
version "10.0.0-beta.2"
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.0.0-beta.2.tgz#2974f168a61c80d3240f10923294bc6e36879c08"
integrity sha512-/HjuxRVLGSxTqcGApsRHTJO89Md47qwHlsE4lXKigkmHPdE1q5RjFVEu0ee0hkMtSOHO14bpnbjFICiNp+9kLQ==
dependencies:
nanoid "^3.3.3"

View File

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

View File

@ -154,7 +154,6 @@ export class Pushy {
if (resp.status !== 200) {
report({
type: 'errorChecking',
//@ts-ignore
message: result.message,
});
}
@ -187,11 +186,11 @@ export class Pushy {
onDownloadProgress?: (data: ProgressData) => void,
) => {
assertRelease();
if (!('update' in info)) {
return;
}
const { hash, diffUrl, pdiffUrl, updateUrl, name, description, metaInfo } =
info;
if (!info.update || !hash) {
return;
}
if (rolledBackVersion === hash) {
log(`rolledback hash ${rolledBackVersion}, ignored`);
return;

13
src/client.web.js Normal file
View 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;
},
});
}
}

View File

@ -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;

View File

@ -45,19 +45,19 @@ export const PushyProvider = ({
);
const switchVersion = useCallback(() => {
if (updateInfo && 'hash' in updateInfo) {
if (updateInfo && updateInfo.hash) {
client.switchVersion(updateInfo.hash);
}
}, [client, updateInfo]);
const switchVersionLater = useCallback(() => {
if (updateInfo && 'hash' in updateInfo) {
if (updateInfo && updateInfo.hash) {
client.switchVersionLater(updateInfo.hash);
}
}, [client, updateInfo]);
const downloadUpdate = useCallback(async () => {
if (!updateInfo || !('update' in updateInfo)) {
if (!updateInfo || !updateInfo.update) {
return;
}
try {
@ -98,7 +98,7 @@ export const PushyProvider = ({
return;
}
setUpdateInfo(info);
if ('expired' in info) {
if (info.expired) {
const { downloadUrl } = info;
showAlert('提示', '您的应用版本已更新,点击更新下载安装新版本', [
{
@ -114,7 +114,7 @@ export const PushyProvider = ({
},
},
]);
} else if ('update' in info) {
} else if (info.update) {
showAlert(
'提示',
'检查到新的版本' + info.name + ',是否下载?\n' + info.description,

2
src/provider.web.js Normal file
View File

@ -0,0 +1,2 @@
import { Fragment } from 'react';
export const PushyProvider = Fragment;

View File

@ -1,31 +1,19 @@
export interface ExpiredResult {
expired: true;
downloadUrl: string;
}
export interface UpTodateResult {
upToDate: true;
paused?: 'app' | 'package';
}
export interface UpdateAvailableResult {
upToDate: false;
update: true;
name: string; // version name
hash: string;
description: string;
metaInfo: string;
pdiffUrl: string;
export interface CheckResult {
upToDate?: true;
expired?: true;
downloadUrl?: string;
update?: true;
name?: string; // version name
hash?: string;
description?: string;
metaInfo?: string;
pdiffUrl?: string;
diffUrl?: string;
updateUrl?: string;
paused?: 'app' | 'package';
message?: string;
}
export type CheckResult =
| ExpiredResult
| UpTodateResult
| UpdateAvailableResult
| {};
export interface ProgressData {
hash: string;
received: number;
@ -59,6 +47,7 @@ export interface EventData {
newVersion?: string;
[key: string]: any;
}
export type UpdateEventsLogger = ({
type,
data,
@ -72,6 +61,7 @@ export interface PushyServerConfig {
backups?: string[];
queryUrl?: string;
}
export interface PushyOptions {
appKey: string;
server?: PushyServerConfig;