react-native-update 10.28.11 → 10.29.0-beta.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.
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>react-native-update</name>
4
+ <comment>Project react-native-update created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16
+ </natures>
17
+ <filteredResources>
18
+ <filter>
19
+ <id>1727963310481</id>
20
+ <name></name>
21
+ <type>30</type>
22
+ <matcher>
23
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
24
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25
+ </matcher>
26
+ </filter>
27
+ </filteredResources>
28
+ </projectDescription>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>react-native-update</name>
4
+ <comment>Project react-native-update created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.jdt.core.javabuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ </buildSpec>
19
+ <natures>
20
+ <nature>org.eclipse.jdt.core.javanature</nature>
21
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
+ </natures>
23
+ <filteredResources>
24
+ <filter>
25
+ <id>1727963310481</id>
26
+ <name></name>
27
+ <type>30</type>
28
+ <matcher>
29
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
30
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31
+ </matcher>
32
+ </filter>
33
+ </filteredResources>
34
+ </projectDescription>
@@ -0,0 +1,13 @@
1
+ arguments=--init-script /var/folders/l6/0fn3x28s5s585ld3p04gsy1h0000gn/T/db3b08fc4a9ef609cb16b96b200fa13e563f396e9bb1ed0905fdab7bc3bc513b.gradle --init-script /var/folders/l6/0fn3x28s5s585ld3p04gsy1h0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
2
+ auto.sync=false
3
+ build.scans.enabled=false
4
+ connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.9))
5
+ connection.project.dir=
6
+ eclipse.preferences.version=1
7
+ gradle.user.home=
8
+ java.home=/Users/sunny/.sdkman/candidates/java/17.0.9-zulu/zulu-17.jdk/Contents/Home
9
+ jvm.arguments=
10
+ offline.mode=false
11
+ override.workspace.settings=true
12
+ show.console.view=true
13
+ show.executions.view=true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.28.11",
3
+ "version": "10.29.0-beta.0",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
@@ -72,5 +72,6 @@
72
72
  "react-native": "0.73",
73
73
  "ts-jest": "^29.3.2",
74
74
  "typescript": "^5.6.3"
75
- }
75
+ },
76
+ "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
76
77
  }
