expo-brownfield 58.0.12 → 58.0.14

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
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies.
8
+ - expo-build-properties@58.0.11
9
+
10
+ ## 58.0.13
11
+
12
+ ### Patch Changes
13
+
14
+ - [iOS][Internal] Define `ExpoBrownfieldModule` and `ExpoBrownfieldStateModule` with the `@ExpoModule`, `@SharedObject`, `@JS` and `@Event` macros instead of the module definition DSL. ([#51381](https://github.com/expo/expo/pull/51381) by [@tsapeta](https://github.com/tsapeta))
15
+ - [Internal] Bump precompiled artifacts due to ABI breakage in expo-modules-jsi, which makes `JavaScriptValue` a non-copyable struct. ([#51368](https://github.com/expo/expo/pull/51368) by [@tsapeta](https://github.com/tsapeta))
16
+ - [iOS] Make `JavaScriptValue` a non-copyable struct. This is a breaking change for Swift code that uses `JavaScriptValue` directly:
17
+
18
+ - Values are moved, not shared. Pass them as `borrowing` or `consuming` parameters, and call `copy()` where a second owned value is needed.
19
+ - `JavaScriptValue.undefined` and `JavaScriptValue.null` are functions now: write `.undefined()` and `.null()`.
20
+ - A `JavaScriptValue` can no longer be an argument or a result of a `Function`, `AsyncFunction`, `Property` or `Field` definition. Declare the function with the `@JS` macro instead (in an `@ExpoModule` or `@SharedObject` class) and take the value as `borrowing JavaScriptValue`, or use a typed argument.
21
+ - To keep a value in an array, an escaping closure or another place that takes copyable types only, wrap it with `value.ref()` and read it back with `take()` or `withUnwrappedValue(_:)`.
22
+ - `JavaScriptArray.init(_:items:)`, `JavaScriptArray.enumerated()`, `JavaScriptArray.filter(_:)` and `JavaScriptValuesBuffer.copying(in:values:)` with an array of values are removed. Use the parameter pack initializer, `forEach`, `forEachIndexed`, `reduce`, or the `[JavaScriptValue.Ref]` overload.
23
+
24
+ ([#51368](https://github.com/expo/expo/pull/51368) by [@tsapeta](https://github.com/tsapeta))
25
+
26
+ - [iOS] Remove the module class declarations from `expo-module.config.json`. Autolinking now detects the `@ExpoModule`-annotated classes. ([#49784](https://github.com/expo/expo/pull/49784) by [@tsapeta](https://github.com/tsapeta))
27
+ - Updated dependencies. ([#51321](https://github.com/expo/expo/pull/51321))
28
+ - @expo/env@2.5.2
29
+
3
30
  ## 58.0.12
4
31
 
5
32
  ### Patch Changes
@@ -4,7 +4,7 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'expo.modules.brownfield'
7
- version = '58.0.12'
7
+ version = '58.0.14'
8
8
 
9
9
  expoModule {
10
10
  canBePublished false
@@ -14,7 +14,7 @@ android {
14
14
  namespace "expo.modules.brownfield"
15
15
  defaultConfig {
16
16
  versionCode 1
17
- versionName '58.0.12'
17
+ versionName '58.0.14'
18
18
  }
19
19
  }
20
20
 
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "platforms": ["apple", "android", "web"],
3
- "apple": {
4
- "modules": ["ExpoBrownfieldModule", "ExpoBrownfieldStateModule"]
5
- },
6
3
  "android": {
7
4
  "modules": [
8
5
  "expo.modules.brownfield.ExpoBrownfieldModule",
@@ -1,49 +1,56 @@
1
1
  import ExpoModulesCore
2
2
 
3
- let NATIVE_MESSAGE_EVENT_NAME = "onMessage"
4
-
5
3
  // MARK: - ExpoBrownfieldModule
6
4
 
5
+ @ExpoModule
7
6
  public class ExpoBrownfieldModule: Module {
8
- public func definition() -> ModuleDefinition {
9
- Name("ExpoBrownfieldModule")
7
+ @Event("onMessage")
8
+ var onMessage: (BrownfieldMessage) -> Void
10
9
 
11
- Events(NATIVE_MESSAGE_EVENT_NAME)
10
+ public override func didStartListening(event: String) {
11
+ BrownfieldMessagingInternal.shared.setExpoModule(self)
12
+ }
12
13
 
13
- OnStartObserving {
14
- BrownfieldMessagingInternal.shared.setExpoModule(self)
15
- }
14
+ public override func didStopListening(event: String) {
15
+ BrownfieldMessagingInternal.shared.clearExpoModule(self)
16
+ }
16
17
 
17
- OnStopObserving {
18
- BrownfieldMessagingInternal.shared.clearExpoModule(self)
18
+ @JS
19
+ func popToNative(_ animated: Bool) {
20
+ DispatchQueue.main.async {
21
+ NotificationCenter.default.post(
22
+ name: Notification.Name("popToNative"),
23
+ object: nil,
24
+ userInfo: ["animated": animated]
25
+ )
19
26
  }
27
+ }
20
28
 
21
- Function("popToNative") { (animated: Bool) in
22
- DispatchQueue.main.async {
23
- NotificationCenter.default.post(
24
- name: Notification.Name("popToNative"),
25
- object: nil,
26
- userInfo: ["animated": animated]
27
- )
28
- }
29
+ @JS
30
+ func setNativeBackEnabled(_ enabled: Bool) {
31
+ DispatchQueue.main.async {
32
+ NotificationCenter.default.post(
33
+ name: Notification.Name("setNativeBackEnabled"),
34
+ object: nil,
35
+ userInfo: ["enabled": enabled]
36
+ )
29
37
  }
38
+ }
30
39
 
31
- Function("setNativeBackEnabled") { (enabled: Bool) in
32
- DispatchQueue.main.async {
33
- NotificationCenter.default.post(
34
- name: Notification.Name("setNativeBackEnabled"),
35
- object: nil,
36
- userInfo: ["enabled": enabled]
37
- )
40
+ @JS
41
+ func sendMessage(_ message: borrowing JavaScriptValue) throws {
42
+ let object = try message.asObject()
43
+ var result: BrownfieldMessage = [:]
44
+
45
+ // Same conversion as the `[String: Any?]` DSL argument: `undefined` properties are dropped
46
+ // and `null` ones are kept as `nil`.
47
+ for key in object.getPropertyNames() {
48
+ let property = object.getProperty(key)
49
+ if property.isUndefined() {
50
+ continue
38
51
  }
52
+ result.updateValue(property.isNull() ? nil : property.getAny(), forKey: key)
39
53
  }
40
-
41
- Function("sendMessage") { (message: BrownfieldMessage) in
42
- BrownfieldMessagingInternal.shared.emit(message)
43
- }
44
- }
45
-
46
- public func sendMessage(_ message: BrownfieldMessage) {
47
- sendEvent(NATIVE_MESSAGE_EVENT_NAME, message)
54
+ BrownfieldMessagingInternal.shared.emit(result)
48
55
  }
49
56
  }
@@ -1,47 +1,27 @@
1
1
  import ExpoModulesCore
2
2
 
3
- let KEY_RECREATED_EVENT_NAME = "onKeyRecreated"
4
-
5
3
  // MARK: - ExpoBrownfieldStateModule
6
4
 
5
+ @ExpoModule(classes: [SharedState.self])
7
6
  public class ExpoBrownfieldStateModule: Module {
8
- public func definition() -> ModuleDefinition {
9
- Name("ExpoBrownfieldStateModule")
10
-
11
- Events(KEY_RECREATED_EVENT_NAME)
12
-
13
- Class(SharedState.self) {
14
- Constructor { (key: String) in
15
- return SharedState(key)
16
- }
17
-
18
- Function("get") { (state: SharedState) -> Any? in
19
- return state.get()
20
- }
21
-
22
- Function("set") { (state: SharedState, value: JavaScriptValue?) in
23
- state.set(value?.getAny())
24
- }
25
- }
7
+ @Event("onKeyRecreated")
8
+ var onKeyRecreated: ([String: String]) -> Void
26
9
 
27
- OnCreate {
28
- BrownfieldStateInternal.shared.setExpoModule(self)
29
- }
30
-
31
- OnDestroy {
32
- BrownfieldStateInternal.shared.clearExpoModule(self)
33
- }
10
+ public override func didCreate() {
11
+ BrownfieldStateInternal.shared.setExpoModule(self)
12
+ }
34
13
 
35
- Function("getSharedState") { (key: String) -> SharedState in
36
- return BrownfieldStateInternal.shared.getOrCreate(key)
37
- }
14
+ public override func willDestroy() {
15
+ BrownfieldStateInternal.shared.clearExpoModule(self)
16
+ }
38
17
 
39
- Function("deleteSharedState") { (key: String) in
40
- BrownfieldStateInternal.shared.delete(key)
41
- }
18
+ @JS
19
+ func getSharedState(_ key: String) -> SharedState {
20
+ return BrownfieldStateInternal.shared.getOrCreate(key)
42
21
  }
43
22
 
44
- public func notifyKeyRecreated(_ key: String) {
45
- sendEvent(KEY_RECREATED_EVENT_NAME, ["key": key])
23
+ @JS
24
+ func deleteSharedState(_ key: String) {
25
+ _ = BrownfieldStateInternal.shared.delete(key)
46
26
  }
47
27
  }
@@ -32,7 +32,7 @@ public class BrownfieldMessagingInternal {
32
32
  let module = expoModule
33
33
  lock.unlock()
34
34
 
35
- module?.sendMessage(message)
35
+ module?.onMessage(message)
36
36
  }
37
37
 
38
38
  func emit(_ message: BrownfieldMessage) {
@@ -1,16 +1,19 @@
1
1
  import ExpoModulesCore
2
2
 
3
+ @SharedObject
3
4
  public final class SharedState: SharedObject {
4
5
  private let lock = NSLock()
5
6
  private let key: String
6
7
  private var value: Any?
7
8
 
8
- public init(_ key: String) {
9
+ @JS
10
+ nonisolated public init(_ key: String) {
9
11
  self.key = key
10
12
  super.init()
11
13
  }
12
14
 
13
- public func get() -> Any? {
15
+ @JS
16
+ nonisolated public func get() -> Any? {
14
17
  lock.lock()
15
18
  defer { lock.unlock() }
16
19
  return value
@@ -25,4 +28,9 @@ public final class SharedState: SharedObject {
25
28
  BrownfieldStateInternal.shared.notifySubscribers(key, newValue)
26
29
  BrownfieldStateInternal.shared.maybeNotifyKeyRecreated(key)
27
30
  }
31
+
32
+ @JS
33
+ func set(fromJS value: borrowing JavaScriptValue) {
34
+ set(value.isUndefined() || value.isNull() ? nil : value.getAny())
35
+ }
28
36
  }
package/ios/State.swift CHANGED
@@ -89,7 +89,7 @@ public final class BrownfieldStateInternal {
89
89
  module = expoModule
90
90
  }
91
91
 
92
- module?.notifyKeyRecreated(key)
92
+ module?.onKeyRecreated(["key": key])
93
93
  }
94
94
 
95
95
  public func setExpoModule(_ expoModule: ExpoBrownfieldStateModule) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-brownfield",
3
- "version": "58.0.12",
3
+ "version": "58.0.14",
4
4
  "description": "Toolkit and APIs for adding brownfield setup to Expo projects",
5
5
  "keywords": [
6
6
  "brownfield",
@@ -38,26 +38,26 @@
38
38
  "./plugin": "./plugin/build/index.js"
39
39
  },
40
40
  "dependencies": {
41
- "@expo/env": "~2.5.1",
41
+ "@expo/env": "~2.5.2",
42
42
  "@expo/spawn-async": "^1.8.0",
43
43
  "chalk": "^4.1.2",
44
44
  "commander": "^14.0.3",
45
45
  "diff": "^5.2.0",
46
- "expo-build-properties": "~58.0.10",
46
+ "expo-build-properties": "~58.0.11",
47
47
  "expo-manifests": "~58.0.1",
48
48
  "ora": "^5.4.1",
49
49
  "prompts": "^2.4.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@bacons/xcode": "1.0.0-alpha.29",
53
+ "@expo/internal-scripts": "58.0.3",
53
54
  "@types/diff": "^5.2.0",
54
55
  "@types/jest": "^30.0.0",
55
56
  "@types/node": "^22.14.0",
56
57
  "@types/prompts": "^2.0.6",
57
58
  "@types/react": "~19.3.0",
58
- "create-expo": "5.1.4",
59
- "expo": "58.0.5",
60
- "expo-module-scripts": "56.0.7",
59
+ "create-expo": "5.1.5",
60
+ "expo": "58.0.14",
61
61
  "glob": "^13.0.6"
62
62
  },
63
63
  "peerDependencies": {