From e9e67b011c5d1605a2fb146de91c8ec47867eb27 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Tue, 23 Apr 2024 00:15:13 +0800 Subject: [PATCH] v10.5.3 --- package.json | 2 +- src/client.ts | 4 +--- src/core.ts | 13 +------------ src/permissions.native.ts | 1 + src/permissions.ts | 4 ++++ src/utils.ts | 12 ++++++++++++ 6 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 src/permissions.native.ts create mode 100644 src/permissions.ts diff --git a/package.json b/package.json index b524a5c..997ca01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update", - "version": "10.5.2", + "version": "10.5.3", "description": "react-native hot update", "main": "src/index", "scripts": { diff --git a/src/client.ts b/src/client.ts index c12b182..c98d035 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,7 +1,7 @@ import { CheckResult, PushyOptions, ProgressData, EventType } from './type'; import { log, testUrls } from './utils'; import { EmitterSubscription, Platform } from 'react-native'; -import type { PermissionsAndroidStatic } from 'react-native'; +import { PermissionsAndroid } from './permissions'; import { PushyModule, buildTime, @@ -371,8 +371,6 @@ 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, ); diff --git a/src/core.ts b/src/core.ts index 5f903bc..707c2d0 100644 --- a/src/core.ts +++ b/src/core.ts @@ -1,5 +1,5 @@ import { NativeEventEmitter, NativeModules, Platform } from 'react-native'; -import { log } from './utils'; +import { EmptyModule, log } from './utils'; const { version: v, } = require('react-native/Libraries/Core/ReactNativeVersion'); @@ -8,17 +8,6 @@ const isTurboModuleEnabled = // @ts-expect-error global.__turboModuleProxy != null; -const noop = () => {}; -class EmptyModule { - constructor() { - return new Proxy(this, { - get() { - return noop; - }, - }); - } -} - export const PushyModule = Platform.OS === 'web' ? new EmptyModule() diff --git a/src/permissions.native.ts b/src/permissions.native.ts new file mode 100644 index 0000000..6c92b14 --- /dev/null +++ b/src/permissions.native.ts @@ -0,0 +1 @@ +export { PermissionsAndroid } from 'react-native'; diff --git a/src/permissions.ts b/src/permissions.ts new file mode 100644 index 0000000..6a9ce3a --- /dev/null +++ b/src/permissions.ts @@ -0,0 +1,4 @@ +import type { PermissionsAndroidStatic } from 'react-native'; +import { EmptyModule } from './utils'; + +export const PermissionsAndroid = new EmptyModule() as PermissionsAndroidStatic; diff --git a/src/utils.ts b/src/utils.ts index 9cc5670..de557f8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,8 +1,20 @@ import { Platform } from 'react-native'; + export function log(...args: any[]) { console.log('pushy: ', ...args); } +const noop = () => {}; +export class EmptyModule { + constructor() { + return new Proxy(this, { + get() { + return noop; + }, + }); + } +} + const ping = Platform.OS === 'web' ? () => Promise.resolve(true)