munim-wifi 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 (96) hide show
  1. package/LICENSE +21 -0
  2. package/MunimWifi.podspec +31 -0
  3. package/README.md +591 -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 +6 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  10. package/android/src/main/java/com/munimwifi/HybridMunimWifi.kt +283 -0
  11. package/android/src/main/java/com/munimwifi/MunimWifiPackage.kt +20 -0
  12. package/ios/Bridge.h +8 -0
  13. package/ios/HybridMunimWifi.swift +222 -0
  14. package/lib/commonjs/index.js +216 -0
  15. package/lib/commonjs/index.js.map +1 -0
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/commonjs/specs/munim-wifi.nitro.js +6 -0
  18. package/lib/commonjs/specs/munim-wifi.nitro.js.map +1 -0
  19. package/lib/module/index.js +198 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/specs/munim-wifi.nitro.js +4 -0
  22. package/lib/module/specs/munim-wifi.nitro.js.map +1 -0
  23. package/lib/typescript/src/index.d.ts +120 -0
  24. package/lib/typescript/src/index.d.ts.map +1 -0
  25. package/lib/typescript/src/specs/munim-wifi.nitro.d.ts +118 -0
  26. package/lib/typescript/src/specs/munim-wifi.nitro.d.ts.map +1 -0
  27. package/nitro.json +24 -0
  28. package/nitrogen/generated/.gitattributes +1 -0
  29. package/nitrogen/generated/android/MunimWifi+autolinking.cmake +85 -0
  30. package/nitrogen/generated/android/MunimWifi+autolinking.gradle +27 -0
  31. package/nitrogen/generated/android/MunimWifiOnLoad.cpp +44 -0
  32. package/nitrogen/generated/android/MunimWifiOnLoad.hpp +25 -0
  33. package/nitrogen/generated/android/c++/JChannelInfo.hpp +61 -0
  34. package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.cpp +262 -0
  35. package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.hpp +78 -0
  36. package/nitrogen/generated/android/c++/JLocation.hpp +61 -0
  37. package/nitrogen/generated/android/c++/JScanOptions.hpp +61 -0
  38. package/nitrogen/generated/android/c++/JVariant_NullType_ChannelInfo.cpp +26 -0
  39. package/nitrogen/generated/android/c++/JVariant_NullType_ChannelInfo.hpp +71 -0
  40. package/nitrogen/generated/android/c++/JVariant_NullType_Double.cpp +26 -0
  41. package/nitrogen/generated/android/c++/JVariant_NullType_Double.hpp +69 -0
  42. package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
  43. package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
  44. package/nitrogen/generated/android/c++/JVariant_NullType_WifiNetwork.cpp +26 -0
  45. package/nitrogen/generated/android/c++/JVariant_NullType_WifiNetwork.hpp +73 -0
  46. package/nitrogen/generated/android/c++/JWifiFingerprint.hpp +89 -0
  47. package/nitrogen/generated/android/c++/JWifiNetwork.hpp +86 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/ChannelInfo.kt +41 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/HybridMunimWifiSpec.kt +107 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Location.kt +41 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/MunimWifiOnLoad.kt +35 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/ScanOptions.kt +41 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_ChannelInfo.kt +59 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_Double.kt +59 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_String.kt +59 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_WifiNetwork.kt +59 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/WifiFingerprint.kt +44 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/WifiNetwork.kt +59 -0
  59. package/nitrogen/generated/ios/MunimWifi+autolinking.rb +60 -0
  60. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.cpp +105 -0
  61. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.hpp +653 -0
  62. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Umbrella.hpp +64 -0
  63. package/nitrogen/generated/ios/MunimWifiAutolinking.mm +33 -0
  64. package/nitrogen/generated/ios/MunimWifiAutolinking.swift +26 -0
  65. package/nitrogen/generated/ios/c++/HybridMunimWifiSpecSwift.cpp +11 -0
  66. package/nitrogen/generated/ios/c++/HybridMunimWifiSpecSwift.hpp +189 -0
  67. package/nitrogen/generated/ios/swift/ChannelInfo.swift +35 -0
  68. package/nitrogen/generated/ios/swift/Func_void_WifiFingerprint.swift +47 -0
  69. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  70. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  71. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__ChannelInfo_.swift +59 -0
  72. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__WifiNetwork_.swift +59 -0
  73. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__double_.swift +59 -0
  74. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__std__string_.swift +59 -0
  75. package/nitrogen/generated/ios/swift/Func_void_std__vector_WifiNetwork_.swift +47 -0
  76. package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +47 -0
  77. package/nitrogen/generated/ios/swift/HybridMunimWifiSpec.swift +68 -0
  78. package/nitrogen/generated/ios/swift/HybridMunimWifiSpec_cxx.swift +382 -0
  79. package/nitrogen/generated/ios/swift/Location.swift +47 -0
  80. package/nitrogen/generated/ios/swift/ScanOptions.swift +47 -0
  81. package/nitrogen/generated/ios/swift/Variant_NullType_ChannelInfo.swift +18 -0
  82. package/nitrogen/generated/ios/swift/Variant_NullType_Double.swift +18 -0
  83. package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +18 -0
  84. package/nitrogen/generated/ios/swift/Variant_NullType_WifiNetwork.swift +18 -0
  85. package/nitrogen/generated/ios/swift/WifiFingerprint.swift +52 -0
  86. package/nitrogen/generated/ios/swift/WifiNetwork.swift +103 -0
  87. package/nitrogen/generated/shared/c++/ChannelInfo.hpp +87 -0
  88. package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.cpp +33 -0
  89. package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.hpp +90 -0
  90. package/nitrogen/generated/shared/c++/Location.hpp +87 -0
  91. package/nitrogen/generated/shared/c++/ScanOptions.hpp +87 -0
  92. package/nitrogen/generated/shared/c++/WifiFingerprint.hpp +97 -0
  93. package/nitrogen/generated/shared/c++/WifiNetwork.hpp +112 -0
  94. package/package.json +122 -0
  95. package/src/index.ts +221 -0
  96. package/src/specs/munim-wifi.nitro.ts +140 -0
