mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
chore(web): add prettier and format
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {isEnvBrowser} from "./misc";
|
||||
import { isEnvBrowser } from './misc';
|
||||
|
||||
interface DebugEvent<T = any> {
|
||||
action: string;
|
||||
@@ -13,11 +13,11 @@ interface DebugEvent<T = any> {
|
||||
* @param timer - How long until it should trigger (ms)
|
||||
*/
|
||||
export const debugData = <P>(events: DebugEvent<P>[], timer = 1000): void => {
|
||||
if (process.env.NODE_ENV === "development" && isEnvBrowser()) {
|
||||
if (process.env.NODE_ENV === 'development' && isEnvBrowser()) {
|
||||
for (const event of events) {
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent("message", {
|
||||
new MessageEvent('message', {
|
||||
data: {
|
||||
action: event.action,
|
||||
data: event.data,
|
||||
@@ -27,4 +27,4 @@ export const debugData = <P>(events: DebugEvent<P>[], timer = 1000): void => {
|
||||
}, timer);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -18,11 +18,13 @@ export async function fetchNui<T = any>(eventName: string, data?: any): Promise<
|
||||
body: JSON.stringify(data),
|
||||
};
|
||||
|
||||
const resourceName = (window as any).GetParentResourceName ? (window as any).GetParentResourceName() : 'nui-frame-app';
|
||||
const resourceName = (window as any).GetParentResourceName
|
||||
? (window as any).GetParentResourceName()
|
||||
: 'nui-frame-app';
|
||||
|
||||
const resp = await fetch(`https://${resourceName}/${eventName}`, options);
|
||||
|
||||
const respFormatted = await resp.json()
|
||||
const respFormatted = await resp.json();
|
||||
|
||||
return respFormatted
|
||||
return respFormatted;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Will return whether the current environment is in a regular browser
|
||||
// and not CEF
|
||||
export const isEnvBrowser = (): boolean => !(window as any).invokeNative
|
||||
export const isEnvBrowser = (): boolean => !(window as any).invokeNative;
|
||||
|
||||
// Basic no operation function
|
||||
export const noop = () => {}
|
||||
export const noop = () => {};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// yoinked from https://github.com/project-error/npwd/blob/d8dc5b7f47faf5fc581ffee30f31ff61d184cfe7/phone/src/os/phone/hooks/useClipboard.ts#L1
|
||||
export const setClipboard = (value: string) => {
|
||||
const clipElem = document.createElement('input');
|
||||
clipElem.value = value;
|
||||
document.body.appendChild(clipElem);
|
||||
clipElem.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(clipElem);
|
||||
};
|
||||
const clipElem = document.createElement('input');
|
||||
clipElem.value = value;
|
||||
document.body.appendChild(clipElem);
|
||||
clipElem.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(clipElem);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user