expo-modules-core 1.3.0 → 1.3.1

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,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 1.3.1 — 2023-05-08
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 1.3.0 — 2023-05-08
14
18
 
15
19
  ### 🎉 New features
@@ -6,7 +6,7 @@ apply plugin: 'maven-publish'
6
6
  apply plugin: "de.undercouch.download"
7
7
 
8
8
  group = 'host.exp.exponent'
9
- version = '1.3.0'
9
+ version = '1.3.1'
10
10
 
11
11
  buildscript {
12
12
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -173,7 +173,7 @@ android {
173
173
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
174
174
  consumerProguardFiles 'proguard-rules.pro'
175
175
  versionCode 1
176
- versionName "1.3.0"
176
+ versionName "1.3.1"
177
177
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled.toString()
178
178
 
179
179
  testInstrumentationRunner "expo.modules.TestRunner"
@@ -40,6 +40,13 @@ open class JavaScriptObject @DoNotStrip internal constructor(@DoNotStrip private
40
40
  external fun hasProperty(name: String): Boolean
41
41
  external fun getProperty(name: String): JavaScriptValue
42
42
 
43
+ operator fun get(name: String): JavaScriptValue? {
44
+ if (hasProperty(name)) {
45
+ return getProperty(name)
46
+ }
47
+ return null
48
+ }
49
+
43
50
  external fun getPropertyNames(): Array<String>
44
51
  private external fun setBoolProperty(name: String, value: Boolean)
45
52
  private external fun setDoubleProperty(name: String, value: Double)
@@ -64,15 +71,27 @@ open class JavaScriptObject @DoNotStrip internal constructor(@DoNotStrip private
64
71
  }
65
72
 
66
73
  fun setProperty(name: String, value: Boolean) = setBoolProperty(name, value)
74
+ operator fun set(name: String, value: Boolean) = setBoolProperty(name, value)
75
+
67
76
  fun setProperty(name: String, value: Int) = setDoubleProperty(name, value.toDouble())
77
+ operator fun set(name: String, value: Int) = setDoubleProperty(name, value.toDouble())
78
+
68
79
  fun setProperty(name: String, value: Double) = setDoubleProperty(name, value)
80
+ operator fun set(name: String, value: Double) = setDoubleProperty(name, value)
81
+
69
82
  fun setProperty(name: String, value: String?) = setStringProperty(name, value)
83
+ operator fun set(name: String, value: String?) = setStringProperty(name, value)
84
+
70
85
  fun setProperty(name: String, value: JavaScriptValue?) = setJSValueProperty(name, value)
86
+ operator fun set(name: String, value: JavaScriptValue?) = setJSValueProperty(name, value)
87
+
71
88
  fun setProperty(name: String, value: JavaScriptObject?) = setJSObjectProperty(name, value)
89
+ operator fun set(name: String, value: JavaScriptObject?) = setJSObjectProperty(name, value)
72
90
 
73
91
  // Needed to handle untyped null value
74
92
  // Without it setProperty(name, null) won't work
75
93
  fun setProperty(name: String, `null`: Nothing?) = unsetProperty(name)
94
+ operator fun set(name: String, `null`: Nothing?) = unsetProperty(name)
76
95
 
77
96
  fun defineProperty(
78
97
  name: String,
@@ -25,8 +25,8 @@ protocol AnyJavaScriptValue {
25
25
  static func convert(from value: JavaScriptValue, appContext: AppContext) throws -> Self
26
26
  }
27
27
 
28
- extension JavaScriptValue: AnyJavaScriptValue {
29
- var kind: JavaScriptValueKind {
28
+ extension JavaScriptValue: AnyJavaScriptValue, AnyArgument {
29
+ public var kind: JavaScriptValueKind {
30
30
  switch true {
31
31
  case isUndefined():
32
32
  return .undefined
@@ -83,7 +83,14 @@ public final class ClassComponent: ObjectDefinition {
83
83
  internal protocol ClassAssociatedObject {}
84
84
 
85
85
  // Basically we only need these two
86
- extension JavaScriptObject: ClassAssociatedObject {}
86
+ extension JavaScriptObject: ClassAssociatedObject, AnyArgument {
87
+ internal static func convert(from value: JavaScriptValue, appContext: AppContext) throws -> Self {
88
+ guard value.kind == .object else {
89
+ throw Conversions.ConvertingException<JavaScriptObject>(value)
90
+ }
91
+ return value.getObject() as! Self
92
+ }
93
+ }
87
94
  extension SharedObject: ClassAssociatedObject {}
88
95
 
89
96
  // MARK: - Privates
@@ -11,7 +11,9 @@
11
11
  - Throws: Rethrows various exceptions that could be thrown by the dynamic types.
12
12
  */
13
13
  internal func cast(_ value: Any, toType type: AnyDynamicType, appContext: AppContext) throws -> Any {
14
- // TODO: Accept JavaScriptValue and JavaScriptObject as argument types.
14
+ if let dynamicJSType = type as? DynamicJavaScriptType, dynamicJSType.equals(~JavaScriptValue.self) {
15
+ return value
16
+ }
15
17
  if !(type is DynamicTypedArrayType), let value = value as? JavaScriptValue {
16
18
  return try type.cast(value.getRaw(), appContext: appContext)
17
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,5 +42,5 @@
42
42
  "@testing-library/react-hooks": "^7.0.1",
43
43
  "expo-module-scripts": "^3.0.0"
44
44
  },
45
- "gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
45
+ "gitHead": "51f434ef271cece0aadf07f73912eaf11356865c"
46
46
  }