1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-11-24 00:13:36 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Compare commits

..

7 Commits

Author SHA1 Message Date
sunnylqm
34e053ae48 update react-native-update version from 10.35.2 to 10.35.3 in package.json and remove lastVersion from shared preferences in UpdateContext.java 2025-10-26 23:51:58 +08:00
sunnylqm
d55ef1d8c8 update react-native-update version from 10.35.1 to 10.35.2 in package.json and bun.lock 2025-10-26 23:27:24 +08:00
sunnylqm
de3e7d9e4c decrement version in package.json from 10.35.3 to 10.35.2 2025-10-26 23:12:29 +08:00
sunnylqm
e0201d3882 fix hvigor plugin 2025-10-26 23:10:44 +08:00
sunnylqm
ba5b35813d fix unzip 2025-10-25 00:59:12 +08:00
sunnylqm
3134f36739 update example dep 2025-10-24 23:01:50 +08:00
sunnylqm
d4f4740053 update lock 2025-10-24 22:52:15 +08:00
11 changed files with 82 additions and 79 deletions

View File

@@ -7,7 +7,7 @@
"@react-native-oh/react-native-harmony": "^0.72.59", "@react-native-oh/react-native-harmony": "^0.72.59",
"react": "18.2.0", "react": "18.2.0",
"react-native": "0.72.5", "react-native": "0.72.5",
"react-native-update": "^10.35.0", "react-native-update": "^10.35.2",
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.0", "@babel/core": "^7.20.0",
@@ -1399,7 +1399,7 @@
"react-native": ["react-native@0.72.5", "", { "dependencies": { "@jest/create-cache-key-function": "^29.2.1", "@react-native-community/cli": "11.3.7", "@react-native-community/cli-platform-android": "11.3.7", "@react-native-community/cli-platform-ios": "11.3.7", "@react-native/assets-registry": "^0.72.0", "@react-native/codegen": "^0.72.7", "@react-native/gradle-plugin": "^0.72.11", "@react-native/js-polyfills": "^0.72.1", "@react-native/normalize-colors": "^0.72.0", "@react-native/virtualized-lists": "^0.72.8", "abort-controller": "^3.0.0", "anser": "^1.4.9", "base64-js": "^1.1.2", "deprecated-react-native-prop-types": "4.1.0", "event-target-shim": "^5.0.1", "flow-enums-runtime": "^0.0.5", "invariant": "^2.2.4", "jest-environment-node": "^29.2.1", "jsc-android": "^250231.0.0", "memoize-one": "^5.0.0", "metro-runtime": "0.76.8", "metro-source-map": "0.76.8", "mkdirp": "^0.5.1", "nullthrows": "^1.1.1", "pretty-format": "^26.5.2", "promise": "^8.3.0", "react-devtools-core": "^4.27.2", "react-refresh": "^0.4.0", "react-shallow-renderer": "^16.15.0", "regenerator-runtime": "^0.13.2", "scheduler": "0.24.0-canary-efb381bbf-20230505", "stacktrace-parser": "^0.1.10", "use-sync-external-store": "^1.0.0", "whatwg-fetch": "^3.0.0", "ws": "^6.2.2", "yargs": "^17.6.2" }, "peerDependencies": { "react": "18.2.0" }, "bin": { "react-native": "cli.js" } }, "sha512-oIewslu5DBwOmo7x5rdzZlZXCqDIna0R4dUwVpfmVteORYLr4yaZo5wQnMeR+H7x54GaMhmgeqp0ZpULtulJFg=="], "react-native": ["react-native@0.72.5", "", { "dependencies": { "@jest/create-cache-key-function": "^29.2.1", "@react-native-community/cli": "11.3.7", "@react-native-community/cli-platform-android": "11.3.7", "@react-native-community/cli-platform-ios": "11.3.7", "@react-native/assets-registry": "^0.72.0", "@react-native/codegen": "^0.72.7", "@react-native/gradle-plugin": "^0.72.11", "@react-native/js-polyfills": "^0.72.1", "@react-native/normalize-colors": "^0.72.0", "@react-native/virtualized-lists": "^0.72.8", "abort-controller": "^3.0.0", "anser": "^1.4.9", "base64-js": "^1.1.2", "deprecated-react-native-prop-types": "4.1.0", "event-target-shim": "^5.0.1", "flow-enums-runtime": "^0.0.5", "invariant": "^2.2.4", "jest-environment-node": "^29.2.1", "jsc-android": "^250231.0.0", "memoize-one": "^5.0.0", "metro-runtime": "0.76.8", "metro-source-map": "0.76.8", "mkdirp": "^0.5.1", "nullthrows": "^1.1.1", "pretty-format": "^26.5.2", "promise": "^8.3.0", "react-devtools-core": "^4.27.2", "react-refresh": "^0.4.0", "react-shallow-renderer": "^16.15.0", "regenerator-runtime": "^0.13.2", "scheduler": "0.24.0-canary-efb381bbf-20230505", "stacktrace-parser": "^0.1.10", "use-sync-external-store": "^1.0.0", "whatwg-fetch": "^3.0.0", "ws": "^6.2.2", "yargs": "^17.6.2" }, "peerDependencies": { "react": "18.2.0" }, "bin": { "react-native": "cli.js" } }, "sha512-oIewslu5DBwOmo7x5rdzZlZXCqDIna0R4dUwVpfmVteORYLr4yaZo5wQnMeR+H7x54GaMhmgeqp0ZpULtulJFg=="],
"react-native-update": ["react-native-update@10.35.0", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-jTFtTAmOec05Gf06ununz+bLFkLC7bu7GV2y5/VjEx3XDhk+/ohvpefIFYuaDub23+0Tbq85aIg9WlDa72tReQ=="], "react-native-update": ["react-native-update@10.35.2", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-rM/GGFY/yr5ANsBpEOOirIEVWzZ/aDIszzr5iGIbmiBFHNDlPNZL0pTGubHtglnhlkQbNoouVcYh9wbVQeivcA=="],
"react-native-url-polyfill": ["react-native-url-polyfill@2.0.0", "", { "dependencies": { "whatwg-url-without-unicode": "8.0.0-3" }, "peerDependencies": { "react-native": "*" } }, "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA=="], "react-native-url-polyfill": ["react-native-url-polyfill@2.0.0", "", { "dependencies": { "whatwg-url-without-unicode": "8.0.0-3" }, "peerDependencies": { "react-native": "*" } }, "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA=="],

