Skip to content

Commit ff71056

Browse files
authored
🤖 Merge PR DefinitelyTyped#74076 [Gimloader] Update net api types by @TheLazySquid
1 parent fe279db commit ff71056

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

types/gimloader/gimloader-tests.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ api.patcher.before({}, "foo", () => true);
4444
GL.net.gamemode; // $ExpectType string
4545
api.net.gamemode; // $ExpectType string
4646
api.net.onLoad((type, gamemode) => {});
47+
api.net.modifyFetchRequest("/path/*/thing", (options) => null);
48+
api.net.modifyFetchRequest("/path/*/thing", (options) => options);
49+
api.net.modifyFetchResponse("/path/*/thing", (response) => response);
4750

4851
GL.stores.phaser; // $ExpectType Phaser
4952
window.stores.phaser; // $ExpectType Phaser

types/gimloader/index.d.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,9 +2248,9 @@ declare global {
22482248
webpage: string | null;
22492249
needsLib: string[];
22502250
optionalLib: string[];
2251-
syncEval: string;
22522251
deprecated: string | null;
22532252
gamemode: string[];
2253+
changelog: string[];
22542254
hasSettings: string;
22552255
};
22562256
/** Gets the exported values of a plugin, if it has been enabled */
@@ -2281,9 +2281,9 @@ declare global {
22812281
webpage: string | null;
22822282
needsLib: string[];
22832283
optionalLib: string[];
2284-
syncEval: string;
22852284
deprecated: string | null;
22862285
gamemode: string[];
2286+
changelog: string[];
22872287
hasSettings: string;
22882288
};
22892289
/** Gets the exported values of a library */
@@ -2477,6 +2477,10 @@ declare global {
24772477
callback: (type: ConnectionType, gamemode: string) => void,
24782478
gamemode?: string | string[],
24792479
): () => void;
2480+
/** Runs a callback when a request is made that matches a certain path (can have wildcards) */
2481+
modifyFetchRequest(path: string, callback: (options: RequesterOptions) => any): () => void;
2482+
/** Runs a callback when a response is recieved for a request under a certain path (can have wildcards) */
2483+
modifyFetchResponse(path: string, callback: (response: any) => any): () => void;
24802484
}
24812485

24822486
type ConnectionType = "None" | "Colyseus" | "Blueboat";
@@ -2495,6 +2499,16 @@ declare global {
24952499
send(channel: string, message: any): void;
24962500
}
24972501

2502+
interface RequesterOptions {
2503+
url: string;
2504+
method?: string;
2505+
data?: any;
2506+
cacheKey?: string;
2507+
success?: (response: any, cached: boolean) => void;
2508+
both?: () => void;
2509+
error?: (error: any) => void;
2510+
}
2511+
24982512
interface NetApi extends BaseNetApi {
24992513
new(): this;
25002514
/**
@@ -2508,6 +2522,14 @@ declare global {
25082522
): () => void;
25092523
/** Cancels any calls to {@link onLoad} with the same id */
25102524
offLoad(id: string): void;
2525+
/** Runs a callback when a request is made that matches a certain path (can have wildcards) */
2526+
modifyFetchRequest(id: string, path: string, callback: (options: RequesterOptions) => any): () => void;
2527+
/** Runs a callback when a response is recieved for a request under a certain path (can have wildcards) */
2528+
modifyFetchResponse(id: string, path: string, callback: (response: any) => any): () => void;
2529+
/** Stops any modifications made by {@link modifyFetchRequest} with the same id */
2530+
stopModifyRequest(id: string): void;
2531+
/** Stops any modifications made by {@link modifyFetchResponse} with the same id */
2532+
stopModifyResponse(id: string): void;
25112533
/**
25122534
* @deprecated Methods for both transports are now on the base net api
25132535
* @hidden

0 commit comments

Comments
 (0)