1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-29 04:23:10 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm
2025-10-24 17:01:50 +08:00
parent 1b4c03924a
commit 6e4f432e26
12 changed files with 343 additions and 746 deletions

1
.gitignore vendored
View File

@@ -59,3 +59,4 @@ harmony/package
harmony/pushy/.preview
Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/meta.json
**/.hvigor
Example/harmony_use_pushy/harmony/entry/src/main/cpp/generated

View File

@@ -1,4 +1,3 @@
/* eslint-disable react/no-unstable-nested-components */
/* eslint-disable react-native/no-inline-styles */
import React, {useState} from 'react';
import {StyleSheet, Text, View, TouchableOpacity, Image} from 'react-native';
@@ -6,7 +5,7 @@ import {StyleSheet, Text, View, TouchableOpacity, Image} from 'react-native';
import TestConsole from './TestConsole';
import _updateConfig from './update.json';
import {PushyProvider, Pushy, usePushy} from 'react-native-update';
import {UpdateProvider, Pushy, useUpdate} from 'react-native-update';
const {appKey} = _updateConfig.harmony;
function App() {
@@ -20,7 +19,7 @@ function App() {
packageVersion,
currentHash,
progress: {received, total} = {},
} = usePushy();
} = useUpdate();
const [useDefaultAlert, setUseDefaultAlert] = useState(false);
const [showTestConsole, setShowTestConsole] = useState(false);
const [showUpdateBanner, setShowUpdateBanner] = useState(false);
@@ -41,6 +40,7 @@ function App() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>使Pushy热更新服务</Text>
{/* <Image source={require('./gmail.png')} style={styles.image} /> */}
{/* <Text style={styles.welcome}>😁hdiffFromAPP更新成功</Text> */}
{/* <Text style={styles.welcome}>😁hdiffFromPPk更新成功</Text> */}
<View style={{flexDirection: 'row'}}>
@@ -166,7 +166,7 @@ function App() {
style={{marginRight: 20}}>
<Text style={{color: '#2196F3'}}></Text>
</TouchableOpacity>
<TouchableOpacity onPress={switchVersion}>
<TouchableOpacity onPress={() => switchVersion()}>
<Text style={{color: '#2196F3'}}></Text>
</TouchableOpacity>
</View>
@@ -204,18 +204,22 @@ const styles = StyleSheet.create({
color: '#333333',
marginBottom: 5,
},
image: {},
image: {
width: 109,
height: 40,
},
});
const pushyClient = new Pushy({
appKey,
debug: true,
updateStrategy: null,
});
export default function Root() {
return (
<PushyProvider client={pushyClient}>
<UpdateProvider client={pushyClient}>
<App />
</PushyProvider>
</UpdateProvider>
);
}

View File

@@ -1,6 +0,0 @@
source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"
gem 'cocoapods', '~> 1.12'

File diff suppressed because it is too large Load Diff

View File

@@ -1,65 +0,0 @@
/**
* This code was generated by "react-native codegen-harmony"
*
* Do not edit this file as changes may cause incorrect behavior and will be
* lost once the code is regenerated.
*
* @generatorVersion: 1
*/
#pragma once
#include "RNOH/Package.h"
#include "RNOH/ArkTSTurboModule.h"
namespace rnoh {
class RNOHGeneratedPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
public:
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
return nullptr;
};
};
class GeneratedEventEmitRequestHandler : public EventEmitRequestHandler {
public:
void handleEvent(Context const &ctx) override {
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
if (eventEmitter == nullptr) {
return;
}
std::vector<std::string> supportedEventNames = {
};
if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
}
}
};
class RNOHGeneratedPackage : public Package {
public:
RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){};
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
return std::make_unique<RNOHGeneratedPackageTurboModuleFactoryDelegate>();
}
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
return {
};
}
ComponentJSIBinderByString createComponentJSIBinderByName() override {
return {
};
};
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
return {
std::make_shared<GeneratedEventEmitRequestHandler>(),
};
}
};
} // namespace rnoh

File diff suppressed because one or more lines are too long

View File

@@ -18,7 +18,7 @@
"@react-native-oh/react-native-harmony": "^0.72.59",
"react": "18.2.0",
"react-native": "0.72.5",
"react-native-update": "latest"
"react-native-update": "^10.34.9"
},
"devDependencies": {
"@babel/core": "^7.20.0",

View File

@@ -57,7 +57,7 @@ export class DownloadTask {
try {
try {
const exists = fileIo.accessSync(params.targetFile);
let exists = fileIo.accessSync(params.targetFile);
if (exists) {
await fileIo.unlink(params.targetFile);
} else {
@@ -65,7 +65,7 @@ export class DownloadTask {
0,
params.targetFile.lastIndexOf('/'),
);
const exists = fileIo.accessSync(targetDir);
exists = fileIo.accessSync(targetDir);
if (!exists) {
await fileIo.mkdir(targetDir);
}

View File

@@ -101,6 +101,7 @@ export class UpdateContext {
params.hash = hash;
params.listener = listener;
params.targetFile = `${this.rootDir}/${hash}.ppk`;
params.unzipDirectory = `${this.rootDir}/${hash}`;
const downloadTask = new DownloadTask(this.context);
await downloadTask.execute(params);
} catch (e) {
@@ -162,8 +163,8 @@ export class UpdateContext {
const downloadTask = new DownloadTask(this.context);
return await downloadTask.execute(params);
} catch (e) {
throw e;
console.error('Failed to download APK patch:', e);
throw e;
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "10.34.9",
"version": "10.35.0",
"description": "react-native hot update",
"main": "src/index",
"scripts": {

View File

@@ -47,7 +47,7 @@ export const currentVersionInfo = _currentVersionInfo;
export const isFirstTime: boolean = PushyConstants.isFirstTime;
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
export const isRolledBack: boolean = typeof rolledBackVersion === 'string';
export const isRolledBack: boolean = !!rolledBackVersion;
export const buildTime: string = PushyConstants.buildTime;
let uuid = PushyConstants.uuid;