View File

@@ -1,44 +1,9 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin'; import {hapTasks} from '@ohos/hvigor-ohos-plugin';
import fs from 'fs'; import {reactNativeUpdatePlugin} from 'pushy/hvigor-plugin';
import path from 'path';
export function generatePushyBuildTime(str?: string) {
return {
pluginId: 'PushyBuildTimePlugin',
apply(pluginContext) {
pluginContext.registerTask({
name: 'pushy_build_time',
run: (taskContext) => {
const metaFilePath = path.resolve(__dirname, 'src/main/resources/rawfile/meta.json');
const dirPath = path.dirname(metaFilePath);
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
}
const moduleJsonPath = path.resolve(__dirname, '../AppScope/app.json5');
let versionName = '';
if (fs.existsSync(moduleJsonPath)) {
const moduleContent = fs.readFileSync(moduleJsonPath, 'utf-8');
const versionMatch = moduleContent.match(/"versionName":\s*"([^"]+)"/);
if (versionMatch && versionMatch[1]) {
versionName = versionMatch[1];
}
}
const buildTime = new Date().toISOString();
const metaContent = {
pushy_build_time: buildTime,
versionName: versionName
};
fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4));
console.log(`Build time written to ${metaFilePath}`);
},
dependencies: [],
postDependencies: ['default@BuildJS']
})
}
}
}
export default { export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ system: hapTasks /* Built-in plugin of Hvigor. It cannot be modified. */,
plugins:[generatePushyBuildTime()] /* Custom plugin to extend the functionality of Hvigor. */ plugins: [
} reactNativeUpdatePlugin(),
] /* Custom plugin to extend the functionality of Hvigor. */,
};

