react-native-update 10.42.6 → 10.42.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/harmony/pushy/src/main/ets/UpdateContext.ts +18 -3
- package/harmony/pushy.har +0 -0
- package/ios/ImportReact.h +2 -0
- package/package.json +1 -1
- package/react-native-update.podspec +1 -0
- package/scripts/prepublish.ts +13 -0
- package/src/core.ts +49 -41
|
@@ -26,6 +26,8 @@ export class UpdateContext {
|
|
|
26
26
|
private static DEBUG: boolean = false;
|
|
27
27
|
private static isUsingBundleUrl: boolean = false;
|
|
28
28
|
private static ignoreRollback: boolean = false;
|
|
29
|
+
private static cachedPackageVersion: string = '';
|
|
30
|
+
private static cachedBuildTime: string = '';
|
|
29
31
|
|
|
30
32
|
constructor(context: common.UIAbilityContext) {
|
|
31
33
|
this.context = context;
|
|
@@ -60,11 +62,15 @@ export class UpdateContext {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
public getPackageVersion(): string {
|
|
65
|
+
if (UpdateContext.cachedPackageVersion) {
|
|
66
|
+
return UpdateContext.cachedPackageVersion;
|
|
67
|
+
}
|
|
63
68
|
try {
|
|
64
69
|
const bundleInfo = bundleManager.getBundleInfoForSelfSync(
|
|
65
70
|
this.getBundleFlags(),
|
|
66
71
|
);
|
|
67
|
-
|
|
72
|
+
UpdateContext.cachedPackageVersion = bundleInfo?.versionName || 'Unknown';
|
|
73
|
+
return UpdateContext.cachedPackageVersion;
|
|
68
74
|
} catch (error) {
|
|
69
75
|
console.error('Failed to get bundle info:', error);
|
|
70
76
|
return '';
|
|
@@ -72,6 +78,9 @@ export class UpdateContext {
|
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
public getBuildTime(): string {
|
|
81
|
+
if (UpdateContext.cachedBuildTime) {
|
|
82
|
+
return UpdateContext.cachedBuildTime;
|
|
83
|
+
}
|
|
75
84
|
try {
|
|
76
85
|
const content =
|
|
77
86
|
this.context.resourceManager.getRawFileContentSync('meta.json');
|
|
@@ -79,9 +88,12 @@ export class UpdateContext {
|
|
|
79
88
|
new util.TextDecoder().decodeToString(content),
|
|
80
89
|
) as Record<string, string | number | boolean | null | undefined>;
|
|
81
90
|
if (metaData.pushy_build_time) {
|
|
82
|
-
|
|
91
|
+
UpdateContext.cachedBuildTime = String(metaData.pushy_build_time);
|
|
92
|
+
return UpdateContext.cachedBuildTime;
|
|
83
93
|
}
|
|
84
|
-
} catch {
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error('Failed to read build time from raw file:', error);
|
|
96
|
+
}
|
|
85
97
|
return '';
|
|
86
98
|
}
|
|
87
99
|
|
|
@@ -244,6 +256,9 @@ export class UpdateContext {
|
|
|
244
256
|
packageVersion: string,
|
|
245
257
|
buildTime: string,
|
|
246
258
|
): void {
|
|
259
|
+
if (!packageVersion || !buildTime) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
247
262
|
const currentState = this.getStateSnapshot();
|
|
248
263
|
const nextState = NativePatchCore.syncStateWithBinaryVersion(
|
|
249
264
|
packageVersion,
|
package/harmony/pushy.har
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/scripts/prepublish.ts
CHANGED
|
@@ -8,6 +8,12 @@ function normalizeVersion(version: string): string {
|
|
|
8
8
|
return version.trim().replace(/^refs\/tags\//, '').replace(/^v/, '');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
const SEMVER_REGEX = /^\d+\.\d+\.\d+(-.+)?$/;
|
|
12
|
+
|
|
13
|
+
function isValidSemver(version: string): boolean {
|
|
14
|
+
return SEMVER_REGEX.test(version);
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
function getVersionFromEnvironment(): string | null {
|
|
12
18
|
const candidates = [
|
|
13
19
|
process.env.RELEASE_VERSION,
|
|
@@ -134,6 +140,13 @@ async function main(): Promise<void> {
|
|
|
134
140
|
try {
|
|
135
141
|
if (isGitHubCI()) {
|
|
136
142
|
const version = await resolveVersion();
|
|
143
|
+
if (!isValidSemver(version)) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
`Resolved version "${version}" is not a valid semantic version. ` +
|
|
146
|
+
`Please ensure RELEASE_VERSION, GITHUB_REF, or GITHUB_REF_NAME is set correctly, ` +
|
|
147
|
+
`or that the git history is fully fetched.`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
137
150
|
console.log(`Using publish version ${version}`);
|
|
138
151
|
await modifyPackageJson({ version });
|
|
139
152
|
} else {
|
package/src/core.ts
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
1
|
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
2
|
-
import { emptyModule, error, log } from './utils';
|
|
3
2
|
import i18n from './i18n';
|
|
3
|
+
import { emptyModule, error, log } from './utils';
|
|
4
|
+
|
|
4
5
|
/* eslint-disable @react-native/no-deep-imports */
|
|
5
6
|
const {
|
|
6
|
-
|
|
7
|
+
version: v,
|
|
7
8
|
} = require('react-native/Libraries/Core/ReactNativeVersion');
|
|
8
9
|
const RNVersion = `${v.major}.${v.minor}.${v.patch}`;
|
|
9
10
|
const isTurboModuleEnabled =
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
// https://github.com/facebook/react-native/pull/48362
|
|
12
|
+
(global as any).__turboModuleProxy || (global as any).RN$Bridgeless;
|
|
12
13
|
|
|
13
14
|
export const PushyModule =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
Platform.OS === 'web'
|
|
16
|
+
? emptyModule
|
|
17
|
+
: isTurboModuleEnabled
|
|
18
|
+
? require('./NativePushy').default
|
|
19
|
+
: NativeModules.Pushy;
|
|
19
20
|
|
|
20
21
|
export const UpdateModule = PushyModule;
|
|
21
22
|
|
|
22
23
|
if (!PushyModule) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
throw Error(
|
|
25
|
+
'Failed to load react-native-update native module, please try to recompile',
|
|
26
|
+
);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
const PushyConstants = isTurboModuleEnabled
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
? PushyModule.getConstants()
|
|
31
|
+
: PushyModule;
|
|
31
32
|
|
|
32
33
|
export const downloadRootDir: string = PushyConstants.downloadRootDir;
|
|
33
34
|
export const packageVersion: string = PushyConstants.packageVersion;
|
|
34
35
|
export const currentVersion: string = PushyConstants.currentVersion;
|
|
35
36
|
|
|
36
37
|
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
|
|
37
|
-
|
|
38
|
+
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
const currentVersionInfoString: string = PushyConstants.currentVersionInfo;
|
|
41
42
|
let _currentVersionInfo: Record<string, any> = {};
|
|
42
43
|
let isDebugChannel = false;
|
|
43
44
|
if (currentVersionInfoString) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
try {
|
|
46
|
+
_currentVersionInfo = JSON.parse(currentVersionInfoString);
|
|
47
|
+
if (_currentVersionInfo.debugChannel) {
|
|
48
|
+
isDebugChannel = true;
|
|
49
|
+
delete _currentVersionInfo.debugChannel;
|
|
50
|
+
setLocalHashInfo(currentVersion, _currentVersionInfo);
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
error(
|
|
54
|
+
i18n.t('error_parse_version_info', { info: currentVersionInfoString }),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
56
57
|
}
|
|
57
58
|
export const currentVersionInfo = _currentVersionInfo;
|
|
58
59
|
|
|
@@ -64,32 +65,39 @@ export const isRolledBack: boolean = !!rolledBackVersion;
|
|
|
64
65
|
export const buildTime: string = PushyConstants.buildTime;
|
|
65
66
|
let uuid = PushyConstants.uuid;
|
|
66
67
|
|
|
67
|
-
|
|
68
68
|
async function getLocalHashInfo(hash: string) {
|
|
69
|
-
|
|
69
|
+
return JSON.parse(await PushyModule.getLocalHashInfo(hash));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// @deprecated use currentVersionInfo instead
|
|
73
73
|
export async function getCurrentVersionInfo(): Promise<{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
name?: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
metaInfo?: string;
|
|
77
77
|
}> {
|
|
78
|
-
|
|
78
|
+
return currentVersion ? (await getLocalHashInfo(currentVersion)) || {} : {};
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export const pushyNativeEventEmitter = new NativeEventEmitter(PushyModule);
|
|
82
82
|
|
|
83
83
|
if (!uuid) {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
uuid = require('nanoid/non-secure').nanoid();
|
|
85
|
+
PushyModule.setUuid(uuid);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
log('uuid: ' + uuid);
|
|
89
|
-
|
|
90
88
|
export const cInfo = {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
rnu: require('../package.json').version,
|
|
90
|
+
rn: RNVersion,
|
|
91
|
+
os: `${Platform.OS} ${Platform.Version}`,
|
|
92
|
+
uuid,
|
|
95
93
|
};
|
|
94
|
+
|
|
95
|
+
log('bootup status', {
|
|
96
|
+
packageVersion,
|
|
97
|
+
currentVersion,
|
|
98
|
+
currentVersionInfo,
|
|
99
|
+
isFirstTime,
|
|
100
|
+
isFirstTimeDebug,
|
|
101
|
+
isDebugChannel,
|
|
102
|
+
cInfo,
|
|
103
|
+
});
|