rn-system-bar 3.1.5 → 3.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-system-bar",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "description": "Control Android & iOS system bars, brightness, volume, orientation and screen flags from React Native.",
5
5
  "main": "lib/index.js",
6
6
  "react-native": "lib/index.js",
@@ -27,6 +27,7 @@
27
27
  "specs/",
28
28
  "android/",
29
29
  "ios/",
30
+ "plugin/",
30
31
  "rn-system-bar.podspec"
31
32
  ],
32
33
  "peerDependencies": {
@@ -38,9 +39,15 @@
38
39
  "npm:prepublish": "npm publish --access public",
39
40
  "installing": "cd .. && npm install rn-system-bar@latest && cd rn-system-bar"
40
41
  },
42
+ "expo": {
43
+ "plugins": [
44
+ "./plugin/withRnSystemBar"
45
+ ]
46
+ },
41
47
  "devDependencies": {
42
48
  "@types/react": "^19.2.14",
43
49
  "@types/react-native": "^0.72.8",
50
+ "rimraf": "^6.0.1",
44
51
  "typescript": "^5.9.3"
45
52
  }
46
53
  }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // ─────────────────────────────────────────────
3
+ // rn-system-bar · Expo Config Plugin
4
+ // plugin/withRnSystemBar.js (compiled from withRnSystemBar.ts)
5
+ //
6
+ // Automatically wires the native module into
7
+ // an Expo-managed (EAS Build) project.
8
+ //
9
+ // What it does:
10
+ // Android → ensures WRITE_SETTINGS permission is
11
+ // declared in AndroidManifest.xml so
12
+ // setBrightness() works without crashing.
13
+ // iOS → no-op (Swift module is auto-linked).
14
+ // ─────────────────────────────────────────────
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+
17
+ const config_plugins_1 = require("@expo/config-plugins");
18
+
19
+ const { getMainApplicationOrThrow } = config_plugins_1.AndroidConfig.Manifest;
20
+
21
+ // ── Permission tag we need ───────────────────
22
+ const WRITE_SETTINGS = "android.permission.WRITE_SETTINGS";
23
+
24
+ // ── withAndroidPermission ────────────────────
25
+ // Adds <uses-permission android:name="android.permission.WRITE_SETTINGS" />
26
+ // to AndroidManifest.xml if it is not already present.
27
+ const withRnSystemBarAndroid = (config) =>
28
+ (0, config_plugins_1.withAndroidManifest)(config, (mod) => {
29
+ const manifest = mod.modResults;
30
+
31
+ // Ensure the top-level <manifest> permissions array exists
32
+ if (!Array.isArray(manifest.manifest["uses-permission"])) {
33
+ manifest.manifest["uses-permission"] = [];
34
+ }
35
+
36
+ const permissions = manifest.manifest["uses-permission"];
37
+
38
+ const alreadyAdded = permissions.some(
39
+ (p) => p.$?.["android:name"] === WRITE_SETTINGS
40
+ );
41
+
42
+ if (!alreadyAdded) {
43
+ permissions.push({ $: { "android:name": WRITE_SETTINGS } });
44
+ }
45
+
46
+ return mod;
47
+ });
48
+
49
+ // ── Main plugin ──────────────────────────────
50
+ const withRnSystemBar = (config) => {
51
+ // Apply Android manifest modifications
52
+ config = withRnSystemBarAndroid(config);
53
+ // iOS: auto-linking handles everything — nothing to patch
54
+ return config;
55
+ };
56
+
57
+ // createRunOncePlugin ensures the plugin runs exactly once
58
+ // even if the user lists it multiple times in app.json.
59
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(
60
+ withRnSystemBar,
61
+ "rn-system-bar", // plugin name (must match package name)
62
+ "3.1.5" // plugin version (keep in sync with package.json)
63
+ );
64
+
65
+ module.exports = exports.default;
@@ -0,0 +1,68 @@
1
+ // ─────────────────────────────────────────────
2
+ // rn-system-bar · Expo Config Plugin
3
+ // plugin/withRnSystemBar.ts
4
+ //
5
+ // Automatically wires the native module into
6
+ // an Expo-managed (EAS Build) project.
7
+ //
8
+ // What it does:
9
+ // Android → ensures WRITE_SETTINGS permission is
10
+ // declared in AndroidManifest.xml so
11
+ // setBrightness() works without crashing.
12
+ // iOS → no-op (Swift module is auto-linked).
13
+ // ─────────────────────────────────────────────
14
+
15
+ import {
16
+ AndroidConfig,
17
+ ConfigPlugin,
18
+ createRunOncePlugin,
19
+ withAndroidManifest,
20
+ } from "@expo/config-plugins";
21
+
22
+ const { getMainApplicationOrThrow } = AndroidConfig.Manifest;
23
+
24
+ // ── Permission tag we need ───────────────────
25
+ const WRITE_SETTINGS = "android.permission.WRITE_SETTINGS";
26
+
27
+ // ── withAndroidPermission ────────────────────
28
+ // Adds <uses-permission android:name="android.permission.WRITE_SETTINGS" />
29
+ // to AndroidManifest.xml if it is not already present.
30
+ const withRnSystemBarAndroid: ConfigPlugin = (config) =>
31
+ withAndroidManifest(config, (mod) => {
32
+ const manifest = mod.modResults;
33
+
34
+ // Ensure the top-level <manifest> permissions array exists
35
+ if (!Array.isArray(manifest.manifest["uses-permission"])) {
36
+ manifest.manifest["uses-permission"] = [];
37
+ }
38
+
39
+ const permissions = manifest.manifest["uses-permission"] as Array<{
40
+ $: { "android:name": string };
41
+ }>;
42
+
43
+ const alreadyAdded = permissions.some(
44
+ (p) => p.$?.["android:name"] === WRITE_SETTINGS,
45
+ );
46
+
47
+ if (!alreadyAdded) {
48
+ permissions.push({ $: { "android:name": WRITE_SETTINGS } });
49
+ }
50
+
51
+ return mod;
52
+ });
53
+
54
+ // ── Main plugin ──────────────────────────────
55
+ const withRnSystemBar: ConfigPlugin = (config) => {
56
+ // Apply Android manifest modifications
57
+ config = withRnSystemBarAndroid(config);
58
+ // iOS: auto-linking handles everything — nothing to patch
59
+ return config;
60
+ };
61
+
62
+ // createRunOncePlugin ensures the plugin runs exactly once
63
+ // even if the user lists it multiple times in app.json.
64
+ export default createRunOncePlugin(
65
+ withRnSystemBar,
66
+ "rn-system-bar", // plugin name (must match package name)
67
+ "3.1.6", // plugin version (keep in sync with package.json)
68
+ );