Skip to content

Commit

Permalink
fix files load
Browse files Browse the repository at this point in the history
  • Loading branch information
killserver committed Jun 23, 2023
1 parent f4e139e commit 51fdb05
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "react-native-screenshot-prevent",
"version": "1.1.4",
"version": "1.1.5",
"description": "This fork contains fully working blank screenshot on IOS13+ including screen recording",
"main": "lib/commonjs/index",
"module": "lib/module/index",
"types": "index.d.ts",
"types": "./src/index.d.ts",
"react-native": "index",
"source": "./src/index",
"files": [
Expand All @@ -28,6 +28,7 @@
"scripts": {
"test": "jest",
"typecheck": "tsc --noEmit",
"prepare": "bob build",
"lint": "eslint \"**/*.{js,ts,tsx}\""
},
"keywords": [
Expand All @@ -43,6 +44,7 @@
},
"homepage": "https://github.com/killserver/react-native-screenshot-prevent#readme",
"devDependencies": {
"@react-native-community/bob": "^0.4.1",
"@commitlint/config-conventional": "^17.0.2",
"@evilmartians/lefthook": "^1.2.2",
"@react-native-community/eslint-config": "^3.0.2",
Expand Down Expand Up @@ -113,6 +115,14 @@
"trailingComma": "es5",
"useTabs": true
},
"@react-native-community/bob": {
"source": "src",
"output": "lib",
"targets": [
"module",
"typescript"
]
},
"codegenConfig": {
"name": "RNScreenshotPreventSpec",
"type": "modules",
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ declare module 'react-native-screenshot-prevent' {
export function disableSecureView(): void;
export function usePreventScreenshot(): void;
export function useDisableSecureView(): void;
export function addListener(fn: Function) => void;
export function addListener(fn: Function): void;
}
18 changes: 13 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
import { useEffect } from 'react';

let addListen, RNScreenshotPrevent;
type FN = (resp: any) => void
type Return = {
readonly remove: () => void
}

let addListen: any, RNScreenshotPrevent: any;
if(Platform.OS !== "web") {
const { RNScreenshotPrevent: RNScreenshotPreventNative } = NativeModules;
RNScreenshotPrevent = RNScreenshotPreventNative
Expand All @@ -12,7 +17,7 @@ if(Platform.OS !== "web") {
* @param {function} callback handler
* @returns {function} unsubscribe fn
*/
addListen = (fn): void => {
addListen = (fn: FN): Return => {
if(typeof(fn) !== 'function') {
console.error('RNScreenshotPrevent: addListener requires valid callback function');
return {
Expand All @@ -27,7 +32,7 @@ if(Platform.OS !== "web") {
} else {
RNScreenshotPrevent = {
enabled: (enabled: boolean): void => {
console.warn("RNScreenshotPrevent: enabled not work in web");
console.warn("RNScreenshotPrevent: enabled not work in web. value: "+enabled);
},
enableSecureView: (): void => {
console.warn("RNScreenshotPrevent: enableSecureView not work in web");
Expand All @@ -36,7 +41,7 @@ if(Platform.OS !== "web") {
console.warn("RNScreenshotPrevent: disableSecureView not work in web");
}
}
addListen = (fn): void => {
addListen = (fn: FN): Return => {
if(typeof(fn) !== 'function') {
console.error('RNScreenshotPrevent: addListener requires valid callback function');
return {
Expand Down Expand Up @@ -72,5 +77,8 @@ export const useDisableSecureView = () => {
}, []);
}

export const addListener = addListen
export const enabled: (enabled: boolean) => void = RNScreenshotPrevent.enabled
export const enableSecureView: () => void = RNScreenshotPrevent.enableSecureView
export const disableSecureView: () => void = RNScreenshotPrevent.disableSecureView
export const addListener: (fn: FN) => void = addListen
export default RNScreenshotPrevent;
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"paths": {
"react-native-screenshot-prevent": ["./src/index"]
},
"files": ["src/index.d.ts"],
"include": ["src/index.ts"],
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"esModuleInterop": true,
Expand Down

0 comments on commit 51fdb05

Please sign in to comment.