Skip to content

Commit

Permalink
wip: fix web player card in nui iframe + notes
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Dec 30, 2023
1 parent c073303 commit 1597a52
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
46 changes: 46 additions & 0 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,52 @@ Processo:
- Action Log
=======================================================================

This worked, no time to check which.
Note it's in the core root and not in the `types` folder, also it has an `export` before the declaration.
```js
//file: core/global.d.ts
export declare global {
const globals: any;
namespace globalThis {
interface Console {
xxxx: any
}
}
namespace NodeJS {
interface Global {
xxxx: any
}
}
interface Console {
exampleProperty: string;
}
}
```

Nui events testing stuff
```lua
RegisterRawNuiCallback('abc', function(req, cb)
print('abc', json.encode(req), cb)
cb({
status = 200,
body = json.encode({ success = true }),
})
end)
```
```js
await (async () => {
const options = {
method: "post",
headers: {
"Content-Type": "application/json; charset=UTF-8",
},
body: JSON.stringify({}),
}
const resp = await fetch(`https://monitor/abc?token`, options);
return await resp.json();
})()
```


```patch
diff --git a/resource/menu/client/cl_player_ids.lua b/resource/menu/client/cl_player_ids.lua
Expand Down
8 changes: 6 additions & 2 deletions panel/src/hooks/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ export const useAuthedFetcher = () => {

return async (fetchUrl: string, fetchOpts: FetcherOpts = {}, abortController?: AbortController) => {
if (!csrfToken) throw new Error('CSRF token not set');
if (!fetchUrl.startsWith('/')) {
throw new Error(`[useAuthedFetcher] fetchUrl must start with a slash.`);
const obligatoryPrefix = window.txConsts.isWebInterface ? '/' : WEBPIPE_PATH;
if (!fetchUrl.startsWith(obligatoryPrefix)) {
throw new Error(`[useAuthedFetcher] fetchUrl MUST start with '${obligatoryPrefix}', got '${fetchUrl}'.`);
}
if (fetchUrl.startsWith('//')) {
throw new Error(`[useAuthedFetcher] fetchUrl MUST NOT start with '//', got '${fetchUrl}'.`);
}

fetchOpts.method ??= 'GET';
Expand Down

0 comments on commit 1597a52

Please sign in to comment.