View File

@@ -6,15 +6,15 @@
"lockfileVersion": 3, "lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": { "specifiers": {
"@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38", "@rnoh/react-native-openharmony@0.72.96": "@rnoh/react-native-openharmony@0.72.96",
"pushy@../../node_modules/react-native-update/harmony/pushy": "pushy@../../node_modules/react-native-update/harmony/pushy" "pushy@../../node_modules/react-native-update/harmony/pushy": "pushy@../../node_modules/react-native-update/harmony/pushy"
}, },
"packages": { "packages": {
"@rnoh/react-native-openharmony@0.72.38": { "@rnoh/react-native-openharmony@0.72.96": {
"name": "", "name": "",
"version": "0.72.38", "version": "0.72.96",
"integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==", "integrity": "sha512-gBbm8LLyqi5UE7qHWdZYeQnjyncfEpCczKZUP/9M2U1Z7exR0Kya8PMKMwr1ta5ujy7w/hZVC2LomEV4QvBeqA==",
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.38.har", "resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.96.har",
"registryType": "ohpm" "registryType": "ohpm"
}, },
"pushy@../../node_modules/react-native-update/harmony/pushy": { "pushy@../../node_modules/react-native-update/harmony/pushy": {

View File

@@ -1,6 +1,7 @@
{ {
"modelVersion": "5.0.0", "modelVersion": "5.0.0",
"dependencies": { "dependencies": {
pushy: 'file:../../node_modules/react-native-update/harmony/pushy'
}, },
"execution": { "execution": {
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */

View File

@@ -8,7 +8,7 @@
"lint": "eslint .", "lint": "eslint .",
"start": "npm run codegen && hdc rport tcp:8081 tcp:8081 && react-native start", "start": "npm run codegen && hdc rport tcp:8081 tcp:8081 && react-native start",
"codegen": "react-native codegen-harmony --rnoh-module-path ./harmony/react_native_openharmony", "codegen": "react-native codegen-harmony --rnoh-module-path ./harmony/react_native_openharmony",
"build": "pushy bundle --platform harmony", "build": "pushy bundle --platform harmony --no-interactive",
"test": "jest", "test": "jest",
"hdiffFromPPK": "pushy hdiffFromPPK .pushy/output/harmony.1735052610653.ppk .pushy/output/harmony.1735052678646.ppk .pushy/output/hdiff.ppk-patch", "hdiffFromPPK": "pushy hdiffFromPPK .pushy/output/harmony.1735052610653.ppk .pushy/output/harmony.1735052678646.ppk .pushy/output/hdiff.ppk-patch",
"hdiffFromApp": "pushy hdiffFromApp .pushy/output/version-1.0.0.app .pushy/output/harmony.1735052610653.ppk .pushy/output/hdiff.app-patch", "hdiffFromApp": "pushy hdiffFromApp .pushy/output/version-1.0.0.app .pushy/output/harmony.1735052610653.ppk .pushy/output/hdiff.app-patch",
@@ -18,7 +18,7 @@
"@react-native-oh/react-native-harmony": "^0.72.59", "@react-native-oh/react-native-harmony": "^0.72.59",
"react": "18.2.0", "react": "18.2.0",
"react-native": "0.72.5", "react-native": "0.72.5",
"react-native-update": "^10.35.0" "react-native-update": "^10.35.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.0", "@babel/core": "^7.20.0",

View File

@@ -273,6 +273,7 @@ public class UpdateContext {
if (lastVersion == null) { if (lastVersion == null) {
editor.remove("currentVersion"); editor.remove("currentVersion");
} else { } else {
editor.remove("lastVersion");
editor.putString("currentVersion", lastVersion); editor.putString("currentVersion", lastVersion);
} }
editor.putBoolean("firstTimeOk", true); editor.putBoolean("firstTimeOk", true);

View File

@@ -0,0 +1,41 @@
import fs from 'fs';
import path from 'path';
export function reactNativeUpdatePlugin() {
return {
pluginId: 'reactNativeUpdatePlugin',
apply(node) {
node.registerTask({
name: 'reactNativeUpdatePlugin',
run: () => {
const cwd = process.cwd();
const metaFilePath = path.resolve(
cwd,
'entry/src/main/resources/rawfile/meta.json',
);
fs.mkdirSync(path.dirname(metaFilePath), { recursive: true });
const moduleJsonPath = path.resolve(cwd, 'AppScope/app.json5');
let versionName = '';
if (fs.existsSync(moduleJsonPath)) {
const content = fs.readFileSync(moduleJsonPath, 'utf-8');
const match = content.match(
/(?:"versionName"|versionName):\s*["']([^"']+)["']/,
);
versionName = match?.[1] || '';
}
const metaContent = {
pushy_build_time: new Date().toISOString(),
versionName,
};
fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4));
console.log(`Build time written to ${metaFilePath}`);
},
dependencies: [],
postDependencies: ['default@BuildJS'],
});
},
};
}

View File

@@ -1,10 +1,8 @@
import http from '@ohos.net.http'; import http from '@ohos.net.http';
import fileIo from '@ohos.file.fs'; import fileIo from '@ohos.file.fs';
import util from '@ohos.util';
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
import { BusinessError } from '@kit.BasicServicesKit';
import { buffer } from '@kit.ArkTS'; import { buffer } from '@kit.ArkTS';
import zip from '@ohos.zlib'; import { zlib, BusinessError } from '@kit.BasicServicesKit';
import { EventHub } from './EventHub'; import { EventHub } from './EventHub';
import { DownloadTaskParams } from './DownloadTaskParams'; import { DownloadTaskParams } from './DownloadTaskParams';
import Pushy from 'librnupdate.so'; import Pushy from 'librnupdate.so';
@@ -37,7 +35,9 @@ export class DownloadTask {
if (stat.isDirectory()) { if (stat.isDirectory()) {
const files = await fileIo.listFile(path); const files = await fileIo.listFile(path);
for (const file of files) { for (const file of files) {
if (file === '.' || file === '..') continue; if (file === '.' || file === '..') {
continue;
}
await this.removeDirectory(`${path}/${file}`); await this.removeDirectory(`${path}/${file}`);
} }
await fileIo.rmdir(path); await fileIo.rmdir(path);
@@ -180,12 +180,7 @@ export class DownloadTask {
await this.removeDirectory(params.unzipDirectory); await this.removeDirectory(params.unzipDirectory);
await fileIo.mkdir(params.unzipDirectory); await fileIo.mkdir(params.unzipDirectory);
try { await zlib.decompressFile(params.targetFile, params.unzipDirectory);
await zip.decompressFile(params.targetFile, params.unzipDirectory);
} catch (error) {
console.error('Unzip failed:', error);
throw error;
}
} }
private async processUnzippedFiles(directory: string): Promise<ZipFile> { private async processUnzippedFiles(directory: string): Promise<ZipFile> {
@@ -193,7 +188,9 @@ export class DownloadTask {
try { try {
const files = await fileIo.listFile(directory); const files = await fileIo.listFile(directory);
for (const file of files) { for (const file of files) {
if (file === '.' || file === '..') continue; if (file === '.' || file === '..') {
continue;
}
const filePath = `${directory}/${file}`; const filePath = `${directory}/${file}`;
const stat = await fileIo.stat(filePath); const stat = await fileIo.stat(filePath);
@@ -230,7 +227,7 @@ export class DownloadTask {
let foundDiff = false; let foundDiff = false;
let foundBundlePatch = false; let foundBundlePatch = false;
const copyList: Map<string, Array<any>> = new Map(); const copyList: Map<string, Array<any>> = new Map();
await zip.decompressFile(params.targetFile, params.unzipDirectory); await zlib.decompressFile(params.targetFile, params.unzipDirectory);
const zipFile = await this.processUnzippedFiles(params.unzipDirectory); const zipFile = await this.processUnzippedFiles(params.unzipDirectory);
for (const entry of zipFile.entries) { for (const entry of zipFile.entries) {
const fn = entry.filename; const fn = entry.filename;
@@ -295,10 +292,6 @@ export class DownloadTask {
throw error; throw error;
} }
} }
if (fn !== '.DS_Store') {
await zip.decompressFile(fn, params.unzipDirectory);
}
} }
if (!foundDiff) { if (!foundDiff) {
@@ -318,7 +311,7 @@ export class DownloadTask {
let foundDiff = false; let foundDiff = false;
let foundBundlePatch = false; let foundBundlePatch = false;
const copyList: Map<string, Array<any>> = new Map(); const copyList: Map<string, Array<any>> = new Map();
await zip.decompressFile(params.targetFile, params.unzipDirectory); await zlib.decompressFile(params.targetFile, params.unzipDirectory);
const zipFile = await this.processUnzippedFiles(params.unzipDirectory); const zipFile = await this.processUnzippedFiles(params.unzipDirectory);
for (const entry of zipFile.entries) { for (const entry of zipFile.entries) {
const fn = entry.filename; const fn = entry.filename;
@@ -389,8 +382,6 @@ export class DownloadTask {
} }
} }
} }
await zip.decompressFile(entry.filename, params.unzipDirectory);
} }
if (!foundDiff) { if (!foundDiff) {
@@ -410,7 +401,9 @@ export class DownloadTask {
const files = await fileIo.listFile(bundlePath); const files = await fileIo.listFile(bundlePath);
for (const file of files) { for (const file of files) {
if (file === '.' || file === '..') continue; if (file === '.' || file === '..') {
continue;
}
const targets = copyList.get(file); const targets = copyList.get(file);
if (targets) { if (targets) {
@@ -443,7 +436,9 @@ export class DownloadTask {
try { try {
const files = await fileIo.listFile(params.unzipDirectory); const files = await fileIo.listFile(params.unzipDirectory);
for (const file of files) { for (const file of files) {
if (file.startsWith('.')) continue; if (file.startsWith('.')) {
continue;
}
const filePath = `${params.unzipDirectory}/${file}`; const filePath = `${params.unzipDirectory}/${file}`;
const stat = await fileIo.stat(filePath); const stat = await fileIo.stat(filePath);

View File

@@ -26,14 +26,13 @@ export class PushyFileJSBundleProvider extends JSBundleProvider {
if (!this.path) { if (!this.path) {
throw new JSBundleProviderError({ throw new JSBundleProviderError({
whatHappened: 'No pushy bundle found. using default bundle', whatHappened: 'No pushy bundle found. using default bundle',
howCanItBeFixed: ['']
}) })
} }
try { try {
const status = await fs.access(this.path, fs.OpenMode.READ_ONLY); await fs.access(this.path, fs.OpenMode.READ_ONLY);
if (status) { return {
return { filePath: this.path
filePath: this.path
}
} }
} catch (error) { } catch (error) {
throw new JSBundleProviderError({ throw new JSBundleProviderError({

View File

@@ -245,6 +245,7 @@ export class UpdateContext {
if (!lastVersion) { if (!lastVersion) {
this.preferences.deleteSync('currentVersion'); this.preferences.deleteSync('currentVersion');
} else { } else {
this.preferences.deleteSync('lastVersion');
this.preferences.putSync('currentVersion', lastVersion); this.preferences.putSync('currentVersion', lastVersion);
} }
this.preferences.putSync('firstTimeOk', true); this.preferences.putSync('firstTimeOk', true);

View File

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