Skip to content

Commit ed0e4a3

Browse files
committed
fix script grap
1 parent 7f7bed4 commit ed0e4a3

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"rust-analyzer.checkOnSave": false
2+
"rust-analyzer.checkOnSave": false,
3+
"files.associations": {
4+
"*.jslib": "javascript",
5+
"config": "toml",
6+
"iosfwd": "cpp"
7+
}
38
}

crates/jsbundle/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
const JSBUNDLE_SRC: &str = include_str!("jsbundle.js");
22

33
#[no_mangle]
4-
pub extern "C" fn get_jsbundle() -> *const u8 {
4+
pub extern "C" fn get_jsbundle_ptr() -> *const u8 {
55
JSBUNDLE_SRC.as_ptr()
66
}
7+
8+
#[no_mangle]
9+
pub extern "C" fn get_jsbundle_size() -> usize {
10+
JSBUNDLE_SRC.len()
11+
}

src/runtime/entry.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ class NodeBootstrapper
234234
threadHandle = new std::thread([this]()
235235
{
236236
if (RunNodeInstance(platformOnProcess) != 0)
237-
DEBUG("transmute", "nodejs script exited with error.");
237+
DEBUG("transmute", "nodejs script exited with error.");
238238

239239
started = false;
240240
if (dispose_v8_onexit)
241241
{
242-
V8::Dispose();
243-
V8::DisposePlatform();
244-
node::TearDownOncePerProcess();
242+
V8::Dispose();
243+
V8::DisposePlatform();
244+
node::TearDownOncePerProcess();
245245
} });
246246

247247
started = true;
@@ -291,12 +291,15 @@ extern "C"
291291
if (processInitializationResult != nullptr && platformOnProcess != nullptr)
292292
return 1;
293293

294-
const char *jsbundle_source = reinterpret_cast<const char *>(get_jsbundle());
294+
const char *jsbundle_source = reinterpret_cast<const char *>(get_jsbundle_ptr());
295+
size_t jsbundle_size = get_jsbundle_size();
296+
295297
std::vector<std::string> args = {
296298
"node",
297299
"--experimental-vm-modules",
300+
"--experimental-global-customevent",
298301
"-e",
299-
jsbundle_source};
302+
std::string(jsbundle_source, jsbundle_size)};
300303

301304
#ifdef __ANDROID__
302305
if (isDebug)

0 commit comments

Comments
 (0)