Skip to content

Commit

Permalink
feat(client): new WebView API
Browse files Browse the repository at this point in the history
  • Loading branch information
xxshady committed Jan 28, 2025
1 parent 5936e69 commit b748f97
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ declare module "alt-client" {
Justify,
}

export enum CookieSameSite {
NoRestriction = "NO_RESTRICTION",
LaxMode = "LAX_MODE",
StrictMode = "STRICT_MODE",
}

export enum CookiePriority {
Low = "LOW",
Medium = "MEDIUM",
High = "HIGH",
}

export interface IClientEvent {
anyResourceError: (resourceName: string) => void;
anyResourceStart: (resourceName: string) => void;
Expand Down Expand Up @@ -574,6 +586,33 @@ declare module "alt-client" {
max: number;
}

export interface IWebViewParams {
url: string;
pos?: shared.IVector2;
size?: shared.IVector2;
isOverlay?: boolean;
drawableHash?: number;
targetTexture?: string;
headers?: Record<string, string>;
cookies?: ICookie[];
}

export interface ICookie {
/**
* Cookie name must always start with "__altv_"
*/
name: `__altv_${string}`;
url: string;
value: unknown;
httpOnly?: boolean;
secure?: boolean;
domain?: string;
path?: string;
sameSite?: CookieSameSite;
priority: CookiePriority;
expires: number;
}

export class BaseObject extends shared.BaseObject {
/**
* Whether this entity was created clientside or serverside. (Clientside = false, Serverside = true).
Expand Down Expand Up @@ -1918,10 +1957,18 @@ declare module "alt-client" {
* Creates a WebView rendered on game object.
*
* @param url URL of the html file.
* @param propHash Hash of object to render on.
* @param targetTexture Name of object's texture to replace.
* @param drawableHash Hash of drawable to render on.
* @param targetTexture Name of texture to replace.
*/
constructor(url: string, drawableHash: number, targetTexture: string);

/**
* Creates a WebView depending on params.
*
* @param url URL of the html file.
*
*/
constructor(url: string, propHash: number, targetTexture: string);
constructor(params: IWebViewParams);

/**
* Emits specified event across particular WebView.
Expand Down Expand Up @@ -2002,6 +2049,7 @@ declare module "alt-client" {
public removeOutput(output: AudioOutput): void;
public getOutputs(): readonly (AudioOutput | number)[];
public reload(ignoreCache?: boolean): void;
public setCookie(cookie: ICookie): void;

public deleteMeta(key: string): void;
public deleteMeta<K extends shared.ExtractStringKeys<ICustomWebViewMeta>>(key: K): void;
Expand Down

0 comments on commit b748f97

Please sign in to comment.