react-native-nitro-compass 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 (105) hide show
  1. package/LICENSE +21 -0
  2. package/NitroCompass.podspec +31 -0
  3. package/README.md +206 -0
  4. package/android/CMakeLists.txt +32 -0
  5. package/android/build.gradle +148 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  10. package/android/src/main/java/com/margelo/nitro/nitrocompass/HybridNitroCompass.kt +481 -0
  11. package/android/src/main/java/com/margelo/nitro/nitrocompass/NitroCompassPackage.kt +18 -0
  12. package/app.plugin.js +16 -0
  13. package/ios/Bridge.h +8 -0
  14. package/ios/HybridNitroCompass.swift +473 -0
  15. package/lib/commonjs/hook.js +69 -0
  16. package/lib/commonjs/hook.js.map +1 -0
  17. package/lib/commonjs/index.js +39 -0
  18. package/lib/commonjs/index.js.map +1 -0
  19. package/lib/commonjs/multiplex.js +109 -0
  20. package/lib/commonjs/multiplex.js.map +1 -0
  21. package/lib/commonjs/native.js +9 -0
  22. package/lib/commonjs/native.js.map +1 -0
  23. package/lib/commonjs/package.json +1 -0
  24. package/lib/commonjs/specs/NitroCompass.nitro.js +6 -0
  25. package/lib/commonjs/specs/NitroCompass.nitro.js.map +1 -0
  26. package/lib/module/hook.js +65 -0
  27. package/lib/module/hook.js.map +1 -0
  28. package/lib/module/index.js +6 -0
  29. package/lib/module/index.js.map +1 -0
  30. package/lib/module/multiplex.js +103 -0
  31. package/lib/module/multiplex.js.map +1 -0
  32. package/lib/module/native.js +5 -0
  33. package/lib/module/native.js.map +1 -0
  34. package/lib/module/specs/NitroCompass.nitro.js +4 -0
  35. package/lib/module/specs/NitroCompass.nitro.js.map +1 -0
  36. package/lib/typescript/src/hook.d.ts +49 -0
  37. package/lib/typescript/src/hook.d.ts.map +1 -0
  38. package/lib/typescript/src/index.d.ts +8 -0
  39. package/lib/typescript/src/index.d.ts.map +1 -0
  40. package/lib/typescript/src/multiplex.d.ts +38 -0
  41. package/lib/typescript/src/multiplex.d.ts.map +1 -0
  42. package/lib/typescript/src/native.d.ts +3 -0
  43. package/lib/typescript/src/native.d.ts.map +1 -0
  44. package/lib/typescript/src/specs/NitroCompass.nitro.d.ts +176 -0
  45. package/lib/typescript/src/specs/NitroCompass.nitro.d.ts.map +1 -0
  46. package/nitro.json +30 -0
  47. package/nitrogen/generated/.gitattributes +1 -0
  48. package/nitrogen/generated/android/NitroCompass+autolinking.cmake +81 -0
  49. package/nitrogen/generated/android/NitroCompass+autolinking.gradle +27 -0
  50. package/nitrogen/generated/android/NitroCompassOnLoad.cpp +60 -0
  51. package/nitrogen/generated/android/NitroCompassOnLoad.hpp +34 -0
  52. package/nitrogen/generated/android/c++/JAccuracyQuality.hpp +64 -0
  53. package/nitrogen/generated/android/c++/JCompassSample.hpp +61 -0
  54. package/nitrogen/generated/android/c++/JFunc_void_AccuracyQuality.hpp +77 -0
  55. package/nitrogen/generated/android/c++/JFunc_void_CompassSample.hpp +77 -0
  56. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  57. package/nitrogen/generated/android/c++/JHybridNitroCompassSpec.cpp +143 -0
  58. package/nitrogen/generated/android/c++/JHybridNitroCompassSpec.hpp +75 -0
  59. package/nitrogen/generated/android/c++/JPermissionStatus.hpp +61 -0
  60. package/nitrogen/generated/android/c++/JSensorDiagnostics.hpp +58 -0
  61. package/nitrogen/generated/android/c++/JSensorKind.hpp +61 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/AccuracyQuality.kt +25 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/CompassSample.kt +56 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_AccuracyQuality.kt +80 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_CompassSample.kt +80 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_bool.kt +80 -0
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/HybridNitroCompassSpec.kt +118 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/NitroCompassOnLoad.kt +35 -0
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/PermissionStatus.kt +24 -0
  70. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/SensorDiagnostics.kt +51 -0
  71. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/SensorKind.kt +24 -0
  72. package/nitrogen/generated/ios/NitroCompass+autolinking.rb +62 -0
  73. package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Bridge.cpp +73 -0
  74. package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Bridge.hpp +267 -0
  75. package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Umbrella.hpp +61 -0
  76. package/nitrogen/generated/ios/NitroCompassAutolinking.mm +33 -0
  77. package/nitrogen/generated/ios/NitroCompassAutolinking.swift +26 -0
  78. package/nitrogen/generated/ios/c++/HybridNitroCompassSpecSwift.cpp +11 -0
  79. package/nitrogen/generated/ios/c++/HybridNitroCompassSpecSwift.hpp +180 -0
  80. package/nitrogen/generated/ios/swift/AccuracyQuality.swift +48 -0
  81. package/nitrogen/generated/ios/swift/CompassSample.swift +34 -0
  82. package/nitrogen/generated/ios/swift/Func_void_AccuracyQuality.swift +46 -0
  83. package/nitrogen/generated/ios/swift/Func_void_CompassSample.swift +46 -0
  84. package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +46 -0
  85. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  86. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  87. package/nitrogen/generated/ios/swift/HybridNitroCompassSpec.swift +67 -0
  88. package/nitrogen/generated/ios/swift/HybridNitroCompassSpec_cxx.swift +309 -0
  89. package/nitrogen/generated/ios/swift/PermissionStatus.swift +44 -0
  90. package/nitrogen/generated/ios/swift/SensorDiagnostics.swift +29 -0
  91. package/nitrogen/generated/ios/swift/SensorKind.swift +44 -0
  92. package/nitrogen/generated/shared/c++/AccuracyQuality.hpp +84 -0
  93. package/nitrogen/generated/shared/c++/CompassSample.hpp +87 -0
  94. package/nitrogen/generated/shared/c++/HybridNitroCompassSpec.cpp +33 -0
  95. package/nitrogen/generated/shared/c++/HybridNitroCompassSpec.hpp +87 -0
  96. package/nitrogen/generated/shared/c++/PermissionStatus.hpp +80 -0
  97. package/nitrogen/generated/shared/c++/SensorDiagnostics.hpp +84 -0
  98. package/nitrogen/generated/shared/c++/SensorKind.hpp +80 -0
  99. package/package.json +136 -0
  100. package/react-native.config.js +11 -0
  101. package/src/hook.ts +118 -0
  102. package/src/index.ts +28 -0
  103. package/src/multiplex.ts +117 -0
  104. package/src/native.ts +5 -0
  105. package/src/specs/NitroCompass.nitro.ts +193 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_native","require","headingListeners","Set","calibrationListeners","interferenceListeners","calibrationRegistered","interferenceRegistered","DEFAULT_FILTER_DEG","dispatchHeading","sample","cb","Array","from","e","console","error","dispatchCalibration","quality","dispatchInterference","detected","addHeadingListener","wasEmpty","size","add","NitroCompass","start","delete","stop","addCalibrationListener","setOnCalibrationNeeded","addInterferenceListener","setOnInterferenceDetected"],"sourceRoot":"../../src","sources":["multiplex.ts"],"mappings":";;;;;;;;AAgBA,IAAAA,OAAA,GAAAC,OAAA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAkB,CAAC;AACnD,MAAMC,oBAAoB,GAAG,IAAID,GAAG,CAAsB,CAAC;AAC3D,MAAME,qBAAqB,GAAG,IAAIF,GAAG,CAAuB,CAAC;AAE7D,IAAIG,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B,CAACyB,MAAM,CAAChB,EAAE,CAAC,EAAE;IAClC,IAAIT,gBAAgB,CAACqB,IAAI,KAAK,CAAC,EAAE;MAC/BE,oBAAY,CAACG,IAAI,CAAC,CAAC;IACrB;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CACpClB,EAAuB,EACX;EACZ,IAAI,CAACL,qBAAqB,EAAE;IAC1BmB,oBAAY,CAACK,sBAAsB,CAACb,mBAAmB,CAAC;IACxDX,qBAAqB,GAAG,IAAI;EAC9B;EACAF,oBAAoB,CAACoB,GAAG,CAACb,EAAE,CAAC;EAC5B,OAAO,MAAM;IACXP,oBAAoB,CAACuB,MAAM,CAAChB,EAAE,CAAC;EACjC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASoB,uBAAuBA,CACrCpB,EAAwB,EACZ;EACZ,IAAI,CAACJ,sBAAsB,EAAE;IAC3BkB,oBAAY,CAACO,yBAAyB,CAACb,oBAAoB,CAAC;IAC5DZ,sBAAsB,GAAG,IAAI;EAC/B;EACAF,qBAAqB,CAACmB,GAAG,CAACb,EAAE,CAAC;EAC7B,OAAO,MAAM;IACXN,qBAAqB,CAACsB,MAAM,CAAChB,EAAE,CAAC;EAClC,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NitroCompass = void 0;
