Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 12805e9862 | |||
| d889a21465 | |||
| 8125d74057 | |||
| c39087a81a | |||
| 7b849b80cb | |||
| b98a5c378e | |||
| 215def7e15 | |||
| 3b954cc6fb | |||
| 20bdd8ad2f | |||
| cb9a9c0530 | |||
| 48d8d236c0 | |||
| 87d9511b31 | |||
| 5d8efef02f | |||
| c9008cd835 | |||
| 203a9cc234 | |||
| 5fcaf7c68b | |||
| c74e530d4a | |||
| 3f78be0c95 | |||
| 2a3d52045d | |||
| ea5b81d25e | |||
| cec9d7103a | |||
| 34dd2c1487 | |||
| a5667f85d0 | |||
| ec3dd52f83 | |||
| 87ebde3abb | |||
| dc5b55bffb | |||
| df20993917 | |||
| caa0fb31e6 |
@@ -1,50 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report an issue with WXT
|
||||
title: ''
|
||||
labels: triage
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
### Describe the bug
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
### To Reproduce
|
||||
|
||||
Share minimal reproduction. Examples of a minimal reproduction:
|
||||
|
||||
- PR with a failing test case
|
||||
- ZIP file containing a minimal WXT project (be sure to include your lockfile!!)
|
||||
|
||||
> **_⚠️ If you don't upload a minimal reproduction, your issue will be closed until a reproduction is added._**
|
||||
>
|
||||
> Why? https://antfu.me/posts/why-reproductions-are-required
|
||||
|
||||
Steps to reproduce the bug using the reproduction:
|
||||
|
||||
1. Install dependencies: `pnpm i`
|
||||
2. Start dev mode: `pnpm dev`
|
||||
3. Click this...
|
||||
4. Do that...
|
||||
5. Etc...
|
||||
|
||||
### Expected behavior
|
||||
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
### Screenshots
|
||||
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
### Environment
|
||||
|
||||
<!--- Run `npx envinfo --system --browsers --binaries --npmPackages wxt,vite` and paste the output below -->
|
||||
|
||||
```
|
||||
Paste output here
|
||||
```
|
||||
|
||||
### Additional context
|
||||
|
||||
Add any other context about the problem here, otherwise you can delete this section.
|
||||
@@ -0,0 +1,74 @@
|
||||
name: "\U0001F41E Bug report"
|
||||
description: Report an issue with WXT
|
||||
labels: [pending-triage]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
- type: textarea
|
||||
id: bug-description
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks!
|
||||
placeholder: I am doing ... What I expect is ... What actually happening is ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Reproduction
|
||||
description: |
|
||||
Please provide a minimal reproduction. This can include:
|
||||
|
||||
- A PR with a failing test case
|
||||
- A link to a github repo
|
||||
- A ZIP you upload to this issue
|
||||
|
||||
A [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) is required ([Why?](https://antfu.me/posts/why-reproductions-are-required)). If a report is vague (e.g. just a generic error message) and has no reproduction or a partial reproduction, it will be closed immediately and labeled with as "needs-reproduction". Once a reproduction is provided, it will be re-opened.
|
||||
placeholder: Reproduction URL or attach a ZIP
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduction-steps
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Please provide any reproduction steps that may need to be described. E.g. if it happens only when running the dev or build script make sure it's clear which one to use.
|
||||
placeholder: Run `npm install` followed by `npm run dev`
|
||||
- type: textarea
|
||||
id: system-info
|
||||
attributes:
|
||||
label: System Info
|
||||
description: Output of `npx envinfo --system --browsers --binaries --npmPackages wxt,vite`
|
||||
render: shell
|
||||
placeholder: System, Binaries, Browsers
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: package-manager
|
||||
attributes:
|
||||
label: Used Package Manager
|
||||
description: Select the used package manager
|
||||
options:
|
||||
- npm
|
||||
- yarn
|
||||
- pnpm
|
||||
- bun
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: checkboxes
|
||||
attributes:
|
||||
label: Validations
|
||||
description: Before submitting the issue, please make sure you do the following
|
||||
options:
|
||||
- label: Read the [Contributing Guidelines](https://github.com/wxt-dev/wxt/blob/main/CONTRIBUTING.md).
|
||||
required: true
|
||||
- label: Read the [docs](https://wxt.dev/guide/installation.html).
|
||||
required: true
|
||||
- label: Check that there isn't [already an issue](https://github.com/wxt-dev/wxt/issues) that reports the same bug to avoid creating a duplicate.
|
||||
required: true
|
||||
- label: Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/wxt-dev/wxt/discussions) or join our [Discord Chat Server](https://discord.gg/ZFsZqGery9).
|
||||
required: true
|
||||
- label: The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
|
||||
required: true
|
||||
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Discord Chat
|
||||
url: https://discord.gg/ZFsZqGery9
|
||||
about: Ask questions and discuss with other WXT users in real time.
|
||||
- name: Questions & Discussions
|
||||
url: https://github.com/wxt-dev/wxt/discussions
|
||||
about: Use GitHub discussions for message-board style questions and discussions.
|
||||
@@ -5,7 +5,7 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- CHANGELOG.md
|
||||
- packages/wxt/CHANGELOG.md
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
@@ -20,3 +20,4 @@ jobs:
|
||||
node-version: 18
|
||||
cache: pnpm
|
||||
- run: pnpm sync-releases all --token ${{ secrets.GITHUB_TOKEN }}
|
||||
working-directory: packages/wxt
|
||||
|
||||
+4
-4
@@ -37,13 +37,13 @@ pnpm build
|
||||
|
||||
```sh
|
||||
# Build WXT package, then build demo extension
|
||||
cd demo
|
||||
cd packages/wxt-demo
|
||||
pnpm build
|
||||
```
|
||||
|
||||
```sh
|
||||
# Build WXT package, then start the demo extension in dev mode
|
||||
cd demo
|
||||
cd packages/wxt-demo
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
@@ -75,7 +75,7 @@ To run tests for a specific file, add the filename at the end of the test comman
|
||||
pnpm test manifest-contents
|
||||
```
|
||||
|
||||
Unit and E2E tests are ran together via [Vitest workspaces](https://vitest.dev/guide/#workspaces-support).
|
||||
All test (unit and E2E) for all packages are ran together via [Vitest workspaces](https://vitest.dev/guide/#workspaces-support).
|
||||
|
||||
If you want to manually test a change, you can modify the demo project for your test, but please don't leave those changes committed once you open a PR.
|
||||
|
||||
@@ -90,7 +90,7 @@ npm run dev
|
||||
npm run build
|
||||
```
|
||||
|
||||
Note that templates are hardcoded to a specific version of `wxt` from NPM, they do not use the local version. PR checks will test your changes against the templates, but if you want to manually do it, update the package.json dependency:
|
||||
Note that templates are hardcoded to a specific version of `wxt` from NPM, they do not use the local version. PR checks will test your PR's changes against the templates, but if you want to manually do it, update the package.json dependency:
|
||||
|
||||
```diff
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<h1 align="center">
|
||||
<img style="vertical-align:middle" width="44" src="./docs/public/hero-logo.svg" alt="WXT Logo">
|
||||
<span>WXT</span>
|
||||
</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/wxt" target="_blank"><img alt="npm" src="https://img.shields.io/npm/v/wxt?labelColor=black&color=%234fa048"></a>
|
||||
<span> </span>
|
||||
<a href="https://www.npmjs.com/package/wxt" target="_blank"><img alt="npm" src="https://img.shields.io/npm/dm/wxt?labelColor=black&color=%234fa048"></a>
|
||||
<span> </span>
|
||||
<a href="https://github.com/wxt-dev/wxt/blob/main/LICENSE" target="_blank"><img alt="NPM" src="https://img.shields.io/npm/l/wxt?labelColor=black&color=%234fa048"></a>
|
||||
<span> </span>
|
||||
<a href="https://codecov.io/github/wxt-dev/wxt" target="_blank"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/wxt-dev/wxt?labelColor=black&color=%234fa048"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<span>Next-gen framework for developing web extensions.</span>
|
||||
<br/>
|
||||
<span>⚡</span>
|
||||
<br/>
|
||||
<q><i>It's like Nuxt, but for Chrome Extensions</i></q>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://wxt.dev" target="_blank">Get Started</a>
|
||||
•
|
||||
<a href="https://wxt.dev/guide/installation.html" target="_blank">Installation</a>
|
||||
•
|
||||
<a href="https://wxt.dev/api/config.html" target="_blank">Configuration</a>
|
||||
•
|
||||
<a href="https://wxt.dev/examples.html" target="_blank">Examples</a>
|
||||
•
|
||||
<a href="https://discord.gg/ZFsZqGery9" target="_blank">Discord</a>
|
||||
</p>
|
||||
|
||||

|
||||
|
||||
## Demo
|
||||
|
||||
https://github.com/wxt-dev/wxt/assets/10101283/4d678939-1bdb-495c-9c36-3aa281d84c94
|
||||
|
||||
## Quick Start
|
||||
|
||||
Bootstrap a new project:
|
||||
|
||||
```sh
|
||||
pnpm dlx wxt@latest init <project-name>
|
||||
```
|
||||
|
||||
Or see the [installation guide](https://wxt.dev/guide/installation.html) to get started with WXT.
|
||||
|
||||
## Features
|
||||
|
||||
- 🌐 Supports all browsers
|
||||
- ✅ Supports both MV2 and MV3
|
||||
- ⚡ Dev mode with HMR & fast reload
|
||||
- 📂 File based entrypoints
|
||||
- 🚔 TypeScript
|
||||
- 🦾 Auto-imports
|
||||
- 🤖 Automated publishing
|
||||
- 🎨 Frontend framework agnostic: works with Vue, React, Svelte, etc
|
||||
- 🖍️ Quickly bootstrap a new project
|
||||
- 📏 Bundle analysis
|
||||
- ⬇️ Download and bundle remote URL imports
|
||||
|
||||
## Contributors
|
||||
|
||||
<a href="https://github.com/wxt-dev/wxt/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=wxt-dev/wxt" />
|
||||
</a>
|
||||
@@ -26,6 +26,7 @@ const chromeExtensionIds = [
|
||||
'nhclljcpfmmaiojbhhnkpjcfmacfcian', // Facebook Video Controls
|
||||
'mblkhbaakhbhiimkbcnmeciblfhmafna', // ElemSnap - Quick capture of webpage elements and conversion to images,
|
||||
'oajalfneblkfiejoadecnmodfpnaeblh', // MS Edge TTS (Text to Speech)
|
||||
'nedcanggplmbbgmlpcjiafgjcpdimpea', // YTBlock - Block any content from YouTube™
|
||||
];
|
||||
|
||||
const { data, err, isLoading } = useListExtensionDetails(chromeExtensionIds);
|
||||
|
||||
@@ -388,14 +388,14 @@ WXT provides a helper function, [`createIframeUi`](/api/wxt/client/functions/cre
|
||||
export default defineContentScript({
|
||||
matches: ['<all_urls>'],
|
||||
|
||||
async main(ctx) {
|
||||
main(ctx) {
|
||||
// Define the UI
|
||||
const ui = await createIframeUi(ctx, {
|
||||
const ui = createIframeUi(ctx, {
|
||||
page: '/example-iframe.html',
|
||||
position: 'inline',
|
||||
onMount: (wrapper, iframe) => {
|
||||
// Add styles to the iframe like width
|
||||
iframe.width = 123;
|
||||
iframe.width = '123';
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ To validate this, you can create a third ZIP file with a rare permission like `g
|
||||
You can setup a callback that runs after your extension updates like so:
|
||||
|
||||
```ts
|
||||
browser.runtime.onInstalled.addEventListener(({ reason }) => {
|
||||
browser.runtime.onInstalled.addListener(({ reason }) => {
|
||||
if (reason === 'update') {
|
||||
// Do something
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Remote Code
|
||||
|
||||
WXT will automatically download and bundle imports with the `url:` prefix so the extension does not depend of remote code, [a requirement from Google for MV3](https://developer.chrome.com/docs/extensions/migrating/improve-security/#remove-remote-code).
|
||||
WXT will automatically download and bundle imports with the `url:` prefix so the extension does not depend on remote code, [a requirement from Google for MV3](https://developer.chrome.com/docs/extensions/migrating/improve-security/#remove-remote-code).
|
||||
|
||||
## Google Analytics
|
||||
|
||||
For example, you can import google analytics:
|
||||
For example, you can import Google Analytics:
|
||||
|
||||
```ts
|
||||
// utils/google-analytics.ts
|
||||
|
||||
@@ -22,4 +22,4 @@ If you want to try to use a different framework for unit tests, you will need to
|
||||
- **Global Variables**: If you consume them, manually define globals provided by WXT (like `import.meta.env.BROWSER`) by adding them to the global scope before accessing them (`import.meta.env.BROWSER = "chrome"`)
|
||||
- **Import paths**: If you use the `@/` or `~/` path aliases, add them to your test environment
|
||||
|
||||
[Here's how Vitest is configured](https://github.com/wxt-dev/wxt/blob/main/src/testing/wxt-vitest-plugin.ts) for reference.
|
||||
[Here's how Vitest is configured](https://github.com/wxt-dev/wxt/blob/main/packages/wxt/src/testing/wxt-vitest-plugin.ts) for reference.
|
||||
|
||||
+1
-7
@@ -15,8 +15,7 @@
|
||||
"docs:gen": "typedoc --options docs/typedoc.json",
|
||||
"docs:dev": "pnpm -s docs:gen && vitepress dev docs",
|
||||
"docs:build": "pnpm -s docs:gen && vitepress build docs",
|
||||
"docs:preview": "pnpm -s docs:gen && vitepress preview docs",
|
||||
"sync-releases": "pnpx changelogen@latest gh release"
|
||||
"docs:preview": "pnpm -s docs:gen && vitepress preview docs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@aklinker1/check": "^1.1.1",
|
||||
@@ -44,11 +43,6 @@
|
||||
"lint-staged": {
|
||||
"*": "prettier --ignore-unknown --write"
|
||||
},
|
||||
"changelog": {
|
||||
"excludeAuthors": [
|
||||
"aaronklinker1@gmail.com"
|
||||
]
|
||||
},
|
||||
"pnpm": {
|
||||
"peerDependencyRules": {
|
||||
"ignoreMissing": [
|
||||
|
||||
+155
-67
@@ -1,5 +1,91 @@
|
||||
# Changelog
|
||||
|
||||
## v0.18.4
|
||||
|
||||
[compare changes](https://github.com/wxt-dev/wxt/compare/v0.18.3...v0.18.4)
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- Allow zipping hidden files in sources by listing them explicitly in `includeSources` ([#674](https://github.com/wxt-dev/wxt/pull/674))
|
||||
- Properly invalidate content script context ([#683](https://github.com/wxt-dev/wxt/pull/683))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
- Update contributing guidelines ([8125d74](https://github.com/wxt-dev/wxt/commit/8125d74))
|
||||
|
||||
### ❤️ Contributors
|
||||
|
||||
- Hujiulong ([@hujiulong](http://github.com/hujiulong))
|
||||
|
||||
## v0.18.3
|
||||
|
||||
[compare changes](https://github.com/wxt-dev/wxt/compare/v0.18.2...v0.18.3)
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- Automatically add dev server to sandbox CSP ([#663](https://github.com/wxt-dev/wxt/pull/663))
|
||||
- Remove `import * as` imports from entrypoints during build ([#671](https://github.com/wxt-dev/wxt/pull/671))
|
||||
- **security:** Upgrade tar to 6.2.1 ([215def7](https://github.com/wxt-dev/wxt/commit/215def7))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
- Add YTBlock to homepage ([#666](https://github.com/wxt-dev/wxt/pull/666))
|
||||
|
||||
### 🏡 Chore
|
||||
|
||||
- Add missing tests for dev mode CSP ([#662](https://github.com/wxt-dev/wxt/pull/662))
|
||||
- Upgrade templates to v0.18 ([3b954cc](https://github.com/wxt-dev/wxt/commit/3b954cc))
|
||||
|
||||
### 🤖 CI
|
||||
|
||||
- Fix sync-releases workflow trigger ([5d8efef](https://github.com/wxt-dev/wxt/commit/5d8efef))
|
||||
|
||||
### ❤️ Contributors
|
||||
|
||||
- Edoan ([@EdoanR](http://github.com/EdoanR))
|
||||
|
||||
## v0.18.2
|
||||
|
||||
[compare changes](https://github.com/wxt-dev/wxt/compare/v0.18.1...v0.18.2)
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- **runner:** Add `keepProfileChanges` option ([#655](https://github.com/wxt-dev/wxt/pull/655))
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- Automatically detect and add "sidePanel" permission ([5fcaf7c](https://github.com/wxt-dev/wxt/commit/5fcaf7c))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
- Fix `wxt-vitest-plugin` reference ([#650](https://github.com/wxt-dev/wxt/pull/650))
|
||||
- Fix spelling mistake in remote-code.md ([#652](https://github.com/wxt-dev/wxt/pull/652))
|
||||
- Correct event handler name in handling-updates.md ([#653](https://github.com/wxt-dev/wxt/pull/653))
|
||||
- Fix iframe typos ([c74e530](https://github.com/wxt-dev/wxt/commit/c74e530))
|
||||
|
||||
### ❤️ Contributors
|
||||
|
||||
- Edoan ([@EdoanR](http://github.com/EdoanR))
|
||||
- Linus Norton ([@linusnorton](http://github.com/linusnorton))
|
||||
- Jeffrey Zang ([@jeffrey-zang](http://github.com/jeffrey-zang))
|
||||
- Emmanuel Ferdman ([@emmanuel-ferdman](https://github.com/emmanuel-ferdman))
|
||||
|
||||
## v0.18.1
|
||||
|
||||
[compare changes](https://github.com/wxt-dev/wxt/compare/v0.18.0...v0.18.1)
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- `_background` is not defined ([#649](https://github.com/wxt-dev/wxt/pull/649))
|
||||
|
||||
### 🏡 Chore
|
||||
|
||||
- Add root README back ([ec3dd52](https://github.com/wxt-dev/wxt/commit/ec3dd52))
|
||||
|
||||
### 🤖 CI
|
||||
|
||||
- Fix sync releases workflow ([dc5b55b](https://github.com/wxt-dev/wxt/commit/dc5b55b))
|
||||
|
||||
## v0.18.0
|
||||
|
||||
[compare changes](https://github.com/wxt-dev/wxt/compare/v0.17.12...v0.18.0)
|
||||
@@ -12,7 +98,7 @@
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- ⚠️ Automatically move `host_permissions` to `permissions` for MV2 ([#626](https://github.com/wxt-dev/wxt/pull/626))
|
||||
- ⚠️ Automatically move `host_permissions` to `permissions` for MV2 ([#626](https://github.com/wxt-dev/wxt/pull/626))
|
||||
- **dep:** Upgrade `@webext-core/isolated-element` to v1.1.2 ([#625](https://github.com/wxt-dev/wxt/pull/625))
|
||||
|
||||
### 📖 Documentation
|
||||
@@ -39,18 +125,19 @@
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
- ⚠️ Automatically move `host_permissions` to `permissions` for MV2 ([#626](https://github.com/wxt-dev/wxt/pull/626))
|
||||
- ⚠️ Automatically move `host_permissions` to `permissions` for MV2 ([#626](https://github.com/wxt-dev/wxt/pull/626))
|
||||
|
||||
Out of an abundance of caution, I've marked this as a breaking change because permission generation has changed. **_If you list `host_permissions` in your `wxt.config.ts`'s manifest and have released your extension_**, double check that your `permissions` and `host_permissions` have not changed for all browsers you target in your `.output/*/manifest.json` files. Permission changes can cause the extension to be disabled on update, and can cause a drop in users, so be sure to double check for differences compared to the previous manifest version.
|
||||
|
||||
### ❤️ Contributors
|
||||
|
||||
- Aaron <aaronklinker1@gmail.com>
|
||||
- Alegal200 <alex.gallez11@gmail.com>
|
||||
- Alegal200 ([@alegal200](https://github.com/alegal200))
|
||||
- Yacine-bens ([@yacine-bens](http://github.com/yacine-bens))
|
||||
- Ayden <itxcc420@gmail.com>
|
||||
- Ayden ([@AydenGen](https://github.com/AydenGen))
|
||||
- Wuzequanyouzi ([@wuzequanyouzi](http://github.com/wuzequanyouzi))
|
||||
- Can Rau ([@CanRau](http://github.com/CanRau))
|
||||
- 日高 凌 ([@ryohidaka](http://github.com/ryohidaka))
|
||||
- Bas Van Zanten <bas.van.zanten007@gmail.com>
|
||||
- Bas Van Zanten ([@Bas950](http://github.com/Bas950))
|
||||
- ThinkStu ([@Bistutu](http://github.com/Bistutu))
|
||||
|
||||
## v0.17.12
|
||||
@@ -312,11 +399,11 @@
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- **storage:** ⚠️ Improved support for default values on storage items ([#477](https://github.com/wxt-dev/wxt/pull/477))
|
||||
- **storage:** ⚠️ Improved support for default values on storage items ([#477](https://github.com/wxt-dev/wxt/pull/477))
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- **storage:** ⚠️ Only run migrations when the extension is updated ([#478](https://github.com/wxt-dev/wxt/pull/478))
|
||||
- **storage:** ⚠️ Only run migrations when the extension is updated ([#478](https://github.com/wxt-dev/wxt/pull/478))
|
||||
- Improve dev mode for content scripts registered at runtime ([#474](https://github.com/wxt-dev/wxt/pull/474))
|
||||
|
||||
### 📖 Documentation
|
||||
@@ -344,12 +431,13 @@ const item = storage.defineItem<number | null>("local:count", {
|
||||
})
|
||||
```
|
||||
|
||||
The `defaultValue` property is now required if passing in the second options argument.
|
||||
The `defaultValue` property is now required if passing in the second options argument.
|
||||
|
||||
If you exclude the second options argument, it will default to being nullable, as before.
|
||||
|
||||
```ts
|
||||
const item: WxtStorageItem<number | null> = storage.defineItem<number>("local:count");
|
||||
const item: WxtStorageItem<number | null> =
|
||||
storage.defineItem<number>('local:count');
|
||||
const value: number | null = await item.getValue();
|
||||
```
|
||||
|
||||
@@ -359,13 +447,13 @@ For storage items that are not nullable, the `watch` callback types has improved
|
||||
|
||||
```ts
|
||||
// >=0.17
|
||||
const item = storage.defineItem<number>("local:count", { defaultValue: 0 });
|
||||
const item = storage.defineItem<number>('local:count', { defaultValue: 0 });
|
||||
item.watch((newValue: number | null, oldValue: number | null) => {
|
||||
// ...
|
||||
});
|
||||
|
||||
// >=0.17
|
||||
const item = storage.defineItem<number>("local:count", { defaultValue: 0 });
|
||||
const item = storage.defineItem<number>('local:count', { defaultValue: 0 });
|
||||
item.watch((newValue: number, oldValue: number) => {
|
||||
// ...
|
||||
});
|
||||
@@ -595,7 +683,7 @@ item.migrate();
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- ⚠️ ESM background support ([#398](https://github.com/wxt-dev/wxt/pull/398))
|
||||
- ⚠️ ESM background support ([#398](https://github.com/wxt-dev/wxt/pull/398))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
@@ -612,23 +700,23 @@ item.migrate();
|
||||
In [#398](https://github.com/wxt-dev/wxt/pull/398), HTML pages' JS entrypoints in the output directory have been moved. Unless you're doing some kind of post-build work referencing files, you don't have to make any changes.
|
||||
|
||||
- Before:
|
||||
```
|
||||
.output/
|
||||
<target>/
|
||||
chunks/
|
||||
some-shared-chunk-<hash>.js
|
||||
popup-<hash>.js
|
||||
popup.html
|
||||
```
|
||||
```
|
||||
.output/
|
||||
<target>/
|
||||
chunks/
|
||||
some-shared-chunk-<hash>.js
|
||||
popup-<hash>.js
|
||||
popup.html
|
||||
```
|
||||
- After:
|
||||
```
|
||||
.output/
|
||||
<target>/
|
||||
chunks/
|
||||
some-shared-chunk-<hash>.js
|
||||
popup.html
|
||||
popup.js
|
||||
```
|
||||
```
|
||||
.output/
|
||||
<target>/
|
||||
chunks/
|
||||
some-shared-chunk-<hash>.js
|
||||
popup.html
|
||||
popup.js
|
||||
```
|
||||
|
||||
This effects all HTML files, not just the Popup. The hash has been removed, and it's been moved to the root of the build target folder, not inside the `chunks/` directory. Moving files like this has not historically increased review times or triggered in-depth reviews when submitting updates to the stores.
|
||||
|
||||
@@ -694,12 +782,12 @@ This effects all HTML files, not just the Popup. The hash has been removed, and
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- **zip:** ⚠️ Add `includeSources` and rename `ignoredSources` to `excludeSources` ([#378](https://github.com/wxt-dev/wxt/pull/378))
|
||||
- **zip:** ⚠️ Add `includeSources` and rename `ignoredSources` to `excludeSources` ([#378](https://github.com/wxt-dev/wxt/pull/378))
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- Generate missing sourcemap in `wxt:unimport` plugin ([#381](https://github.com/wxt-dev/wxt/pull/381))
|
||||
- ⚠️ Move browser constants to `import.meta.env` ([#380](https://github.com/wxt-dev/wxt/pull/380))
|
||||
- ⚠️ Move browser constants to `import.meta.env` ([#380](https://github.com/wxt-dev/wxt/pull/380))
|
||||
- Enable inline sourcemaps by default during development ([#382](https://github.com/wxt-dev/wxt/pull/382))
|
||||
|
||||
### 📖 Documentation
|
||||
@@ -849,7 +937,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- ⚠️ Refactor content script UI functions and add helper for "integrated" UIs ([#333](https://github.com/wxt-dev/wxt/pull/333))
|
||||
- ⚠️ Refactor content script UI functions and add helper for "integrated" UIs ([#333](https://github.com/wxt-dev/wxt/pull/333))
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
@@ -858,7 +946,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
- `createContentScriptUi({ ... })` → `createShadowRootUi({ ... })`
|
||||
- `createContentScriptIframe({ ... })` → `createIframeUi({ ... })`
|
||||
- `type: "inline" | "overlay" | "modal"` has been changed to `position: "inline" | "overlay" | "modal"`
|
||||
- `onRemove` is now called ***before*** the UI is removed from the DOM, previously it was called after the UI was removed
|
||||
- `onRemove` is now called **_before_** the UI is removed from the DOM, previously it was called after the UI was removed
|
||||
- `mount` option has been renamed to `onMount`, to better match the related option, `onRemove`.
|
||||
|
||||
## v0.13.5
|
||||
@@ -954,7 +1042,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- ⚠️ New `wxt/storage` APIs ([#300](https://github.com/wxt-dev/wxt/pull/300))
|
||||
- ⚠️ New `wxt/storage` APIs ([#300](https://github.com/wxt-dev/wxt/pull/300))
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
@@ -1011,7 +1099,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- ⚠️ Add support for "main world" content scripts ([#284](https://github.com/wxt-dev/wxt/pull/284))
|
||||
- ⚠️ Add support for "main world" content scripts ([#284](https://github.com/wxt-dev/wxt/pull/284))
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
@@ -1033,10 +1121,10 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
- If you use auto-imports, no changes are required.
|
||||
- If you have disabled auto-imports, you'll need to manually update your import statements:
|
||||
```diff
|
||||
- import { defineBackground, defineContentScript } from 'wxt/client';
|
||||
+ import { defineBackground, defineContentScript } from 'wxt/sandbox';
|
||||
```
|
||||
```diff
|
||||
- import { defineBackground, defineContentScript } from 'wxt/client';
|
||||
+ import { defineBackground, defineContentScript } from 'wxt/sandbox';
|
||||
```
|
||||
|
||||
## v0.11.2
|
||||
|
||||
@@ -1074,7 +1162,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- ⚠️ Vite 5 support ([#261](https://github.com/wxt-dev/wxt/pull/261))
|
||||
- ⚠️ Vite 5 support ([#261](https://github.com/wxt-dev/wxt/pull/261))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
@@ -1166,7 +1254,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
### 🚀 Enhancements
|
||||
|
||||
- List `bun` as an experimental option in `wxt init` ([#233](https://github.com/wxt-dev/wxt/pull/233))
|
||||
- ⚠️ Allow plural directory and only png's for manifest icons ([#237](https://github.com/wxt-dev/wxt/pull/237))
|
||||
- ⚠️ Allow plural directory and only png's for manifest icons ([#237](https://github.com/wxt-dev/wxt/pull/237))
|
||||
- Add `wxt/storage` API ([#234](https://github.com/wxt-dev/wxt/pull/234))
|
||||
|
||||
### 🩹 Fixes
|
||||
@@ -1238,7 +1326,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- ⚠️ Remove `lib` from `.wxt/tsconfig.json` ([#209](https://github.com/wxt-dev/wxt/pull/209))
|
||||
- ⚠️ Remove `lib` from `.wxt/tsconfig.json` ([#209](https://github.com/wxt-dev/wxt/pull/209))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
@@ -1251,15 +1339,15 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
- ⚠️ Removed [`"WebWorker"` types](https://www.typescriptlang.org/tsconfig/lib.html) from `.wxt/tsconfig.json` ([#209](https://github.com/wxt-dev/wxt/pull/209)). These types are useful for MV3 projects using a service worker. To add them back to your project, add the following to your project's TSConfig:
|
||||
```diff
|
||||
{
|
||||
"extends": "./.wxt/tsconfig.json",
|
||||
+ "compilerOptions": {
|
||||
+ "lib": ["ESNext", "DOM", "WebWorker"]
|
||||
+ }
|
||||
}
|
||||
```
|
||||
- ⚠️ Removed [`"WebWorker"` types](https://www.typescriptlang.org/tsconfig/lib.html) from `.wxt/tsconfig.json` ([#209](https://github.com/wxt-dev/wxt/pull/209)). These types are useful for MV3 projects using a service worker. To add them back to your project, add the following to your project's TSConfig:
|
||||
```diff
|
||||
{
|
||||
"extends": "./.wxt/tsconfig.json",
|
||||
+ "compilerOptions": {
|
||||
+ "lib": ["ESNext", "DOM", "WebWorker"]
|
||||
+ }
|
||||
}
|
||||
```
|
||||
|
||||
### ❤️ Contributors
|
||||
|
||||
@@ -1373,7 +1461,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- ⚠️ Use `defineUnlistedScript` to define unlisted scripts ([#167](https://github.com/wxt-dev/wxt/pull/167))
|
||||
- ⚠️ Use `defineUnlistedScript` to define unlisted scripts ([#167](https://github.com/wxt-dev/wxt/pull/167))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
@@ -1381,12 +1469,12 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
### 🌊 Types
|
||||
|
||||
- ⚠️ Rename `BackgroundScriptDefintition` to `BackgroundDefinition` ([446f265](https://github.com/wxt-dev/wxt/commit/446f265))
|
||||
- ⚠️ Rename `BackgroundScriptDefintition` to `BackgroundDefinition` ([446f265](https://github.com/wxt-dev/wxt/commit/446f265))
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
- ⚠️ Unlisted scripts must now `export default defineUnlistedScript(...)` ([#167](https://github.com/wxt-dev/wxt/pull/167))
|
||||
- ⚠️ Rename `BackgroundScriptDefintition` to `BackgroundDefinition` ([446f265](https://github.com/wxt-dev/wxt/commit/446f265))
|
||||
- ⚠️ Unlisted scripts must now `export default defineUnlistedScript(...)` ([#167](https://github.com/wxt-dev/wxt/pull/167))
|
||||
- ⚠️ Rename `BackgroundScriptDefintition` to `BackgroundDefinition` ([446f265](https://github.com/wxt-dev/wxt/commit/446f265))
|
||||
|
||||
### ❤️ Contributors
|
||||
|
||||
@@ -1479,7 +1567,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
### 🩹 Fixes
|
||||
|
||||
- Validate transformed manifest correctly ([4b2012c](https://github.com/wxt-dev/wxt/commit/4b2012c))
|
||||
- ⚠️ Output content script CSS to `content-scripts/<name>.css` ([#140](https://github.com/wxt-dev/wxt/pull/140))
|
||||
- ⚠️ Output content script CSS to `content-scripts/<name>.css` ([#140](https://github.com/wxt-dev/wxt/pull/140))
|
||||
- Reorder typescript paths to give priority to `@` and `~` over `@@` and `~~` ([#142](https://github.com/wxt-dev/wxt/pull/142))
|
||||
|
||||
### 🏡 Chore
|
||||
@@ -1577,7 +1665,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
### 🚀 Enhancements
|
||||
|
||||
- Export `ContentScriptContext` from `wxt/client` ([1f448d1](https://github.com/wxt-dev/wxt/commit/1f448d1))
|
||||
- ⚠️ Require a function for `vite` configuration ([#121](https://github.com/wxt-dev/wxt/pull/121))
|
||||
- ⚠️ Require a function for `vite` configuration ([#121](https://github.com/wxt-dev/wxt/pull/121))
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
@@ -1586,7 +1674,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
- ⚠️ The `vite` config option must now be a function. If you were using an object before, change it from `vite: { ... }` to `vite: () => ({ ... })`. ([#121](https://github.com/wxt-dev/wxt/pull/121))
|
||||
- ⚠️ The `vite` config option must now be a function. If you were using an object before, change it from `vite: { ... }` to `vite: () => ({ ... })`. ([#121](https://github.com/wxt-dev/wxt/pull/121))
|
||||
|
||||
## v0.5.6
|
||||
|
||||
@@ -1653,7 +1741,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
### 🩹 Fixes
|
||||
|
||||
- **types:** Don't write to files if nothing changes ([#107](https://github.com/wxt-dev/wxt/pull/107))
|
||||
- ⚠️ Change default `publicDir` to `<srcDir>/public` ([5f15f9c](https://github.com/wxt-dev/wxt/commit/5f15f9c))
|
||||
- ⚠️ Change default `publicDir` to `<srcDir>/public` ([5f15f9c](https://github.com/wxt-dev/wxt/commit/5f15f9c))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
@@ -1673,7 +1761,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
- ⚠️ Change default `publicDir` to `<srcDir>/public` ([5f15f9c](https://github.com/wxt-dev/wxt/commit/5f15f9c))
|
||||
- ⚠️ Change default `publicDir` to `<srcDir>/public` ([5f15f9c](https://github.com/wxt-dev/wxt/commit/5f15f9c))
|
||||
|
||||
## v0.4.1
|
||||
|
||||
@@ -1701,7 +1789,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
- Allow adding custom content scripts ([b428a62](https://github.com/wxt-dev/wxt/commit/b428a62))
|
||||
- Don't overwrite `wxt.config.ts` content scripts, append entrypoints to it ([5f5f1d9](https://github.com/wxt-dev/wxt/commit/5f5f1d9))
|
||||
- ⚠️ Use relative path aliases inside `.wxt/tsconfig.json` ([#102](https://github.com/wxt-dev/wxt/pull/102))
|
||||
- ⚠️ Use relative path aliases inside `.wxt/tsconfig.json` ([#102](https://github.com/wxt-dev/wxt/pull/102))
|
||||
|
||||
### 📖 Documentation
|
||||
|
||||
@@ -1734,7 +1822,7 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
- ⚠️ Use relative path aliases inside `.wxt/tsconfig.json` ([#102](https://github.com/wxt-dev/wxt/pull/102))
|
||||
- ⚠️ Use relative path aliases inside `.wxt/tsconfig.json` ([#102](https://github.com/wxt-dev/wxt/pull/102))
|
||||
|
||||
## v0.3.2
|
||||
|
||||
@@ -1806,8 +1894,8 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- ⚠️ Add type safety to `browser.runtime.getURL` ([58a84ec](https://github.com/wxt-dev/wxt/commit/58a84ec))
|
||||
- ⚠️ Change default `publicDir` to `<rootDir>/public` ([19c0948](https://github.com/wxt-dev/wxt/commit/19c0948))
|
||||
- ⚠️ Add type safety to `browser.runtime.getURL` ([58a84ec](https://github.com/wxt-dev/wxt/commit/58a84ec))
|
||||
- ⚠️ Change default `publicDir` to `<rootDir>/public` ([19c0948](https://github.com/wxt-dev/wxt/commit/19c0948))
|
||||
- Windows support ([#50](https://github.com/wxt-dev/wxt/pull/50))
|
||||
|
||||
### 🩹 Fixes
|
||||
@@ -1826,10 +1914,10 @@ Renamed undocumented constants for detecting the build config at runtime in [#38
|
||||
|
||||
- Improve checks against `demo/` extension ([9cc464f](https://github.com/wxt-dev/wxt/commit/9cc464f))
|
||||
|
||||
#### ⚠️ Breaking Changes
|
||||
#### ⚠️ Breaking Changes
|
||||
|
||||
- ⚠️ Add type safety to `browser.runtime.getURL` ([58a84ec](https://github.com/wxt-dev/wxt/commit/58a84ec))
|
||||
- ⚠️ Change default `publicDir` to `<rootDir>/public` ([19c0948](https://github.com/wxt-dev/wxt/commit/19c0948))
|
||||
- ⚠️ Add type safety to `browser.runtime.getURL` ([58a84ec](https://github.com/wxt-dev/wxt/commit/58a84ec))
|
||||
- ⚠️ Change default `publicDir` to `<rootDir>/public` ([19c0948](https://github.com/wxt-dev/wxt/commit/19c0948))
|
||||
|
||||
## v0.2.5
|
||||
|
||||
|
||||
@@ -294,9 +294,10 @@ describe('Output Directory Structure', () => {
|
||||
warn: (...args) => print(console.warn, ...args),
|
||||
error: (...args) => print(console.error, ...args)
|
||||
};
|
||||
var result;
|
||||
try {
|
||||
const res = definition.main();
|
||||
if (res instanceof Promise) {
|
||||
result = definition.main();
|
||||
if (result instanceof Promise) {
|
||||
console.warn(
|
||||
"The background's main() function return a promise, but it must be synchronous"
|
||||
);
|
||||
@@ -352,7 +353,7 @@ describe('Output Directory Structure', () => {
|
||||
.toMatchInlineSnapshot(`
|
||||
".output/chrome-mv3/background.js
|
||||
----------------------------------------
|
||||
(function() {
|
||||
var _background = function() {
|
||||
"use strict";
|
||||
function defineBackground(arg) {
|
||||
if (typeof arg === "function")
|
||||
@@ -379,9 +380,10 @@ describe('Output Directory Structure', () => {
|
||||
warn: (...args) => print(console.warn, ...args),
|
||||
error: (...args) => print(console.error, ...args)
|
||||
};
|
||||
var result;
|
||||
try {
|
||||
const res = definition.main();
|
||||
if (res instanceof Promise) {
|
||||
result = definition.main();
|
||||
if (result instanceof Promise) {
|
||||
console.warn(
|
||||
"The background's main() function return a promise, but it must be synchronous"
|
||||
);
|
||||
@@ -390,7 +392,9 @@ describe('Output Directory Structure', () => {
|
||||
logger.error("The background crashed on startup!");
|
||||
throw err;
|
||||
}
|
||||
})();
|
||||
var background_entrypoint_default = result;
|
||||
return background_entrypoint_default;
|
||||
}();
|
||||
_background;
|
||||
"
|
||||
`);
|
||||
|
||||
@@ -96,4 +96,48 @@ describe('Zipping', () => {
|
||||
expect(await project.fileExists(artifactZip)).toBe(true);
|
||||
expect(await project.fileExists(sourcesZip)).toBe(true);
|
||||
});
|
||||
|
||||
it('should not zip hidden files into sources by default', async () => {
|
||||
const project = new TestProject({
|
||||
name: 'test',
|
||||
version: '1.0.0',
|
||||
});
|
||||
project.addFile(
|
||||
'entrypoints/background.ts',
|
||||
'export default defineBackground(() => {});',
|
||||
);
|
||||
project.addFile('.env');
|
||||
const unzipDir = project.resolvePath('.output/test-1.0.0-sources');
|
||||
const sourcesZip = project.resolvePath('.output/test-1.0.0-sources.zip');
|
||||
|
||||
await project.zip({
|
||||
browser: 'firefox',
|
||||
});
|
||||
await extract(sourcesZip, { dir: unzipDir });
|
||||
console.log(unzipDir); // TODO: Remove log
|
||||
expect(await project.fileExists(unzipDir, '.env')).toBe(false);
|
||||
});
|
||||
|
||||
it('should allow zipping hidden files into sources when explicitly listed', async () => {
|
||||
const project = new TestProject({
|
||||
name: 'test',
|
||||
version: '1.0.0',
|
||||
});
|
||||
project.addFile(
|
||||
'entrypoints/background.ts',
|
||||
'export default defineBackground(() => {});',
|
||||
);
|
||||
project.addFile('.env');
|
||||
const unzipDir = project.resolvePath('.output/test-1.0.0-sources');
|
||||
const sourcesZip = project.resolvePath('.output/test-1.0.0-sources.zip');
|
||||
|
||||
await project.zip({
|
||||
browser: 'firefox',
|
||||
zip: {
|
||||
includeSources: ['.env'],
|
||||
},
|
||||
});
|
||||
await extract(sourcesZip, { dir: unzipDir });
|
||||
expect(await project.fileExists(unzipDir, '.env')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "wxt",
|
||||
"type": "module",
|
||||
"version": "0.18.0",
|
||||
"version": "0.18.4",
|
||||
"description": "Next gen framework for developing web extensions",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -88,7 +88,7 @@
|
||||
"check:tsc-virtual": "tsc --noEmit -p src/virtual",
|
||||
"test": "vitest",
|
||||
"test:e2e": "vitest -r e2e",
|
||||
"test:e2e:2": "vitest --config e2e/vitest.config.ts"
|
||||
"sync-releases": "pnpx changelogen@latest gh release"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aklinker1/rollup-plugin-visualizer": "5.12.0",
|
||||
@@ -148,5 +148,10 @@
|
||||
"tsup": "^8.0.1",
|
||||
"tsx": "^4.6.2",
|
||||
"typescript": "^5.3.2"
|
||||
},
|
||||
"changelog": {
|
||||
"excludeAuthors": [
|
||||
"aaronklinker1@gmail.com"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ export class ContentScriptContext implements AbortController {
|
||||
// Use postMessage so it get's sent to all the frames of the page.
|
||||
window.postMessage(
|
||||
{
|
||||
event: ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE,
|
||||
type: ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE,
|
||||
contentScriptName: this.contentScriptName,
|
||||
},
|
||||
'*',
|
||||
|
||||
@@ -35,6 +35,7 @@ export function createWebExtRunner(): ExtensionRunner {
|
||||
console: wxtUserConfig?.openConsole,
|
||||
devtools: wxtUserConfig?.openDevtools,
|
||||
startUrl: wxtUserConfig?.startUrls,
|
||||
keepProfileChanges: wxtUserConfig?.keepProfileChanges,
|
||||
...(wxt.config.browser === 'firefox'
|
||||
? {
|
||||
firefox: wxtUserConfig?.binaries?.firefox,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
fakeOptionsEntrypoint,
|
||||
fakePopupEntrypoint,
|
||||
fakeSidepanelEntrypoint,
|
||||
fakeWxtDevServer,
|
||||
setFakeWxt,
|
||||
} from '../testing/fake-objects';
|
||||
import { Manifest } from 'webextension-polyfill';
|
||||
@@ -897,7 +898,7 @@ describe('Manifest Utils', () => {
|
||||
|
||||
describe('sidepanel', () => {
|
||||
it.each(['chrome', 'safari', 'edge'])(
|
||||
'should include a side_panel ignoring all options for %s',
|
||||
'should include the side_panel and permission, ignoring all options for %s',
|
||||
async (browser) => {
|
||||
const sidepanel = fakeSidepanelEntrypoint({
|
||||
outputDir: outDir,
|
||||
@@ -909,12 +910,14 @@ describe('Manifest Utils', () => {
|
||||
manifestVersion: 3,
|
||||
browser,
|
||||
outDir,
|
||||
command: 'build',
|
||||
},
|
||||
});
|
||||
const expected = {
|
||||
side_panel: {
|
||||
default_path: 'sidepanel.html',
|
||||
},
|
||||
permissions: ['sidePanel'],
|
||||
};
|
||||
|
||||
const { manifest: actual } = await generateManifest(
|
||||
@@ -1494,6 +1497,91 @@ describe('Manifest Utils', () => {
|
||||
expect(actual.host_permissions).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dev mode', () => {
|
||||
it('should not add any code for production builds', async () => {
|
||||
setFakeWxt({
|
||||
config: {
|
||||
command: 'build',
|
||||
},
|
||||
server: {
|
||||
hostname: 'localhost',
|
||||
port: 3000,
|
||||
origin: 'http://localhost:3000',
|
||||
},
|
||||
});
|
||||
const output = fakeBuildOutput();
|
||||
const entrypoints: Entrypoint[] = [];
|
||||
|
||||
const { manifest: actual } = await generateManifest(
|
||||
entrypoints,
|
||||
output,
|
||||
);
|
||||
|
||||
expect(actual.permissions).toBeUndefined();
|
||||
expect(actual.content_security_policy).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should add required permissions for dev mode to function for MV2', async () => {
|
||||
setFakeWxt({
|
||||
config: {
|
||||
command: 'serve',
|
||||
manifestVersion: 2,
|
||||
},
|
||||
server: fakeWxtDevServer({
|
||||
port: 3000,
|
||||
hostname: 'localhost',
|
||||
origin: 'http://localhost:3000',
|
||||
}),
|
||||
});
|
||||
const output = fakeBuildOutput();
|
||||
const entrypoints: Entrypoint[] = [];
|
||||
|
||||
const { manifest: actual } = await generateManifest(
|
||||
entrypoints,
|
||||
output,
|
||||
);
|
||||
|
||||
expect(actual).toMatchObject({
|
||||
content_security_policy:
|
||||
"script-src 'self' http://localhost:3000; object-src 'self';",
|
||||
permissions: ['http://localhost/*', 'tabs'],
|
||||
});
|
||||
});
|
||||
|
||||
it('should add required permissions for dev mode to function for MV3', async () => {
|
||||
setFakeWxt({
|
||||
config: {
|
||||
command: 'serve',
|
||||
manifestVersion: 3,
|
||||
browser: 'chrome',
|
||||
},
|
||||
server: fakeWxtDevServer({
|
||||
hostname: 'localhost',
|
||||
port: 3000,
|
||||
origin: 'http://localhost:3000',
|
||||
}),
|
||||
});
|
||||
const output = fakeBuildOutput();
|
||||
const entrypoints: Entrypoint[] = [];
|
||||
|
||||
const { manifest: actual } = await generateManifest(
|
||||
entrypoints,
|
||||
output,
|
||||
);
|
||||
|
||||
expect(actual).toMatchObject({
|
||||
content_security_policy: {
|
||||
extension_pages:
|
||||
"script-src 'self' 'wasm-unsafe-eval' http://localhost:3000; object-src 'self';",
|
||||
sandbox:
|
||||
"script-src 'self' 'unsafe-inline' 'unsafe-eval' http://localhost:3000; sandbox allow-scripts allow-forms allow-popups allow-modals; child-src 'self';",
|
||||
},
|
||||
host_permissions: ['http://localhost/*'],
|
||||
permissions: ['tabs', 'scripting'],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('stripPathFromMatchPattern', () => {
|
||||
|
||||
@@ -50,6 +50,7 @@ import "@/utils/github";
|
||||
import '@/utils/github';
|
||||
import"@/utils/github"
|
||||
import'@/utils/github';
|
||||
import * as abc from "@/utils/github"
|
||||
`;
|
||||
expect(removeImportStatements(imports).trim()).toEqual('');
|
||||
});
|
||||
|
||||
@@ -347,6 +347,7 @@ function addEntrypoints(
|
||||
manifest.side_panel = {
|
||||
default_path: page,
|
||||
};
|
||||
addPermission(manifest, 'sidePanel');
|
||||
} else {
|
||||
wxt.logger.warn(
|
||||
'Side panel not supported by Chromium using MV2. side_panel.default_path was not added to the manifest',
|
||||
@@ -465,23 +466,34 @@ function addDevModeCsp(manifest: Manifest.WebExtensionManifest): void {
|
||||
addPermission(manifest, permission);
|
||||
}
|
||||
|
||||
const csp = new ContentSecurityPolicy(
|
||||
const extensionPagesCsp = new ContentSecurityPolicy(
|
||||
manifest.manifest_version === 3
|
||||
? // @ts-expect-error: extension_pages is not typed
|
||||
manifest.content_security_policy?.extension_pages ??
|
||||
"script-src 'self' 'wasm-unsafe-eval'; object-src 'self';" // default CSP for MV3
|
||||
"script-src 'self' 'wasm-unsafe-eval'; object-src 'self';" // default extension_pages CSP for MV3
|
||||
: manifest.content_security_policy ??
|
||||
"script-src 'self'; object-src 'self';", // default CSP for MV2
|
||||
);
|
||||
const sandboxCsp = new ContentSecurityPolicy(
|
||||
// @ts-expect-error: sandbox is not typed
|
||||
manifest.content_security_policy?.sandbox ??
|
||||
"sandbox allow-scripts allow-forms allow-popups allow-modals; script-src 'self' 'unsafe-inline' 'unsafe-eval'; child-src 'self';", // default sandbox CSP for MV3
|
||||
);
|
||||
|
||||
if (wxt.server) csp.add('script-src', allowedCsp);
|
||||
if (wxt.server) {
|
||||
extensionPagesCsp.add('script-src', allowedCsp);
|
||||
sandboxCsp.add('script-src', allowedCsp);
|
||||
}
|
||||
|
||||
if (manifest.manifest_version === 3) {
|
||||
manifest.content_security_policy ??= {};
|
||||
// @ts-expect-error: extension_pages is not typed
|
||||
manifest.content_security_policy.extension_pages = csp.toString();
|
||||
manifest.content_security_policy.extension_pages =
|
||||
extensionPagesCsp.toString();
|
||||
// @ts-expect-error: sandbox is not typed
|
||||
manifest.content_security_policy.sandbox = sandboxCsp.toString();
|
||||
} else {
|
||||
manifest.content_security_policy = csp.toString();
|
||||
manifest.content_security_policy = extensionPagesCsp.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export function safeVarName(str: string): string {
|
||||
*/
|
||||
export function removeImportStatements(text: string): string {
|
||||
return text.replace(
|
||||
/(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
|
||||
/(import\s?[\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
|
||||
'',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -311,10 +311,27 @@ export const fakeWxt = fakeObjectCreator<Wxt>(() => ({
|
||||
logger: mock(),
|
||||
reloadConfig: vi.fn(),
|
||||
pm: mock(),
|
||||
server: faker.helpers.arrayElement([undefined, mock<WxtDevServer>()]),
|
||||
server: faker.helpers.arrayElement([undefined, fakeWxtDevServer()]),
|
||||
builder: mock(),
|
||||
}));
|
||||
|
||||
export const fakeWxtDevServer = fakeObjectCreator<WxtDevServer>(() => ({
|
||||
currentOutput: fakeBuildOutput(),
|
||||
hostname: 'localhost',
|
||||
origin: 'http://localhost:3000',
|
||||
port: 3000,
|
||||
reloadContentScript: vi.fn(),
|
||||
reloadExtension: vi.fn(),
|
||||
reloadPage: vi.fn(),
|
||||
restart: vi.fn(),
|
||||
restartBrowser: vi.fn(),
|
||||
start: vi.fn(),
|
||||
stop: vi.fn(),
|
||||
transformHtml: vi.fn(),
|
||||
watcher: mock(),
|
||||
ws: mock(),
|
||||
}));
|
||||
|
||||
export function setFakeWxt(overrides?: DeepPartial<Wxt>) {
|
||||
const wxt = fakeWxt(overrides);
|
||||
setWxtForTesting(wxt);
|
||||
|
||||
@@ -104,15 +104,12 @@ async function zipDir(
|
||||
// Ignore node_modules, otherwise this glob step takes forever
|
||||
ignore: ['**/node_modules'],
|
||||
onlyFiles: true,
|
||||
dot: true,
|
||||
})
|
||||
).filter((relativePath) => {
|
||||
return (
|
||||
wxt.config.zip.includeSources.some((pattern) =>
|
||||
minimatch(relativePath, pattern),
|
||||
) ||
|
||||
!wxt.config.zip.excludeSources.some((pattern) =>
|
||||
minimatch(relativePath, pattern),
|
||||
)
|
||||
options?.include?.some((pattern) => minimatch(relativePath, pattern)) ||
|
||||
!options?.exclude?.some((pattern) => minimatch(relativePath, pattern))
|
||||
);
|
||||
});
|
||||
const filesToZip = [
|
||||
|
||||
@@ -927,6 +927,10 @@ export interface ExtensionRunnerConfig {
|
||||
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#start-url
|
||||
*/
|
||||
startUrls?: string[];
|
||||
/**
|
||||
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#keep-profile-changes
|
||||
*/
|
||||
keepProfileChanges?: boolean;
|
||||
}
|
||||
|
||||
export interface WxtBuilder {
|
||||
|
||||
@@ -34,10 +34,12 @@ if (import.meta.env.COMMAND === 'serve') {
|
||||
});
|
||||
}
|
||||
|
||||
let result;
|
||||
|
||||
try {
|
||||
const res = definition.main();
|
||||
result = definition.main();
|
||||
// @ts-expect-error: res shouldn't be a promise, but we're checking it anyways
|
||||
if (res instanceof Promise) {
|
||||
if (result instanceof Promise) {
|
||||
console.warn(
|
||||
"The background's main() function return a promise, but it must be synchronous",
|
||||
);
|
||||
@@ -46,3 +48,9 @@ try {
|
||||
logger.error('The background crashed on startup!');
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Return the main function's result to the background when executed via the
|
||||
// scripting API. Default export causes the IIFE to return a value.
|
||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript#return_value
|
||||
// Tested on both Chrome and Firefox
|
||||
export default result;
|
||||
|
||||
Generated
+45
-9
@@ -1494,7 +1494,7 @@ packages:
|
||||
vite: ^5.0.0
|
||||
vue: ^3.2.25
|
||||
dependencies:
|
||||
vite: 5.2.8(@types/node@20.10.3)
|
||||
vite: 5.2.8
|
||||
vue: 3.4.21(typescript@5.3.3)
|
||||
dev: true
|
||||
|
||||
@@ -2988,7 +2988,7 @@ packages:
|
||||
mri: 1.2.0
|
||||
node-fetch-native: 1.6.4
|
||||
pathe: 1.1.2
|
||||
tar: 6.2.0
|
||||
tar: 6.2.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
@@ -3004,7 +3004,7 @@ packages:
|
||||
nypm: 0.3.8
|
||||
ohash: 1.1.3
|
||||
pathe: 1.1.2
|
||||
tar: 6.2.0
|
||||
tar: 6.2.1
|
||||
dev: false
|
||||
|
||||
/glob-parent@5.1.2:
|
||||
@@ -5219,8 +5219,8 @@ packages:
|
||||
resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==}
|
||||
dev: true
|
||||
|
||||
/tar@6.2.0:
|
||||
resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==}
|
||||
/tar@6.2.1:
|
||||
resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==}
|
||||
engines: {node: '>=10'}
|
||||
dependencies:
|
||||
chownr: 2.0.0
|
||||
@@ -5563,7 +5563,7 @@ packages:
|
||||
debug: 4.3.4
|
||||
pathe: 1.1.2
|
||||
picocolors: 1.0.0
|
||||
vite: 5.2.8(@types/node@20.10.3)
|
||||
vite: 5.2.8
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- less
|
||||
@@ -5575,6 +5575,41 @@ packages:
|
||||
- terser
|
||||
dev: true
|
||||
|
||||
/vite@5.2.8:
|
||||
resolution: {integrity: sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@types/node': ^18.0.0 || >=20.0.0
|
||||
less: '*'
|
||||
lightningcss: ^1.21.0
|
||||
sass: '*'
|
||||
stylus: '*'
|
||||
sugarss: '*'
|
||||
terser: ^5.4.0
|
||||
peerDependenciesMeta:
|
||||
'@types/node':
|
||||
optional: true
|
||||
less:
|
||||
optional: true
|
||||
lightningcss:
|
||||
optional: true
|
||||
sass:
|
||||
optional: true
|
||||
stylus:
|
||||
optional: true
|
||||
sugarss:
|
||||
optional: true
|
||||
terser:
|
||||
optional: true
|
||||
dependencies:
|
||||
esbuild: 0.20.2
|
||||
postcss: 8.4.38
|
||||
rollup: 4.14.0
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
dev: true
|
||||
|
||||
/vite@5.2.8(@types/node@20.10.3):
|
||||
resolution: {integrity: sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
@@ -5609,6 +5644,7 @@ packages:
|
||||
rollup: 4.14.0
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
dev: false
|
||||
|
||||
/vitepress@1.0.0-rc.34(typescript@5.3.3):
|
||||
resolution: {integrity: sha512-TUbTiSdAZFni2XlHlpx61KikgkQ5uG4Wtmw2R0SXhIOG6qGqzDJczAFjkMc4i45I9c3KyatwOYe8oEfCnzVYwQ==}
|
||||
@@ -5636,7 +5672,7 @@ packages:
|
||||
shikiji: 0.9.16
|
||||
shikiji-core: 0.9.16
|
||||
shikiji-transformers: 0.9.16
|
||||
vite: 5.2.8(@types/node@20.10.3)
|
||||
vite: 5.2.8
|
||||
vue: 3.4.21(typescript@5.3.3)
|
||||
transitivePeerDependencies:
|
||||
- '@algolia/client-search'
|
||||
@@ -5682,7 +5718,7 @@ packages:
|
||||
peerDependencies:
|
||||
vite: ^4.0.0 || ^5.0.0
|
||||
dependencies:
|
||||
vite: 5.2.8(@types/node@20.10.3)
|
||||
vite: 5.2.8
|
||||
dev: true
|
||||
|
||||
/vitest@1.5.3:
|
||||
@@ -5727,7 +5763,7 @@ packages:
|
||||
strip-literal: 2.1.0
|
||||
tinybench: 2.5.1
|
||||
tinypool: 0.8.4
|
||||
vite: 5.2.8(@types/node@20.10.3)
|
||||
vite: 5.2.8
|
||||
vite-node: 1.5.3
|
||||
why-is-node-running: 2.2.2
|
||||
transitivePeerDependencies:
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
"@types/react-dom": "^18.2.18",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"typescript": "^5.3.3",
|
||||
"wxt": "^0.17.0"
|
||||
"wxt": "^0.18.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
"devDependencies": {
|
||||
"typescript": "^5.3.3",
|
||||
"vite-plugin-solid": "^2.8.0",
|
||||
"wxt": "^0.17.0"
|
||||
"wxt": "^0.18.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
"svelte-check": "^3.6.2",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^5.3.3",
|
||||
"wxt": "^0.17.0"
|
||||
"wxt": "^0.18.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.3.3",
|
||||
"wxt": "^0.17.0"
|
||||
"wxt": "^0.18.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
"@vitejs/plugin-vue": "^5.0.1",
|
||||
"typescript": "^5.3.3",
|
||||
"vue-tsc": "^2.0.6",
|
||||
"wxt": "^0.17.0"
|
||||
"wxt": "^0.18.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user