diff --git a/types/client/index.d.ts b/types/client/index.d.ts index 9d2695eb4..01d44f647 100644 --- a/types/client/index.d.ts +++ b/types/client/index.d.ts @@ -91,6 +91,9 @@ declare module "@altv/client" { static create(options: AudioCreateOptions): Audio; static getByID(id: number): Audio | null; + + static setFactory(factory: typeof Audio): void; + static getFactory(): T; } export abstract class AudioCategory { @@ -146,6 +149,9 @@ declare module "@altv/client" { static create(options: AudioFilterCreateOptions): AudioFilter; static getByID(id: number): AudioFilter | null; + + static setFactory(factory: typeof AudioFilter): void; + static getFactory(): T; } export abstract class AudioOutput extends BaseObject { @@ -173,6 +179,9 @@ declare module "@altv/client" { static readonly all: ReadonlyArray; static create(options: AudioOutputAttachedCreateOptions): AudioOutputAttached; + + static setFactory(factory: typeof AudioOutputAttached): void; + static getFactory(): T; } export interface AudioOutputFrontendCreateOptions { @@ -187,6 +196,9 @@ declare module "@altv/client" { static readonly all: ReadonlyArray; static create(options: AudioOutputFrontendCreateOptions): AudioOutputFrontendCreateOptions; + + static setFactory(factory: typeof AudioOutputFrontend): void; + static getFactory(): T; } export interface AudioOutputWorldCreateOptions { @@ -203,6 +215,9 @@ declare module "@altv/client" { static readonly all: ReadonlyArray; static create(options: AudioOutputWorldCreateOptions): AudioOutputWorld; + + static setFactory(factory: typeof AudioOutputWorld): void; + static getFactory(): T; } export class BaseObject extends altShared.BaseObject { @@ -287,6 +302,9 @@ declare module "@altv/client" { static getByID(id: number): Blip | null; static getByRemoteID(id: number): Blip | null; static getByScriptID(id: number): Blip | null; + + static setFactory(factory: typeof Blip): void; + static getFactory(): T; } export abstract class Marker extends WorldObject { @@ -314,6 +332,9 @@ declare module "@altv/client" { static getByID(id: number): Marker | null; static getByRemoteID(id: number): Marker | null; static create(opts: MarkerCreateOptions): Marker; + + static setFactory(factory: typeof Marker): void; + static getFactory(): T; } export abstract class ColShape extends WorldObject { @@ -327,11 +348,14 @@ declare module "@altv/client" { public onCreate?(opts: altShared.ColShapeCreateOptions): void; public onDestroy?(): void; + static readonly all: ReadonlyArray; + static create(opts: altShared.ColShapeCreateOptions): ColShape; static getByID(id: number): ColShape | null; static getByRemoteID(id: number): ColShape | null; - static readonly all: ReadonlyArray; + static setFactory(factory: typeof ColShape): void; + static getFactory(): T; } export interface CheckpointCreateOptions { @@ -366,12 +390,15 @@ declare module "@altv/client" { public onCreate?(opts: CheckpointCreateOptions): void; public onDestroy?(): void; + static readonly all: ReadonlyArray; + static create(opts: CheckpointCreateOptions): Checkpoint; static getByID(id: number): Checkpoint | null; static getByRemoteID(id: number): Checkpoint | null; static getByScriptID(scriptId: number): Checkpoint | null; - static readonly all: ReadonlyArray; + static setFactory(factory: typeof Checkpoint): void; + static getFactory(): T; } export abstract class Entity extends WorldObject { @@ -503,6 +530,9 @@ declare module "@altv/client" { static getByID(id: number): Object | null; static getByRemoteID(id: number): Object | null; static getByScriptID(id: number): Object | null; + + static setFactory(factory: typeof Object): void; + static getFactory(): T; } export interface LocalObjectCreateOptions { @@ -555,6 +585,9 @@ declare module "@altv/client" { static create(options: LocalObjectCreateOptions): LocalObject; static getByID(id: number): LocalObject | null; static getByScriptID(scriptId: number): LocalObject | null; + + static setFactory(factory: typeof LocalObject): void; + static getFactory(): T; } export interface WeaponObjectCreateOptions { @@ -589,6 +622,9 @@ declare module "@altv/client" { static getByID(id: number): Ped | null; static getByRemoteID(id: number): Ped | null; static getByScriptID(scriptID: number): Ped | LocalPed | null; + + static setFactory(factory: typeof Ped): void; + static getFactory(): T; } export interface LocalPedCreateOptions { @@ -618,6 +654,9 @@ declare module "@altv/client" { static create(options: LocalPedCreateOptions): LocalPed; static getByID(id: number): LocalPed | null; static getByScriptID(scriptId: number): LocalPed | null; + + static setFactory(factory: typeof LocalPed): void; + static getFactory(): T; } export abstract class LocalPlayer extends Player { @@ -630,6 +669,9 @@ declare module "@altv/client" { getWeaponAmmo(wepaonHash: number | string): number | undefined; hasWeapon(wepaonHash: number | string): boolean; getWeaponComponents(wepaonHash: number | string): ReadonlyArray | undefined; + + static setFactory(factory: typeof LocalPlayer): void; + static getFactory(): T; } export interface LocalVehicleCreateOptions { @@ -658,6 +700,9 @@ declare module "@altv/client" { static create(opts: LocalVehicleCreateOptions): LocalVehicle; static getByID(id: number): LocalVehicle | null; static getByScriptID(scriptId: number): LocalVehicle | null; + + static setFactory(factory: typeof LocalVehicle): void; + static getFactory(): T; } export abstract class MapZoomData { @@ -723,6 +768,9 @@ declare module "@altv/client" { getWeaponTintIndex(weaponHash: number | string): number | undefined; hasWeaponComponent(weaponHash: number | string, componentHash: number | string): boolean; + readonly syncedMeta: Readonly; + readonly streamSyncedMeta: Readonly; + static readonly local: LocalPlayer; static readonly all: ReadonlyArray; static readonly streamedIn: ReadonlyArray; @@ -730,8 +778,8 @@ declare module "@altv/client" { static getByID(id: number): Player | null; static getByRemoteID(id: number): Player | null; - readonly syncedMeta: Readonly; - readonly streamSyncedMeta: Readonly; + static setFactory(factory: typeof Player): void; + static getFactory(): T; } export interface RmlDocumentCreateOptions { @@ -761,6 +809,9 @@ declare module "@altv/client" { static create(options: RmlDocumentCreateOptions): RmlDocument; static getByID(id: string): RmlDocument | null; + + static setFactory(factory: typeof RmlDocument): void; + static getFactory(): T; } // @ts-ignore - Suppresses "Class static side incorrectly extends base class static side" @@ -874,6 +925,9 @@ declare module "@altv/client" { static getByID(id: number): TextLabel | null; // static getByRemoteID(id: number): TextLabel | null; + + static setFactory(factory: typeof TextLabel): void; + static getFactory(): T; } export abstract class Vehicle extends Entity { @@ -1003,6 +1057,9 @@ declare module "@altv/client" { static getByID(id: number): Vehicle | null; static getByRemoteID(id: number): Vehicle | null; static getByScriptID(scriptId: number): Vehicle | null; + + static setFactory(factory: typeof Vehicle): void; + static getFactory(): T; } export interface TextLabelCreateOptions { @@ -1033,6 +1090,9 @@ declare module "@altv/client" { public onDestroy?(): void; static create(opts: altShared.VirtualEntityGroupCreateOptions): VirtualEntityGroup; + + static setFactory(factory: typeof VirtualEntityGroup): void; + static getFactory(): T; } export abstract class VirtualEntity extends WorldObject { @@ -1054,6 +1114,9 @@ declare module "@altv/client" { public onDestroy?(): void; static create(opts: VirtualEntityCreateOptions): VirtualEntity; + + static setFactory(factory: typeof VirtualEntity): void; + static getFactory(): T; } export abstract class WeaponData { @@ -1119,6 +1182,9 @@ declare module "@altv/client" { static create(options: WebSocketClientCreateOptions): WebSocketClient; static getByID(id: number): WebSocketClient | null; + + static setFactory(factory: typeof WebSocketClient): void; + static getFactory(): T; } export interface _WebViewTextureCreateOptions { @@ -1188,6 +1254,9 @@ declare module "@altv/client" { static create(options: _WebViewCreateOptionsOverlay): WebView; static getByID(id: number): WebView | null; + + static setFactory(factory: typeof WebView): void; + static getFactory(): T; } /** @@ -1251,80 +1320,6 @@ declare module "@altv/client" { export abstract class VoiceChannel extends BaseObject {} - export namespace Factory { - export function setPlayerFactory(factory: typeof Player): void; - export function getPlayerFactory(): T; - - export function setVehicleFactory(factory: typeof Vehicle): void; - export function getVehicleFactory(): T; - - export function setPedFactory(factory: typeof Ped): void; - export function getPedFactory(): T; - - export function setBlipFactory(factory: typeof Blip): void; - export function getBlipFactory(): T; - - export function setMarkerFactory(factory: typeof Marker): void; - export function getMarkerFactory(): T; - - export function setColShapeFactory(factory: typeof ColShape): void; - export function getColShapeFactory(): T; - - export function setObjectFactory(factory: typeof Object): void; - export function getObjectFactory(): T; - - export function setCheckpointFactory(factory: typeof Checkpoint): void; - export function getCheckpointFactory(): T; - - export function setTextLabelFactory(factory: typeof TextLabel): void; - export function getTextLabelFactory(): T; - - export function setVirtualEntityFactory(factory: typeof VirtualEntity): void; - export function getVirtualEntityFactory(): T; - - export function setVirtualEntityGroupFactory(factory: typeof VirtualEntityGroup): void; - export function getVirtualEntityGroupFactory(): T; - - export function setAudioFactory(factory: typeof Audio): void; - export function getAudioFactory(): T; - - export function setAudioFilterFactory(factory: typeof AudioFilter): void; - export function getAudioFilterFactory(): T; - - export function setAudioOutputAttachedFactory(factory: typeof AudioOutputAttached): void; - export function getAudioOutputAttachedFactory(): T; - - export function setAudioOutputFrontendFactory(factory: typeof AudioOutputFrontend): void; - export function getAudioOutputFrontendFactory(): T; - - export function setAudioOutputWorldFactory(factory: typeof AudioOutputWorld): void; - export function getAudioOutputWorldFactory(): T; - - export function setLocalPlayerFactory(factory: typeof LocalPlayer): void; - export function getLocalPlayerFactory(): T; - - export function setLocalPedFactory(factory: typeof LocalPed): void; - export function getLocalPedFactory(): T; - - export function setLocalVehicleFactory(factory: typeof LocalVehicle): void; - export function getLocalVehicleFactory(): T; - - export function setLocalObjectFactory(factory: typeof LocalObject): void; - export function getLocalObjectFactory(): T; - - export function setRmlDocumentFactory(factory: typeof RmlDocument): void; - export function getRmlDocumentFactory(): T; - - export function setWebSocketClientFactory(factory: typeof WebSocketClient): void; - export function getWebSocketClientFactory(): T; - - export function setWebViewFactory(factory: typeof WebView): void; - export function getWebViewFactory(): T; - - export function setTextLabelFactory(factory: typeof TextLabel): void; - export function getTextLabelFactory(): T; - } - export namespace PointBlip { export function create(opts: PointBlipCreateOptions): Blip; } diff --git a/types/client/package.json b/types/client/package.json index 076403d8e..77aaad7ef 100644 --- a/types/client/package.json +++ b/types/client/package.json @@ -1,6 +1,6 @@ { "name": "@altv/client", - "version": "0.0.3", + "version": "0.0.4", "description": "This package contains the type definitions for the alt:V JS module v2 client types", "types": "index.d.ts", "files": [ diff --git a/types/server/index.d.ts b/types/server/index.d.ts index 7b3b7ef86..cdca79a14 100644 --- a/types/server/index.d.ts +++ b/types/server/index.d.ts @@ -102,6 +102,9 @@ declare module "@altv/server" { static getByID(id: number): Blip | null; static create(opts: BlipCreateOptions): Blip; + + static setFactory(factory: typeof Blip): void; + static getFactory(): T; } export namespace PointBlip { @@ -141,6 +144,9 @@ declare module "@altv/server" { static getByID(id: number): Marker | null; static create(opts: MarkerCreateOptions): Marker; + + static setFactory(factory: typeof Marker): void; + static getFactory(): T; } export abstract class ColShapeSphere extends ColShape { @@ -215,6 +221,9 @@ declare module "@altv/server" { readonly syncedMeta: altShared.ColShapeSyncedMeta; static readonly all: ReadonlyArray; + + static setFactory(factory: typeof ColShape): void; + static getFactory(): T; } export interface MarkerCreateOptions { @@ -234,6 +243,7 @@ declare module "@altv/server" { streamingDistance: number; } + // @ts-expect-error - Suppresses "Class static side 'typeof Checkpoint' incorrectly extends base class static side 'typeof ColShape'."" export abstract class Checkpoint extends ColShape { readonly isStreamedIn: boolean; @@ -257,10 +267,13 @@ declare module "@altv/server" { public onCreate?(opts: CheckpointCreateOptions): void; public onDestroy?(): void; + static readonly all: ReadonlyArray; + static create(opts: CheckpointCreateOptions): Checkpoint; static getByID(id: number): Checkpoint | null; - static readonly all: ReadonlyArray; + static setFactory(factory: typeof Checkpoint): void; + static getFactory(): T; } export abstract class Entity extends WorldObject { @@ -326,9 +339,13 @@ declare module "@altv/server" { public onCreate?(opts: ObjectCreateOptions): void; public onDestroy?(): void; + static readonly all: ReadonlyArray; + static getByID(id: number): Object | null; static create(opts: ObjectCreateOptions): Object; - static readonly all: ReadonlyArray; + + static setFactory(factory: typeof Object): void; + static getFactory(): T; } export interface PedCreateOptions { @@ -355,6 +372,9 @@ declare module "@altv/server" { static create(opts: PedCreateOptions): Ped; static readonly all: ReadonlyArray; + + static setFactory(factory: typeof Ped): void; + static getFactory(): T; } export class Player extends Entity { @@ -523,6 +543,9 @@ declare module "@altv/server" { static readonly all: ReadonlyArray; static getByID(id: number): Player | null; + + static setFactory(factory: typeof Player): void; + static getFactory(): T; } export abstract class Resource extends altShared.Resource { @@ -712,6 +735,9 @@ declare module "@altv/server" { static getByID(id: number): Vehicle | null; static create(opts: VehicleCreateOptions): Vehicle; static all: ReadonlyArray; + + static setFactory(factory: typeof Vehicle): void; + static getFactory(): T; } export interface VirtualEntityCreateOptions { @@ -728,6 +754,9 @@ declare module "@altv/server" { public onDestroy?(): void; static create(opts: altShared.VirtualEntityGroupCreateOptions): VirtualEntityGroup; + + static setFactory(factory: typeof VirtualEntityGroup): void; + static getFactory(): T; } export abstract class VirtualEntity extends WorldObject { @@ -746,6 +775,9 @@ declare module "@altv/server" { public onDestroy?(): void; static create(opts: VirtualEntityCreateOptions): VirtualEntity; + + static setFactory(factory: typeof VirtualEntity): void; + static getFactory(): T; } export interface VoiceChannelCreateOptions { @@ -777,41 +809,9 @@ declare module "@altv/server" { public onDestroy?(): void; static create(opts: VoiceChannelCreateOptions): VoiceChannel; - } - - export namespace Factory { - export function setPlayerFactory(factory: typeof Player): void; - export function getPlayerFactory(): T; - - export function setVehicleFactory(factory: typeof Vehicle): void; - export function getVehicleFactory(): T; - - export function setPedFactory(factory: typeof Ped): void; - export function getPedFactory(): T; - - export function setBlipFactory(factory: typeof Blip): void; - export function getBlipFactory(): T; - - export function setMarkerFactory(factory: typeof Marker): void; - export function getMarkerFactory(): T; - - export function setVoiceChannelFactory(factory: typeof VoiceChannel): void; - export function getVoiceChannelFactory(): T; - - export function setColShapeFactory(factory: typeof ColShape): void; - export function getColShapeFactory(): T; - - export function setObjectFactory(factory: typeof Object): void; - export function getObjectFactory(): T; - - export function setCheckpointFactory(factory: typeof Checkpoint): void; - export function getCheckpointFactory(): T; - - export function setVirtualEntityFactory(factory: typeof VirtualEntity): void; - export function getVirtualEntityFactory(): T; - export function setVirtualEntityGroupFactory(factory: typeof VirtualEntityGroup): void; - export function getVirtualEntityGroupFactory(): T; + static setFactory(factory: typeof VoiceChannel): void; + static getFactory(): T; } export abstract class WorldObject extends BaseObject { diff --git a/types/server/package.json b/types/server/package.json index bcbece9db..9d7d5d7ef 100644 --- a/types/server/package.json +++ b/types/server/package.json @@ -1,6 +1,6 @@ { "name": "@altv/server", - "version": "0.0.5", + "version": "0.0.6", "description": "This package contains the type definitions for the alt:V JS module v2 server types", "types": "index.d.ts", "files": [