Skip to content

Commit

Permalink
electron: add missing types from electron/electron#29902
Browse files Browse the repository at this point in the history
  • Loading branch information
remusao committed Sep 22, 2021
1 parent 7cec678 commit 50b85b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/adblocker/src/filters/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,14 @@ const REQUEST_TYPE_TO_MASK: { [s in RequestType]: number | undefined } = {
stylesheet: NETWORK_FILTER_MASK.fromStylesheet,
subFrame: NETWORK_FILTER_MASK.fromSubdocument,
sub_frame: NETWORK_FILTER_MASK.fromSubdocument,
webSocket: NETWORK_FILTER_MASK.fromWebsocket,
websocket: NETWORK_FILTER_MASK.fromWebsocket,
xhr: NETWORK_FILTER_MASK.fromXmlHttpRequest,
xmlhttprequest: NETWORK_FILTER_MASK.fromXmlHttpRequest,

// Other
csp_report: NETWORK_FILTER_MASK.fromOther,
cspReport: NETWORK_FILTER_MASK.fromOther,
eventsource: NETWORK_FILTER_MASK.fromOther,
manifest: NETWORK_FILTER_MASK.fromOther,
other: NETWORK_FILTER_MASK.fromOther,
Expand Down
19 changes: 13 additions & 6 deletions packages/adblocker/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ const TLDTS_OPTIONS = {

// From: https://github.com/electron/electron/blob/34c4c8d5088fa183f56baea28809de6f2a427e02/shell/browser/net/atom_network_delegate.cc#L30
export type ElectronRequestType =
| 'image'
| 'mainFrame'
| 'object'
| 'other'
| 'script'
| 'stylesheet'
| 'subFrame'
| 'xhr';
| 'stylesheet'
| 'script'
| 'image'
| 'font'
| 'object'
| 'xhr'
| 'ping'
| 'cspReport'
| 'media'
| 'webSocket'
| 'other';

// From: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7f3549ed0050f2ca8d7fcc00c33eba21f0cbdd88/types/puppeteer/index.d.ts#L945
export type PuppeteerRequestType =
Expand Down Expand Up @@ -82,6 +87,7 @@ export type RequestType =

export const NORMALIZED_TYPE_TOKEN: { [s in RequestType]: number } = {
beacon: fastHash('type:beacon'),
cspReport: fastHash('type:csp'),
csp_report: fastHash('type:csp'),
cspviolationreport: fastHash('type:cspviolationreport'),
document: fastHash('type:document'),
Expand All @@ -106,6 +112,7 @@ export const NORMALIZED_TYPE_TOKEN: { [s in RequestType]: number } = {
subFrame: fastHash('type:subdocument'),
sub_frame: fastHash('type:subdocument'),
texttrack: fastHash('type:other'),
webSocket: fastHash('type:websocket'),
web_manifest: fastHash('type:other'),
websocket: fastHash('type:websocket'),
xhr: fastHash('type:xhr'),
Expand Down

0 comments on commit 50b85b7

Please sign in to comment.