diff --git a/types/gimloader/gimloader-tests.ts b/types/gimloader/gimloader-tests.ts index 8b8037d1b7dd7c..0ad6a7366ce67f 100644 --- a/types/gimloader/gimloader-tests.ts +++ b/types/gimloader/gimloader-tests.ts @@ -65,6 +65,7 @@ api.UI.showModal(document.createElement("div"), { api.requestReload(); GL.net.gamemode; // $ExpectType string +api.UI.forceReactUpdate(); api.net.gamemode; // $ExpectType string api.net.onLoad((type, gamemode) => {}); api.net.modifyFetchRequest("/path/*/thing", (options) => null); @@ -87,6 +88,11 @@ api.patcher.after(object, "b", (thisVal, args, returnVal) => { }); // @ts-expect-error api.patcher.after(object, "a", () => {}); +api.patcher.swap(object, "b", function(arg1, args2) { + arg1; // $ExpectType number + args2; // $ExpectType string + return false; +}); // Test commands api.commands.addCommand({ diff --git a/types/gimloader/index.d.ts b/types/gimloader/index.d.ts index f8a482b3e84900..e79e9bad9133b4 100644 --- a/types/gimloader/index.d.ts +++ b/types/gimloader/index.d.ts @@ -2273,6 +2273,7 @@ declare global { immediate?: boolean, ): () => void; onChange(callback: () => void): () => void; + onRemove(callback: () => void): () => void; }; type CollectionSchema = ColyseusMethods & { onAdd(callback: (value: T, index: K) => void, immediate?: boolean): () => void; @@ -2874,6 +2875,8 @@ declare global { class BaseUIApi { /** Shows a customizable modal to the user */ showModal(element: HTMLElement | React$1.ReactElement, options?: ModalOptions): void; + /** Forces Gimkit's react tree to fully rerender */ + forceReactUpdate(): void; /** * Gimkit's notification object, only available when joining or playing a game * @@ -2960,6 +2963,8 @@ declare global { ) => boolean | void; type PatcherInsteadCallback = (thisVal: any, args: T extends BaseFunction ? Parameters : any[]) => any; + + type PatcherSwapCallback = (...args: T extends BaseFunction ? Parameters : any[]) => any; class PatcherApi { /** * Runs a callback after a function on an object has been run @@ -2992,6 +2997,16 @@ declare global { method: K, callback: PatcherInsteadCallback, ): () => void; + /** + * Replaces a function on an object with another function + * @returns A function to remove the patch + */ + swap>( + id: string, + object: O, + method: K, + callback: PatcherSwapCallback, + ): () => void; /** Removes all patches with a given id */ unpatchAll(id: string): void; } @@ -3025,10 +3040,19 @@ declare global { method: K, callback: PatcherInsteadCallback, ): () => void; + /** + * Replaces a function on an object with another function + * @returns A function to remove the patch + */ + swap>( + object: O, + method: K, + callback: PatcherSwapCallback, + ): () => void; } // eslint-disable-next-line @typescript-eslint/no-invalid-void-type - type RunInScopeCallback = (code: string, run: (evalCode: string) => void) => true | void; + type RunInScopeCallback = (code: string, run: (evalCode: string) => any, initial: boolean) => true | void; interface Exposer { check?: string; diff --git a/types/gimloader/package.json b/types/gimloader/package.json index af53d38049bf22..8b22324dd14e6c 100644 --- a/types/gimloader/package.json +++ b/types/gimloader/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/gimloader", - "version": "1.11.9999", + "version": "1.12.9999", "nonNpm": "conflict", "nonNpmDescription": "Types for the Gimloader global variables", "projects": [