react-native-update 10.26.4 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.26.4",
3
+ "version": "10.27.0",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
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: { newVersion: hash, diff: succeeded },
473
+ data,
464
474
  });
465
475
  }
466
476
  log(`downloaded ${succeeded} hash:`, hash);
package/src/context.ts CHANGED
@@ -43,6 +43,5 @@ export const UpdateContext = createContext<{
43
43
 
44
44
  export const useUpdate = () => useContext(UpdateContext);
45
45
 
46
+ /** @deprecated Please use `useUpdate` instead */
46
47
  export const usePushy = useUpdate;
47
-
48
- export const useCresc = useUpdate;
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Pushy, Cresc } from './client';
2
- export { UpdateContext, usePushy, useCresc, useUpdate } from './context';
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(
@@ -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 {