package/src/client.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { CheckResult, ClientOptions, ProgressData, EventType } from './type';
2
2
  import {
3
- assertDev,
4
3
  assertWeb,
5
4
  emptyObj,
5
+ enhancedFetch,
6
6
  joinUrls,
7
7
  log,
8
8
  noop,
@@ -170,10 +170,12 @@ export class Pushy {
170
170
  getCheckUrl = (endpoint: string = this.options.server!.main) => {
171
171
  return `${endpoint}/checkUpdate/${this.options.appKey}`;
172
172
  };
173
- assertDebug = () => {
173
+ assertDebug = (matter: string) => {
174
174
  if (__DEV__ && !this.options.debug) {
175
175
  console.info(
176
- 'You are currently in the development environment and have not enabled debug mode. The hot update check will not be performed. If you need to debug hot updates in the development environment, please set debug to true in the client.',
176
+ `You are currently in the development environment and have not enabled debug mode.
177
+ ${matter} will not be performed.
178
+ If you need to debug ${matter} in the development environment, please set debug to true in the client.`,
177
179
  );
178
180
  return false;
179
181
  }
@@ -188,7 +190,7 @@ export class Pushy {
188
190
  this.report({ type: 'markSuccess' });
189
191
  };
190
192
  switchVersion = async (hash: string) => {
191
- if (!assertDev('switchVersion()')) {
193
+ if (!this.assertDebug('switchVersion()')) {
192
194
  return;
193
195
  }
194
196
  if (assertHash(hash) && !sharedState.applyingUpdate) {
@@ -199,7 +201,7 @@ export class Pushy {
199
201
  };
200
202
 
201
203
  switchVersionLater = async (hash: string) => {
202
- if (!assertDev('switchVersionLater()')) {
204
+ if (!this.assertDebug('switchVersionLater()')) {
203
205
  return;
204
206
  }
205
207
  if (assertHash(hash)) {
@@ -208,7 +210,7 @@ export class Pushy {
208
210
  }
209
211
  };
210
212
  checkUpdate = async (extra?: Record<string, any>) => {
211
- if (!this.assertDebug()) {
213
+ if (!this.assertDebug('checkUpdate()')) {
212
214
  return;
213
215
  }
214
216
  if (!assertWeb()) {
@@ -261,7 +263,7 @@ export class Pushy {
261
263
  type: 'checking',
262
264
  message: this.options.appKey + ': ' + stringifyBody,
263
265
  });
264
- resp = await fetch(this.getCheckUrl(), fetchPayload);
266
+ resp = await enhancedFetch(this.getCheckUrl(), fetchPayload);
265
267
  } catch (e: any) {
266
268
  this.report({
267
269
  type: 'errorChecking',
@@ -272,7 +274,7 @@ export class Pushy {
272
274
  try {
273
275
  resp = await promiseAny(
274
276
  backupEndpoints.map(endpoint =>
275
- fetch(this.getCheckUrl(endpoint), fetchPayload),
277
+ enhancedFetch(this.getCheckUrl(endpoint), fetchPayload),
276
278
  ),
277
279
  );
278
280
  } catch (err: any) {
@@ -392,43 +394,37 @@ export class Pushy {
392
394
  this.report({ type: 'downloading' });
393
395
  let lastError: any;
394
396
  let errorMessages: string[] = [];
395
- const diffUrl = await testUrls(joinUrls(paths, diff));
396
- if (diffUrl) {
397
- log('downloading diff');
398
- try {
399
- await PushyModule.downloadPatchFromPpk({
400
- updateUrl: diffUrl,
401
- hash,
402
- originHash: currentVersion,
403
- });
404
- succeeded = 'diff';
405
- } catch (e: any) {
406
- const errorMessage = `diff error: ${e.message}`;
407
- errorMessages.push(errorMessage);
408
- lastError = new Error(errorMessage);
409
- if (__DEV__) {
397
+ if (!__DEV__) {
398
+ const diffUrl = await testUrls(joinUrls(paths, diff));
399
+ if (diffUrl) {
400
+ log('downloading diff');
401
+ try {
402
+ await PushyModule.downloadPatchFromPpk({
403
+ updateUrl: diffUrl,
404
+ hash,
405
+ originHash: currentVersion,
406
+ });
410
407
  succeeded = 'diff';
411
- } else {
408
+ } catch (e: any) {
409
+ const errorMessage = `diff error: ${e.message}`;
410
+ errorMessages.push(errorMessage);
411
+ lastError = new Error(errorMessage);
412
412
  log(errorMessage);
413
413
  }
414
414
  }
415
- }
416
- const pdiffUrl = await testUrls(joinUrls(paths, pdiff));
417
- if (!succeeded && pdiffUrl) {
418
- log('downloading pdiff');
419
- try {
420
- await PushyModule.downloadPatchFromPackage({
421
- updateUrl: pdiffUrl,
422
- hash,
423
- });
424
- succeeded = 'pdiff';
425
- } catch (e: any) {
426
- const errorMessage = `pdiff error: ${e.message}`;
427
- errorMessages.push(errorMessage);
428
- lastError = new Error(errorMessage);
429
- if (__DEV__) {
415
+ const pdiffUrl = await testUrls(joinUrls(paths, pdiff));
416
+ if (!succeeded && pdiffUrl) {
417
+ log('downloading pdiff');
418
+ try {
419
+ await PushyModule.downloadPatchFromPackage({
420
+ updateUrl: pdiffUrl,
421
+ hash,
422
+ });
430
423
  succeeded = 'pdiff';
431
- } else {
424
+ } catch (e: any) {
425
+ const errorMessage = `pdiff error: ${e.message}`;
426
+ errorMessages.push(errorMessage);
427
+ lastError = new Error(errorMessage);
432
428
  log(errorMessage);
433
429
  }
434
430
  }
@@ -446,20 +442,13 @@ export class Pushy {
446
442
  const errorMessage = `full patch error: ${e.message}`;
447
443
  errorMessages.push(errorMessage);
448
444
  lastError = new Error(errorMessage);
449
- if (__DEV__) {
450
- succeeded = 'full';
451
- } else {
452
- log(errorMessage);
453
- }
445
+ log(errorMessage);
454
446
  }
455
447
  }
456
448
  if (sharedState.progressHandlers[hash]) {
457
449
  sharedState.progressHandlers[hash].remove();
458
450
  delete sharedState.progressHandlers[hash];
459
451
  }
460
- if (__DEV__) {
461
- return hash;
462
- }
463
452
  if (!succeeded) {
464
453
  this.report({
465
454
  type: 'errorUpdate',
package/src/provider.tsx CHANGED
@@ -251,7 +251,7 @@ export const UpdateProvider = ({
251
251
  const markSuccess = client.markSuccess;
252
252
 
253
253
  useEffect(() => {
254
- if (!client.assertDebug()) {
254
+ if (!client.assertDebug('checkUpdate()')) {
255
255
  return;
256
256
  }
257
257
  const { checkStrategy, dismissErrorAfter, autoMarkSuccess } = options;
package/src/utils.ts CHANGED
@@ -40,13 +40,13 @@ const ping =
40
40
  : async (url: string) => {
41
41
  let pingFinished = false;
42
42
  return Promise.race([
43
- fetch(url, {
43
+ enhancedFetch(url, {
44
44
  method: 'HEAD',
45
45
  })
46
- .then(({ status, statusText }) => {
46
+ .then(({ status, statusText, url: finalUrl }) => {
47
47
  pingFinished = true;
48
48
  if (status === 200) {
49
- return url;
49
+ return finalUrl;
50
50
  }
51
51
  log('ping failed', url, status, statusText);
52
52
  throw new Error('Ping failed');
@@ -69,7 +69,7 @@ const ping =
69
69
 
70
70
  export function joinUrls(paths: string[], fileName?: string) {
71
71
  if (fileName) {
72
- return paths.map(path => 'https://' + path + '/' + fileName);
72
+ return paths.map(path => `https://${path}/${fileName}`);
73
73
  }
74
74
  }
75
75
 
@@ -99,12 +99,19 @@ export const assertWeb = () => {
99
99
  return true;
100
100
  };
101
101
 
102
- export const assertDev = (matter: string) => {
103
- if (__DEV__) {
104
- console.warn(
105
- `${matter} is not supported in development environment; no action taken.`,
106
- );
107
- return false;
108
- }
109
- return true;
102
+ // export const isAndroid70AndBelow = () => {
103
+ // // android 7.0 and below devices do not support letsencrypt cert
104
+ // // https://letsencrypt.org/2023/07/10/cross-sign-expiration/
105
+ // return Platform.OS === 'android' && Platform.Version <= 24;
106
+ // };
107
+
108
+ export const enhancedFetch = async (
109
+ url: string,
110
+ params: Parameters<typeof fetch>[1],
111
+ ) => {
112
+ return fetch(url, params).catch(e => {
113
+ log('fetch error', url, e);
114
+ log('trying fallback to http');
115
+ return fetch(url.replace('https', 'http'), params);
116
+ });
110
117
  };