v10.5.2
This commit is contained in:
parent
ad9b0778ba
commit
5996a7aa75
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.5.1",
|
||||
"version": "10.5.2",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
|
@ -1,13 +0,0 @@
|
||||
const noop = () => {};
|
||||
export class Pushy {
|
||||
constructor() {
|
||||
console.warn(
|
||||
'react-native-update is not supported and will do nothing on web.',
|
||||
);
|
||||
return new Proxy(this, {
|
||||
get() {
|
||||
return noop;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
import { CheckResult, PushyOptions, ProgressData, EventType } from './type';
|
||||
import { log, testUrls } from './utils';
|
||||
import {
|
||||
EmitterSubscription,
|
||||
PermissionsAndroid,
|
||||
Platform,
|
||||
} from 'react-native';
|
||||
import { EmitterSubscription, Platform } from 'react-native';
|
||||
import type { PermissionsAndroidStatic } from 'react-native';
|
||||
import {
|
||||
PushyModule,
|
||||
buildTime,
|
||||
@ -27,6 +24,10 @@ const defaultServer = {
|
||||
const empty = {};
|
||||
const noop = () => {};
|
||||
|
||||
if (Platform.OS === 'web') {
|
||||
console.warn('react-native-update 不支持 web 端热更,不会执行操作');
|
||||
}
|
||||
|
||||
export class Pushy {
|
||||
options: PushyOptions = {
|
||||
appKey: '',
|
||||
@ -149,10 +150,14 @@ export class Pushy {
|
||||
checkUpdate = async () => {
|
||||
if (__DEV__ && !this.options.debug) {
|
||||
console.info(
|
||||
'您当前处于开发环境且未启用debug,不会进行热更检查。如需在开发环境中调试热更,请在client中设置debug为true',
|
||||
'您当前处于开发环境且未启用 debug,不会进行热更检查。如需在开发环境中调试热更,请在 client 中设置 debug 为 true',
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (Platform.OS === 'web') {
|
||||
console.warn('web 端不支持热更新检查');
|
||||
return;
|
||||
}
|
||||
const now = Date.now();
|
||||
if (
|
||||
this.lastRespJson &&
|
||||
@ -366,6 +371,8 @@ export class Pushy {
|
||||
this.report({ type: 'downloadingApk' });
|
||||
if (Platform.Version <= 23) {
|
||||
try {
|
||||
const PermissionsAndroid =
|
||||
require('react-native/Libraries/PermissionsAndroid/PermissionsAndroid') as PermissionsAndroidStatic;
|
||||
const granted = await PermissionsAndroid.request(
|
||||
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
||||
);
|
16
src/core.ts
16
src/core.ts
@ -8,7 +8,21 @@ const isTurboModuleEnabled =
|
||||
// @ts-expect-error
|
||||
global.__turboModuleProxy != null;
|
||||
|
||||
export const PushyModule = isTurboModuleEnabled
|
||||
const noop = () => {};
|
||||
class EmptyModule {
|
||||
constructor() {
|
||||
return new Proxy(this, {
|
||||
get() {
|
||||
return noop;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const PushyModule =
|
||||
Platform.OS === 'web'
|
||||
? new EmptyModule()
|
||||
: isTurboModuleEnabled
|
||||
? require('./NativePushy').default
|
||||
: NativeModules.Pushy;
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
export { Pushy } from './client.native';
|
||||
export { PushyContext, usePushy } from './context';
|
||||
export { PushyProvider } from './provider.native';
|
@ -1,2 +0,0 @@
|
||||
import React from 'react';
|
||||
export const PushyProvider = ({ children }) => <>{children}</>;
|
@ -12,7 +12,7 @@ import {
|
||||
Platform,
|
||||
Linking,
|
||||
} from 'react-native';
|
||||
import { Pushy } from './client.native';
|
||||
import { Pushy } from './client';
|
||||
import {
|
||||
currentVersion,
|
||||
isFirstTime,
|
@ -1,8 +1,12 @@
|
||||
import { Platform } from 'react-native';
|
||||
export function log(...args: any[]) {
|
||||
console.log('pushy: ', ...args);
|
||||
}
|
||||
|
||||
const ping = async (url: string) =>
|
||||
const ping =
|
||||
Platform.OS === 'web'
|
||||
? () => Promise.resolve(true)
|
||||
: async (url: string) =>
|
||||
Promise.race([
|
||||
fetch(url, {
|
||||
method: 'HEAD',
|
||||
|
Loading…
Reference in New Issue
Block a user