expo-rotation-module 0.1.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.
Files changed (60) hide show
  1. package/.eslintrc.js +5 -0
  2. package/README.md +77 -0
  3. package/android/.gradle/8.14.3/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.14.3/fileChanges/last-build.bin +0 -0
  5. package/android/.gradle/8.14.3/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/8.14.3/gc.properties +0 -0
  7. package/android/.gradle/9.0-milestone-1/checksums/checksums.lock +0 -0
  8. package/android/.gradle/9.0-milestone-1/fileChanges/last-build.bin +0 -0
  9. package/android/.gradle/9.0-milestone-1/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/9.0-milestone-1/gc.properties +0 -0
  11. package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
  12. package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
  13. package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
  14. package/android/.gradle/9.2.0/gc.properties +0 -0
  15. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  16. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  17. package/android/.gradle/config.properties +2 -0
  18. package/android/.gradle/vcs-1/gc.properties +0 -0
  19. package/android/.idea/AndroidProjectSystem.xml +6 -0
  20. package/android/.idea/caches/deviceStreaming.xml +1210 -0
  21. package/android/.idea/gradle.xml +12 -0
  22. package/android/.idea/migrations.xml +10 -0
  23. package/android/.idea/misc.xml +10 -0
  24. package/android/.idea/runConfigurations.xml +17 -0
  25. package/android/.idea/vcs.xml +6 -0
  26. package/android/.idea/workspace.xml +63 -0
  27. package/android/build.gradle +43 -0
  28. package/android/kls_database.db +0 -0
  29. package/android/local.properties +8 -0
  30. package/android/src/main/AndroidManifest.xml +2 -0
  31. package/android/src/main/java/ktsierra/expo/rotationmodule/ExpoRotationModule.kt +131 -0
  32. package/app.plugin.js +3 -0
  33. package/build/ExpoRotationModule.d.ts +15 -0
  34. package/build/ExpoRotationModule.d.ts.map +1 -0
  35. package/build/ExpoRotationModule.js +76 -0
  36. package/build/ExpoRotationModule.js.map +1 -0
  37. package/build/ExpoRotationModule.types.d.ts +18 -0
  38. package/build/ExpoRotationModule.types.d.ts.map +1 -0
  39. package/build/ExpoRotationModule.types.js +2 -0
  40. package/build/ExpoRotationModule.types.js.map +1 -0
  41. package/build/ExpoRotationModule.web.d.ts +12 -0
  42. package/build/ExpoRotationModule.web.d.ts.map +1 -0
  43. package/build/ExpoRotationModule.web.js +17 -0
  44. package/build/ExpoRotationModule.web.js.map +1 -0
  45. package/build/index.d.ts +3 -0
  46. package/build/index.d.ts.map +1 -0
  47. package/build/index.js +3 -0
  48. package/build/index.js.map +1 -0
  49. package/expo-module.config.json +9 -0
  50. package/index.js +2 -0
  51. package/ios/ExpoRotationModule.podspec +29 -0
  52. package/ios/ExpoRotationModule.swift +48 -0
  53. package/package.json +48 -0
  54. package/plugin/index.js +33 -0
  55. package/src/ExpoRotationModule.ts +86 -0
  56. package/src/ExpoRotationModule.types.ts +19 -0
  57. package/src/ExpoRotationModule.web.ts +21 -0
  58. package/src/index.d.ts +17 -0
  59. package/src/index.ts +2 -0
  60. package/tsconfig.json +9 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['universe/native', 'universe/web'],
4
+ ignorePatterns: ['build'],
5
+ };
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # expo-rotation-module
2
+
3
+ An Expo native module that controls the Android system rotation settings (ACCELEROMETER_ROTATION and USER_ROTATION).
4
+
5
+ ## Overview
6
+ This package exposes a small API to check and request the WRITE_SETTINGS permission and to read/set the global rotation mode. This module is Android-only; iOS and web are no-ops.
7
+
8
+ ## Install (local development with pnpm)
9
+
10
+ From the module repo:
11
+
12
+ - `pnpm install`
13
+ - (optional) `pnpm build` — runs the expo-module build scripts
14
+
15
+ From your Expo app project:
16
+
17
+ - Add the module locally: `pnpm add ../expo-rotation-module` (or `pnpm add file:../expo-rotation-module`)
18
+ - IMPORTANT: Add the plugin to your app config so the permission is injected during prebuild:
19
+
20
+ In `app.json` or `app.config.js` add the following to your `expo.plugins` array:
21
+
22
+ ```json
23
+ "plugins": [
24
+ "expo-rotation-module"
25
+ ]
26
+ ```
27
+
28
+ - Run `npx expo prebuild` to apply the config plugin and update `AndroidManifest.xml`.
29
+ - Rebuild the Android app (use EAS dev client or Android Studio):
30
+ - Recommended: `pnpm add expo-dev-client` then `eas build --profile development --platform android` and run with `expo start --dev-client`.
31
+
32
+ ## API
33
+
34
+ Import functions:
35
+
36
+ ```ts
37
+ import Rotation, { canWrite, requestWritePermission, getRotationState, setRotationState } from 'expo-rotation-module';
38
+ ```
39
+
40
+ - `canWrite(): Promise<boolean>` — true if WRITE_SETTINGS is granted (Android M+), otherwise true on older OS.
41
+ - `requestWritePermission(): void` — opens Settings where the user can grant WRITE_SETTINGS.
42
+ - `getRotationState(): Promise<'AUTOROTATE'|'PORTRAIT'|'LANDSCAPE'>` — reads current rotation state.
43
+ - `setRotationState(state): Promise<void>` — sets rotation. Rejects with an Error object that may include a `.code` property.
44
+
45
+ Error codes on the Error object (if available): `E_PERMISSION`, `E_INVALID_STATE`, `E_SET_ROTATION`, `E_GET_ROTATION`, `E_NO_MODULE`.
46
+
47
+ ## Example
48
+
49
+ ```ts
50
+ import * as Rotation from 'expo-rotation-module';
51
+
52
+ async function example() {
53
+ if (!(await Rotation.canWrite())) {
54
+ Rotation.requestWritePermission();
55
+ return;
56
+ }
57
+
58
+ try {
59
+ await Rotation.setRotationState('PORTRAIT');
60
+ } catch (e: any) {
61
+ if (e.code === 'E_PERMISSION') {
62
+ console.warn('Permission missing');
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ ## Plugin
69
+ The package contains `plugin/index.js` that injects `android.permission.WRITE_SETTINGS` into the host app's AndroidManifest during `expo prebuild`.
70
+
71
+ ## Package id and Android settings
72
+ The Android package/namespace used within module sources is `ktsierra.expo.rotationmodule`.
73
+
74
+ ## Contributing & tests
75
+ If you want CI or tests added (TS checks, build smoke tests), I can add a GitHub Actions workflow that runs `pnpm install` and `pnpm build`.
76
+
77
+ ---
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ #Tue Jan 06 14:23:37 EST 2026
2
+ gradle.version=9.2.0
@@ -0,0 +1,2 @@
1
+ #Tue Jan 06 13:19:56 EST 2026
2
+ java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home
File without changes
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AndroidProjectSystem">
4
+ <option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
5
+ </component>
6
+ </project>