From b2af2b5c0637049638e5406dbb2580fb0cc36aca Mon Sep 17 00:00:00 2001 From: Erwan Jugand <47392755+erwanjugand@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:30:13 +0200 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#73439=20[chrom?= =?UTF-8?q?e]=20add=20enterprise.login=20namespace=20by=20@erwanjugand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/chrome/index.d.ts | 19 +++++++++++++++++++ types/chrome/test/index.ts | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 94844f700847cc..a8abc18d03cfa7 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -4262,6 +4262,24 @@ declare namespace chrome { export function getHardwarePlatformInfo(callback: (info: HardwarePlatformInfo) => void): void; } + //////////////////// + // Enterprise Login + //////////////////// + /** + * Use the `chrome.enterprise.login` API to exit Managed Guest sessions. Note: This API is only available to extensions installed by enterprise policy in ChromeOS Managed Guest sessions. + * + * Permissions: "enterprise.login" + * + * Note: Only available to policy installed extensions. + * @platform ChromeOS only + * @since Chrome 139 + */ + export namespace enterprise.login { + /** Exits the current managed guest session. */ + export function exitCurrentManagedGuestSession(): Promise; + export function exitCurrentManagedGuestSession(callback: () => void): void; + } + //////////////////// // Enterprise Networking Attributes //////////////////// @@ -8826,6 +8844,7 @@ declare namespace chrome { | "downloads.ui" | "enterprise.deviceAttributes" | "enterprise.hardwarePlatform" + | "enterprise.login" | "enterprise.networkingAttributes" | "enterprise.platformKeys" | "experimental" diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts index 257ed56750dd4c..47a2e915415d97 100644 --- a/types/chrome/test/index.ts +++ b/types/chrome/test/index.ts @@ -3632,6 +3632,14 @@ function testEnterpriseHardwarePlatform() { chrome.enterprise.hardwarePlatform.getHardwarePlatformInfo((info) => {}).then((info) => {}); } +// https://developer.chrome.com/docs/extensions/reference/api/enterprise/login +function testEnterpriseLogin() { + chrome.enterprise.login.exitCurrentManagedGuestSession(); // $ExpectType Promise + chrome.enterprise.login.exitCurrentManagedGuestSession(() => void 0); // $ExpectType void + // @ts-expect-error + chrome.enterprise.login.exitCurrentManagedGuestSession(() => {}).then(() => {}); +} + // https://developer.chrome.com/docs/extensions/reference/api/browsingData function testBrowsingData() { const removalOptions: chrome.browsingData.RemovalOptions = { From 32a648fbb87745f87383a67bd0ee303f039d290c Mon Sep 17 00:00:00 2001 From: Erwan Jugand <47392755+erwanjugand@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:30:30 +0200 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#73393=20[chrom?= =?UTF-8?q?e]=20update=20runtime=20namespace=20by=20@erwanjugand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/chrome/index.d.ts | 4 +++- types/chrome/test/index.ts | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index a8abc18d03cfa7..33070d13129e88 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -8589,6 +8589,8 @@ declare namespace chrome { MIPS = "mips", /** Specifies the processer architecture as mips64. */ MIPS64 = "mips64", + /** Specifies the processer architecture as riscv64. */ + RISCV64 = "riscv64", } /** @@ -8755,7 +8757,7 @@ declare namespace chrome { /** The machine's processor architecture. */ arch: `${PlatformArch}`; /** The native client architecture. This may be different from arch on some platforms. */ - nacl_arch: `${PlatformNaclArch}`; + nacl_arch?: `${PlatformNaclArch}`; } /** An object which allows two way communication with other pages. */ diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts index 47a2e915415d97..56cf49852b31b5 100644 --- a/types/chrome/test/index.ts +++ b/types/chrome/test/index.ts @@ -638,6 +638,7 @@ function testRuntime() { chrome.runtime.PlatformArch.MIPS64 === "mips64"; chrome.runtime.PlatformArch.X86_32 === "x86-32"; chrome.runtime.PlatformArch.X86_64 === "x86-64"; + chrome.runtime.PlatformArch.RISCV64 === "riscv64"; chrome.runtime.PlatformNaclArch.ARM === "arm"; chrome.runtime.PlatformNaclArch.MIPS === "mips"; @@ -709,8 +710,8 @@ function testRuntime() { chrome.runtime.getPlatformInfo(); // $ExpectType Promise chrome.runtime.getPlatformInfo((platformInfo) => { // $ExpectType void - platformInfo.arch; // $ExpectType "arm" | "arm64" | "x86-32" | "x86-64" | "mips" | "mips64" - platformInfo.nacl_arch; // $ExpectType "arm" | "mips" | "mips64" | "x86-32" | "x86-64" + platformInfo.arch; // $ExpectType "arm" | "arm64" | "x86-32" | "x86-64" | "mips" | "mips64" | "riscv64" + platformInfo.nacl_arch; // $ExpectType "arm" | "mips" | "mips64" | "x86-32" | "x86-64" | undefined platformInfo.os; // $ExpectType "android" | "cros" | "fuchsia" | "linux" | "mac" | "openbsd" | "win" }); // @ts-expect-error From 378d63d275678fdae279edcdee5194d147c24b48 Mon Sep 17 00:00:00 2001 From: Erwan Jugand <47392755+erwanjugand@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:30:46 +0200 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#73395=20[chrom?= =?UTF-8?q?e]=20update=20cookies=20namespace=20by=20@erwanjugand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/chrome/index.d.ts | 138 ++++++++++++++++++------------------- types/chrome/test/index.ts | 58 ++++++++++++++-- 2 files changed, 117 insertions(+), 79 deletions(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 33070d13129e88..42f4bc7c9cec1b 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -2086,7 +2086,12 @@ declare namespace chrome { */ export namespace cookies { /** A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set with 'SameSite=None', 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'. 'unspecified' corresponds to a cookie set without the SameSite attribute. **/ - export type SameSiteStatus = "unspecified" | "no_restriction" | "lax" | "strict"; + export enum SameSiteStatus { + NO_RESTRICTION = "no_restriction", + LAX = "lax", + STRICT = "strict", + UNSPECIFIED = "unspecified", + } /** Represents information about an HTTP cookie. */ export interface Cookie { @@ -2107,8 +2112,8 @@ declare namespace chrome { session: boolean; /** True if the cookie is a host-only cookie (i.e. a request's host must exactly match the domain of the cookie). */ hostOnly: boolean; - /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */ - expirationDate?: number | undefined; + /** The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */ + expirationDate?: number; /** The path of the cookie. */ path: string; /** True if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts). */ @@ -2119,10 +2124,13 @@ declare namespace chrome { * The cookie's same-site status (i.e. whether the cookie is sent with cross-site requests). * @since Chrome 51 */ - sameSite: SameSiteStatus; + sameSite: `${SameSiteStatus}`; } - /** Represents a partitioned cookie's partition key. */ + /** + * Represents a partitioned cookie's partition key. + * @since Chrome 119 + */ export interface CookiePartitionKey { /** * Indicates if the cookie was set in a cross-cross site context. This prevents a top-level site embedded in a cross-site context from accessing cookies set by the top-level site in a same-site context. @@ -2142,31 +2150,31 @@ declare namespace chrome { } export interface GetAllDetails { - /** Optional. Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */ + /** Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */ domain?: string | undefined; - /** Optional. Filters the cookies by name. */ + /** Filters the cookies by name. */ name?: string | undefined; /** * The partition key for reading or modifying cookies with the Partitioned attribute. * @since Chrome 119 */ partitionKey?: CookiePartitionKey | undefined; - /** Optional. Restricts the retrieved cookies to those that would match the given URL. */ + /** Restricts the retrieved cookies to those that would match the given URL. */ url?: string | undefined; - /** Optional. The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */ + /** The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */ storeId?: string | undefined; - /** Optional. Filters out session vs. persistent cookies. */ + /** Filters out session vs. persistent cookies. */ session?: boolean | undefined; - /** Optional. Restricts the retrieved cookies to those whose path exactly matches this string. */ + /** Restricts the retrieved cookies to those whose path exactly matches this string. */ path?: string | undefined; - /** Optional. Filters the cookies by their Secure property. */ + /** Filters the cookies by their Secure property. */ secure?: boolean | undefined; } export interface SetDetails { - /** Optional. The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */ + /** The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */ domain?: string | undefined; - /** Optional. The name of the cookie. Empty by default if omitted. */ + /** The name of the cookie. Empty by default if omitted. */ name?: string | undefined; /** * The partition key for reading or modifying cookies with the Partitioned attribute. @@ -2175,26 +2183,29 @@ declare namespace chrome { partitionKey?: CookiePartitionKey | undefined; /** The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail. */ url: string; - /** Optional. The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store. */ + /** The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store. */ storeId?: string | undefined; - /** Optional. The value of the cookie. Empty by default if omitted. */ + /** The value of the cookie. Empty by default if omitted. */ value?: string | undefined; - /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie. */ + /** The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie. */ expirationDate?: number | undefined; - /** Optional. The path of the cookie. Defaults to the path portion of the url parameter. */ + /** The path of the cookie. Defaults to the path portion of the url parameter. */ path?: string | undefined; - /** Optional. Whether the cookie should be marked as HttpOnly. Defaults to false. */ + /** Whether the cookie should be marked as HttpOnly. Defaults to false. */ httpOnly?: boolean | undefined; - /** Optional. Whether the cookie should be marked as Secure. Defaults to false. */ + /** Whether the cookie should be marked as Secure. Defaults to false. */ secure?: boolean | undefined; /** - * Optional. The cookie's same-site status. Defaults to "unspecified", i.e., if omitted, the cookie is set without specifying a SameSite attribute. + * The cookie's same-site status. Defaults to "unspecified", i.e., if omitted, the cookie is set without specifying a SameSite attribute. * @since Chrome 51 */ - sameSite?: SameSiteStatus | undefined; + sameSite?: `${SameSiteStatus}` | undefined; } - /** Details to identify the cookie. */ + /** + * Details to identify the cookie. + * @since Chrome 88 + */ export interface CookieDetails { /** The name of the cookie to access. */ name: string; @@ -2214,11 +2225,8 @@ declare namespace chrome { cookie: Cookie; /** True if a cookie was removed. */ removed: boolean; - /** - * @since Chrome 12 - * The underlying reason behind the cookie's change. - */ - cause: string; + /** The underlying reason behind the cookie's change. */ + cause: `${OnChangedCause}`; } /** @@ -2227,30 +2235,37 @@ declare namespace chrome { */ export interface FrameDetails { /** The unique identifier for the document. If the frameId and/or tabId are provided they will be validated to match the document found by provided document ID. */ - documentId?: string; + documentId?: string | undefined; /** The unique identifier for the frame within the tab. */ - frameId?: number; + frameId?: number | undefined; /* The unique identifier for the tab containing the frame. */ - tabId?: number; + tabId?: number | undefined; } - export interface CookieChangedEvent extends chrome.events.Event<(changeInfo: CookieChangeInfo) => void> {} - /** - * Lists all existing cookie stores. - * Parameter cookieStores: All the existing cookie stores. + * The underlying reason behind the cookie's change. If a cookie was inserted, or removed via an explicit call to "chrome.cookies.remove", "cause" will be "explicit". If a cookie was automatically removed due to expiry, "cause" will be "expired". If a cookie was removed due to being overwritten with an already-expired expiration date, "cause" will be set to "expired_overwrite". If a cookie was automatically removed due to garbage collection, "cause" will be "evicted". If a cookie was automatically removed due to a "set" call that overwrote it, "cause" will be "overwrite". Plan your response accordingly. + * @since Chrome 44 */ - export function getAllCookieStores(callback: (cookieStores: CookieStore[]) => void): void; + export enum OnChangedCause { + EVICTED = "evicted", + EXPIRED = "expired", + EXPLICIT = "explicit", + EXPIRED_OVERWRITE = "expired_overwrite", + OVERWRITE = "overwrite", + } /** * Lists all existing cookie stores. - * @return The `getAllCookieStores` method provides its result via callback or returned as a `Promise` (MV3 only). + * + * Can return its result via Promise in Manifest V3 or later. */ export function getAllCookieStores(): Promise; + export function getAllCookieStores(callback: (cookieStores: CookieStore[]) => void): void; /** * The partition key for the frame indicated. - * Can return its result via Promise in Manifest V3 + * + * Can return its result via Promise in Manifest V3 or later. * @since Chrome 132 */ export function getPartitionKey(details: FrameDetails): Promise<{ partitionKey: CookiePartitionKey }>; @@ -2260,62 +2275,41 @@ declare namespace chrome { ): void; /** - * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first. - * @param details Information to filter the cookies being retrieved. - * Parameter cookies: All the existing, unexpired cookies that match the given cookie info. - */ - export function getAll(details: GetAllDetails, callback: (cookies: Cookie[]) => void): void; - - /** - * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first. - * @param details Information to filter the cookies being retrieved. - * @return The `getAll` method provides its result via callback or returned as a `Promise` (MV3 only). + * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first. This method only retrieves cookies for domains that the extension has host permissions to + * @param details Information to identify the cookie to remove. + * + * Can return its result via Promise in Manifest V3 or later. */ export function getAll(details: GetAllDetails): Promise; + export function getAll(details: GetAllDetails, callback: (cookies: Cookie[]) => void): void; /** * Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist. * @param details Details about the cookie being set. - * @return The `set` method provides its result via callback or returned as a `Promise` (MV3 only). + * + * Can return its result via Promise in Manifest V3 or later. */ export function set(details: SetDetails): Promise; - - /** - * Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist. - * @param details Details about the cookie being set. - * Optional parameter cookie: Contains details about the cookie that's been set. If setting failed for any reason, this will be "null", and "chrome.runtime.lastError" will be set. - */ export function set(details: SetDetails, callback: (cookie: Cookie | null) => void): void; /** * Deletes a cookie by name. - * @param details Information to identify the cookie to remove. - * @return The `remove` method provides its result via callback or returned as a `Promise` (MV3 only). + * + * Can return its result via Promise in Manifest V3 or later. */ export function remove(details: CookieDetails): Promise; - - /** - * Deletes a cookie by name. - * @param details Information to identify the cookie to remove. - */ export function remove(details: CookieDetails, callback?: (details: CookieDetails) => void): void; /** * Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned. - * @param details Details to identify the cookie being retrieved. - * Parameter cookie: Contains details about the cookie. This parameter is null if no such cookie was found. - */ - export function get(details: CookieDetails, callback: (cookie: Cookie | null) => void): void; - - /** - * Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned. - * @param details Details to identify the cookie being retrieved. - * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only). + * + * Can return its result via Promise in Manifest V3 or later. */ export function get(details: CookieDetails): Promise; + export function get(details: CookieDetails, callback: (cookie: Cookie | null) => void): void; /** Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a two step process: the cookie to be updated is first removed entirely, generating a notification with "cause" of "overwrite" . Afterwards, a new cookie is written with the updated values, generating a second notification with "cause" "explicit". */ - export var onChanged: CookieChangedEvent; + export const onChanged: events.Event<(changeInfo: CookieChangeInfo) => void>; } //////////////////// diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts index 56cf49852b31b5..dc57cd4453a658 100644 --- a/types/chrome/test/index.ts +++ b/types/chrome/test/index.ts @@ -1972,6 +1972,17 @@ async function testBrowserActionForPromise() { // https://developer.chrome.com/docs/extensions/reference/api/cookies async function testCookie() { + chrome.cookies.OnChangedCause.EVICTED === "evicted"; + chrome.cookies.OnChangedCause.EXPIRED === "expired"; + chrome.cookies.OnChangedCause.EXPIRED_OVERWRITE === "expired_overwrite"; + chrome.cookies.OnChangedCause.EXPLICIT === "explicit"; + chrome.cookies.OnChangedCause.OVERWRITE === "overwrite"; + + chrome.cookies.SameSiteStatus.LAX === "lax"; + chrome.cookies.SameSiteStatus.NO_RESTRICTION === "no_restriction"; + chrome.cookies.SameSiteStatus.STRICT === "strict"; + chrome.cookies.SameSiteStatus.UNSPECIFIED === "unspecified"; + const cookieDetails: chrome.cookies.CookieDetails = { url: "https://example.com", name: "example", @@ -1979,6 +1990,7 @@ async function testCookie() { topLevelSite: "https://example.com", hasCrossSiteAncestor: false, }, + storeId: "storeId1", }; chrome.cookies.get(cookieDetails); // $ExpectType Promise @@ -1988,12 +2000,26 @@ async function testCookie() { // @ts-expect-error chrome.cookies.get(cookieDetails, () => {}).then(() => {}); - chrome.cookies.getAll(cookieDetails); // $ExpectType Promise - chrome.cookies.getAll(cookieDetails, (cookies) => { + const cookiesAllDetails: chrome.cookies.GetAllDetails = { + domain: "example.com", + name: "example", + partitionKey: { + topLevelSite: "https://example.com", + hasCrossSiteAncestor: false, + }, + path: "/", + secure: true, + session: true, + storeId: "storeId1", + url: "https://example.com", + }; + + chrome.cookies.getAll(cookiesAllDetails); // $ExpectType Promise + chrome.cookies.getAll(cookiesAllDetails, (cookies) => { cookies; // $ExpectType Cookie[] }); // @ts-expect-error - chrome.cookies.getAll(cookieDetails, () => {}).then(() => {}); + chrome.cookies.getAll(cookiesAllDetails, () => {}).then(() => {}); chrome.cookies.getAllCookieStores(); // $ExpectType Promise chrome.cookies.getAllCookieStores((cookieStores) => { @@ -2020,15 +2046,33 @@ async function testCookie() { // @ts-expect-error chrome.cookies.remove(cookieDetails, () => {}).then(() => {}); - chrome.cookies.set(cookieDetails); // $ExpectType Promise - chrome.cookies.set(cookieDetails, (cookie) => { + const cookieDetailsSet: chrome.cookies.SetDetails = { + domain: "example.com", + expirationDate: 1717334400, + httpOnly: true, + name: "example", + partitionKey: { + topLevelSite: "https://example.com", + hasCrossSiteAncestor: false, + }, + path: "/", + sameSite: "strict", + secure: true, + url: "https://example.com", + value: "value1", + }; + + chrome.cookies.set(cookieDetailsSet); // $ExpectType Promise + chrome.cookies.set(cookieDetailsSet, (cookie) => { cookie; // $ExpectType Cookie | null }); // @ts-expect-error - chrome.cookies.set(cookieDetails, () => {}).then(() => {}); + chrome.cookies.set(cookieDetailsSet, () => {}).then(() => {}); checkChromeEvent(chrome.cookies.onChanged, (changeInfo) => { - changeInfo; // $ExpectType CookieChangeInfo + changeInfo.cause; // $ExpectType "evicted" | "expired" | "explicit" | "expired_overwrite" | "overwrite" + changeInfo.cookie; // $ExpectType Cookie + changeInfo.removed; // $ExpectType boolean }); } From 18d88c30ac8a0dfaae216bf35647d910638dee66 Mon Sep 17 00:00:00 2001 From: Erwan Jugand <47392755+erwanjugand@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:31:00 +0200 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#73413=20[chrom?= =?UTF-8?q?e]=20update=20desktopCapture=20namespace=20by=20@erwanjugand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/chrome/index.d.ts | 32 ++++++++++++++++++++------------ types/chrome/test/index.ts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 42f4bc7c9cec1b..4052459d53ad52 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -2617,31 +2617,39 @@ declare namespace chrome { * Permissions: "desktopCapture" */ export namespace desktopCapture { - /** Contains properties that describe the stream. */ + /** Enum used to define set of desktop media sources used in {@link chooseDesktopMedia}. */ + export enum DesktopCaptureSourceType { + SCREEN = "screen", + WINDOW = "window", + TAB = "tab", + AUDIO = "audio", + } + + /** + * Contains properties that describe the stream. + * @since Chrome 57 + */ export interface StreamOptions { /** True if "audio" is included in parameter sources, and the end user does not uncheck the "Share audio" checkbox. Otherwise false, and in this case, one should not ask for audio stream through getUserMedia call. */ canRequestAudioTrack: boolean; } /** * Shows desktop media picker UI with the specified set of sources. - * @param sources Set of sources that should be shown to the user. - * Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used. + * @param sources Set of sources that should be shown to the user. The sources order in the set decides the tab order in the picker. + * @param targetTab Optional tab for which the stream is created. If not specified then the resulting stream can be used only by the calling extension. The stream can only be used by frames in the given tab whose security origin matches `tab.url`. The tab's origin must be a secure origin, e.g. HTTPS. + * @param callback streamId: An opaque string that can be passed to `getUserMedia()` API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty `streamId`. The created `streamId` can be used only once and expires after a few seconds when it is not used. + * @return An id that can be passed to cancelChooseDesktopMedia() in case the prompt need to be canceled. */ export function chooseDesktopMedia( - sources: string[], + sources: `${DesktopCaptureSourceType}`[], callback: (streamId: string, options: StreamOptions) => void, ): number; - /** - * Shows desktop media picker UI with the specified set of sources. - * @param sources Set of sources that should be shown to the user. - * @param targetTab Optional tab for which the stream is created. If not specified then the resulting stream can be used only by the calling extension. The stream can only be used by frames in the given tab whose security origin matches tab.url. - * Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used. - */ export function chooseDesktopMedia( - sources: string[], - targetTab: chrome.tabs.Tab, + sources: `${DesktopCaptureSourceType}`[], + targetTab: tabs.Tab | undefined, callback: (streamId: string, options: StreamOptions) => void, ): number; + /** * Hides desktop media picker dialog shown by chooseDesktopMedia(). * @param desktopMediaRequestId Id returned by chooseDesktopMedia() diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts index dc57cd4453a658..57e231dc4e2278 100644 --- a/types/chrome/test/index.ts +++ b/types/chrome/test/index.ts @@ -6513,3 +6513,38 @@ function testReadingList() { function testDom() { chrome.dom.openOrClosedShadowRoot(document.body); // $ExpectType ShadowRoot | null } + +// https://developer.chrome.com/docs/extensions/reference/api/desktopCapture +function testDesktopCapture() { + chrome.desktopCapture.DesktopCaptureSourceType.AUDIO === "audio"; + chrome.desktopCapture.DesktopCaptureSourceType.SCREEN === "screen"; + chrome.desktopCapture.DesktopCaptureSourceType.TAB === "tab"; + chrome.desktopCapture.DesktopCaptureSourceType.WINDOW === "window"; + + chrome.desktopCapture.cancelChooseDesktopMedia(0); // $ExpectType void + + const sources: `${chrome.desktopCapture.DesktopCaptureSourceType}`[] = [ + "screen", + chrome.desktopCapture.DesktopCaptureSourceType.WINDOW, + ]; + + const tab: chrome.tabs.Tab = { + index: 0, + pinned: false, + highlighted: false, + windowId: 0, + active: false, + frozen: false, + incognito: false, + selected: false, + discarded: false, + autoDiscardable: false, + groupId: 0, + }; + + chrome.desktopCapture.chooseDesktopMedia(sources, () => {}); // $ExpectType number + chrome.desktopCapture.chooseDesktopMedia(sources, tab, (streamId, options) => { + streamId; // $ExpectType string + options; // $ExpectType StreamOptions + }); +} From 9b936f8f028ae8ff65dde6fcf65348afc814135e Mon Sep 17 00:00:00 2001 From: agachuma <52526593+agachuma@users.noreply.github.com> Date: Thu, 14 Aug 2025 10:53:13 +0200 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#73469=20Featur?= =?UTF-8?q?e/mapping=20editor=20by=20@agachuma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan Hörnle Co-authored-by: Paul Kellett --- types/gorilla-engine/components/MappingEditor.d.ts | 3 ++- types/gorilla-engine/gorilla-engine-tests.ts | 5 +++-- types/gorilla-engine/index.d.ts | 9 ++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/types/gorilla-engine/components/MappingEditor.d.ts b/types/gorilla-engine/components/MappingEditor.d.ts index 58096e8bf0ef54..624bb2777028f9 100644 --- a/types/gorilla-engine/components/MappingEditor.d.ts +++ b/types/gorilla-engine/components/MappingEditor.d.ts @@ -1,4 +1,5 @@ declare namespace GorillaEngine.UI { + interface Zone { path: string; name: string; @@ -16,7 +17,7 @@ declare namespace GorillaEngine.UI { refreshView(index?: number): void; selectAllZones(): void; deselectAllZones(): void; - selectZones(zones: Partial): void; + selectZones(zones: Partial):void; addZones(zones: Partial): void; removeZones(zones: Partial): void; } diff --git a/types/gorilla-engine/gorilla-engine-tests.ts b/types/gorilla-engine/gorilla-engine-tests.ts index 451b3738131c7c..1546ce88b595ae 100644 --- a/types/gorilla-engine/gorilla-engine-tests.ts +++ b/types/gorilla-engine/gorilla-engine-tests.ts @@ -1,3 +1,4 @@ + const mylabel = new GorillaEngine.UI.Label({ text: "rr" }); const combo = new GorillaEngine.UI.ComboBox({ id: "myCombo", x: 0 }); @@ -12,6 +13,6 @@ const knob = new GorillaEngine.UI.Knob({ id: "myknob" }); const label = new GorillaEngine.UI.Label({ margin: 5 }); -const slider = new GorillaEngine.UI.Slider({ id: "slider", x: 0 }); +const slider = new GorillaEngine.UI.Slider({ id: "slider", x: 0, y: 2 }); -const mappingEditor = new GorillaEngine.UI.MappingEditor({ id: "myNewMappingEditor", x: 3, y: 2 }); +const mappingEditor = new GorillaEngine.UI.MappingEditor({ id: 'myNewMappingEditor', x: 3, y:2}) diff --git a/types/gorilla-engine/index.d.ts b/types/gorilla-engine/index.d.ts index 722a26ad33d83c..30c6859ac38350 100755 --- a/types/gorilla-engine/index.d.ts +++ b/types/gorilla-engine/index.d.ts @@ -174,6 +174,13 @@ declare namespace GorillaEngine { * @param module The serialised module to set as a string */ setModuleAtPath(path: string, module: string): boolean; + /** + * Method used to replace a module in an instrument in a given path + * @param path The path to the module that should be retrieved. + * @param module The serialised module to replace as a string + */ + replaceModuleAtPath(path: string, module: string): boolean; + /** * Method used to determine if a value from the Gorilla Engine is a module. * @@ -598,4 +605,4 @@ declare namespace GorillaEngine { */ function setSettingsButtonPosition(x: number, y: number): void; } -} +} \ No newline at end of file From b00bfabaded8aee586b7b59ede6a654e36e552a2 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Thu, 14 Aug 2025 08:53:47 +0000 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=A4=96=20dprint=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/gorilla-engine/components/MappingEditor.d.ts | 3 +-- types/gorilla-engine/gorilla-engine-tests.ts | 3 +-- types/gorilla-engine/index.d.ts | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/types/gorilla-engine/components/MappingEditor.d.ts b/types/gorilla-engine/components/MappingEditor.d.ts index 624bb2777028f9..58096e8bf0ef54 100644 --- a/types/gorilla-engine/components/MappingEditor.d.ts +++ b/types/gorilla-engine/components/MappingEditor.d.ts @@ -1,5 +1,4 @@ declare namespace GorillaEngine.UI { - interface Zone { path: string; name: string; @@ -17,7 +16,7 @@ declare namespace GorillaEngine.UI { refreshView(index?: number): void; selectAllZones(): void; deselectAllZones(): void; - selectZones(zones: Partial):void; + selectZones(zones: Partial): void; addZones(zones: Partial): void; removeZones(zones: Partial): void; } diff --git a/types/gorilla-engine/gorilla-engine-tests.ts b/types/gorilla-engine/gorilla-engine-tests.ts index 1546ce88b595ae..b3af70be7348b3 100644 --- a/types/gorilla-engine/gorilla-engine-tests.ts +++ b/types/gorilla-engine/gorilla-engine-tests.ts @@ -1,4 +1,3 @@ - const mylabel = new GorillaEngine.UI.Label({ text: "rr" }); const combo = new GorillaEngine.UI.ComboBox({ id: "myCombo", x: 0 }); @@ -15,4 +14,4 @@ const label = new GorillaEngine.UI.Label({ margin: 5 }); const slider = new GorillaEngine.UI.Slider({ id: "slider", x: 0, y: 2 }); -const mappingEditor = new GorillaEngine.UI.MappingEditor({ id: 'myNewMappingEditor', x: 3, y:2}) +const mappingEditor = new GorillaEngine.UI.MappingEditor({ id: "myNewMappingEditor", x: 3, y: 2 }); diff --git a/types/gorilla-engine/index.d.ts b/types/gorilla-engine/index.d.ts index 30c6859ac38350..40d313451e5e27 100755 --- a/types/gorilla-engine/index.d.ts +++ b/types/gorilla-engine/index.d.ts @@ -605,4 +605,4 @@ declare namespace GorillaEngine { */ function setSettingsButtonPosition(x: number, y: number): void; } -} \ No newline at end of file +}