Skip to content

Commit 421cf43

Browse files
authored
Merge branch 'main' into inject-script-use-script-text
2 parents 8f220bc + a8379cb commit 421cf43

File tree

26 files changed

+1688
-2400
lines changed

26 files changed

+1688
-2400
lines changed

.github/workflows/update-browser-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- name: Commit Changes
3434
id: commit
35-
uses: stefanzweifel/git-auto-commit-action@v5
35+
uses: stefanzweifel/git-auto-commit-action@v6
3636
env:
3737
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3838
with:

.github/workflows/vhs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
path: 'docs/tapes/init-demo.tape'
3737

3838
- name: Save recorded GIF
39-
uses: stefanzweifel/git-auto-commit-action@v5
39+
uses: stefanzweifel/git-auto-commit-action@v6
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4242
with:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,5 @@ Anyone is welcome to submit a blog post on <https://wxt.dev/blog>!
182182
> [!NOTE]
183183
> Before starting on a blog post, please message Aaron on Discord or start a discussion on GitHub to get permission to write about a topic, but most topics are welcome: Major version updates, tutorials, etc.
184184
185-
- **English only**: Blog posts should be written in English. Unfortunately, our maintainers doesn't have the bandwidth right now to translate our docs, let alone blog posts. Sorry 😓
185+
- **English only**: Blog posts should be written in English. Unfortunately, our maintainers don't have the bandwidth right now to translate our docs, let alone blog posts. Sorry 😓
186186
- **AI**: Please only use AI to translate or proof-read your blog post. Don't generate the whole thing... We don't want to publish that.

