react-native-screenshot-aware 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/app.plugin.js +1 -0
- package/lib/commonjs/plugin/withReactNativeScreenshotAware.js +48 -0
- package/lib/commonjs/plugin/withReactNativeScreenshotAware.js.map +1 -0
- package/lib/module/plugin/withReactNativeScreenshotAware.js +44 -0
- package/lib/module/plugin/withReactNativeScreenshotAware.js.map +1 -0
- package/lib/typescript/plugin/withReactNativeScreenshotAware.d.ts +11 -0
- package/lib/typescript/plugin/withReactNativeScreenshotAware.d.ts.map +1 -0
- package/package.json +9 -2
- package/src/plugin/withReactNativeScreenshotAware.ts +50 -0
package/README.md
CHANGED
|
@@ -37,6 +37,26 @@ npm install react-native-screenshot-aware
|
|
|
37
37
|
- Leverages the new `DETECT_SCREEN_CAPTURE` permission introduced in Android 14
|
|
38
38
|
- Provides a more privacy-friendly and performant approach to screenshot detection
|
|
39
39
|
|
|
40
|
+
## Expo
|
|
41
|
+
|
|
42
|
+
For Expo projects, you can use the Expo plugin in `app.json`
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
"plugins": [
|
|
46
|
+
"react-native-screenshot-aware"
|
|
47
|
+
],
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
or add the permission manually to your `app.json`:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
"android": {
|
|
54
|
+
"permissions": ["android.permission.DETECT_SCREEN_CAPTURE"]
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Bare RN
|
|
59
|
+
|
|
40
60
|
### Permissions
|
|
41
61
|
|
|
42
62
|
To use the screenshot detection feature on Android, you need to add the following permission to your `AndroidManifest.xml` file:
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./lib/commonjs/plugin/withReactNativeScreenshotAware");
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
8
|
+
/**
|
|
9
|
+
* Modifies the `AndroidManifest.xml` file to add `DETECT_SCREEN_CAPTURE` permission,
|
|
10
|
+
* allowing the app to detect screen capture.
|
|
11
|
+
*
|
|
12
|
+
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
13
|
+
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
14
|
+
*/
|
|
15
|
+
const withCustomAndroidManifest = config => {
|
|
16
|
+
return (0, _configPlugins.withAndroidManifest)(config, config => {
|
|
17
|
+
const androidManifest = config.modResults;
|
|
18
|
+
if (!androidManifest.manifest["uses-permission"]) {
|
|
19
|
+
androidManifest.manifest["uses-permission"] = [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Check if the permission already exists
|
|
23
|
+
const permissionExists = androidManifest.manifest["uses-permission"].some(permission => permission.$?.["android:name"] === "android.permission.DETECT_SCREEN_CAPTURE");
|
|
24
|
+
|
|
25
|
+
// Only add the permission if it doesn't already exist
|
|
26
|
+
if (!permissionExists) {
|
|
27
|
+
androidManifest.manifest["uses-permission"].push({
|
|
28
|
+
$: {
|
|
29
|
+
"android:name": "android.permission.DETECT_SCREEN_CAPTURE"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return config;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Applies `withCustomAndroidManifest`
|
|
39
|
+
* to enable screenshot detection on Android.
|
|
40
|
+
*
|
|
41
|
+
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
42
|
+
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
43
|
+
*/
|
|
44
|
+
const withReactNativeScreenshotAware = config => {
|
|
45
|
+
return withCustomAndroidManifest(config);
|
|
46
|
+
};
|
|
47
|
+
var _default = exports.default = withReactNativeScreenshotAware;
|
|
48
|
+
//# sourceMappingURL=withReactNativeScreenshotAware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","withCustomAndroidManifest","config","withAndroidManifest","androidManifest","modResults","manifest","permissionExists","some","permission","$","push","withReactNativeScreenshotAware","_default","exports","default"],"sourceRoot":"../../../src","sources":["plugin/withReactNativeScreenshotAware.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAAuC,GAAIC,MAAM,IAAK;EAC1D,OAAO,IAAAC,kCAAmB,EAACD,MAAM,EAAGA,MAAM,IAAK;IAC7C,MAAME,eAAe,GAAGF,MAAM,CAACG,UAAU;IAEzC,IAAI,CAACD,eAAe,CAACE,QAAQ,CAAC,iBAAiB,CAAC,EAAE;MAChDF,eAAe,CAACE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,EAAE;IAClD;;IAEA;IACA,MAAMC,gBAAgB,GAAGH,eAAe,CAACE,QAAQ,CAAC,iBAAiB,CAAC,CAACE,IAAI,CACtEC,UAAU,IACTA,UAAU,CAACC,CAAC,GAAG,cAAc,CAAC,KAC9B,0CACJ,CAAC;;IAED;IACA,IAAI,CAACH,gBAAgB,EAAE;MACrBH,eAAe,CAACE,QAAQ,CAAC,iBAAiB,CAAC,CAACK,IAAI,CAAC;QAC/CD,CAAC,EAAE;UACD,cAAc,EAAE;QAClB;MACF,CAAC,CAAC;IACJ;IAEA,OAAOR,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMU,8BAA4C,GAAIV,MAAM,IAAK;EAC/D,OAAOD,yBAAyB,CAACC,MAAM,CAAC;AAC1C,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaH,8BAA8B","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { withAndroidManifest } from "@expo/config-plugins";
|
|
4
|
+
/**
|
|
5
|
+
* Modifies the `AndroidManifest.xml` file to add `DETECT_SCREEN_CAPTURE` permission,
|
|
6
|
+
* allowing the app to detect screen capture.
|
|
7
|
+
*
|
|
8
|
+
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
9
|
+
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
10
|
+
*/
|
|
11
|
+
const withCustomAndroidManifest = config => {
|
|
12
|
+
return withAndroidManifest(config, config => {
|
|
13
|
+
const androidManifest = config.modResults;
|
|
14
|
+
if (!androidManifest.manifest["uses-permission"]) {
|
|
15
|
+
androidManifest.manifest["uses-permission"] = [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Check if the permission already exists
|
|
19
|
+
const permissionExists = androidManifest.manifest["uses-permission"].some(permission => permission.$?.["android:name"] === "android.permission.DETECT_SCREEN_CAPTURE");
|
|
20
|
+
|
|
21
|
+
// Only add the permission if it doesn't already exist
|
|
22
|
+
if (!permissionExists) {
|
|
23
|
+
androidManifest.manifest["uses-permission"].push({
|
|
24
|
+
$: {
|
|
25
|
+
"android:name": "android.permission.DETECT_SCREEN_CAPTURE"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return config;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Applies `withCustomAndroidManifest`
|
|
35
|
+
* to enable screenshot detection on Android.
|
|
36
|
+
*
|
|
37
|
+
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
38
|
+
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
39
|
+
*/
|
|
40
|
+
const withReactNativeScreenshotAware = config => {
|
|
41
|
+
return withCustomAndroidManifest(config);
|
|
42
|
+
};
|
|
43
|
+
export default withReactNativeScreenshotAware;
|
|
44
|
+
//# sourceMappingURL=withReactNativeScreenshotAware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withAndroidManifest","withCustomAndroidManifest","config","androidManifest","modResults","manifest","permissionExists","some","permission","$","push","withReactNativeScreenshotAware"],"sourceRoot":"../../../src","sources":["plugin/withReactNativeScreenshotAware.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,sBAAsB;AAG1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAAuC,GAAIC,MAAM,IAAK;EAC1D,OAAOF,mBAAmB,CAACE,MAAM,EAAGA,MAAM,IAAK;IAC7C,MAAMC,eAAe,GAAGD,MAAM,CAACE,UAAU;IAEzC,IAAI,CAACD,eAAe,CAACE,QAAQ,CAAC,iBAAiB,CAAC,EAAE;MAChDF,eAAe,CAACE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,EAAE;IAClD;;IAEA;IACA,MAAMC,gBAAgB,GAAGH,eAAe,CAACE,QAAQ,CAAC,iBAAiB,CAAC,CAACE,IAAI,CACtEC,UAAU,IACTA,UAAU,CAACC,CAAC,GAAG,cAAc,CAAC,KAC9B,0CACJ,CAAC;;IAED;IACA,IAAI,CAACH,gBAAgB,EAAE;MACrBH,eAAe,CAACE,QAAQ,CAAC,iBAAiB,CAAC,CAACK,IAAI,CAAC;QAC/CD,CAAC,EAAE;UACD,cAAc,EAAE;QAClB;MACF,CAAC,CAAC;IACJ;IAEA,OAAOP,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMS,8BAA4C,GAAIT,MAAM,IAAK;EAC/D,OAAOD,yBAAyB,CAACC,MAAM,CAAC;AAC1C,CAAC;AAED,eAAeS,8BAA8B","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ConfigPlugin } from "expo/config-plugins";
|
|
2
|
+
/**
|
|
3
|
+
* Applies `withCustomAndroidManifest`
|
|
4
|
+
* to enable screenshot detection on Android.
|
|
5
|
+
*
|
|
6
|
+
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
7
|
+
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
8
|
+
*/
|
|
9
|
+
declare const withReactNativeScreenshotAware: ConfigPlugin;
|
|
10
|
+
export default withReactNativeScreenshotAware;
|
|
11
|
+
//# sourceMappingURL=withReactNativeScreenshotAware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withReactNativeScreenshotAware.d.ts","sourceRoot":"","sources":["../../../src/plugin/withReactNativeScreenshotAware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAqCxD;;;;;;GAMG;AACH,QAAA,MAAM,8BAA8B,EAAE,YAErC,CAAC;AAEF,eAAe,8BAA8B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-screenshot-aware",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "React Native module for real-time screenshot detection on Android and iOS",
|
|
5
5
|
"source": "src/index.tsx",
|
|
6
6
|
"main": "lib/commonjs/index.js",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"!**/__tests__",
|
|
24
24
|
"!**/__fixtures__",
|
|
25
25
|
"!**/__mocks__",
|
|
26
|
-
"!**/.*"
|
|
26
|
+
"!**/.*",
|
|
27
|
+
"app.plugin.js"
|
|
27
28
|
],
|
|
28
29
|
"scripts": {
|
|
29
30
|
"example": "yarn workspace react-native-screenshot-aware-example",
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
"@types/react-test-renderer": "19.0.0",
|
|
72
73
|
"commitlint": "19.7.1",
|
|
73
74
|
"del-cli": "6.0.0",
|
|
75
|
+
"expo": "^52.0.37",
|
|
74
76
|
"husky": "9.1.7",
|
|
75
77
|
"jest": "29.7.0",
|
|
76
78
|
"react": "19.0.0",
|
|
@@ -88,6 +90,11 @@
|
|
|
88
90
|
"react": "*",
|
|
89
91
|
"react-native": "*"
|
|
90
92
|
},
|
|
93
|
+
"peerDependenciesMeta": {
|
|
94
|
+
"expo": {
|
|
95
|
+
"optional": true
|
|
96
|
+
}
|
|
97
|
+
},
|
|
91
98
|
"workspaces": [
|
|
92
99
|
"example"
|
|
93
100
|
],
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { withAndroidManifest } from "@expo/config-plugins";
|
|
2
|
+
import type { ConfigPlugin } from "expo/config-plugins";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Modifies the `AndroidManifest.xml` file to add `DETECT_SCREEN_CAPTURE` permission,
|
|
6
|
+
* allowing the app to detect screen capture.
|
|
7
|
+
*
|
|
8
|
+
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
9
|
+
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
10
|
+
*/
|
|
11
|
+
const withCustomAndroidManifest: ConfigPlugin = (config) => {
|
|
12
|
+
return withAndroidManifest(config, (config) => {
|
|
13
|
+
const androidManifest = config.modResults;
|
|
14
|
+
|
|
15
|
+
if (!androidManifest.manifest["uses-permission"]) {
|
|
16
|
+
androidManifest.manifest["uses-permission"] = [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Check if the permission already exists
|
|
20
|
+
const permissionExists = androidManifest.manifest["uses-permission"].some(
|
|
21
|
+
(permission) =>
|
|
22
|
+
permission.$?.["android:name"] ===
|
|
23
|
+
"android.permission.DETECT_SCREEN_CAPTURE",
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Only add the permission if it doesn't already exist
|
|
27
|
+
if (!permissionExists) {
|
|
28
|
+
androidManifest.manifest["uses-permission"].push({
|
|
29
|
+
$: {
|
|
30
|
+
"android:name": "android.permission.DETECT_SCREEN_CAPTURE",
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return config;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Applies `withCustomAndroidManifest`
|
|
41
|
+
* to enable screenshot detection on Android.
|
|
42
|
+
*
|
|
43
|
+
* @param {ConfigPlugin} config - The Expo configuration object.
|
|
44
|
+
* @returns {ConfigPlugin} - The modified Expo configuration.
|
|
45
|
+
*/
|
|
46
|
+
const withReactNativeScreenshotAware: ConfigPlugin = (config) => {
|
|
47
|
+
return withCustomAndroidManifest(config);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default withReactNativeScreenshotAware;
|