Skip to content

Commit

Permalink
Merge tag 'dev/16.2.14-dev.1' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzz-dev committed Oct 1, 2024
2 parents 38ecccf + 621bfb0 commit 3333854
Show file tree
Hide file tree
Showing 3,831 changed files with 1,344,725 additions and 43,413 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
cd server
mkdir -p upload/modules/js-module
cp ./dist/libjs-module.so ./upload/modules/js-module
cp ./dist/libnode.so.108 ./upload/modules/js-module
cp ./dist/libnode.so ./upload/modules/js-module
echo ${{ steps.version.outputs.SDK_COMMIT }} >> ./upload/sdk.version
- uses: actions/upload-artifact@v3
Expand Down
16 changes: 8 additions & 8 deletions client/cmake/DepsDownload.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ include(../shared/cmake/DepsHelpers.cmake)

# Set this to false, when using a custom v8 build for testing
set(__deps_check_enabled true)
set(V8_VERSION "12.4.254")

function(DownloadDeps)
set(__base_path "${PROJECT_SOURCE_DIR}/deps/v8")

GetBranchAndOS(__deps_branch __deps_os_path_name)
set(__deps_url_base_path "https://cdn.alt-mp.com/deps/v8/${__deps_branch}")
set(__deps_url_base_path "https://cdn.alt-mp.com/deps/v8/${V8_VERSION}")

if(__deps_check_enabled)
message("Checking release binaries...")

GetCDNInfo("${__deps_url_base_path}/${__deps_os_path_name}/Release" __deps_release_hashes __deps_current_version)

DownloadFile("v8_monolith.lib" "${__base_path}/lib/Release" "${__deps_os_path_name}/Release" ${__deps_release_hashes})

# Only download debug binary in Debug builds
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Checking debug binaries...")

GetCDNInfo("${__deps_url_base_path}/${__deps_os_path_name}/Debug" __deps_debug_hashes __deps_current_version)

DownloadFile("v8_monolith.lib" "${__base_path}/lib/Debug" "${__deps_os_path_name}/Debug" ${__deps_debug_hashes})
# GetCDNInfo("${__deps_url_base_path}/${__deps_os_path_name}/Debug" __deps_debug_hashes __deps_current_version)
# DownloadFile("v8_monolith.lib" "${__base_path}/lib/Debug" "${__deps_os_path_name}/Debug" ${__deps_debug_hashes})
endif()

GetCDNInfo("${__deps_url_base_path}" __deps_headers_hashes __deps_current_version)
DownloadFile("headers.zip" "${__base_path}/include" "" ${__deps_headers_hashes})
file(ARCHIVE_EXTRACT INPUT "${__base_path}/include/headers.zip" DESTINATION "${__base_path}/..")
GetCDNInfo("${__deps_url_base_path}/include" __deps_headers_hashes __deps_current_version)
DownloadFile("include.zip" "${__base_path}/include" "include" ${__deps_headers_hashes})
file(ARCHIVE_EXTRACT INPUT "${__base_path}/include/include.zip" DESTINATION "${__base_path}/include")
file(REMOVE "${__base_path}/include/include.zip")

if(__deps_current_version)
message("V8 deps version: ${__deps_current_version}")
Expand Down
10 changes: 7 additions & 3 deletions client/src/CV8Resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,16 @@ v8::MaybeLocal<v8::Value> EvaluateSyntheticModule(v8::Local<v8::Context> context

v8::Local<v8::Module> CV8ResourceImpl::CreateSyntheticModule(const std::string& name, v8::Local<v8::Value> exportValue)
{
std::vector<v8::Local<v8::String>> exports = {V8Helpers::JSValue("default")};
v8::Local<v8::String> defaultExport = V8Helpers::JSValue("default");
v8::MemorySpan<const v8::Local<v8::String>> exports = { &defaultExport, 1 };

v8::Local<v8::Module> syntheticModule = v8::Module::CreateSyntheticModule(
isolate, V8Helpers::JSValue(name), exports, &EvaluateSyntheticModule);
isolate, V8Helpers::JSValue(name), exports, &EvaluateSyntheticModule);

syntheticModuleExports.insert({
syntheticModule->GetIdentityHash(), V8Helpers::CPersistent<v8::Value>(isolate, exportValue)
});
});

