react-native-update 10.7.3 → 10.8.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.
|
@@ -26,16 +26,16 @@ concurrency:
|
|
|
26
26
|
jobs:
|
|
27
27
|
ios:
|
|
28
28
|
name: iOS
|
|
29
|
-
runs-on: macos-
|
|
29
|
+
runs-on: macos-14-arm64
|
|
30
30
|
# TODO matrix across APIs, at least 11 and 15 (lowest to highest)
|
|
31
31
|
timeout-minutes: 60
|
|
32
32
|
env:
|
|
33
33
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
34
34
|
steps:
|
|
35
35
|
# Set up tool versions
|
|
36
|
-
- uses: actions/setup-node@
|
|
36
|
+
- uses: actions/setup-node@v4
|
|
37
37
|
with:
|
|
38
|
-
node-version:
|
|
38
|
+
node-version: 18
|
|
39
39
|
|
|
40
40
|
- name: Configure JDK 1.11
|
|
41
41
|
uses: actions/setup-java@v3
|
|
@@ -75,7 +75,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
|
|
|
75
75
|
.build();
|
|
76
76
|
Response response = client.newCall(request).execute();
|
|
77
77
|
if (response.code() > 299) {
|
|
78
|
-
throw new Error("Server
|
|
78
|
+
throw new Error("Server error:" + response.code() + " " + response.message());
|
|
79
79
|
}
|
|
80
80
|
ResponseBody body = response.body();
|
|
81
81
|
long contentLength = body.contentLength();
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -37,6 +37,7 @@ export class Pushy {
|
|
|
37
37
|
checkStrategy: 'both',
|
|
38
38
|
logger: noop,
|
|
39
39
|
debug: false,
|
|
40
|
+
throwError: false,
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
lastChecking?: number;
|
|
@@ -289,6 +290,7 @@ export class Pushy {
|
|
|
289
290
|
}
|
|
290
291
|
let succeeded = false;
|
|
291
292
|
this.report({ type: 'downloading' });
|
|
293
|
+
let lastError: any;
|
|
292
294
|
const diffUrl = (await testUrls(diffUrls)) || _diffUrl;
|
|
293
295
|
if (diffUrl) {
|
|
294
296
|
log('downloading diff');
|
|
@@ -300,6 +302,7 @@ export class Pushy {
|
|
|
300
302
|
});
|
|
301
303
|
succeeded = true;
|
|
302
304
|
} catch (e: any) {
|
|
305
|
+
lastError = e;
|
|
303
306
|
if (__DEV__) {
|
|
304
307
|
succeeded = true;
|
|
305
308
|
} else {
|
|
@@ -317,6 +320,7 @@ export class Pushy {
|
|
|
317
320
|
});
|
|
318
321
|
succeeded = true;
|
|
319
322
|
} catch (e: any) {
|
|
323
|
+
lastError = e;
|
|
320
324
|
if (__DEV__) {
|
|
321
325
|
succeeded = true;
|
|
322
326
|
} else {
|
|
@@ -334,6 +338,7 @@ export class Pushy {
|
|
|
334
338
|
});
|
|
335
339
|
succeeded = true;
|
|
336
340
|
} catch (e: any) {
|
|
341
|
+
lastError = e;
|
|
337
342
|
if (__DEV__) {
|
|
338
343
|
succeeded = true;
|
|
339
344
|
} else {
|
|
@@ -349,10 +354,14 @@ export class Pushy {
|
|
|
349
354
|
return hash;
|
|
350
355
|
}
|
|
351
356
|
if (!succeeded) {
|
|
352
|
-
|
|
357
|
+
this.report({
|
|
353
358
|
type: 'errorUpdate',
|
|
354
359
|
data: { newVersion: hash },
|
|
355
360
|
});
|
|
361
|
+
if (lastError) {
|
|
362
|
+
throw lastError;
|
|
363
|
+
}
|
|
364
|
+
return;
|
|
356
365
|
}
|
|
357
366
|
log('downloaded hash:', hash);
|
|
358
367
|
setLocalHashInfo(hash, {
|
package/src/provider.tsx
CHANGED
|
@@ -37,6 +37,15 @@ export const PushyProvider = ({
|
|
|
37
37
|
const [lastError, setLastError] = useState<Error>();
|
|
38
38
|
const lastChecking = useRef(0);
|
|
39
39
|
|
|
40
|
+
const throwErrorIfEnabled = useCallback(
|
|
41
|
+
(e: Error) => {
|
|
42
|
+
if (options.throwError) {
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[options.throwError],
|
|
47
|
+
);
|
|
48
|
+
|
|
40
49
|
const dismissError = useCallback(() => {
|
|
41
50
|
setLastError(undefined);
|
|
42
51
|
}, []);
|
|
@@ -115,9 +124,16 @@ export const PushyProvider = ({
|
|
|
115
124
|
} catch (e: any) {
|
|
116
125
|
setLastError(e);
|
|
117
126
|
alertError('更新失败', e.message);
|
|
127
|
+
throwErrorIfEnabled(e);
|
|
118
128
|
}
|
|
119
129
|
},
|
|
120
|
-
[
|
|
130
|
+
[
|
|
131
|
+
client,
|
|
132
|
+
options.updateStrategy,
|
|
133
|
+
alertUpdate,
|
|
134
|
+
alertError,
|
|
135
|
+
throwErrorIfEnabled,
|
|
136
|
+
],
|
|
121
137
|
);
|
|
122
138
|
|
|
123
139
|
const downloadAndInstallApk = useCallback(
|
|
@@ -141,6 +157,7 @@ export const PushyProvider = ({
|
|
|
141
157
|
} catch (e: any) {
|
|
142
158
|
setLastError(e);
|
|
143
159
|
alertError('更新检查失败', e.message);
|
|
160
|
+
throwErrorIfEnabled(e);
|
|
144
161
|
return;
|
|
145
162
|
}
|
|
146
163
|
if (!info) {
|
|
@@ -195,12 +212,13 @@ export const PushyProvider = ({
|
|
|
195
212
|
);
|
|
196
213
|
}
|
|
197
214
|
}, [
|
|
198
|
-
alertError,
|
|
199
215
|
client,
|
|
200
|
-
|
|
201
|
-
|
|
216
|
+
alertError,
|
|
217
|
+
throwErrorIfEnabled,
|
|
202
218
|
options.updateStrategy,
|
|
203
219
|
alertUpdate,
|
|
220
|
+
downloadAndInstallApk,
|
|
221
|
+
downloadUpdate,
|
|
204
222
|
]);
|
|
205
223
|
|
|
206
224
|
const markSuccess = client.markSuccess;
|