[android][expo-media-library] migrate to new modules API (#20232)# Why Migrate native module to use new modules API # How This was a much larger migration than any I have attempted before so I
[android][expo-media-library] migrate to new modules API (#20232)# Why Migrate native module to use new modules API # How This was a much larger migration than any I have attempted before so I will need feedback from the team. Maybe something of this size is not wanted from external contributors. Followed the typical migration steps. Note - One of the functions `getAssetsAsync` accepts an options object. One of the parameters is an array that can be a mixed type. A string or a tuple. I wasn't sure how to type this. The Either type is still marked as experimental so I didn't want to use it. Also, regarding this options type, the `first` variable was used as an`Int` sometimes and a `Double` at other times. I settled on a `Double`. - The module was renamed from `ExponentMediaLibrary` to `ExpoMediaLibrary` - There are cases where I still use `promise.resolve(null)` I'm aware this is not usually necessary but without it, some functions would never resolve - There are some instances where an exception is caught and rejected in the same way it was with the old API. I've got varied feedback on this so I'm not sure which way is preferred - There are cases where functions use things that require a min SDK of 29. In the original code sometimes this was handled and other times it wasn't. Didn't know whether to handle this or leave as it # Test Plan Checked by running the bare expo app and running the existing test suite. After the first iteration, the checks in the bare app all passed but the native unit tests were broken because of the changes in the Pomise API. These were fixed, and now all 43 native tests pass. The JS tests all pass as before.
show more ...
[clipboard][Android] Fixes clipboard listener is called twice (#19723)# Why Fixes clipboard listener is called twice on Android. Fixes clipboard listener crashing the application on Android dur
[clipboard][Android] Fixes clipboard listener is called twice (#19723)# Why Fixes clipboard listener is called twice on Android. Fixes clipboard listener crashing the application on Android during the initialization phase. # How During the `dev-client` QA, I faced two issues with a clipboard. First of all, the listener's called twice for a single event. It was fixed by checking the timestamp. Moreover, the clipboard code may break the application, when the same listener is called in the initialization phase when react modules aren't fully initiated. I've decided to add a function to the app context to check if the react native is alive. # Test Plan - bare-expo ✅
[sweet API][Kotlin] Add a way to pass `Map` as a payload to the `sendEvent` method (#17859)# Why Adds a way to pass `Map<String, Any?>` as a payload to the `sendEvent` method. # How Add tw
[sweet API][Kotlin] Add a way to pass `Map` as a payload to the `sendEvent` method (#17859)# Why Adds a way to pass `Map<String, Any?>` as a payload to the `sendEvent` method. # How Add two new versions of `sendEvent` method: - with empty payload - with `Map<String, Any?> as a payload
[sweet API][Kotlin] Split the implementation of async and sync functions (#17656)# Why Split the implementation of async and sync functions. # How - The `call` method isn't in the base cl
[sweet API][Kotlin] Split the implementation of async and sync functions (#17656)# Why Split the implementation of async and sync functions. # How - The `call` method isn't in the base class `AnyFunction`. It was moved to the `appropriate` components. - I've added a common class for all of async functions - `AsyncFunction` - `function(...).runSynchronously` isn't available anymore - new component `Function` was introduced - Unfortunately, I had to add another builder for suspend functions which defer construction until we have access to the module's coroutine scope. # Test Plan - unit tests ✅ - instrumental tests ✅
[test-core][android] Support testing sync functions (#17641)* Clean up test utils, leverage contracts * Test support for sync functions - `ModuleHolder` already had support for test sync call
[test-core][android] Support testing sync functions (#17641)* Clean up test utils, leverage contracts * Test support for sync functions - `ModuleHolder` already had support for test sync calls, but it was unused - Adopted `ModuleMockInvocationHandler` to support sync calls - Deleted unused utils code from tests-core. We prefer to use a promise-less testing approach, but still not sure if deleting it is a good move. - Leveraged Kotlin [Contracts API](https://www.baeldung.com/kotlin/contracts) in some test utils to make testing more convenient
[test-core][android] Improve module mocking (#17519)- Exposed a spy object of actual `Module` instance (as a `moduleSpy` variable available in the test block scope). This adds a possibility to mock
[test-core][android] Improve module mocking (#17519)- Exposed a spy object of actual `Module` instance (as a `moduleSpy` variable available in the test block scope). This adds a possibility to mock module class members. - Added a possibility to provide both `Module` and `AppContext` instances to `ModuleMock.createMock` already as a `spyk()` objects. This makes additional mock setup possible. - Added a utility function `assertCodedException` to perform some common assertions of exceptions thrown by module methods. Co-authored-by: Łukasz Kosmaty <[email protected]>
[tests-core][android] Try fix "ReactContext is null" (#17350)The `AppContext` class holds only a weak reference to the `ReactContext` instance. I suspect that when there are lots of tests with diff
[tests-core][android] Try fix "ReactContext is null" (#17350)The `AppContext` class holds only a weak reference to the `ReactContext` instance. I suspect that when there are lots of tests with different Robolectric test configurations (API level, custom shadows etc.), moreover, some of them are being run in parallel, Robolectric sometimes destroys (garbage collects?) the context instance too early, before some tests can finish. I made `AppContext` a spy and overridden the `reactContext` getter to always return a strong reference to the `ReactApplicationContext` object (a proxy to the `android.content.Context`). It is created locally, but the `every { ... } returns context` construct stores the reference in MockK internals. * Fix module mock context * Uncomment clipboard tests
[ios][android] Migrate names of module definition components (#17193)
[core] Rename `expo-modules-tests-core` -> `expo-modules-test-core` (#16928)# Why Rename `expo-modules-tests-core` -> `expo-modules-test-core` # Test Plan - CI