expo-network 5.6.0 → 5.7.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/CHANGELOG.md CHANGED
@@ -10,6 +10,20 @@
10
10
 
11
11
  ### 💡 Others
12
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
+
13
27
  ## 5.6.0 — 2023-09-04
14
28
 
15
29
  ### 🎉 New features
@@ -3,15 +3,20 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '5.6.0'
6
+ version = '5.7.0'
7
7
 
8
- buildscript {
9
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
10
- if (expoModulesCorePlugin.exists()) {
11
- apply from: expoModulesCorePlugin
12
- applyKotlinExpoModulesCorePlugin()
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()
13
16
  }
17
+ }
14
18
 
19
+ buildscript {
15
20
  // Simple helper that allows the root project to override versions declared by this library.
16
21
  ext.safeExtGet = { prop, fallback ->
17
22
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -35,23 +40,44 @@ buildscript {
35
40
  }
36
41
  }
37
42
 
38
- afterEvaluate {
39
- publishing {
40
- publications {
41
- release(MavenPublication) {
42
- from components.release
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
+ }
43
51
  }
44
- }
45
- repositories {
46
- maven {
47
- url = mavenLocal().url
52
+ repositories {
53
+ maven {
54
+ url = mavenLocal().url
55
+ }
48
56
  }
49
57
  }
50
58
  }
51
59
  }
52
60
 
53
61
  android {
54
- compileSdkVersion safeExtGet("compileSdkVersion", 33)
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
+ }
55
81
 
56
82
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
57
83
  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
@@ -67,23 +93,15 @@ android {
67
93
 
68
94
  namespace "expo.modules.network"
69
95
  defaultConfig {
70
- minSdkVersion safeExtGet("minSdkVersion", 21)
71
- targetSdkVersion safeExtGet("targetSdkVersion", 33)
72
96
  versionCode 11
73
- versionName '5.6.0'
74
- }
75
- lintOptions {
76
- abortOnError false
77
- }
78
- publishing {
79
- singleVariant("release") {
80
- withSourcesJar()
81
- }
97
+ versionName '5.7.0'
82
98
  }
83
99
  }
84
100
 
85
101
  dependencies {
86
- implementation project(':expo-modules-core')
87
-
88
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
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
+ }
89
107
  }
@@ -2,7 +2,6 @@ import { NetworkState } from './Network.types';
2
2
  declare const _default: {
3
3
  getIpAddressAsync(): Promise<string>;
4
4
  getNetworkStateAsync(): Promise<NetworkState>;
5
- getMacAddressAsync(): Promise<null>;
6
5
  };
7
6
  export default _default;
8
7
  //# sourceMappingURL=ExpoNetwork.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoNetwork.web.d.ts","sourceRoot":"","sources":["../src/ExpoNetwork.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,iBAAiB,CAAC;;yBAGpC,QAAQ,MAAM,CAAC;4BASZ,QAAQ,YAAY,CAAC;0BAUvB,QAAQ,IAAI,CAAC;;AApB3C,wBAuBE"}
1
+ {"version":3,"file":"ExpoNetwork.web.d.ts","sourceRoot":"","sources":["../src/ExpoNetwork.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,iBAAiB,CAAC;;yBAGpC,QAAQ,MAAM,CAAC;4BASZ,QAAQ,YAAY,CAAC;;AAVrD,wBAkBE"}
@@ -11,17 +11,12 @@ export default {
11
11
  }
12
12
  },
13
13
  async getNetworkStateAsync() {
14
- const type = navigator.onLine ? NetworkStateType.UNKNOWN : NetworkStateType.NONE;
15
- const isConnected = navigator.onLine;
16
- const isInternetReachable = isConnected;
14
+ const isOnline = typeof navigator !== 'undefined' && navigator.onLine;
17
15
  return {
18
- type,
19
- isConnected,
20
- isInternetReachable,
16
+ type: isOnline ? NetworkStateType.UNKNOWN : NetworkStateType.NONE,
17
+ isConnected: isOnline,
18
+ isInternetReachable: isOnline,
21
19
  };
22
20
  },
23
- async getMacAddressAsync() {
24
- return null;
25
- },
26
21
  };
