react-native-update 10.5.0 → 10.5.2
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 +2 -2
- package/src/{client.native.ts → client.ts} +13 -6
- package/src/core.ts +17 -3
- package/src/{provider.native.tsx → provider.tsx} +1 -1
- package/src/utils.ts +11 -7
- package/src/client.js +0 -13
- package/src/index.native.ts +0 -3
- package/src/provider.jsx +0 -2
- /package/src/{index.js → index.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update",
|
|
3
|
-
"version": "10.5.
|
|
3
|
+
"version": "10.5.2",
|
|
4
4
|
"description": "react-native hot update",
|
|
5
|
-
"main": "src/index
|
|
5
|
+
"main": "src/index",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn submodule && yarn lint",
|
|
8
8
|
"lint": "eslint \"src/*.@(ts|tsx|js|jsx)\" && tsc --noEmit",
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { CheckResult, PushyOptions, ProgressData, EventType } from './type';
|
|
2
2
|
import { log, testUrls } from './utils';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
PermissionsAndroid,
|
|
6
|
-
Platform,
|
|
7
|
-
} from 'react-native';
|
|
3
|
+
import { EmitterSubscription, Platform } from 'react-native';
|
|
4
|
+
import type { PermissionsAndroidStatic } from 'react-native';
|
|
8
5
|
import {
|
|
9
6
|
PushyModule,
|
|
10
7
|
buildTime,
|
|
@@ -27,6 +24,10 @@ const defaultServer = {
|
|
|
27
24
|
const empty = {};
|
|
28
25
|
const noop = () => {};
|
|
29
26
|
|
|
27
|
+
if (Platform.OS === 'web') {
|
|
28
|
+
console.warn('react-native-update 不支持 web 端热更,不会执行操作');
|
|
29
|
+
}
|
|
30
|
+
|
|
30
31
|
export class Pushy {
|
|
31
32
|
options: PushyOptions = {
|
|
32
33
|
appKey: '',
|
|
@@ -149,10 +150,14 @@ export class Pushy {
|
|
|
149
150
|
checkUpdate = async () => {
|
|
150
151
|
if (__DEV__ && !this.options.debug) {
|
|
151
152
|
console.info(
|
|
152
|
-
'您当前处于开发环境且未启用debug,不会进行热更检查。如需在开发环境中调试热更,请在client中设置debug为true',
|
|
153
|
+
'您当前处于开发环境且未启用 debug,不会进行热更检查。如需在开发环境中调试热更,请在 client 中设置 debug 为 true',
|
|
153
154
|
);
|
|
154
155
|
return;
|
|
155
156
|
}
|
|
157
|
+
if (Platform.OS === 'web') {
|
|
158
|
+
console.warn('web 端不支持热更新检查');
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
156
161
|
const now = Date.now();
|
|
157
162
|
if (
|
|
158
163
|
this.lastRespJson &&
|
|
@@ -366,6 +371,8 @@ export class Pushy {
|
|
|
366
371
|
this.report({ type: 'downloadingApk' });
|
|
367
372
|
if (Platform.Version <= 23) {
|
|
368
373
|
try {
|
|
374
|
+
const PermissionsAndroid =
|
|
375
|
+
require('react-native/Libraries/PermissionsAndroid/PermissionsAndroid') as PermissionsAndroidStatic;
|
|
369
376
|
const granted = await PermissionsAndroid.request(
|
|
370
377
|
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
|
371
378
|
);
|
package/src/core.ts
CHANGED
|
@@ -8,9 +8,23 @@ const isTurboModuleEnabled =
|
|
|
8
8
|
// @ts-expect-error
|
|
9
9
|
global.__turboModuleProxy != null;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const noop = () => {};
|
|
12
|
+
class EmptyModule {
|
|
13
|
+
constructor() {
|
|
14
|
+
return new Proxy(this, {
|
|
15
|
+
get() {
|
|
16
|
+
return noop;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const PushyModule =
|
|
23
|
+
Platform.OS === 'web'
|
|
24
|
+
? new EmptyModule()
|
|
25
|
+
: isTurboModuleEnabled
|
|
26
|
+
? require('./NativePushy').default
|
|
27
|
+
: NativeModules.Pushy;
|
|
14
28
|
|
|
15
29
|
if (!PushyModule) {
|
|
16
30
|
throw new Error('react-native-update模块无法加载,请对照安装文档检查配置。');
|
package/src/utils.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
1
2
|
export function log(...args: any[]) {
|
|
2
3
|
console.log('pushy: ', ...args);
|
|
3
4
|
}
|
|
4
5
|
|
|
5
|
-
const ping =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const ping =
|
|
7
|
+
Platform.OS === 'web'
|
|
8
|
+
? () => Promise.resolve(true)
|
|
9
|
+
: async (url: string) =>
|
|
10
|
+
Promise.race([
|
|
11
|
+
fetch(url, {
|
|
12
|
+
method: 'HEAD',
|
|
13
|
+
}).then(({ status }) => status === 200),
|
|
14
|
+
new Promise<false>(r => setTimeout(() => r(false), 2000)),
|
|
15
|
+
]);
|
|
12
16
|
|
|
13
17
|
const canUseGoogle = ping('https://www.google.com');
|
|
14
18
|
|
package/src/client.js
DELETED
package/src/index.native.ts
DELETED
package/src/provider.jsx
DELETED
|
File without changes
|