Skip to content

Commit

Permalink
feat: update node engine to v22.12.0
Browse files Browse the repository at this point in the history
fix: fix some warnings
  • Loading branch information
ShrBox committed Jan 7, 2025
1 parent de21675 commit 0e96931
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/legacy/api/BlockAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Local<Value> BlockClass::destroyBlock(const Arguments& args) {

Local<Value> BlockClass::getNbt(const Arguments&) {
try {
return NbtCompoundClass::pack(std::move(block->getSerializationId().clone()));
return NbtCompoundClass::pack(block->getSerializationId().clone());
}
CATCH("Fail in getNbt!");
}
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/api/FileSystemAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ Local<Value> FileClass::writeLine(const Arguments& args) {
if (args.size() >= 2) CHECK_ARG_TYPE(args[1], ValueKind::kFunction);

try {
std::string data{std::move(args[0].asString().toString())};
std::string data{args[0].asString().toString()};

script::Global<Function> callbackFunc;
if (args.size() >= 2) callbackFunc = args[1].asFunction();
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/api/ItemAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ Local<Value> ItemClass::setDamage(const Arguments& args) {

Local<Value> ItemClass::getNbt(const Arguments&) {
try {
return NbtCompoundClass::pack(std::move(get()->save(*SaveContextFactory::createCloneSaveContext())));
return NbtCompoundClass::pack(get()->save(*SaveContextFactory::createCloneSaveContext()));
}
CATCH("Fail in getNbt!");
}
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/api/StructureAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Local<Value> McClass::getStructure(const Arguments& args) {
ignoreEntities
);

return NbtCompoundClass::pack(std::move(structure->save()));
return NbtCompoundClass::pack(structure->save());
}
CATCH("Fail in getStructure!");
}
Expand Down
19 changes: 12 additions & 7 deletions src/legacy/main/NodeJsHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ bool initNodeJs() {
auto path = ll::string_utils::wstr2str(buf) + "\\bedrock_server_mod.exe";
char* cPath = (char*)path.c_str();
uv_setup_args(1, &cPath);
args = {path};
std::vector<std::string> errors;
auto exitCode = node::InitializeNodeWithArgs(&args, &exec_args, &errors);
if (exitCode != 0) {
args = {path};
auto result = node::InitializeOncePerProcess(
args,
node::ProcessInitializationFlags::Flags(
node::ProcessInitializationFlags::kNoInitializeV8
| node::ProcessInitializationFlags::kNoInitializeNodeV8Platform
)
);
exec_args = result->exec_args();
if (result->exit_code() != 0) {
lse::getSelfModInstance().getLogger().error("Failed to initialize node! NodeJs plugins won't be loaded");
return false;
}
Expand All @@ -67,7 +73,7 @@ bool initNodeJs() {

void shutdownNodeJs() {
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
}

script::ScriptEngine* newEngine() {
Expand Down Expand Up @@ -132,8 +138,7 @@ bool loadPluginCode(script::ScriptEngine* engine, std::string entryScriptPath, s
auto it = setups->find(engine);
if (it == setups->end()) return false;

auto isolate = it->second->isolate();
auto env = it->second->env();
auto env = it->second->env();

try {
using namespace v8;
Expand Down
3 changes: 2 additions & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ target("legacy-script-engine")

elseif is_config("backend", "nodejs") then
add_defines(
"LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS"
"LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS",
"USING_V8_PLATFORM_SHARED"
)
set_basename("legacy-script-engine-nodejs")
after_build(function(target)
Expand Down

0 comments on commit 0e96931

Please sign in to comment.