react-native-orientation-director 2.6.4 → 3.0.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 (178) hide show
  1. package/README.md +11 -33
  2. package/android/build.gradle +19 -79
  3. package/android/src/main/AndroidManifest.xml +1 -2
  4. package/android/src/{newarch → main/java/com/orientationdirector}/OrientationDirectorModule.kt +20 -11
  5. package/android/src/main/java/com/orientationdirector/OrientationDirectorPackage.kt +15 -20
  6. package/android/src/main/java/com/orientationdirector/implementation/EventManager.kt +4 -17
  7. package/android/src/main/java/com/orientationdirector/implementation/EventManagerDelegate.kt +9 -0
  8. package/android/src/main/java/com/orientationdirector/implementation/OrientationDirectorModuleImpl.kt +23 -24
  9. package/android/src/main/java/com/orientationdirector/implementation/OrientationSensorsEventListener.kt +73 -80
  10. package/android/src/main/java/com/orientationdirector/implementation/Utils.kt +0 -54
  11. package/app.plugin.js +1 -1
  12. package/ios/OrientationDirector.h +1 -18
  13. package/ios/OrientationDirector.mm +35 -35
  14. package/ios/SharedOrientationDirectorImpl.swift +12 -0
  15. package/ios/implementation/EventManager.swift +12 -37
  16. package/ios/implementation/OrientationDirectorImpl.swift +6 -6
  17. package/lib/module/EventEmitter.js +15 -9
  18. package/lib/module/EventEmitter.js.map +1 -1
  19. package/lib/module/NativeOrientationDirector.js.map +1 -1
  20. package/lib/module/module.js +1 -2
  21. package/lib/module/module.js.map +1 -1
  22. package/lib/plugin/index.d.ts +3 -0
  23. package/lib/plugin/index.js +10 -0
  24. package/lib/plugin/withAndroidConfiguration.d.ts +3 -0
  25. package/{plugin/build/withRNOrientationMainActivity.js → lib/plugin/withAndroidConfiguration.js} +3 -3
  26. package/lib/plugin/withIosConfiguration.d.ts +3 -0
  27. package/lib/plugin/withIosConfiguration.js +62 -0
  28. package/lib/typescript/{commonjs/src → src}/EventEmitter.d.ts +5 -4
  29. package/lib/typescript/src/EventEmitter.d.ts.map +1 -0
  30. package/lib/typescript/{commonjs/src → src}/NativeOrientationDirector.d.ts +10 -3
  31. package/lib/typescript/src/NativeOrientationDirector.d.ts.map +1 -0
  32. package/lib/typescript/{module/src → src}/RNOrientationDirector.d.ts +3 -3
  33. package/lib/typescript/src/RNOrientationDirector.d.ts.map +1 -0
  34. package/lib/typescript/src/hooks/useDeviceOrientation.hook.d.ts.map +1 -0
  35. package/lib/typescript/src/hooks/useInterfaceOrientation.hook.d.ts.map +1 -0
  36. package/lib/typescript/src/hooks/useIsInterfaceOrientationLocked.hook.d.ts.map +1 -0
  37. package/lib/typescript/src/index.d.ts.map +1 -0
  38. package/lib/typescript/src/module.d.ts +4 -0
  39. package/lib/typescript/src/module.d.ts.map +1 -0
  40. package/lib/typescript/src/types/AutoRotation.enum.d.ts.map +1 -0
  41. package/lib/typescript/src/types/Event.enum.d.ts.map +1 -0
  42. package/lib/typescript/src/types/HumanReadableAutoRotationsResource.type.d.ts.map +1 -0
  43. package/lib/typescript/src/types/HumanReadableOrientationsResource.type.d.ts.map +1 -0
  44. package/lib/typescript/src/types/LockableOrientation.type.d.ts.map +1 -0
  45. package/lib/typescript/src/types/LockedEvent.interface.d.ts.map +1 -0
  46. package/lib/typescript/src/types/Orientation.enum.d.ts.map +1 -0
  47. package/lib/typescript/src/types/OrientationEvent.interface.d.ts.map +1 -0
  48. package/lib/typescript/src/types/OrientationType.enum.d.ts.map +1 -0
  49. package/package.json +72 -77
  50. package/react-native-orientation-director.podspec +4 -24
  51. package/src/EventEmitter.ts +21 -24
  52. package/src/NativeOrientationDirector.ts +8 -3
  53. package/src/module.ts +1 -3
  54. package/android/gradle.properties +0 -17
  55. package/android/src/main/AndroidManifestNew.xml +0 -2
  56. package/android/src/oldarch/OrientationDirectorModule.kt +0 -66
  57. package/android/src/test/java/com/orientationdirector/implementation/OrientationDirectorModuleImplTest.kt +0 -199
  58. package/android/src/test/java/com/orientationdirector/implementation/UtilsTest.kt +0 -314
  59. package/ios/react-native-orientation-director-Bridging-Header.h +0 -6
  60. package/lib/commonjs/EventEmitter.js +0 -48
  61. package/lib/commonjs/NativeOrientationDirector.js +0 -8
  62. package/lib/commonjs/RNOrientationDirector.js +0 -126
  63. package/lib/commonjs/hooks/useDeviceOrientation.hook.js +0 -37
  64. package/lib/commonjs/hooks/useInterfaceOrientation.hook.js +0 -37
  65. package/lib/commonjs/hooks/useIsInterfaceOrientationLocked.hook.js +0 -27
  66. package/lib/commonjs/index.js +0 -51
  67. package/lib/commonjs/module.js +0 -22
  68. package/lib/commonjs/package.json +0 -1
  69. package/lib/commonjs/types/AutoRotation.enum.js +0 -12
  70. package/lib/commonjs/types/Event.enum.js +0 -13
  71. package/lib/commonjs/types/HumanReadableAutoRotationsResource.type.js +0 -5
  72. package/lib/commonjs/types/HumanReadableOrientationsResource.type.js +0 -5
  73. package/lib/commonjs/types/LockableOrientation.type.js +0 -5
  74. package/lib/commonjs/types/LockedEvent.interface.js +0 -1
  75. package/lib/commonjs/types/Orientation.enum.js +0 -17
  76. package/lib/commonjs/types/OrientationEvent.interface.js +0 -5
  77. package/lib/commonjs/types/OrientationType.enum.js +0 -11
  78. package/lib/typescript/commonjs/example/src/App.d.ts +0 -2
  79. package/lib/typescript/commonjs/example/src/App.d.ts.map +0 -1
  80. package/lib/typescript/commonjs/example/src/AppNavigationContainer.d.ts +0 -3
  81. package/lib/typescript/commonjs/example/src/AppNavigationContainer.d.ts.map +0 -1
  82. package/lib/typescript/commonjs/example/src/screens/Explore.d.ts +0 -3
  83. package/lib/typescript/commonjs/example/src/screens/Explore.d.ts.map +0 -1
  84. package/lib/typescript/commonjs/example/src/screens/Home.d.ts +0 -3
  85. package/lib/typescript/commonjs/example/src/screens/Home.d.ts.map +0 -1
  86. package/lib/typescript/commonjs/example/src/screens/InnerExplore.d.ts +0 -3
  87. package/lib/typescript/commonjs/example/src/screens/InnerExplore.d.ts.map +0 -1
  88. package/lib/typescript/commonjs/example/src/screens/styles.d.ts +0 -51
  89. package/lib/typescript/commonjs/example/src/screens/styles.d.ts.map +0 -1
  90. package/lib/typescript/commonjs/package.json +0 -1
  91. package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +0 -1
  92. package/lib/typescript/commonjs/src/NativeOrientationDirector.d.ts.map +0 -1
  93. package/lib/typescript/commonjs/src/RNOrientationDirector.d.ts +0 -62
  94. package/lib/typescript/commonjs/src/RNOrientationDirector.d.ts.map +0 -1
  95. package/lib/typescript/commonjs/src/hooks/useDeviceOrientation.hook.d.ts.map +0 -1
  96. package/lib/typescript/commonjs/src/hooks/useInterfaceOrientation.hook.d.ts.map +0 -1
  97. package/lib/typescript/commonjs/src/hooks/useIsInterfaceOrientationLocked.hook.d.ts.map +0 -1
  98. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  99. package/lib/typescript/commonjs/src/module.d.ts +0 -6
  100. package/lib/typescript/commonjs/src/module.d.ts.map +0 -1
  101. package/lib/typescript/commonjs/src/types/AutoRotation.enum.d.ts.map +0 -1
  102. package/lib/typescript/commonjs/src/types/Event.enum.d.ts.map +0 -1
  103. package/lib/typescript/commonjs/src/types/HumanReadableAutoRotationsResource.type.d.ts.map +0 -1
  104. package/lib/typescript/commonjs/src/types/HumanReadableOrientationsResource.type.d.ts.map +0 -1
  105. package/lib/typescript/commonjs/src/types/LockableOrientation.type.d.ts.map +0 -1
  106. package/lib/typescript/commonjs/src/types/LockedEvent.interface.d.ts.map +0 -1
  107. package/lib/typescript/commonjs/src/types/Orientation.enum.d.ts.map +0 -1
  108. package/lib/typescript/commonjs/src/types/OrientationEvent.interface.d.ts.map +0 -1
  109. package/lib/typescript/commonjs/src/types/OrientationType.enum.d.ts.map +0 -1
  110. package/lib/typescript/module/example/src/App.d.ts +0 -2
  111. package/lib/typescript/module/example/src/App.d.ts.map +0 -1
  112. package/lib/typescript/module/example/src/AppNavigationContainer.d.ts +0 -3
  113. package/lib/typescript/module/example/src/AppNavigationContainer.d.ts.map +0 -1
  114. package/lib/typescript/module/example/src/screens/Explore.d.ts +0 -3
  115. package/lib/typescript/module/example/src/screens/Explore.d.ts.map +0 -1
  116. package/lib/typescript/module/example/src/screens/Home.d.ts +0 -3
  117. package/lib/typescript/module/example/src/screens/Home.d.ts.map +0 -1
  118. package/lib/typescript/module/example/src/screens/InnerExplore.d.ts +0 -3
  119. package/lib/typescript/module/example/src/screens/InnerExplore.d.ts.map +0 -1
  120. package/lib/typescript/module/example/src/screens/styles.d.ts +0 -51
  121. package/lib/typescript/module/example/src/screens/styles.d.ts.map +0 -1
  122. package/lib/typescript/module/src/EventEmitter.d.ts +0 -11
  123. package/lib/typescript/module/src/EventEmitter.d.ts.map +0 -1
  124. package/lib/typescript/module/src/NativeOrientationDirector.d.ts +0 -17
  125. package/lib/typescript/module/src/NativeOrientationDirector.d.ts.map +0 -1
  126. package/lib/typescript/module/src/RNOrientationDirector.d.ts.map +0 -1
  127. package/lib/typescript/module/src/hooks/useDeviceOrientation.hook.d.ts +0 -8
  128. package/lib/typescript/module/src/hooks/useDeviceOrientation.hook.d.ts.map +0 -1
  129. package/lib/typescript/module/src/hooks/useInterfaceOrientation.hook.d.ts +0 -8
  130. package/lib/typescript/module/src/hooks/useInterfaceOrientation.hook.d.ts.map +0 -1
  131. package/lib/typescript/module/src/hooks/useIsInterfaceOrientationLocked.hook.d.ts +0 -7
  132. package/lib/typescript/module/src/hooks/useIsInterfaceOrientationLocked.hook.d.ts.map +0 -1
  133. package/lib/typescript/module/src/index.d.ts +0 -12
  134. package/lib/typescript/module/src/index.d.ts.map +0 -1
  135. package/lib/typescript/module/src/module.d.ts +0 -6
  136. package/lib/typescript/module/src/module.d.ts.map +0 -1
  137. package/lib/typescript/module/src/types/AutoRotation.enum.d.ts +0 -6
  138. package/lib/typescript/module/src/types/AutoRotation.enum.d.ts.map +0 -1
  139. package/lib/typescript/module/src/types/Event.enum.d.ts +0 -7
  140. package/lib/typescript/module/src/types/Event.enum.d.ts.map +0 -1
  141. package/lib/typescript/module/src/types/HumanReadableAutoRotationsResource.type.d.ts +0 -3
  142. package/lib/typescript/module/src/types/HumanReadableAutoRotationsResource.type.d.ts.map +0 -1
  143. package/lib/typescript/module/src/types/HumanReadableOrientationsResource.type.d.ts +0 -3
  144. package/lib/typescript/module/src/types/HumanReadableOrientationsResource.type.d.ts.map +0 -1
  145. package/lib/typescript/module/src/types/LockableOrientation.type.d.ts +0 -3
  146. package/lib/typescript/module/src/types/LockableOrientation.type.d.ts.map +0 -1
  147. package/lib/typescript/module/src/types/LockedEvent.interface.d.ts +0 -4
  148. package/lib/typescript/module/src/types/LockedEvent.interface.d.ts.map +0 -1
  149. package/lib/typescript/module/src/types/Orientation.enum.d.ts +0 -11
  150. package/lib/typescript/module/src/types/Orientation.enum.d.ts.map +0 -1
  151. package/lib/typescript/module/src/types/OrientationEvent.interface.d.ts +0 -5
  152. package/lib/typescript/module/src/types/OrientationEvent.interface.d.ts.map +0 -1
  153. package/lib/typescript/module/src/types/OrientationType.enum.d.ts +0 -5
  154. package/lib/typescript/module/src/types/OrientationType.enum.d.ts.map +0 -1
  155. package/plugin/build/custom-mod/withBridgingHeader.d.ts +0 -12
  156. package/plugin/build/custom-mod/withBridgingHeader.js +0 -107
  157. package/plugin/build/index.d.ts +0 -3
  158. package/plugin/build/index.js +0 -27
  159. package/plugin/build/withRNOrientationAppDelegate.d.ts +0 -4
  160. package/plugin/build/withRNOrientationAppDelegate.js +0 -102
  161. package/plugin/build/withRNOrientationBridgingHeader.d.ts +0 -3
  162. package/plugin/build/withRNOrientationBridgingHeader.js +0 -27
  163. package/plugin/build/withRNOrientationMainActivity.d.ts +0 -3
  164. package/plugin/tsconfig.json +0 -9
  165. /package/lib/typescript/{module/package.json → package.json} +0 -0
  166. /package/lib/typescript/{commonjs/src → src}/hooks/useDeviceOrientation.hook.d.ts +0 -0
  167. /package/lib/typescript/{commonjs/src → src}/hooks/useInterfaceOrientation.hook.d.ts +0 -0
  168. /package/lib/typescript/{commonjs/src → src}/hooks/useIsInterfaceOrientationLocked.hook.d.ts +0 -0
  169. /package/lib/typescript/{commonjs/src → src}/index.d.ts +0 -0
  170. /package/lib/typescript/{commonjs/src → src}/types/AutoRotation.enum.d.ts +0 -0
  171. /package/lib/typescript/{commonjs/src → src}/types/Event.enum.d.ts +0 -0
  172. /package/lib/typescript/{commonjs/src → src}/types/HumanReadableAutoRotationsResource.type.d.ts +0 -0
  173. /package/lib/typescript/{commonjs/src → src}/types/HumanReadableOrientationsResource.type.d.ts +0 -0
  174. /package/lib/typescript/{commonjs/src → src}/types/LockableOrientation.type.d.ts +0 -0
  175. /package/lib/typescript/{commonjs/src → src}/types/LockedEvent.interface.d.ts +0 -0
  176. /package/lib/typescript/{commonjs/src → src}/types/Orientation.enum.d.ts +0 -0
  177. /package/lib/typescript/{commonjs/src → src}/types/OrientationEvent.interface.d.ts +0 -0
  178. /package/lib/typescript/{commonjs/src → src}/types/OrientationType.enum.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
