react-native-update 10.38.0-beta.1 → 10.38.0-beta.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.
|
@@ -4,8 +4,6 @@ import static androidx.core.content.FileProvider.getUriForFile;
|
|
|
4
4
|
import android.content.Intent;
|
|
5
5
|
import android.net.Uri;
|
|
6
6
|
import android.os.Build;
|
|
7
|
-
import android.os.Handler;
|
|
8
|
-
import android.os.Looper;
|
|
9
7
|
import com.facebook.react.bridge.Promise;
|
|
10
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
9
|
import com.facebook.react.bridge.ReactContext;
|
|
@@ -19,7 +17,6 @@ import java.util.Map;
|
|
|
19
17
|
public class UpdateModule extends NativePushySpec {
|
|
20
18
|
UpdateContext updateContext;
|
|
21
19
|
public static ReactApplicationContext mContext;
|
|
22
|
-
private final Handler handler = new Handler(Looper.getMainLooper());
|
|
23
20
|
public UpdateModule(ReactApplicationContext reactContext, UpdateContext updateContext) {
|
|
24
21
|
super(reactContext);
|
|
25
22
|
this.updateContext = updateContext;
|
|
@@ -43,22 +40,12 @@ public class UpdateModule extends NativePushySpec {
|
|
|
43
40
|
boolean isFirstTime = updateContext.isFirstTime();
|
|
44
41
|
constants.put("isFirstTime", isFirstTime);
|
|
45
42
|
if (isFirstTime) {
|
|
46
|
-
|
|
47
|
-
@Override
|
|
48
|
-
public void run() {
|
|
49
|
-
updateContext.clearFirstTime();
|
|
50
|
-
}
|
|
51
|
-
}, 2000);
|
|
43
|
+
updateContext.clearFirstTime();
|
|
52
44
|
}
|
|
53
45
|
String rolledBackVersion = updateContext.rolledBackVersion();
|
|
54
46
|
constants.put("rolledBackVersion", rolledBackVersion);
|
|
55
47
|
if (rolledBackVersion != null) {
|
|
56
|
-
|
|
57
|
-
@Override
|
|
58
|
-
public void run() {
|
|
59
|
-
updateContext.clearRollbackMark();
|
|
60
|
-
}
|
|
61
|
-
}, 2000);
|
|
48
|
+
updateContext.clearRollbackMark();
|
|
62
49
|
}
|
|
63
50
|
constants.put("uuid", updateContext.getKv("uuid"));
|
|
64
51
|
return constants;
|
package/package.json
CHANGED
package/src/__tests__/setup.ts
CHANGED
package/src/client.ts
CHANGED
|
@@ -42,8 +42,7 @@ import { dedupeEndpoints, executeEndpointFallback } from './endpoint';
|
|
|
42
42
|
const SERVER_PRESETS = {
|
|
43
43
|
// cn
|
|
44
44
|
Pushy: {
|
|
45
|
-
main: 'https://update.react-native.cn/api',
|
|
46
|
-
backups: ['https://update.reactnative.cn/api'],
|
|
45
|
+
main: ['https://update.react-native.cn/api', 'https://update.reactnative.cn/api'],
|
|
47
46
|
queryUrls: [
|
|
48
47
|
'https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json',
|
|
49
48
|
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-update@master/endpoints.json',
|
|
@@ -51,14 +50,26 @@ const SERVER_PRESETS = {
|
|
|
51
50
|
},
|
|
52
51
|
// i18n
|
|
53
52
|
Cresc: {
|
|
54
|
-
main: 'https://api.cresc.dev',
|
|
55
|
-
backups: ['https://api.cresc.app'],
|
|
53
|
+
main: ['https://api.cresc.dev', 'https://api.cresc.app'],
|
|
56
54
|
queryUrls: [
|
|
57
55
|
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-update@master/endpoints_cresc.json',
|
|
58
56
|
],
|
|
59
57
|
},
|
|
60
58
|
};
|
|
61
59
|
|
|
60
|
+
const cloneServerConfig = (server: UpdateServerConfig): UpdateServerConfig => ({
|
|
61
|
+
main: dedupeEndpoints([...(server.main || [])]),
|
|
62
|
+
queryUrls: server.queryUrls ? [...server.queryUrls] : undefined,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const excludeConfiguredEndpoints = (
|
|
66
|
+
endpoints: string[],
|
|
67
|
+
configuredEndpoints: string[],
|
|
68
|
+
) => {
|
|
69
|
+
const configured = new Set(configuredEndpoints);
|
|
70
|
+
return endpoints.filter(endpoint => !configured.has(endpoint));
|
|
71
|
+
};
|
|
72
|
+
|
|
62
73
|
assertWeb();
|
|
63
74
|
|
|
64
75
|
const defaultClientOptions: ClientOptions = {
|
|
@@ -71,19 +82,6 @@ const defaultClientOptions: ClientOptions = {
|
|
|
71
82
|
throwError: false,
|
|
72
83
|
};
|
|
73
84
|
|
|
74
|
-
const cloneServerConfig = (
|
|
75
|
-
server?: UpdateServerConfig,
|
|
76
|
-
): UpdateServerConfig | undefined => {
|
|
77
|
-
if (!server) {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
main: server.main,
|
|
82
|
-
backups: server.backups ? [...server.backups] : undefined,
|
|
83
|
-
queryUrls: server.queryUrls ? [...server.queryUrls] : undefined,
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
85
|
export const sharedState: {
|
|
88
86
|
progressHandlers: Record<string, EmitterSubscription>;
|
|
89
87
|
downloadedHash?: string;
|
|
@@ -209,7 +207,7 @@ export class Pushy {
|
|
|
209
207
|
throw e;
|
|
210
208
|
}
|
|
211
209
|
};
|
|
212
|
-
getCheckUrl = (endpoint: string
|
|
210
|
+
getCheckUrl = (endpoint: string) => {
|
|
213
211
|
return `${endpoint}/checkUpdate/${this.options.appKey}`;
|
|
214
212
|
};
|
|
215
213
|
getConfiguredCheckEndpoints = () => {
|
|
@@ -217,7 +215,7 @@ export class Pushy {
|
|
|
217
215
|
if (!server) {
|
|
218
216
|
return [];
|
|
219
217
|
}
|
|
220
|
-
return dedupeEndpoints(
|
|
218
|
+
return dedupeEndpoints(server.main);
|
|
221
219
|
};
|
|
222
220
|
getRemoteEndpoints = async () => {
|
|
223
221
|
const { server } = this.options;
|
|
@@ -233,16 +231,14 @@ export class Pushy {
|
|
|
233
231
|
const remoteEndpoints = await resp.json();
|
|
234
232
|
log('fetch endpoints:', remoteEndpoints);
|
|
235
233
|
if (Array.isArray(remoteEndpoints)) {
|
|
236
|
-
|
|
234
|
+
return excludeConfiguredEndpoints(
|
|
235
|
+
dedupeEndpoints(
|
|
237
236
|
remoteEndpoints.filter(
|
|
238
237
|
(endpoint): endpoint is string => typeof endpoint === 'string',
|
|
239
238
|
),
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
...normalizedRemoteEndpoints,
|
|
244
|
-
]).filter(endpoint => endpoint !== server.main);
|
|
245
|
-
return normalizedRemoteEndpoints;
|
|
239
|
+
),
|
|
240
|
+
this.getConfiguredCheckEndpoints(),
|
|
241
|
+
);
|
|
246
242
|
}
|
|
247
243
|
} catch (e) {
|
|
248
244
|
log('failed to fetch endpoints from: ', server.queryUrls, e);
|
|
@@ -410,8 +406,9 @@ export class Pushy {
|
|
|
410
406
|
return [];
|
|
411
407
|
}
|
|
412
408
|
const remoteEndpoints = await this.getRemoteEndpoints();
|
|
413
|
-
return
|
|
414
|
-
|
|
409
|
+
return excludeConfiguredEndpoints(
|
|
410
|
+
dedupeEndpoints(remoteEndpoints),
|
|
411
|
+
this.getConfiguredCheckEndpoints(),
|
|
415
412
|
);
|
|
416
413
|
};
|
|
417
414
|
downloadUpdate = async (
|