expo-modules-jsi 57.0.6 → 57.0.7

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,13 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 57.0.7 — 2026-09-01
14
+
15
+ ### 💡 Others
16
+
17
+ - [iOS] `JavaScriptValue.undefined` and `JavaScriptValue.null` now return shared immortal instances instead of allocating a new value on each access, removing one allocation from every void-returning host call. ([#49545](https://github.com/expo/expo/pull/49545) by [@tsapeta](https://github.com/tsapeta))
18
+ - [iOS] `CppError::tryCatch` now takes a C++ callable instead of an Objective-C block. Every caller already passes a pure C++ body, so the block bridged no Swift closure and only added a non-inlinable indirect call and an Objective-C runtime dependency on the JS call/eval error-handling path. ([#48333](https://github.com/expo/expo/pull/48333) by [@tsapeta](https://github.com/tsapeta))
19
+
13
20
  ## 57.0.6 — 2026-08-26
14
21
 
15
22
  ### 💡 Others
@@ -600,18 +600,25 @@ public final class JavaScriptValue: JavaScriptType, Equatable, Escapable {
600
600
 
601
601
  // MARK: - Runtime-free initializers
602
602
 
603
+ // Shared immortal instances for the runtime-free `undefined`/`null` kinds. The class is fully
604
+ // immutable and these carry no runtime and a trivial `jsi::Value`, so one instance can be safely
605
+ // handed out from any isolation context. Every void-returning `@JS` function returns `.undefined`,
606
+ // so a computed getter here would allocate on every host call.
607
+ private static let sharedUndefined = JavaScriptValue(nil, facebook.jsi.Value.undefined())
608
+ private static let sharedNull = JavaScriptValue(nil, facebook.jsi.Value.null())
609
+
603
610
  /// This is a lightweight way to create an undefined value that can be used in contexts
604
611
  /// where a runtime is not available or needed. The resulting value can be passed to
605
612
  /// JavaScript functions or used in comparisons.
606
613
  public static var undefined: JavaScriptValue {
607
- JavaScriptValue(nil, facebook.jsi.Value.undefined())
614
+ return sharedUndefined
608
615
  }
609
616
 
610
617
  /// This is a lightweight way to create a null value that can be used in contexts
611
618
  /// where a runtime is not available or needed. The resulting value represents
612
619
  /// JavaScript's `null`, which is distinct from `undefined`.
613
620
  public static var null: JavaScriptValue {
614
- JavaScriptValue(nil, facebook.jsi.Value.null())
621
+ return sharedNull
615
622
  }
616
623
 
617
624
  /// This is a lightweight way to create a boolean true value that can be used in contexts
@@ -68,12 +68,18 @@ public:
68
68
  }
69
69
 
70
70
  /**
71
- Executes a block of code and catches any C++ exceptions that are thrown.
71
+ Executes a C++ callable and catches any C++ exceptions that are thrown.
72
72
  Caught exceptions are stored in thread-local storage and can be retrieved
73
73
  using `getCurrent()`. The function returns `nullptr` when an exception occurs.
74
+
75
+ Takes a forwarding reference to a C++ callable (e.g. a lambda) rather than an
76
+ Objective-C block. Every caller passes a pure C++ body, so no Swift closure
77
+ crosses this boundary; the block only added a non-inlinable indirect call and
78
+ a dependency on the Objective-C runtime. This helper is C++-only and is not
79
+ imported into Swift.
74
80
  */
75
- template <typename Result>
76
- inline static Result tryCatch(jsi::IRuntime &runtime, Result(^block)(void)) {
81
+ template <typename Fn>
82
+ inline static auto tryCatch(jsi::IRuntime &runtime, Fn &&block) -> decltype(block()) {
77
83
  try {
78
84
  return block();
79
85
  } catch (jsi::JSError e) {
@@ -136,25 +136,25 @@ inline void destroyRuntime(jsi::Runtime &runtime) {
136
136
  }
137
137
 
138
138
  inline jsi::Value evaluateJavaScript(jsi::IRuntime &runtime, const std::shared_ptr<const jsi::Buffer>& buffer, const std::string& sourceURL) {
139
- return expo::CppError::tryCatch(runtime, ^{
139
+ return expo::CppError::tryCatch(runtime, [&] {
140
140
  return runtime.evaluateJavaScript(buffer, sourceURL);
141
141
  });
142
142
  }
143
143
 
144
144
  inline jsi::Value callFunction(jsi::IRuntime &runtime, const jsi::Function &function, const jsi::Value *_Nullable args, size_t count) {
145
- return expo::CppError::tryCatch(runtime, ^{
145
+ return expo::CppError::tryCatch(runtime, [&] {
146
146
  return function.call(runtime, args, count);
147
147
  });
148
148
  }
149
149
 
150
150
  inline jsi::Value callFunctionWithThis(jsi::IRuntime &runtime, const jsi::Function &function, const jsi::Object &jsThis, const jsi::Value *_Nullable args, size_t count) {
151
- return expo::CppError::tryCatch(runtime, ^{
151
+ return expo::CppError::tryCatch(runtime, [&] {
152
152
  return function.callWithThis(runtime, jsThis, args, count);
153
153
  });
154
154
  }
155
155
 
156
156
  inline jsi::Value callAsConstructor(jsi::IRuntime &runtime, const jsi::Function &function, const jsi::Value *_Nullable args, size_t count) {
157
- return expo::CppError::tryCatch(runtime, ^{
157
+ return expo::CppError::tryCatch(runtime, [&] {
158
158
  return function.callAsConstructor(runtime, args, count);
159
159
  });
160
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-jsi",
3
- "version": "57.0.6",
3
+ "version": "57.0.7",
4
4
  "description": "The JavaScript Interface for Expo Modules",
5
5
  "main": "index.js",
6
6
  "sideEffects": [],
@@ -41,7 +41,7 @@
41
41
  "./apple/scripts/test.sh"
42
42
  ]
43
43
  },
44
- "gitHead": "c300d2cc60c9e684e64f48d9bc90ea18a571d01d",
44
+ "gitHead": "b76ecf192c5325793bcea31dd9bb8efd91f9ad7f",
45
45
  "scripts": {
46
46
  "build": "apple/scripts/build-xcframework.sh",
47
47
  "clean": "apple/scripts/clear-caches.sh",