Skip to content

Commit 73ee7c2

Browse files
authored
chore: merge pull request #15 from addon-stack/develop
2 parents 53c096b + 654275d commit 73ee7c2

File tree

5 files changed

+184
-59
lines changed

5 files changed

+184
-59
lines changed

biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"includes": [
2626
"src/**/*.{ts,tsx,js,jsx}",
2727
"**/*.{json,jsonc,md,mdx,cjs,mjs}",
28-
"!dist/**/*"
28+
"!dist/**/*",
29+
"!addon/**/*"
2930
]
3031
},
3132
"formatter": {

docs/sidebar.md

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
```
3949
getSidebarOptions(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
```
4959
getSidebarBehavior(): 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]
5969
canOpenSidebar(): 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
6989
openSidebar(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
```
79109
setSidebarOptions(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
```
89119
setSidebarBehavior(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
99129
setSidebarPath(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
109139
getSidebarPath(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
119169
setSidebarTitle(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
129179
setSidebarIcon(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
142192
setSidebarBadgeText(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
162212
setSidebarBadgeTextColor(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
172222
setSidebarBadgeBgColor(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

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"@commitlint/cli": "^20.0.0",
6363
"@commitlint/config-conventional": "^20.0.0",
6464
"@release-it/conventional-changelog": "^10.0.1",
65-
"@types/chrome": "^0.1.12",
65+
"@types/chrome": "^0.1.36",
6666
"@types/jest": "^30.0.0",
6767
"husky": "^9.1.7",
6868
"jest": "^30.1.3",

0 commit comments

Comments
 (0)