Compare commits

..

13 Commits

Author SHA1 Message Date
GitHub Actions 36cfcd0acb chore(release): @wxt-dev/module-solid v1.1.2 2024-08-06 13:07:15 +00:00
GitHub Actions f746d46247 chore(release): @wxt-dev/module-svelte v1.0.1 2024-08-06 12:29:43 +00:00
GitHub Actions a2de6cbe44 chore(release): @wxt-dev/module-vue v1.0.1 2024-08-06 04:23:00 +00:00
GitHub Actions e632a2964a chore(release): @wxt-dev/module-react v1.1.1 2024-08-06 01:55:29 +00:00
GitHub Actions f736a14651 chore(release): @wxt-dev/auto-icons v1.0.2 2024-08-05 23:52:51 +00:00
uncenter a8b0d40959 docs(auto-icons): fix configuration example typo (#905) 2024-08-05 18:48:54 -05:00
Aaron 4c5504d139 Update changelog 2024-08-04 10:18:02 -05:00
GitHub Actions fb86deb388 chore(release): wxt v0.19.4 2024-08-04 14:31:30 +00:00
Aaron 3a8e6135ac fix: Fix createIframeUi page option types 2024-08-04 09:27:46 -05:00
Aaron a38de0c03f feat: Add injectScript helper (#900) 2024-08-04 09:16:46 -05:00
Aaron ea97410fb4 fix(types): PublicPath type resolution with extensionApi: "chrome" (#901) 2024-08-04 08:59:45 -05:00
hikiko4ern e36549ddce fix: do not clear .wxt/tsconfig.json in findEntrypoints if it exists (#898) 2024-08-03 21:59:12 -05:00
KnightYoshi 10851ae01c docs: add missing extension-apis segment (#896) 2024-08-03 19:28:53 -05:00
26 changed files with 202 additions and 35 deletions
+17
View File
@@ -1,5 +1,22 @@
# Changelog
## v1.0.2
[compare changes](https://github.com/wxt-dev/wxt/compare/auto-icons-v1.0.1...auto-icons-v1.0.2)
### 📖 Documentation
- **auto-icons:** Fix configuration example typo ([#905](https://github.com/wxt-dev/wxt/pull/905))
### 🏡 Chore
- Add more metadata for npm ([#885](https://github.com/wxt-dev/wxt/pull/885))
### ❤️ Contributors
- Uncenter ([@uncenter](http://github.com/uncenter))
- Florian Metz ([@Timeraa](http://github.com/Timeraa))
## v1.0.1
[compare changes](https://github.com/wxt-dev/wxt/compare/auto-icons-v1.0.0...auto-icons-v1.0.1)
+1 -1
View File
@@ -32,7 +32,7 @@ The module can be configured via the `autoIcons` config:
```ts
export default defineConfig({
module: ['@wxt-dev/auto-icons'],
modules: ['@wxt-dev/auto-icons'],
autoIcons: {
// ...
},
+1 -1
View File
@@ -24,7 +24,7 @@
}
],
"license": "MIT",
"version": "1.0.1",
"version": "1.0.2",
"type": "module",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
+14
View File
@@ -1,5 +1,19 @@
# Changelog
## v1.1.1
[compare changes](https://github.com/wxt-dev/wxt/compare/module-react-v1.1.0...module-react-v1.1.1)
### 🏡 Chore
- **deps:** Bump all non-major dependencies ([#834](https://github.com/wxt-dev/wxt/pull/834))
- **deps:** Upgrade all dependencies ([#869](https://github.com/wxt-dev/wxt/pull/869))
- Add more metadata for npm ([#885](https://github.com/wxt-dev/wxt/pull/885))
### ❤️ Contributors
- Florian Metz ([@Timeraa](http://github.com/Timeraa))
## v1.1.0
[compare changes](https://github.com/wxt-dev/wxt/compare/module-react-v1.0.0...module-react-v1.1.0)
+1 -1
View File
@@ -17,7 +17,7 @@
"email": "aaronklinker1+wxt@gmail.com"
},
"license": "MIT",
"version": "1.1.0",
"version": "1.1.1",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
+14
View File
@@ -1,5 +1,19 @@
# Changelog
## v1.1.2
[compare changes](https://github.com/wxt-dev/wxt/compare/module-solid-v1.1.1...module-solid-v1.1.2)
### 🏡 Chore
- **deps:** Bump all non-major dependencies ([#834](https://github.com/wxt-dev/wxt/pull/834))
- **deps:** Upgrade all dependencies ([#869](https://github.com/wxt-dev/wxt/pull/869))
- Add more metadata for npm ([#885](https://github.com/wxt-dev/wxt/pull/885))
### ❤️ Contributors
- Florian Metz ([@Timeraa](http://github.com/Timeraa))
## v1.1.1
[compare changes](https://github.com/wxt-dev/wxt/compare/module-solid-v1.1.0...module-solid-v1.1.1)
+1 -1
View File
@@ -17,7 +17,7 @@
"email": "aaronklinker1+wxt@gmail.com"
},
"license": "MIT",
"version": "1.1.1",
"version": "1.1.2",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
+27 -1
View File
@@ -1,5 +1,31 @@
# Changelog
## v1.0.1
[compare changes](https://github.com/wxt-dev/wxt/compare/module-svelte-v1.0.0...module-svelte-v1.0.1)
### 🩹 Fixes
- Upgrade wxt peer to >= 0.18.6 ([7edf1c8](https://github.com/wxt-dev/wxt/commit/7edf1c8))
### 📖 Documentation
- Fix link to unimport ([#826](https://github.com/wxt-dev/wxt/pull/826))
### 🏡 Chore
- Add changelog ([21e8ca0](https://github.com/wxt-dev/wxt/commit/21e8ca0))
- Extract build cache script to NPM package ([#737](https://github.com/wxt-dev/wxt/pull/737))
- **deps:** Upgrade non-major deps ([#778](https://github.com/wxt-dev/wxt/pull/778))
- **deps:** Bump all non-major dependencies ([#834](https://github.com/wxt-dev/wxt/pull/834))
- **deps:** Upgrade all dependencies ([#869](https://github.com/wxt-dev/wxt/pull/869))
- Add more metadata for npm ([#885](https://github.com/wxt-dev/wxt/pull/885))
### ❤️ Contributors
- Florian Metz ([@Timeraa](http://github.com/Timeraa))
- Eetann ([@eetann](http://github.com/eetann))
## v1.0.0
Initial release 🎉
Initial release 🎉
+1 -1
View File
@@ -17,7 +17,7 @@
"email": "aaronklinker1+wxt@gmail.com"
},
"license": "MIT",
"version": "1.0.0",
"version": "1.0.1",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
+22 -1
View File
@@ -1,5 +1,26 @@
# Changelog
## v1.0.1
[compare changes](https://github.com/wxt-dev/wxt/compare/module-vue-v1.0.0...module-vue-v1.0.1)
### 🩹 Fixes
- Upgrade wxt peer to >= 0.18.6 ([7edf1c8](https://github.com/wxt-dev/wxt/commit/7edf1c8))
### 🏡 Chore
- Add changelog ([21e8ca0](https://github.com/wxt-dev/wxt/commit/21e8ca0))
- Extract build cache script to NPM package ([#737](https://github.com/wxt-dev/wxt/pull/737))
- **deps:** Upgrade non-major deps ([#778](https://github.com/wxt-dev/wxt/pull/778))
- **deps:** Bump all non-major dependencies ([#834](https://github.com/wxt-dev/wxt/pull/834))
- **deps:** Upgrade all dependencies ([#869](https://github.com/wxt-dev/wxt/pull/869))
- Add more metadata for npm ([#885](https://github.com/wxt-dev/wxt/pull/885))
### ❤️ Contributors
- Florian Metz ([@Timeraa](http://github.com/Timeraa))
## v1.0.0
Initial release 🎉
Initial release 🎉
+1 -1
View File
@@ -17,7 +17,7 @@
"email": "aaronklinker1+wxt@gmail.com"
},
"license": "MIT",
"version": "1.0.0",
"version": "1.0.1",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
+20 -2
View File
@@ -1,5 +1,23 @@
# Changelog
## v0.19.4
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.19.3...wxt-v0.19.4)
### 🚀 Enhancements
- Add `injectScript` helper ([#900](https://github.com/wxt-dev/wxt/pull/900))
### 🩹 Fixes
- Do not clear `.wxt/tsconfig.json` in `findEntrypoints` if it exists ([#898](https://github.com/wxt-dev/wxt/pull/898))
- **types:** `PublicPath` type resolution with `extensionApi: "chrome"` ([#901](https://github.com/wxt-dev/wxt/pull/901))
- Fix `createIframeUi` `page` option types ([3a8e613](https://github.com/wxt-dev/wxt/commit/3a8e613))
### ❤️ Contributors
- Hikiko4ern ([@hikiko4ern](http://github.com/hikiko4ern))
## v0.19.3
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.19.2...wxt-v0.19.3)
@@ -16,7 +34,7 @@
### ❤️ Contributors
- Hikiko4ern ([@hikiko4ern](http://github.com/hikiko4ern))
- Himanshu Patil <himanshupatil744@gmail.com>
- Himanshu Patil ([@mehimanshupatil](https://github.com/mehimanshupatil))
## v0.19.2
@@ -2335,4 +2353,4 @@ Initial release of WXT. Full support for production builds and initial toolkit f
### 🤖 CI
- Create validation workflow ([#12](https://github.com/wxt-dev/wxt/pull/12))
- Create release workflow ([#13](https://github.com/wxt-dev/wxt/pull/13))
- Create release workflow ([#13](https://github.com/wxt-dev/wxt/pull/13))
@@ -19,6 +19,7 @@ exports[`Auto Imports > eslintrc > "enabled: 8" should output a JSON config file
"defineUnlistedScript": true,
"defineWxtPlugin": true,
"fakeBrowser": true,
"injectScript": true,
"storage": true,
"useAppConfig": true
}
@@ -44,6 +45,7 @@ const globals = {
"defineUnlistedScript": true,
"defineWxtPlugin": true,
"fakeBrowser": true,
"injectScript": true,
"storage": true,
"useAppConfig": true
}
@@ -77,6 +79,7 @@ exports[`Auto Imports > eslintrc > "enabled: true" should output a JSON config f
"defineUnlistedScript": true,
"defineWxtPlugin": true,
"fakeBrowser": true,
"injectScript": true,
"storage": true,
"useAppConfig": true
}
@@ -103,6 +106,7 @@ exports[`Auto Imports > eslintrc > should allow customizing the output 1`] = `
"defineUnlistedScript": "readonly",
"defineWxtPlugin": "readonly",
"fakeBrowser": "readonly",
"injectScript": "readonly",
"storage": "readonly",
"useAppConfig": "readonly"
}
@@ -31,6 +31,7 @@ describe('Auto Imports', () => {
const defineUnlistedScript: typeof import('wxt/sandbox')['defineUnlistedScript']
const defineWxtPlugin: typeof import('wxt/sandbox')['defineWxtPlugin']
const fakeBrowser: typeof import('wxt/testing')['fakeBrowser']
const injectScript: typeof import('wxt/client')['injectScript']
const storage: typeof import('wxt/storage')['storage']
const useAppConfig: typeof import('wxt/client')['useAppConfig']
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "wxt",
"type": "module",
"version": "0.19.3",
"version": "0.19.4",
"description": "Next gen framework for developing web extensions",
"repository": {
"type": "git",
+2 -7
View File
@@ -1,4 +1,6 @@
/// <reference types="chrome" />
import type { WxtRuntime, WxtI18n } from './index';
/**
* EXPERIMENTAL
*
@@ -7,13 +9,6 @@
* @module wxt/browser/chrome
*/
export interface WxtRuntime {
// Overriden per-project
}
export interface WxtI18n {
// Overriden per-project
}
export type Chrome = typeof chrome;
export type WxtBrowser = Omit<Chrome, 'runtime' | 'i18n'> & {
runtime: WxtRuntime & Omit<Chrome['runtime'], 'getURL'>;
+7 -7
View File
@@ -4,18 +4,18 @@
* @module wxt/browser
*/
import originalBrowser, { Browser, Runtime, I18n } from 'webextension-polyfill';
import originalBrowser, { Browser } from 'webextension-polyfill';
export interface AugmentedBrowser extends Browser {
runtime: WxtRuntime;
i18n: WxtI18n;
}
export type AugmentedBrowser = Omit<Browser, 'runtime' | 'i18n'> & {
runtime: WxtRuntime & Omit<Browser['runtime'], 'getURL'>;
i18n: WxtI18n & Omit<Browser['i18n'], 'getMessage'>;
};
export interface WxtRuntime extends Runtime.Static {
export interface WxtRuntime {
// Overriden per-project
}
export interface WxtI18n extends I18n.Static {
export interface WxtI18n {
// Overriden per-project
}
@@ -62,6 +62,7 @@ export function createIframeUi<TMounted>(
const wrapper = document.createElement('div');
wrapper.setAttribute('data-wxt-iframe', '');
const iframe = document.createElement('iframe');
// @ts-expect-error: getURL is defined per-project, but not inside the package
iframe.src = browser.runtime.getURL(options.page);
wrapper.appendChild(iframe);
@@ -258,6 +259,7 @@ function mountUi(
* Load the CSS for the current entrypoint.
*/
async function loadCss(): Promise<string> {
// @ts-expect-error: getURL is defined per-project, but not inside the package
const url = browser.runtime.getURL(
`/content-scripts/${import.meta.env.ENTRYPOINT}.css`,
);
@@ -83,7 +83,8 @@ export type IframeContentScriptUiOptions<TMounted> =
* The path to the HTML page that will be shown in the iframe. This string is passed into
* `browser.runtime.getURL`.
*/
page: PublicPath;
// @ts-expect-error: HtmlPublicPath is generated per-project
page: import('wxt/browser').HtmlPublicPath;
/**
* Callback executed when mounting the UI. Use this function to customize the iframe or wrapper
* element's appearance. It is called every time `ui.mount()` is called.
+1
View File
@@ -5,3 +5,4 @@
*/
export * from './content-scripts';
export * from './app-config';
export * from './inject-script';
+47
View File
@@ -0,0 +1,47 @@
import { browser } from 'wxt/browser';
export type ScriptPublicPath = Extract<
// @ts-expect-error: PublicPath is generated per-project
import('wxt/browser').PublicPath,
`${string}.js`
>;
/**
* This function can only be called inside content scripts.
*
* Inject an unlisted script into the page. Scripts are added to the `<head>`
* element or `document.documentElement` if there is no head.
*
* Make sure to add the injected script to your manifest's
* `web_accessible_resources`.
*/
export async function injectScript(
path: ScriptPublicPath,
options?: InjectScriptOptions,
): Promise<void> {
// @ts-expect-error: getURL is defined per-project, but not inside the package
const url = browser.runtime.getURL(path);
const script = document.createElement('script');
if (browser.runtime.getManifest().manifest_version === 2) {
// MV2 requires using an inline script
script.innerHTML = await fetch(url).then((res) => res.text());
} else {
// MV3 requires using src
script.src = url;
}
if (!options?.keepInDom) {
script.onload = () => script.remove();
}
(document.head ?? document.documentElement).append(script);
}
export interface InjectScriptOptions {
/**
* By default, the injected script is removed from the DOM after being
* injected. To disable this behavior, set this flag to true.
*/
keepInDom?: boolean;
}
@@ -36,7 +36,17 @@ import { createExtensionEnvironment } from '../environments';
export async function findEntrypoints(): Promise<Entrypoint[]> {
// Make sure required TSConfig file exists to load dependencies
await fs.mkdir(wxt.config.wxtDir, { recursive: true });
await fs.writeJson(resolve(wxt.config.wxtDir, 'tsconfig.json'), {});
try {
await fs.writeJson(
resolve(wxt.config.wxtDir, 'tsconfig.json'),
{},
{ flag: 'wx' },
);
} catch (err) {
if (!(err instanceof Error) || !('code' in err) || err.code !== 'EEXIST') {
throw err;
}
}
const relativePaths = await glob(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
cwd: wxt.config.entrypointsDir,
@@ -94,9 +94,9 @@ async function getPathsDeclarationEntry(
.join('\n');
const template = `// Generated by wxt
import "${wxt.config.browserModule}";
import "wxt/browser";
declare module "${wxt.config.browserModule}" {
declare module "wxt/browser" {
export type PublicPath =
{{ union }}
type HtmlPublicPath = Extract<PublicPath, \`\${string}.html\`>
@@ -117,9 +117,9 @@ declare module "${wxt.config.browserModule}" {
async function getI18nDeclarationEntry(): Promise<WxtDirFileEntry> {
const defaultLocale = wxt.config.manifest.default_locale;
const template = `// Generated by wxt
import "${wxt.config.browserModule}";
import "wxt/browser";
declare module "${wxt.config.browserModule}" {
declare module "wxt/browser" {
/**
* See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
*/
@@ -183,8 +183,6 @@ export async function resolveConfig(
userConfigMetadata: userConfigMetadata ?? {},
alias,
extensionApi,
browserModule:
extensionApi === 'chrome' ? 'wxt/browser/chrome' : 'wxt/browser',
entrypointLoader: mergedConfig.entrypointLoader ?? 'vite-node',
experimental: defu(mergedConfig.experimental, {}),
dev: {
@@ -297,7 +297,6 @@ export const fakeResolvedConfig = fakeObjectCreator<ResolvedConfig>(() => {
userConfigMetadata: {},
alias: {},
extensionApi: 'webextension-polyfill',
browserModule: 'wxt/browser',
entrypointLoader: 'vite-node',
experimental: {},
dev: {
-1
View File
@@ -1215,7 +1215,6 @@ export interface ResolvedConfig {
*/
alias: Record<string, string>;
extensionApi: 'webextension-polyfill' | 'chrome';
browserModule: 'wxt/browser' | 'wxt/browser/chrome';
entrypointLoader: 'vite-node' | 'jiti';
experimental: {};
dev: {