Skip to content

Commit 0199e18

Browse files
committed
fix: workaround for race condition with turbomodule in android.
fix(cpp.js): include prebuilt/_/{config.general.name}/_.h in dependency header search paths
1 parent 1c2e707 commit 0199e18

File tree

45 files changed

+310
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+310
-294
lines changed

packages/cpp.js/CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# cpp.js
22

3+
## 1.0.4
4+
5+
### Patch Changes
6+
7+
- fix: workaround for race condition with turbomodule in android.
8+
9+
## 1.0.1
10+
11+
### Patch Changes
12+
13+
- fix: include prebuilt/_/{config.general.name}/_.h in dependency header search paths
14+
315
## 1.0.0
416

517
### Major Changes

packages/cpp.js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cpp.js",
3-
"version": "1.0.0",
3+
"version": "1.0.4",
44
"license": "MIT",
55
"homepage": "https://cpp.js.org",
66
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cpp.js/src/integration/getCppJsScript.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ function getReactNativeScript(env, modulePrefix) {
5151
}
5252
5353
export function initCppJs(config = {}) {
54-
return new Promise((resolve, reject) => {
54+
return new Promise(async (resolve, reject) => {
5555
if (RNJsiLib && RNJsiLib.start) {
56-
RNJsiLib.start();
56+
await RNJsiLib.start();
5757
setEnv();
5858
const m = Module;
5959
${modulePrefix}

packages/cpp.js/src/integration/getDependFilePath.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function getDependFilePath(source, platform) {
88
const dependPackage = state.config.allDependencies.find((d) => source.startsWith(d.package.name));
99
if (dependPackage) {
1010
const depName = dependPackage.package.name;
11+
const configName = dependPackage.general.name;
1112
const filePath = source.substring(depName.length + 1);
1213

1314
let path;
@@ -19,7 +20,9 @@ export default function getDependFilePath(source, platform) {
1920
path = `${dependPackage.paths.output}/prebuilt/${platform}`;
2021
}
2122

22-
if (fs.existsSync(`${path}/${depName}/${filePath}`)) {
23+
if (fs.existsSync(`${path}/${configName}/${filePath}`)) {
24+
path = `${path}/${configName}/${filePath}`;
25+
} else if (fs.existsSync(`${path}/${depName}/${filePath}`)) {
2326
path = `${path}/${depName}/${filePath}`;
2427
} else if (fs.existsSync(`${path}/${filePath}`)) {
2528
path = `${path}/${filePath}`;

packages/cppjs-core-create-app/CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# create-cpp.js
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
319
## 1.0.1
420

521
### Major Changes

packages/cppjs-core-create-app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-cpp.js",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Create Cpp.js Applications",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-core-create-app#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",
@@ -21,7 +21,7 @@
2121
"@cpp.js/sample-backend-nodejs-wasm": "workspace:^",
2222
"@cpp.js/sample-cloud-cloudflare-worker": "workspace:^",
2323
"@cpp.js/sample-mobile-reactnative-cli": "workspace:^",
24-
"@cpp.js/sample-mobile-reactnative-expo": "1.0.0",
24+
"@cpp.js/sample-mobile-reactnative-expo": "1.0.1",
2525
"fs-extra": "^11.2.0",
2626
"kleur": "^4.1.5",
2727
"prompts": "^2.4.2",

packages/cppjs-core-embind-jsi/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @cpp.js/core-embind-jsi
22

3+
## 1.0.3
4+
5+
### Patch Changes
6+
7+
- fix: workaround for race condition with turbomodule in android.
8+
39
## 1.0.0
410

511
### Major Changes

packages/cppjs-core-embind-jsi/cpp/src/emscripten/bind.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include <unordered_map>
2222
#include <stdlib.h>
2323

24+
#ifdef __ANDROID__
25+
#include <unistd.h>
26+
#endif
2427

2528
using namespace emscripten;
2629
using namespace internal;
@@ -915,6 +918,10 @@ namespace emscripten {
915918
CppJS::setEnv("CPPJS_DATA_PATH", path, false);
916919
jsRuntime = &rt;
917920

921+
#ifdef __ANDROID__
922+
sleep(2);
923+
#endif
924+
918925
char* name = "M";
919926
uint64_t namePtrNumber = reinterpret_cast<uint64_t>(name);
920927
// uint64_t offset = (namePtrNumber >> 32) << 32;

packages/cppjs-core-embind-jsi/js/embind.js

-1
Original file line numberDiff line numberDiff line change
@@ -4748,7 +4748,6 @@ globalThis.Module['ASSERTIONS'] = true;
47484748
export default globalThis.Module;
47494749

47504750
function toArray(vector) {
4751-
console.log('aaaaa', vector);
47524751
const output = [];
47534752
for (let i = 0; i < vector.size(); i += 1) {
47544753
output.push(vector.get(i));

packages/cppjs-core-embind-jsi/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/core-embind-jsi",
3-
"version": "1.0.0",
3+
"version": "1.0.3",
44
"description": "The Embind JSI integration tool enables seamless C++ integration with React Native and Expo.",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-core-embind-jsi#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-plugin-metro/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @cpp.js/plugin-metro
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
310
## 1.0.0
411

512
### Major Changes

packages/cppjs-plugin-metro/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/plugin-metro",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "Cpp.js Metro plugin: A tool for seamless C++ integration with the Metro bundler.",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-plugin-metro#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-plugin-react-native/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @cpp.js/plugin-react-native
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- fix: workaround for race condition with turbomodule in android.
8+
- Updated dependencies
9+
10+
11+
12+
313
## 1.0.0
414

515
### Major Changes

packages/cppjs-plugin-react-native/android/src/main/java/com/jsi/lib/RNJsiLibModule.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.facebook.react.bridge.ReactContextBaseJavaModule;
66
import com.facebook.react.bridge.ReactMethod;
77
import com.facebook.react.bridge.Callback;
8+
import com.facebook.react.bridge.Promise;
89

910
public class RNJsiLibModule extends ReactContextBaseJavaModule {
1011

@@ -16,9 +17,10 @@ public RNJsiLibModule(ReactApplicationContext reactContext) {
1617
Utils.copyAssetFolder(reactContext, "cppjs", reactContext.getCacheDir().getAbsolutePath() + "/cppjs");
1718
}
1819

19-
@ReactMethod(isBlockingSynchronousMethod = true)
20-
public void start() {
20+
@ReactMethod
21+
public void start(Promise promise) {
2122
install(this.reactContext.getJavaScriptContextHolder().get(), this.reactContext.getCacheDir().getAbsolutePath());
23+
promise.resolve(true);
2224
}
2325

2426
@Override

packages/cppjs-plugin-react-native/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/plugin-react-native",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "Cpp.js React Native plugin: A tool for seamless C++ integration with React Native and Expo.",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-plugin-react-native#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-plugin-rollup/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @cpp.js/plugin-rollup
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
310
## 1.0.0
411

512
### Major Changes

packages/cppjs-plugin-rollup/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/plugin-rollup",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "Cpp.js Rollup plugin: A tool for seamless C++ integration with the Rollup bundler.",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-plugin-rollup#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-plugin-vite/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @cpp.js/plugin-vite
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
10+
311
## 1.0.0
412

513
### Major Changes

packages/cppjs-plugin-vite/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/plugin-vite",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "Cpp.js Vite plugin: A tool for seamless C++ integration with the Vite.",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-plugin-vite#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-plugin-webpack-loader/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @cpp.js/plugin-webpack-loader
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
310
## 1.0.0
411

512
### Major Changes

packages/cppjs-plugin-webpack-loader/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/plugin-webpack-loader",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "Cpp.js Webpack loader: A tool for seamless C++ integration with the Webpack bundler.",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-plugin-webpack-loader#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-plugin-webpack/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @cpp.js/plugin-webpack
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
310
## 1.0.0
411

512
### Major Changes

packages/cppjs-plugin-webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/plugin-webpack",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "Cpp.js Webpack plugin: A tool for seamless C++ integration with the Webpack bundler.",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-plugin-rollup#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-sample-backend-nodejs-wasm/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @cpp.js/sample-backend-nodejs-wasm
22

3+
## 1.0.1
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
310
## 1.0.0
411

512
### Major Changes

packages/cppjs-sample-backend-nodejs-wasm/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/sample-backend-nodejs-wasm",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Cpp.js - Node.js webassembly sample",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-sample-backend-nodejs-wasm#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",
@@ -9,11 +9,9 @@
99
"build": "cppjs build -p WebAssembly"
1010
},
1111
"dependencies": {
12+
"cpp.js": "workspace:^",
1213
"@cpp.js/sample-lib-prebuilt-matrix": "workspace:^"
1314
},
14-
"devDependencies": {
15-
"cpp.js": "workspace:^"
16-
},
1715
"keywords": [
1816
"cpp.js-sample",
1917
"node",

packages/cppjs-sample-cloud-cloudflare-worker/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @cpp.js/sample-cloud-cloudflare-worker
22

3+
## 1.0.1
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
310
## 1.0.0
411

512
### Major Changes

packages/cppjs-sample-cloud-cloudflare-worker/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cpp.js/sample-cloud-cloudflare-worker",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Cpp.js - Cloudflare webassembly sample",
55
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-sample-cloud-cloudflare-worker#readme",
66
"repository": "https://github.com/bugra9/cpp.js.git",
@@ -20,8 +20,10 @@
2020
"wrangler.toml",
2121
"src"
2222
],
23+
"dependencies": {
24+
"cpp.js": "workspace:^"
25+
},
2326
"devDependencies": {
24-
"cpp.js": "workspace:^",
2527
"wrangler": "^3.99.0",
2628
"@playwright/test": "^1.49.1"
2729
},

packages/cppjs-sample-mobile-reactnative-cli/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @cpp.js/sample-mobile-reactnative-cli
22

3+
## 1.0.1
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
9+
10+
11+
312
## 1.0.0
413

514
### Major Changes

packages/cppjs-sample-mobile-reactnative-cli/ios/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ PODS:
12431243
- ReactCommon/turbomodule/bridging
12441244
- ReactCommon/turbomodule/core
12451245
- Yoga
1246-
- react-native-cppjs (1.0.0)
1246+
- react-native-cppjs (1.0.2)
12471247
- react-native-cppjs-ios-helper (1.0.0):
12481248
- DoubleConversion
12491249
- glog
@@ -1781,7 +1781,7 @@ SPEC CHECKSUMS:
17811781
React-logger: 697873f06b8ba436e3cddf28018ab4741e8071b6
17821782
React-Mapbuffer: c174e11bdea12dce07df8669d6c0dc97eb0c7706
17831783
React-microtasksnativemodule: 8a80099ad7391f4e13a48b12796d96680f120dc6
1784-
react-native-cppjs: bf43782b3149df83b572fe882f22c65007e467d8
1784+
react-native-cppjs: a557b429a0f33cd5ab0603335113c01f9355fe59
17851785
react-native-cppjs-ios-helper: 24275032a6124028683462f9835d40c135fd6e49
17861786
React-nativeconfig: f7ab6c152e780b99a8c17448f2d99cf5f69a2311
17871787
React-NativeModulesApple: 70600f7edfc2c2a01e39ab13a20fd59f4c60df0b

0 commit comments

Comments
 (0)