Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions types/chrome/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,10 @@ declare namespace chrome {
export function setIcon(details: TabIconDetails, callback: () => void): void;

/**
* Sets the html document to be opened as a popup when the user clicks on the action's icon.
* Sets the HTML document to be opened as a popup when the user clicks on the action's icon.
*
* Can return its result via Promise.
* @since Chrome 96
*/
export function setPopup(details: PopupDetails): Promise<void>;
export function setPopup(details: PopupDetails, callback: () => void): void;
Expand Down Expand Up @@ -1165,6 +1166,7 @@ declare namespace chrome {
* Clears websites' cache storage data.
*
* Can return its result via Promise in Manifest V3 or later since Chrome 96.
* @since Chrome 72
*/
export function removeCacheStorage(options: RemovalOptions): Promise<void>;
export function removeCacheStorage(options: RemovalOptions, callback: () => void): void;
Expand Down Expand Up @@ -2433,7 +2435,17 @@ declare namespace chrome {
* Exactly one of `imageData` or `path` must be specified. Both are dictionaries mapping a number of pixels to an image representation. The image representation in `imageData` is an `ImageData` object; for example, from a `canvas` element, while the image representation in `path` is the path to an image file relative to the extension's manifest. If `scale` screen pixels fit into a device-independent pixel, the `scale * n` icon is used. If that scale is missing, another image is resized to the required size.
*/
export class SetIcon {
constructor(options?: { imageData?: ImageData | { [size: string]: ImageData } | undefined });
constructor(
options:
| {
imageData: ImageData | { [index: number]: ImageData };
path?: string | { [index: number]: string } | undefined;
}
| {
imageData?: ImageData | { [index: number]: ImageData } | undefined;
path: string | { [index: number]: string };
},
);
}

/** Provides the Declarative Event API consisting of {@link events.Event.addRules addRules}, {@link events.Event.removeRules removeRules}, and {@link events.Event.getRules getRules}. */
Expand Down Expand Up @@ -3330,7 +3342,7 @@ declare namespace chrome {
/** Indicates the data type of the option. The requested data type must match the real data type of the underlying option. */
type: `${OptionType}`;
/** Indicates the value to set. Leave unset to request automatic setting for options that have `autoSettable` enabled. The data type supplied for `value` must match `type`. */
value?: string | number | boolean | number;
value?: string | number | boolean | number[];
}

/**
Expand Down Expand Up @@ -3560,6 +3572,8 @@ declare namespace chrome {
/**
* Performs a document scan and returns a Promise that resolves with a {@link ScanResults} object. If a callback is passed to this function, the returned data is passed to it instead.
* @param options An object containing scan parameters.
*
* Can return its result via Promise in Manifest V3 or later since Chrome 96.
*/
export function scan(options: ScanOptions): Promise<ScanResults>;
export function scan(options: ScanOptions, callback: (result: ScanResults) => void): void;
Expand Down Expand Up @@ -4364,9 +4378,12 @@ declare namespace chrome {
}

/**
* Retrieves the network details of the device's default network. If the user is not affiliated or the device is not connected to a network, runtime.lastError will be set with a failure reason.
* Retrieves the network details of the device's default network. If the user is not affiliated or the device is not connected to a network, {@link runtime.lastError} will be set with a failure reason.
* @param callback Called with the device's default network's NetworkDetails.
*
* Can return its result via Promise in Manifest V3 or later since Chrome 96.
*/
export function getNetworkDetails(): Promise<NetworkDetails>;
export function getNetworkDetails(callback: (networkDetails: NetworkDetails) => void): void;
}

Expand Down Expand Up @@ -6308,7 +6325,7 @@ declare namespace chrome {
* This API is different from identity.getAccounts in two ways. The information returned is available offline, and it only applies to the primary account for the profile.
* @param details Profile options.
*
* Can return its result via Promise since Chrome 105.
* Can return its result via Promise since Chrome 106.
*/
export function getProfileUserInfo(details?: ProfileDetails): Promise<ProfileUserInfo>;
export function getProfileUserInfo(
Expand All @@ -6323,7 +6340,7 @@ declare namespace chrome {
* If an access token is discovered to be invalid, it should be passed to removeCachedAuthToken to remove it from the cache. The app may then retrieve a fresh token with `getAuthToken`.
* @param details Token information.
*
* Can return its result via Promise since Chrome 105.
* Can return its result via Promise since Chrome 106.
*/
export function removeCachedAuthToken(details: InvalidTokenDetails): Promise<void>;
export function removeCachedAuthToken(details: InvalidTokenDetails, callback: () => void): void;
Expand Down Expand Up @@ -7911,7 +7928,7 @@ declare namespace chrome {

export enum ClientCertificateType {
ECDSA_SIGN = "ecdsaSign",
RAS_SIGN = "rasSign",
RSA_SIGN = "rsaSign",
}

export interface SelectDetails {
Expand Down Expand Up @@ -8806,7 +8823,7 @@ declare namespace chrome {
export type QueryInfo =
& {
/** String to query with the default search provider. */
text?: string | undefined;
text: string;
}
& (
| {
Expand Down Expand Up @@ -12142,7 +12159,7 @@ declare namespace chrome {
* Called when the list of {@link TtsVoice} that would be returned by getVoices has changed.
* @since Chrome 124
*/
const onVoicesChanged: chrome.events.Event<() => void>;
export const onVoicesChanged: chrome.events.Event<() => void>;
}

////////////////////
Expand Down Expand Up @@ -13094,7 +13111,7 @@ declare namespace chrome {
EXTRA_HEADERS = "extraHeaders",
}

/** @since Chrome 44 */
/** @since Chrome 79 */
export enum OnErrorOccurredOptions {
/** Specifies that headers can violate Cross-Origin Resource Sharing (CORS). */
EXTRA_HEADERS = "extraHeaders",
Expand Down Expand Up @@ -13286,14 +13303,14 @@ declare namespace chrome {
extends SetPartial<WebRequestDetails, "documentId" | "documentLifecycle" | "frameType">
{
/** Contains the HTTP request body data. Only provided if extraInfoSpec contains 'requestBody'. */
requestBody: {
requestBody?: {
/** Errors when obtaining request body data. */
error?: string;
/** If the request method is POST and the body is a sequence of key-value pairs encoded in UTF8, encoded as either multipart/form-data, or application/x-www-form-urlencoded, this dictionary is present and for each key contains the list of all values for that key. If the data is of another media type, or if it is malformed, the dictionary is not present. An example value of this dictionary is {'key': \['value1', 'value2'\]}. */
formData?: { [key: string]: FormDataItem[] };
/** If the request method is PUT or POST, and the body is not already parsed in formData, then the unparsed request body elements are contained in this array. */
raw?: UploadData[];
} | undefined;
};
}

export interface OnBeforeSendHeadersDetails extends WebRequestDetails {
Expand Down Expand Up @@ -14345,7 +14362,7 @@ declare namespace chrome {
* The headers provided by a hypothetical response if the request does not get blocked or redirected before it is sent. Represented as an object which maps a header name to a list of string values. If not specified, the hypothetical response would return empty response headers, which can match rules which match on the non-existence of headers. E.g. `{"content-type": ["text/html; charset=utf-8", "multipart/form-data"]}`
* @since Chrome 129
*/
responseHeaders?: { [name: string]: unknown };
responseHeaders?: { [name: string]: string[] };
/** The ID of the tab in which the hypothetical request takes place. Does not need to correspond to a real tab ID. Default is -1, meaning that the request isn't related to a tab. */
tabId?: number;
/**
Expand Down Expand Up @@ -14683,13 +14700,13 @@ declare namespace chrome {
* Fired when the extension's side panel is closed.
* @since Chrome 142
*/
const onClosed: events.Event<(info: PanelClosedInfo) => void>;
export const onClosed: events.Event<(info: PanelClosedInfo) => void>;

/**
* Fired when the extension's side panel is opened.
* @since Chrome 141
*/
const onOpened: events.Event<(info: PanelOpenedInfo) => void>;
export const onOpened: events.Event<(info: PanelOpenedInfo) => void>;
}

////////////////////
Expand Down Expand Up @@ -14795,7 +14812,7 @@ declare namespace chrome {
/** Specifies wildcard patterns for pages this user script will be injected into. */
includeGlobs?: string[] | undefined;
/** The list of ScriptSource objects defining sources of scripts to be injected into matching pages. This property must be specified for {@link register}, and when specified it must be a non-empty array.*/
js: ScriptSource[];
js?: ScriptSource[] | undefined;
/** Specifies which pages this user script will be injected into. See Match Patterns for more details on the syntax of these strings. This property must be specified for {@link register}. */
matches?: string[] | undefined;
/** Specifies when JavaScript files are injected into the web page. The preferred and default value is `document_idle` */
Expand Down
26 changes: 23 additions & 3 deletions types/chrome/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,14 @@ function testDeclarativeContent() {
const imageData = new ImageData(32, 32);

new chrome.declarativeContent.SetIcon({ imageData }); // $ExpectType SetIcon
new chrome.declarativeContent.SetIcon({ imageData: { 32: imageData } }); // $ExpectType SetIcon
new chrome.declarativeContent.SetIcon({ path: "image.jpg" }); // $ExpectType SetIcon
new chrome.declarativeContent.SetIcon({ imageData, path: "image.jpg" }); // $ExpectType SetIcon
new chrome.declarativeContent.SetIcon({ imageData, path: { "32": "image.jpg" } }); // $ExpectType SetIcon
// @ts-expect-error Cannot use 'in' operator to search for 'iconIndex' in undefined
new chrome.declarativeContent.SetIcon();
// @ts-expect-error Uncaught Error: Either the path or imageData property must be specified
new chrome.declarativeContent.SetIcon({});

const action = new chrome.declarativeContent.ShowAction(); // $ExpectType ShowAction

Expand Down Expand Up @@ -4528,7 +4536,7 @@ function testDocumentScan() {
const optionSettings: chrome.documentScan.OptionSetting[] = [{
name: "name",
type: "GROUP",
value: "value",
value: [10],
}];
chrome.documentScan.setOptions(scannerHandle, optionSettings); // $ExpectType Promise<SetOptionsResponse<"handle">>
chrome.documentScan.setOptions(scannerHandle, optionSettings, response => { // $ExpectType void
Expand Down Expand Up @@ -4597,6 +4605,18 @@ function testEnterpriseHardwarePlatform() {
chrome.enterprise.hardwarePlatform.getHardwarePlatformInfo((info) => {}).then((info) => {});
}

// https://developer.chrome.com/docs/extensions/reference/api/enterprise/networkingAttributes
function testEntrepriseNetworkingAttributes() {
chrome.enterprise.networkingAttributes.getNetworkDetails(); // $ExpectType Promise<NetworkDetails>
chrome.enterprise.networkingAttributes.getNetworkDetails((networkAddresses) => { // $ExpectType void
networkAddresses.ipv4; // $ExpectType string | undefined
networkAddresses.ipv6; // $ExpectType string | undefined
networkAddresses.macAddress; // $ExpectType string
});
// @ts-expect-error
chrome.enterprise.networkingAttributes.getNetworkDetails((networkAddresses) => {}).then((networkAddresses) => {});
}

// https://developer.chrome.com/docs/extensions/reference/api/enterprise/login
function testEnterpriseLogin() {
chrome.enterprise.login.exitCurrentManagedGuestSession(); // $ExpectType Promise<void>
Expand Down Expand Up @@ -6626,7 +6646,7 @@ function testPrinterProvider() {
// https://developer.chrome.com/docs/extensions/reference/api/platformKeys
function testPlatformKeys() {
chrome.platformKeys.ClientCertificateType.ECDSA_SIGN === "ecdsaSign";
chrome.platformKeys.ClientCertificateType.RAS_SIGN === "rasSign";
chrome.platformKeys.ClientCertificateType.RSA_SIGN === "rsaSign";

const arrayBuffer = new ArrayBuffer(0);

Expand All @@ -6645,7 +6665,7 @@ function testPlatformKeys() {
interactive: true,
request: {
certificateAuthorities: [],
certificateTypes: ["ecdsaSign", chrome.platformKeys.ClientCertificateType.RAS_SIGN],
certificateTypes: ["ecdsaSign", chrome.platformKeys.ClientCertificateType.RSA_SIGN],
},
};

Expand Down
18 changes: 8 additions & 10 deletions types/layui/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
/// <reference types="jquery" />
/// <reference path="modules/breadcrumb.d.ts" />
/// <reference path="modules/carousel.d.ts" />
/// <reference path="modules/code.d.ts" />
/// <reference path="modules/collapse.d.ts" />
/// <reference path="modules/colorpicker.d.ts" />
/// <reference path="modules/component.d.ts" />
/// <reference path="modules/dropdown.d.ts" />
/// <reference path="modules/element.d.ts" />
/// <reference path="modules/flow.d.ts" />
/// <reference path="modules/form.d.ts" />
/// <reference path="modules/i18n.d.ts" />
/// <reference path="modules/lay.d.ts" />
/// <reference path="modules/laydate.d.ts" />
/// <reference path="modules/layedit.d.ts" />
/// <reference path="modules/layer.d.ts" />
/// <reference path="modules/laypage.d.ts" />
/// <reference path="modules/laytpl.d.ts" />
/// <reference path="modules/nav.d.ts" />
/// <reference path="modules/progress.d.ts" />
/// <reference path="modules/rate.d.ts" />
/// <reference path="modules/slider.d.ts" />
/// <reference path="modules/tab.d.ts" />
/// <reference path="modules/table.d.ts" />
/// <reference path="modules/tabs.d.ts" />
/// <reference path="modules/transfer.d.ts" />
Expand All @@ -28,19 +34,11 @@
declare const layui: Layui;
declare const lay: Layui.LayStatic;
declare const layer: Layui.Layer;
/**
* 动态加载等特殊场景设置 layui 目录
* @since 2.6.6
*/
declare const LAYUI_GLOBAL: { dir: string };
declare const LAYUI_GLOBAL: Layui.GlobalProperties;

interface Window {
layui: Layui;
lay: Layui.LayStatic;
layer: Layui.Layer;
/**
* 动态加载等特殊场景设置 layui 目录
* @since 2.6.6
*/
LAYUI_GLOBAL: { dir: string };
LAYUI_GLOBAL: Layui.GlobalProperties;
}
Loading