return syntheticModule;
}

Expand Down
31 changes: 20 additions & 11 deletions client/src/CV8ScriptRuntime.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@

#include "CV8ScriptRuntime.h"
#include "inspector/CV8InspectorClient.h"
#include "inspector/CV8InspectorChannel.h"
#include "V8Module.h"
#include "events/Events.h"
#include "CProfiler.h"
#include "CProfiler.h"
#include <Windows.h>

CV8ScriptRuntime::CV8ScriptRuntime()
{
// !!! Don't change these without adjusting bytecode module !!!
v8::V8::SetFlagsFromString("--harmony-import-assertions --short-builtin-calls --no-lazy --no-flush-bytecode");
platform = v8::platform::NewDefaultPlatform();
platform = v8::platform::NewDefaultPlatform();

v8::LogEventCallback;

v8::V8::InitializePlatform(platform.get());
v8::V8::InitializeICU((alt::ICore::Instance().GetClientPath() + "/libs/icudtl_v8.dat").c_str());
// MessageBoxA(NULL, "js init 3", "", MB_OK);
v8::V8::Initialize();

create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
Expand All @@ -22,9 +26,10 @@ CV8ScriptRuntime::CV8ScriptRuntime()
isolate->SetFatalErrorHandler([](const char* location, const char* message) { Log::Error << "[V8] " << location << ": " << message << Log::Endl; });

isolate->SetOOMErrorHandler(
[](const char* location, bool isHeap)
[](const char* location, const v8::OOMDetails& details)
{
if(!isHeap) return;
if(!details.is_heap_oom) return;

Log::Error << "[V8] " << location << ": Heap out of memory. Forward this to the server developers." << Log::Endl;
Log::Error << "[V8] The current heap limit can be shown with the 'heap' console command. Consider increasing your system RAM." << Log::Endl;
});
Expand Down Expand Up @@ -79,22 +84,26 @@ CV8ScriptRuntime::CV8ScriptRuntime()
});

