expo-device 5.0.0 → 5.2.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/build/Device.js CHANGED
@@ -2,41 +2,232 @@ import { UnavailabilityError } from 'expo-modules-core';
2
2
  import { DeviceType } from './Device.types';
3
3
  import ExpoDevice from './ExpoDevice';
4
4
  export { DeviceType };
5
+ /**
6
+ * `true` if the app is running on a real device and `false` if running in a simulator or emulator.
7
+ * On web, this is always set to `true`.
8
+ */
5
9
  export const isDevice = ExpoDevice ? ExpoDevice.isDevice : true;
10
+ /**
11
+ * The device brand. The consumer-visible brand of the product/hardware. On web, this value is always `null`.
12
+ *
13
+ * @example
14
+ * ```js
15
+ * Device.brand; // Android: "google", "xiaomi"; iOS: "Apple"; web: null
16
+ * ```
17
+ * @platform android
18
+ * @platform ios
19
+ */
6
20
  export const brand = ExpoDevice ? ExpoDevice.brand : null;
21
+ /**
22
+ * The actual device manufacturer of the product or hardware. This value of this field may be `null` if it cannot be determined.
23
+ *
24
+ * To view difference between `brand` and `manufacturer` on Android see [official documentation](https://developer.android.com/reference/android/os/Build).
25
+ *
26
+ * @example
27
+ * ```js
28
+ * Device.manufacturer; // Android: "Google", "xiaomi"; iOS: "Apple"; web: "Google", null
29
+ * ```
30
+ */
7
31
  export const manufacturer = ExpoDevice ? ExpoDevice.manufacturer : null;
32
+ /**
33
+ * The internal model ID of the device. This is useful for programmatically identifying the type of device and is not a human-friendly string.
34
+ * On web and Android, this value is always `null`.
35
+ *
36
+ * @example
37
+ * ```js
38
+ * Device.modelId; // iOS: "iPhone7,2"; Android: null; web: null
39
+ * ```
40
+ * @platform ios
41
+ */
8
42
  export const modelId = ExpoDevice ? ExpoDevice.modelId || null : null;
43
+ /**
44
+ * The human-friendly name of the device model. This is the name that people would typically use to refer to the device rather than a programmatic model identifier.
45
+ * This value of this field may be `null` if it cannot be determined.
46
+ *
47
+ * @example
48
+ * ```js
49
+ * Device.modelName; // Android: "Pixel 2"; iOS: "iPhone XS Max"; web: "iPhone", null
50
+ * ```
51
+ */
9
52
  export const modelName = ExpoDevice ? ExpoDevice.modelName : null;
53
+ /**
54
+ * The specific configuration or name of the industrial design. It represents the device's name when it was designed during manufacturing into mass production.
55
+ * On Android, it corresponds to [`Build.DEVICE`](https://developer.android.com/reference/android/os/Build#DEVICE). On web and iOS, this value is always `null`.
56
+ *
57
+ * @example
58
+ * ```js
59
+ * Device.designName; // Android: "kminilte"; iOS: null; web: null
60
+ * ```
61
+ * @platform android
62
+ */
10
63
  export const designName = ExpoDevice ? ExpoDevice.designName || null : null;
64
+ /**
65
+ * The device's overall product name chosen by the device implementer containing the development name or code name of the device.
66
+ * Corresponds to [`Build.PRODUCT`](https://developer.android.com/reference/android/os/Build#PRODUCT). On web and iOS, this value is always `null`.
67
+ *
68
+ * @example
69
+ * ```js
70
+ * Device.productName; // Android: "kminiltexx"; iOS: null; web: null
71
+ * ```
72
+ * @platform android
73
+ */
11
74
  export const productName = ExpoDevice ? ExpoDevice.productName || null : null;
75
+ /**
76
+ * The [device year class](https://github.com/facebook/device-year-class) of this device. On web, this value is always `null`.
77
+ */
12
78
  export const deviceYearClass = ExpoDevice ? ExpoDevice.deviceYearClass : null;
79
+ /**
80
+ * The device's total memory, in bytes. This is the total memory accessible to the kernel, but not necessarily to a single app.
81
+ * This is basically the amount of RAM the device has, not including below-kernel fixed allocations like DMA buffers, RAM for the baseband CPU, etc…
82
+ * On web, this value is always `null`.
83
+ *
84
+ * @example
85
+ * ```js
86
+ * Device.totalMemory; // 17179869184
87
+ * ```
88
+ */
13
89
  export const totalMemory = ExpoDevice ? ExpoDevice.totalMemory : null;
90
+ /**
91
+ * A list of supported processor architecture versions. The device expects the binaries it runs to be compiled for one of these architectures.
92
+ * This value is `null` if the supported architectures could not be determined, particularly on web.
93
+ *
94
+ * @example
95
+ * ```js
96
+ * Device.supportedCpuArchitectures; // ['arm64 v8', 'Intel x86-64h Haswell', 'arm64-v8a', 'armeabi-v7a", 'armeabi']
97
+ * ```
98
+ */
14
99
  export const supportedCpuArchitectures = ExpoDevice
15
100
  ? ExpoDevice.supportedCpuArchitectures
16
101
  : null;
102
+ /**
103
+ * The name of the OS running on the device.
104
+ *
105
+ * @example
106
+ * ```js
107
+ * Device.osName; // Android: "Android"; iOS: "iOS" or "iPadOS"; web: "iOS", "Android", "Windows"
108
+ * ```
109
+ */
17
110
  export const osName = ExpoDevice ? ExpoDevice.osName : null;
111
+ /**
112
+ * The human-readable OS version string. Note that the version string may not always contain three numbers separated by dots.
113
+ *
114
+ * @example
115
+ * ```js
116
+ * Device.osVersion; // Android: "4.0.3"; iOS: "12.3.1"; web: "11.0", "8.1.0"
117
+ * ```
118
+ */
18
119
  export const osVersion = ExpoDevice ? ExpoDevice.osVersion : null;