docs/.vitepress/components/UsingWxtSection.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import useListExtensionDetails, {
44
ChromeExtension,
55
} from '../composables/useListExtensionDetails';
66
7-
// Add extension IDs here. Order doesn't matter, will be sorted by a combination of weekly active users and rating.
7+
// Add extension IDs to end of the list. On the website, extensions will be sorted by a combination of weekly active users and rating.
88
// Change the commit message or PR title to: "docs: Added "[extension name]" to the homepage"
99
const chromeExtensionIds = [
1010
'ocfdgncpifmegplaglcnglhioflaimkd', // GitHub: Better Line Counts
@@ -86,9 +86,18 @@ const chromeExtensionIds = [
8686
'cckggnbnimdbbpmdinkkgbbncopbloob', // WeChat Markdown Editor(微信 Markdown 编辑器)
8787
'jcblcjolcojmfopefcighfmkkefbaofg', // Tab Grab
8888
'eehmoikadcijkapfjocnhjclpbaindlb', // BrowserLens - https://browserlens.com/
89+
'hfhellofkjebbchcdffmicekjdomkcmc', // Epic Games Library Extension
90+
'gknigcbhlammoakmmdddkblknanpjiac', // Zen Analytics Pixel Tracker - zapt.web.app
91+
'cnklededohhcbmjjdlbjdkkihkgoggol', // Crypto Pulse - Compose your newtab with nature images, widgets & realtime Crypto Price & Bitcoin RSS.
92+
'miponnamafdenpgjemkknimgjfibicdc', // Youtube Video Scheduler
8993
'nhmbcmalgpkjbomhlhgdicanmkkaajmg', // Chatslator: Livestream Chat Translator
9094
'mbamjfdjbcdgpopfnkkmlohadbbnplhm', // 公众号阅读增强器 - https://wxreader.honwhy.wang
9195
'hannhecbnjnnbbafffmogdlnajpcomek', // 토탐정
96+
'ehboaofjncodknjkngdggmpdinhdoijp', // 2FAS Pass - https://2fas.com/
97+
'hnjamiaoicaepbkhdoknhhcedjdocpkd', // Quick Prompt - https://github.com/wenyuanw/quick-prompt
98+
'kacblhilkacgfnkjfodalohcnllcgmjd', // Add QR Code Generator Icon Back To Address Bar
99+
'fkbdlogfdjmpfepbbbjcgcfbgbcfcnne', // Piwik PRO Tracking Helper
100+
'nkbikckldmljjiiajklecmgmajgapbfl', // PIPX - Take Control of Picture-in-Picture, Automatically
92101
];
93102
94103
const { data, err, isLoading } = useListExtensionDetails(chromeExtensionIds);

docs/.vitepress/composables/useListExtensionDetails.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export default function (ids: string[]) {
3535
query,
3636
variables: { ids },
3737
}),
38+
headers: {
39+
'Content-Type': 'application/json',
40+
},
3841
})
3942
.then(async (res) => {
4043
isLoading.value = false;

docs/guide/essentials/config/entrypoint-loaders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WXT does several pre-processing steps to try and prevent errors during this proc
1010
2. Use `@webext-core/fake-browser` to create a fake version of the `chrome` and `browser` globals expected by extensions.
1111
3. Pre-process the JS/TS code, stripping out the `main` function then tree-shaking unused code from the file
1212

13-
However, this process is not perfect. It doesn't setup all the globals found in the browser and the APIs may behave differently. As such, **_you should avoid using browser or extension APIs outside the `main` function of your entrypoints!_**
13+
However, this process is not perfect. It doesn't setup all the globals found in the browser and the APIs may behave differently. As such, **_you should avoid using browser or extension APIs outside the `main` function of your entrypoints!_** See [Entrypoint Limitations](/guide/essentials/extension-apis#entrypoint-limitations) for more details.
1414

1515
:::tip
1616
If you're running into errors while importing entrypoints, run `wxt prepare --debug` to see more details about this process. When debugging, WXT will print out the pre-processed code to help you identify issues.

docs/guide/essentials/entrypoints.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,14 @@ When defining content script entrypoints, keep in mind that WXT will import this
300300

301301
<!-- prettier-ignore -->
302302
```ts
303-
browser.runtime.onMessage.addListener((message) => { // [!code --]
304-
// ... // [!code --]
305-
}); // [!code --]
303+
const container = document.createElement('div'); // [!code --]
304+
document.body.append(container); // [!code --]
306305

307-
export default defineBackground(() => {
308-
browser.runtime.onMessage.addListener((message) => { // [!code ++]
309-
// ... // [!code ++]
310-
}); // [!code ++]
306+
export default defineContentScript({
307+
main: function () {
308+
const container = document.createElement('div'); // [!code ++]
309+
document.body.append(container); // [!code ++]
310+
},
311311
});
312312
```
313313

docs/guide/essentials/es-modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ES Modules
22

3-
You source code should always be written as ESM. However, you have some control whether an entrypoint is bundled as ESM.
3+
Your source code should always be written as ESM. However, you have some control whether an entrypoint is bundled as ESM.
44

55
## HTML Pages <Badge type="warning" text="≥0.0.1" />
66

docs/guide/essentials/extension-apis.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,63 @@ Alternatively, if you're trying to use similar APIs under different names (to su
7575
//
7676
});
7777
```
78+
79+
## Entrypoint Limitations
80+
81+
Because WXT imports your entrypoint files into a NodeJS, non-extension environment, the `chrome`/`browser` variables provided to extensions by the browser **will not be available**.
82+
83+
To prevent some basic errors, WXT polyfills these globals with the same in-memory, fake implementation it uses for testing: [`@webext-core/fake-browser`](https://webext-core.aklinker1.io/fake-browser/installation/). However, not all the APIs have been implemented.
84+
85+
So it is extremely important to NEVER use `browser.*` extension APIs outside the main function of any JS/TS entrypoints (background, content scripts, and unlisted scripts). If you do, you'll see an error like this:
86+
87+
```plaintext
88+
✖ Command failed after 440 ms
89+
90+
ERROR Browser.action.onClicked.addListener not implemented.
91+
```
92+
93+
The fix is simple, just move your API usage into the entrypoint's main function:
94+
95+
:::code-group
96+
97+
```ts [background.ts]
98+
browser.action.onClicked.addListener(() => {
99+
/* ... */
100+
}); // [!code --]
101+
102+
export default defineBackground(() => {
103+
browser.action.onClicked.addListener(() => {
104+
/* ... */
105+
}); // [!code ++]
106+
});
107+
```
108+
109+
```ts [content.ts]
110+
browser.runtime.onMessage.addListener(() => {
111+
/* ... */
112+
}); // [!code --]
113+
114+
export default defineContentScript({
115+
main() {
116+
browser.runtime.onMessage.addListener(() => {
117+
/* ... */
118+
}); // [!code ++]
119+
},
120+
});
121+
```
122+
123+
```ts [unlisted.ts]
124+
browser.runtime.onMessage.addListener(() => {
125+
/* ... */
126+
}); // [!code --]
127+
128+
export default defineUnlistedScript(() => {
129+
browser.runtime.onMessage.addListener(() => {
130+
/* ... */
131+
}); // [!code ++]
132+
});
133+
```
134+
135+
:::
136+
137+
Read [Entrypoint Loaders](/guide/essentials/config/entrypoint-loaders) for more technical details about this limitation.

packages/auto-icons/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
## Features
66

77
- Generate extension icons with the correct sizes
8-
- Make the icon greyscale during development
8+
- Make the icon greyscale or include a visible overlay during development
9+
- SVG is supported
910

1011
## Usage
1112

0 commit comments

Comments
 (0)