expo-modules-core 1.5.2 → 1.5.4

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,22 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 1.5.4 — 2023-07-04
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fix the `View cannot be cast to ViewGroup` exception on Android. ([#23264](https://github.com/expo/expo/pull/23264) by [@lukmccall](https://github.com/lukmccall))
18
+
19
+ ### 💡 Others
20
+
21
+ - Changed Objective-C names for `ExpoReactDelegate` and `ExpoReactDelegateHandler` to fix issues with versioning in Expo Go. ([#23229](https://github.com/expo/expo/pull/23229) by [@tsapeta](https://github.com/tsapeta))
22
+
23
+ ## 1.5.3 — 2023-06-24
24
+
25
+ ### 🎉 New features
26
+
27
+ - Supported other network CDP types like `Image` and `Media` rather than `Fetch`. ([#23058](https://github.com/expo/expo/pull/23058) by [@kudo](https://github.com/kudo))
28
+
13
29
  ## 1.5.2 — 2023-06-24
14
30
 
15
31
  _This version does not introduce any user-facing changes._
@@ -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.5.2'
9
+ version = '1.5.4'
10
10
 
11
11
  buildscript {
12
12
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -160,7 +160,7 @@ android {
160
160
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
161
161
  consumerProguardFiles 'proguard-rules.pro'
162
162
  versionCode 1
163
- versionName "1.5.2"
163
+ versionName "1.5.4"
164
164
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled.toString()
165
165
 
166
166
  testInstrumentationRunner "expo.modules.TestRunner"
@@ -21,7 +21,16 @@ enum class ResourceType(val value: String) {
21
21
  FONT("Font"),
22
22
  SCRIPT("Script"),
23
23
  FETCH("Fetch"),
24
- OTHER("Other")
24
+ OTHER("Other");
25
+
26
+ companion object {
27
+ fun fromMimeType(mimeType: String): ResourceType = when {
28
+ mimeType.startsWith("image/") -> IMAGE
29
+ mimeType.startsWith("audio") || mimeType.startsWith("video") -> MEDIA
30
+ mimeType.startsWith("font") -> FONT
31
+ else -> OTHER
32
+ }
33
+ }
25
34
  }
26
35
 
27
36
  interface JsonSerializable {
@@ -120,7 +129,7 @@ data class RequestWillBeSentParams(
120
129
  wallTime = now,
121
130
  redirectHasExtraInfo = redirectResponse != null,
122
131
  redirectResponse = redirectResponse?.let { Response(it) },
123
- type = ResourceType.FETCH,
132
+ type = ResourceType.OTHER,
124
133
  )
125
134
 
126
135
  override fun toJSONObject(): JSONObject {
@@ -172,11 +181,11 @@ data class ResponseReceivedParams(
172
181
  val response: Response,
173
182
  val hasExtraInfo: Boolean = false,
174
183
  ) : JsonSerializable {
175
- constructor(now: BigDecimal, requestId: RequestId, request: okhttp3.Request, repsonse: okhttp3.Response) : this(
184
+ constructor(now: BigDecimal, requestId: RequestId, request: okhttp3.Request, okhttpResponse: okhttp3.Response) : this(
176
185
  requestId = requestId,
177
186
  timestamp = now,
178
- type = ResourceType.FETCH,
179
- response = Response(repsonse),
187
+ type = ResourceType.fromMimeType(okhttpResponse.header("Content-Type", "") ?: ""),
188
+ response = Response(okhttpResponse),
180
189
  )
181
190
 
182
191
  override fun toJSONObject(): JSONObject {
@@ -0,0 +1,11 @@
1
+ package expo.modules.kotlin.views
2
+
3
+ import android.content.Context
4
+ import android.view.ViewGroup
5
+
6
+ /**
7
+ * A NOOP view group, which is used when an error occurs.
8
+ */
9
+ class ErrorViewGroup(context: Context) : ViewGroup(context) {
10
+ override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) = Unit
11
+ }
@@ -334,7 +334,12 @@ class ViewDefinitionBuilder<T : View>(
334
334
  UnexpectedException(e)
335
335
  }
336
336
  )
337
- return View(context)
337
+
338
+ return if (ViewGroup::class.java.isAssignableFrom(viewClass.java)) {
339
+ ErrorViewGroup(context)
340
+ } else {
341
+ View(context)
342
+ }
338
343
  }
339
344
 
340
345
  private fun getPrimaryConstructor(): KFunction<T>? {
@@ -10,5 +10,5 @@ if (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {
10
10
  });
11
11
  }
12
12
  // We have to export `CodedError` via global object to use in later in the C++ code.
13
- global.ExpoModulesCore_CodedError = CodedError;
13
+ globalThis.ExpoModulesCore_CodedError = CodedError;
14
14
  //# sourceMappingURL=setUpErrorManager.fx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setUpErrorManager.fx.js","sourceRoot":"","sources":["../../src/sweet/setUpErrorManager.fx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,IAAI,OAAO,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,kBAAkB,EAAE;IAC9D,MAAM,cAAc,GAAG,4CAA4C,CAAC;IACpE,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAAC;IAE1D,YAAY,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,EAAE,OAAO,EAAuB,EAAE,EAAE;QAC5E,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;CACJ;AAED,oFAAoF;AACpF,MAAM,CAAC,0BAA0B,GAAG,UAAU,CAAC","sourcesContent":["import { EventEmitter } from '../EventEmitter';\nimport Platform from '../Platform';\nimport { CodedError } from '../errors/CodedError';\nimport NativeErrorManager from './NativeErrorManager';\n\nif (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {\n const onNewException = 'ExpoModulesCoreErrorManager.onNewException';\n const eventEmitter = new EventEmitter(NativeErrorManager);\n\n eventEmitter.addListener(onNewException, ({ message }: { message: string }) => {\n console.error(message);\n });\n}\n\n// We have to export `CodedError` via global object to use in later in the C++ code.\nglobal.ExpoModulesCore_CodedError = CodedError;\n"]}
1
+ {"version":3,"file":"setUpErrorManager.fx.js","sourceRoot":"","sources":["../../src/sweet/setUpErrorManager.fx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,IAAI,OAAO,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,kBAAkB,EAAE;IAC9D,MAAM,cAAc,GAAG,4CAA4C,CAAC;IACpE,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAAC;IAE1D,YAAY,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,EAAE,OAAO,EAAuB,EAAE,EAAE;QAC5E,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;CACJ;AAED,oFAAoF;AACpF,UAAU,CAAC,0BAA0B,GAAG,UAAU,CAAC","sourcesContent":["import { EventEmitter } from '../EventEmitter';\nimport Platform from '../Platform';\nimport { CodedError } from '../errors/CodedError';\nimport NativeErrorManager from './NativeErrorManager';\n\nif (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {\n const onNewException = 'ExpoModulesCoreErrorManager.onNewException';\n const eventEmitter = new EventEmitter(NativeErrorManager);\n\n eventEmitter.addListener(onNewException, ({ message }: { message: string }) => {\n console.error(message);\n });\n}\n\n// We have to export `CodedError` via global object to use in later in the C++ code.\nglobalThis.ExpoModulesCore_CodedError = CodedError;\n"]}
@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
11
11
  */
12
12
  @interface EXReactDelegateWrapper(Private)
13
13
 
14
- - (instancetype)initWithExpoReactDelegate:(ExpoReactDelegate *)expoReactDelegate;
14
+ - (instancetype)initWithExpoReactDelegate:(EXReactDelegate *)expoReactDelegate;
15
15
 
16
16
  @end
17
17
 
@@ -7,13 +7,13 @@
7
7
 
8
8
  @interface EXReactDelegateWrapper()
9
9
 
10
- @property (nonatomic, weak) ExpoReactDelegate *expoReactDelegate;
10
+ @property (nonatomic, weak) EXReactDelegate *expoReactDelegate;
11
11
 
12
12
  @end
13
13
 
14
14
  @implementation EXReactDelegateWrapper
15
15
 
16
- - (instancetype)initWithExpoReactDelegate:(ExpoReactDelegate *)expoReactDelegate
16
+ - (instancetype)initWithExpoReactDelegate:(EXReactDelegate *)expoReactDelegate
17
17
  {
18
18
  if (self = [super init]) {
19
19
  _expoReactDelegate = expoReactDelegate;
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  An extensible react instance creation delegate. This class will loop through each `ExpoReactDelegateHandler` to determine the winner to create the instance.
5
5
  */
6
- @objc
6
+ @objc(EXReactDelegate)
7
7
  public class ExpoReactDelegate: NSObject {
8
8
  private let handlers: [ExpoReactDelegateHandler]
9
9
 
@@ -5,7 +5,7 @@ import React
5
5
  /**
6
6
  The handler for `ExpoReactDelegate`. A module can implement a handler to process react instance creation.
7
7
  */
8
- @objc
8
+ @objc(EXReactDelegateHandler)
9
9
  open class ExpoReactDelegateHandler: NSObject {
10
10
  public override required init() {}
11
11
 
@@ -17,6 +17,19 @@ struct CdpNetwork {
17
17
  case script = "Script"
18
18
  case fetch = "Fetch"
19
19
  case other = "Other"
20
+
21
+ static func fromMimeType(_ mimeType: String) -> ResourceType {
22
+ if mimeType.starts(with: "image/") {
23
+ return image
24
+ }
25
+ if mimeType.starts(with: "audio/") || mimeType.starts(with: "video/") {
26
+ return media
27
+ }
28
+ if mimeType.starts(with: "font/") {
29
+ return font
30
+ }
31
+ return other
32
+ }
20
33
  }
21
34
 
22
35
  struct ConnectTiming: Encodable {
@@ -91,7 +104,7 @@ struct CdpNetwork {
91
104
  } else {
92
105
  self.redirectResponse = nil
93
106
  }
94
- self.type = ResourceType.fetch
107
+ self.type = ResourceType.other
95
108
  }
96
109
  }
97
110
 
@@ -119,8 +132,8 @@ struct CdpNetwork {
119
132
  init(now: TimeInterval, requestId: RequestId, request: URLRequest, response: HTTPURLResponse) {
120
133
  self.requestId = requestId
121
134
  self.timestamp = now
122
- self.type = ResourceType.fetch
123
135
  self.response = Response(response)
136
+ self.type = ResourceType.fromMimeType(self.response.mimeType)
124
137
  }
125
138
  }
126
139
 
@@ -161,5 +161,31 @@ final class ExpoRequestCdpInterceptorSpec: ExpoSpec {
161
161
  }.resume()
162
162
  }
163
163
  }
164
+
165
+
166
+ it("respect image mimeType to CDP event") {
167
+ waitUntil(timeout: .seconds(2)) { done in
168
+ self.session.dataTask(with: URL(string: "https://avatars.githubusercontent.com/u/12504344")!) { (data, response, error) in
169
+ DispatchQueue.main.async {
170
+ expect(self.mockDelegate.events.count).to(equal(5))
171
+
172
+ // Network.requestWillBeSent
173
+ // Network.requestWillBeSentExtraInfo
174
+
175
+ // Network.responseReceived
176
+ let json = self.parseJSON(data: self.mockDelegate.events[2])
177
+ let method = json["method"] as! String
178
+ let params = json["params"] as! [String: Any]
179
+ let response = params["response"] as! [String: Any]
180
+ expect(method).to(equal("Network.responseReceived"))
181
+ expect(response["status"] as? Int).to(equal(200))
182
+ expect(response["mimeType"] as? String).to(equal("image/png"))
183
+ expect(params["type"] as? String).to(equal("Image"))
184
+
185
+ done()
186
+ }
187
+ }.resume()
188
+ }
189
+ }
164
190
  }
165
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
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": "0efde1d91bcf609c94a9f9b57f47afd9ef315e2d"
45
+ "gitHead": "cf90d5c30c2a08a6493ebfa8aa3791aa70666759"
46
46
  }
@@ -13,4 +13,4 @@ if (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {
13
13
  }
14
14
 
15
15
  // We have to export `CodedError` via global object to use in later in the C++ code.
16
- global.ExpoModulesCore_CodedError = CodedError;
16
+ globalThis.ExpoModulesCore_CodedError = CodedError;