@@ -0,0 +1,97 @@
1
+ ///
2
+ /// WifiFingerprint.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `WifiNetwork` to properly resolve imports.
32
+ namespace margelo::nitro::munimwifi { struct WifiNetwork; }
33
+ // Forward declaration of `Location` to properly resolve imports.
34
+ namespace margelo::nitro::munimwifi { struct Location; }
35
+
36
+ #include "WifiNetwork.hpp"
37
+ #include <vector>
38
+ #include "Location.hpp"
39
+ #include <optional>
40
+
41
+ namespace margelo::nitro::munimwifi {
42
+
43
+ /**
44
+ * A struct which can be represented as a JavaScript object (WifiFingerprint).
45
+ */
46
+ struct WifiFingerprint final {
47
+ public:
48
+ std::vector<WifiNetwork> networks SWIFT_PRIVATE;
49
+ double timestamp SWIFT_PRIVATE;
50
+ std::optional<Location> location SWIFT_PRIVATE;
51
+
52
+ public:
53
+ WifiFingerprint() = default;
54
+ explicit WifiFingerprint(std::vector<WifiNetwork> networks, double timestamp, std::optional<Location> location): networks(networks), timestamp(timestamp), location(location) {}
55
+
56
+ public:
57
+ friend bool operator==(const WifiFingerprint& lhs, const WifiFingerprint& rhs) = default;
58
+ };
59
+
60
+ } // namespace margelo::nitro::munimwifi
61
+
62
+ namespace margelo::nitro {
63
+
64
+ // C++ WifiFingerprint <> JS WifiFingerprint (object)
65
+ template <>
66
+ struct JSIConverter<margelo::nitro::munimwifi::WifiFingerprint> final {
67
+ static inline margelo::nitro::munimwifi::WifiFingerprint fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
68
+ jsi::Object obj = arg.asObject(runtime);
69
+ return margelo::nitro::munimwifi::WifiFingerprint(
70
+ JSIConverter<std::vector<margelo::nitro::munimwifi::WifiNetwork>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "networks"))),
71
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp"))),
72
+ JSIConverter<std::optional<margelo::nitro::munimwifi::Location>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "location")))
73
+ );
74
+ }
75
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimwifi::WifiFingerprint& arg) {
76
+ jsi::Object obj(runtime);
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "networks"), JSIConverter<std::vector<margelo::nitro::munimwifi::WifiNetwork>>::toJSI(runtime, arg.networks));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "timestamp"), JSIConverter<double>::toJSI(runtime, arg.timestamp));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "location"), JSIConverter<std::optional<margelo::nitro::munimwifi::Location>>::toJSI(runtime, arg.location));
80
+ return obj;
81
+ }
82
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
83
+ if (!value.isObject()) {
84
+ return false;
85
+ }
86
+ jsi::Object obj = value.getObject(runtime);
87
+ if (!nitro::isPlainObject(runtime, obj)) {
88
+ return false;
89
+ }
90
+ if (!JSIConverter<std::vector<margelo::nitro::munimwifi::WifiNetwork>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "networks")))) return false;
91
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp")))) return false;
92
+ if (!JSIConverter<std::optional<margelo::nitro::munimwifi::Location>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "location")))) return false;
93
+ return true;
94
+ }
95
+ };
96
+
97
+ } // namespace margelo::nitro
@@ -0,0 +1,112 @@
1
+ ///
2
+ /// WifiNetwork.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+
36
+ namespace margelo::nitro::munimwifi {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (WifiNetwork).
40
+ */
41
+ struct WifiNetwork final {
42
+ public:
43
+ std::string ssid SWIFT_PRIVATE;
44
+ std::string bssid SWIFT_PRIVATE;
45
+ double rssi SWIFT_PRIVATE;
46
+ double frequency SWIFT_PRIVATE;
47
+ std::optional<double> channel SWIFT_PRIVATE;
48
+ std::optional<std::string> capabilities SWIFT_PRIVATE;
49
+ std::optional<bool> isSecure SWIFT_PRIVATE;
50
+ std::optional<double> timestamp SWIFT_PRIVATE;
51
+
52
+ public:
53
+ WifiNetwork() = default;
54
+ explicit WifiNetwork(std::string ssid, std::string bssid, double rssi, double frequency, std::optional<double> channel, std::optional<std::string> capabilities, std::optional<bool> isSecure, std::optional<double> timestamp): ssid(ssid), bssid(bssid), rssi(rssi), frequency(frequency), channel(channel), capabilities(capabilities), isSecure(isSecure), timestamp(timestamp) {}
55
+
56
+ public:
57
+ friend bool operator==(const WifiNetwork& lhs, const WifiNetwork& rhs) = default;
58
+ };
59
+
60
+ } // namespace margelo::nitro::munimwifi
61
+
62
+ namespace margelo::nitro {
63
+
64
+ // C++ WifiNetwork <> JS WifiNetwork (object)
65
+ template <>
66
+ struct JSIConverter<margelo::nitro::munimwifi::WifiNetwork> final {
67
+ static inline margelo::nitro::munimwifi::WifiNetwork fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
68
+ jsi::Object obj = arg.asObject(runtime);
69
+ return margelo::nitro::munimwifi::WifiNetwork(
70
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid"))),
71
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bssid"))),
72
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi"))),
73
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frequency"))),
74
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "channel"))),
75
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "capabilities"))),
76
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSecure"))),
77
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp")))
78
+ );
79
+ }
80
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimwifi::WifiNetwork& arg) {
81
+ jsi::Object obj(runtime);
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ssid"), JSIConverter<std::string>::toJSI(runtime, arg.ssid));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "bssid"), JSIConverter<std::string>::toJSI(runtime, arg.bssid));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "rssi"), JSIConverter<double>::toJSI(runtime, arg.rssi));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "frequency"), JSIConverter<double>::toJSI(runtime, arg.frequency));
86
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "channel"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.channel));
87
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "capabilities"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.capabilities));
88
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "isSecure"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isSecure));
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "timestamp"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.timestamp));
90
+ return obj;
91
+ }
92
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
93
+ if (!value.isObject()) {
94
+ return false;
95
+ }
96
+ jsi::Object obj = value.getObject(runtime);
97
+ if (!nitro::isPlainObject(runtime, obj)) {
98
+ return false;
99
+ }
100
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid")))) return false;
101
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bssid")))) return false;
102
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi")))) return false;
103
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frequency")))) return false;
104
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "channel")))) return false;
105
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "capabilities")))) return false;
106
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSecure")))) return false;
107
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp")))) return false;
108
+ return true;
109
+ }
110
+ };
111
+
112
+ } // namespace margelo::nitro
package/package.json ADDED
@@ -0,0 +1,122 @@
1
+ {
2
+ "name": "munim-wifi",
3
+ "version": "0.1.0",
4
+ "description": "munim-wifi is a react native package built with Nitro",
5
+ "main": "./lib/commonjs/index.js",
6
+ "module": "./lib/module/index.js",
7
+ "types": "./lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "scripts": {
11
+ "typecheck": "tsc --noEmit",
12
+ "clean": "git clean -dfX",
13
+ "release": "semantic-release",
14
+ "build": "npm run typecheck && bob build",
15
+ "codegen": "nitrogen --logLevel=\"debug\" && npm run build && node post-script.js"
16
+ },
17
+ "keywords": [
18
+ "react-native",
19
+ "munim-wifi"
20
+ ],
21
+ "files": [
22
+ "src",
23
+ "react-native.config.js",
24
+ "lib",
25
+ "nitrogen",
26
+ "cpp",
27
+ "nitro.json",
28
+ "android/build.gradle",
29
+ "android/fix-prefab.gradle",
30
+ "android/gradle.properties",
31
+ "android/CMakeLists.txt",
32
+ "android/src",
33
+ "ios/**/*.h",
34
+ "ios/**/*.m",
35
+ "ios/**/*.mm",
36
+ "ios/**/*.cpp",
37
+ "ios/**/*.swift",
38
+ "app.plugin.js",
39
+ "*.podspec",
40
+ "README.md"
41
+ ],
42
+ "workspaces": [
43
+ "example"
44
+ ],
45
+ "repository": "https://github.com/munimtechnologies/munim-wifi.git",
46
+ "author": "sheehanmunim",
47
+ "license": "MIT",
48
+ "bugs": "https://github.com/munimtechnologies/munim-wifi/issues",
49
+ "homepage": "https://github.com/munimtechnologies/munim-wifi#readme",
50
+ "publishConfig": {
51
+ "access": "public",
52
+ "registry": "https://registry.npmjs.org/"
53
+ },
54
+ "devDependencies": {
55
+ "@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
56
+ "@semantic-release/changelog": "^6.0.3",
57
+ "@semantic-release/git": "^10.0.1",
58
+ "@types/jest": "^29.5.12",
59
+ "@types/react": "19.2.0",
60
+ "nitrogen": "0.33.2",
61
+ "react": "19.2.0",
62
+ "react-native": "0.83",
63
+ "react-native-builder-bob": "^0.40.17",
64
+ "react-native-nitro-modules": "0.33.2",
65
+ "conventional-changelog-conventionalcommits": "^9.1.0",
66
+ "semantic-release": "^25.0.2",
67
+ "typescript": "^5.8.3"
68
+ },
69
+ "peerDependencies": {
70
+ "react": "*",
71
+ "react-native": "*",
72
+ "react-native-nitro-modules": "*"
73
+ },
74
+ "eslintConfig": {
75
+ "root": true,
76
+ "extends": [
77
+ "@react-native",
78
+ "prettier"
79
+ ],
80
+ "plugins": [
81
+ "prettier"
82
+ ],
83
+ "rules": {
84
+ "prettier/prettier": [
85
+ "warn",
86
+ {
87
+ "quoteProps": "consistent",
88
+ "singleQuote": true,
89
+ "tabWidth": 2,
90
+ "trailingComma": "es5",
91
+ "useTabs": false
92
+ }
93
+ ]
94
+ }
95
+ },
96
+ "eslintIgnore": [
97
+ "node_modules/",
98
+ "lib/"
99
+ ],
100
+ "prettier": {
101
+ "quoteProps": "consistent",
102
+ "singleQuote": true,
103
+ "tabWidth": 2,
104
+ "trailingComma": "es5",
105
+ "useTabs": false,
106
+ "semi": false
107
+ },
108
+ "react-native-builder-bob": {
109
+ "source": "src",
110
+ "output": "lib",
111
+ "targets": [
112
+ "commonjs",
113
+ "module",
114
+ [
115
+ "typescript",
116
+ {
117
+ "project": "tsconfig.json"
118
+ }
119
+ ]
120
+ ]
121
+ }
122
+ }
package/src/index.ts ADDED
@@ -0,0 +1,221 @@
1
+ import { NitroModules } from 'react-native-nitro-modules'
2
+ import { NativeEventEmitter, NativeModules } from 'react-native'
3
+ import type {
4
+ MunimWifi as MunimWifiSpec,
5
+ WifiNetwork,
6
+ WifiFingerprint,
7
+ ScanOptions,
8
+ ChannelInfo,
9
+ Location,
10
+ } from './specs/munim-wifi.nitro'
11
+
12
+ const MunimWifi =
13
+ NitroModules.createHybridObject<MunimWifiSpec>('MunimWifi')
14
+
15
+ // Event Emitter for Wi-Fi events
16
+ const { MunimWifiEventEmitter } = NativeModules
17
+
18
+ let eventEmitter: NativeEventEmitter | null = null
19
+
20
+ if (MunimWifiEventEmitter) {
21
+ try {
22
+ eventEmitter = new NativeEventEmitter(MunimWifiEventEmitter)
23
+ } catch (error) {
24
+ console.error(
25
+ '[munim-wifi] Failed to initialize event emitter:',
26
+ error
27
+ )
28
+ }
29
+ }
30
+
31
+ // ========== Wi-Fi Functions ==========
32
+
33
+ /**
34
+ * Check if Wi-Fi is enabled on the device.
35
+ *
36
+ * @returns Promise resolving to true if Wi-Fi is enabled, false otherwise.
37
+ */
38
+ export function isWifiEnabled(): Promise<boolean> {
39
+ return MunimWifi.isWifiEnabled()
40
+ }
41
+
42
+ /**
43
+ * Request Wi-Fi permissions (Android) or check authorization status (iOS).
44
+ * On Android, this requests location permission which is required for Wi-Fi scanning.
45
+ * On iOS, this checks location authorization status.
46
+ *
47
+ * @returns Promise resolving to true if permissions are granted, false otherwise.
48
+ */
49
+ export function requestWifiPermission(): Promise<boolean> {
50
+ return MunimWifi.requestWifiPermission()
51
+ }
52
+
53
+ /**
54
+ * Scan for nearby Wi-Fi networks.
55
+ *
56
+ * @param options - Optional scan configuration including max results and timeout.
57
+ * @returns Promise resolving to array of discovered Wi-Fi networks.
58
+ */
59
+ export function scanNetworks(options?: ScanOptions): Promise<WifiNetwork[]> {
60
+ return MunimWifi.scanNetworks(options)
61
+ }
62
+
63
+ /**
64
+ * Start continuous Wi-Fi scanning. Results will be emitted via events.
65
+ *
66
+ * @param options - Optional scan configuration.
67
+ */
68
+ export function startScan(options?: ScanOptions): void {
69
+ return MunimWifi.startScan(options)
70
+ }
71
+
72
+ /**
73
+ * Stop continuous Wi-Fi scanning.
74
+ */
75
+ export function stopScan(): void {
76
+ return MunimWifi.stopScan()
77
+ }
78
+
79
+ /**
80
+ * Get list of SSIDs (network names) from the last scan.
81
+ *
82
+ * @returns Promise resolving to array of SSID strings.
83
+ */
84
+ export function getSSIDs(): Promise<string[]> {
85
+ return MunimWifi.getSSIDs()
86
+ }
87
+
88
+ /**
89
+ * Get Wi-Fi fingerprint containing all network information.
90
+ * This includes SSIDs, BSSIDs, RSSI, channels, and frequencies.
91
+ *
92
+ * @returns Promise resolving to Wi-Fi fingerprint data.
93
+ */
94
+ export function getWifiFingerprint(): Promise<WifiFingerprint> {
95
+ return MunimWifi.getWifiFingerprint()
96
+ }
97
+
98
+ /**
99
+ * Get RSSI (signal strength) for a specific network by SSID.
100
+ *
101
+ * @param ssid - The SSID of the network.
102
+ * @returns Promise resolving to RSSI value in dBm, or null if network not found.
103
+ */
104
+ export function getRSSI(ssid: string): Promise<number | null> {
105
+ return MunimWifi.getRSSI(ssid)
106
+ }
107
+
108
+ /**
109
+ * Get BSSID (MAC address) for a specific network by SSID.
110
+ *
111
+ * @param ssid - The SSID of the network.
112
+ * @returns Promise resolving to BSSID string, or null if network not found.
113
+ */
114
+ export function getBSSID(ssid: string): Promise<string | null> {
115
+ return MunimWifi.getBSSID(ssid)
116
+ }
117
+
118
+ /**
119
+ * Get channel and frequency information for a specific network by SSID.
120
+ *
121
+ * @param ssid - The SSID of the network.
122
+ * @returns Promise resolving to object with channel and frequency, or null if network not found.
123
+ */
124
+ export function getChannelInfo(ssid: string): Promise<ChannelInfo | null> {
125
+ return MunimWifi.getChannelInfo(ssid)
126
+ }
127
+
128
+ /**
129
+ * Get all available information for a specific network by SSID.
130
+ *
131
+ * @param ssid - The SSID of the network.
132
+ * @returns Promise resolving to WifiNetwork object, or null if network not found.
133
+ */
134
+ export function getNetworkInfo(ssid: string): Promise<WifiNetwork | null> {
135
+ return MunimWifi.getNetworkInfo(ssid)
136
+ }
137
+
138
+ // ========== Event Management ==========
139
+
140
+ /**
141
+ * Add a network found event listener (for continuous scanning).
142
+ *
143
+ * @param callback - Function to call when a network is found
144
+ * @returns A function to remove the listener
145
+ */
146
+ export function addNetworkFoundListener(
147
+ callback: (network: WifiNetwork) => void
148
+ ): () => void {
149
+ if (!eventEmitter) {
150
+ console.warn(
151
+ '[munim-wifi] Cannot add listener - event emitter not available'
152
+ )
153
+ return () => {}
154
+ }
155
+
156
+ const subscription = eventEmitter.addListener('networkFound', callback)
157
+ return () => subscription.remove()
158
+ }
159
+
160
+ /**
161
+ * Add an event listener.
162
+ *
163
+ * @param eventName - The name of the event to listen for.
164
+ * @param callback - The callback to invoke when the event occurs.
165
+ * @returns A function to remove the listener
166
+ */
167
+ export function addEventListener(
168
+ eventName: string,
169
+ callback: (data: any) => void
170
+ ): () => void {
171
+ if (!eventEmitter) {
172
+ console.warn(
173
+ '[munim-wifi] Cannot add listener - event emitter not available'
174
+ )
175
+ return () => {}
176
+ }
177
+
178
+ const subscription = eventEmitter.addListener(eventName, callback)
179
+ return () => subscription.remove()
180
+ }
181
+
182
+ /**
183
+ * Add an event listener (legacy method).
184
+ *
185
+ * @param eventName - The name of the event to listen for.
186
+ */
187
+ export function addListener(eventName: string): void {
188
+ return MunimWifi.addListener(eventName)
189
+ }
190
+
191
+ /**
192
+ * Remove event listeners.
193
+ *
194
+ * @param count - Number of listeners to remove.
195
+ */
196
+ export function removeListeners(count: number): void {
197
+ return MunimWifi.removeListeners(count)
198
+ }
199
+
200
+ // ========== Type Exports ==========
201
+
202
+ export type { WifiNetwork, WifiFingerprint, ScanOptions, ChannelInfo, Location }
203
+
204
+ // Default export for convenience
205
+ export default {
206
+ isWifiEnabled,
207
+ requestWifiPermission,
208
+ scanNetworks,
209
+ startScan,
210
+ stopScan,
211
+ getSSIDs,
212
+ getWifiFingerprint,
213
+ getRSSI,
214
+ getBSSID,
215
+ getChannelInfo,
216
+ getNetworkInfo,
217
+ addNetworkFoundListener,
218
+ addEventListener,
219
+ addListener,
220
+ removeListeners,
221
+ }
@@ -0,0 +1,140 @@
1
+ import { type HybridObject } from 'react-native-nitro-modules'
2
+
3
+ // Location information
4
+ export interface Location {
5
+ latitude?: number
6
+ longitude?: number
7
+ }
8
+
9
+ // Channel information
10
+ export interface ChannelInfo {
11
+ channel: number
12
+ frequency: number
13
+ }
14
+
15
+ // Wi-Fi Network information
16
+ export interface WifiNetwork {
17
+ ssid: string
18
+ bssid: string
19
+ rssi: number
20
+ frequency: number
21
+ channel?: number
22
+ capabilities?: string
23
+ isSecure?: boolean
24
+ timestamp?: number
25
+ }
26
+
27
+ // Wi-Fi Fingerprint data
28
+ export interface WifiFingerprint {
29
+ networks: WifiNetwork[]
30
+ timestamp: number
31
+ location?: Location
32
+ }
33
+
34
+ // Scan options
35
+ export interface ScanOptions {
36
+ maxResults?: number
37
+ timeout?: number
38
+ }
39
+
40
+ export interface MunimWifi
41
+ extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
42
+ /**
43
+ * Check if Wi-Fi is enabled on the device.
44
+ *
45
+ * @returns Promise resolving to true if Wi-Fi is enabled, false otherwise.
46
+ */
47
+ isWifiEnabled(): Promise<boolean>
48
+
49
+ /**
50
+ * Request Wi-Fi permissions (Android) or check authorization status (iOS).
51
+ * On Android, this requests location permission which is required for Wi-Fi scanning.
52
+ * On iOS, this checks location authorization status.
53
+ *
54
+ * @returns Promise resolving to true if permissions are granted, false otherwise.
55
+ */
56
+ requestWifiPermission(): Promise<boolean>
57
+
58
+ /**
59
+ * Scan for nearby Wi-Fi networks.
60
+ *
61
+ * @param options - Optional scan configuration including max results and timeout.
62
+ * @returns Promise resolving to array of discovered Wi-Fi networks.
63
+ */
64
+ scanNetworks(options?: ScanOptions): Promise<WifiNetwork[]>
65
+
66
+ /**
67
+ * Start continuous Wi-Fi scanning. Results will be emitted via events.
68
+ *
69
+ * @param options - Optional scan configuration.
70
+ */
71
+ startScan(options?: ScanOptions): void
72
+
73
+ /**
74
+ * Stop continuous Wi-Fi scanning.
75
+ */
76
+ stopScan(): void
77
+
78
+ /**
79
+ * Get list of SSIDs (network names) from the last scan.
80
+ *
81
+ * @returns Promise resolving to array of SSID strings.
82
+ */
83
+ getSSIDs(): Promise<string[]>
84
+
85
+ /**
86
+ * Get Wi-Fi fingerprint containing all network information.
87
+ * This includes SSIDs, BSSIDs, RSSI, channels, and frequencies.
88
+ *
89
+ * @returns Promise resolving to Wi-Fi fingerprint data.
90
+ */
91
+ getWifiFingerprint(): Promise<WifiFingerprint>
92
+
93
+ /**
94
+ * Get RSSI (signal strength) for a specific network by SSID.
95
+ *
96
+ * @param ssid - The SSID of the network.
97
+ * @returns Promise resolving to RSSI value in dBm, or null if network not found.
98
+ */
99
+ getRSSI(ssid: string): Promise<number | null>
100
+
101
+ /**
102
+ * Get BSSID (MAC address) for a specific network by SSID.
103
+ *
104
+ * @param ssid - The SSID of the network.
105
+ * @returns Promise resolving to BSSID string, or null if network not found.
106
+ */
107
+ getBSSID(ssid: string): Promise<string | null>
108
+
109
+ /**
110
+ * Get channel and frequency information for a specific network by SSID.
111
+ *
112
+ * @param ssid - The SSID of the network.
113
+ * @returns Promise resolving to object with channel and frequency, or null if network not found.
114
+ */
115
+ getChannelInfo(ssid: string): Promise<ChannelInfo | null>
116
+
117
+ /**
118
+ * Get all available information for a specific network by SSID.
119
+ *
120
+ * @param ssid - The SSID of the network.
121
+ * @returns Promise resolving to WifiNetwork object, or null if network not found.
122
+ */
123
+ getNetworkInfo(ssid: string): Promise<WifiNetwork | null>
124
+
125
+ // ========== Event Management ==========
126
+
127
+ /**
128
+ * Add an event listener for network found events (when using startScan).
129
+ *
130
+ * @param eventName - The name of the event to listen for.
131
+ */
132
+ addListener(eventName: string): void
133
+
134
+ /**
135
+ * Remove event listeners.
136
+ *
137
+ * @param count - Number of listeners to remove.
138
+ */
139
+ removeListeners(count: number): void
140
+ }