react-native-update 10.42.5 → 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.
@@ -9,36 +9,35 @@ import { UpdateContext } from './UpdateContext';
9
9
 
10
10
  export class PushyFileJSBundleProvider extends JSBundleProvider {
11
11
  private updateContext: UpdateContext;
12
- private path: string = '';
13
12
 
14
13
  constructor(context: common.UIAbilityContext) {
15
14
  super();
16
15
  this.updateContext = new UpdateContext(context);
17
- this.path = this.updateContext.getBundleUrl();
18
16
  }
19
17
 
20
18
  getURL(): string {
21
- return this.path;
19
+ return this.updateContext.getBundleUrl();
22
20
  }
23
21
 
24
22
  async getBundle(): Promise<FileJSBundle> {
25
- if (!this.path) {
23
+ const path = this.updateContext.getBundleUrl();
24
+ if (!path) {
26
25
  throw new JSBundleProviderError({
27
26
  whatHappened: 'No pushy bundle found. using default bundle',
28
27
  howCanItBeFixed: [''],
29
28
  });
30
29
  }
31
30
  try {
32
- await fs.access(this.path, fs.OpenMode.READ_ONLY);
31
+ await fs.access(path, fs.OpenMode.READ_ONLY);
33
32
  return {
34
- filePath: this.path,
33
+ filePath: path,
35
34
  };
36
35
  } catch (error) {
37
36
  throw new JSBundleProviderError({
38
- whatHappened: `Couldn't load JSBundle from ${this.path}`,
37
+ whatHappened: `Couldn't load JSBundle from ${path}`,
39
38
  extraData: error,
40
39
  howCanItBeFixed: [
41
- `Check if a bundle exists at "${this.path}" on your device.`,
40
+ `Check if a bundle exists at "${path}" on your device.`,
42
41
  ],
43
42
  });
44
43
  }
@@ -65,6 +65,17 @@ export class PushyTurboModule extends UITurboModule {
65
65
  await this.mUiCtx.startAbility(want);
66
66
  }
67
67
 
68
+ private async reloadBridge(): Promise<void> {
69
+ const devToolsController = (this.ctx as Record<string, any>).devToolsController;
70
+ if (devToolsController) {
71
+ logger.debug(TAG, 'reloadBridge via devToolsController RELOAD');
72
+ devToolsController.eventEmitter.emit("RELOAD", { reason: 'HotReload2' });
73
+ } else {
74
+ logger.debug(TAG, 'reloadBridge via restartAbility');
75
+ await this.restartAbility();
76
+ }
77
+ }
78
+
68
79
  getConstants(): Object {
69
80
  logger.debug(TAG, ',call getConstants');
70
81
  const packageVersion = this.context.getPackageVersion();
@@ -121,7 +132,7 @@ export class PushyTurboModule extends UITurboModule {
121
132
 
122
133
  try {
123
134
  this.context.switchVersion(hash);
124
- await this.restartAbility();
135
+ await this.reloadBridge();
125
136
  } catch (error) {
126
137
  logger.error(TAG, `reloadUpdate failed: ${getErrorMessage(error)}`);
127
138
  throw Error(`switchVersion failed ${getErrorMessage(error)}`);
@@ -131,7 +142,7 @@ export class PushyTurboModule extends UITurboModule {
131
142
  async restartApp(): Promise<void> {
132
143
  logger.debug(TAG, ',call restartApp');
133
144
  try {
134
- await this.restartAbility();
145
+ await this.reloadBridge();
135
146
  } catch (error) {
136
147
  logger.error(TAG, `restartApp failed: ${getErrorMessage(error)}`);
137
148
  throw Error(`restartApp failed ${getErrorMessage(error)}`);
@@ -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
- return bundleInfo?.versionName || 'Unknown';
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
- return String(metaData.pushy_build_time);
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
@@ -0,0 +1,2 @@
1
+ @import React;
2
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.42.5",
3
+ "version": "10.42.7",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
@@ -104,6 +104,7 @@ Pod::Spec.new do |s|
104
104
 
105
105
  # Conditionally add Expo dependency
106
106
  if valid_expo_project
107
+ s.public_header_files = ['ios/ImportReact.h']
107
108
  s.dependency 'ExpoModulesCore'
108
109
  end
109
110
 
@@ -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
- version: v,
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
- // https://github.com/facebook/react-native/pull/48362
11
- (global as any).__turboModuleProxy || (global as any).RN$Bridgeless;
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
- Platform.OS === 'web'
15
- ? emptyModule
16
- : isTurboModuleEnabled
17
- ? require('./NativePushy').default
18
- : NativeModules.Pushy;
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
- throw Error(
24
- 'Failed to load react-native-update native module, please try to recompile',
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
- ? PushyModule.getConstants()
30
- : PushyModule;
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
- PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
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
- try {
45
- _currentVersionInfo = JSON.parse(currentVersionInfoString);
46
- if (_currentVersionInfo.debugChannel) {
47
- isDebugChannel = true;
48
- delete _currentVersionInfo.debugChannel;
49
- setLocalHashInfo(currentVersion, _currentVersionInfo);
50
- }
51
- } catch {
52
- error(
53
- i18n.t('error_parse_version_info', { info: currentVersionInfoString }),
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
- return JSON.parse(await PushyModule.getLocalHashInfo(hash));
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
- name?: string;
75
- description?: string;
76
- metaInfo?: string;
74
+ name?: string;
75
+ description?: string;
76
+ metaInfo?: string;
77
77
  }> {
78
- return currentVersion ? (await getLocalHashInfo(currentVersion)) || {} : {};
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
- uuid = require('nanoid/non-secure').nanoid();
85
- PushyModule.setUuid(uuid);
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
- rnu: require('../package.json').version,
92
- rn: RNVersion,
93
- os: Platform.OS + ' ' + Platform.Version,
94
- uuid,
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
+ });