Skip to content

Commit

Permalink
Merge branch 'release/0.17.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lusito committed Jun 6, 2020
2 parents 792bba7 + 98e6f46 commit 58b8857
Show file tree
Hide file tree
Showing 13 changed files with 268 additions and 46 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Expand Up @@ -76,6 +76,7 @@ If you use any of the above, it is assumed that the current node is an array.

Usually the last part of a key is not a special instruction, but a normal key. These are exceptions:
- If the last part is exactly `+[]`, values are appended to an array.
- If the last part is exactly `-[]`, the values are selectors to remove elements from an array. See the instructions to navigate an array above.
- If the last part is exactly `!fixAsync`, async functions can be easily fixed.

### Appending to an array instead of setting an attribute.
Expand Down
11 changes: 11 additions & 0 deletions fixes.json
Expand Up @@ -277,7 +277,18 @@
"optional": true,
"description": "If true, the new window will be focused. If false, the new window will be opened in the background and the currently focused window will stay focused. Defaults to true."
},
"webRequest:events.%onBeforeRequest.returns.$ref": "BlockingResponseOrPromise",
"webRequest:events.%onBeforeSendHeaders.returns.$ref": "BlockingResponseOrPromise",
"webRequest:events.%onHeadersReceived.returns.$ref": "BlockingResponseOrPromise",
"webRequest:events.%onAuthRequired.returns.$ref": "BlockingResponseOrPromise",
"webRequest:events.%onAuthRequired.parameters.-[]": ["%callback"],
"webRequest:types.+[]": [{
"type": "choices",
"id": "BlockingResponseOrPromise",
"description": "A BlockingResponse or a Promise<BlockingResponse>",
"choices": [{ "type": "BlockingResponse" }, { "type": "Promise<BlockingResponse>" }]
},
{
"id": "StreamFilterStatus",
"type": "string",
"enum": [{
Expand Down
2 changes: 1 addition & 1 deletion lib/geckoProfiler.d.ts
Expand Up @@ -8,7 +8,7 @@
import { Events } from "./events";

export declare namespace GeckoProfiler {
type ProfilerFeature = "java" | "js" | "leaf" | "mainthreadio" | "privacy" | "responsiveness" | "screenshots" | "seqstyle" | "stackwalk" | "tasktracer" | "threads" | "trackopts" | "jstracer" | "jsallocations" | "nostacksampling" | "nativeallocations" | "preferencereads" | "ipcmessages";
type ProfilerFeature = "java" | "js" | "leaf" | "mainthreadio" | "responsiveness" | "screenshots" | "seqstyle" | "stackwalk" | "tasktracer" | "threads" | "jstracer" | "jsallocations" | "nostacksampling" | "nativeallocations" | "preferencereads" | "ipcmessages" | "fileio" | "fileioall" | "noiostacks";

type supports = "windowLength";

Expand Down
64 changes: 62 additions & 2 deletions lib/storage.d.ts
Expand Up @@ -62,7 +62,49 @@ export declare namespace Storage {
clear(): Promise<void>;
}

interface SyncStorageArea extends StorageArea {
interface StorageAreaSync {

/**
* Gets one or more items from storage.
*
* @param keys Optional. A single key to get, list of keys to get, or a dictionary specifying default values (see description of the object). An empty list or object will return an empty result object. Pass in <code>null</code> to get the entire contents of storage.
* @returns Promise<StorageAreaSyncGetCallbackItemsType> Callback with storage items, or on failure (in which case $(ref:runtime.lastError) will be set).
*/
get(keys?: string | string[] | StorageAreaSyncGetKeysC3Type): Promise<StorageAreaSyncGetCallbackItemsType>;

/**
* Gets the amount of space (in bytes) being used by one or more items.
*
* @param keys Optional. A single key or list of keys to get the total usage for. An empty list will return 0. Pass in <code>null</code> to get the total usage of all of storage.
* @returns Promise<number> Callback with the amount of space being used by storage, or on failure (in which case $(ref:runtime.lastError) will be set).
*/
getBytesInUse(keys?: string | string[]): Promise<number>;

/**
* Sets multiple items.
*
* @param items <p>An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected.</p><p>Primitive values such as numbers will serialize as expected. Values with a <code>typeof</code> <code>"object"</code> and <code>"function"</code> will typically serialize to <code>{}</code>, with the exception of <code>Array</code> (serializes as expected), <code>Date</code>, and <code>Regex</code> (serialize using their <code>String</code> representation).</p>
* @returns Promise<void> Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
*/
set(items: StorageAreaSyncSetItemsType): Promise<void>;

/**
* Removes one or more items from storage.
*
* @param keys A single key or a list of keys for items to remove.
* @returns Promise<void> Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
*/
remove(keys: string | string[]): Promise<void>;

/**
* Removes all items from storage.
*
* @returns Promise<void> Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
*/
clear(): Promise<void>;
}

interface SyncStorageAreaSync extends StorageAreaSync {

/**
* The maximum total amount (in bytes) of data that can be stored in sync storage, as measured by the JSON stringification of every value plus every key's length. Updates that would cause this limit to be exceeded fail immediately and set $(ref:runtime.lastError).
Expand Down Expand Up @@ -112,6 +154,24 @@ export declare namespace Storage {
interface StorageAreaSetItemsType {
}

/**
* Storage items to return in the callback, where the values are replaced with those from storage if they exist.
*/
interface StorageAreaSyncGetKeysC3Type {
}

/**
* Object with items in their key-value mappings.
*/
interface StorageAreaSyncGetCallbackItemsType {
}

/**
* <p>An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected.</p><p>Primitive values such as numbers will serialize as expected. Values with a <code>typeof</code> <code>"object"</code> and <code>"function"</code> will typically serialize to <code>{}</code>, with the exception of <code>Array</code> (serializes as expected), <code>Date</code>, and <code>Regex</code> (serialize using their <code>String</code> representation).</p>
*/
interface StorageAreaSyncSetItemsType {
}

interface Static {

/**
Expand All @@ -122,7 +182,7 @@ export declare namespace Storage {
*/
onChanged: Events.Event<(changes: {[s:string]:StorageChange}, areaName: string) => void>;

sync: SyncStorageArea;
sync: SyncStorageAreaSync;

local: LocalStorageArea;

Expand Down
2 changes: 1 addition & 1 deletion lib/topSites.d.ts
Expand Up @@ -80,7 +80,7 @@ export declare namespace TopSites {
includeSearchShortcuts?: boolean;

/**
* Return the sites that exactly appear on the user's new-tab page. When true, all other options are ignored except limit and includeFavicon.
* Return the sites that exactly appear on the user's new-tab page. When true, all other options are ignored except limit and includeFavicon. If the user disabled newtab Top Sites, the newtab parameter will be ignored.
* Optional.
*/
newtab?: boolean;
Expand Down
21 changes: 13 additions & 8 deletions lib/webRequest.d.ts
Expand Up @@ -271,6 +271,11 @@ export declare namespace WebRequest {
thirdParty: UrlClassificationParty;
}

/**
* A BlockingResponse or a Promise<BlockingResponse>
*/
type BlockingResponseOrPromise = BlockingResponse | Promise<BlockingResponse>;

/**
* "uninitialized": The StreamFilter is not fully initialized. No methods may be called until a "start" event has been received.
* "transferringdata": The underlying channel is currently transferring data, which will be dispatched via "data" events.
Expand Down Expand Up @@ -1332,7 +1337,7 @@ export declare namespace WebRequest {
/**
* Fired when a request is about to occur.
*/
interface onBeforeRequestEvent extends Events.Event<(details: OnBeforeRequestDetailsType) => BlockingResponse | void> {
interface onBeforeRequestEvent extends Events.Event<(details: OnBeforeRequestDetailsType) => BlockingResponseOrPromise | void> {

/**
* Registers an event listener <em>callback</em> to an event.
Expand All @@ -1341,13 +1346,13 @@ export declare namespace WebRequest {
* @param filter A set of filters that restricts the events that will be sent to this listener.
* @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
*/
addListener(callback: (details: OnBeforeRequestDetailsType) => BlockingResponse | void, filter: RequestFilter, extraInfoSpec?: OnBeforeRequestOptions[]): void;
addListener(callback: (details: OnBeforeRequestDetailsType) => BlockingResponseOrPromise | void, filter: RequestFilter, extraInfoSpec?: OnBeforeRequestOptions[]): void;
}

/**
* Fired before sending an HTTP request, once the request headers are available. This may occur after a TCP connection is made to the server, but before any HTTP data is sent.
*/
interface onBeforeSendHeadersEvent extends Events.Event<(details: OnBeforeSendHeadersDetailsType) => BlockingResponse | void> {
interface onBeforeSendHeadersEvent extends Events.Event<(details: OnBeforeSendHeadersDetailsType) => BlockingResponseOrPromise | void> {

/**
* Registers an event listener <em>callback</em> to an event.
Expand All @@ -1356,7 +1361,7 @@ export declare namespace WebRequest {
* @param filter A set of filters that restricts the events that will be sent to this listener.
* @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
*/
addListener(callback: (details: OnBeforeSendHeadersDetailsType) => BlockingResponse | void, filter: RequestFilter, extraInfoSpec?: OnBeforeSendHeadersOptions[]): void;
addListener(callback: (details: OnBeforeSendHeadersDetailsType) => BlockingResponseOrPromise | void, filter: RequestFilter, extraInfoSpec?: OnBeforeSendHeadersOptions[]): void;
}

/**
Expand All @@ -1377,7 +1382,7 @@ export declare namespace WebRequest {
/**
* Fired when HTTP response headers of a request have been received.
*/
interface onHeadersReceivedEvent extends Events.Event<(details: OnHeadersReceivedDetailsType) => BlockingResponse | void> {
interface onHeadersReceivedEvent extends Events.Event<(details: OnHeadersReceivedDetailsType) => BlockingResponseOrPromise | void> {

/**
* Registers an event listener <em>callback</em> to an event.
Expand All @@ -1386,13 +1391,13 @@ export declare namespace WebRequest {
* @param filter A set of filters that restricts the events that will be sent to this listener.
* @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
*/
addListener(callback: (details: OnHeadersReceivedDetailsType) => BlockingResponse | void, filter: RequestFilter, extraInfoSpec?: OnHeadersReceivedOptions[]): void;
addListener(callback: (details: OnHeadersReceivedDetailsType) => BlockingResponseOrPromise | void, filter: RequestFilter, extraInfoSpec?: OnHeadersReceivedOptions[]): void;
}

/**
* Fired when an authentication failure is received. The listener has three options: it can provide authentication credentials, it can cancel the request and display the error page, or it can take no action on the challenge. If bad user credentials are provided, this may be called multiple times for the same request.
*/
interface onAuthRequiredEvent extends Events.Event<(details: OnAuthRequiredDetailsType, callback: ((response: BlockingResponse) => void) | undefined) => BlockingResponse | void> {
interface onAuthRequiredEvent extends Events.Event<(details: OnAuthRequiredDetailsType) => BlockingResponseOrPromise | void> {

/**
* Registers an event listener <em>callback</em> to an event.
Expand All @@ -1401,7 +1406,7 @@ export declare namespace WebRequest {
* @param filter A set of filters that restricts the events that will be sent to this listener.
* @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
*/
addListener(callback: (details: OnAuthRequiredDetailsType, callback: ((response: BlockingResponse) => void) | undefined) => BlockingResponse | void, filter: RequestFilter, extraInfoSpec?: OnAuthRequiredOptions[]): void;
addListener(callback: (details: OnAuthRequiredDetailsType) => BlockingResponseOrPromise | void, filter: RequestFilter, extraInfoSpec?: OnAuthRequiredOptions[]): void;
}

/**
Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "webextension-polyfill-ts",
"version": "0.16.0",
"version": "0.17.0",
"description": "webextension-polyfill for TypeScript",
"keywords": [
"TypeScript",
Expand Down Expand Up @@ -33,11 +33,11 @@
"webextension-polyfill": "^0.6.0"
},
"devDependencies": {
"@types/node": "^14.0.5",
"@types/node": "^14.0.11",
"@types/rimraf": "^3.0.0",
"got": "^11.1.4",
"got": "^11.3.0",
"rimraf": "^3.0.2",
"ts-node": "^8.10.1",
"typescript": "^3.9.3"
"ts-node": "^8.10.2",
"typescript": "^3.9.5"
}
}
6 changes: 3 additions & 3 deletions schemas/chrome_settings_overrides.json
Expand Up @@ -33,7 +33,7 @@
"search_url": {
"type": "string",
"format": "url",
"pattern": "^https://.*$",
"pattern": "^(https://|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])).*$",
"preprocess": "localize"
},
"favicon_url": {
Expand All @@ -45,7 +45,7 @@
"suggest_url": {
"type": "string",
"optional": true,
"pattern": "^https://.*$|^$",
"pattern": "^(https://|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])).*$",
"preprocess": "localize"
},
"instant_url": {
Expand Down Expand Up @@ -102,7 +102,7 @@
"type": "string",
"optional": true,
"format": "url",
"pattern": "^https://.*$",
"pattern": "^(https://|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])).*$",
"preprocess": "localize"
},
"alternate_urls": {
Expand Down
7 changes: 4 additions & 3 deletions schemas/geckoProfiler.json
Expand Up @@ -27,20 +27,21 @@
"js",
"leaf",
"mainthreadio",
"privacy",
"responsiveness",
"screenshots",
"seqstyle",
"stackwalk",
"tasktracer",
"threads",
"trackopts",
"jstracer",
"jsallocations",
"nostacksampling",
"nativeallocations",
"preferencereads",
"ipcmessages"
"ipcmessages",
"fileio",
"fileioall",
"noiostacks"
]
},
{
Expand Down

0 comments on commit 58b8857

Please sign in to comment.