react-native-update 10.37.11 → 10.37.12

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.
@@ -45,20 +45,7 @@ export class PushyTurboModule extends TurboModule {
45
45
  '',
46
46
  ) as string;
47
47
  const currentVersionInfo = this.context.getKv(`hash_${currentVersion}`);
48
- let buildTime = preferencesManager.getSync('buildTime', '') as string;
49
- if (!buildTime) {
50
- try {
51
- const resourceManager = this.mUiCtx.resourceManager;
52
- const content = resourceManager.getRawFileContentSync('meta.json');
53
- const metaData = JSON.parse(
54
- new util.TextDecoder().decodeToString(content),
55
- );
56
- if (metaData.pushy_build_time) {
57
- buildTime = String(metaData.pushy_build_time);
58
- preferencesManager.putSync('buildTime', buildTime);
59
- }
60
- } catch {}
61
- }
48
+
62
49
  const isUsingBundleUrl = this.context.getIsUsingBundleUrl();
63
50
  let bundleFlags =
64
51
  bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
@@ -69,6 +56,35 @@ export class PushyTurboModule extends TurboModule {
69
56
  } catch (error) {
70
57
  console.error('Failed to get bundle info:', error);
71
58
  }
59
+ const storedPackageVersion = preferencesManager.getSync(
60
+ 'packageVersion',
61
+ '',
62
+ ) as string;
63
+ const storedBuildTime = preferencesManager.getSync(
64
+ 'buildTime',
65
+ '',
66
+ ) as string;
67
+ let buildTime = '';
68
+ try {
69
+ const resourceManager = this.mUiCtx.resourceManager;
70
+ const content = resourceManager.getRawFileContentSync('meta.json');
71
+ const metaData = JSON.parse(
72
+ new util.TextDecoder().decodeToString(content),
73
+ );
74
+ if (metaData.pushy_build_time) {
75
+ buildTime = String(metaData.pushy_build_time);
76
+ }
77
+ } catch {}
78
+
79
+ const packageVersionChanged =
80
+ !storedPackageVersion || packageVersion !== storedPackageVersion;
81
+ const buildTimeChanged = !storedBuildTime || buildTime !== storedBuildTime;
82
+
83
+ if (packageVersionChanged || buildTimeChanged) {
84
+ this.context.cleanUp();
85
+ preferencesManager.putSync('packageVersion', packageVersion);
86
+ preferencesManager.putSync('buildTime', buildTime);
87
+ }
72
88
 
73
89
  if (isFirstTime) {
74
90
  preferencesManager.deleteSync('isFirstTime');
@@ -246,14 +246,14 @@ export class UpdateContext {
246
246
  return lastVersion;
247
247
  }
248
248
 
249
- private cleanUp(): void {
249
+ public async cleanUp() {
250
250
  const params = new DownloadTaskParams();
251
251
  params.type = DownloadTaskParams.TASK_TYPE_CLEANUP;
252
252
  params.hash = this.preferences.getSync('currentVersion', '') as string;
253
253
  params.originHash = this.preferences.getSync('lastVersion', '') as string;
254
254
  params.unzipDirectory = this.rootDir;
255
255
  const downloadTask = new DownloadTask(this.context);
256
- downloadTask.execute(params);
256
+ await downloadTask.execute(params);
257
257
  }
258
258
 
259
259
  public getIsUsingBundleUrl(): boolean {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.37.11",
3
+ "version": "10.37.12",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {