From 9fd62930379a15c4169bb6f2688ce9f34c5b786e Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Tue, 23 Apr 2024 00:24:32 +0800 Subject: [PATCH] emptymodule --- src/core.ts | 4 ++-- src/permissions.ts | 4 ++-- src/utils.ts | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core.ts b/src/core.ts index 707c2d0..6d76da1 100644 --- a/src/core.ts +++ b/src/core.ts @@ -1,5 +1,5 @@ import { NativeEventEmitter, NativeModules, Platform } from 'react-native'; -import { EmptyModule, log } from './utils'; +import { emptyModule, log } from './utils'; const { version: v, } = require('react-native/Libraries/Core/ReactNativeVersion'); @@ -10,7 +10,7 @@ const isTurboModuleEnabled = export const PushyModule = Platform.OS === 'web' - ? new EmptyModule() + ? emptyModule : isTurboModuleEnabled ? require('./NativePushy').default : NativeModules.Pushy; diff --git a/src/permissions.ts b/src/permissions.ts index 6a9ce3a..f01ee5a 100644 --- a/src/permissions.ts +++ b/src/permissions.ts @@ -1,4 +1,4 @@ import type { PermissionsAndroidStatic } from 'react-native'; -import { EmptyModule } from './utils'; +import { emptyModule } from './utils'; -export const PermissionsAndroid = new EmptyModule() as PermissionsAndroidStatic; +export const PermissionsAndroid = emptyModule as PermissionsAndroidStatic; diff --git a/src/utils.ts b/src/utils.ts index de557f8..97623ea 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -5,7 +5,7 @@ export function log(...args: any[]) { } const noop = () => {}; -export class EmptyModule { +class EmptyModule { constructor() { return new Proxy(this, { get() { @@ -14,6 +14,7 @@ export class EmptyModule { }); } } +export const emptyModule = new EmptyModule(); const ping = Platform.OS === 'web'