Skip to content

Commit

Permalink
v10.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylqm committed Apr 22, 2024
1 parent 5996a7a commit e9e67b0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 1 addition & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
);
Expand Down
13 changes: 1 addition & 12 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/permissions.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PermissionsAndroid } from 'react-native';
4 changes: 4 additions & 0 deletions src/permissions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { PermissionsAndroidStatic } from 'react-native';
import { EmptyModule } from './utils';

export const PermissionsAndroid = new EmptyModule() as PermissionsAndroidStatic;
12 changes: 12 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit e9e67b0

Please sign in to comment.