Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hooking API #9

Open
xxshady opened this issue Nov 19, 2022 · 1 comment
Open

Add hooking API #9

xxshady opened this issue Nov 19, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@xxshady
Copy link
Owner

xxshady commented Nov 19, 2022

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 xxshady added the enhancement New feature or request label Nov 19, 2022
@xxshady
Copy link
Owner Author

xxshady commented Dec 4, 2022

its been a while and now i think its not a good idea to provide this api in esbuild plugin options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant