expo-eas-client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,2 @@
1
+ // @generated by expo-module-scripts
2
+ module.exports = require('expo-module-scripts/eslintrc.base.js');
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## Unpublished
4
+
5
+ ### 🛠 Breaking changes
6
+
7
+ - Change package name. ([#16884](https://github.com/expo/expo/pull/16884) by [@wschurman](https://github.com/wschurman))
8
+
9
+ ### 🎉 New features
10
+
11
+ ### 🐛 Bug fixes
12
+
13
+ - Fixed import error on Web. ([#16810](https://github.com/expo/expo/pull/16810) by [@kudo](https://github.com/kudo))
14
+
15
+ ### 💡 Others
16
+
17
+ ## 0.1.0 — 2022-03-28
18
+
19
+ _This version does not introduce any user-facing changes._
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # expo-eas-client
2
+
3
+ Information related to EAS.
4
+
5
+ ## Client ID Discussion
6
+
7
+ Stable client identifier for EAS services.
8
+
9
+ On iOS, this is stored in NSUserDefaults which is persisted and backed up. Upon restore (set up new iOS device for example), the identifier should be the same.
10
+
11
+ On Android, this is stored in SharedPreferences. By default since Android 6, SharedPreferences are backed up automatically via Auto Backup, though some devices or apps may not (for example, if `android:allowBackup="true"` is not specified in AndroidManifest.xml).
12
+
13
+ ## Contributing
14
+
15
+ Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).
16
+
@@ -0,0 +1,102 @@
1
+ apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
3
+ apply plugin: 'kotlin-android-extensions'
4
+ apply plugin: 'maven-publish'
5
+
6
+ group = 'host.exp.exponent'
7
+ version = '0.1.0'
8
+
9
+ buildscript {
10
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
11
+ if (expoModulesCorePlugin.exists()) {
12
+ apply from: expoModulesCorePlugin
13
+ applyKotlinExpoModulesCorePlugin()
14
+ }
15
+
16
+ // Simple helper that allows the root project to override versions declared by this library.
17
+ ext.safeExtGet = { prop, fallback ->
18
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
19
+ }
20
+
21
+ // Ensures backward compatibility
22
+ ext.getKotlinVersion = {
23
+ if (ext.has("kotlinVersion")) {
24
+ ext.kotlinVersion()
25
+ } else {
26
+ ext.safeExtGet("kotlinVersion", "1.6.10")
27
+ }
28
+ }
29
+
30
+ repositories {
31
+ mavenCentral()
32
+ }
33
+
34
+ dependencies {
35
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
36
+ }
37
+ }
38
+
39
+ // Creating sources with comments
40
+ task androidSourcesJar(type: Jar) {
41
+ classifier = 'sources'
42
+ from android.sourceSets.main.java.srcDirs
43
+ }
44
+
45
+ afterEvaluate {
46
+ publishing {
47
+ publications {
48
+ release(MavenPublication) {
49
+ from components.release
50
+ // Add additional sourcesJar to artifacts
51
+ artifact(androidSourcesJar)
52
+ }
53
+ }
54
+ repositories {
55
+ maven {
56
+ url = mavenLocal().url
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ android {
63
+ compileSdkVersion safeExtGet("compileSdkVersion", 30)
64
+
65
+ compileOptions {
66
+ sourceCompatibility JavaVersion.VERSION_1_8
67
+ targetCompatibility JavaVersion.VERSION_1_8
68
+ }
69
+
70
+ kotlinOptions {
71
+ jvmTarget = JavaVersion.VERSION_1_8
72
+ }
73
+
74
+ defaultConfig {
75
+ minSdkVersion safeExtGet("minSdkVersion", 21)
76
+ targetSdkVersion safeExtGet("targetSdkVersion", 30)
77
+ versionCode 1
78
+ versionName "0.1.0"
79
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
80
+ }
81
+ testOptions {
82
+ unitTests.includeAndroidResources = true
83
+ }
84
+ lintOptions {
85
+ abortOnError false
86
+ }
87
+ }
88
+
89
+ repositories {
90
+ mavenCentral()
91
+ }
92
+
93
+ dependencies {
94
+ implementation project(':expo-modules-core')
95
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
96
+
97
+ androidTestImplementation 'org.amshove.kluent:kluent-android:1.68'
98
+ androidTestImplementation 'androidx.test:runner:1.1.0'
99
+ androidTestImplementation 'androidx.test:core:1.0.0'
100
+ androidTestImplementation 'androidx.test:rules:1.1.0'
101
+ androidTestImplementation 'io.mockk:mockk-android:1.12.3'
102
+ }
@@ -0,0 +1,2 @@
1
+ <manifest package="expo.modules.easclient">
2
+ </manifest>
@@ -0,0 +1,22 @@
1
+ package expo.modules.easclient
2
+
3
+ import android.content.Context
4
+ import java.util.UUID
5
+
6
+ private const val PREFERENCES_FILE_NAME = "dev.expo.EASSharedPreferences"
7
+ private const val EAS_CLIENT_ID_SHARED_PREFERENCES_KEY = "eas-client-id"
8
+
9
+ class EASClientID(private val context: Context) {
10
+ val uuid: UUID by lazy {
11
+ val sharedPreferences = context.getSharedPreferences(PREFERENCES_FILE_NAME, Context.MODE_PRIVATE)
12
+ var clientId = sharedPreferences.getString(EAS_CLIENT_ID_SHARED_PREFERENCES_KEY, null)
13
+ if (clientId == null) {
14
+ clientId = UUID.randomUUID().toString()
15
+ with(sharedPreferences.edit()) {
16
+ putString(EAS_CLIENT_ID_SHARED_PREFERENCES_KEY, clientId)
17
+ apply()
18
+ }
19
+ }
20
+ UUID.fromString(clientId)
21
+ }
22
+ }
@@ -0,0 +1,19 @@
1
+ package expo.modules.easclient
2
+
3
+ import expo.modules.kotlin.modules.Module
4
+ import expo.modules.kotlin.modules.ModuleDefinition
5
+
6
+ class EASClientModule : Module() {
7
+ private val context
8
+ get() = requireNotNull(appContext.reactContext) {
9
+ "React Application Context is null"
10
+ }
11
+
12
+ override fun definition() = ModuleDefinition {
13
+ name("EASClient")
14
+
15
+ constants {
16
+ mapOf("clientID" to EASClientID(context).uuid.toString())
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ declare const _default: import("expo-modules-core").ProxyNativeModule;
2
+ export default _default;
3
+ //# sourceMappingURL=EASClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EASClient.d.ts","sourceRoot":"","sources":["../src/EASClient.ts"],"names":[],"mappings":";AACA,wBAAkD"}
@@ -0,0 +1,3 @@
1
+ import { NativeModulesProxy } from 'expo-modules-core';
2
+ export default NativeModulesProxy.EASClient || {};
3
+ //# sourceMappingURL=EASClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EASClient.js","sourceRoot":"","sources":["../src/EASClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,eAAe,kBAAkB,CAAC,SAAS,IAAI,EAAE,CAAC","sourcesContent":["import { NativeModulesProxy } from 'expo-modules-core';\nexport default NativeModulesProxy.EASClient || {};\n"]}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ readonly name: string;
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=EASClient.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EASClient.web.d.ts","sourceRoot":"","sources":["../src/EASClient.web.ts"],"names":[],"mappings":";;;AAAA,wBAIE"}
@@ -0,0 +1,6 @@
1
+ export default {
2
+ get name() {
3
+ return 'EASClient';
4
+ },
5
+ };
6
+ //# sourceMappingURL=EASClient.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EASClient.web.js","sourceRoot":"","sources":["../src/EASClient.web.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,IAAI,IAAI;QACN,OAAO,WAAW,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["export default {\n get name(): string {\n return 'EASClient';\n },\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const clientID: any;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAAqB,CAAC"}
package/build/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import EASClient from './EASClient';
2
+ export const clientID = EASClient.clientID;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC","sourcesContent":["import EASClient from './EASClient';\n\nexport const clientID = EASClient.clientID;\n"]}
@@ -0,0 +1,9 @@
1
+ {
2
+ "platforms": ["ios", "android"],
3
+ "ios": {
4
+ "modulesClassNames": ["EASClientModule"]
5
+ },
6
+ "android": {
7
+ "modulesClassNames": ["expo.modules.easclient.EASClientModule"]
8
+ }
9
+ }
@@ -0,0 +1,25 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ import Foundation
4
+
5
+ @objc
6
+ public class EASClientID : NSObject {
7
+ private static let EAS_CLIENT_ID_SHARED_PREFERENCES_KEY = "expo.eas-client-id"
8
+
9
+ @objc public static func uuid() -> UUID {
10
+ return UUID.init(uuidString: UserDefaults.standard.computeStringIfAbsent(forKey: EAS_CLIENT_ID_SHARED_PREFERENCES_KEY) {
11
+ UUID.init().uuidString
12
+ })!
13
+ }
14
+ }
15
+
16
+ extension UserDefaults {
17
+ func computeStringIfAbsent(forKey: String, _ compute: () throws -> String) rethrows -> String {
18
+ if let storedValue = string(forKey: forKey) {
19
+ return storedValue
20
+ }
21
+ let computedValue = try compute()
22
+ set(computedValue, forKey: forKey)
23
+ return computedValue
24
+ }
25
+ }
@@ -0,0 +1,13 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ import ExpoModulesCore
4
+
5
+ public class EASClientModule: Module {
6
+ public func definition() -> ModuleDefinition {
7
+ name("EASClient")
8
+
9
+ constants([
10
+ "clientID": EASClientID.uuid().uuidString
11
+ ])
12
+ }
13
+ }
@@ -0,0 +1,38 @@
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 = 'EASClient'
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, '12.0'
14
+ s.swift_version = '5.4'
15
+ s.source = { git: '' }
16
+ s.static_framework = true
17
+
18
+ s.dependency 'ExpoModulesCore'
19
+
20
+ # Swift/Objective-C compatibility
21
+ s.pod_target_xcconfig = {
22
+ 'GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS' => 'YES',
23
+ 'GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS' => 'YES',
24
+ 'DEFINES_MODULE' => 'YES',
25
+ 'SWIFT_COMPILATION_MODE' => 'wholemodule'
26
+ }
27
+
28
+ 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')
29
+ s.source_files = "#{s.name}/**/*.h"
30
+ s.vendored_frameworks = "#{s.name}.xcframework"
31
+ else
32
+ s.source_files = "#{s.name}/**/*.{h,m,swift}"
33
+ end
34
+
35
+ s.test_spec 'Tests' do |test_spec|
36
+ test_spec.source_files = 'Tests/*.{h,m,swift}'
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ // Copyright (c) 2020 650 Industries, Inc. All rights reserved.
2
+
3
+ import XCTest
4
+
5
+ @testable import EASClient
6
+
7
+ class EASClientIdTests : XCTestCase {
8
+ func testCreatesStableUUID() throws {
9
+ let easClientId = EASClientID.uuid().uuidString
10
+ XCTAssertNotNil(easClientId)
11
+
12
+ let easClientId2 = EASClientID.uuid().uuidString
13
+ XCTAssertEqual(easClientId, easClientId2)
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "expo-eas-client",
3
+ "version": "0.1.0",
4
+ "description": "Stable client identifier for EAS services",
5
+ "main": "build/index.js",
6
+ "types": "build/index.d.ts",
7
+ "sideEffects": false,
8
+ "scripts": {
9
+ "build": "expo-module build",
10
+ "clean": "expo-module clean",
11
+ "lint": "expo-module lint",
12
+ "test": "expo-module test",
13
+ "prepare": "expo-module prepare",
14
+ "prepublishOnly": "expo-module prepublishOnly",
15
+ "expo-module": "expo-module"
16
+ },
17
+ "keywords": [
18
+ "react-native",
19
+ "expo",
20
+ "eas-client",
21
+ "EASClient"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/expo/expo.git",
26
+ "directory": "packages/eas-client"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/expo/expo/issues"
30
+ },
31
+ "author": "650 Industries, Inc.",
32
+ "license": "MIT",
33
+ "homepage": "https://github.com/expo/expo/tree/main/packages/expo-eas-client",
34
+ "jest": {
35
+ "preset": "expo-module-scripts"
36
+ },
37
+ "devDependencies": {
38
+ "expo-module-scripts": "^2.0.0"
39
+ }
40
+ }
@@ -0,0 +1,2 @@
1
+ import { NativeModulesProxy } from 'expo-modules-core';
2
+ export default NativeModulesProxy.EASClient || {};
@@ -0,0 +1,5 @@
1
+ export default {
2
+ get name(): string {
3
+ return 'EASClient';
4
+ },
5
+ };
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ import EASClient from './EASClient';
2
+
3
+ export const clientID = EASClient.clientID;
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ // @generated by expo-module-scripts
2
+ {
3
+ "extends": "expo-module-scripts/tsconfig.base",
4
+ "compilerOptions": {
5
+ "outDir": "./build"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
+ }