120
+ /**
121
+ * The build ID of the OS that more precisely identifies the version of the OS. On Android, this corresponds to `Build.DISPLAY` (not `Build.ID`)
122
+ * and currently is a string as described [here](https://source.android.com/setup/start/build-numbers). On iOS, this corresponds to `kern.osversion`
123
+ * and is the detailed OS version sometimes displayed next to the more human-readable version. On web, this value is always `null`.
124
+ *
125
+ * @example
126
+ * ```js
127
+ * Device.osBuildId; // Android: "PSR1.180720.075"; iOS: "16F203"; web: null
128
+ * ```
129
+ */
19
130
  export const osBuildId = ExpoDevice ? ExpoDevice.osBuildId : null;
131
+ /**
132
+ * The internal build ID of the OS running on the device. On Android, this corresponds to `Build.ID`.
133
+ * On iOS, this is the same value as [`Device.osBuildId`](#deviceosbuildid). On web, this value is always `null`.
134
+ *
135
+ * @example
136
+ * ```js
137
+ * Device.osInternalBuildId; // Android: "MMB29K"; iOS: "16F203"; web: null,
138
+ * ```
139
+ */
20
140
  export const osInternalBuildId = ExpoDevice ? ExpoDevice.osInternalBuildId : null;
141
+ /**
142
+ * A string that uniquely identifies the build of the currently running system OS. On Android, it follows this template:
143
+ * - `$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/\$(TAGS)`
144
+ * On web and iOS, this value is always `null`.
145
+ *
146
+ * @example
147
+ * ```js
148
+ * Device.osBuildFingerprint;
149
+ * // Android: "google/sdk_gphone_x86/generic_x86:9/PSR1.180720.075/5124027:user/release-keys";
150
+ * // iOS: null; web: null
151
+ * ```
152
+ * @platform android
153
+ */
21
154
  export const osBuildFingerprint = ExpoDevice
22
155
  ? ExpoDevice.osBuildFingerprint || null
23
156
  : null;
157
+ /**
158
+ * The Android SDK version of the software currently running on this hardware device. This value never changes while a device is booted,
159
+ * but it may increase when the hardware manufacturer provides an OS update. See [here](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html)
160
+ * to see all possible version codes and corresponding versions. On iOS and web, this value is always `null`.
161
+ *
162
+ * @example
163
+ * ```js
164
+ * Device.platformApiLevel; // Android: 19; iOS: null; web: null
165
+ * ```
166
+ * @platform android
167
+ */
24
168
  export const platformApiLevel = ExpoDevice
25
169
  ? ExpoDevice.platformApiLevel || null
26
170
  : null;
171
+ /**
172
+ * The human-readable name of the device, which may be set by the device's user. If the device name is unavailable, particularly on web, this value is `null`.
173
+ *
174
+ * > On iOS 16 and newer, this value will be set to generic "iPhone" until you add the correct entitlement, see [iOS Capabilities page](/build-reference/ios-capabilities)
175
+ * > to learn how to add one and check out [Apple documentation](https://developer.apple.com/documentation/uikit/uidevice/1620015-name#discussion)
176
+ * > for more details on this change.
177
+ *
178
+ * @example
179
+ * ```js
180
+ * Device.deviceName; // "Vivian's iPhone XS"
181
+ * ```
182
+ */
27
183
  export const deviceName = ExpoDevice ? ExpoDevice.deviceName : null;
184
+ /**
185
+ * Checks the type of the device as a [`DeviceType`](#devicetype) enum value.
186
+ *
187
+ * On Android, for devices other than TVs, the device type is determined by the screen resolution (screen diagonal size), so the result may not be completely accurate.
188
+ * If the screen diagonal length is between 3" and 6.9", the method returns `DeviceType.PHONE`. For lengths between 7" and 18", the method returns `DeviceType.TABLET`.
189
+ * Otherwise, the method returns `DeviceType.UNKNOWN`.
190
+ *
191
+ * @return Returns a promise that resolves to a [`DeviceType`](#devicetype) enum value.
192
+ * @example
193
+ * ```js
194
+ * await Device.getDeviceTypeAsync();
195
+ * // DeviceType.PHONE
196
+ * ```
197
+ */
28
198
  export async function getDeviceTypeAsync() {
29
199
  if (!ExpoDevice.getDeviceTypeAsync) {
30
200
  throw new UnavailabilityError('expo-device', 'getDeviceTypeAsync');
31
201
  }
32
202
  return await ExpoDevice.getDeviceTypeAsync();
33
203
  }
204
+ /**
205
+ * Gets the uptime since the last reboot of the device, in milliseconds. Android devices do not count time spent in deep sleep.
206
+ * @return Returns a promise that resolves to a `number` that represents the milliseconds since last reboot.
207
+ * @example
208
+ * ```js
209
+ * await Device.getUptimeAsync();
210
+ * // 4371054
211
+ * ```
212
+ * @platform android
213
+ * @platform ios
214
+ */
34
215
  export async function getUptimeAsync() {
35
216
  if (!ExpoDevice.getUptimeAsync) {
36
217
  throw new UnavailabilityError('expo-device', 'getUptimeAsync');
37
218
  }
38
219
  return await ExpoDevice.getUptimeAsync();
39
220
  }
