diff --git a/docs/.vitepress/components/ExampleList.vue b/docs/.vitepress/components/ExampleList.vue deleted file mode 100644 index 717a4d2a..00000000 --- a/docs/.vitepress/components/ExampleList.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - diff --git a/docs/.vitepress/components/ExampleSearch.vue b/docs/.vitepress/components/ExampleSearch.vue new file mode 100644 index 00000000..03b319c2 --- /dev/null +++ b/docs/.vitepress/components/ExampleSearch.vue @@ -0,0 +1,226 @@ + + + + + diff --git a/docs/.vitepress/components/ExampleSearchFilterByItem.vue b/docs/.vitepress/components/ExampleSearchFilterByItem.vue new file mode 100644 index 00000000..23b387be --- /dev/null +++ b/docs/.vitepress/components/ExampleSearchFilterByItem.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/docs/.vitepress/components/ExampleSearchResult.vue b/docs/.vitepress/components/ExampleSearchResult.vue new file mode 100644 index 00000000..b46c6d1e --- /dev/null +++ b/docs/.vitepress/components/ExampleSearchResult.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index b8d1137c..1b6f968d 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -78,7 +78,6 @@ export default defineConfig({ menuItem('Configuration', 'configuration'), menuItem('Entrypoints', 'entrypoints'), menuItem('Assets', 'assets'), - menuItem('Testing', 'testing'), menuItem('Publishing', 'publishing'), menuItem('Migrate to WXT', 'migrate-to-wxt'), menuItem('Compare', 'compare'), diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 6d9cc4f3..883b411a 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -2,7 +2,7 @@ import DefaultTheme from 'vitepress/theme'; import Icon from '../components/Icon.vue'; import EntrypointPatterns from '../components/EntrypointPatterns.vue'; import UsingWxtSection from '../components/UsingWxtSection.vue'; -import ExampleList from '../components/ExampleList.vue'; +import ExampleSearch from '../components/ExampleSearch.vue'; import './custom.css'; export default { @@ -11,6 +11,6 @@ export default { ctx.app.component('Icon', Icon); ctx.app.component('EntrypointPatterns', EntrypointPatterns); ctx.app.component('UsingWxtSection', UsingWxtSection); - ctx.app.component('ExampleList', ExampleList); + ctx.app.component('ExampleSearch', ExampleSearch); }, }; diff --git a/docs/.vitepress/utils/types.ts b/docs/.vitepress/utils/types.ts new file mode 100644 index 00000000..ed3460ef --- /dev/null +++ b/docs/.vitepress/utils/types.ts @@ -0,0 +1,18 @@ +export interface Example { + name: string; + description?: string; + url: string; + searchText: string; + apis: string[]; + permissions: string[]; + packages: string[]; +} + +export type ExamplesMetadata = { + examples: Example[]; + allApis: string[]; + allPermissions: string[]; + allPackages: string[]; +}; + +export type KeySelectedObject = Record; diff --git a/docs/examples.md b/docs/examples.md index a464f711..66385e6d 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -1,7 +1,19 @@ -# Examples +--- +layout: page +--- -Simple walkthroughs to accomplish common tasks or patterns with WXT. + - +
+
+

Examples

+
-> Full code available at [`wxt-dev/examples`](https://github.com/wxt-dev/examples) +
+ + +
diff --git a/docs/get-started/testing.md b/docs/get-started/testing.md deleted file mode 100644 index 27d88fd6..00000000 --- a/docs/get-started/testing.md +++ /dev/null @@ -1,25 +0,0 @@ -# Testing - -## Official Frameworks - -WXT officially supports [Vitest](https://vitest.dev/) for unit tests and either [Playwright](https://playwright.dev/) or [Puppeteer](https://pptr.dev/) for E2E tests against Chromium browsers. - -For details setting up each testing framework, see the official examples: - - - -## Unofficial Frameworks - -Puppeteer and Playwright are the only E2E test runners that support Chrome Extensions. There are no other options at the time of writing. - -There are other options for unit tests however, like [Jest](https://jestjs.io/), [Mocha](https://mochajs.org/), or [`node:test`](https://nodejs.org/api/test.html). **_WXT does not claim to support any of them_** because none of them support all of WXT's features, like TypeScript or auto-imports. - -If you want to try to use a different framework for unit tests, you will need to configure the environment manually: - -- **Auto-imports**: Add `unimport` to your test environment or disable them by setting `imports: false` in your `wxt.config.ts` file -- **`browser` mock**: Mock the `webextension-polyfill` module globally with `wxt/dist/virtual/mock-browser.js` -- **[Remote Code Bundling](/guide/go-further/remote-code)**: If you use it, configure your environment to handle the `url:` module prefix -- **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/packages/wxt/src/testing/wxt-vitest-plugin.ts) for reference. diff --git a/docs/guide/directory-structure/entrypoints/devtools.md b/docs/guide/directory-structure/entrypoints/devtools.md index a93fea09..da3cda04 100644 --- a/docs/guide/directory-structure/entrypoints/devtools.md +++ b/docs/guide/directory-structure/entrypoints/devtools.md @@ -37,4 +37,4 @@ Chrome extensions allow you to add panels and side panes to the devtools window. See the WXT's examples for a full walkthrough of extending the devtools window: - +- [Devtools Setup](https://github.com/wxt-dev/wxt-examples/tree/main/examples/vanilla-devtools#readme) diff --git a/docs/guide/go-further/testing.md b/docs/guide/go-further/testing.md index 37e1848c..96250b5b 100644 --- a/docs/guide/go-further/testing.md +++ b/docs/guide/go-further/testing.md @@ -6,7 +6,9 @@ WXT officially supports [Vitest](https://vitest.dev/) for unit tests and either For details setting up each testing framework, see the official examples: - +- [Vitest](https://github.com/wxt-dev/wxt-examples/tree/main/examples/vanilla-vitest#readme) +- [Playwright](https://github.com/wxt-dev/wxt-examples/tree/main/examples/vanilla-playwright#readme) +- [Puppeteer](https://github.com/wxt-dev/wxt-examples/tree/main/examples/vanilla-puppeteer#readme) ### Unofficial Frameworks diff --git a/docs/guide/key-concepts/manifest.md b/docs/guide/key-concepts/manifest.md index 6060e9aa..cfdbe6af 100644 --- a/docs/guide/key-concepts/manifest.md +++ b/docs/guide/key-concepts/manifest.md @@ -176,7 +176,8 @@ export default defineConfig({ See the official localization examples for more details: - +- [I18n](https://github.com/wxt-dev/wxt-examples/tree/main/examples/vanilla-i18n#readme) +- [Vue I18n](https://github.com/wxt-dev/wxt-examples/tree/main/examples/vue-i18n#readme) ## Actions