(events: DebugEvent
[], timer = 1000): void => {
+ if (import.meta.env.MODE === 'development' && isEnvBrowser()) {
+ for (const event of events) {
+ setTimeout(() => {
+ window.dispatchEvent(
+ new MessageEvent('message', {
+ data: {
+ action: event.action,
+ data: event.data,
+ },
+ }),
+ );
+ }, timer);
+ }
+ }
+};
diff --git a/resources/scenes-main/web/src/utils/fetchNui.ts b/resources/scenes-main/web/src/utils/fetchNui.ts
new file mode 100644
index 000000000..3487da4a7
--- /dev/null
+++ b/resources/scenes-main/web/src/utils/fetchNui.ts
@@ -0,0 +1,33 @@
+import { isEnvBrowser } from "./misc";
+
+/**
+ * Simple wrapper around fetch API tailored for CEF/NUI use. This abstraction
+ * can be extended to include AbortController if needed or if the response isn't
+ * JSON. Tailor it to your needs.
+ *
+ * @param eventName - The endpoint eventname to target
+ * @param data - Data you wish to send in the NUI Callback
+ * @param mockData - Mock data to be returned if in the browser
+ *
+ * @return returnData - A promise for the data sent back by the NuiCallbacks CB argument
+ */
+
+export async function fetchNui