react-native-update 10.26.3 → 10.27.0
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/package.json +1 -1
- package/src/client.ts +11 -1
- package/src/context.ts +1 -2
- package/src/index.ts +1 -1
- package/src/provider.tsx +11 -8
- package/src/type.ts +1 -0
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -353,6 +353,7 @@ export class Pushy {
|
|
|
353
353
|
if (Pushy.progressHandlers[hash]) {
|
|
354
354
|
return;
|
|
355
355
|
}
|
|
356
|
+
const patchStartTime = Date.now();
|
|
356
357
|
if (onDownloadProgress) {
|
|
357
358
|
// @ts-expect-error harmony not in existing platforms
|
|
358
359
|
if (Platform.OS === 'harmony') {
|
|
@@ -458,9 +459,18 @@ export class Pushy {
|
|
|
458
459
|
}
|
|
459
460
|
return;
|
|
460
461
|
} else {
|
|
462
|
+
const duration = Date.now() - patchStartTime;
|
|
463
|
+
const data: Record<string, any> = {
|
|
464
|
+
newVersion: hash,
|
|
465
|
+
diff: succeeded,
|
|
466
|
+
duration,
|
|
467
|
+
};
|
|
468
|
+
if (errorMessages.length > 0) {
|
|
469
|
+
data.error = errorMessages.join(';');
|
|
470
|
+
}
|
|
461
471
|
this.report({
|
|
462
472
|
type: 'downloadSuccess',
|
|
463
|
-
data
|
|
473
|
+
data,
|
|
464
474
|
});
|
|
465
475
|
}
|
|
466
476
|
log(`downloaded ${succeeded} hash:`, hash);
|
package/src/context.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Pushy, Cresc } from './client';
|
|
2
|
-
export { UpdateContext, usePushy,
|
|
2
|
+
export { UpdateContext, usePushy, useUpdate } from './context';
|
|
3
3
|
export { PushyProvider, UpdateProvider } from './provider';
|
|
4
4
|
export { PushyModule, UpdateModule } from './core';
|
package/src/provider.tsx
CHANGED
|
@@ -100,6 +100,14 @@ export const UpdateProvider = ({
|
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
102
102
|
stateListener.current && stateListener.current.remove();
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
options.afterDownloadUpdate &&
|
|
106
|
+
(await options.afterDownloadUpdate(info)) === false
|
|
107
|
+
) {
|
|
108
|
+
log('afterDownloadUpdate returned false, skipping');
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
103
111
|
if (options.updateStrategy === 'silentAndNow') {
|
|
104
112
|
client.switchVersion(hash);
|
|
105
113
|
return true;
|
|
@@ -131,13 +139,7 @@ export const UpdateProvider = ({
|
|
|
131
139
|
return false;
|
|
132
140
|
}
|
|
133
141
|
},
|
|
134
|
-
[
|
|
135
|
-
client,
|
|
136
|
-
options.updateStrategy,
|
|
137
|
-
alertUpdate,
|
|
138
|
-
alertError,
|
|
139
|
-
throwErrorIfEnabled,
|
|
140
|
-
],
|
|
142
|
+
[client, options, alertUpdate, alertError, throwErrorIfEnabled],
|
|
141
143
|
);
|
|
142
144
|
|
|
143
145
|
const downloadAndInstallApk = useCallback(
|
|
@@ -181,7 +183,7 @@ export const UpdateProvider = ({
|
|
|
181
183
|
setUpdateInfo(info);
|
|
182
184
|
if (info.expired) {
|
|
183
185
|
const { downloadUrl } = info;
|
|
184
|
-
if (downloadUrl) {
|
|
186
|
+
if (downloadUrl && Pushy.apkStatus === null) {
|
|
185
187
|
if (options.updateStrategy === 'silentAndNow') {
|
|
186
188
|
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
|
|
187
189
|
downloadAndInstallApk(downloadUrl);
|
|
@@ -365,4 +367,5 @@ export const UpdateProvider = ({
|
|
|
365
367
|
);
|
|
366
368
|
};
|
|
367
369
|
|
|
370
|
+
/** @deprecated Please use `UpdateProvider` instead */
|
|
368
371
|
export const PushyProvider = UpdateProvider;
|
package/src/type.ts
CHANGED
|
@@ -88,6 +88,7 @@ export interface ClientOptions {
|
|
|
88
88
|
throwError?: boolean;
|
|
89
89
|
beforeCheckUpdate?: () => Promise<boolean>;
|
|
90
90
|
beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
|
|
91
|
+
afterDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
export interface UpdateTestPayload {
|