(events: DebugEvent
[], timer = 1000): void => {
16 | if (import.meta.env.MODE === "development" && isEnvBrowser()) {
17 | for (const event of events) {
18 | setTimeout(() => {
19 | window.dispatchEvent(
20 | new MessageEvent("message", {
21 | data: {
22 | action: event.action,
23 | data: event.data,
24 | },
25 | }),
26 | );
27 | }, timer);
28 | }
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/web/src/utils/fetchNui.ts:
--------------------------------------------------------------------------------
1 | import { isEnvBrowser } from "./misc";
2 |
3 | /**
4 | * Simple wrapper around fetch API tailored for CEF/NUI use. This abstraction
5 | * can be extended to include AbortController if needed or if the response isn't
6 | * JSON. Tailor it to your needs.
7 | *
8 | * @param eventName - The endpoint eventname to target
9 | * @param data - Data you wish to send in the NUI Callback
10 | * @param mockData - Mock data to be returned if in the browser
11 | *
12 | * @return returnData - A promise for the data sent back by the NuiCallbacks CB argument
13 | */
14 |
15 | export async function fetchNui