7
+ var _reactNativeNitroModules = require("react-native-nitro-modules");
8
+ const NitroCompass = exports.NitroCompass = _reactNativeNitroModules.NitroModules.createHybridObject('NitroCompass');
9
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeNitroModules","require","NitroCompass","exports","NitroModules","createHybridObject"],"sourceRoot":"../../src","sources":["native.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAGO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GACvBE,qCAAY,CAACC,kBAAkB,CAAmB,cAAc,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=NitroCompass.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/NitroCompass.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { NitroCompass } from './native';
5
+ import { addCalibrationListener, addHeadingListener, addInterferenceListener } from './multiplex';
6
+ /**
7
+ * Ergonomic React wrapper for the NitroCompass surface. Handles
8
+ * subscription lifecycle, callback registration, and the live-tuneable
9
+ * knobs. Multiple instances mounted at once safely share the same
10
+ * underlying native subscription via the multi-listener primitives in
11
+ * `./multiplex`.
12
+ */
13
+ export function useCompass(options = {}) {
14
+ const {
15
+ filterDegrees = 1,
16
+ declination = 0,
17
+ pauseOnBackground = true,
18
+ enabled = true
19
+ } = options;
20
+ const [reading, setReading] = useState(null);
21
+ const [quality, setQuality] = useState(null);
22
+ const [interfering, setInterfering] = useState(false);
23
+ const [hasCompass] = useState(() => NitroCompass.hasCompass());
24
+ const [diagnostics] = useState(() => NitroCompass.getDiagnostics());
25
+
26
+ // Tracked via ref so the heading-subscription effect can re-apply
27
+ // the user's filter after a stop/start cycle without restarting on
28
+ // every filterDegrees change.
29
+ const filterRef = useRef(filterDegrees);
30
+ filterRef.current = filterDegrees;
31
+ useEffect(() => {
32
+ NitroCompass.setFilter(filterDegrees);
33
+ }, [filterDegrees]);
34
+ useEffect(() => {
35
+ NitroCompass.setDeclination(declination);
36
+ }, [declination]);
37
+ useEffect(() => {
38
+ NitroCompass.setPauseOnBackground(pauseOnBackground);
39
+ }, [pauseOnBackground]);
40
+ useEffect(() => {
41
+ if (!hasCompass) return;
42
+ return addCalibrationListener(setQuality);
43
+ }, [hasCompass]);
44
+ useEffect(() => {
45
+ if (!hasCompass) return;
46
+ return addInterferenceListener(setInterfering);
47
+ }, [hasCompass]);
48
+ useEffect(() => {
49
+ if (!hasCompass || !enabled) return;
50
+ const off = addHeadingListener(setReading);
51
+ // Multiplex starts the sensor with a default filter; re-apply the
52
+ // current option after subscribing.
53
+ NitroCompass.setFilter(filterRef.current);
54
+ return off;
55
+ // eslint-disable-next-line react-hooks/exhaustive-deps
56
+ }, [hasCompass, enabled]);
57
+ return {
58
+ reading,
59
+ quality,
60
+ interfering,
61
+ hasCompass,
62
+ diagnostics
63
+ };
64
+ }
65
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","useState","NitroCompass","addCalibrationListener","addHeadingListener","addInterferenceListener","useCompass","options","filterDegrees","declination","pauseOnBackground","enabled","reading","setReading","quality","setQuality","interfering","setInterfering","hasCompass","diagnostics","getDiagnostics","filterRef","current","setFilter","setDeclination","setPauseOnBackground","off"],"sourceRoot":"../../src","sources":["hook.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAMnD,SAASC,YAAY,QAAQ,UAAU;AACvC,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,uBAAuB,QAClB,aAAa;AA2CpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CACxBC,OAA0B,GAAG,CAAC,CAAC,EACb;EAClB,MAAM;IACJC,aAAa,GAAG,CAAC;IACjBC,WAAW,GAAG,CAAC;IACfC,iBAAiB,GAAG,IAAI;IACxBC,OAAO,GAAG;EACZ,CAAC,GAAGJ,OAAO;EAEX,MAAM,CAACK,OAAO,EAAEC,UAAU,CAAC,GAAGZ,QAAQ,CAAuB,IAAI,CAAC;EAClE,MAAM,CAACa,OAAO,EAAEC,UAAU,CAAC,GAAGd,QAAQ,CAAyB,IAAI,CAAC;E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AC,EAAE,CAACR,UAAU,EAAEP,OAAO,CAAC,CAAC;EAEzB,OAAO;IAAEC,OAAO;IAAEE,OAAO;IAAEE,WAAW;IAAEE,UAAU;IAAEC;EAAY,CAAC;AACnE","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ export { NitroCompass } from './native';
4
+ export { addCalibrationListener, addHeadingListener, addInterferenceListener } from './multiplex';
5
+ export { useCompass } from './hook';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NitroCompass","addCalibrationListener","addHeadingListener","addInterferenceListener","useCompass"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AASA,SAASA,YAAY,QAAQ,UAAU;AAWvC,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,uBAAuB,QAClB,aAAa;AAEpB,SAASC,UAAU,QAAQ,QAAQ","ignoreList":[]}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * JS-side fan-out so multiple consumers can subscribe to the same
5
+ * compass stream without clobbering each other. The native API is
6
+ * single-callback by design (start, setOnCalibrationNeeded,
7
+ * setOnInterferenceDetected each own one slot); these helpers wrap
8
+ * that into multi-listener primitives with reference-counted
9
+ * lifecycle.
10
+ *
11
+ * Mixing direct `NitroCompass.start()` / `setOnCalibrationNeeded()` /
12
+ * `setOnInterferenceDetected()` calls with these helpers will
13
+ * clobber the multiplex's internal callback slot — pick one path.
14
+ */
15
+
16
+ import { NitroCompass } from './native';
17
+ const headingListeners = new Set();
18
+ const calibrationListeners = new Set();
19
+ const interferenceListeners = new Set();
20
+ let calibrationRegistered = false;
21
+ let interferenceRegistered = false;
22
+ const DEFAULT_FILTER_DEG = 1;
23
+ function dispatchHeading(sample) {
24
+ for (const cb of Array.from(headingListeners)) {
25
+ try {
26
+ cb(sample);
27
+ } catch (e) {
28
+ console.error('[NitroCompass] heading listener threw:', e);
29
+ }
30
+ }
31
+ }
32
+ function dispatchCalibration(quality) {
33
+ for (const cb of Array.from(calibrationListeners)) {
34
+ try {
35
+ cb(quality);
36
+ } catch (e) {
37
+ console.error('[NitroCompass] calibration listener threw:', e);
38
+ }
39
+ }
40
+ }
41
+ function dispatchInterference(detected) {
42
+ for (const cb of Array.from(interferenceListeners)) {
43
+ try {
44
+ cb(detected);
45
+ } catch (e) {
46
+ console.error('[NitroCompass] interference listener threw:', e);
47
+ }
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Subscribe to heading samples. The first listener implicitly calls
53
+ * `NitroCompass.start()`; the last `unsubscribe()` calls
54
+ * `NitroCompass.stop()`. Returns the unsubscribe function.
55
+ *
56
+ * Filter, declination, and pauseOnBackground remain global state on
57
+ * `NitroCompass` and are shared across all listeners — call
58
+ * `NitroCompass.setFilter()` etc. directly to tune them.
59
+ */
60
+ export function addHeadingListener(cb) {
61
+ const wasEmpty = headingListeners.size === 0;
62
+ headingListeners.add(cb);
63
+ if (wasEmpty) {
64
+ NitroCompass.start(DEFAULT_FILTER_DEG, dispatchHeading);
65
+ }
66
+ return () => {
67
+ if (!headingListeners.delete(cb)) return;
68
+ if (headingListeners.size === 0) {
69
+ NitroCompass.stop();
70
+ }
71
+ };
72
+ }
73
+
74
+ /**
75
+ * Subscribe to calibration-bucket transitions. Only fires while a
76
+ * heading subscription is active. Returns the unsubscribe function.
77
+ */
78
+ export function addCalibrationListener(cb) {
79
+ if (!calibrationRegistered) {
80
+ NitroCompass.setOnCalibrationNeeded(dispatchCalibration);
81
+ calibrationRegistered = true;
82
+ }
83
+ calibrationListeners.add(cb);
84
+ return () => {
85
+ calibrationListeners.delete(cb);
86
+ };
87
+ }
88
+
89
+ /**
90
+ * Subscribe to magnetic-interference transitions. Only fires while a
91
+ * heading subscription is active. Returns the unsubscribe function.
92
+ */
93
+ export function addInterferenceListener(cb) {
94
+ if (!interferenceRegistered) {
95
+ NitroCompass.setOnInterferenceDetected(dispatchInterference);
96
+ interferenceRegistered = true;
97
+ }
98
+ interferenceListeners.add(cb);
99
+ return () => {
100
+ interferenceListeners.delete(cb);
101
+ };
102
+ }
103
+ //# sourceMappingURL=multiplex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NitroCompass","headingListeners","Set","calibrationListeners","interferenceListeners","calibrationRegistered","interferenceRegistered","DEFAULT_FILTER_DEG","dispatchHeading","sample","cb","Array","from","e","console","error","dispatchCalibration","quality","dispatchInterference","detected","addHeadingListener","wasEmpty","size","add","start","delete","stop","addCalibrationListener","setOnCalibrationNeeded","addInterferenceListener","setOnInterferenceDetected"],"sourceRoot":"../../src","sources":["multiplex.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,YAAY,QAAQ,UAAU;AAMvC,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAkB,CAAC;AACnD,MAAMC,oBAAoB,GAAG,IAAID,GAAG,CAAsB,CAAC;AAC3D,MAAME,qBAAqB,GAAG,IAAIF,GAAG,CAAuB,CAAC;AAE7D,IAAIG,qBAAqB,GAAG,KAAK;AACjC,IAAIC,sBAAsB,GAAG,KAAK;AAElC,MAAMC,kBAAkB,GAAG,CAAC;AAE5B,SAASC,eAAeA,CAACC,MAAqB,EAAE;EAC9C,KAAK,MAAMC,EAAE,IAAIC,KAAK,CAACC,IAAI,CAACX,gBAAgB,CAAC,EAAE;IAC7C,IAAI;MACFS,EAAE,CAACD,MAAM,CAAC;IACZ,CAAC,CAAC,OAAOI,CAAC,EAAE;MACVC,OAAO,CAACC,KAAK,CAAC,wCAAwC,EAAEF,CAAC,CAAC;IAC5D;EACF;AACF;AAEA,SAASG,mBAAmBA,CAACC,OAAwB,EAAE;EACrD,KAAK,MAAMP,EAAE,IAAIC,KAAK,CAACC,IAAI,CAACT,oBAAoB,CAAC,EAAE;IACjD,IAAI;MACFO,EAAE,CAACO,OAAO,CAAC;IACb,CAAC,CAAC,OAAOJ,CAAC,EAAE;MACVC,OAAO,CAACC,KAAK,CAAC,4CAA4C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AY,CAAC8B,yBAAyB,CAACZ,oBAAoB,CAAC;IAC5DZ,sBAAsB,GAAG,IAAI;EAC/B;EACAF,qBAAqB,CAACmB,GAAG,CAACb,EAAE,CAAC;EAC7B,OAAO,MAAM;IACXN,qBAAqB,CAACqB,MAAM,CAACf,EAAE,CAAC;EAClC,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import { NitroModules } from 'react-native-nitro-modules';
4
+ export const NitroCompass = NitroModules.createHybridObject('NitroCompass');
5
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NitroModules","NitroCompass","createHybridObject"],"sourceRoot":"../../src","sources":["native.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAGzD,OAAO,MAAMC,YAAY,GACvBD,YAAY,CAACE,kBAAkB,CAAmB,cAAc,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=NitroCompass.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/NitroCompass.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,49 @@
1
+ import type { AccuracyQuality, CompassSample, SensorDiagnostics } from './specs/NitroCompass.nitro';
2
+ export interface UseCompassOptions {
3
+ /**
4
+ * Minimum change between samples in degrees. Pass `0` for "every
5
+ * event". Default `1`. Updated live via `NitroCompass.setFilter()`.
6
+ * Note: this is global state shared with any other consumer of
7
+ * the library — last-write-wins.
8
+ */
9
+ filterDegrees?: number;
10
+ /**
11
+ * Magnetic-to-true offset in signed degrees. Default `0` (magnetic).
12
+ * Pull from a model like `geomagnetism` keyed on the user's lat/lon.
13
+ * Like `filterDegrees`, this is shared global state.
14
+ */
15
+ declination?: number;
16
+ /**
17
+ * Pause the underlying sensor when the app is backgrounded. Default
18
+ * `true`. Shared global state.
19
+ */
20
+ pauseOnBackground?: boolean;
21
+ /**
22
+ * Toggle the heading subscription without unmounting the hook.
23
+ * Default `true`. When `false`, the hook still observes calibration
24
+ * and interference (so you can show warnings) but won't tear down
25
+ * its own state — `reading` simply stops updating.
26
+ */
27
+ enabled?: boolean;
28
+ }
29
+ export interface UseCompassResult {
30
+ /** Latest emitted sample, or `null` until the first arrives. */
31
+ reading: CompassSample | null;
32
+ /** Coarse accuracy bucket, or `null` until the first transition. */
33
+ quality: AccuracyQuality | null;
34
+ /** Whether external magnetic interference is currently detected. */
35
+ interfering: boolean;
36
+ /** Hardware availability — read once on first render. */
37
+ hasCompass: boolean;
38
+ /** Which sensor backs the readings on this device. */
39
+ diagnostics: SensorDiagnostics | undefined;
40
+ }
41
+ /**
42
+ * Ergonomic React wrapper for the NitroCompass surface. Handles
43
+ * subscription lifecycle, callback registration, and the live-tuneable
44
+ * knobs. Multiple instances mounted at once safely share the same
45
+ * underlying native subscription via the multi-listener primitives in
46
+ * `./multiplex`.
47
+ */
48
+ export declare function useCompass(options?: UseCompassOptions): UseCompassResult;
49
+ //# sourceMappingURL=hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AAQnC,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;IAC7B,oEAAoE;IACpE,OAAO,EAAE,eAAe,GAAG,IAAI,CAAA;IAC/B,oEAAoE;IACpE,WAAW,EAAE,OAAO,CAAA;IACpB,yDAAyD;IACzD,UAAU,EAAE,OAAO,CAAA;IACnB,sDAAsD;IACtD,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAA;CAC3C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,OAAO,GAAE,iBAAsB,GAC9B,gBAAgB,CAsDlB"}
@@ -0,0 +1,8 @@
1
+ import type { AccuracyQuality, CompassSample, NitroCompass as NitroCompassSpec, PermissionStatus, SensorDiagnostics, SensorKind } from './specs/NitroCompass.nitro';
2
+ export { NitroCompass } from './native';
3
+ export type { AccuracyQuality, CompassSample, PermissionStatus, SensorDiagnostics, SensorKind, };
4
+ export type { NitroCompassSpec as NitroCompassHybridObject };
5
+ export { addCalibrationListener, addHeadingListener, addInterferenceListener, } from './multiplex';
6
+ export { useCompass } from './hook';
7
+ export type { UseCompassOptions, UseCompassResult } from './hook';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,YAAY,IAAI,gBAAgB,EAChC,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACX,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,YAAY,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,CAAA;AACD,YAAY,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,CAAA;AAE5D,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * JS-side fan-out so multiple consumers can subscribe to the same
3
+ * compass stream without clobbering each other. The native API is
4
+ * single-callback by design (start, setOnCalibrationNeeded,
5
+ * setOnInterferenceDetected each own one slot); these helpers wrap
6
+ * that into multi-listener primitives with reference-counted
7
+ * lifecycle.
8
+ *
9
+ * Mixing direct `NitroCompass.start()` / `setOnCalibrationNeeded()` /
10
+ * `setOnInterferenceDetected()` calls with these helpers will
11
+ * clobber the multiplex's internal callback slot — pick one path.
12
+ */
13
+ import type { AccuracyQuality, CompassSample } from './specs/NitroCompass.nitro';
14
+ type HeadingListener = (sample: CompassSample) => void;
15
+ type CalibrationListener = (quality: AccuracyQuality) => void;
16
+ type InterferenceListener = (interferenceDetected: boolean) => void;
17
+ /**
18
+ * Subscribe to heading samples. The first listener implicitly calls
19
+ * `NitroCompass.start()`; the last `unsubscribe()` calls
20
+ * `NitroCompass.stop()`. Returns the unsubscribe function.
21
+ *
22
+ * Filter, declination, and pauseOnBackground remain global state on
23
+ * `NitroCompass` and are shared across all listeners — call
24
+ * `NitroCompass.setFilter()` etc. directly to tune them.
25
+ */
26
+ export declare function addHeadingListener(cb: HeadingListener): () => void;
27
+ /**
28
+ * Subscribe to calibration-bucket transitions. Only fires while a
29
+ * heading subscription is active. Returns the unsubscribe function.
30
+ */
31
+ export declare function addCalibrationListener(cb: CalibrationListener): () => void;
32
+ /**
33
+ * Subscribe to magnetic-interference transitions. Only fires while a
34
+ * heading subscription is active. Returns the unsubscribe function.
35
+ */
36
+ export declare function addInterferenceListener(cb: InterferenceListener): () => void;
37
+ export {};
38
+ //# sourceMappingURL=multiplex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplex.d.ts","sourceRoot":"","sources":["../../../src/multiplex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACd,MAAM,4BAA4B,CAAA;AAGnC,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAA;AACtD,KAAK,mBAAmB,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAA;AAC7D,KAAK,oBAAoB,GAAG,CAAC,oBAAoB,EAAE,OAAO,KAAK,IAAI,CAAA;AAyCnE;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,eAAe,GAAG,MAAM,IAAI,CAYlE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,mBAAmB,GACtB,MAAM,IAAI,CASZ;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,oBAAoB,GACvB,MAAM,IAAI,CASZ"}
@@ -0,0 +1,3 @@
1
+ import type { NitroCompass as NitroCompassSpec } from './specs/NitroCompass.nitro';
2
+ export declare const NitroCompass: NitroCompassSpec;
3
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/native.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAElF,eAAO,MAAM,YAAY,kBAC0C,CAAA"}
@@ -0,0 +1,176 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+ /**
3
+ * One compass heading sample, delivered to the JS callback registered with
4
+ * `start()`. Both fields are in degrees.
5
+ *
6
+ * - `heading`: heading clockwise from north, in `[0, 360)`. Magnetic by
7
+ * default; if you call `setDeclination(deg)` the offset is applied
8
+ * natively before this sample is delivered (and reflected in
9
+ * `getCurrentHeading()`).
10
+ * - `accuracy`: estimated heading uncertainty in degrees, or `-1` when the
11
+ * platform has not yet reported a usable accuracy. Smaller is better.
12
+ * On Android this is read from `event.values[4]` of the rotation-vector
13
+ * sensor when available, otherwise mapped from `SensorManager.SENSOR_STATUS_*`.
14
+ * On iOS this is `CLHeading.headingAccuracy`.
15
+ */
16
+ export interface CompassSample {
17
+ heading: number;
18
+ accuracy: number;
19
+ }
20
+ /**
21
+ * Coarse calibration bucket reported via `setOnCalibrationNeeded`. Buckets
22
+ * are derived from numeric heading accuracy on both platforms (same
23
+ * thresholds), so values agree across iOS and Android:
24
+ *
25
+ * `<5°` → `high`, `<15°` → `medium`, `<30°` → `low`, otherwise `unreliable`.
26
+ *
27
+ * On iOS `unreliable` is also reported when the system asks to display
28
+ * its built-in calibration UI (we suppress it).
29
+ */
30
+ export type AccuracyQuality = 'high' | 'medium' | 'low' | 'unreliable';
31
+ /**
32
+ * Identifies which underlying sensor / framework is producing headings.
33
+ *
34
+ * - `rotationVector` — Android `Sensor.TYPE_ROTATION_VECTOR` (gyro + accel
35
+ * + magnetometer fused). Best quality.
36
+ * - `geomagneticRotationVector` — Android
37
+ * `Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR` (accel + magnetometer only).
38
+ * Used as fallback on gyroless / budget devices; lower update rate and
39
+ * more susceptible to magnetic interference.
40
+ * - `coreLocation` — iOS `CLLocationManager` heading. Apple's stack
41
+ * handles fusion natively.
42
+ */
43
+ export type SensorKind = 'rotationVector' | 'geomagneticRotationVector' | 'coreLocation';
44
+ export interface SensorDiagnostics {
45
+ sensor: SensorKind;
46
+ }
47
+ /**
48
+ * Platform permission state required to deliver headings.
49
+ *
50
+ * - `granted` — headings will deliver. iOS: `authorizedAlways` /
51
+ * `authorizedWhenInUse`. Android: always (sensors require no permission).
52
+ * - `denied` — user has refused or the OS has restricted access (e.g.
53
+ * parental controls). On iOS, `start()` will throw with this status.
54
+ * - `unknown` — iOS `notDetermined`: nothing has been asked yet. Calling
55
+ * `requestPermission()` is the way to resolve from `unknown` to
56
+ * `granted`/`denied`.
57
+ */
58
+ export type PermissionStatus = 'granted' | 'denied' | 'unknown';
59
+ /**
60
+ * Native compass module. Pull this from `NitroModules.createHybridObject`
61
+ * via the bundled `NitroCompass` export, e.g.:
62
+ *
63
+ * ```ts
64
+ * import { NitroCompass } from 'react-native-nitro-compass'
65
+ *
66
+ * NitroCompass.start(1, ({ heading, accuracy }) => {
67
+ * console.log(heading, accuracy)
68
+ * })
69
+ * NitroCompass.stop()
70
+ * ```
71
+ */
72
+ export interface NitroCompass extends HybridObject<{
73
+ ios: 'swift';
74
+ android: 'kotlin';
75
+ }> {
76
+ /**
77
+ * Begin emitting heading samples to `onHeading`. If `start()` has already
78
+ * been called without a matching `stop()`, the previous subscription is
79
+ * silently torn down and replaced — the old `onHeading` is detached.
80
+ *
81
+ * @param filterDegrees Minimum change (in degrees) between samples before
82
+ * the next one is emitted. Pass `0` for "every event"; typical UI values
83
+ * are 1–3. Use `setFilter()` to update without restarting.
84
+ * @param onHeading JS callback invoked on each accepted sample. Called on
85
+ * the JS thread; calling `stop()` from inside this callback is safe.
86
+ */
87
+ start(filterDegrees: number, onHeading: (sample: CompassSample) => void): void;
88
+ /** Stop the underlying sensor / location-manager subscription. Idempotent — safe to call when not started. */
89
+ stop(): void;
90
+ /** Whether `start()` has been called without a matching `stop()`. */
91
+ isStarted(): boolean;
92
+ /**
93
+ * Update the deadband filter live without tearing down the subscription.
94
+ * Same semantics as the `filterDegrees` argument to `start()`. Has no
95
+ * effect until `start()` is called.
96
+ */
97
+ setFilter(degrees: number): void;
98
+ /**
99
+ * Describe which underlying sensor / framework would produce headings on
100
+ * this device. Returns `undefined` if the device has no compass hardware
101
+ * (equivalent to `hasCompass() === false`). Safe to call before `start()`.
102
+ */
103
+ getDiagnostics(): SensorDiagnostics | undefined;
104
+ /**
105
+ * Whether the device has the hardware required for a compass reading.
106
+ * Android: a rotation-vector sensor (fused or geomagnetic) is present.
107
+ * iOS: `CLLocationManager.headingAvailable()`.
108
+ */
109
+ hasCompass(): boolean;
110
+ /**
111
+ * Last sample emitted by the active subscription, with declination
112
+ * already applied. Returns `undefined` when not started, or when started
113
+ * but no sample has arrived yet.
114
+ */
115
+ getCurrentHeading(): CompassSample | undefined;
116
+ /**
117
+ * Magnetic-to-true offset (degrees, signed) added to every heading
118
+ * before it leaves the native side. Pass `0` to revert to magnetic.
119
+ * Survives across `start`/`stop`. Apply your own declination from a
120
+ * model like `geomagnetism` keyed on the user's lat/lon.
121
+ */
122
+ setDeclination(degrees: number): void;
123
+ /**
124
+ * Register a callback fired when the calibration bucket transitions.
125
+ * Replaces any previously registered callback. Pass a no-op to mute.
126
+ * The callback is invoked on the JS thread.
127
+ */
128
+ setOnCalibrationNeeded(onChange: (quality: AccuracyQuality) => void): void;
129
+ /**
130
+ * Register a callback fired when external magnetic interference is
131
+ * detected — typical sources are laptops, monitors, car engines, and
132
+ * large steel structures, all of which can skew heading by tens of
133
+ * degrees while the calibration bucket still reads `'medium'` or
134
+ * better. Fires `true` when the raw magnetic field magnitude leaves
135
+ * the normal Earth band (~20–70 µT) and `false` when it returns.
136
+ * Only transitions are reported; the callback is debounce-free, so
137
+ * brief excursions still fire.
138
+ *
139
+ * Replaces any previously registered callback. Pass a no-op to mute.
140
+ * The callback is invoked on the JS thread. Only meaningful while
141
+ * `start()` is active.
142
+ *
143
+ * iOS uses `CMDeviceMotion.magneticField` — the calibrated field
144
+ * with the device's own hard-iron bias subtracted in real time.
145
+ * No transitions are reported until CoreMotion's bias estimate
146
+ * converges (a second or two of normal device movement); that's
147
+ * required, otherwise raw readings dominated by internal bias
148
+ * would fire false alarms continuously.
149
+ */
150
+ setOnInterferenceDetected(onChange: (interferenceDetected: boolean) => void): void;
151
+ /**
152
+ * Toggle automatic pause/resume on app background/foreground. Default
153
+ * `true`. When enabled, the underlying sensor / location-manager
154
+ * subscription is silently paused while the app is backgrounded and
155
+ * resumed when it returns to the foreground; the JS callback and
156
+ * declination are preserved across the pause. Call before or after
157
+ * `start()`; takes effect immediately.
158
+ */
159
+ setPauseOnBackground(enabled: boolean): void;
160
+ /**
161
+ * Read the current platform permission state synchronously.
162
+ * On Android this is always `'granted'` (sensors require no permission);
163
+ * on iOS it maps `CLLocationManager.authorizationStatus`.
164
+ */
165
+ getPermissionStatus(): PermissionStatus;
166
+ /**
167
+ * Request the platform permission required to deliver headings. On iOS
168
+ * this prompts the system "Allow location" dialog if the status is
169
+ * `'unknown'` and resolves once the user makes a choice. If already
170
+ * `'granted'` or `'denied'` it resolves immediately with that value
171
+ * (iOS does not re-prompt). On Android it resolves immediately with
172
+ * `'granted'`.
173
+ */
174
+ requestPermission(): Promise<PermissionStatus>;
175
+ }
176
+ //# sourceMappingURL=NitroCompass.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NitroCompass.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroCompass.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,YAAY,CAAA;AAEtE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,2BAA2B,GAC3B,cAAc,CAAA;AAElB,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,UAAU,CAAA;CACnB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAa,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACrF;;;;;;;;;;OAUG;IACH,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI,CAAA;IAE9E,8GAA8G;IAC9G,IAAI,IAAI,IAAI,CAAA;IAEZ,qEAAqE;IACrE,SAAS,IAAI,OAAO,CAAA;IAEpB;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhC;;;;OAIG;IACH,cAAc,IAAI,iBAAiB,GAAG,SAAS,CAAA;IAE/C;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAA;IAErB;;;;OAIG;IACH,iBAAiB,IAAI,aAAa,GAAG,SAAS,CAAA;IAE9C;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAErC;;;;OAIG;IACH,sBAAsB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAAG,IAAI,CAAA;IAE1E;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,yBAAyB,CAAC,QAAQ,EAAE,CAAC,oBAAoB,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAA;IAElF;;;;;;;OAOG;IACH,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IAE5C;;;;OAIG;IACH,mBAAmB,IAAI,gBAAgB,CAAA;IAEvC;;;;;;;OAOG;IACH,iBAAiB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAC/C"}
package/nitro.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "https://nitro.margelo.com/nitro.schema.json",
3
+ "cxxNamespace": [
4
+ "nitrocompass"
5
+ ],
6
+ "ios": {
7
+ "iosModuleName": "NitroCompass"
8
+ },
9
+ "android": {
10
+ "androidNamespace": [
11
+ "nitrocompass"
12
+ ],
13
+ "androidCxxLibName": "NitroCompass"
14
+ },
15
+ "autolinking": {
16
+ "NitroCompass": {
17
+ "ios": {
18
+ "language": "swift",
19
+ "implementationClassName": "HybridNitroCompass"
20
+ },
21
+ "android": {
22
+ "language": "kotlin",
23
+ "implementationClassName": "HybridNitroCompass"
24
+ }
25
+ }
26
+ },
27
+ "ignorePaths": [
28
+ "**/node_modules"
29
+ ]
30
+ }
@@ -0,0 +1 @@
1
+ ** linguist-generated=true