chore(rpc): add explanation comments

This commit is contained in:
2026-09-28 02:05:40 +01:00
parent 143bee3e4e
commit ed66e61de0
2 changed files with 10 additions and 1 deletions
+2
View File
@@ -164,6 +164,8 @@ export class RPCInstanceWebview extends RPCInstanceBase {
}, },
body: stringify(data), body: stringify(data),
} }
// FiveM injects GetParentResourceName into NUI pages. Without it (page
// opened in a regular browser) the fetch fails and the call rejects.
const resourceName = window?.GetParentResourceName?.() ?? 'nui-frame-app' const resourceName = window?.GetParentResourceName?.() ?? 'nui-frame-app'
return fetch( return fetch(
`https://${resourceName}/${RPCEvents.LISTENER_WEB}`, `https://${resourceName}/${RPCEvents.LISTENER_WEB}`,
+8 -1
View File
@@ -64,7 +64,14 @@ export function stringifyWeb(data: RPCStateWeb): RPCStateWebRaw {
return JSON.stringify(data) as RPCStateWebRaw return JSON.stringify(data) as RPCStateWebRaw
} }
/** **Internal** */ /**
* **Internal**
*
* UUID v4 shaped call id. Not `crypto.randomUUID`: the FiveM client runtime
* has no `crypto` global, and one generator serves all environments. Only
* pairs a response with its call, so it need not be unguessable: the server
* binds each call to its target player (`Pending` peer check).
*/
export function generateUUID(): string { export function generateUUID(): string {
let uuid = '' let uuid = ''
let random = 0 let random = 0