Skip to content

Commit

Permalink
Merge branch 'v1-compatibility' of github.com:altmp/altv-js-module-v2…
Browse files Browse the repository at this point in the history
… into v1-compatibility
  • Loading branch information
LeonMrBonnie committed Oct 22, 2023
2 parents b54504f + ac44a32 commit 0dceefc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
4 changes: 3 additions & 1 deletion shared/js/compatibility/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/// <reference path="../../../types/client/index.d.ts" />
// import * as alt from "@altv/shared";

requireBinding("shared/logging.js");

/**
*
* @param {string} resourceName
Expand Down Expand Up @@ -44,7 +46,7 @@ cppBindings.registerCompatibilityExport("emitRaw", alt.Events.emitRaw);
cppBindings.registerCompatibilityExport("log", alt.log);
cppBindings.registerCompatibilityExport("logError", alt.logError);
cppBindings.registerCompatibilityExport("logWarning", alt.logWarning);
cppBindings.registerCompatibilityExport("logDebug", () => {});
cppBindings.registerCompatibilityExport("logDebug", alt.logDebug);

cppBindings.registerCompatibilityExport("hash", alt.hash);
cppBindings.registerCompatibilityExport("stringToSHA256", alt.sha256);
Expand Down
8 changes: 8 additions & 0 deletions shared/js/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -2831,9 +2831,17 @@ function timeEnd(label) {
timeLabelMap.delete(label ?? "Timer");
}

function logDebug(...args) {
if (!alt.isDebug) return;
alt.log(...args);
}

alt.logDebug = logDebug;

if (alt.isClient) {
if (!globalThis.console) globalThis.console = {};
globalThis.console.log = alt.log;
globalThis.console.debug = alt.logDebug;
globalThis.console.warn = alt.logWarning;
globalThis.console.error = alt.logError;
globalThis.console.time = time;
Expand Down
1 change: 1 addition & 0 deletions types/shared/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare module "@altv/shared" {
export const syncedMeta: GlobalSyncedMeta;

export function log(...args: unknown[]): void;
export function logDebug(...args: unknown[]): void;
export function logWarning(...args: unknown[]): void;
export function logError(...args: unknown[]): void;
export function sha256(str: string): string;
Expand Down
36 changes: 18 additions & 18 deletions types/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"name": "@altv/shared",
"version": "0.0.2",
"version": "0.0.3",
"description": "This package contains the type definitions for the alt:V JS module v2 shared types",
"types": "index.d.ts",
"files": [
"index.d.ts"
"index.d.ts"
],
"scripts": {
"test": "tsc",
"preversion": "yarn run test",
"release": "yarn version --no-git-tag-version"
"test": "tsc",
"preversion": "yarn run test",
"release": "yarn version --no-git-tag-version"
},
"repository": {
"type": "git",
"url": "git+https://github.com/altmp/altv-js-module-v2.git"
"type": "git",
"url": "git+https://github.com/altmp/altv-js-module-v2.git"
},
"keywords": [
"altmp",
"altv",
"node",
"v8",
"js-module",
"js-module-v2",
"gta",
"gta5",
"gtav"
"altmp",
"altv",
"node",
"v8",
"js-module",
"js-module-v2",
"gta",
"gta5",
"gtav"
],
"author": "altMP Team",
"license": "MIT",
"bugs": {
"url": "https://github.com/altmp/altv-js-module-v2/issues"
"url": "https://github.com/altmp/altv-js-module-v2/issues"
},
"homepage": "https://github.com/altmp/altv-js-module-v2/tree/dev/types/shared"
}
}

0 comments on commit 0dceefc

Please sign in to comment.