expo-modules-core 58.0.20 → 58.0.22

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,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.22
4
+
5
+ ### Patch Changes
6
+
7
+ - [Android] Fix native memory that grew with each module class under Hermes V1, by about 0.57 MiB per class on React Native 0.86 and 0.87 and about 93 KiB on 0.88. `createClass` evaluated a new JavaScript source for each class, and Hermes keeps memory for every evaluated source until the runtime is destroyed. It now evaluates one class factory for each runtime and calls it for each class. On iOS, this code creates only the four base classes (`SharedObject`, `SharedRef`, `EventEmitter` and `NativeModule`). ([#51582](https://github.com/expo/expo/pull/51582) by [@amillez](https://github.com/amillez))
8
+ - Fix an `-Wunused-result` warning in `Worklet.cpp` on Android when building with `react-native-worklets@0.13`. Running a worklet synchronously now discards its return value while the worklet runtime lock is still held, on Android and iOS. ([#51656](https://github.com/expo/expo/pull/51656) by [@tomekzaw](https://github.com/tomekzaw))
9
+ - Fix the `Do not include this file directly` warnings from `react-native-worklets@0.13` on Android and iOS. The worklets integration now includes the specific `Serializable` headers instead of the deprecated `worklets/SharedItems/Serializable.h`. ([#51664](https://github.com/expo/expo/pull/51664) by [@tomekzaw](https://github.com/tomekzaw))
10
+ - Updated dependencies. ([#51583](https://github.com/expo/expo/pull/51583))
11
+ - expo-modules-jsi@58.0.15
12
+
13
+ ## 58.0.21
14
+
15
+ ### Patch Changes
16
+
17
+ - [Web] Fix `globalThis.expo` missing on web when Rolldown or `vite build` on Vite 8 drops `ensureNativeModulesAreInstalled` and the polyfill it imports. The module is now listed in `sideEffects`. ([#51624](https://github.com/expo/expo/pull/51624) by [@Kudo](https://github.com/Kudo))
18
+
3
19
  ## 58.0.20
4
20
 
5
21
  ### Patch Changes
@@ -46,7 +46,7 @@ if (shouldIncludeCompose) {
46
46
  }
47
47
 
48
48
  group = 'host.exp.exponent'
49
- version = '58.0.20'
49
+ version = '58.0.22'
50
50
 
51
51
  def isExpoModulesCoreTests = {
52
52
  Gradle gradle = getGradle()
@@ -175,7 +175,7 @@ android {
175
175
  defaultConfig {
176
176
  consumerProguardFiles 'proguard-rules.pro'
177
177
  versionCode 1
178
- versionName "58.0.20"
178
+ versionName "58.0.22"
179
179
  buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
180
180
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
181
181
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "reactNativeVersion": "0.88.0",
3
- "sourceHash": "0b72456880c81b38b6a81f2e69eb4cf4",
3
+ "sourceHash": "5d969987e485331bb2f3b9a20d954e37",
4
4
  "variants": [
5
5
  "debug",
6
6
  "release"
@@ -16,5 +16,5 @@
16
16
  "libexpo-modules-jsi.so"
17
17
  ],
18
18
  "stripped": true,
19
- "createdAt": "2026-10-16T05:55:32.127257085Z"
19
+ "createdAt": "2026-10-16T19:27:48.952650783Z"
20
20
  }
Binary file
@@ -4,7 +4,7 @@
4
4
  #include "../JSIContext.h"
5
5
  #include "../JNIDeallocator.h"
6
6
 
7
- #include <worklets/SharedItems/Serializable.h>
7
+ #include <worklets/SharedItems/Serializable/Serializable.h>
8
8
 
9
9
  namespace jni = facebook::jni;
10
10
 
@@ -36,7 +36,7 @@ void Worklet::execute(
36
36
  synchronizable->cthis()->getSerializable()
37
37
  );
38
38
 
39
- workletRuntime->runSync(worklet);
39
+ workletRuntime->runSyncAndDiscard(worklet);
40
40
  }
41
41
 
42
42
  void Worklet::scheduleWithArgs(
@@ -1,21 +1,39 @@
1
1
  // Copyright 2022-present 650 Industries. All rights reserved.
2
2
 
3
- #include <sstream>
4
3
  #include <utility>
5
4
  #include "JSIUtils.h"
6
5
 
7
6
  namespace expo::common {
8
7
 
8
+ static constexpr jsi::UUID classFactoryUUID{0xa1f49c57, 0x6f0a, 0x4775, 0x9f44, 0xcb0673675b4c};
9
+
10
+ // Hermes keeps memory for every evaluated source until the runtime is destroyed, so the
11
+ // constructor source is evaluated once per runtime and the factory is called for each class.
12
+ // The runtime data releases the factory when the runtime is destroyed, and JS code can't reach it.
13
+ static std::shared_ptr<jsi::Function> getClassFactory(jsi::Runtime &runtime) {
14
+ if (std::shared_ptr<void> cached = runtime.getRuntimeData(classFactoryUUID)) {
15
+ return std::static_pointer_cast<jsi::Function>(cached);
16
+ }
17
+ std::shared_ptr<jsi::StringBuffer> sourceBuffer = std::make_shared<jsi::StringBuffer>(
18
+ "(function (name) {"
19
+ " const klass = function (...args) { return this.__native_constructor__(...args); };"
20
+ " Object.defineProperty(klass, 'name', { value: name });"
21
+ " return klass;"
22
+ "})"
23
+ );
24
+ auto factory = std::make_shared<jsi::Function>(
25
+ runtime.evaluateJavaScript(sourceBuffer, "expo-modules-core/class-factory.js").asObject(runtime).asFunction(runtime)
26
+ );
27
+ runtime.setRuntimeData(classFactoryUUID, factory);
28
+ return factory;
29
+ }
30
+
9
31
  jsi::Function createClass(jsi::Runtime &runtime, const char *name, ClassConstructor constructor) {
10
32
  std::string nativeConstructorKey("__native_constructor__");
11
33
 
12
- // Create a string buffer of the source code to evaluate.
13
- std::stringstream source;
14
- source << "(function " << name << "(...args) { return this." << nativeConstructorKey << "(...args); })";
15
- std::shared_ptr<jsi::StringBuffer> sourceBuffer = std::make_shared<jsi::StringBuffer>(source.str());
16
-
17
- // Evaluate the code and obtain the returned value (the constructor function).
18
- jsi::Object klass = runtime.evaluateJavaScript(sourceBuffer, "").asObject(runtime);
34
+ jsi::Object klass = getClassFactory(runtime)
35
+ ->call(runtime, jsi::String::createFromUtf8(runtime, name))
36
+ .asObject(runtime);
19
37
 
20
38
  // Set the native constructor in the prototype.
21
39
  jsi::Object prototype = klass.getPropertyAsObject(runtime, "prototype");
@@ -8,7 +8,8 @@
8
8
  #include <memory>
9
9
  #include <vector>
10
10
  #include <worklets/Compat/StableApi.h>
11
- #include <worklets/SharedItems/Serializable.h>
11
+ #include <worklets/SharedItems/Serializable/Serializable.h>
12
+ #include <worklets/SharedItems/Serializable/SerializableWorklet.h>
12
13
  #include <worklets/WorkletRuntime/WorkletRuntime.h>
13
14
 
14
15
  namespace jsi = facebook::jsi;
@@ -233,8 +234,8 @@ static jsi::Value callWorklet(jsi::Runtime &rt, std::shared_ptr<worklets::Serial
233
234
  return;
234
235
  }
235
236
 
236
- workletRuntime->runSync([worklet, arguments](jsi::Runtime &rt) -> jsi::Value {
237
- return callWorklet(rt, worklet, arguments);
237
+ workletRuntime->runSync([worklet, arguments](jsi::Runtime &rt) {
238
+ callWorklet(rt, worklet, arguments);
238
239
  });
239
240
  }
240
241
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "58.0.20",
3
+ "version": "58.0.22",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "keywords": [
6
6
  "expo",
@@ -24,7 +24,9 @@
24
24
  "*.fx.ts",
25
25
  "*.fx.js",
26
26
  "./src/polyfill/*.ts",
27
- "./build/polyfill/*.js"
27
+ "./build/polyfill/*.js",
28
+ "./src/ensureNativeModulesAreInstalled.ts",
29
+ "./build/ensureNativeModulesAreInstalled.js"
28
30
  ],
29
31
  "main": "build/index.js",
30
32
  "types": "build/index.d.ts",
@@ -64,7 +66,7 @@
64
66
  "./package.json": "./package.json"
65
67
  },
66
68
  "dependencies": {
67
- "expo-modules-jsi": "~58.0.14",
69
+ "expo-modules-jsi": "~58.0.15",
68
70
  "expo-modules-macros": "0.20.0",
69
71
  "invariant": "^2.2.4"
70
72
  },