Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57229c69c1 | |||
| 8f3a90eeb2 | |||
| a360965d92 | |||
| eb1ace6d20 | |||
| 497c902283 | |||
| 4d4453b830 | |||
| ef53580ed1 | |||
| 52e5387d47 | |||
| f5b7f7e0e5 | |||
| 592bdbe4d9 | |||
| 6fc227bad6 |
@@ -4,6 +4,9 @@ inputs:
|
|||||||
install:
|
install:
|
||||||
default: 'true'
|
default: 'true'
|
||||||
description: Whether or not to run 'pnpm install'
|
description: Whether or not to run 'pnpm install'
|
||||||
|
installArgs:
|
||||||
|
default: ''
|
||||||
|
description: Additional args to append to "pnpm install"
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
@@ -17,4 +20,4 @@ runs:
|
|||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
if: ${{ inputs.install == 'true' }}
|
if: ${{ inputs.install == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: pnpm install
|
run: pnpm install ${{ inputs.installArgs }}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ./.github/actions/setup
|
- uses: ./.github/actions/setup
|
||||||
|
with:
|
||||||
|
installArgs: --ignore-scripts
|
||||||
- run: pnpm tsx scripts/sync-releases.ts ${{ inputs.package }}
|
- run: pnpm tsx scripts/sync-releases.ts ${{ inputs.package }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ import { defineWxtModule } from 'wxt/modules';
|
|||||||
|
|
||||||
export default defineWxtModule({
|
export default defineWxtModule({
|
||||||
setup(wxt) {
|
setup(wxt) {
|
||||||
wxt.hook('ready', () => {
|
wxt.hook('config:resolved', () => {
|
||||||
wxt.config.outDir = 'dist';
|
wxt.config.outDir = 'dist';
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v1.1.2
|
||||||
|
|
||||||
|
[compare changes](https://github.com/wxt-dev/wxt/compare/module-react-v1.1.1...module-react-v1.1.2)
|
||||||
|
|
||||||
|
### 🩹 Fixes
|
||||||
|
|
||||||
|
- Use `config:resolved` hook to update config instead of `ready` ([#1178](https://github.com/wxt-dev/wxt/pull/1178))
|
||||||
|
|
||||||
|
### 🏡 Chore
|
||||||
|
|
||||||
|
- Add `oxlint` for linting ([#947](https://github.com/wxt-dev/wxt/pull/947))
|
||||||
|
- Upgrade all non-major dependencies ([#1040](https://github.com/wxt-dev/wxt/pull/1040))
|
||||||
|
- **deps:** Upgrade all non-major dependencies ([#1164](https://github.com/wxt-dev/wxt/pull/1164))
|
||||||
|
|
||||||
|
### ❤️ Contributors
|
||||||
|
|
||||||
|
- Aaron ([@aklinker1](http://github.com/aklinker1))
|
||||||
|
|
||||||
## v1.1.1
|
## v1.1.1
|
||||||
|
|
||||||
[compare changes](https://github.com/wxt-dev/wxt/compare/module-react-v1.1.0...module-react-v1.1.1)
|
[compare changes](https://github.com/wxt-dev/wxt/compare/module-react-v1.1.0...module-react-v1.1.1)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default defineWxtModule<ReactModuleOptions>({
|
|||||||
addImportPreset(wxt, 'react');
|
addImportPreset(wxt, 'react');
|
||||||
|
|
||||||
// Enable auto-imports for JSX files
|
// Enable auto-imports for JSX files
|
||||||
wxt.hooks.hook('ready', (wxt) => {
|
wxt.hook('config:resolved', (wxt) => {
|
||||||
if (wxt.config.imports === false) return;
|
if (wxt.config.imports === false) return;
|
||||||
|
|
||||||
wxt.config.imports.dirsScanOptions ??= {};
|
wxt.config.imports.dirsScanOptions ??= {};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"email": "aaronklinker1+wxt@gmail.com"
|
"email": "aaronklinker1+wxt@gmail.com"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
"prepare": "buildc --deps-only -- wxt prepare"
|
"prepare": "buildc --deps-only -- wxt prepare"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"wxt": ">=0.18.6"
|
"wxt": ">=0.19.16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vitejs/plugin-react": "^4.3.3"
|
"@vitejs/plugin-react": "^4.3.3"
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v1.1.3
|
||||||
|
|
||||||
|
[compare changes](https://github.com/wxt-dev/wxt/compare/module-solid-v1.1.2...module-solid-v1.1.3)
|
||||||
|
|
||||||
|
### 🩹 Fixes
|
||||||
|
|
||||||
|
- Use `config:resolved` hook to update config instead of `ready` ([#1178](https://github.com/wxt-dev/wxt/pull/1178))
|
||||||
|
|
||||||
|
### 🏡 Chore
|
||||||
|
|
||||||
|
- Add `oxlint` for linting ([#947](https://github.com/wxt-dev/wxt/pull/947))
|
||||||
|
- Upgrade all non-major dependencies ([#1040](https://github.com/wxt-dev/wxt/pull/1040))
|
||||||
|
- **deps:** Upgrade all non-major dependencies ([#1164](https://github.com/wxt-dev/wxt/pull/1164))
|
||||||
|
|
||||||
|
### ❤️ Contributors
|
||||||
|
|
||||||
|
- Aaron ([@aklinker1](http://github.com/aklinker1))
|
||||||
|
|
||||||
## v1.1.2
|
## v1.1.2
|
||||||
|
|
||||||
[compare changes](https://github.com/wxt-dev/wxt/compare/module-solid-v1.1.1...module-solid-v1.1.2)
|
[compare changes](https://github.com/wxt-dev/wxt/compare/module-solid-v1.1.1...module-solid-v1.1.2)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default defineWxtModule<SolidModuleOptions>({
|
|||||||
addImportPreset(wxt, 'solid-js');
|
addImportPreset(wxt, 'solid-js');
|
||||||
|
|
||||||
// Enable auto-imports for JSX files
|
// Enable auto-imports for JSX files
|
||||||
wxt.hooks.hook('ready', (wxt) => {
|
wxt.hook('config:resolved', (wxt) => {
|
||||||
if (wxt.config.imports === false) return;
|
if (wxt.config.imports === false) return;
|
||||||
|
|
||||||
wxt.config.imports.dirsScanOptions ??= {};
|
wxt.config.imports.dirsScanOptions ??= {};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"email": "aaronklinker1+wxt@gmail.com"
|
"email": "aaronklinker1+wxt@gmail.com"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
"prepare": "buildc --deps-only -- wxt prepare"
|
"prepare": "buildc --deps-only -- wxt prepare"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"wxt": ">=0.18.6"
|
"wxt": ">=0.19.16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vite-plugin-solid": "^2.10.2"
|
"vite-plugin-solid": "^2.10.2"
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v1.0.2
|
||||||
|
|
||||||
|
[compare changes](https://github.com/wxt-dev/wxt/compare/module-vue-v1.0.1...module-vue-v1.0.2)
|
||||||
|
|
||||||
|
### 🩹 Fixes
|
||||||
|
|
||||||
|
- Use `config:resolved` hook to update config instead of `ready` ([#1178](https://github.com/wxt-dev/wxt/pull/1178))
|
||||||
|
|
||||||
|
### 🏡 Chore
|
||||||
|
|
||||||
|
- Add `oxlint` for linting ([#947](https://github.com/wxt-dev/wxt/pull/947))
|
||||||
|
- **deps:** Bump @vitejs/plugin-vue from 5.1.1 to 5.1.4 ([#1020](https://github.com/wxt-dev/wxt/pull/1020))
|
||||||
|
- Upgrade all non-major dependencies ([#1040](https://github.com/wxt-dev/wxt/pull/1040))
|
||||||
|
- **deps:** Upgrade all non-major dependencies ([#1164](https://github.com/wxt-dev/wxt/pull/1164))
|
||||||
|
|
||||||
|
### ❤️ Contributors
|
||||||
|
|
||||||
|
- Aaron ([@aklinker1](http://github.com/aklinker1))
|
||||||
|
|
||||||
## v1.0.1
|
## v1.0.1
|
||||||
|
|
||||||
[compare changes](https://github.com/wxt-dev/wxt/compare/module-vue-v1.0.0...module-vue-v1.0.1)
|
[compare changes](https://github.com/wxt-dev/wxt/compare/module-vue-v1.0.0...module-vue-v1.0.1)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"email": "aaronklinker1+wxt@gmail.com"
|
"email": "aaronklinker1+wxt@gmail.com"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
"check": "pnpm build && check"
|
"check": "pnpm build && check"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"wxt": ">=0.18.6"
|
"wxt": ">=0.19.16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vitejs/plugin-vue": "^5.2.0"
|
"@vitejs/plugin-vue": "^5.2.0"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default defineWxtModule<VueModuleOptions>({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Enable auto-imports in template files
|
// Enable auto-imports in template files
|
||||||
wxt.hooks.hook('ready', (wxt) => {
|
wxt.hook('config:resolved', (wxt) => {
|
||||||
if (!wxt.config.imports) return;
|
if (!wxt.config.imports) return;
|
||||||
|
|
||||||
wxt.config.imports.addons ??= {};
|
wxt.config.imports.addons ??= {};
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v1.0.0
|
||||||
|
|
||||||
|
Extracted `wxt/storage` into it's own package, `@wxt-dev/storage`!
|
||||||
|
|
||||||
|
It's still shipped inside WXT and accessible via `wxt/storage`, but now:
|
||||||
|
|
||||||
|
- Non-WXT projects can use the storage wrapper.
|
||||||
|
- We can make breaking changes to the API separately.
|
||||||
|
|
||||||
|
[Read the docs](https://wxt.dev/storage.html) for more details.
|
||||||
|
|
||||||
|
> This is apart of the v1.0 initiative for WXT.
|
||||||
@@ -1,5 +1,35 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.19.16
|
||||||
|
|
||||||
|
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.19.15...wxt-v0.19.16)
|
||||||
|
|
||||||
|
### 🚀 Enhancements
|
||||||
|
|
||||||
|
- **hooks:** Add new `config:resolved` hook ([#1177](https://github.com/wxt-dev/wxt/pull/1177))
|
||||||
|
|
||||||
|
### ❤️ Contributors
|
||||||
|
|
||||||
|
- Aaron ([@aklinker1](http://github.com/aklinker1))
|
||||||
|
|
||||||
|
## v0.19.15
|
||||||
|
|
||||||
|
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.19.14...wxt-v0.19.15)
|
||||||
|
|
||||||
|
### 🚀 Enhancements
|
||||||
|
|
||||||
|
- Extract `wxt/storage` to its own package, `@wxt-dev/storage` ([#1129](https://github.com/wxt-dev/wxt/pull/1129))
|
||||||
|
|
||||||
|
### 🩹 Fixes
|
||||||
|
|
||||||
|
- Add "/" to `PublicPath` and `browser.runtime.getURL` ([#1171](https://github.com/wxt-dev/wxt/pull/1171))
|
||||||
|
- Add extension ID to event used to invalidate `ContentScriptContext` ([#1175](https://github.com/wxt-dev/wxt/pull/1175))
|
||||||
|
|
||||||
|
### ❤️ Contributors
|
||||||
|
|
||||||
|
- Aaron ([@aklinker1](http://github.com/aklinker1))
|
||||||
|
- Nishu ([@nishu-murmu](http://github.com/nishu-murmu))
|
||||||
|
|
||||||
## v0.19.14
|
## v0.19.14
|
||||||
|
|
||||||
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.19.13...wxt-v0.19.14)
|
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.19.13...wxt-v0.19.14)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { WxtHooks } from '../../src/types';
|
|||||||
|
|
||||||
const hooks: WxtHooks = {
|
const hooks: WxtHooks = {
|
||||||
ready: vi.fn(),
|
ready: vi.fn(),
|
||||||
|
'config:resolved': vi.fn(),
|
||||||
'prepare:types': vi.fn(),
|
'prepare:types': vi.fn(),
|
||||||
'prepare:publicPaths': vi.fn(),
|
'prepare:publicPaths': vi.fn(),
|
||||||
'build:before': vi.fn(),
|
'build:before': vi.fn(),
|
||||||
@@ -49,6 +50,7 @@ describe('Hooks', () => {
|
|||||||
|
|
||||||
expectHooksToBeCalled({
|
expectHooksToBeCalled({
|
||||||
ready: true,
|
ready: true,
|
||||||
|
'config:resolved': true,
|
||||||
'prepare:types': true,
|
'prepare:types': true,
|
||||||
'prepare:publicPaths': true,
|
'prepare:publicPaths': true,
|
||||||
'build:before': false,
|
'build:before': false,
|
||||||
@@ -76,6 +78,7 @@ describe('Hooks', () => {
|
|||||||
|
|
||||||
expectHooksToBeCalled({
|
expectHooksToBeCalled({
|
||||||
ready: true,
|
ready: true,
|
||||||
|
'config:resolved': true,
|
||||||
'prepare:types': true,
|
'prepare:types': true,
|
||||||
'prepare:publicPaths': true,
|
'prepare:publicPaths': true,
|
||||||
'build:before': true,
|
'build:before': true,
|
||||||
@@ -103,6 +106,7 @@ describe('Hooks', () => {
|
|||||||
|
|
||||||
expectHooksToBeCalled({
|
expectHooksToBeCalled({
|
||||||
ready: true,
|
ready: true,
|
||||||
|
'config:resolved': true,
|
||||||
'prepare:types': true,
|
'prepare:types': true,
|
||||||
'prepare:publicPaths': true,
|
'prepare:publicPaths': true,
|
||||||
'build:before': true,
|
'build:before': true,
|
||||||
@@ -130,6 +134,7 @@ describe('Hooks', () => {
|
|||||||
|
|
||||||
expectHooksToBeCalled({
|
expectHooksToBeCalled({
|
||||||
ready: true,
|
ready: true,
|
||||||
|
'config:resolved': true,
|
||||||
'prepare:types': true,
|
'prepare:types': true,
|
||||||
'prepare:publicPaths': true,
|
'prepare:publicPaths': true,
|
||||||
'build:before': true,
|
'build:before': true,
|
||||||
@@ -163,6 +168,7 @@ describe('Hooks', () => {
|
|||||||
|
|
||||||
expectHooksToBeCalled({
|
expectHooksToBeCalled({
|
||||||
ready: true,
|
ready: true,
|
||||||
|
'config:resolved': true,
|
||||||
'prepare:types': true,
|
'prepare:types': true,
|
||||||
'prepare:publicPaths': true,
|
'prepare:publicPaths': true,
|
||||||
'build:before': true,
|
'build:before': true,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "wxt",
|
"name": "wxt",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.19.14",
|
"version": "0.19.16",
|
||||||
"description": "Next gen framework for developing web extensions",
|
"description": "Next gen framework for developing web extensions",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ describe('Module Utilities', () => {
|
|||||||
|
|
||||||
wxt.config.vite = () => Promise.resolve(userConfig);
|
wxt.config.vite = () => Promise.resolve(userConfig);
|
||||||
addViteConfig(wxt, () => moduleConfig);
|
addViteConfig(wxt, () => moduleConfig);
|
||||||
await wxt.hooks.callHook('ready', wxt);
|
await wxt.hooks.callHook('config:resolved', wxt);
|
||||||
const actual = await wxt.config.vite(wxt.config.env);
|
const actual = await wxt.config.vite(wxt.config.env);
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
@@ -31,7 +31,7 @@ describe('Module Utilities', () => {
|
|||||||
|
|
||||||
wxt.config.vite = () => userConfig;
|
wxt.config.vite = () => userConfig;
|
||||||
addViteConfig(wxt, () => moduleConfig);
|
addViteConfig(wxt, () => moduleConfig);
|
||||||
await wxt.hooks.callHook('ready', wxt);
|
await wxt.hooks.callHook('config:resolved', wxt);
|
||||||
const actual = await wxt.config.vite(wxt.config.env);
|
const actual = await wxt.config.vite(wxt.config.env);
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
@@ -44,7 +44,7 @@ describe('Module Utilities', () => {
|
|||||||
const wxt = fakeWxt({ hooks: createHooks() });
|
const wxt = fakeWxt({ hooks: createHooks() });
|
||||||
|
|
||||||
addImportPreset(wxt, preset);
|
addImportPreset(wxt, preset);
|
||||||
await wxt.hooks.callHook('ready', wxt);
|
await wxt.hooks.callHook('config:resolved', wxt);
|
||||||
|
|
||||||
expect(wxt.config.imports && wxt.config.imports.presets).toContain(
|
expect(wxt.config.imports && wxt.config.imports.presets).toContain(
|
||||||
preset,
|
preset,
|
||||||
@@ -63,7 +63,7 @@ describe('Module Utilities', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addImportPreset(wxt, preset);
|
addImportPreset(wxt, preset);
|
||||||
await wxt.hooks.callHook('ready', wxt);
|
await wxt.hooks.callHook('config:resolved', wxt);
|
||||||
|
|
||||||
expect(wxt.config.imports && wxt.config.imports.presets).toHaveLength(2);
|
expect(wxt.config.imports && wxt.config.imports.presets).toHaveLength(2);
|
||||||
});
|
});
|
||||||
@@ -78,7 +78,7 @@ describe('Module Utilities', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addImportPreset(wxt, preset);
|
addImportPreset(wxt, preset);
|
||||||
await wxt.hooks.callHook('ready', wxt);
|
await wxt.hooks.callHook('config:resolved', wxt);
|
||||||
|
|
||||||
expect(wxt.config.imports).toBe(false);
|
expect(wxt.config.imports).toBe(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default defineWxtModule({
|
|||||||
let unimport: Unimport;
|
let unimport: Unimport;
|
||||||
|
|
||||||
// Add user module imports to config
|
// Add user module imports to config
|
||||||
wxt.hooks.hook('ready', () => {
|
wxt.hooks.hook('config:resolved', () => {
|
||||||
const addModuleImports = (module: WxtModule<any>) => {
|
const addModuleImports = (module: WxtModule<any>) => {
|
||||||
if (!module.imports) return;
|
if (!module.imports) return;
|
||||||
|
|
||||||
@@ -30,10 +30,10 @@ export default defineWxtModule({
|
|||||||
wxt.config.userModules.forEach(addModuleImports);
|
wxt.config.userModules.forEach(addModuleImports);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create unimport instance AFTER "ready" so any modifications to the
|
// Create unimport instance AFTER "config:resolved" so any modifications to the
|
||||||
// config inside "ready" are applied.
|
// config inside "config:resolved" are applied.
|
||||||
wxt.hooks.afterEach((event) => {
|
wxt.hooks.afterEach((event) => {
|
||||||
if (event.name === 'ready') {
|
if (event.name === 'config:resolved') {
|
||||||
unimport = createUnimport(options);
|
unimport = createUnimport(options);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ import { createLocationWatcher } from './location-watcher';
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export class ContentScriptContext implements AbortController {
|
export class ContentScriptContext implements AbortController {
|
||||||
private static SCRIPT_STARTED_MESSAGE_TYPE = 'wxt:content-script-started';
|
private static SCRIPT_STARTED_MESSAGE_TYPE = getUniqueEventName(
|
||||||
|
'wxt:content-script-started',
|
||||||
|
);
|
||||||
|
|
||||||
private isTopFrame = window.self === window.top;
|
private isTopFrame = window.self === window.top;
|
||||||
private abortController: AbortController;
|
private abortController: AbortController;
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ declare module "wxt/browser" {
|
|||||||
message.message,
|
message.message,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Include a final union-based override so TS accepts valid string templates or concatinations
|
// Include a final union-based override so TS accepts valid string templates or concatenations
|
||||||
// ie: browser.i18n.getMessage(`some_enum_${enumValue}`)
|
// ie: browser.i18n.getMessage(`some_enum_${enumValue}`)
|
||||||
renderGetMessageOverload(
|
renderGetMessageOverload(
|
||||||
messages.map((message) => `"${message.name}"`).join(' | '),
|
messages.map((message) => `"${message.name}"`).join(' | '),
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export async function registerWxt(
|
|||||||
},
|
},
|
||||||
async reloadConfig() {
|
async reloadConfig() {
|
||||||
wxt.config = await resolveConfig(inlineConfig, command);
|
wxt.config = await resolveConfig(inlineConfig, command);
|
||||||
|
await wxt.hooks.callHook('config:resolved', wxt);
|
||||||
},
|
},
|
||||||
pm,
|
pm,
|
||||||
builder,
|
builder,
|
||||||
@@ -82,6 +83,7 @@ export async function registerWxt(
|
|||||||
}
|
}
|
||||||
|
|
||||||
await wxt.hooks.callHook('ready', wxt);
|
await wxt.hooks.callHook('ready', wxt);
|
||||||
|
await wxt.hooks.callHook('config:resolved', wxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export function defineWxtModule<TOptions extends WxtModuleOptions>(
|
|||||||
/**
|
/**
|
||||||
* Adds a TS/JS file as an entrypoint to the project. This file will be bundled
|
* Adds a TS/JS file as an entrypoint to the project. This file will be bundled
|
||||||
* along with the other entrypoints.
|
* along with the other entrypoints.
|
||||||
|
*
|
||||||
* If you're publishing the module to NPM, you should probably pre-build the
|
* If you're publishing the module to NPM, you should probably pre-build the
|
||||||
* entrypoint and use `addPublicAssets` instead to copy pre-bundled assets into
|
* entrypoint and use `addPublicAssets` instead to copy pre-bundled assets into
|
||||||
* the output directory. This will speed up project builds since it just has to
|
* the output directory. This will speed up project builds since it just has to
|
||||||
@@ -53,7 +53,7 @@ export function defineWxtModule<TOptions extends WxtModuleOptions>(
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
export function addEntrypoint(wxt: Wxt, entrypoint: Entrypoint): void {
|
export function addEntrypoint(wxt: Wxt, entrypoint: Entrypoint): void {
|
||||||
wxt.hooks.hook('entrypoints:resolved', (wxt, entrypoints) => {
|
wxt.hooks.hook('entrypoints:resolved', (_, entrypoints) => {
|
||||||
entrypoints.push(entrypoint);
|
entrypoints.push(entrypoint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ export function addViteConfig(
|
|||||||
wxt: Wxt,
|
wxt: Wxt,
|
||||||
viteConfig: (env: vite.ConfigEnv) => vite.UserConfig | undefined,
|
viteConfig: (env: vite.ConfigEnv) => vite.UserConfig | undefined,
|
||||||
): void {
|
): void {
|
||||||
wxt.hooks.hook('ready', (wxt) => {
|
wxt.hooks.hook('config:resolved', (wxt) => {
|
||||||
const userVite = wxt.config.vite;
|
const userVite = wxt.config.vite;
|
||||||
wxt.config.vite = async (env) => {
|
wxt.config.vite = async (env) => {
|
||||||
const fromUser = await userVite(env);
|
const fromUser = await userVite(env);
|
||||||
@@ -130,7 +130,7 @@ export function addViteConfig(
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
export function addWxtPlugin(wxt: Wxt, plugin: string): void {
|
export function addWxtPlugin(wxt: Wxt, plugin: string): void {
|
||||||
wxt.hooks.hook('ready', (wxt) => {
|
wxt.hooks.hook('config:resolved', (wxt) => {
|
||||||
wxt.config.plugins.push(plugin);
|
wxt.config.plugins.push(plugin);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ export function addImportPreset(
|
|||||||
wxt: Wxt,
|
wxt: Wxt,
|
||||||
preset: UnimportOptions['presets'][0],
|
preset: UnimportOptions['presets'][0],
|
||||||
): void {
|
): void {
|
||||||
wxt.hooks.hook('ready', (wxt) => {
|
wxt.hooks.hook('config:resolved', (wxt) => {
|
||||||
if (!wxt.config.imports) return;
|
if (!wxt.config.imports) return;
|
||||||
|
|
||||||
wxt.config.imports.presets ??= [];
|
wxt.config.imports.presets ??= [];
|
||||||
@@ -205,12 +205,13 @@ export function addImportPreset(
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
export function addAlias(wxt: Wxt, alias: string, path: string) {
|
export function addAlias(wxt: Wxt, alias: string, path: string) {
|
||||||
wxt.hooks.hook('ready', (wxt) => {
|
wxt.hooks.hook('config:resolved', (wxt) => {
|
||||||
const target = resolve(wxt.config.root, path);
|
const target = resolve(wxt.config.root, path);
|
||||||
if (wxt.config.alias[alias] != null) {
|
if (wxt.config.alias[alias] != null && wxt.config.alias[alias] !== target) {
|
||||||
wxt.logger.warn(
|
wxt.logger.warn(
|
||||||
`Skipped adding alias (${alias} => ${target}) because an alias with the same name already exists: ${alias} => ${wxt.config.alias[alias]}`,
|
`Skipped adding alias (${alias} => ${target}) because an alias with the same name already exists: ${alias} => ${wxt.config.alias[alias]}`,
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
wxt.config.alias[alias] = target;
|
wxt.config.alias[alias] = target;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1100,11 +1100,15 @@ export type HookResult = Promise<void> | void;
|
|||||||
|
|
||||||
export interface WxtHooks {
|
export interface WxtHooks {
|
||||||
/**
|
/**
|
||||||
* Called after WXT initialization, when the WXT instance is ready to work.
|
* Called only one time after WXT initialization, when the WXT instance is ready to work.
|
||||||
* @param wxt The configured WXT object
|
* @param wxt The configured WXT object
|
||||||
* @returns Promise
|
|
||||||
*/
|
*/
|
||||||
ready: (wxt: Wxt) => HookResult;
|
ready: (wxt: Wxt) => HookResult;
|
||||||
|
/**
|
||||||
|
* Called whenever config is loaded or reloaded. Use this hook to modify config by modifying `wxt.config`.
|
||||||
|
* @param wxt The configured WXT object
|
||||||
|
*/
|
||||||
|
'config:resolved': (wxt: Wxt) => HookResult;
|
||||||
/**
|
/**
|
||||||
* Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing
|
* Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing
|
||||||
* addition of custom references and declarations in wxt.d.ts, or directly
|
* addition of custom references and declarations in wxt.d.ts, or directly
|
||||||
|
|||||||
Reference in New Issue
Block a user