diff --git a/.github/workflows/build-deploy-custom.yml b/.github/workflows/build-deploy-custom.yml index ab2f8a4b..880db04e 100644 --- a/.github/workflows/build-deploy-custom.yml +++ b/.github/workflows/build-deploy-custom.yml @@ -15,7 +15,7 @@ jobs: runs-on: windows-2019 steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive @@ -45,12 +45,12 @@ jobs: copy dist\libnode.dll upload\modules\js-module copy dist\js-module.pdb debug - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: js-module-windows path: ./server/upload/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: js-module-windows-debug path: ./server/debug @@ -60,7 +60,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive @@ -89,7 +89,7 @@ jobs: cp ./dist/libnode.so ./upload/modules/js-module echo ${{ steps.version.outputs.SDK_COMMIT }} >> ./upload/sdk.version - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: js-module-linux path: ./server/upload/ @@ -100,24 +100,24 @@ jobs: needs: [build-linux, build-windows] steps: - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 16.x - name: Cache node_modules - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }} - name: Download windows artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-windows path: dist-windows - name: Download linux artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-linux path: dist-linux @@ -191,19 +191,19 @@ jobs: needs: [build-linux, build-windows] steps: - name: Download windows artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-windows path: dist-windows - name: Download windows debug artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-windows-debug path: dist-windows - name: Download linux artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: js-module-linux path: dist-linux diff --git a/client/src/bindings/ClientBindingsMain.cpp b/client/src/bindings/ClientBindingsMain.cpp index 95a9d08c..e923eaf8 100644 --- a/client/src/bindings/ClientBindingsMain.cpp +++ b/client/src/bindings/ClientBindingsMain.cpp @@ -1360,7 +1360,8 @@ extern V8Module sharedModule; extern V8Class v8Player, v8Player, v8Vehicle, v8WebView, v8HandlingData, v8LocalStorage, v8MemoryBuffer, v8MapZoomData, v8Discord, v8Voice, v8WebSocketClient, v8Checkpoint, v8HttpClient, v8Audio, v8LocalPlayer, v8Profiler, v8Worker, v8RmlDocument, v8RmlElement, v8WeaponData, v8FocusData, v8LocalObject, v8TextEncoder, v8TextDecoder, v8Object, v8VirtualEntityGroup, v8VirtualEntity, v8AudioFilter, v8Marker, v8Ped, v8Colshape, v8ColshapeCylinder, v8ColshapeSphere, v8ColshapeCircle, v8ColshapeCuboid, v8ColshapeRectangle, v8ColshapePolygon, v8TextLabel, - v8LocalPed, v8LocalVehicle, v8Font, v8WeaponObject, v8AudioOutput, v8AudioOutputFrontend, v8AudioOutputWorld, v8AudioOutputAttached, v8AudioCategory, v8Interior, v8InteriorRoom, v8InteriorPortal; + v8LocalPed, v8LocalVehicle, v8Font, v8WeaponObject, v8AudioOutput, v8AudioOutputFrontend, v8AudioOutputWorld, v8AudioOutputAttached, v8AudioCategory, v8Interior, v8InteriorRoom, + v8InteriorPortal, v8SystemInfo; extern V8Module altModule("alt", &sharedModule, { v8Player, @@ -1411,7 +1412,8 @@ extern V8Module altModule("alt", v8AudioCategory, v8Interior, v8InteriorRoom, - v8InteriorPortal }, + v8InteriorPortal, + v8SystemInfo }, [](v8::Local ctx, v8::Local exports) { v8::Isolate* isolate = ctx->GetIsolate(); diff --git a/client/src/bindings/SystemInfo.cpp b/client/src/bindings/SystemInfo.cpp new file mode 100644 index 00000000..73869ae0 --- /dev/null +++ b/client/src/bindings/SystemInfo.cpp @@ -0,0 +1,49 @@ + +#include "V8Helpers.h" +#include "V8ResourceImpl.h" +#include "V8Class.h" + +static void GetCpuLoad(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + V8_RETURN_NUMBER(alt::ICore::Instance().GetCPULoad()); +} + +static void GetVideoMemoryUsage(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + V8_RETURN_NUMBER(alt::ICore::Instance().GetVideoMemoryUsage()); +} + +static void GetRAMUsage(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + V8_RETURN_NUMBER(alt::ICore::Instance().GetRAMUsage()); +} + +static void GetTotalRAM(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + V8_RETURN_NUMBER(alt::ICore::Instance().GetTotalRAM()); +} + +static void GetCurrentProcessRamUsage(v8::Local, const v8::PropertyCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + + V8_RETURN_NUMBER(alt::ICore::Instance().GetCurrentProcessRamUsage()); +} + +extern V8Class v8SystemInfo("SystemInfo", [](v8::Local tpl) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + + V8Helpers::SetStaticAccessor(isolate, tpl, "cpuLoad", GetCpuLoad, nullptr); + V8Helpers::SetStaticAccessor(isolate, tpl, "videoMemoryUsage", GetVideoMemoryUsage, nullptr); + V8Helpers::SetStaticAccessor(isolate, tpl, "ramUsage", GetRAMUsage, nullptr); + V8Helpers::SetStaticAccessor(isolate, tpl, "totalRamSize", GetTotalRAM, nullptr); + V8Helpers::SetStaticAccessor(isolate, tpl, "currentProcessRamUsage", GetCurrentProcessRamUsage, nullptr); +}); diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index 8d2a0845..bb215b36 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit 8d2a0845c4a339bcfdb0c8cf89f3ebd2a3c5ef37 +Subproject commit bb215b36ecf7db2dc96a71347298b441c506cfe6