react-native-update 10.28.11 → 10.29.0-beta.1

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.1",
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) {
@@ -413,43 +415,47 @@ export class Pushy {
413
415
  }
414
416
  }
415
417
  }
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__) {
418
+ if (!succeeded) {
419
+ const pdiffUrl = await testUrls(joinUrls(paths, pdiff));
420
+ if (pdiffUrl) {
421
+ log('downloading pdiff');
422
+ try {
423
+ await PushyModule.downloadPatchFromPackage({
424
+ updateUrl: pdiffUrl,
425
+ hash,
426
+ });
430
427
  succeeded = 'pdiff';
431
- } else {
432
- log(errorMessage);
428
+ } catch (e: any) {
429
+ const errorMessage = `pdiff error: ${e.message}`;
430
+ errorMessages.push(errorMessage);
431
+ lastError = new Error(errorMessage);
432
+ if (__DEV__) {
433
+ succeeded = 'pdiff';
434
+ } else {
435
+ log(errorMessage);
436
+ }
433
437
  }
434
438
  }
435
439
  }
436
- const fullUrl = await testUrls(joinUrls(paths, full));
437
- if (!succeeded && fullUrl) {
438
- log('downloading full patch');
439
- try {
440
- await PushyModule.downloadFullUpdate({
441
- updateUrl: fullUrl,
442
- hash,
443
- });
444
- succeeded = 'full';
445
- } catch (e: any) {
446
- const errorMessage = `full patch error: ${e.message}`;
447
- errorMessages.push(errorMessage);
448
- lastError = new Error(errorMessage);
449
- if (__DEV__) {
440
+ if (!succeeded) {
441
+ const fullUrl = await testUrls(joinUrls(paths, full));
442
+ if (fullUrl) {
443
+ log('downloading full patch');
444
+ try {
445
+ await PushyModule.downloadFullUpdate({
446
+ updateUrl: fullUrl,
447
+ hash,
448
+ });
450
449
  succeeded = 'full';
451
- } else {
452
- log(errorMessage);
450
+ } catch (e: any) {
451
+ const errorMessage = `full patch error: ${e.message}`;
452
+ errorMessages.push(errorMessage);
453
+ lastError = new Error(errorMessage);
454
+ if (__DEV__) {
455
+ succeeded = 'full';
456
+ } else {
457
+ log(errorMessage);
458
+ }
453
459
  }
454
460
  }
455
461
  }
@@ -457,9 +463,6 @@ export class Pushy {
457
463
  sharedState.progressHandlers[hash].remove();
458
464
  delete sharedState.progressHandlers[hash];
459
465
  }
460
- if (__DEV__) {
461
- return hash;
462
- }
463
466
  if (!succeeded) {
464
467
  this.report({
465
468
  type: 'errorUpdate',
package/src/provider.tsx CHANGED
@@ -251,14 +251,14 @@ 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;
258
258
  if (autoMarkSuccess) {
259
- setTimeout(() => {
260
- markSuccess();
261
- }, 1000);
259
+ // setTimeout(() => {
260
+ markSuccess();
261
+ // }, 1000);
262
262
  }
263
263
  if (checkStrategy === 'both' || checkStrategy === 'onAppResume') {
264
264
  stateListener.current = AppState.addEventListener(
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
  };