3
+ import { NativeModules, Platform } from 'react-native';
4
4
  const LINKING_ERROR = `The package 'react-native-orientation-director' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
5
5
  ios: "- You have run 'pod install'\n",
6
6
  default: ''
@@ -14,6 +14,5 @@ const OrientationDirectorModule = Module ? Module : new Proxy({}, {
14
14
  throw new Error(LINKING_ERROR);
15
15
  }
16
16
  });
17
- export const ModuleEventEmitter = new NativeEventEmitter(Module);
18
17
  export default OrientationDirectorModule;
19
18
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","LINKING_ERROR","select","ios","default","isTurboModuleEnabled","global","__turboModuleProxy","Module","require","OrientationDirector","OrientationDirectorModule","Proxy","get","Error","ModuleEventEmitter"],"sourceRoot":"../../src","sources":["module.ts"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAG1E,MAAMC,aAAa,GACjB,4FAA4F,GAC5FD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,kBAAkB,IAAI,IAAI;AAE9D,MAAMC,MAAM,GAAGH,oBAAoB,GAC/BI,OAAO,CAAC,6BAA6B,CAAC,CAACL,OAAO,GAC9CL,aAAa,CAACW,mBAAmB;AAErC,MAAMC,yBAAyB,GAAGH,MAAM,GACpCA,MAAM,GACN,IAAII,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACb,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMc,kBAAkB,GAAG,IAAIjB,kBAAkB,CAACU,MAAM,CAAC;AAEhE,eAAeG,yBAAyB","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","isTurboModuleEnabled","global","__turboModuleProxy","Module","require","OrientationDirector","OrientationDirectorModule","Proxy","get","Error"],"sourceRoot":"../../src","sources":["module.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAGtD,MAAMC,aAAa,GACjB,4FAA4F,GAC5FD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,kBAAkB,IAAI,IAAI;AAE9D,MAAMC,MAAM,GAAGH,oBAAoB,GAC/BI,OAAO,CAAC,6BAA6B,CAAC,CAACL,OAAO,GAC9CL,aAAa,CAACW,mBAAmB;AAErC,MAAMC,yBAAyB,GAAGH,MAAM,GACpCA,MAAM,GACN,IAAII,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACb,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,eAAeU,yBAAyB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import { type ConfigPlugin } from 'expo/config-plugins';
2
+ declare const withYourLibrary: ConfigPlugin;
3
+ export default withYourLibrary;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const withAndroidConfiguration_1 = require("./withAndroidConfiguration");
4
+ const withIosConfiguration_1 = require("./withIosConfiguration");
5
+ const withYourLibrary = (config) => {
6
+ config = (0, withAndroidConfiguration_1.withAndroidConfiguration)(config);
7
+ config = (0, withIosConfiguration_1.withIosConfiguration)(config);
8
+ return config;
9
+ };
10
+ exports.default = withYourLibrary;
@@ -0,0 +1,3 @@
1
+ import { type ConfigPlugin } from 'expo/config-plugins';
2
+ export declare const withAndroidConfiguration: ConfigPlugin;
3
+ export declare function ktFileUpdater(originalContents: string): string;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withRNOrientationMainActivity = void 0;
3
+ exports.withAndroidConfiguration = void 0;
4
4
  exports.ktFileUpdater = ktFileUpdater;
5
5
  const config_plugins_1 = require("@expo/config-plugins");
6
6
  const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
7
- const withRNOrientationMainActivity = (config) => {
7
+ const withAndroidConfiguration = (config) => {
8
8
  return (0, config_plugins_1.withMainActivity)(config, readMainActivityFileAndUpdateContents);
9
9
  };
10
- exports.withRNOrientationMainActivity = withRNOrientationMainActivity;
10
+ exports.withAndroidConfiguration = withAndroidConfiguration;
11
11
  async function readMainActivityFileAndUpdateContents(config) {
12
12
  const { modResults: mainActivityFile } = config;
13
13
  const worker = getCompatibleFileUpdater(mainActivityFile.language);
@@ -0,0 +1,3 @@
1
+ import { type ConfigPlugin } from 'expo/config-plugins';
2
+ export declare const withIosConfiguration: ConfigPlugin;
3
+ export declare function swiftFileUpdater(originalContents: string, sdkVersion?: string): string;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withIosConfiguration = void 0;
4
+ exports.swiftFileUpdater = swiftFileUpdater;
5
+ const config_plugins_1 = require("@expo/config-plugins");
6
+ const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
7
+ const withIosConfiguration = (config) => {
8
+ return (0, config_plugins_1.withAppDelegate)(config, readAppDelegateFileAndUpdateContents);
9
+ };
10
+ exports.withIosConfiguration = withIosConfiguration;
11
+ async function readAppDelegateFileAndUpdateContents(config) {
12
+ const { modResults: appDelegateFile } = config;
13
+ if (appDelegateFile.language !== 'swift') {
14
+ throw new Error(`Cannot add React Native Orientation Director code to AppDelegate of language "${appDelegateFile.language}"`);
15
+ }
16
+ appDelegateFile.contents = swiftFileUpdater(appDelegateFile.contents, config.sdkVersion);
17
+ return config;
18
+ }
19
+ function swiftFileUpdater(originalContents, sdkVersion) {
20
+ const methodPrefix = computeMethodPrefix(sdkVersion);
21
+ const libraryImportCodeBlock = `import OrientationDirector`;
22
+ const rightBeforeAnnotation = /@main|@UIApplicationMain/g;
23
+ const withImport = (0, generateCode_1.mergeContents)({
24
+ tag: '@react-native-orientation-director/library-import',
25
+ src: originalContents,
26
+ newSrc: libraryImportCodeBlock,
27
+ anchor: rightBeforeAnnotation,
28
+ offset: -1,
29
+ comment: '// React Native Orientation Director',
30
+ });
31
+ const supportedInterfaceOrientationsCodeBlock = `\n ${methodPrefix} func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
32
+ return SharedOrientationDirectorImpl.shared.supportedInterfaceOrientations
33
+ }\n`;
34
+ const rightBeforeLastClosingBrace = /didFinishLaunchingWithOptions:\s*launchOptions\)/g;
35
+ const pasteInTheListJustAfterTheClosingBracket = 2;
36
+ const completedMerge = (0, generateCode_1.mergeContents)({
37
+ tag: '@react-native-orientation-director/supportedInterfaceOrientations-implementation',
38
+ src: withImport.contents,
39
+ newSrc: supportedInterfaceOrientationsCodeBlock,
40
+ anchor: rightBeforeLastClosingBrace,
41
+ offset: pasteInTheListJustAfterTheClosingBracket,
42
+ comment: '// React Native Orientation Director',
43
+ });
44
+ return completedMerge.contents;
45
+ function computeMethodPrefix(_sdkVersion) {
46
+ if (!_sdkVersion) {
47
+ return '';
48
+ }
49
+ const rawMajor = _sdkVersion.split('.').at(0);
50
+ if (!rawMajor) {
51
+ return '';
52
+ }
53
+ const major = Number(rawMajor);
54
+ if (Number.isNaN(major)) {
55
+ return '';
56
+ }
57
+ if (major === 53) {
58
+ return '';
59
+ }
60
+ return 'public override';
61
+ }
62
+ }
@@ -1,10 +1,11 @@
1
- import { type EmitterSubscription } from 'react-native';
1
+ import { type EventSubscription } from 'react-native';
2
2
  import type { OrientationEvent } from './types/OrientationEvent.interface';
3
3
  import type { LockedEvent } from './types/LockedEvent.interface';
4
4
  declare class EventEmitter {
5
- static addDeviceOrientationDidChangeListener(callback: (orientation: OrientationEvent) => void): EmitterSubscription;
6
- static addInterfaceOrientationDidChangeListener(callback: (orientation: OrientationEvent) => void): EmitterSubscription;
7
- static addLockDidChangeListener(callback: (event: LockedEvent) => void): EmitterSubscription;
5
+ private static androidListenerCount;
6
+ static addDeviceOrientationDidChangeListener(callback: (orientation: OrientationEvent) => void): EventSubscription;
7
+ static addInterfaceOrientationDidChangeListener(callback: (orientation: OrientationEvent) => void): EventSubscription;
8
+ static addLockDidChangeListener(callback: (event: LockedEvent) => void): EventSubscription;
8
9
  private static createDeviceOrientationListenerProxy;
9
10
  }
10
11
  export default EventEmitter;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../../src/EventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,cAAM,YAAY;IAChB,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAK;IAExC,MAAM,CAAC,qCAAqC,CAC1C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAgBnD,MAAM,CAAC,wCAAwC,CAC7C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAKnD,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI;IAItE,OAAO,CAAC,MAAM,CAAC,oCAAoC;CA6BpD;AAED,eAAe,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { TurboModule } from 'react-native';
1
+ import { type CodegenTypes, type TurboModule } from 'react-native';
2
2
  export interface Spec extends TurboModule {
3
3
  getInterfaceOrientation(): Promise<number>;
4
4
  getDeviceOrientation(): Promise<number>;
@@ -9,8 +9,15 @@ export interface Spec extends TurboModule {
9
9
  isAutoRotationEnabled(): boolean;
10
10
  enableOrientationSensors(): void;
11
11
  disableOrientationSensors(): void;
12
- addListener: (eventType: string) => void;
13
- removeListeners: (count: number) => void;
12
+ readonly onDeviceOrientationChanged: CodegenTypes.EventEmitter<{
13
+ orientation: number;
14
+ }>;
15
+ readonly onInterfaceOrientationChanged: CodegenTypes.EventEmitter<{
16
+ orientation: number;
17
+ }>;
18
+ readonly onLockChanged: CodegenTypes.EventEmitter<{
19
+ locked: boolean;
20
+ }>;
14
21
  }
15
22
  declare const _default: Spec;
16
23
  export default _default;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/NativeOrientationDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGnE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,IAAI,IAAI,CAAC;IACf,QAAQ,IAAI,OAAO,CAAC;IACpB,mCAAmC,IAAI,IAAI,CAAC;IAO5C,qBAAqB,IAAI,OAAO,CAAC;IACjC,wBAAwB,IAAI,IAAI,CAAC;IACjC,yBAAyB,IAAI,IAAI,CAAC;IAKlC,QAAQ,CAAC,0BAA0B,EAAE,YAAY,CAAC,YAAY,CAAC;QAC7D,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,QAAQ,CAAC,6BAA6B,EAAE,YAAY,CAAC,YAAY,CAAC;QAChE,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,QAAQ,CAAC,aAAa,EAAE,YAAY,CAAC,YAAY,CAAC;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACxE;;AAED,wBAA6E"}
@@ -36,9 +36,9 @@ declare class RNOrientationDirector {
36
36
  static isLocked(): boolean;
37
37
  static isAutoRotationEnabled(): AutoRotation;
38
38
  static resetSupportedInterfaceOrientations(): void;
39
- static listenForDeviceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EmitterSubscription;
40
- static listenForInterfaceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EmitterSubscription;
41
- static listenForLockChanges(callback: (event: LockedEvent) => void): import("react-native").EmitterSubscription;
39
+ static listenForDeviceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EventSubscription;
40
+ static listenForInterfaceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EventSubscription;
41
+ static listenForLockChanges(callback: (event: LockedEvent) => void): import("react-native").EventSubscription;
42
42
  static convertOrientationToHumanReadableString(orientation: Orientation): string;
43
43
  static convertAutoRotationToHumanReadableString(autoRotation: AutoRotation): string;
44
44
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RNOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/RNOrientationDirector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gDAAgD,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AAG1G,cAAM,qBAAqB;IACzB,OAAO,CAAC,MAAM,CAAC,kCAAkC,CAU7C;IAEJ,OAAO,CAAC,MAAM,CAAC,mCAAmC,CAK9C;IAEJ,4BAA4B,CAAC,QAAQ,EAAE,iCAAiC;IAIxE,6BAA6B,CAAC,QAAQ,EAAE,kCAAkC;IAI1E,MAAM,CAAC,uBAAuB,IAAI,OAAO,CAAC,WAAW,CAAC;IAItD,MAAM,CAAC,oBAAoB,IAAI,OAAO,CAAC,WAAW,CAAC;IAInD;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,MAAM,CACX,WAAW,EAAE,mBAAmB,EAChC,eAAe,GAAE,eAA2C;IAoB9D,MAAM,CAAC,MAAM;IAIb,MAAM,CAAC,QAAQ;IAIf,MAAM,CAAC,qBAAqB;IAS5B,MAAM,CAAC,mCAAmC;IAI1C,MAAM,CAAC,iCAAiC,CACtC,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAKnD,MAAM,CAAC,oCAAoC,CACzC,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAKnD,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI;IAIlE,MAAM,CAAC,uCAAuC,CAAC,WAAW,EAAE,WAAW;IAMvE,MAAM,CAAC,wCAAwC,CAAC,YAAY,EAAE,YAAY;IAM1E;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,qBAAqB,CAC1B,WAAW,EAAE,WAAW,GACvB,WAAW,IAAI,mBAAmB;CAOtC;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDeviceOrientation.hook.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDeviceOrientation.hook.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD;;;GAGG;AACH,QAAA,MAAM,oBAAoB,mBA4BzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInterfaceOrientation.hook.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useInterfaceOrientation.hook.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD;;;GAGG;AACH,QAAA,MAAM,uBAAuB,mBA4B5B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsInterfaceOrientationLocked.hook.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useIsInterfaceOrientationLocked.hook.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,QAAA,MAAM,+BAA+B,eAiBpC,CAAC;AAEF,eAAe,+BAA+B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,OAAO,uBAAuB,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,+BAA+B,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,+BAA+B,EAAE,CAAC;AAE3C,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Spec } from './NativeOrientationDirector';
2
+ declare const _default: Spec;
3
+ export default _default;
4
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;wBA0BZ,IAAI;AAAhD,wBAAiD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoRotation.enum.d.ts","sourceRoot":"","sources":["../../../../src/types/AutoRotation.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,OAAO,IAAI;IACX,OAAO,IAAI;IACX,QAAQ,IAAI;CACb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Event.enum.d.ts","sourceRoot":"","sources":["../../../../src/types/Event.enum.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK;IACR,0BAA0B,+BAA+B;IACzD,6BAA6B,kCAAkC;IAC/D,aAAa,kBAAkB;CAChC;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HumanReadableAutoRotationsResource.type.d.ts","sourceRoot":"","sources":["../../../../src/types/HumanReadableAutoRotationsResource.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,MAAM,kCAAkC,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HumanReadableOrientationsResource.type.d.ts","sourceRoot":"","sources":["../../../../src/types/HumanReadableOrientationsResource.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,iCAAiC,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LockableOrientation.type.d.ts","sourceRoot":"","sources":["../../../../src/types/LockableOrientation.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,mBAAmB,GAC3B,WAAW,CAAC,QAAQ,GACpB,WAAW,CAAC,kBAAkB,GAC9B,WAAW,CAAC,aAAa,GACzB,WAAW,CAAC,cAAc,GAC1B,WAAW,CAAC,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LockedEvent.interface.d.ts","sourceRoot":"","sources":["../../../../src/types/LockedEvent.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;CACjB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Orientation.enum.d.ts","sourceRoot":"","sources":["../../../../src/types/Orientation.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,cAAc,IAAI;IAClB,kBAAkB,IAAI;IACtB,aAAa,IAAI;IACjB,SAAS,IAAI;IACb,MAAM,IAAI;IACV,QAAQ,IAAI;CACb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrientationEvent.interface.d.ts","sourceRoot":"","sources":["../../../../src/types/OrientationEvent.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,WAAW,CAAC;CAC1B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrientationType.enum.d.ts","sourceRoot":"","sources":["../../../../src/types/OrientationType.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,MAAM,WAAW;IACjB,SAAS,cAAc;CACxB"}
package/package.json CHANGED
@@ -1,22 +1,17 @@
1
1
  {
2
2
  "name": "react-native-orientation-director",
3
- "version": "2.6.4",
3
+ "version": "3.0.0",
4
4
  "description": "A Modern React Native library that allows you to access orientation",
5
5
  "main": "./lib/module/index.js",
6
- "types": "./lib/typescript/module/src/index.d.ts",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "import": {
10
- "types": "./lib/typescript/module/src/index.d.ts",
11
- "default": "./lib/module/index.js"
12
- },
13
- "require": {
14
- "types": "./lib/typescript/commonjs/src/index.d.ts",
15
- "default": "./lib/commonjs/index.js"
16
- }
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
17
12
  },
18
- "./package.json": "./package.json",
19
- "./app.plugin.js": "./app.plugin.js"
13
+ "./app.plugin.js": "./app.plugin.js",
14
+ "./package.json": "./package.json"
20
15
  },
21
16
  "files": [
22
17
  "src",
@@ -24,8 +19,6 @@
24
19
  "android",
25
20
  "ios",
26
21
  "cpp",
27
- "plugin/build",
28
- "plugin/tsconfig.json",
29
22
  "app.plugin.js",
30
23
  "*.podspec",
31
24
  "react-native.config.js",
@@ -47,7 +40,7 @@
47
40
  "typecheck": "tsc",
48
41
  "lint": "eslint \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\"",
49
42
  "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
50
- "prepare": "bob build",
43
+ "prepare": "yarn expo-plugin prepare && bob build",
51
44
  "release": "release-it"
52
45
  },
53
46
  "keywords": [
@@ -59,7 +52,7 @@
59
52
  "type": "git",
60
53
  "url": "git+https://github.com/gladiuscode/react-native-orientation-director.git"
61
54
  },
62
- "author": "gladius <gladiusservices@protonmail.com> (https://github.com/gladiuscode)",
55
+ "author": "gladiuscode <gladiusservices@protonmail.com> (https://github.com/gladiuscode)",
63
56
  "license": "MIT",
64
57
  "bugs": {
65
58
  "url": "https://github.com/gladiuscode/react-native-orientation-director/issues"
@@ -69,32 +62,29 @@
69
62
  "registry": "https://registry.npmjs.org/"
70
63
  },
71
64
  "devDependencies": {
72
- "@commitlint/config-conventional": "^19.6.0",
73
- "@eslint/compat": "^1.2.7",
74
- "@eslint/eslintrc": "^3.3.0",
75
- "@eslint/js": "^9.22.0",
76
- "@evilmartians/lefthook": "^1.5.0",
77
- "@react-native-community/cli": "15.0.0-alpha.2",
78
- "@react-native/babel-preset": "0.80.0",
79
- "@react-native/eslint-config": "0.80.0",
80
- "@release-it/conventional-changelog": "^9.0.2",
81
- "@types/jest": "^29.5.5",
82
- "@types/react": "^19.1.0",
83
- "@typescript-eslint/eslint-plugin": "^7.18.0",
84
- "commitlint": "^19.6.1",
85
- "del-cli": "^5.1.0",
86
- "eslint": "^9.22.0",
87
- "eslint-config-prettier": "^10.1.1",
88
- "eslint-plugin-jest": "^27.9.0",
89
- "eslint-plugin-prettier": "^5.2.3",
65
+ "@commitlint/config-conventional": "^19.8.1",
66
+ "@eslint/compat": "^1.3.2",
67
+ "@eslint/eslintrc": "^3.3.1",
68
+ "@eslint/js": "^9.35.0",
69
+ "@react-native/babel-preset": "0.83.0",
70
+ "@react-native/eslint-config": "0.83.0",
71
+ "@release-it/conventional-changelog": "^10.0.1",
72
+ "@types/jest": "^29.5.14",
73
+ "@types/react": "^19.2.0",
74
+ "commitlint": "^19.8.1",
75
+ "del-cli": "^6.0.0",
76
+ "eslint": "^9.35.0",
77
+ "eslint-config-prettier": "^10.1.8",
78
+ "eslint-plugin-prettier": "^5.5.4",
90
79
  "jest": "^29.7.0",
80
+ "lefthook": "^2.0.3",
91
81
  "prettier": "^3.0.3",
92
- "react": "19.1.0",
93
- "react-native": "0.80.0",
94
- "react-native-builder-bob": "^0.40.10",
95
- "release-it": "^17.10.0",
96
- "turbo": "^1.10.7",
97
- "typescript": "^5.2.2"
82
+ "react": "19.2.0",
83
+ "react-native": "0.84.1",
84
+ "react-native-builder-bob": "^0.40.18",
85
+ "release-it": "^19.0.4",
86
+ "turbo": "^2.5.6",
87
+ "typescript": "^5.9.2"
98
88
  },
99
89
  "peerDependencies": {
100
90
  "expo": ">=47.0.0",
@@ -106,15 +96,42 @@
106
96
  "optional": true
107
97
  }
108
98
  },
109
- "resolutions": {
110
- "eslint-plugin-jest": "^27.9.0",
111
- "@typescript-eslint/eslint-plugin": "^7.18.0"
112
- },
113
99
  "workspaces": [
114
100
  "example",
115
101
  "plugin"
116
102
  ],
117
- "packageManager": "yarn@3.6.1",
103
+ "packageManager": "yarn@4.11.0",
104
+ "react-native-builder-bob": {
105
+ "source": "src",
106
+ "output": "lib",
107
+ "targets": [
108
+ [
109
+ "module",
110
+ {
111
+ "esm": true
112
+ }
113
+ ],
114
+ [
115
+ "typescript",
116
+ {
117
+ "project": "tsconfig.build.json"
118
+ }
119
+ ]
120
+ ]
121
+ },
122
+ "codegenConfig": {
123
+ "name": "RNOrientationDirectorSpec",
124
+ "type": "modules",
125
+ "jsSrcsDir": "src",
126
+ "android": {
127
+ "javaPackageName": "com.orientationdirector"
128
+ },
129
+ "ios": {
130
+ "modulesProvider": {
131
+ "OrientationDirector": "OrientationDirector"
132
+ }
133
+ }
134
+ },
118
135
  "jest": {
119
136
  "preset": "react-native",
120
137
  "modulePathIgnorePatterns": [
@@ -164,41 +181,19 @@
164
181
  "trailingComma": "es5",
165
182
  "useTabs": false
166
183
  },
167
- "react-native-builder-bob": {
168
- "source": "src",
169
- "output": "lib",
170
- "targets": [
171
- [
172
- "commonjs",
173
- {
174
- "esm": true,
175
- "sourceMaps": false
176
- }
177
- ],
178
- [
179
- "module",
180
- {
181
- "esm": true
182
- }
183
- ],
184
- "typescript"
185
- ]
186
- },
187
- "codegenConfig": {
188
- "name": "RNOrientationDirectorSpec",
189
- "type": "modules",
190
- "jsSrcsDir": "src",
191
- "android": {
192
- "javaPackageName": "com.orientationdirector"
193
- }
194
- },
195
184
  "create-react-native-library": {
196
- "languages": "kotlin-objc",
197
185
  "type": "turbo-module",
198
- "version": "0.50.2"
186
+ "languages": "kotlin-objc",
187
+ "tools": [
188
+ "jest",
189
+ "lefthook",
190
+ "release-it",
191
+ "eslint"
192
+ ],
193
+ "version": "0.57.2"
199
194
  },
200
195
  "volta": {
201
- "node": "22.17.0",
202
- "yarn": "3.6.1"
196
+ "node": "22.20.0",
197
+ "yarn": "4.11.0"
203
198
  }
204
199
  }
@@ -1,7 +1,6 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
4
 
6
5
  Pod::Spec.new do |s|
7
6
  s.name = "react-native-orientation-director"
@@ -14,29 +13,10 @@ Pod::Spec.new do |s|
14
13
  s.platforms = { :ios => min_ios_version_supported }
15
14
  s.source = { :git => "https://github.com/gladiuscode/react-native-orientation-director.git", :tag => "#{s.version}" }
16
15
 
17
- s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
18
- s.private_header_files = "ios/generated/**/*.h"
16
+ s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
17
+ s.private_header_files = "ios/**/*.h"
19
18
 
20
- # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21
- # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
22
- if respond_to?(:install_modules_dependencies, true)
23
- install_modules_dependencies(s)
24
- else
25
- s.dependency "React-Core"
19
+ s.module_name = "OrientationDirector"
26
20
 
27
- # Don't install the dependencies when we run `pod install` in the old architecture.
28
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
29
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
30
- s.pod_target_xcconfig = {
31
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
32
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
33
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
34
- }
35
- s.dependency "React-Codegen"
36
- s.dependency "RCT-Folly"
37
- s.dependency "RCTRequired"
38
- s.dependency "RCTTypeSafety"
39
- s.dependency "ReactCommon/turbomodule/core"
40
- end
41
- end
21
+ install_modules_dependencies(s)
42
22
  end
@@ -1,27 +1,22 @@
1
- import { Platform, type EmitterSubscription } from 'react-native';
2
- import Module, { ModuleEventEmitter } from './module';
3
- import Event from './types/Event.enum';
1
+ import { Platform, type EventSubscription } from 'react-native';
2
+ import Module from './module';
4
3
  import type { OrientationEvent } from './types/OrientationEvent.interface';
5
4
  import type { LockedEvent } from './types/LockedEvent.interface';
6
5
 
7
6
  class EventEmitter {
7
+ private static androidListenerCount = 0;
8
+
8
9
  static addDeviceOrientationDidChangeListener(
9
10
  callback: (orientation: OrientationEvent) => void
10
11
  ) {
11
- let listener = ModuleEventEmitter.addListener(
12
- Event.DeviceOrientationDidChange,
13
- callback
14
- );
12
+ let listener = Module.onDeviceOrientationChanged(callback);
15
13
 
16
14
  if (Platform.OS !== 'android') {
17
15
  return listener;
18
16
  }
19
17
 
20
- const listenerCount = ModuleEventEmitter.listenerCount(
21
- Event.DeviceOrientationDidChange
22
- );
23
-
24
- if (listenerCount === 1) {
18
+ EventEmitter.androidListenerCount++;
19
+ if (EventEmitter.androidListenerCount === 1) {
25
20
  Module.enableOrientationSensors();
26
21
  }
27
22
 
@@ -31,20 +26,17 @@ class EventEmitter {
31
26
  static addInterfaceOrientationDidChangeListener(
32
27
  callback: (orientation: OrientationEvent) => void
33
28
  ) {
34
- return ModuleEventEmitter.addListener(
35
- Event.InterfaceOrientationDidChange,
36
- callback
37
- );
29
+ return Module.onInterfaceOrientationChanged(callback);
38
30
  }
39
31
 
40
32
  static addLockDidChangeListener(callback: (event: LockedEvent) => void) {
41
- return ModuleEventEmitter.addListener(Event.LockDidChange, callback);
33
+ return Module.onLockChanged(callback);
42
34
  }
43
35
 
44
36
  private static createDeviceOrientationListenerProxy(
45
- listener: EmitterSubscription
37
+ listener: EventSubscription
46
38
  ) {
47
- const handler: ProxyHandler<EmitterSubscription> = {
39
+ const handler: ProxyHandler<EventSubscription> = {
48
40
  get(target, propertyKey, receiver) {
49
41
  if (propertyKey === 'remove') {
50
42
  disableOrientationSensorsIfLastListener();
@@ -56,13 +48,18 @@ class EventEmitter {
56
48
  return new Proxy(listener, handler);
57
49
 
58
50
  function disableOrientationSensorsIfLastListener() {
59
- const listenerCount = ModuleEventEmitter.listenerCount(
60
- Event.DeviceOrientationDidChange
61
- );
62
-
63
- if (listenerCount === 1) {
51
+ if (EventEmitter.androidListenerCount === 1) {
52
+ EventEmitter.androidListenerCount = 0;
64
53
  Module.disableOrientationSensors();
54
+ return;
65
55
  }
56
+
57
+ if (EventEmitter.androidListenerCount === 0) {
58
+ return;
59
+ }
60
+
61
+ EventEmitter.androidListenerCount--;
62
+ return;
66
63
  }
67
64
  }
68
65
  }
@@ -1,4 +1,4 @@
1
- import type { TurboModule } from 'react-native';
1
+ import { type CodegenTypes, type TurboModule } from 'react-native';
2
2
  import { TurboModuleRegistry } from 'react-native';
3
3
 
4
4
  export interface Spec extends TurboModule {
@@ -21,8 +21,13 @@ export interface Spec extends TurboModule {
21
21
  //
22
22
  ////////////////////////////////////
23
23
 
24
- addListener: (eventType: string) => void;
25
- removeListeners: (count: number) => void;
24
+ readonly onDeviceOrientationChanged: CodegenTypes.EventEmitter<{
25
+ orientation: number;
26
+ }>;
27
+ readonly onInterfaceOrientationChanged: CodegenTypes.EventEmitter<{
28
+ orientation: number;
29
+ }>;
30
+ readonly onLockChanged: CodegenTypes.EventEmitter<{ locked: boolean }>;
26
31
  }
27
32
 
28
33
  export default TurboModuleRegistry.getEnforcing<Spec>('OrientationDirector');
package/src/module.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
1
+ import { NativeModules, Platform } from 'react-native';
2
2
  import type { Spec } from './NativeOrientationDirector';
3
3
 
4
4
  const LINKING_ERROR =
@@ -25,6 +25,4 @@ const OrientationDirectorModule = Module
25
25
  }
26
26
  );
27
27
 
28
- export const ModuleEventEmitter = new NativeEventEmitter(Module);
29
-
30
28
  export default OrientationDirectorModule as Spec;