27
22
  //# sourceMappingURL=ExpoNetwork.web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoNetwork.web.js","sourceRoot":"","sources":["../src/ExpoNetwork.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,eAAe;IACb,KAAK,CAAC,iBAAiB;QACrB,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,mCAAmC,CAAC,CAAC;YAC9D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,EAAE,CAAC;SAChB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IACD,KAAK,CAAC,oBAAoB;QACxB,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC;QACjF,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC;QACrC,MAAM,mBAAmB,GAAG,WAAW,CAAC;QACxC,OAAO;YACL,IAAI;YACJ,WAAW;YACX,mBAAmB;SACpB,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,kBAAkB;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC","sourcesContent":["import { NetworkState, NetworkStateType } from './Network.types';\n\nexport default {\n async getIpAddressAsync(): Promise<string> {\n try {\n const resp = await fetch('https://api.ipify.org?format=json');\n const data = await resp.json();\n return data.ip;\n } catch (e) {\n throw e;\n }\n },\n async getNetworkStateAsync(): Promise<NetworkState> {\n const type = navigator.onLine ? NetworkStateType.UNKNOWN : NetworkStateType.NONE;\n const isConnected = navigator.onLine;\n const isInternetReachable = isConnected;\n return {\n type,\n isConnected,\n isInternetReachable,\n };\n },\n async getMacAddressAsync(): Promise<null> {\n return null;\n },\n};\n"]}
