@amazon-devices/expo-network 2.0.9000000000 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.kepler.md CHANGED
@@ -94,7 +94,6 @@ Check out the dedicated documentation page for info about this library, API refe
94
94
  ## Known Issues
95
95
 
96
96
  * `Network.isAirplaneModeEnabledAsync()` - always returns false
97
- * `Network.getNetworkStateAsync()` - `isInternetReachable` field is always missing
98
97
  * `Network.getNetworkStateAsync()` - `type` field can only be either `NONE` or `WIFI`
99
98
 
100
99
  ## Supported Versions
@@ -102,3 +101,4 @@ Check out the dedicated documentation page for info about this library, API refe
102
101
  | Package version | Based on | @amazon-devices/react-native-kepler version |
103
102
  | ---------------- | -------- | --------------------------------- |
104
103
  | 2.0.x | expo-network v5.7.0 | 2.0.x |
104
+ | 2.0.x | expo-network v5.7.0 | 4.0.x+rn0.83.0 |
@@ -1,7 +1,7 @@
1
1
  import { TurboModuleRegistry } from '@amazon-devices/keplerscript-turbomodule-api';
2
2
  import { NetworkStateType } from './Network.types';
3
3
  export { NetworkStateType };
4
- const nativeModule = TurboModuleRegistry.getEnforcing('ExpoNetwork');
4
+ const nativeModule = TurboModuleRegistry.getEnforcing('ExpoNetworkAppTM');
5
5
  const networkStateNumberToType = (num) => {
6
6
  switch (num) {
7
7
  case 0:
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoNetwork.kepler.js","sourceRoot":"","sources":["../src/ExpoNetwork.kepler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAe,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAe,gBAAgB,EAAC,CAAC;AAYxC,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAO,aAAa,CAAS,CAAC;AAEnF,MAAM,wBAAwB,GAAG,CAAC,GAAW,EAAoB,EAAE;IAC/D,QAAQ,GAAG,EA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E,EAAE,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,mBAAmB,GAAG,KAAK,CAAC;YAC5B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACxB,CAAC;QAED,OAAO;YACH,IAAI,EAAE,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC;YAC1C,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,mBAAmB,EAAE,mBAAmB;SAC3C,CAAC;IACN,CAAC;IACD,KAAK,CAAC,iBAAiB;QACnB,OAAO,YAAY,CAAC,iBAAiB,EAAE,CAAC;IAC5C,CAAC;IACD,KAAK,CAAC,0BAA0B;QAC5B,OAAO,YAAY,CAAC,0BAA0B,EAAE,CAAC;IACrD,CAAC;CACJ,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import {KeplerTurboModule, TurboModuleRegistry} from '@amazon-devices/keplerscript-turbomodule-api';\nimport {NetworkState, NetworkStateType} from './Network.types';\n\nexport {NetworkState, NetworkStateType};\n\ntype NativeModuleNetworkState = {\n isConnected: boolean; isInternetReachable: boolean; type: number;\n};\n\ninterface Spec extends KeplerTurboModule {\n getNetworkStateAsync(): Promise<NativeModuleNetworkState>;\n getIpAddressAsync(): Promise<string>;\n isAirplaneModeEnabledAsync(): Promise<boolean>;\n}\n\nconst nativeModule = TurboModuleRegistry.getEnforcing<Spec>('ExpoNetwork') as Spec;\n\nconst networkStateNumberToType = (num: number): NetworkStateType => {\n switch (num) {\n case 0:\n return NetworkStateType.NONE;\n case 1:\n return NetworkStateType.UNKNOWN;\n case 2:\n return NetworkStateType.CELLULAR;\n case 3:\n return NetworkStateType.WIFI;\n case 4:\n return NetworkStateType.BLUETOOTH;\n case 5:\n return NetworkStateType.ETHERNET;\n case 6:\n return NetworkStateType.WIMAX;\n case 7:\n return NetworkStateType.VPN;\n case 8:\n return NetworkStateType.OTHER;\n default:\n return NetworkStateType.UNKNOWN;\n }\n};\n\nasync function fetchWithTimeout(url: string) {\n const controller = new AbortController();\n const id = setTimeout(() => controller.abort(), 800);\n\n const response = await fetch(url, {signal: controller.signal});\n clearTimeout(id);\n\n return response;\n}\n\nconst module = {\n async getNetworkStateAsync(): Promise<NetworkState> {\n const state = await nativeModule.getNetworkStateAsync();\n\n let dnsResponseReceived = false;\n try {\n const response = await fetchWithTimeout('https://dns.google/');\n dnsResponseReceived = !!response?.ok;\n } catch (error) {\n dnsResponseReceived = false;\n console.error(error)\n }\n\n return {\n type: networkStateNumberToType(state.type),\n isConnected: state.isConnected,\n isInternetReachable: dnsResponseReceived,\n };\n },\n async getIpAddressAsync(): Promise<string> {\n return nativeModule.getIpAddressAsync();\n },\n async isAirplaneModeEnabledAsync(): Promise<boolean> {\n return nativeModule.isAirplaneModeEnabledAsync();\n },\n};\n\nexport default module;\n"]}
1
+ {"version":3,"file":"ExpoNetwork.kepler.js","sourceRoot":"","sources":["../src/ExpoNetwork.kepler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAe,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAe,gBAAgB,EAAC,CAAC;AAYxC,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAO,kBAAkB,CAAS,CAAC;AAExF,MAAM,wBAAwB,GAAG,CAAC,GAAW,EAAoB,EAAE;IAC/D,QAAQ,GAAG,EAAE,CAAC;QACV,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAC,IAAI,CAAC;QACjC,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAC,OAAO,CAAC;QACpC,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAC,QAAQ,CAAC;QACrC,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAC,IAAI,CAAC;QACjC,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAC,SAAS,CAAC;QACtC,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAC,QAAQ,CAAC;QAC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AAY,CAAC,iBAAiB,EAAE,CAAC;IAC5C,CAAC;IACD,KAAK,CAAC,0BAA0B;QAC5B,OAAO,YAAY,CAAC,0BAA0B,EAAE,CAAC;IACrD,CAAC;CACJ,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import {KeplerTurboModule, TurboModuleRegistry} from '@amazon-devices/keplerscript-turbomodule-api';\nimport {NetworkState, NetworkStateType} from './Network.types';\n\nexport {NetworkState, NetworkStateType};\n\ntype NativeModuleNetworkState = {\n isConnected: boolean; isInternetReachable: boolean; type: number;\n};\n\ninterface Spec extends KeplerTurboModule {\n getNetworkStateAsync(): Promise<NativeModuleNetworkState>;\n getIpAddressAsync(): Promise<string>;\n isAirplaneModeEnabledAsync(): Promise<boolean>;\n}\n\nconst nativeModule = TurboModuleRegistry.getEnforcing<Spec>('ExpoNetworkAppTM') as Spec;\n\nconst networkStateNumberToType = (num: number): NetworkStateType => {\n switch (num) {\n case 0:\n return NetworkStateType.NONE;\n case 1:\n return NetworkStateType.UNKNOWN;\n case 2:\n return NetworkStateType.CELLULAR;\n case 3:\n return NetworkStateType.WIFI;\n case 4:\n return NetworkStateType.BLUETOOTH;\n case 5:\n return NetworkStateType.ETHERNET;\n case 6:\n return NetworkStateType.WIMAX;\n case 7:\n return NetworkStateType.VPN;\n case 8:\n return NetworkStateType.OTHER;\n default:\n return NetworkStateType.UNKNOWN;\n }\n};\n\nasync function fetchWithTimeout(url: string) {\n const controller = new AbortController();\n const id = setTimeout(() => controller.abort(), 800);\n\n const response = await fetch(url, {signal: controller.signal});\n clearTimeout(id);\n\n return response;\n}\n\nconst module = {\n async getNetworkStateAsync(): Promise<NetworkState> {\n const state = await nativeModule.getNetworkStateAsync();\n\n let dnsResponseReceived = false;\n try {\n const response = await fetchWithTimeout('https://dns.google/');\n dnsResponseReceived = !!response?.ok;\n } catch (error) {\n dnsResponseReceived = false;\n console.error(error)\n }\n\n return {\n type: networkStateNumberToType(state.type),\n isConnected: state.isConnected,\n isInternetReachable: dnsResponseReceived,\n };\n },\n async getIpAddressAsync(): Promise<string> {\n return nativeModule.getIpAddressAsync();\n },\n async isAirplaneModeEnabledAsync(): Promise<boolean> {\n return nativeModule.isAirplaneModeEnabledAsync();\n },\n};\n\nexport default module;\n"]}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@amazon-devices/expo-network", "version": "2.0.9000000000+5.7.0", "description": "Provides useful information about the device's network such as its IP address, MAC address, and airplane mode status", "main": "build/Network.js", "types": "build/Network.d.ts", "scripts": {"build": "expo-module build", "clean": "expo-module clean", "lint": "expo-module lint", "test": "expo-module test", "prepublishOnly": "expo-module prepublishOnly", "expo-module": "expo-module"}, "kepler": {"temporary-alias-for-package": {"name": "expo-network", "version": "5.7.0"}}, "keywords": ["react-native", "expo", "expo-network"], "repository": {"type": "git", "url": "https://github.com/expo/expo.git", "directory": "packages/expo-network"}, "bugs": {"url": "https://github.com/expo/expo/issues"}, "author": "650 Industries, Inc.", "license": "See license in LICENSE", "homepage": "https://docs.expo.dev/versions/latest/sdk/network/", "dependencies": {"@amazon-devices/keplerscript-turbomodule-api": "^1.0.0"}, "devDependencies": {"expo-module-scripts": "^3.0.0"}, "peerDependencies": {"expo": "*"}, "jest": {"preset": "expo-module-scripts"}}
1
+ {"name": "@amazon-devices/expo-network", "version": "3.0.0+5.7.0", "description": "Provides useful information about the device's network such as its IP address, MAC address, and airplane mode status", "main": "build/Network.js", "types": "build/Network.d.ts", "scripts": {"build": "expo-module build", "clean": "expo-module clean", "lint": "expo-module lint", "test": "expo-module test", "prepublishOnly": "expo-module prepublishOnly", "expo-module": "expo-module"}, "kepler": {"temporary-alias-for-package": {"name": "expo-network", "version": "5.7.0"}}, "keywords": ["react-native", "expo", "expo-network"], "repository": {"type": "git", "url": "https://github.com/expo/expo.git", "directory": "packages/expo-network"}, "bugs": {"url": "https://github.com/expo/expo/issues"}, "author": "650 Industries, Inc.", "license": "See license in LICENSE", "homepage": "https://docs.expo.dev/versions/latest/sdk/network/", "dependencies": {"@amazon-devices/keplerscript-turbomodule-api": "^1.0.0"}, "devDependencies": {"expo-module-scripts": "^3.0.0"}, "peerDependencies": {"react-native": "*", "expo": "^50.0.0-alpha.1"}, "jest": {"preset": "expo-module-scripts"}, "files": ["build", "lib", "react-native.config.js", "mocks"]}
@@ -10,9 +10,11 @@ module.exports = {
10
10
  platforms: {
11
11
  kepler: {
12
12
  autolink: {
13
- ExpoNetworkLib: {
14
- provider: 'system',
15
- turbomodules: ['ExpoNetwork'],
13
+ ExpoNetworkAppLib: {
14
+ provider: 'application',
15
+ linkDynamic: true,
16
+ libraryName: 'libexpo-network-3.so',
17
+ turbomodules: ['ExpoNetworkAppTM'],
16
18
  },
17
19
  },
18
20
  },
package/.eslintrc.js DELETED
@@ -1,2 +0,0 @@
1
- // @generated by expo-module-scripts
2
- module.exports = require('expo-module-scripts/eslintrc.base.js');
package/CHANGELOG.md DELETED
@@ -1,156 +0,0 @@
1
- # Changelog
2
-
3
- ## Unpublished
4
-
5
- ### 🛠 Breaking changes
6
-
7
- ### 🎉 New features
8
-
9
- ### 🐛 Bug fixes
10
-
11
- ### 💡 Others
12
-
13
- ## 5.7.0 — 2023-10-17
14
-
15
- ### 🛠 Breaking changes
16
-
17
- - Dropped support for Android SDK 21 and 22. ([#24201](https://github.com/expo/expo/pull/24201) by [@behenate](https://github.com/behenate))
18
-
19
- ### 🎉 New features
20
-
21
- - Add Node.js support. ([#24505](https://github.com/expo/expo/pull/24505) by [@EvanBacon](https://github.com/EvanBacon))
22
-
23
- ### 💡 Others
24
-
25
- - Remove deprecated `getMacAddressAsync` method. ([#24505](https://github.com/expo/expo/pull/24505) by [@EvanBacon](https://github.com/EvanBacon))
26
-
27
- ## 5.6.0 — 2023-09-04
28
-
29
- ### 🎉 New features
30
-
31
- - Added support for React Native 0.73. ([#24018](https://github.com/expo/expo/pull/24018) by [@kudo](https://github.com/kudo))
32
-
33
- ## 5.5.0 — 2023-08-02
34
-
35
- _This version does not introduce any user-facing changes._
36
-
37
- ## 5.4.0 — 2023-06-21
38
-
39
- ### 🐛 Bug fixes
40
-
41
- - Fixed Android build warnings for Gradle version 8. ([#22537](https://github.com/expo/expo/pull/22537), [#22609](https://github.com/expo/expo/pull/22609) by [@kudo](https://github.com/kudo))
42
-
43
- ## 5.3.0 — 2023-05-08
44
-
45
- _This version does not introduce any user-facing changes._
46
-
47
- ## 5.2.1 — 2023-02-09
48
-
49
- _This version does not introduce any user-facing changes._
50
-
51
- ## 5.2.0 — 2023-02-03
52
-
53
- ### 💡 Others
54
-
55
- - On Android bump `compileSdkVersion` and `targetSdkVersion` to `33`. ([#20721](https://github.com/expo/expo/pull/20721) by [@lukmccall](https://github.com/lukmccall))
56
-
57
- ## 5.1.0 — 2022-12-30
58
-
59
- ### 🎉 New features
60
-
61
- - Migrated to Expo Modules API. ([#20083](https://github.com/expo/expo/pull/20083) and [#20303](https://github.com/expo/expo/pull/20303) by [@alanhughes](https://github.com/alanjhughes))
62
-
63
- ## 5.0.0 — 2022-10-25
64
-
65
- ### 🛠 Breaking changes
66
-
67
- - Bumped iOS deployment target to 13.0 and deprecated support for iOS 12. ([#18873](https://github.com/expo/expo/pull/18873) by [@tsapeta](https://github.com/tsapeta))
68
-
69
- ## 4.3.0 — 2022-07-07
70
-
71
- _This version does not introduce any user-facing changes._
72
-
73
- ## 4.2.0 — 2022-04-18
74
-
75
- ### ⚠️ Notices
76
-
77
- - On Android bump `compileSdkVersion` to `31`, `targetSdkVersion` to `31` and `Java` version to `11`. ([#16941](https://github.com/expo/expo/pull/16941) by [@bbarthec](https://github.com/bbarthec))
78
-
79
- ## 4.1.1 - 2022-02-01
80
-
81
- ### 🐛 Bug fixes
82
-
83
- - Fix `Plugin with id 'maven' not found` build error from Android Gradle 7. ([#16080](https://github.com/expo/expo/pull/16080) by [@kudo](https://github.com/kudo))
84
-
85
- ## 4.1.0 — 2021-12-03
86
-
87
- _This version does not introduce any user-facing changes._
88
-
89
- ## 4.0.1 — 2021-10-01
90
-
91
- _This version does not introduce any user-facing changes._
92
-
93
- ## 4.0.0 — 2021-09-28
94
-
95
- ### 🛠 Breaking changes
96
-
97
- - Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach))
98
-
99
- ### 🐛 Bug fixes
100
-
101
- - Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
102
-
103
- ### 💡 Others
104
-
105
- - Migrated from `@unimodules/core` to `expo-modules-core`. ([#13757](https://github.com/expo/expo/pull/13757) by [@tsapeta](https://github.com/tsapeta))
106
- - Rewrite Android code to Kotlin. ([#14474](https://github.com/expo/expo/pull/14474) by [@kkafar](https://github.com/kkafar))
107
-
108
- ## 3.2.0 — 2021-06-16
109
-
110
- ### 🐛 Bug fixes
111
-
112
- - Enable kotlin in all modules. ([#12716](https://github.com/expo/expo/pull/12716) by [@wschurman](https://github.com/wschurman))
113
-
114
- ### 💡 Others
115
-
116
- - Build Android code using Java 8 to fix Android instrumented test build error. ([#12939](https://github.com/expo/expo/pull/12939) by [@kudo](https://github.com/kudo))
117
-
118
- ## 3.1.1 — 2021-03-30
119
-
120
- _This version does not introduce any user-facing changes._
121
-
122
- ## 3.1.0 — 2021-03-10
123
-
124
- ### 🎉 New features
125
-
126
- - Updated Android build configuration to target Android 11 (added support for Android SDK 30). ([#11647](https://github.com/expo/expo/pull/11647) by [@bbarthec](https://github.com/bbarthec))
127
-
128
- ### 🐛 Bug fixes
129
-
130
- - Remove peerDependencies and unimodulePeerDependencies from Expo modules. ([#11980](https://github.com/expo/expo/pull/11980) by [@brentvatne](https://github.com/brentvatne))
131
-
132
- ## 3.0.0 — 2021-01-15
133
-
134
- ### 🛠 Breaking changes
135
-
136
- - Dropped support for iOS 10.0 ([#11344](https://github.com/expo/expo/pull/11344) by [@tsapeta](https://github.com/tsapeta))
137
-
138
- ### 🐛 Bug fixes
139
-
140
- - Fixed issue on Android where apps would crash when calling `getIpAddressAsync` when using cellular data or on certain IP addresses.
141
-
142
- ## 2.4.0 — 2020-11-17
143
-
144
- _This version does not introduce any user-facing changes._
145
-
146
- ## 2.3.0 — 2020-08-18
147
-
148
- _This version does not introduce any user-facing changes._
149
-
150
- ## 2.2.1 — 2020-05-29
151
-
152
- _This version does not introduce any user-facing changes._
153
-
154
- ## 2.2.0 — 2020-05-27
155
-
156
- _This version does not introduce any user-facing changes._
package/CMakeLists.txt DELETED
@@ -1,50 +0,0 @@
1
- #
2
- # Copyright 2023 Amazon.com, Inc. or its affiliates. All rights reserved.
3
- #
4
- # AMAZON PROPRIETARY/CONFIDENTIAL
5
- #
6
- # You may not use this file except in compliance with the terms and conditions
7
- # set forth in the accompanying LICENSE.TXT file.
8
- #
9
- # THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
10
- # DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
11
- # IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
12
- # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
13
- #
14
- set(PACKAGE_NAME "expo-network")
15
- set(AUTO_LINK_PACKAGE_NAME "${PACKAGE_NAME}-${KEPLER_REACT_NATIVE_MAJOR_VERSION}")
16
- set(SOURCES_KEPLER
17
- kepler/ExpoNetwork.cpp
18
- kepler/NetworkInterfaces.cpp
19
- )
20
-
21
- add_library(${PACKAGE_NAME} STATIC ${SOURCES_KEPLER})
22
-
23
- target_link_libraries(
24
- ${PACKAGE_NAME}
25
- PUBLIC
26
- keplerui::keplerscript-${KEPLER_REACT_NATIVE_MAJOR_VERSION}
27
- )
28
-
29
- add_library(${AUTO_LINK_PACKAGE_NAME} SHARED kepler/KeplerInit.cpp)
30
-
31
- set_target_properties(${AUTO_LINK_PACKAGE_NAME} PROPERTIES SOVERSION ${KEPLER_REACT_NATIVE_MAJOR_VERSION}.${KEPLER_REACT_NATIVE_MINOR_VERSION})
32
-
33
- target_link_libraries(
34
- ${AUTO_LINK_PACKAGE_NAME}
35
- PRIVATE
36
- keplerui::keplerscript-${KEPLER_REACT_NATIVE_MAJOR_VERSION}
37
- ${PACKAGE_NAME}
38
- )
39
-
40
- # Helps in checking undefined references
41
- add_executable(${AUTO_LINK_PACKAGE_NAME}_exe kepler/KeplerInit.cpp)
42
- target_link_libraries(${AUTO_LINK_PACKAGE_NAME}_exe
43
- PRIVATE
44
- ${AUTO_LINK_PACKAGE_NAME}
45
- keplerui::keplerscript-${KEPLER_REACT_NATIVE_MAJOR_VERSION}
46
- )
47
-
48
- install(TARGETS ${AUTO_LINK_PACKAGE_NAME}
49
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
50
- )
@@ -1,4 +0,0 @@
1
- License from package.json:
2
- ==============================
3
-
4
- MIT
@@ -1,107 +0,0 @@
1
- apply plugin: 'com.android.library'
2
- apply plugin: 'kotlin-android'
3
- apply plugin: 'maven-publish'
4
-
5
- group = 'host.exp.exponent'
6
- version = '5.7.0'
7
-
8
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
- if (expoModulesCorePlugin.exists()) {
10
- apply from: expoModulesCorePlugin
11
- applyKotlinExpoModulesCorePlugin()
12
- // Remove this check, but keep the contents after SDK49 support is dropped
13
- if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
- useExpoPublishing()
15
- useCoreDependencies()
16
- }
17
- }
18
-
19
- buildscript {
20
- // Simple helper that allows the root project to override versions declared by this library.
21
- ext.safeExtGet = { prop, fallback ->
22
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
23
- }
24
-
25
- // Ensures backward compatibility
26
- ext.getKotlinVersion = {
27
- if (ext.has("kotlinVersion")) {
28
- ext.kotlinVersion()
29
- } else {
30
- ext.safeExtGet("kotlinVersion", "1.8.10")
31
- }
32
- }
33
-
34
- repositories {
35
- mavenCentral()
36
- }
37
-
38
- dependencies {
39
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
40
- }
41
- }
42
-
43
- // Remove this if and it's contents, when support for SDK49 is dropped
44
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
- afterEvaluate {
46
- publishing {
47
- publications {
48
- release(MavenPublication) {
49
- from components.release
50
- }
51
- }
52
- repositories {
53
- maven {
54
- url = mavenLocal().url
55
- }
56
- }
57
- }
58
- }
59
- }
60
-
61
- android {
62
- // Remove this if and it's contents, when support for SDK49 is dropped
63
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
- compileSdkVersion safeExtGet("compileSdkVersion", 33)
65
-
66
- defaultConfig {
67
- minSdkVersion safeExtGet("minSdkVersion", 23)
68
- targetSdkVersion safeExtGet("targetSdkVersion", 33)
69
- }
70
-
71
- publishing {
72
- singleVariant("release") {
73
- withSourcesJar()
74
- }
75
- }
76
-
77
- lintOptions {
78
- abortOnError false
79
- }
80
- }
81
-
82
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
83
- if (agpVersion.tokenize('.')[0].toInteger() < 8) {
84
- compileOptions {
85
- sourceCompatibility JavaVersion.VERSION_11
86
- targetCompatibility JavaVersion.VERSION_11
87
- }
88
-
89
- kotlinOptions {
90
- jvmTarget = JavaVersion.VERSION_11.majorVersion
91
- }
92
- }
93
-
94
- namespace "expo.modules.network"
95
- defaultConfig {
96
- versionCode 11
97
- versionName '5.7.0'
98
- }
99
- }
100
-
101
- dependencies {
102
- // Remove this if and it's contents, when support for SDK49 is dropped
103
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
104
- implementation project(':expo-modules-core')
105
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
106
- }
107
- }
@@ -1,4 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
3
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
4
- </manifest>
@@ -1,9 +0,0 @@
1
- package expo.modules.network
2
-
3
- import expo.modules.kotlin.exception.CodedException
4
-
5
- internal class NetworkAccessException(e: Exception) :
6
- CodedException("Unable to access network information", e.cause)
7
-
8
- internal class NetworkWifiException(e: Exception) :
9
- CodedException("Wi-Fi information could not be acquired", e.cause)
@@ -1,144 +0,0 @@
1
- package expo.modules.network
2
-
3
- import android.content.Context
4
- import android.net.ConnectivityManager
5
- import android.net.NetworkCapabilities
6
- import android.net.NetworkInfo
7
- import android.net.wifi.WifiInfo
8
- import android.net.wifi.WifiManager
9
- import android.os.Build
10
- import android.os.Bundle
11
- import android.provider.Settings
12
- import android.util.Log
13
- import expo.modules.kotlin.Promise
14
- import expo.modules.kotlin.exception.Exceptions
15
- import expo.modules.kotlin.modules.Module
16
- import expo.modules.kotlin.modules.ModuleDefinition
17
- import java.math.BigInteger
18
- import java.net.InetAddress
19
- import java.net.UnknownHostException
20
- import java.nio.ByteOrder
21
-
22
- private val TAG = NetworkModule::class.java.simpleName
23
-
24
- class NetworkModule : Module() {
25
- private val context: Context
26
- get() = appContext.reactContext ?: throw Exceptions.ReactContextLost()
27
-
28
- override fun definition() = ModuleDefinition {
29
- Name("ExpoNetwork")
30
-
31
- AsyncFunction("getNetworkStateAsync") { promise: Promise ->
32
- val result = Bundle()
33
- val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
34
-
35
- try {
36
- if (Build.VERSION.SDK_INT < 29) { // use getActiveNetworkInfo before api level 29
37
- val netInfo = connectivityManager.activeNetworkInfo
38
- val connectionType = getConnectionType(netInfo)
39
-
40
- result.apply {
41
- putBoolean("isInternetReachable", netInfo!!.isConnected)
42
- putString("type", connectionType.value)
43
- putBoolean("isConnected", connectionType.isDefined)
44
- }
45
-
46
- promise.resolve(result)
47
- } else {
48
- val network = connectivityManager.activeNetwork
49
- val isInternetReachable = network != null
50
-
51
- val connectionType = if (isInternetReachable) {
52
- val netCapabilities = connectivityManager.getNetworkCapabilities(network)
53
- getConnectionType(netCapabilities)
54
- } else {
55
- null
56
- }
57
-
58
- result.apply {
59
- putString("type", connectionType?.value ?: NetworkStateType.NONE.value)
60
- putBoolean("isInternetReachable", isInternetReachable)
61
- putBoolean("isConnected", connectionType != null && connectionType.isDefined)
62
- }
63
- promise.resolve(result)
64
- }
65
- } catch (e: Exception) {
66
- throw NetworkAccessException(e)
67
- }
68
- }
69
-
70
- AsyncFunction("getIpAddressAsync") {
71
- return@AsyncFunction rawIpToString(wifiInfo.ipAddress)
72
- }
73
-
74
- AsyncFunction("isAirplaneModeEnabledAsync") {
75
- return@AsyncFunction Settings.Global.getInt(context.contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0
76
- }
77
- }
78
-
79
- enum class NetworkStateType(val value: String) {
80
- NONE("NONE"),
81
- UNKNOWN("UNKNOWN"),
82
- CELLULAR("CELLULAR"),
83
- WIFI("WIFI"),
84
- BLUETOOTH("BLUETOOTH"),
85
- ETHERNET("ETHERNET"),
86
- WIMAX("WIMAX"),
87
- VPN("VPN"),
88
- OTHER("OTHER");
89
-
90
- val isDefined: Boolean
91
- get() = this.value != "NONE" && this.value != "UNKNOWN"
92
- }
93
-
94
- private val wifiInfo: WifiInfo
95
- get() = try {
96
- val manager = context.getSystemService(Context.WIFI_SERVICE) as WifiManager
97
- manager.connectionInfo
98
- } catch (e: Exception) {
99
- Log.e(TAG, e.message ?: "Wi-Fi information could not be acquired")
100
- throw NetworkWifiException(e)
101
- }
102
-
103
- private fun getConnectionType(netInfo: NetworkInfo?): NetworkStateType = when (netInfo?.type) {
104
- ConnectivityManager.TYPE_MOBILE,
105
- ConnectivityManager.TYPE_MOBILE_DUN -> NetworkStateType.CELLULAR
106
- ConnectivityManager.TYPE_WIFI -> NetworkStateType.WIFI
107
- ConnectivityManager.TYPE_BLUETOOTH -> NetworkStateType.BLUETOOTH
108
- ConnectivityManager.TYPE_ETHERNET -> NetworkStateType.ETHERNET
109
- ConnectivityManager.TYPE_WIMAX -> NetworkStateType.WIMAX
110
- ConnectivityManager.TYPE_VPN -> NetworkStateType.VPN
111
- else -> NetworkStateType.UNKNOWN
112
- }
113
-
114
- private fun getConnectionType(netCapabilities: NetworkCapabilities?): NetworkStateType =
115
- when {
116
- netCapabilities == null -> NetworkStateType.UNKNOWN
117
- netCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> NetworkStateType.CELLULAR
118
- netCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) || netCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI_AWARE) -> NetworkStateType.WIFI
119
- netCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH) -> NetworkStateType.BLUETOOTH
120
- netCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> NetworkStateType.ETHERNET
121
- netCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN) -> NetworkStateType.VPN
122
- else -> NetworkStateType.UNKNOWN
123
- }
124
-
125
- private fun rawIpToString(ipAddress: Int): String {
126
- // Convert little-endian to big-endian if needed
127
- val ip = if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
128
- Integer.reverseBytes(ipAddress)
129
- } else {
130
- ipAddress
131
- }
132
-
133
- var ipByteArray = BigInteger.valueOf(ip.toLong()).toByteArray()
134
- if (ipByteArray.size < 4) {
135
- ipByteArray = frontPadWithZeros(ipByteArray)
136
- }
137
-
138
- return try {
139
- InetAddress.getByAddress(ipByteArray).hostAddress as String
140
- } catch (e: UnknownHostException) {
141
- "0.0.0.0"
142
- }
143
- }
144
- }
@@ -1,7 +0,0 @@
1
- package expo.modules.network
2
-
3
- internal fun frontPadWithZeros(inputArray: ByteArray): ByteArray {
4
- val newByteArray = byteArrayOf(0, 0, 0, 0)
5
- System.arraycopy(inputArray, 0, newByteArray, 4 - inputArray.size, inputArray.size)
6
- return newByteArray
7
- }
@@ -1,10 +0,0 @@
1
- {
2
- "name": "expo-network",
3
- "platforms": ["ios", "android", "web"],
4
- "ios": {
5
- "modules": ["NetworkModule"]
6
- },
7
- "android": {
8
- "modules": ["expo.modules.network.NetworkModule"]
9
- }
10
- }
@@ -1,7 +0,0 @@
1
- import ExpoModulesCore
2
-
3
- internal class IpAddressException: GenericException<Int32> {
4
- override var reason: String {
5
- "No network interfaces could be retrieved. getifaddrs() failed with error number: \(param)"
6
- }
7
- }
@@ -1,31 +0,0 @@
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 = 'ExpoNetwork'
7
- s.version = package['version']
8
- s.summary = package['description']
9
- s.description = package['description']
10
- s.license = package['license']
11
- s.author = package['author']
12
- s.homepage = package['homepage']
13
- s.platform = :ios, '13.0'
14
- s.source = { git: 'https://github.com/expo/expo.git' }
15
- s.static_framework = true
16
-
17
- s.dependency 'ExpoModulesCore'
18
-
19
- # Swift/Objective-C compatibility
20
- s.pod_target_xcconfig = {
21
- 'DEFINES_MODULE' => 'YES',
22
- 'SWIFT_COMPILATION_MODE' => 'wholemodule'
23
- }
24
-
25
- if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
26
- s.source_files = "**/*.h"
27
- s.vendored_frameworks = "#{s.name}.xcframework"
28
- else
29
- s.source_files = "**/*.{h,m,swift}"
30
- end
31
- end