react-native-update 10.15.0 → 10.15.2
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/.yarnrc.yml +1 -0
- package/bun.lockb +0 -0
- package/package.json +13 -13
- package/src/client.ts +43 -13
package/.yarnrc.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodeLinker: node-modules
|
package/bun.lockb
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update",
|
|
3
|
-
"version": "10.15.
|
|
3
|
+
"version": "10.15.2",
|
|
4
4
|
"description": "react-native hot update",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"scripts": {
|
|
@@ -54,25 +54,25 @@
|
|
|
54
54
|
"jsSrcsDir": "src"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@babel/core": "^7.
|
|
57
|
+
"@babel/core": "^7.25.8",
|
|
58
58
|
"@react-native/babel-preset": "^0.73.21",
|
|
59
59
|
"@react-native/eslint-config": "^0.73.2",
|
|
60
60
|
"@react-native/typescript-config": "^0.74.0",
|
|
61
|
-
"@types/fs-extra": "^
|
|
62
|
-
"@types/jest": "^29.
|
|
63
|
-
"@types/node": "^
|
|
64
|
-
"@types/react": "^18.
|
|
65
|
-
"detox": "^20.
|
|
61
|
+
"@types/fs-extra": "^11.0.4",
|
|
62
|
+
"@types/jest": "^29.5.13",
|
|
63
|
+
"@types/node": "^22.7.6",
|
|
64
|
+
"@types/react": "^18.3.11",
|
|
65
|
+
"detox": "^20.27.3",
|
|
66
66
|
"eslint": "^8.57.0",
|
|
67
67
|
"eslint-plugin-ft-flow": "^3.0.7",
|
|
68
|
-
"firebase-tools": "^
|
|
69
|
-
"fs-extra": "^
|
|
68
|
+
"firebase-tools": "^13.22.1",
|
|
69
|
+
"fs-extra": "^11.2.0",
|
|
70
70
|
"jest": "^29.7.0",
|
|
71
|
-
"pod-install": "^0.
|
|
72
|
-
"prettier": "^
|
|
71
|
+
"pod-install": "^0.2.2",
|
|
72
|
+
"prettier": "^3",
|
|
73
73
|
"react": "18.2.0",
|
|
74
74
|
"react-native": "0.73",
|
|
75
|
-
"ts-jest": "^29.
|
|
76
|
-
"typescript": "^5.
|
|
75
|
+
"ts-jest": "^29.2.5",
|
|
76
|
+
"typescript": "^5.6.3"
|
|
77
77
|
}
|
|
78
78
|
}
|
package/src/client.ts
CHANGED
|
@@ -52,6 +52,16 @@ export class Pushy {
|
|
|
52
52
|
marked = false;
|
|
53
53
|
applyingUpdate = false;
|
|
54
54
|
version = cInfo.pushy;
|
|
55
|
+
loggerPromise = (() => {
|
|
56
|
+
let resolve: (value?: unknown) => void = () => {};
|
|
57
|
+
const promise = new Promise(res => {
|
|
58
|
+
resolve = res;
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
promise,
|
|
62
|
+
resolve,
|
|
63
|
+
};
|
|
64
|
+
})();
|
|
55
65
|
|
|
56
66
|
constructor(options: PushyOptions) {
|
|
57
67
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
@@ -60,6 +70,14 @@ export class Pushy {
|
|
|
60
70
|
}
|
|
61
71
|
}
|
|
62
72
|
this.setOptions(options);
|
|
73
|
+
if (isRolledBack) {
|
|
74
|
+
this.report({
|
|
75
|
+
type: 'rollback',
|
|
76
|
+
data: {
|
|
77
|
+
rolledBackVersion,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
63
81
|
}
|
|
64
82
|
|
|
65
83
|
setOptions = (options: Partial<PushyOptions>) => {
|
|
@@ -67,20 +85,13 @@ export class Pushy {
|
|
|
67
85
|
if (value !== undefined) {
|
|
68
86
|
(this.options as any)[key] = value;
|
|
69
87
|
if (key === 'logger') {
|
|
70
|
-
|
|
71
|
-
this.report({
|
|
72
|
-
type: 'rollback',
|
|
73
|
-
data: {
|
|
74
|
-
rolledBackVersion,
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
}
|
|
88
|
+
this.loggerPromise.resolve();
|
|
78
89
|
}
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
92
|
};
|
|
82
93
|
|
|
83
|
-
report = ({
|
|
94
|
+
report = async ({
|
|
84
95
|
type,
|
|
85
96
|
message = '',
|
|
86
97
|
data = {},
|
|
@@ -90,6 +101,7 @@ export class Pushy {
|
|
|
90
101
|
data?: Record<string, string | number>;
|
|
91
102
|
}) => {
|
|
92
103
|
log(type + ' ' + message);
|
|
104
|
+
await this.loggerPromise.promise;
|
|
93
105
|
const { logger = noop, appKey } = this.options;
|
|
94
106
|
logger({
|
|
95
107
|
type,
|
|
@@ -104,7 +116,11 @@ export class Pushy {
|
|
|
104
116
|
},
|
|
105
117
|
});
|
|
106
118
|
};
|
|
107
|
-
|
|
119
|
+
throwIfEnabled = (e: Error) => {
|
|
120
|
+
if (this.options.throwError) {
|
|
121
|
+
throw e;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
108
124
|
getCheckUrl = (endpoint: string = this.options.server!.main) => {
|
|
109
125
|
return `${endpoint}/checkUpdate/${this.options.appKey}`;
|
|
110
126
|
};
|
|
@@ -219,7 +235,11 @@ export class Pushy {
|
|
|
219
235
|
fetch(this.getCheckUrl(endpoint), fetchPayload),
|
|
220
236
|
),
|
|
221
237
|
);
|
|
222
|
-
} catch {
|
|
238
|
+
} catch (err: any) {
|
|
239
|
+
this.throwIfEnabled(new Error('errorCheckingUseBackup'));
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
this.throwIfEnabled(new Error('errorCheckingGetBackup'));
|
|
223
243
|
}
|
|
224
244
|
}
|
|
225
245
|
if (!resp) {
|
|
@@ -227,6 +247,7 @@ export class Pushy {
|
|
|
227
247
|
type: 'errorChecking',
|
|
228
248
|
message: 'Can not connect to update server. Please check your network.',
|
|
229
249
|
});
|
|
250
|
+
this.throwIfEnabled(new Error('errorChecking'));
|
|
230
251
|
return this.lastRespJson ? await this.lastRespJson : empty;
|
|
231
252
|
}
|
|
232
253
|
this.lastRespJson = resp.json();
|
|
@@ -240,6 +261,7 @@ export class Pushy {
|
|
|
240
261
|
type: 'errorChecking',
|
|
241
262
|
message: result.message,
|
|
242
263
|
});
|
|
264
|
+
this.throwIfEnabled(new Error(result.message));
|
|
243
265
|
}
|
|
244
266
|
|
|
245
267
|
return result;
|
|
@@ -415,14 +437,21 @@ export class Pushy {
|
|
|
415
437
|
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
|
416
438
|
);
|
|
417
439
|
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
|
|
418
|
-
|
|
440
|
+
this.report({ type: 'rejectStoragePermission' });
|
|
441
|
+
this.throwIfEnabled(new Error('rejectStoragePermission'));
|
|
442
|
+
return;
|
|
419
443
|
}
|
|
420
444
|
} catch (e: any) {
|
|
421
|
-
|
|
445
|
+
this.report({ type: 'errorStoragePermission' });
|
|
446
|
+
this.throwIfEnabled(e);
|
|
447
|
+
return;
|
|
422
448
|
}
|
|
423
449
|
}
|
|
424
450
|
const progressKey = 'downloadingApk';
|
|
425
451
|
if (onDownloadProgress) {
|
|
452
|
+
if (this.progressHandlers[progressKey]) {
|
|
453
|
+
this.progressHandlers[progressKey].remove();
|
|
454
|
+
}
|
|
426
455
|
this.progressHandlers[progressKey] = pushyNativeEventEmitter.addListener(
|
|
427
456
|
'RCTPushyDownloadProgress',
|
|
428
457
|
(progressData: ProgressData) => {
|
|
@@ -438,6 +467,7 @@ export class Pushy {
|
|
|
438
467
|
hash: progressKey,
|
|
439
468
|
}).catch(() => {
|
|
440
469
|
this.report({ type: 'errorDownloadAndInstallApk' });
|
|
470
|
+
this.throwIfEnabled(new Error('errorDownloadAndInstallApk'));
|
|
441
471
|
});
|
|
442
472
|
if (this.progressHandlers[progressKey]) {
|
|
443
473
|
this.progressHandlers[progressKey].remove();
|