221
+ /**
222
+ * Returns the maximum amount of memory that the Java VM will attempt to use. If there is no inherent limit then `Number.MAX_SAFE_INTEGER` is returned.
223
+ * @return Returns a promise that resolves to the maximum available memory that the Java VM will use, in bytes.
224
+ * @example
225
+ * ```js
226
+ * await Device.getMaxMemoryAsync();
227
+ * // 402653184
228
+ * ```
229
+ * @platform android
230
+ */
40
231
  export async function getMaxMemoryAsync() {
41
232
  if (!ExpoDevice.getMaxMemoryAsync) {
42
233
  throw new UnavailabilityError('expo-device', 'getMaxMemoryAsync');
@@ -47,24 +238,83 @@ export async function getMaxMemoryAsync() {
47
238
  }
48
239
  return maxMemory;
49
240
  }
241
+ /**
242
+ * > **warning** This method is experimental and is not completely reliable. See description below.
243
+ *
244
+ * Checks whether the device has been rooted (Android) or jailbroken (iOS). This is not completely reliable because there exist solutions to bypass root-detection
245
+ * on both [iOS](https://www.theiphonewiki.com/wiki/XCon) and [Android](https://tweakerlinks.com/how-to-bypass-apps-root-detection-in-android-device/).
246
+ * Further, many root-detection checks can be bypassed via reverse engineering.
247
+ * - On Android, it's implemented in a way to find all possible files paths that contain the `"su"` executable but some devices that are not rooted may also have this executable. Therefore, there's no guarantee that this method will always return correctly.
248
+ * - On iOS, [these jailbreak checks](https://www.theiphonewiki.com/wiki/Bypassing_Jailbreak_Detection) are used to detect if a device is rooted/jailbroken. However, since there are closed-sourced solutions such as [xCon](https://www.theiphonewiki.com/wiki/XCon) that aim to hook every known method and function responsible for informing an application of a jailbroken device, this method may not reliably detect devices that have xCon or similar packages installed.
249
+ * - On web, this always resolves to `false` even if the device is rooted.
250
+ * @return Returns a promise that resolves to a `boolean` that specifies whether this device is rooted.
251
+ * @example
252
+ * ```js
253
+ * await Device.isRootedExperimentalAsync();
254
+ * // true or false
255
+ * ```
256
+ */
50
257
  export async function isRootedExperimentalAsync() {
51
258
  if (!ExpoDevice.isRootedExperimentalAsync) {
52
259
  throw new UnavailabilityError('expo-device', 'isRootedExperimentalAsync');
53
260
  }
54
261
  return await ExpoDevice.isRootedExperimentalAsync();
55
262
  }
263
+ /**
264
+ * **Using this method requires you to [add the `REQUEST_INSTALL_PACKAGES` permission](/config/app#permissions).**
265
+ * Returns whether applications can be installed for this user via the system's [Intent#ACTION_INSTALL_PACKAGE](https://developer.android.com/reference/android/content/Intent.html#ACTION_INSTALL_PACKAGE)
266
+ * mechanism rather than through the OS's default app store, like Google Play.
267
+ * @return Returns a promise that resolves to a `boolean` that represents whether the calling package is allowed to request package installation.
268
+ * @example
269
+ * ```js
270
+ * await Device.isSideLoadingEnabledAsync();
271
+ * // true or false
272
+ * ```
273
+ * @platform android
274
+ */
56
275
  export async function isSideLoadingEnabledAsync() {
57
276
  if (!ExpoDevice.isSideLoadingEnabledAsync) {
58
277
  throw new UnavailabilityError('expo-device', 'isSideLoadingEnabledAsync');
59
278
  }
60
279
  return await ExpoDevice.isSideLoadingEnabledAsync();
61
280
  }
281
+ /**
282
+ * Gets a list of features that are available on the system. The feature names are platform-specific.
283
+ * See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures()>)
284
+ * to learn more about this implementation.
285
+ * @return Returns a promise that resolves to an array of strings, each of which is a platform-specific name of a feature available on the current device.
286
+ * On iOS and web, the promise always resolves to an empty array.
287
+ * @example
288
+ * ```js
289
+ * await Device.getPlatformFeaturesAsync();
290
+ * // [
291
+ * // 'android.software.adoptable_storage',
292
+ * // 'android.software.backup',
293
+ * // 'android.hardware.sensor.accelerometer',
294
+ * // 'android.hardware.touchscreen',
295
+ * // ]
296
+ * ```
297
+ * @platform android
298
+ */
62
299
  export async function getPlatformFeaturesAsync() {
63
300
  if (!ExpoDevice.getPlatformFeaturesAsync) {
64
301
  return [];
65
302
  }
66
303
  return await ExpoDevice.getPlatformFeaturesAsync();
67
304
  }
305
+ /**
306
+ * Tells if the device has a specific system feature.
307
+ * @param feature The platform-specific name of the feature to check for on the device. You can get all available system features with `Device.getSystemFeatureAsync()`.
308
+ * See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)>) to view acceptable feature strings.
309
+ * @return Returns a promise that resolves to a boolean value indicating whether the device has the specified system feature.
310
+ * On iOS and web, the promise always resolves to `false`.
311
+ * @example
312
+ * ```js
313
+ * await Device.hasPlatformFeatureAsync('amazon.hardware.fire_tv');
314
+ * // true or false
315
+ * ```
316
+ * @platform android
317
+ */
68
318
  export async function hasPlatformFeatureAsync(feature) {
69
319
  if (!ExpoDevice.hasPlatformFeatureAsync) {
70
320
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"Device.js","sourceRoot":"","sources":["../src/Device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,CA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AM,IAAI,mBAAmB,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;KACnE;IACD,IAAI,SAAS,GAAG,MAAM,UAAU,CAAC,iBAAiB,EAAE,CAAC;IACrD,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;QACpB,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;KACrC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,UAAU,CAAC,yBAAyB,EAAE;QACzC,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC;KAC3E;IACD,OAAO,MAAM,UAAU,CAAC,yBAAyB,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,UAAU,CAAC,yBAAyB,EAAE;QACzC,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC;KAC3E;IACD,OAAO,MAAM,UAAU,CAAC,yBAAyB,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC5C,IAAI,CAAC,UAAU,CAAC,wBAAwB,EAAE;QACxC,OAAO,EAAE,CAAC;KACX;IACD,OAAO,MAAM,UAAU,CAAC,wBAAwB,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAe;IAC3D,IAAI,CAAC,UAAU,CAAC,uBAAuB,EAAE;QACvC,OAAO,KAAK,CAAC;KACd;IACD,OAAO,MAAM,UAAU,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { DeviceType } from './Device.types';\nimport ExpoDevice from './ExpoDevice';\n\nexport { DeviceType };\n\nexport const isDevice: boolean = ExpoDevice ? ExpoDevice.isDevice : true;\nexport const brand: string | null = ExpoDevice ? ExpoDevice.brand : null;\nexport const manufacturer: string | null = ExpoDevice ? ExpoDevice.manufacturer : null;\nexport const modelId = ExpoDevice ? ExpoDevice.modelId || null : null;\nexport const modelName: string | null = ExpoDevice ? ExpoDevice.modelName : null;\nexport const designName: string | null = ExpoDevice ? ExpoDevice.designName || null : null;\nexport const productName: string | null = ExpoDevice ? ExpoDevice.productName || null : null;\nexport const deviceYearClass: number | null = ExpoDevice ? ExpoDevice.deviceYearClass : null;\nexport const totalMemory: number | null = ExpoDevice ? ExpoDevice.totalMemory : null;\nexport const supportedCpuArchitectures: string[] | null = ExpoDevice\n ? ExpoDevice.supportedCpuArchitectures\n : null;\nexport const osName: string | null = ExpoDevice ? ExpoDevice.osName : null;\nexport const osVersion: string | null = ExpoDevice ? ExpoDevice.osVersion : null;\nexport const osBuildId: string | null = ExpoDevice ? ExpoDevice.osBuildId : null;\nexport const osInternalBuildId: string | null = ExpoDevice ? ExpoDevice.osInternalBuildId : null;\nexport const osBuildFingerprint: string | null = ExpoDevice\n ? ExpoDevice.osBuildFingerprint || null\n : null;\nexport const platformApiLevel: number | null = ExpoDevice\n ? ExpoDevice.platformApiLevel || null\n : null;\nexport const deviceName: string | null = ExpoDevice ? ExpoDevice.deviceName : null;\n\nexport async function getDeviceTypeAsync(): Promise<DeviceType> {\n if (!ExpoDevice.getDeviceTypeAsync) {\n throw new UnavailabilityError('expo-device', 'getDeviceTypeAsync');\n }\n return await ExpoDevice.getDeviceTypeAsync();\n}\n\nexport async function getUptimeAsync(): Promise<number> {\n if (!ExpoDevice.getUptimeAsync) {\n throw new UnavailabilityError('expo-device', 'getUptimeAsync');\n }\n return await ExpoDevice.getUptimeAsync();\n}\n\nexport async function getMaxMemoryAsync(): Promise<number> {\n if (!ExpoDevice.getMaxMemoryAsync) {\n throw new UnavailabilityError('expo-device', 'getMaxMemoryAsync');\n }\n let maxMemory = await ExpoDevice.getMaxMemoryAsync();\n if (maxMemory === -1) {\n maxMemory = Number.MAX_SAFE_INTEGER;\n }\n return maxMemory;\n}\n\nexport async function isRootedExperimentalAsync(): Promise<boolean> {\n if (!ExpoDevice.isRootedExperimentalAsync) {\n throw new UnavailabilityError('expo-device', 'isRootedExperimentalAsync');\n }\n return await ExpoDevice.isRootedExperimentalAsync();\n}\n\nexport async function isSideLoadingEnabledAsync(): Promise<boolean> {\n if (!ExpoDevice.isSideLoadingEnabledAsync) {\n throw new UnavailabilityError('expo-device', 'isSideLoadingEnabledAsync');\n }\n return await ExpoDevice.isSideLoadingEnabledAsync();\n}\n\nexport async function getPlatformFeaturesAsync(): Promise<string[]> {\n if (!ExpoDevice.getPlatformFeaturesAsync) {\n return [];\n }\n return await ExpoDevice.getPlatformFeaturesAsync();\n}\n\nexport async function hasPlatformFeatureAsync(feature: string): Promise<boolean> {\n if (!ExpoDevice.hasPlatformFeatureAsync) {\n return false;\n }\n return await ExpoDevice.hasPlatformFeatureAsync(feature);\n}\n"]}
1
+ {"version":3,"file":"Device.js","sourceRoot":"","sources":["../src/Device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAY,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,KAAK,GAAkB,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAEvF;;;;;;;;;GASG;AACH,MAAM,CA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AAa,EAAE,mBAAmB,CAAC,CAAC;KACnE;IACD,IAAI,SAAS,GAAG,MAAM,UAAU,CAAC,iBAAiB,EAAE,CAAC;IACrD,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;QACpB,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;KACrC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,UAAU,CAAC,yBAAyB,EAAE;QACzC,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC;KAC3E;IACD,OAAO,MAAM,UAAU,CAAC,yBAAyB,EAAE,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,UAAU,CAAC,yBAAyB,EAAE;QACzC,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC;KAC3E;IACD,OAAO,MAAM,UAAU,CAAC,yBAAyB,EAAE,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC5C,IAAI,CAAC,UAAU,CAAC,wBAAwB,EAAE;QACxC,OAAO,EAAE,CAAC;KACX;IACD,OAAO,MAAM,UAAU,CAAC,wBAAwB,EAAE,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAe;IAC3D,IAAI,CAAC,UAAU,CAAC,uBAAuB,EAAE;QACvC,OAAO,KAAK,CAAC;KACd;IACD,OAAO,MAAM,UAAU,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { DeviceType } from './Device.types';\nimport ExpoDevice from './ExpoDevice';\n\nexport { DeviceType };\n\n/**\n * `true` if the app is running on a real device and `false` if running in a simulator or emulator.\n * On web, this is always set to `true`.\n */\nexport const isDevice: boolean = ExpoDevice ? ExpoDevice.isDevice : true;\n\n/**\n * The device brand. The consumer-visible brand of the product/hardware. On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.brand; // Android: \"google\", \"xiaomi\"; iOS: \"Apple\"; web: null\n * ```\n * @platform android\n * @platform ios\n */\nexport const brand: string | null = ExpoDevice ? ExpoDevice.brand : null;\n\n/**\n * The actual device manufacturer of the product or hardware. This value of this field may be `null` if it cannot be determined.\n *\n * To view difference between `brand` and `manufacturer` on Android see [official documentation](https://developer.android.com/reference/android/os/Build).\n *\n * @example\n * ```js\n * Device.manufacturer; // Android: \"Google\", \"xiaomi\"; iOS: \"Apple\"; web: \"Google\", null\n * ```\n */\nexport const manufacturer: string | null = ExpoDevice ? ExpoDevice.manufacturer : null;\n\n/**\n * The internal model ID of the device. This is useful for programmatically identifying the type of device and is not a human-friendly string.\n * On web and Android, this value is always `null`.\n *\n * @example\n * ```js\n * Device.modelId; // iOS: \"iPhone7,2\"; Android: null; web: null\n * ```\n * @platform ios\n */\nexport const modelId = ExpoDevice ? ExpoDevice.modelId || null : null;\n\n/**\n * The human-friendly name of the device model. This is the name that people would typically use to refer to the device rather than a programmatic model identifier.\n * This value of this field may be `null` if it cannot be determined.\n *\n * @example\n * ```js\n * Device.modelName; // Android: \"Pixel 2\"; iOS: \"iPhone XS Max\"; web: \"iPhone\", null\n * ```\n */\nexport const modelName: string | null = ExpoDevice ? ExpoDevice.modelName : null;\n\n/**\n * The specific configuration or name of the industrial design. It represents the device's name when it was designed during manufacturing into mass production.\n * On Android, it corresponds to [`Build.DEVICE`](https://developer.android.com/reference/android/os/Build#DEVICE). On web and iOS, this value is always `null`.\n *\n * @example\n * ```js\n * Device.designName; // Android: \"kminilte\"; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const designName: string | null = ExpoDevice ? ExpoDevice.designName || null : null;\n\n/**\n * The device's overall product name chosen by the device implementer containing the development name or code name of the device.\n * Corresponds to [`Build.PRODUCT`](https://developer.android.com/reference/android/os/Build#PRODUCT). On web and iOS, this value is always `null`.\n *\n * @example\n * ```js\n * Device.productName; // Android: \"kminiltexx\"; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const productName: string | null = ExpoDevice ? ExpoDevice.productName || null : null;\n\n/**\n * The [device year class](https://github.com/facebook/device-year-class) of this device. On web, this value is always `null`.\n */\nexport const deviceYearClass: number | null = ExpoDevice ? ExpoDevice.deviceYearClass : null;\n\n/**\n * The device's total memory, in bytes. This is the total memory accessible to the kernel, but not necessarily to a single app.\n * This is basically the amount of RAM the device has, not including below-kernel fixed allocations like DMA buffers, RAM for the baseband CPU, etc…\n * On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.totalMemory; // 17179869184\n * ```\n */\nexport const totalMemory: number | null = ExpoDevice ? ExpoDevice.totalMemory : null;\n\n/**\n * A list of supported processor architecture versions. The device expects the binaries it runs to be compiled for one of these architectures.\n * This value is `null` if the supported architectures could not be determined, particularly on web.\n *\n * @example\n * ```js\n * Device.supportedCpuArchitectures; // ['arm64 v8', 'Intel x86-64h Haswell', 'arm64-v8a', 'armeabi-v7a\", 'armeabi']\n * ```\n */\nexport const supportedCpuArchitectures: string[] | null = ExpoDevice\n ? ExpoDevice.supportedCpuArchitectures\n : null;\n\n/**\n * The name of the OS running on the device.\n *\n * @example\n * ```js\n * Device.osName; // Android: \"Android\"; iOS: \"iOS\" or \"iPadOS\"; web: \"iOS\", \"Android\", \"Windows\"\n * ```\n */\nexport const osName: string | null = ExpoDevice ? ExpoDevice.osName : null;\n\n/**\n * The human-readable OS version string. Note that the version string may not always contain three numbers separated by dots.\n *\n * @example\n * ```js\n * Device.osVersion; // Android: \"4.0.3\"; iOS: \"12.3.1\"; web: \"11.0\", \"8.1.0\"\n * ```\n */\nexport const osVersion: string | null = ExpoDevice ? ExpoDevice.osVersion : null;\n\n/**\n * The build ID of the OS that more precisely identifies the version of the OS. On Android, this corresponds to `Build.DISPLAY` (not `Build.ID`)\n * and currently is a string as described [here](https://source.android.com/setup/start/build-numbers). On iOS, this corresponds to `kern.osversion`\n * and is the detailed OS version sometimes displayed next to the more human-readable version. On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osBuildId; // Android: \"PSR1.180720.075\"; iOS: \"16F203\"; web: null\n * ```\n */\nexport const osBuildId: string | null = ExpoDevice ? ExpoDevice.osBuildId : null;\n\n/**\n * The internal build ID of the OS running on the device. On Android, this corresponds to `Build.ID`.\n * On iOS, this is the same value as [`Device.osBuildId`](#deviceosbuildid). On web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osInternalBuildId; // Android: \"MMB29K\"; iOS: \"16F203\"; web: null,\n * ```\n */\nexport const osInternalBuildId: string | null = ExpoDevice ? ExpoDevice.osInternalBuildId : null;\n\n/**\n * A string that uniquely identifies the build of the currently running system OS. On Android, it follows this template:\n * - `$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/\\$(TAGS)`\n * On web and iOS, this value is always `null`.\n *\n * @example\n * ```js\n * Device.osBuildFingerprint;\n * // Android: \"google/sdk_gphone_x86/generic_x86:9/PSR1.180720.075/5124027:user/release-keys\";\n * // iOS: null; web: null\n * ```\n * @platform android\n */\nexport const osBuildFingerprint: string | null = ExpoDevice\n ? ExpoDevice.osBuildFingerprint || null\n : null;\n\n/**\n * The Android SDK version of the software currently running on this hardware device. This value never changes while a device is booted,\n * but it may increase when the hardware manufacturer provides an OS update. See [here](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html)\n * to see all possible version codes and corresponding versions. On iOS and web, this value is always `null`.\n *\n * @example\n * ```js\n * Device.platformApiLevel; // Android: 19; iOS: null; web: null\n * ```\n * @platform android\n */\nexport const platformApiLevel: number | null = ExpoDevice\n ? ExpoDevice.platformApiLevel || null\n : null;\n\n/**\n * The human-readable name of the device, which may be set by the device's user. If the device name is unavailable, particularly on web, this value is `null`.\n *\n * > On iOS 16 and newer, this value will be set to generic \"iPhone\" until you add the correct entitlement, see [iOS Capabilities page](/build-reference/ios-capabilities)\n * > to learn how to add one and check out [Apple documentation](https://developer.apple.com/documentation/uikit/uidevice/1620015-name#discussion)\n * > for more details on this change.\n *\n * @example\n * ```js\n * Device.deviceName; // \"Vivian's iPhone XS\"\n * ```\n */\nexport const deviceName: string | null = ExpoDevice ? ExpoDevice.deviceName : null;\n\n/**\n * Checks the type of the device as a [`DeviceType`](#devicetype) enum value.\n *\n * On Android, for devices other than TVs, the device type is determined by the screen resolution (screen diagonal size), so the result may not be completely accurate.\n * If the screen diagonal length is between 3\" and 6.9\", the method returns `DeviceType.PHONE`. For lengths between 7\" and 18\", the method returns `DeviceType.TABLET`.\n * Otherwise, the method returns `DeviceType.UNKNOWN`.\n *\n * @return Returns a promise that resolves to a [`DeviceType`](#devicetype) enum value.\n * @example\n * ```js\n * await Device.getDeviceTypeAsync();\n * // DeviceType.PHONE\n * ```\n */\nexport async function getDeviceTypeAsync(): Promise<DeviceType> {\n if (!ExpoDevice.getDeviceTypeAsync) {\n throw new UnavailabilityError('expo-device', 'getDeviceTypeAsync');\n }\n return await ExpoDevice.getDeviceTypeAsync();\n}\n\n/**\n * Gets the uptime since the last reboot of the device, in milliseconds. Android devices do not count time spent in deep sleep.\n * @return Returns a promise that resolves to a `number` that represents the milliseconds since last reboot.\n * @example\n * ```js\n * await Device.getUptimeAsync();\n * // 4371054\n * ```\n * @platform android\n * @platform ios\n */\nexport async function getUptimeAsync(): Promise<number> {\n if (!ExpoDevice.getUptimeAsync) {\n throw new UnavailabilityError('expo-device', 'getUptimeAsync');\n }\n return await ExpoDevice.getUptimeAsync();\n}\n\n/**\n * Returns the maximum amount of memory that the Java VM will attempt to use. If there is no inherent limit then `Number.MAX_SAFE_INTEGER` is returned.\n * @return Returns a promise that resolves to the maximum available memory that the Java VM will use, in bytes.\n * @example\n * ```js\n * await Device.getMaxMemoryAsync();\n * // 402653184\n * ```\n * @platform android\n */\nexport async function getMaxMemoryAsync(): Promise<number> {\n if (!ExpoDevice.getMaxMemoryAsync) {\n throw new UnavailabilityError('expo-device', 'getMaxMemoryAsync');\n }\n let maxMemory = await ExpoDevice.getMaxMemoryAsync();\n if (maxMemory === -1) {\n maxMemory = Number.MAX_SAFE_INTEGER;\n }\n return maxMemory;\n}\n\n/**\n * > **warning** This method is experimental and is not completely reliable. See description below.\n *\n * Checks whether the device has been rooted (Android) or jailbroken (iOS). This is not completely reliable because there exist solutions to bypass root-detection\n * on both [iOS](https://www.theiphonewiki.com/wiki/XCon) and [Android](https://tweakerlinks.com/how-to-bypass-apps-root-detection-in-android-device/).\n * Further, many root-detection checks can be bypassed via reverse engineering.\n * - On Android, it's implemented in a way to find all possible files paths that contain the `\"su\"` executable but some devices that are not rooted may also have this executable. Therefore, there's no guarantee that this method will always return correctly.\n * - On iOS, [these jailbreak checks](https://www.theiphonewiki.com/wiki/Bypassing_Jailbreak_Detection) are used to detect if a device is rooted/jailbroken. However, since there are closed-sourced solutions such as [xCon](https://www.theiphonewiki.com/wiki/XCon) that aim to hook every known method and function responsible for informing an application of a jailbroken device, this method may not reliably detect devices that have xCon or similar packages installed.\n * - On web, this always resolves to `false` even if the device is rooted.\n * @return Returns a promise that resolves to a `boolean` that specifies whether this device is rooted.\n * @example\n * ```js\n * await Device.isRootedExperimentalAsync();\n * // true or false\n * ```\n */\nexport async function isRootedExperimentalAsync(): Promise<boolean> {\n if (!ExpoDevice.isRootedExperimentalAsync) {\n throw new UnavailabilityError('expo-device', 'isRootedExperimentalAsync');\n }\n return await ExpoDevice.isRootedExperimentalAsync();\n}\n\n/**\n * **Using this method requires you to [add the `REQUEST_INSTALL_PACKAGES` permission](/config/app#permissions).**\n * Returns whether applications can be installed for this user via the system's [Intent#ACTION_INSTALL_PACKAGE](https://developer.android.com/reference/android/content/Intent.html#ACTION_INSTALL_PACKAGE)\n * mechanism rather than through the OS's default app store, like Google Play.\n * @return Returns a promise that resolves to a `boolean` that represents whether the calling package is allowed to request package installation.\n * @example\n * ```js\n * await Device.isSideLoadingEnabledAsync();\n * // true or false\n * ```\n * @platform android\n */\nexport async function isSideLoadingEnabledAsync(): Promise<boolean> {\n if (!ExpoDevice.isSideLoadingEnabledAsync) {\n throw new UnavailabilityError('expo-device', 'isSideLoadingEnabledAsync');\n }\n return await ExpoDevice.isSideLoadingEnabledAsync();\n}\n\n/**\n * Gets a list of features that are available on the system. The feature names are platform-specific.\n * See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures()>)\n * to learn more about this implementation.\n * @return Returns a promise that resolves to an array of strings, each of which is a platform-specific name of a feature available on the current device.\n * On iOS and web, the promise always resolves to an empty array.\n * @example\n * ```js\n * await Device.getPlatformFeaturesAsync();\n * // [\n * // 'android.software.adoptable_storage',\n * // 'android.software.backup',\n * // 'android.hardware.sensor.accelerometer',\n * // 'android.hardware.touchscreen',\n * // ]\n * ```\n * @platform android\n */\nexport async function getPlatformFeaturesAsync(): Promise<string[]> {\n if (!ExpoDevice.getPlatformFeaturesAsync) {\n return [];\n }\n return await ExpoDevice.getPlatformFeaturesAsync();\n}\n\n/**\n * Tells if the device has a specific system feature.\n * @param feature The platform-specific name of the feature to check for on the device. You can get all available system features with `Device.getSystemFeatureAsync()`.\n * See [Android documentation](<https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)>) to view acceptable feature strings.\n * @return Returns a promise that resolves to a boolean value indicating whether the device has the specified system feature.\n * On iOS and web, the promise always resolves to `false`.\n * @example\n * ```js\n * await Device.hasPlatformFeatureAsync('amazon.hardware.fire_tv');\n * // true or false\n * ```\n * @platform android\n */\nexport async function hasPlatformFeatureAsync(feature: string): Promise<boolean> {\n if (!ExpoDevice.hasPlatformFeatureAsync) {\n return false;\n }\n return await ExpoDevice.hasPlatformFeatureAsync(feature);\n}\n"]}
@@ -1,8 +1,26 @@
1
+ /**
2
+ * An enum representing the different types of devices supported by Expo.
3
+ */
1
4
  export declare enum DeviceType {
5
+ /**
6
+ * An unrecognized device type.
7
+ */
2
8
  UNKNOWN = 0,
9
+ /**
10
+ * Mobile phone handsets, typically with a touch screen and held in one hand.
11
+ */
3
12
  PHONE = 1,
13
+ /**
14
+ * Tablet computers, typically with a touch screen that is larger than a usual phone.
15
+ */
4
16
  TABLET = 2,
17
+ /**
18
+ * Desktop or laptop computers, typically with a keyboard and mouse.
19
+ */
5
20
  DESKTOP = 3,
21
+ /**
22
+ * Device with TV-based interfaces.
23
+ */
6
24
  TV = 4
7
25
  }
8
26
  //# sourceMappingURL=Device.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Device.types.d.ts","sourceRoot":"","sources":["../src/Device.types.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,OAAO,IAAI;IACX,KAAK,IAAA;IACL,MAAM,IAAA;IACN,OAAO,IAAA;IACP,EAAE,IAAA;CACH"}
1
+ {"version":3,"file":"Device.types.d.ts","sourceRoot":"","sources":["../src/Device.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,UAAU;IACpB;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,KAAK,IAAA;IACL;;OAEG;IACH,MAAM,IAAA;IACN;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,EAAE,IAAA;CACH"}
@@ -1,9 +1,27 @@
1
+ /**
2
+ * An enum representing the different types of devices supported by Expo.
3
+ */
1
4
  export var DeviceType;
2
5
  (function (DeviceType) {
6
+ /**
7
+ * An unrecognized device type.
8
+ */
3
9
  DeviceType[DeviceType["UNKNOWN"] = 0] = "UNKNOWN";
10
+ /**
11
+ * Mobile phone handsets, typically with a touch screen and held in one hand.
12
+ */
4
13
  DeviceType[DeviceType["PHONE"] = 1] = "PHONE";
14
+ /**
15
+ * Tablet computers, typically with a touch screen that is larger than a usual phone.
16
+ */
5
17
  DeviceType[DeviceType["TABLET"] = 2] = "TABLET";
18
+ /**
19
+ * Desktop or laptop computers, typically with a keyboard and mouse.
20
+ */
6
21
  DeviceType[DeviceType["DESKTOP"] = 3] = "DESKTOP";
22
+ /**
23
+ * Device with TV-based interfaces.
24
+ */
7
25
  DeviceType[DeviceType["TV"] = 4] = "TV";
8
26
  })(DeviceType || (DeviceType = {}));
9
27
  //# sourceMappingURL=Device.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Device.types.js","sourceRoot":"","sources":["../src/Device.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,iDAAW,CAAA;IACX,6CAAK,CAAA;IACL,+CAAM,CAAA;IACN,iDAAO,CAAA;IACP,uCAAE,CAAA;AACJ,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB","sourcesContent":["export enum DeviceType {\n UNKNOWN = 0,\n PHONE,\n TABLET,\n DESKTOP,\n TV,\n}\n"]}
1
+ {"version":3,"file":"Device.types.js","sourceRoot":"","sources":["../src/Device.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,UAqBX;AArBD,WAAY,UAAU;IACpB;;OAEG;IACH,iDAAW,CAAA;IACX;;OAEG;IACH,6CAAK,CAAA;IACL;;OAEG;IACH,+CAAM,CAAA;IACN;;OAEG;IACH,iDAAO,CAAA;IACP;;OAEG;IACH,uCAAE,CAAA;AACJ,CAAC,EArBW,UAAU,KAAV,UAAU,QAqBrB","sourcesContent":["/**\n * An enum representing the different types of devices supported by Expo.\n */\nexport enum DeviceType {\n /**\n * An unrecognized device type.\n */\n UNKNOWN = 0,\n /**\n * Mobile phone handsets, typically with a touch screen and held in one hand.\n */\n PHONE,\n /**\n * Tablet computers, typically with a touch screen that is larger than a usual phone.\n */\n TABLET,\n /**\n * Desktop or laptop computers, typically with a keyboard and mouse.\n */\n DESKTOP,\n /**\n * Device with TV-based interfaces.\n */\n TV,\n}\n"]}
@@ -1,3 +1,3 @@
1
- declare const _default: import("expo-modules-core").ProxyNativeModule;
1
+ declare const _default: any;
2
2
  export default _default;
3
3
  //# sourceMappingURL=ExpoDevice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoDevice.d.ts","sourceRoot":"","sources":["../src/ExpoDevice.ts"],"names":[],"mappings":";AACA,wBAA6C"}
1
+ {"version":3,"file":"ExpoDevice.d.ts","sourceRoot":"","sources":["../src/ExpoDevice.ts"],"names":[],"mappings":";AACA,wBAAiD"}
@@ -1,3 +1,3 @@
1
- import { NativeModulesProxy } from 'expo-modules-core';
2
- export default NativeModulesProxy.ExpoDevice;
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+ export default requireNativeModule('ExpoDevice');
3
3
  //# sourceMappingURL=ExpoDevice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoDevice.js","sourceRoot":"","sources":["../src/ExpoDevice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,eAAe,kBAAkB,CAAC,UAAU,CAAC","sourcesContent":["import { NativeModulesProxy } from 'expo-modules-core';\nexport default NativeModulesProxy.ExpoDevice;\n"]}
1
+ {"version":3,"file":"ExpoDevice.js","sourceRoot":"","sources":["../src/ExpoDevice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,eAAe,mBAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\nexport default requireNativeModule('ExpoDevice');\n"]}
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "expo-device",
3
+ "platforms": ["ios", "android", "web"],
4
+ "ios": {
5
+ "modules": ["DeviceModule"]
6
+ },
7
+ "android": {
8
+ "modules": ["expo.modules.device.DeviceModule"]
9
+ }
10
+ }
@@ -0,0 +1,95 @@
1
+ import ExpoModulesCore
2
+ import UIKit
3
+ import MachO
4
+
5
+ public class DeviceModule: Module {
6
+ public func definition() -> ModuleDefinition {
7
+ Name("ExpoDevice")
8
+
9
+ Constants([
10
+ "isDevice": isDevice(),
11
+ "brand": "Apple",
12
+ "manufacturer": "Apple",
13
+ "modelId": UIDevice.modelIdentifier,
14
+ "modelName": UIDevice.DeviceMap.modelName,
15
+ "deviceYearClass": UIDevice.DeviceMap.deviceYearClass,
16
+ "totalMemory": ProcessInfo.processInfo.physicalMemory,
17
+ "osName": UIDevice.current.systemName,
18
+ "osVersion": UIDevice.current.systemVersion,
19
+ "osBuildId": osBuildId(),
20
+ "osInternalBuildId": osBuildId(),
21
+ "deviceName": UIDevice.current.name,
22
+ "supportedCpuArchitectures": cpuArchitectures()
23
+ ])
24
+
25
+ AsyncFunction("getDeviceTypeAsync") { () -> Int in
26
+ switch UIDevice.current.userInterfaceIdiom {
27
+ case UIUserInterfaceIdiom.phone:
28
+ return DeviceType.phone.rawValue
29
+ case UIUserInterfaceIdiom.pad:
30
+ return DeviceType.tablet.rawValue
31
+ case UIUserInterfaceIdiom.tv:
32
+ return DeviceType.tv.rawValue
33
+ default:
34
+ return DeviceType.unknown.rawValue
35
+ }
36
+ }
37
+
38
+ AsyncFunction("getUptimeAsync") { () -> Double in
39
+ let uptimeMs: Double = ProcessInfo.processInfo.systemUptime * 1000
40
+
41
+ return uptimeMs
42
+ }
43
+
44
+ AsyncFunction("isRootedExperimentalAsync") { () -> Bool in
45
+ return UIDevice.current.isJailbroken
46
+ }
47
+ }
48
+ }
49
+
50
+ func isDevice() -> Bool {
51
+ #if targetEnvironment(simulator)
52
+ return false
53
+ #else
54
+ return true
55
+ #endif
56
+ }
57
+
58
+ func osBuildId() -> String? {
59
+ #if os(tvOS)
60
+ return nil
61
+ #else
62
+ // Credit: https://stackoverflow.com/a/65858410
63
+ var mib: [Int32] = [CTL_KERN, KERN_OSVERSION]
64
+ let namelen = UInt32(MemoryLayout.size(ofValue: mib) / MemoryLayout.size(ofValue: mib[0]))
65
+ var bufferSize = 0
66
+
67
+ // Get the size for the buffer
68
+ sysctl(&mib, namelen, nil, &bufferSize, nil, 0)
69
+
70
+ var buildBuffer = [UInt8](repeating: 0, count: bufferSize)
71
+ let result = sysctl(&mib, namelen, &buildBuffer, &bufferSize, nil, 0)
72
+
73
+ if result >= 0 && bufferSize > 0 {
74
+ return String(bytesNoCopy: &buildBuffer, length: bufferSize - 1, encoding: .utf8, freeWhenDone: false)
75
+ }
76
+
77
+ return nil
78
+ #endif
79
+ }
80
+
81
+ func cpuArchitectures() -> [String]? {
82
+ // Credit: https://stackoverflow.com/a/70134518
83
+ guard let archRaw = NXGetLocalArchInfo().pointee.name else {
84
+ return nil
85
+ }
86
+ return [String(cString: archRaw)]
87
+ }
88
+
89
+ enum DeviceType: Int {
90
+ case unknown = 0
91
+ case phone = 1
92
+ case tablet = 2
93
+ case desktop = 3
94
+ case tv = 4
95
+ }
@@ -3,7 +3,7 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = 'EXDevice'
6
+ s.name = 'ExpoDevice'
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
  s.description = package['description']
@@ -11,15 +11,22 @@ Pod::Spec.new do |s|
11
11
  s.author = package['author']
12
12
  s.homepage = package['homepage']
13
13
  s.platform = :ios, '13.0'
14
+ s.swift_version = '5.4'
14
15
  s.source = { git: 'https://github.com/expo/expo.git' }
15
16
  s.static_framework = true
16
17
 
17
18
  s.dependency 'ExpoModulesCore'
18
19
 
20
+ # Swift/Objective-C compatibility
21
+ s.pod_target_xcconfig = {
22
+ 'DEFINES_MODULE' => 'YES',
23
+ 'SWIFT_COMPILATION_MODE' => 'wholemodule'
24
+ }
25
+
19
26
  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')
20
- s.source_files = "#{s.name}/**/*.h"
27
+ s.source_files = "**/*.h"
21
28
  s.vendored_frameworks = "#{s.name}.xcframework"
22
29
  else
23
- s.source_files = "#{s.name}/**/*.{h,m}"
30
+ s.source_files = "**/*.{h,m,swift}"
24
31
  end
25
32
  end