react-native-update 10.11.3 → 10.11.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.11.3",
3
+ "version": "10.11.5",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
package/src/client.ts CHANGED
@@ -172,7 +172,6 @@ export class Pushy {
172
172
  return await this.lastRespJson;
173
173
  }
174
174
  this.lastChecking = now;
175
- this.report({ type: 'checking' });
176
175
  const fetchBody = {
177
176
  packageVersion,
178
177
  hash: currentVersion,
@@ -183,16 +182,21 @@ export class Pushy {
183
182
  if (__DEV__) {
184
183
  delete fetchBody.buildTime;
185
184
  }
185
+ const body = JSON.stringify(fetchBody);
186
186
  const fetchPayload = {
187
187
  method: 'POST',
188
188
  headers: {
189
189
  Accept: 'application/json',
190
190
  'Content-Type': 'application/json',
191
191
  },
192
- body: JSON.stringify(fetchBody),
192
+ body,
193
193
  };
194
194
  let resp;
195
195
  try {
196
+ this.report({
197
+ type: 'checking',
198
+ message: this.options.appKey + ': ' + body,
199
+ });
196
200
  resp = await fetch(this.getCheckUrl(), fetchPayload);
197
201
  } catch (e: any) {
198
202
  this.report({
@@ -221,6 +225,8 @@ export class Pushy {
221
225
 
222
226
  const result: CheckResult = await this.lastRespJson;
223
227
 
228
+ log('checking result:', result);
229
+
224
230
  if (resp.status !== 200) {
225
231
  this.report({
226
232
  type: 'errorChecking',
package/src/provider.tsx CHANGED
@@ -147,7 +147,7 @@ export const PushyProvider = ({
147
147
  );
148
148
 
149
149
  const checkUpdate = useCallback(
150
- async (extra?: Record<string, any>) => {
150
+ async ({ extra }: { extra?: Record<string, any> } | undefined = {}) => {
151
151
  const now = Date.now();
152
152
  if (lastChecking.current && now - lastChecking.current < 1000) {
153
153
  return;
@@ -272,7 +272,7 @@ export const PushyProvider = ({
272
272
  Alert.alert(type, JSON.stringify(data));
273
273
  };
274
274
  if (payload.type === '__rnPushyVersionHash') {
275
- checkUpdate({ toHash: payload.data }).then(() => {
275
+ checkUpdate({ extra: { toHash: payload.data } }).then(() => {
276
276
  if (updateInfoRef.current && updateInfoRef.current.upToDate) {
277
277
  Alert.alert(
278
278
  '提示',
@@ -290,10 +290,9 @@ export const PushyProvider = ({
290
290
  );
291
291
 
292
292
  const parseTestQrCode = useCallback(
293
- (code: string) => {
294
- let payload: PushyTestPayload;
293
+ (code: string | PushyTestPayload) => {
295
294
  try {
296
- payload = JSON.parse(code);
295
+ const payload = typeof code === 'string' ? JSON.parse(code) : code;
297
296
  return parseTestPayload(payload);
298
297
  } catch {
299
298
  return false;