refactor(web): initial svelte rewrite files

This commit is contained in:
Luke committed 2023-03-18 19:03:35 +01:00
1 parent be8580396c
commit e04a43a86c
53 files changed
+3462 -12172

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import { isEnvBrowser } from './misc';
interface DebugEvent<T = any> {
action: string;
data: T;
}
/**
* Emulates dispatching an event using SendNuiMessage in the lua scripts.
* This is used when developing in browser
*
* @param events - The event you want to cover
* @param timer - How long until it should trigger (ms)
*/
export const debugData = <P>(events: DebugEvent<P>[], timer = 1000): void => {
if (isEnvBrowser()) {
for (const event of events) {
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
action: event.action,
data: event.data,
},
})
);
}, timer);
}
}
};