Add hooking API
Opened this issue · 1 comments
xxshady commented
Allow users to intercept various function calls in the alt:V JS API for debugging/development purposes
Example:
altvEsbuild({
mode: "client",
dev: {
hooks: {
// "alt-client" module
alt: {
// hook function must be an arrow-function so it can be converted to a string
// caution: variables from outer scope (any variable of build script) can't be used
log: (args, originalFunc, alt) => {
originalFunc("alt.log is called")
originalFunc(...args)
alt.logWarning("calling another api function")
alt.log("since alt.log is hooked this call will cause infinite recursion")
},
},
// "natives" module (clientside only ofcourse)
natives: {
},
globalThis: {
console: { ... },
setTimeout,
// ....etc.
}
}
}
})
xxshady commented
its been a while and now i think its not a good idea to provide this api in esbuild plugin options