team202-wifi-scanner 1.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.
- package/LICENSE +20 -0
- package/README.md +37 -0
- package/WifiScanner.podspec +20 -0
- package/android/build.gradle +67 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/com/wifiscanner/WifiScannerModule.kt +68 -0
- package/android/src/main/java/com/wifiscanner/WifiScannerPackage.kt +31 -0
- package/ios/WifiScanner.h +5 -0
- package/ios/WifiScanner.mm +21 -0
- package/lib/module/NativeWifiScanner.js +5 -0
- package/lib/module/NativeWifiScanner.js.map +1 -0
- package/lib/module/index.js +21 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/multiply.js +6 -0
- package/lib/module/multiply.js.map +1 -0
- package/lib/module/multiply.native.js +7 -0
- package/lib/module/multiply.native.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeWifiScanner.d.ts +7 -0
- package/lib/typescript/src/NativeWifiScanner.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/multiply.d.ts +2 -0
- package/lib/typescript/src/multiply.d.ts.map +1 -0
- package/lib/typescript/src/multiply.native.d.ts +2 -0
- package/lib/typescript/src/multiply.native.d.ts.map +1 -0
- package/package.json +175 -0
- package/src/NativeWifiScanner.ts +7 -0
- package/src/index.tsx +28 -0
- package/src/multiply.native.tsx +5 -0
- package/src/multiply.tsx +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 misslyslone
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# wifi-scanner
|
|
2
|
+
|
|
3
|
+
scanne les wifi environnant
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install wifi-scanner
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { multiply } from 'wifi-scanner';
|
|
18
|
+
|
|
19
|
+
// ...
|
|
20
|
+
|
|
21
|
+
const result = multiply(3, 7);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
- [Development workflow](CONTRIBUTING.md#development-workflow)
|
|
28
|
+
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
29
|
+
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "WifiScanner"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/misslyslone/wifi-scanner.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
|
|
19
|
+
install_modules_dependencies(s)
|
|
20
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.WifiScanner = [
|
|
3
|
+
kotlinVersion: "2.0.21",
|
|
4
|
+
minSdkVersion: 24,
|
|
5
|
+
compileSdkVersion: 36,
|
|
6
|
+
targetSdkVersion: 36
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
ext.getExtOrDefault = { prop ->
|
|
10
|
+
if (rootProject.ext.has(prop)) {
|
|
11
|
+
return rootProject.ext.get(prop)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return WifiScanner[prop]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
repositories {
|
|
18
|
+
google()
|
|
19
|
+
mavenCentral()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
dependencies {
|
|
23
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
24
|
+
// noinspection DifferentKotlinGradleVersion
|
|
25
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
apply plugin: "com.android.library"
|
|
31
|
+
apply plugin: "kotlin-android"
|
|
32
|
+
|
|
33
|
+
apply plugin: "com.facebook.react"
|
|
34
|
+
|
|
35
|
+
android {
|
|
36
|
+
namespace "com.wifiscanner"
|
|
37
|
+
|
|
38
|
+
compileSdkVersion getExtOrDefault("compileSdkVersion")
|
|
39
|
+
|
|
40
|
+
defaultConfig {
|
|
41
|
+
minSdkVersion getExtOrDefault("minSdkVersion")
|
|
42
|
+
targetSdkVersion getExtOrDefault("targetSdkVersion")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
buildFeatures {
|
|
46
|
+
buildConfig true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
buildTypes {
|
|
50
|
+
release {
|
|
51
|
+
minifyEnabled false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
lint {
|
|
56
|
+
disable "GradleCompatible"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
compileOptions {
|
|
60
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
61
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
dependencies {
|
|
66
|
+
implementation "com.facebook.react:react-android"
|
|
67
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
3
|
+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
|
4
|
+
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
|
5
|
+
</manifest>
|
|
6
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
package com.wifiscanner
|
|
2
|
+
|
|
3
|
+
import android.content.BroadcastReceiver
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import android.content.IntentFilter
|
|
7
|
+
import android.net.wifi.WifiManager
|
|
8
|
+
import com.facebook.react.bridge.*
|
|
9
|
+
|
|
10
|
+
class WifiScannerModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
11
|
+
|
|
12
|
+
private val wifiManager = reactContext.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
|
13
|
+
private var promise: Promise? = null
|
|
14
|
+
|
|
15
|
+
override fun getName(): String {
|
|
16
|
+
return "WifiScanner"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Déclaration de la méthode accessible depuis le code JavaScript
|
|
20
|
+
@ReactMethod
|
|
21
|
+
fun scanWifiNetworks(promise: Promise) {
|
|
22
|
+
this.promise = promise
|
|
23
|
+
|
|
24
|
+
// Vérifier si le Wi-Fi est activé sur l'appareil
|
|
25
|
+
if (!wifiManager.isWifiEnabled) {
|
|
26
|
+
promise.reject("WIFI_DISABLED", "Le Wi-Fi est désactivé sur l'appareil.")
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Créer un écouteur (Receiver) pour récupérer les résultats du scan
|
|
31
|
+
val wifiScanReceiver = object : BroadcastReceiver() {
|
|
32
|
+
override fun onReceive(context: Context, intent: Intent) {
|
|
33
|
+
val success = intent.getBooleanExtra(WifiManager.EXTRA_RESULTS_UPDATED, false)
|
|
34
|
+
if (success) {
|
|
35
|
+
val results = wifiManager.scanResults
|
|
36
|
+
val array = Arguments.createArray()
|
|
37
|
+
|
|
38
|
+
// Parcourir les réseaux trouvés et formater les données pour JS
|
|
39
|
+
for (scanResult in results) {
|
|
40
|
+
val map = Arguments.createMap()
|
|
41
|
+
map.putString("ssid", scanResult.SSID)
|
|
42
|
+
map.putString("bssid", scanResult.BSSID)
|
|
43
|
+
map.putInt("level", scanResult.level) // Force du signal en dBm
|
|
44
|
+
array.pushMap(map)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Renvoyer les données à la promesse React Native
|
|
48
|
+
this@WifiScannerModule.promise?.resolve(array)
|
|
49
|
+
} else {
|
|
50
|
+
this@WifiScannerModule.promise?.reject("SCAN_FAILED", "Le scan Wi-Fi a échoué.")
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Toujours désenregistrer le receiver pour éviter les fuites de mémoire
|
|
54
|
+
reactApplicationContext.unregisterReceiver(this)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Enregistrer le receiver et démarrer le scan
|
|
59
|
+
val intentFilter = IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)
|
|
60
|
+
reactApplicationContext.registerReceiver(wifiScanReceiver, intentFilter)
|
|
61
|
+
|
|
62
|
+
val success = wifiManager.startScan()
|
|
63
|
+
if (!success) {
|
|
64
|
+
promise.reject("START_SCAN_FAILED", "Impossible de démarrer le scan Wi-Fi (Scan Throttling possible).")
|
|
65
|
+
reactApplicationContext.unregisterReceiver(wifiScanReceiver)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.wifiscanner
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class WifiScannerPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == WifiScannerModule.NAME) {
|
|
13
|
+
WifiScannerModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
|
|
20
|
+
mapOf(
|
|
21
|
+
WifiScannerModule.NAME to ReactModuleInfo(
|
|
22
|
+
name = WifiScannerModule.NAME,
|
|
23
|
+
className = WifiScannerModule.NAME,
|
|
24
|
+
canOverrideExistingModule = false,
|
|
25
|
+
needsEagerInit = false,
|
|
26
|
+
isCxxModule = false,
|
|
27
|
+
isTurboModule = true
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#import "WifiScanner.h"
|
|
2
|
+
|
|
3
|
+
@implementation WifiScanner
|
|
4
|
+
- (NSNumber *)multiply:(double)a b:(double)b {
|
|
5
|
+
NSNumber *result = @(a * b);
|
|
6
|
+
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
11
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
12
|
+
{
|
|
13
|
+
return std::make_shared<facebook::react::NativeWifiScannerSpecJSI>(params);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
+ (NSString *)moduleName
|
|
17
|
+
{
|
|
18
|
+
return @"WifiScanner";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"..\\..\\src","sources":["NativeWifiScanner.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;AAMpE,eAAeA,mBAAmB,CAACC,YAAY,CAAO,aAAa,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeModules, Platform } from 'react-native';
|
|
4
|
+
const LINKING_ERROR = `Le package 'wifi-scanner' n'est pas lié correctement. Assurez-vous de :\n\n` + '- Avoir reconstruit l\'application cible après l\'installation\n' + '- Ne pas utiliser Expo Go (le code natif nécessite Expo Prebuild ou React Native CLI)\n';
|
|
5
|
+
const WifiScanner = NativeModules.WifiScanner ? NativeModules.WifiScanner : new Proxy({}, {
|
|
6
|
+
get() {
|
|
7
|
+
throw new Error(LINKING_ERROR);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Scanne les réseaux Wi-Fi environnants (Android uniquement).
|
|
13
|
+
* @returns Une promesse contenant un tableau d'objets { ssid: string, bssid: string, level: number }
|
|
14
|
+
*/
|
|
15
|
+
export function scanWifiNetworks() {
|
|
16
|
+
if (Platform.OS !== 'android') {
|
|
17
|
+
return Promise.reject(new Error('Le scan Wi-Fi direct n\'est supporté que sur Android.'));
|
|
18
|
+
}
|
|
19
|
+
return WifiScanner.scanWifiNetworks();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","WifiScanner","Proxy","get","Error","scanWifiNetworks","OS","Promise","reject"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,6EAA6E,GAC7E,kEAAkE,GAClE,yFAAyF;AAE3F,MAAMC,WAAW,GAAGH,aAAa,CAACG,WAAW,GACzCH,aAAa,CAACG,WAAW,GACzB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACJ,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACA,OAAO,SAASK,gBAAgBA,CAAA,EAAmB;EACjD,IAAIN,QAAQ,CAACO,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAOC,OAAO,CAACC,MAAM,CAAC,IAAIJ,KAAK,CAAC,uDAAuD,CAAC,CAAC;EAC3F;EACA,OAAOH,WAAW,CAACI,gBAAgB,CAAC,CAAC;AACvC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["multiply","a","b"],"sourceRoot":"..\\..\\src","sources":["multiply.tsx"],"mappings":";;AAAA,OAAO,SAASA,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAU;EACrD,OAAOD,CAAC,GAAGC,CAAC;AACd","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WifiScanner","multiply","a","b"],"sourceRoot":"..\\..\\src","sources":["multiply.native.tsx"],"mappings":";;AAAA,OAAOA,WAAW,MAAM,wBAAqB;AAE7C,OAAO,SAASC,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAU;EACrD,OAAOH,WAAW,CAACC,QAAQ,CAACC,CAAC,EAAEC,CAAC,CAAC;AACnC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeWifiScanner.d.ts","sourceRoot":"","sources":["../../../src/NativeWifiScanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxC;;AAED,wBAAqE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scanne les réseaux Wi-Fi environnants (Android uniquement).
|
|
3
|
+
* @returns Une promesse contenant un tableau d'objets { ssid: string, bssid: string, level: number }
|
|
4
|
+
*/
|
|
5
|
+
export declare function scanWifiNetworks(): Promise<any[]>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAKjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiply.d.ts","sourceRoot":"","sources":["../../../src/multiply.tsx"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiply.native.d.ts","sourceRoot":"","sources":["../../../src/multiply.native.tsx"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "team202-wifi-scanner",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "scanne les wifi environnant",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace team202-wifi-scanner-example",
|
|
36
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
37
|
+
"prepare": "bob build",
|
|
38
|
+
"typecheck": "tsc",
|
|
39
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"release": "release-it --only-version",
|
|
42
|
+
"web": "vite",
|
|
43
|
+
"build:web": "vite build"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"react-native",
|
|
47
|
+
"ios",
|
|
48
|
+
"android"
|
|
49
|
+
],
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/misslyslone/wifi-scanner.git"
|
|
53
|
+
},
|
|
54
|
+
"author": "misslyslone <lyslone7@gmail.com> (https://github.com/misslyslone)",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/misslyslone/wifi-scanner/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/misslyslone/wifi-scanner#readme",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"registry": "https://registry.npmjs.org/"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@commitlint/config-conventional": "^21.0.2",
|
|
65
|
+
"@eslint/compat": "^2.1.0",
|
|
66
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
67
|
+
"@eslint/js": "^10.0.1",
|
|
68
|
+
"@jest/globals": "^29.7.0",
|
|
69
|
+
"@react-native/babel-preset": "0.85.0",
|
|
70
|
+
"@react-native/eslint-config": "0.85.0",
|
|
71
|
+
"@react-native/jest-preset": "0.85.0",
|
|
72
|
+
"@release-it/conventional-changelog": "^11.0.1",
|
|
73
|
+
"@types/react": "^19.2.0",
|
|
74
|
+
"commitlint": "^21.0.2",
|
|
75
|
+
"del-cli": "^7.0.0",
|
|
76
|
+
"eslint": "^9.39.4",
|
|
77
|
+
"eslint-config-prettier": "^10.1.8",
|
|
78
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
79
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
80
|
+
"jest": "^29.7.0",
|
|
81
|
+
"lefthook": "^2.1.9",
|
|
82
|
+
"prettier": "^3.8.3",
|
|
83
|
+
"react": "19.2.3",
|
|
84
|
+
"react-native": "0.85.0",
|
|
85
|
+
"react-native-builder-bob": "^0.41.0",
|
|
86
|
+
"react-native-web": "~0.21.2",
|
|
87
|
+
"release-it": "^20.2.0",
|
|
88
|
+
"turbo": "^2.9.16",
|
|
89
|
+
"typescript": "^6.0.3"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"react": "*",
|
|
93
|
+
"react-native": "*"
|
|
94
|
+
},
|
|
95
|
+
"workspaces": [
|
|
96
|
+
"example"
|
|
97
|
+
],
|
|
98
|
+
"packageManager": "yarn@4.11.0",
|
|
99
|
+
"react-native-builder-bob": {
|
|
100
|
+
"source": "src",
|
|
101
|
+
"output": "lib",
|
|
102
|
+
"targets": [
|
|
103
|
+
[
|
|
104
|
+
"module",
|
|
105
|
+
{
|
|
106
|
+
"esm": true
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
"typescript",
|
|
111
|
+
{
|
|
112
|
+
"project": "tsconfig.build.json"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"codegenConfig": {
|
|
118
|
+
"name": "WifiScannerSpec",
|
|
119
|
+
"type": "modules",
|
|
120
|
+
"jsSrcsDir": "src",
|
|
121
|
+
"android": {
|
|
122
|
+
"javaPackageName": "com.wifiscanner"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"prettier": {
|
|
126
|
+
"quoteProps": "consistent",
|
|
127
|
+
"singleQuote": true,
|
|
128
|
+
"tabWidth": 2,
|
|
129
|
+
"trailingComma": "es5",
|
|
130
|
+
"useTabs": false
|
|
131
|
+
},
|
|
132
|
+
"jest": {
|
|
133
|
+
"preset": "@react-native/jest-preset",
|
|
134
|
+
"modulePathIgnorePatterns": [
|
|
135
|
+
"<rootDir>/example/node_modules",
|
|
136
|
+
"<rootDir>/lib/"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"commitlint": {
|
|
140
|
+
"extends": [
|
|
141
|
+
"@commitlint/config-conventional"
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"release-it": {
|
|
145
|
+
"git": {
|
|
146
|
+
"commitMessage": "chore: release ${version}",
|
|
147
|
+
"tagName": "v${version}"
|
|
148
|
+
},
|
|
149
|
+
"npm": {
|
|
150
|
+
"publish": true
|
|
151
|
+
},
|
|
152
|
+
"github": {
|
|
153
|
+
"release": true
|
|
154
|
+
},
|
|
155
|
+
"plugins": {
|
|
156
|
+
"@release-it/conventional-changelog": {
|
|
157
|
+
"preset": {
|
|
158
|
+
"name": "angular"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"create-react-native-library": {
|
|
164
|
+
"type": "turbo-module",
|
|
165
|
+
"languages": "kotlin-objc",
|
|
166
|
+
"tools": [
|
|
167
|
+
"eslint",
|
|
168
|
+
"jest",
|
|
169
|
+
"lefthook",
|
|
170
|
+
"release-it",
|
|
171
|
+
"vite"
|
|
172
|
+
],
|
|
173
|
+
"version": "0.62.1"
|
|
174
|
+
}
|
|
175
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const LINKING_ERROR =
|
|
4
|
+
`Le package 'wifi-scanner' n'est pas lié correctement. Assurez-vous de :\n\n` +
|
|
5
|
+
'- Avoir reconstruit l\'application cible après l\'installation\n' +
|
|
6
|
+
'- Ne pas utiliser Expo Go (le code natif nécessite Expo Prebuild ou React Native CLI)\n';
|
|
7
|
+
|
|
8
|
+
const WifiScanner = NativeModules.WifiScanner
|
|
9
|
+
? NativeModules.WifiScanner
|
|
10
|
+
: new Proxy(
|
|
11
|
+
{},
|
|
12
|
+
{
|
|
13
|
+
get() {
|
|
14
|
+
throw new Error(LINKING_ERROR);
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Scanne les réseaux Wi-Fi environnants (Android uniquement).
|
|
21
|
+
* @returns Une promesse contenant un tableau d'objets { ssid: string, bssid: string, level: number }
|
|
22
|
+
*/
|
|
23
|
+
export function scanWifiNetworks(): Promise<any[]> {
|
|
24
|
+
if (Platform.OS !== 'android') {
|
|
25
|
+
return Promise.reject(new Error('Le scan Wi-Fi direct n\'est supporté que sur Android.'));
|
|
26
|
+
}
|
|
27
|
+
return WifiScanner.scanWifiNetworks();
|
|
28
|
+
}
|
package/src/multiply.tsx
ADDED