bitwarden-estensione-browser/apps/browser/src/platform/globals.d.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

129 lines
3.6 KiB
TypeScript
Raw Normal View History

2017-11-02 04:36:29 +01:00
declare function escape(s: string): string;
declare function unescape(s: string): string;
/**
* @link https://dev.opera.com/extensions/addons-api/
*/
type OperaAddons = {
/**
* @link https://dev.opera.com/extensions/addons-api/#method-installextension
*/
installExtension: (
id: string,
success_callback: () => void,
error_callback: (errorMessage: string) => void,
) => void;
};
type OperaEvent<T> = {
addListener: (callback: (state: T) => void) => void;
};
/**
* @link https://dev.opera.com/extensions/sidebar-action-api/#type-colorarray
*/
type ColorArray = [number, number, number, number];
/**
* @link https://dev.opera.com/extensions/sidebar-action-api/#type-imagedatatype
*/
type ImageDataType = ImageData;
/**
* @link https://dev.opera.com/extensions/sidebar-action-api/
*/
type OperaSidebarAction = {
/**
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-settitle
*/
setTitle: (details: { title: string; tabId?: number }) => void;
/**
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-gettitle
*/
getTitle: (details: { tabId?: number }, callback: (result: string) => void) => void;
/**
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-seticon
*/
setIcon: (
details: {
imageData?: ImageDataType | Record<number, ImageDataType>;
path?: string | Record<number, string>;
tabId?: number;
},
callback?: () => void,
) => void;
/**
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-setpanel
*/
setPanel: (details: { tabId?: number; panel: string }) => void;
/**
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-getpanel
*/
getPanel: (details: { tabId?: number }, callback: (result: string) => void) => void;
/**
* *Not supported on mac*
*
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-setbadgetext
*/
setBadgeText: (details: { text: string; tabId?: number }) => void;
/**
* *Not supported on mac*
*
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-getbadgetext
*/
getBadgeText: (details: { tabId?: number }, callback: (result: string) => void) => void;
/**
* *Not supported on mac*
*
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-setbadgebackgroundcolor
*/
setBadgeBackgroundColor: (details: { color: ColorArray | string; tabId?: number }) => void;
/**
* *Not supported on mac*
*
* @link https://dev.opera.com/extensions/sidebar-action-api/#method-getbadgebackgroundcolor
*/
getBadgeBackgroundColor: (
details: { tabId?: number },
callback: (result: ColorArray) => void,
) => void;
/**
* *Not supported on mac*
*
* @link https://dev.opera.com/extensions/sidebar-action-api/#events-onfocus
*/
onFocus: OperaEvent<Window>;
/**
* *Not supported on mac*
*
* @link https://dev.opera.com/extensions/sidebar-action-api/#events-onblur
*/
onBlur: OperaEvent<Window>;
};
Ps 1291 fix extension icon updates (#3571) * Add needed factories for AuthService WIP: Allow console logs * Add badge updates * Init by listener * Improve tab identification * Define MV3 background init * Init services in factories. Requires conversion of all factories to promises. We need to initialize in factory since the requester of a service doesn't necessarily know all dependencies for that service. The only alternative is to create an out parameter for a generated init function, which isn't ideal. * Improve badge setting * Use `update-badge` in mv2 and mv3 Separates menu and badge updates * Use update-badge everywhere * Use BrowserApi where possible * Update factories * Merge duplicated methods * Continue using private mode messager for now * Add static platform determination. * Break down methods and extract BrowserApi Concerns * Prefer strict equals * Init two-factor service in factory * Use globalThis types * Prefer `globalThis` * Use Window type definition updated with Opera Co-authored-by: Justin Baur <justindbaur@users.noreply.github.com> * Distinguish Opera from Safari Opera includes Gecko, Chrome, Safari, and Opera in its user agent. We need to make sure that we're not in Opera prior to testing Safari. * Update import * Initialize search-service for update badge context * Build all browser MV3 artifacts only uploading Chrome, Edge and Opera artifacts for now, as those support manifest V3 Also corrects build artifact to lower case. * Remove individual dist Co-authored-by: Justin Baur <justindbaur@users.noreply.github.com> Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
2022-10-19 15:55:57 +02:00
/**
* This is for firefox's sidebar action and it is based on the opera one but with a few less methods
*
* @link https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sidebarAction
*/
type FirefoxSidebarAction = typeof browser.sidebarAction;
Ps 1291 fix extension icon updates (#3571) * Add needed factories for AuthService WIP: Allow console logs * Add badge updates * Init by listener * Improve tab identification * Define MV3 background init * Init services in factories. Requires conversion of all factories to promises. We need to initialize in factory since the requester of a service doesn't necessarily know all dependencies for that service. The only alternative is to create an out parameter for a generated init function, which isn't ideal. * Improve badge setting * Use `update-badge` in mv2 and mv3 Separates menu and badge updates * Use update-badge everywhere * Use BrowserApi where possible * Update factories * Merge duplicated methods * Continue using private mode messager for now * Add static platform determination. * Break down methods and extract BrowserApi Concerns * Prefer strict equals * Init two-factor service in factory * Use globalThis types * Prefer `globalThis` * Use Window type definition updated with Opera Co-authored-by: Justin Baur <justindbaur@users.noreply.github.com> * Distinguish Opera from Safari Opera includes Gecko, Chrome, Safari, and Opera in its user agent. We need to make sure that we're not in Opera prior to testing Safari. * Update import * Initialize search-service for update badge context * Build all browser MV3 artifacts only uploading Chrome, Edge and Opera artifacts for now, as those support manifest V3 Also corrects build artifact to lower case. * Remove individual dist Co-authored-by: Justin Baur <justindbaur@users.noreply.github.com> Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
2022-10-19 15:55:57 +02:00
type Opera = {
addons: OperaAddons;
sidebarAction: OperaSidebarAction;
};
interface Window {
opr: Opera | undefined;
opera: unknown;
}
[PM-5880] Refactor browser platform utils service to remove `window` references (#7885) * [PM-5880] Refactor Browser Platform Utils Service to Remove Window Service * [PM-5880] Implementing BrowserClipboardService to handle clipboard logic between the BrowserPlatformUtils and offscreen document * [PM-5880] Adjusting how readText is handled within BrowserClipboardService * [PM-5880] Adjusting how readText is handled within BrowserClipboardService * [PM-5880] Working through implementation of chrome offscreen API usage * [PM-5880] Implementing jest tests for the methods added to the BrowserApi class * [PM-5880] Implementing jest tests for the OffscreenDocument class * [PM-5880] Working through jest tests for BrowserClipboardService * [PM-5880] Adding typing information to the clipboard methods present within the BrowserPlatformUtilsService * [PM-5880] Working on adding ServiceWorkerGlobalScope typing information * [PM-5880] Updating window references when calling BrowserPlatformUtils methods * [PM-5880] Finishing out jest tests for the BrowserClipboardService * [PM-5880] Finishing out jest tests for the BrowserClipboardService * [PM-5880] Implementing jest tests to validate the changes within BrowserApi * [PM-5880] Implementing jest tests to ensure coverage within OffscreenDocument * [PM-5880] Implementing jest tests for the BrowserPlatformUtilsService * [PM-5880] Removing unused catch statements * [PM-5880] Implementing jest tests for the BrowserPlatformUtilsService * [PM-5880] Implementing jest tests for the BrowserPlatformUtilsService * [PM-5880] Fixing broken tests
2024-03-06 17:33:38 +01:00
interface ServiceWorkerGlobalScope {
chrome?: typeof chrome;
opr?: Opera | undefined;
opera?: unknown;
}
declare let opr: Opera | undefined;
declare let opera: unknown | undefined;
2022-02-24 18:14:04 +01:00
declare let safari: any;