-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: [1502] Allow fetch to be intercepted and modified * feat: [1502] Add the possibility to intercept sync requests * fix: [1502] Correct the types for sync response hooks * feat: [1502] Allow fetch response to be intercepted * fix: [1502] Move async task manager to be ended after the intercept * fix: [1502] The interceptor not always being there
- Loading branch information
Showing
8 changed files
with
649 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Request from '../Request.js'; | ||
import BrowserWindow from '../../window/BrowserWindow.js'; | ||
import Response from '../Response.js'; | ||
import ISyncResponse from './ISyncResponse.js'; | ||
|
||
export default interface IFetchInterceptor { | ||
/** | ||
* Hook dispatched before making an async request. | ||
* It can be used for modifying the request, providing a response without making a request or for logging. | ||
* | ||
* @param context Contains the request and the window from where the request was made. | ||
* | ||
* @returns Promise that can resolve to a response to be used instead of sending out the response. | ||
*/ | ||
beforeAsyncRequest?: (context: { | ||
request: Request; | ||
window: BrowserWindow; | ||
}) => Promise<Response | void>; | ||
|
||
/** | ||
* Hook dispatched before making an sync request. | ||
* It can be used for modifying the request, providing a response without making a request or for logging. | ||
* | ||
* @param context Contains the request and the window from where the request was made. | ||
* | ||
* @returns Promise that can resolve to a response to be used instead of sending out the response. | ||
*/ | ||
beforeSyncRequest?: (context: { | ||
request: Request; | ||
window: BrowserWindow; | ||
}) => ISyncResponse | void; | ||
|
||
/** | ||
* Hook dispatched after receiving an async response. | ||
* It can be used for modifying or replacing the response and logging. | ||
* | ||
* @param context Contains the request, response and the window from where the request was made. | ||
* | ||
* @returns Promise that can resolve to a response to be used instead of sending out the response. | ||
*/ | ||
afterAsyncResponse?: (context: { | ||
request: Request; | ||
response: Response; | ||
window: BrowserWindow; | ||
}) => Promise<Response | void>; | ||
|
||
/** | ||
* Hook dispatched after receiving a sync response. | ||
* It can be used for modifying or replacing the response and logging | ||
* | ||
* @param context Contains the request, response and the window from where the request was made. | ||
* | ||
* @returns Promise that can resolve to a response to be used instead of sending out the response. | ||
*/ | ||
afterSyncResponse?: (context: { | ||
request: Request; | ||
response: ISyncResponse; | ||
window: BrowserWindow; | ||
}) => ISyncResponse | void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.