@@ -6,16 +6,26 @@ Documentation:
66- [ Opera Sidebar Action API] ( https://help.opera.com/en/extensions/sidebar-action-api/ )
77- [ Firefox Sidebar Action API] ( https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sidebarAction )
88
9- A promise-based wrapper around Chrome's side panel (` chrome.sidePanel ` , MV3) and Firefox/Opera ` sidebarAction ` APIs. Methods provide unified behavior to get/set options and behavior, open the panel, and, where supported, manage title and icon (Firefox & Opera) and badge (Opera).
9+ A promise-based wrapper around Chromium's side panel (` chrome.sidePanel ` , MV3) and Firefox/Opera ` sidebarAction ` APIs. Methods provide unified behavior to get/set options and behavior, open the panel, and, where supported, manage title and icon (Firefox & Opera) and badge (Opera). Support includes Chrome, Edge, Firefox, and Opera.
10+
11+ ## Classes
12+
13+ ### SidebarError
14+
15+ Custom error class thrown when an API method is not supported or fails.
1016
1117## Methods
1218
13- - [ getSidebarOptions(tabId?)] ( #getSidebarOptions )
14- - [ getSidebarBehavior()] ( #getSidebarBehavior )
19+ - [ getSidebarOptions(tabId?)] ( #getSidebarOptions ) [ Chromium ]
20+ - [ getSidebarBehavior()] ( #getSidebarBehavior ) [ Chromium ]
1521- [ canOpenSidebar()] ( #canOpenSidebar )
22+ - [ canCloseSidebar()] ( #canCloseSidebar )
1623- [ openSidebar(options)] ( #openSidebar )
17- - [ setSidebarOptions(options?)] ( #setSidebarOptions )
18- - [ setSidebarBehavior(behavior?)] ( #setSidebarBehavior )
24+ - [ closeSidebar(options)] ( #closeSidebar )
25+ - [ setSidebarOptions(options?)] ( #setSidebarOptions ) [ Chromium]
26+ - [ setSidebarBehavior(behavior?)] ( #setSidebarBehavior ) [ Chromium]
27+ - [ isOpenSidebar(windowId?)] ( #isOpenSidebar )
28+ - [ toggleSidebar()] ( #toggleSidebar ) [ Firefox]
1929- [ setSidebarPath(path, tabId?)] ( #setSidebarPath )
2030- [ getSidebarPath(tabId?)] ( #getSidebarPath )
2131- [ setSidebarTitle(title, tabId?)] ( #setSidebarTitle ) [ Firefox, Opera]
@@ -33,23 +43,23 @@ A promise-based wrapper around Chrome's side panel (`chrome.sidePanel`, MV3) and
3343
3444<a name =" getSidebarOptions " ></a >
3545
36- ### getSidebarOptions
46+ ### getSidebarOptions [ Chromium ]
3747
3848```
3949getSidebarOptions(tabId?: number): Promise<chrome.sidePanel.PanelOptions>
4050```
4151
42- Retrieves the side panel options (e.g., ` path ` ) for the specified tab. Throws if the Side Panel API isn't supported. [ MV3]
52+ Retrieves the side panel options (e.g., ` path ` ) for the specified tab. Throws if the Side Panel API isn't supported (requires Chromium-based browsers like Chrome, Edge, or Opera MV3) . [ MV3]
4353
4454<a name =" getSidebarBehavior " ></a >
4555
46- ### getSidebarBehavior
56+ ### getSidebarBehavior [ Chromium ]
4757
4858```
4959getSidebarBehavior(): Promise<chrome.sidePanel.PanelBehavior>
5060```
5161
52- Gets the current side panel behavior settings. Throws if unsupported. [ MV3]
62+ Gets the current side panel behavior settings. Throws if unsupported (requires Chromium-based browsers like Chrome, Edge, or Opera MV3) . [ MV3]
5363
5464<a name =" canOpenSidebar " ></a >
5565
@@ -59,7 +69,17 @@ Gets the current side panel behavior settings. Throws if unsupported. [MV3]
5969canOpenSidebar(): boolean
6070```
6171
62- Returns ` true ` if ` chrome.sidePanel ` (MV3) is available, or if ` browser.sidebarAction.open ` is available (Firefox).
72+ Returns ` true ` if ` chrome.sidePanel ` (Chromium MV3) is available, or if ` sidebarAction.open ` is available (Firefox/Opera).
73+
74+ <a name =" canCloseSidebar " ></a >
75+
76+ ### canCloseSidebar
77+
78+ ```
79+ canCloseSidebar(): boolean
80+ ```
81+
82+ Returns ` true ` if ` chrome.sidePanel ` (Chromium MV3) is available, or if ` sidebarAction.close ` is available (Firefox/Opera).
6383
6484<a name =" openSidebar " ></a >
6585
@@ -69,27 +89,37 @@ Returns `true` if `chrome.sidePanel` (MV3) is available, or if `browser.sidebarA
6989openSidebar(options: chrome.sidePanel.OpenOptions): Promise<void>
7090```
7191
72- Opens the side panel with the given options in Chrome (MV3). Falls back to ` browser.sidebarAction.open() ` in Firefox. Logs a warning and resolves as a no-op if unsupported.
92+ Opens the side panel with the given options in Chromium-based browsers (MV3). Falls back to ` sidebarAction.open() ` in Firefox/Opera. Throws if unsupported.
93+
94+ <a name =" closeSidebar " ></a >
95+
96+ ### closeSidebar
97+
98+ ```
99+ closeSidebar(options: chrome.sidePanel.CloseOptions): Promise<void>
100+ ```
101+
102+ Closes the side panel with the given options in Chromium-based browsers (MV3). Falls back to ` sidebarAction.close() ` in Firefox/Opera. Throws if unsupported.
73103
74104<a name =" setSidebarOptions " ></a >
75105
76- ### setSidebarOptions
106+ ### setSidebarOptions [ Chromium ]
77107
78108```
79109setSidebarOptions(options?: chrome.sidePanel.PanelOptions): Promise<void>
80110```
81111
82- Sets side panel options (e.g., ` path ` ) in Chrome (MV3). Logs a warning and resolves as a no-op if unsupported. [ MV3]
112+ Sets side panel options (e.g., ` path ` ) in Chromium-based browsers (MV3). Throws if unsupported. [ MV3]
83113
84114<a name =" setSidebarBehavior " ></a >
85115
86- ### setSidebarBehavior
116+ ### setSidebarBehavior [ Chromium ]
87117
88118```
89119setSidebarBehavior(behavior?: chrome.sidePanel.PanelBehavior): Promise<void>
90120```
91121
92- Updates default panel behavior in Chrome (MV3). Logs a warning and resolves as a no-op if unsupported. [ MV3]
122+ Updates default panel behavior in Chromium-based browsers (MV3). Throws if unsupported. [ MV3]
93123
94124<a name =" setSidebarPath " ></a >
95125
@@ -99,7 +129,7 @@ Updates default panel behavior in Chrome (MV3). Logs a warning and resolves as a
99129setSidebarPath(path: string, tabId?: number): Promise<void>
100130```
101131
102- Sets the sidebar path in Chrome via ` setOptions ` (MV3) or via ` sidebarAction.setPanel() ` in Firefox/Opera. Throws if unsupported.
132+ Sets the sidebar path in Chromium-based browsers via ` setOptions ` (MV3) or via ` sidebarAction.setPanel() ` in Firefox/Opera. Throws if unsupported.
103133
104134<a name =" getSidebarPath " ></a >
105135
@@ -109,7 +139,27 @@ Sets the sidebar path in Chrome via `setOptions` (MV3) or via `sidebarAction.set
109139getSidebarPath(tabId?: number): Promise<string | undefined>
110140```
111141
112- Retrieves the sidebar path from Chrome (MV3) or parses from ` sidebarAction.getPanel() ` in Firefox/Opera. Throws if unsupported.
142+ Retrieves the sidebar path from Chromium-based browsers (MV3) or parses from ` sidebarAction.getPanel() ` in Firefox/Opera. Throws if unsupported.
143+
144+ <a name =" isOpenSidebar " ></a >
145+
146+ ### isOpenSidebar
147+
148+ ```
149+ isOpenSidebar(windowId?: number): Promise<boolean>
150+ ```
151+
152+ Checks if the sidebar is open for the given window in Chromium-based browsers (MV3) using ` getContexts ` and in Firefox/Opera using ` sidebarAction.isOpen() ` . Throws if unsupported.
153+
154+ <a name =" toggleSidebar " ></a >
155+
156+ ### toggleSidebar [ Firefox]
157+
158+ ```
159+ toggleSidebar(): Promise<void>
160+ ```
161+
162+ Toggles the sidebar in Firefox. Throws if unsupported.
113163
114164<a name =" setSidebarTitle " ></a >
115165
@@ -119,7 +169,7 @@ Retrieves the sidebar path from Chrome (MV3) or parses from `sidebarAction.getPa
119169setSidebarTitle(title: string | number, tabId?: number): Promise<void>
120170```
121171
122- Sets the sidebar title via ` sidebarAction.setTitle() ` (Firefox/Opera). Logs a warning if unsupported.
172+ Sets the sidebar title via ` sidebarAction.setTitle() ` (Firefox/Opera). Throws if unsupported.
123173
124174<a name =" setSidebarIcon " ></a >
125175
@@ -129,7 +179,7 @@ Sets the sidebar title via `sidebarAction.setTitle()` (Firefox/Opera). Logs a wa
129179setSidebarIcon(details: opr.sidebarAction.IconDetails): Promise<void>
130180```
131181
132- Sets the sidebar icon via ` sidebarAction.setIcon() ` (Firefox/Opera). Logs a warning if unsupported.
182+ Sets the sidebar icon via ` sidebarAction.setIcon() ` (Firefox/Opera). Throws if unsupported.
133183
134184> Known issue (Opera): The ` opr.sidebarAction.setIcon ` API is currently broken and may fail with "Access to extension API denied".
135185> See: https://forums.opera.com/topic/75680/opr-sidebaraction-seticon-api-is-broken-access-to-extension-api-denied
@@ -142,7 +192,7 @@ Sets the sidebar icon via `sidebarAction.setIcon()` (Firefox/Opera). Logs a warn
142192setSidebarBadgeText(text: string | number, tabId?: number): Promise<void>
143193```
144194
145- Sets the sidebar badge text via ` opr.sidebarAction.setBadgeText() ` (Opera only). Logs a warning if unsupported.
195+ Sets the sidebar badge text via ` opr.sidebarAction.setBadgeText() ` (Opera only). Throws if unsupported.
146196
147197<a name =" clearSidebarBadgeText " ></a >
148198
@@ -162,7 +212,7 @@ Clears the sidebar badge text (equivalent to setting an empty string) via `opr.s
162212setSidebarBadgeTextColor(color: string | [number, number, number, number], tabId?: number): Promise<void>
163213```
164214
165- Sets the sidebar badge text color via ` opr.sidebarAction.setBadgeTextColor() ` (Opera only). Logs a warning if unsupported.
215+ Sets the sidebar badge text color via ` opr.sidebarAction.setBadgeTextColor() ` (Opera only). Throws if unsupported.
166216
167217<a name =" setSidebarBadgeBgColor " ></a >
168218
@@ -172,7 +222,7 @@ Sets the sidebar badge text color via `opr.sidebarAction.setBadgeTextColor()` (O
172222setSidebarBadgeBgColor(color: string | [number, number, number, number], tabId?: number): Promise<void>
173223```
174224
175- Sets the sidebar badge background color via ` opr.sidebarAction.setBadgeBackgroundColor() ` (Opera only). Logs a warning if unsupported.
225+ Sets the sidebar badge background color via ` opr.sidebarAction.setBadgeBackgroundColor() ` (Opera only). Throws if unsupported.
176226
177227<a name =" getSidebarTitle " ></a >
178228
0 commit comments