isolate->SetHostImportModuleDynamicallyCallback(
[](v8::Local<v8::Context> context, v8::Local<v8::ScriptOrModule> referrer, v8::Local<v8::String> specifier, v8::Local<v8::FixedArray> importAssertions)
[](v8::Local<v8::Context> context,
v8::Local<v8::Data> host_defined_options,
v8::Local<v8::Value> resource_name,
v8::Local<v8::String> specifier,
v8::Local<v8::FixedArray> import_attributes)
{
v8::Isolate* isolate = context->GetIsolate();

auto referrerVal = referrer->GetResourceName();
if(referrerVal->IsUndefined()) return v8::MaybeLocal<v8::Promise>();
if(resource_name->IsUndefined())
return v8::MaybeLocal<v8::Promise>();

std::string referrerUrl = *v8::String::Utf8Value(isolate, referrer->GetResourceName());
std::string referrerUrl = *v8::String::Utf8Value(isolate, resource_name);
auto resource = static_cast<CV8ResourceImpl*>(V8ResourceImpl::Get(context));

auto resolver = v8::Promise::Resolver::New(context).ToLocalChecked();

V8Helpers::CPersistent<v8::Promise::Resolver> presolver(isolate, resolver);
V8Helpers::CPersistent<v8::String> pspecifier(isolate, specifier);
V8Helpers::CPersistent<v8::Module> preferrerModule(isolate, resource->GetModuleFromPath(referrerUrl));
V8Helpers::CPersistent<v8::FixedArray> pimportAssertions(isolate, importAssertions);
V8Helpers::CPersistent<v8::FixedArray> pimportAssertions(isolate, import_attributes);

// careful what we take in by value in the lambda
// it is possible pass v8::Local but should not be done
Expand Down Expand Up @@ -236,7 +245,7 @@ void CV8ScriptRuntime::OnDispose()
while(isolate->IsInUse()) isolate->Exit();
isolate->Dispose();
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
delete create_params.array_buffer_allocator;

if(CProfiler::Instance().IsEnabled()) CProfiler::Instance().Dump(alt::ICore::Instance().GetClientPath());
Expand Down
6 changes: 3 additions & 3 deletions client/src/bindings/Handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ static void DriveBiasRearSetter(v8::Local<v8::String>, v8::Local<v8::Value> val,
V8_TO_NUMBER(val, fvalue);
vehicle->ReplaceHandling();
vehicle->GetHandling()->SetDriveBiasRear(fvalue);
}
}

static void AccelerationGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear");
V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear");

V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle);
Expand All @@ -251,7 +251,7 @@ static void AccelerationGetter(v8::Local<v8::String>, const v8::PropertyCallback

static void AccelerationSetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
{
V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear");
V8_DEPRECATE("HandlingData.acceleration", "HandlingData.driveBiasRear");

V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_INTERNAL_FIELD_ENTITY(1, vehicle, alt::IVehicle);
Expand Down
2 changes: 1 addition & 1 deletion client/src/bindings/HandlingData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void HandlingNameHashGetter(v8::Local<v8::String>, const v8::PropertyCall

V8_GET_THIS_INTERNAL_FIELD_INTEGER(1, modelHash);

uint32_t modelHash2 = info.This()->GetInternalField(0)->IntegerValue(ctx).ToChecked();
uint32_t modelHash2 = info.This()->GetInternalField(0).As<v8::Value>()->IntegerValue(ctx).ToChecked();

auto handling = alt::ICore::Instance().GetHandlingData(modelHash);
V8_CHECK(handling, "handling data for vehicle not found");
Expand Down
2 changes: 1 addition & 1 deletion client/src/bindings/V8Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void* ToMemoryBuffer(v8::Local<v8::Value> val, v8::Local<v8::Context> ctx
if(cls == V8Class::ObjectClass::MEMORY_BUFFER)
{
void* memory = obj->GetAlignedPointerFromInternalField(1);
uint32_t size = obj->GetInternalField(2)->Uint32Value(ctx).ToChecked();
uint32_t size = obj->GetInternalField(2).As<v8::Value>()->Uint32Value(ctx).ToChecked();

if(size > 0) return memory;
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/bindings/Worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_CHECK(worker, "Worker is invalid");

worker->Destroy();
info.This()->SetInternalField(0, v8::External::New(isolate, nullptr));
info.This()->SetInternalField(0, v8::Null(isolate));
static_cast<CV8ResourceImpl*>(resource)->RemoveWorker(worker);
}

Expand Down
14 changes: 10 additions & 4 deletions client/src/workers/CWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ void CWorker::SetupIsolate()
});

isolate->SetHostImportModuleDynamicallyCallback(
[](v8::Local<v8::Context> context, v8::Local<v8::ScriptOrModule> referrer, v8::Local<v8::String> specifier, v8::Local<v8::FixedArray> assertions)
[](v8::Local<v8::Context> context,
v8::Local<v8::Data> host_defined_options,
v8::Local<v8::Value> resource_name,
v8::Local<v8::String> specifier,
v8::Local<v8::FixedArray> import_attributes)
{
v8::Isolate* isolate = context->GetIsolate();
v8::Isolate::Scope isolateScope(isolate);
Expand All @@ -161,13 +165,15 @@ void CWorker::SetupIsolate()
if(maybeResolver.IsEmpty()) return v8::MaybeLocal<v8::Promise>();
v8::Local<v8::Promise::Resolver> resolver = maybeResolver.ToLocalChecked();

// if(!resource_name->IsString()) return v8::MaybeLocal<v8::Promise>();

CWorker* worker = static_cast<CWorker*>(context->GetAlignedPointerFromEmbedderData(2));
std::string referrerName = *v8::String::Utf8Value(isolate, referrer->GetResourceName());
std::string referrerName = *v8::String::Utf8Value(isolate, resource_name);
v8::Local<v8::Module> referrerModule = worker->GetModuleFromPath(referrerName);
if(referrerModule.IsEmpty() && referrerName != "<bootstrapper>") resolver->Reject(context, v8::Exception::ReferenceError(V8Helpers::JSValue("Could not resolve referrer module")));
else
{
v8::MaybeLocal<v8::Module> maybeModule = CWorker::Import(context, specifier, assertions, referrerModule);
v8::MaybeLocal<v8::Module> maybeModule = CWorker::Import(context, specifier, import_attributes, referrerModule);
if(maybeModule.IsEmpty()) resolver->Reject(context, v8::Exception::ReferenceError(V8Helpers::JSValue("Could not resolve module")));
else
{
Expand Down Expand Up @@ -218,7 +224,7 @@ bool CWorker::SetupScript()
{
v8::Local<v8::Context> ctx = context.Get(isolate);
v8::MaybeLocal<v8::Module> maybeModule;
v8::ScriptOrigin scriptOrigin(isolate, V8Helpers::JSValue("<bootstrapper>"), 0, 0, false, -1, v8::Local<v8::Value>(), false, false, true, v8::Local<v8::PrimitiveArray>());
v8::ScriptOrigin scriptOrigin(V8Helpers::JSValue("<bootstrapper>"), 0, 0, false, -1, v8::Local<v8::Value>(), false, false, true, v8::Local<v8::PrimitiveArray>());
v8::ScriptCompiler::Source source{ V8Helpers::JSValue(bootstrap_code), scriptOrigin };
maybeModule = v8::ScriptCompiler::CompileModule(isolate, &source);

Expand Down
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Add a C++ file to your project with following content and include it in the `so

extern "C" NODE_EXTERN void node_module_register(void* mod)
{
auto base_ptr = dlopen("libnode.so.108", RTLD_NOW | RTLD_GLOBAL);
auto base_ptr = dlopen("libnode.so", RTLD_NOW | RTLD_GLOBAL);
if (base_ptr == nullptr) return;
auto register_func = reinterpret_cast<decltype(&node_module_register)>(dlsym(base_ptr, "node_module_register"));
if (register_func == nullptr) return;
Expand Down
3 changes: 2 additions & 1 deletion server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ include_directories(
deps/nodejs/deps/v8/include
deps/nodejs/deps/uv/include
deps/nodejs/deps/openssl/openssl/include
deps/nodejs/deps/simdjson
../shared
../shared/deps
)
Expand Down Expand Up @@ -157,5 +158,5 @@ if (WIN32)
endif (WIN32)

if (UNIX)
target_link_libraries(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/deps/nodejs/lib/libnode.so.108)
target_link_libraries(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/deps/nodejs/lib/libnode.so)
endif (UNIX)
2 changes: 1 addition & 1 deletion server/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ if [ ! -d "./dist" ]; then
mkdir dist
fi
cp ./build-linux/libjs-module.so dist
cp ./deps/nodejs/lib/libnode.so.108 dist
cp ./deps/nodejs/lib/libnode.so dist
9 changes: 4 additions & 5 deletions server/cmake/DepsDownload.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ include(../shared/cmake/DepsHelpers.cmake)

# Set this to false, when using a custom nodejs build for testing
set(__deps_check_enabled true)
set(NODEJS_VERSION "22.8.0")

function(DownloadDeps)
set(__base_path "${PROJECT_SOURCE_DIR}/deps/nodejs/lib")

GetBranchAndOS(__deps_branch __deps_os_path_name)
set(__deps_url_base_path "https://cdn.alt-mp.com/deps/nodejs/${__deps_branch}/${__deps_os_path_name}")
set(__deps_url_base_path "https://cdn.alt-mp.com/deps/nodejs/${NODEJS_VERSION}/${__deps_os_path_name}")

if(__deps_check_enabled)
if(WIN32)
Expand All @@ -32,11 +33,9 @@ function(DownloadDeps)

GetCDNInfo("${__deps_url_base_path}" __deps_linux_hashes __deps_current_version)

DownloadFile("libnode.so.108" "${__base_path}" "" ${__deps_linux_hashes})
DownloadFile("libnode.so" "${__base_path}" "" ${__deps_linux_hashes})
endif()

if(__deps_current_version)
message("NodeJS deps version: ${__deps_current_version}")
endif()
message("NodeJS deps version: ${NODEJS_VERSION}")
endif()
endfunction()
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

#define PLATFORM "platform: BSD-x86"
#define DATE "built on: Thu Nov 3 02:13:54 2022 UTC"
#define DATE "built on: Wed Jan 31 12:57:29 2024 UTC"

/*
* Generate compiler_flags as an array of individual characters. This is a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ int BIO_meth_set_puts(BIO_METHOD *biom,
int (*puts) (BIO *, const char *));
int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);
int BIO_meth_set_gets(BIO_METHOD *biom,
int (*gets) (BIO *, char *, int));
int (*ossl_gets) (BIO *, char *, int));
long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);
int BIO_meth_set_ctrl(BIO_METHOD *biom,
long (*ctrl) (BIO *, int, long, void *));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WARNING: do not edit!
* Generated by Makefile from include/openssl/cmp.h.in
*
* Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved.
* Copyright Nokia 2007-2019
* Copyright Siemens AG 2015-2019
*
Expand Down Expand Up @@ -193,13 +193,16 @@ typedef ASN1_BIT_STRING OSSL_CMP_PKIFAILUREINFO;
* -- CertReqMsg
* }
*/
# define OSSL_CMP_PKISTATUS_accepted 0
# define OSSL_CMP_PKISTATUS_grantedWithMods 1
# define OSSL_CMP_PKISTATUS_rejection 2
# define OSSL_CMP_PKISTATUS_waiting 3
# define OSSL_CMP_PKISTATUS_revocationWarning 4
# define OSSL_CMP_PKISTATUS_request -3
# define OSSL_CMP_PKISTATUS_trans -2
# define OSSL_CMP_PKISTATUS_unspecified -1
# define OSSL_CMP_PKISTATUS_accepted 0
# define OSSL_CMP_PKISTATUS_grantedWithMods 1
# define OSSL_CMP_PKISTATUS_rejection 2
# define OSSL_CMP_PKISTATUS_waiting 3
# define OSSL_CMP_PKISTATUS_revocationWarning 4
# define OSSL_CMP_PKISTATUS_revocationNotification 5
# define OSSL_CMP_PKISTATUS_keyUpdateWarning 6
# define OSSL_CMP_PKISTATUS_keyUpdateWarning 6

typedef ASN1_INTEGER OSSL_CMP_PKISTATUS;
DECLARE_ASN1_ITEM(OSSL_CMP_PKISTATUS)
Expand Down Expand Up @@ -439,11 +442,12 @@ int OSSL_CMP_CTX_build_cert_chain(OSSL_CMP_CTX *ctx, X509_STORE *own_trusted,
int OSSL_CMP_CTX_set1_pkey(OSSL_CMP_CTX *ctx, EVP_PKEY *pkey);
int OSSL_CMP_CTX_set1_referenceValue(OSSL_CMP_CTX *ctx,
const unsigned char *ref, int len);
int OSSL_CMP_CTX_set1_secretValue(OSSL_CMP_CTX *ctx, const unsigned char *sec,
const int len);
int OSSL_CMP_CTX_set1_secretValue(OSSL_CMP_CTX *ctx,
const unsigned char *sec, int len);
/* CMP message header and extra certificates: */
int OSSL_CMP_CTX_set1_recipient(OSSL_CMP_CTX *ctx, const X509_NAME *name);
int OSSL_CMP_CTX_push0_geninfo_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav);
int OSSL_CMP_CTX_reset_geninfo_ITAVs(OSSL_CMP_CTX *ctx);
int OSSL_CMP_CTX_set1_extraCertsOut(OSSL_CMP_CTX *ctx,
STACK_OF(X509) *extraCertsOut);
/* certificate template: */
Expand Down Expand Up @@ -499,6 +503,7 @@ ASN1_OCTET_STRING *OSSL_CMP_HDR_get0_recipNonce(const OSSL_CMP_PKIHEADER *hdr);
OSSL_CMP_PKIHEADER *OSSL_CMP_MSG_get0_header(const OSSL_CMP_MSG *msg);
int OSSL_CMP_MSG_get_bodytype(const OSSL_CMP_MSG *msg);
int OSSL_CMP_MSG_update_transactionID(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg);
int OSSL_CMP_MSG_update_recipNonce(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg);
OSSL_CRMF_MSG *OSSL_CMP_CTX_setup_CRM(OSSL_CMP_CTX *ctx, int for_KUR, int rid);
OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx,
const char *propq);
Expand Down
Loading

0 comments on commit 3333854

Please sign in to comment.