react-native-update 10.25.3 → 10.25.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.ts +11 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.25.3",
3
+ "version": "10.25.4",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
package/src/client.ts CHANGED
@@ -82,13 +82,13 @@ export class Pushy {
82
82
  };
83
83
  })();
84
84
 
85
- constructor(options: ClientOptions) {
85
+ constructor(options: ClientOptions, clientType?: 'Pushy' | 'Cresc') {
86
86
  if (Platform.OS === 'ios' || Platform.OS === 'android') {
87
87
  if (!options.appKey) {
88
88
  throw new Error('appKey is required');
89
89
  }
90
90
  }
91
- this.clientType = new.target.name as 'Pushy' | 'Cresc';
91
+ this.clientType = clientType || 'Pushy';
92
92
  this.options.server = SERVER_PRESETS[this.clientType];
93
93
  this.setOptions(options);
94
94
  if (isRolledBack) {
@@ -226,10 +226,11 @@ export class Pushy {
226
226
  // @ts-ignore
227
227
  delete fetchBody.buildTime;
228
228
  }
229
+ const stringifyBody = JSON.stringify(fetchBody);
229
230
  // harmony fetch body is not string
230
231
  let body: any = fetchBody;
231
232
  if (Platform.OS === 'ios' || Platform.OS === 'android') {
232
- body = JSON.stringify(fetchBody);
233
+ body = stringifyBody;
233
234
  }
234
235
  const fetchPayload = {
235
236
  method: 'POST',
@@ -243,13 +244,13 @@ export class Pushy {
243
244
  try {
244
245
  this.report({
245
246
  type: 'checking',
246
- message: this.options.appKey + ': ' + body,
247
+ message: this.options.appKey + ': ' + stringifyBody,
247
248
  });
248
249
  resp = await fetch(this.getCheckUrl(), fetchPayload);
249
250
  } catch (e: any) {
250
251
  this.report({
251
252
  type: 'errorChecking',
252
- message: 'Can not connect to update server. Trying backup endpoints.',
253
+ message: `Can not connect to update server: ${e.message}. Trying backup endpoints.`,
253
254
  });
254
255
  const backupEndpoints = await this.getBackupEndpoints();
255
256
  if (backupEndpoints) {
@@ -520,4 +521,8 @@ export class Pushy {
520
521
  }
521
522
 
522
523
  // for international users
523
- export class Cresc extends Pushy {}
524
+ export class Cresc extends Pushy {
525
+ constructor(options: ClientOptions) {
526
+ super(options, 'Cresc');
527
+ }
528
+ }