1
+ {"version":3,"file":"ExpoNetwork.web.js","sourceRoot":"","sources":["../src/ExpoNetwork.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,eAAe;IACb,KAAK,CAAC,iBAAiB;QACrB,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,mCAAmC,CAAC,CAAC;YAC9D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,EAAE,CAAC;SAChB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IACD,KAAK,CAAC,oBAAoB;QACxB,MAAM,QAAQ,GAAG,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC;QACtE,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI;YACjE,WAAW,EAAE,QAAQ;YACrB,mBAAmB,EAAE,QAAQ;SAC9B,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { NetworkState, NetworkStateType } from './Network.types';\n\nexport default {\n async getIpAddressAsync(): Promise<string> {\n try {\n const resp = await fetch('https://api.ipify.org?format=json');\n const data = await resp.json();\n return data.ip;\n } catch (e) {\n throw e;\n }\n },\n async getNetworkStateAsync(): Promise<NetworkState> {\n const isOnline = typeof navigator !== 'undefined' && navigator.onLine;\n return {\n type: isOnline ? NetworkStateType.UNKNOWN : NetworkStateType.NONE,\n isConnected: isOnline,\n isInternetReachable: isOnline,\n };\n },\n};\n"]}
@@ -34,24 +34,6 @@ export declare function getNetworkStateAsync(): Promise<NetworkState>;
34
34
  * ```
35
35
  */
36
36
  export declare function getIpAddressAsync(): Promise<string>;
37
- /**
38
- * Gets the specified network interface's MAC address.
39
- *
40
- * > Beginning with iOS 7 and Android 11, non-system applications can no longer access the device's
41
- * MAC address. In SDK 41 and above, this method will always resolve to a predefined value that
42
- * isn't useful.
43
- *
44
- * If you need to identify the device, use the `getIosIdForVendorAsync()` method / `androidId`
45
- * property of the `expo-application` unimodule instead.
46
- *
47
- * @deprecated This method is deprecated and will be removed in a future SDK version.
48
- *
49
- * @param interfaceName A string representing interface name (`eth0`, `wlan0`) or `null` (default),
50
- * meaning the method should fetch the MAC address of the first available interface.
51
- *
52
- * @return A `Promise` that fulfils with the value `'02:00:00:00:00:00'`.
53
- */
54
- export declare function getMacAddressAsync(interfaceName?: string | null): Promise<string>;
55
37
  /**
56
38
  * Tells if the device is in airplane mode.
57
39
  * @return Returns a `Promise` that fulfils with a `boolean` value for whether the device is in
@@ -1 +1 @@
1
- {"version":3,"file":"Network.d.ts","sourceRoot":"","sources":["../src/Network.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAG1C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,YAAY,CAAC,CAKlE;AAGD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAKzD;AAGD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,kBAAkB,CAAC,aAAa,GAAE,MAAM,GAAG,IAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAK7F;AAGD;;;;;;;;;;;GAWG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC,CAKnE"}
1
+ {"version":3,"file":"Network.d.ts","sourceRoot":"","sources":["../src/Network.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAG1C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,YAAY,CAAC,CAKlE;AAGD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAKzD;AAGD;;;;;;;;;;;GAWG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC,CAKnE"}
package/build/Network.js CHANGED
@@ -49,28 +49,6 @@ export async function getIpAddressAsync() {
49
49
  return await ExpoNetwork.getIpAddressAsync();
50
50
  }
51
51
  // @needsAudit
52
- /**
53
- * Gets the specified network interface's MAC address.
54
- *
55
- * > Beginning with iOS 7 and Android 11, non-system applications can no longer access the device's
56
- * MAC address. In SDK 41 and above, this method will always resolve to a predefined value that
57
- * isn't useful.
58
- *
59
- * If you need to identify the device, use the `getIosIdForVendorAsync()` method / `androidId`
60
- * property of the `expo-application` unimodule instead.
61
- *
62
- * @deprecated This method is deprecated and will be removed in a future SDK version.
63
- *
64
- * @param interfaceName A string representing interface name (`eth0`, `wlan0`) or `null` (default),
65
- * meaning the method should fetch the MAC address of the first available interface.
66
- *
67
- * @return A `Promise` that fulfils with the value `'02:00:00:00:00:00'`.
68
- */
69
- export async function getMacAddressAsync(interfaceName = null) {
70
- console.warn('Network.getMacAddressAsync has been deprecated and will be removed in a future SDK version. To uniquely identify a device, use the expo-application module instead.');
71
- return '02:00:00:00:00:00';
72
- }
73
- // @needsAudit
74
52
  /**
75
53
  * Tells if the device is in airplane mode.
76
54
  * @return Returns a `Promise` that fulfils with a `boolean` value for whether the device is in
@@ -1 +1 @@
1
- {"version":3,"file":"Network.js","sourceRoot":"","sources":["../src/Network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAgB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAgB,gBAAgB,EAAE,CAAC;AAE1C,cAAc;AACd;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE;QACrC,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;KACvE;IACD,OAAO,MAAM,WAAW,CAAC,oBAAoB,EAAE,CAAC;AAClD,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE;QAClC,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;KACpE;IACD,OAAO,MAAM,WAAW,CAAC,iBAAiB,EAAE,CAAC;AAC/C,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,gBAA+B,IAAI;IAC1E,OAAO,CAAC,IAAI,CACV,qKAAqK,CACtK,CAAC;IACF,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,cAAc;AACd;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,IAAI,CAAC,WAAW,CAAC,0BAA0B,EAAE;QAC3C,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,4BAA4B,CAAC,CAAC;KAC7E;IACD,OAAO,MAAM,WAAW,CAAC,0BAA0B,EAAE,CAAC;AACxD,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoNetwork from './ExpoNetwork';\nimport { NetworkState, NetworkStateType } from './Network.types';\n\nexport { NetworkState, NetworkStateType };\n\n// @needsAudit\n/**\n * Gets the device's current network connection state.\n *\n * On web, `navigator.connection.type` is not available on browsers. So if there is an active\n * network connection, the field `type` returns `NetworkStateType.UNKNOWN`. Otherwise, it returns\n * `NetworkStateType.NONE`.\n * @return A `Promise` that fulfils with a `NetworkState` object.\n *\n * @example\n * ```ts\n * await Network.getNetworkStateAsync();\n * // {\n * // type: NetworkStateType.CELLULAR,\n * // isConnected: true,\n * // isInternetReachable: true,\n * // }\n * ```\n */\nexport async function getNetworkStateAsync(): Promise<NetworkState> {\n if (!ExpoNetwork.getNetworkStateAsync) {\n throw new UnavailabilityError('expo-network', 'getNetworkStateAsync');\n }\n return await ExpoNetwork.getNetworkStateAsync();\n}\n\n// @needsAudit\n/**\n * Gets the device's current IPv4 address. Returns `0.0.0.0` if the IP address could not be retrieved.\n *\n * On web, this method uses the third-party [`ipify service`](https://www.ipify.org/) to get the\n * public IP address of the current device.\n * @return A `Promise` that fulfils with a `string` of the current IP address of the device's main\n * network interface. Can only be IPv4 address.\n *\n * @example\n * ```ts\n * await Network.getIpAddressAsync();\n * // \"92.168.32.44\"\n * ```\n */\nexport async function getIpAddressAsync(): Promise<string> {\n if (!ExpoNetwork.getIpAddressAsync) {\n throw new UnavailabilityError('expo-network', 'getIpAddressAsync');\n }\n return await ExpoNetwork.getIpAddressAsync();\n}\n\n// @needsAudit\n/**\n * Gets the specified network interface's MAC address.\n *\n * > Beginning with iOS 7 and Android 11, non-system applications can no longer access the device's\n * MAC address. In SDK 41 and above, this method will always resolve to a predefined value that\n * isn't useful.\n *\n * If you need to identify the device, use the `getIosIdForVendorAsync()` method / `androidId`\n * property of the `expo-application` unimodule instead.\n *\n * @deprecated This method is deprecated and will be removed in a future SDK version.\n *\n * @param interfaceName A string representing interface name (`eth0`, `wlan0`) or `null` (default),\n * meaning the method should fetch the MAC address of the first available interface.\n *\n * @return A `Promise` that fulfils with the value `'02:00:00:00:00:00'`.\n */\nexport async function getMacAddressAsync(interfaceName: string | null = null): Promise<string> {\n console.warn(\n 'Network.getMacAddressAsync has been deprecated and will be removed in a future SDK version. To uniquely identify a device, use the expo-application module instead.'\n );\n return '02:00:00:00:00:00';\n}\n\n// @needsAudit\n/**\n * Tells if the device is in airplane mode.\n * @return Returns a `Promise` that fulfils with a `boolean` value for whether the device is in\n * airplane mode or not.\n * @platform android\n *\n * @example\n * ```ts\n * await Network.isAirplaneModeEnabledAsync();\n * // false\n * ```\n */\nexport async function isAirplaneModeEnabledAsync(): Promise<boolean> {\n if (!ExpoNetwork.isAirplaneModeEnabledAsync) {\n throw new UnavailabilityError('expo-network', 'isAirplaneModeEnabledAsync');\n }\n return await ExpoNetwork.isAirplaneModeEnabledAsync();\n}\n"]}
1
+ {"version":3,"file":"Network.js","sourceRoot":"","sources":["../src/Network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAgB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAgB,gBAAgB,EAAE,CAAC;AAE1C,cAAc;AACd;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE;QACrC,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;KACvE;IACD,OAAO,MAAM,WAAW,CAAC,oBAAoB,EAAE,CAAC;AAClD,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE;QAClC,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;KACpE;IACD,OAAO,MAAM,WAAW,CAAC,iBAAiB,EAAE,CAAC;AAC/C,CAAC;AAED,cAAc;AACd;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,IAAI,CAAC,WAAW,CAAC,0BAA0B,EAAE;QAC3C,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,4BAA4B,CAAC,CAAC;KAC7E;IACD,OAAO,MAAM,WAAW,CAAC,0BAA0B,EAAE,CAAC;AACxD,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoNetwork from './ExpoNetwork';\nimport { NetworkState, NetworkStateType } from './Network.types';\n\nexport { NetworkState, NetworkStateType };\n\n// @needsAudit\n/**\n * Gets the device's current network connection state.\n *\n * On web, `navigator.connection.type` is not available on browsers. So if there is an active\n * network connection, the field `type` returns `NetworkStateType.UNKNOWN`. Otherwise, it returns\n * `NetworkStateType.NONE`.\n * @return A `Promise` that fulfils with a `NetworkState` object.\n *\n * @example\n * ```ts\n * await Network.getNetworkStateAsync();\n * // {\n * // type: NetworkStateType.CELLULAR,\n * // isConnected: true,\n * // isInternetReachable: true,\n * // }\n * ```\n */\nexport async function getNetworkStateAsync(): Promise<NetworkState> {\n if (!ExpoNetwork.getNetworkStateAsync) {\n throw new UnavailabilityError('expo-network', 'getNetworkStateAsync');\n }\n return await ExpoNetwork.getNetworkStateAsync();\n}\n\n// @needsAudit\n/**\n * Gets the device's current IPv4 address. Returns `0.0.0.0` if the IP address could not be retrieved.\n *\n * On web, this method uses the third-party [`ipify service`](https://www.ipify.org/) to get the\n * public IP address of the current device.\n * @return A `Promise` that fulfils with a `string` of the current IP address of the device's main\n * network interface. Can only be IPv4 address.\n *\n * @example\n * ```ts\n * await Network.getIpAddressAsync();\n * // \"92.168.32.44\"\n * ```\n */\nexport async function getIpAddressAsync(): Promise<string> {\n if (!ExpoNetwork.getIpAddressAsync) {\n throw new UnavailabilityError('expo-network', 'getIpAddressAsync');\n }\n return await ExpoNetwork.getIpAddressAsync();\n}\n\n// @needsAudit\n/**\n * Tells if the device is in airplane mode.\n * @return Returns a `Promise` that fulfils with a `boolean` value for whether the device is in\n * airplane mode or not.\n * @platform android\n *\n * @example\n * ```ts\n * await Network.isAirplaneModeEnabledAsync();\n * // false\n * ```\n */\nexport async function isAirplaneModeEnabledAsync(): Promise<boolean> {\n if (!ExpoNetwork.isAirplaneModeEnabledAsync) {\n throw new UnavailabilityError('expo-network', 'isAirplaneModeEnabledAsync');\n }\n return await ExpoNetwork.isAirplaneModeEnabledAsync();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-network",
3
- "version": "5.6.0",
3
+ "version": "5.7.0",
4
4
  "description": "Provides useful information about the device's network such as its IP address, MAC address, and airplane mode status",
5
5
  "main": "build/Network.js",
6
6
  "types": "build/Network.d.ts",
@@ -36,5 +36,5 @@
36
36
  "peerDependencies": {
37
37
  "expo": "*"
38
38
  },
39
- "gitHead": "79607a7325f47aa17c36d266100d09a4ff2cc544"
39
+ "gitHead": "da25937e2a99661cbe5eb60ca1d8d6245fc96a50"
40
40
  }
@@ -11,16 +11,11 @@ export default {
11
11
  }
12
12
  },
13
13
  async getNetworkStateAsync(): Promise<NetworkState> {
14
- const type = navigator.onLine ? NetworkStateType.UNKNOWN : NetworkStateType.NONE;
15
- const isConnected = navigator.onLine;
16
- const isInternetReachable = isConnected;
14
+ const isOnline = typeof navigator !== 'undefined' && navigator.onLine;
17
15
  return {
18
- type,
19
- isConnected,
20
- isInternetReachable,
16
+ type: isOnline ? NetworkStateType.UNKNOWN : NetworkStateType.NONE,
17
+ isConnected: isOnline,
18
+ isInternetReachable: isOnline,
21
19
  };
22
20
  },
23
- async getMacAddressAsync(): Promise<null> {
24
- return null;
25
- },
26
21
  };
package/src/Network.ts CHANGED
@@ -53,31 +53,6 @@ export async function getIpAddressAsync(): Promise<string> {
53
53
  return await ExpoNetwork.getIpAddressAsync();
54
54
  }
55
55
 
56
- // @needsAudit
57
- /**
58
- * Gets the specified network interface's MAC address.
59
- *
60
- * > Beginning with iOS 7 and Android 11, non-system applications can no longer access the device's
61
- * MAC address. In SDK 41 and above, this method will always resolve to a predefined value that
62
- * isn't useful.
63
- *
64
- * If you need to identify the device, use the `getIosIdForVendorAsync()` method / `androidId`
65
- * property of the `expo-application` unimodule instead.
66
- *
67
- * @deprecated This method is deprecated and will be removed in a future SDK version.
68
- *
69
- * @param interfaceName A string representing interface name (`eth0`, `wlan0`) or `null` (default),
70
- * meaning the method should fetch the MAC address of the first available interface.
71
- *
72
- * @return A `Promise` that fulfils with the value `'02:00:00:00:00:00'`.
73
- */
74
- export async function getMacAddressAsync(interfaceName: string | null = null): Promise<string> {
75
- console.warn(
76
- 'Network.getMacAddressAsync has been deprecated and will be removed in a future SDK version. To uniquely identify a device, use the expo-application module instead.'
77
- );
78
- return '02:00:00:00:00:00';
79
- }
80
-
81
56
  // @needsAudit
82
57
  /**
83
58
  * Tells if the device is in airplane mode.