Skip to content

Commit

Permalink
types!: Rename BackgroundScriptDefintition to BackgroundDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Oct 14, 2023
1 parent 7a46568 commit 446f265
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/guide/auto-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Some WXT APIs can be used without importing them:

- [`browser`](/api/wxt-browser#browser) from `wxt/browser`, a small wrapper around `webextension-polyfill`
- [`defineContentScript`](/api/wxt-client#defiencontentscript) from `wxt/client`
- [`defineBackground`](/api/wxt-client#definebackgroundscript) from `wxt/client`
- [`defineBackground`](/api/wxt-client#definebackground) from `wxt/client`
- [`createContentScriptUi`](/api/wxt-client#createcontentscriptui) from `wxt/client`

And more. All [`wxt/client`](/api/wxt-client) APIs can be used without imports.
Expand Down
12 changes: 6 additions & 6 deletions src/client/defineBackground.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BackgroundScriptDefintition } from '..';
import { BackgroundDefinition } from '..';

export function defineBackground(main: () => void): BackgroundScriptDefintition;
export function defineBackground(main: () => void): BackgroundDefinition;
export function defineBackground(
definition: BackgroundScriptDefintition,
): BackgroundScriptDefintition;
definition: BackgroundDefinition,
): BackgroundDefinition;
export function defineBackground(
arg: (() => void) | BackgroundScriptDefintition,
): BackgroundScriptDefintition {
arg: (() => void) | BackgroundDefinition,
): BackgroundDefinition {
if (typeof arg === 'function') return { main: arg };
return arg;
}
2 changes: 1 addition & 1 deletion src/client/virtual-modules/virtual-module-globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare module '*?raw' {
}

declare module 'virtual:user-background' {
const definition: import('../../').BackgroundScriptDefintition;
const definition: import('../../').BackgroundDefinition;
export default definition;
}

Expand Down
10 changes: 6 additions & 4 deletions src/core/build/findEntrypoints.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { relative, resolve } from 'path';
import {
BackgroundEntrypoint,
BackgroundScriptDefintition,
BackgroundDefinition,
BaseEntrypointOptions,
ContentScriptDefinition,
ContentScriptEntrypoint,
Expand Down Expand Up @@ -295,10 +295,12 @@ async function getBackgroundEntrypoint(
config: InternalConfig,
path: string,
): Promise<BackgroundEntrypoint> {
let options: Omit<BackgroundScriptDefintition, 'main'> = {};
let options: Omit<BackgroundDefinition, 'main'> = {};
if (path !== VIRTUAL_NOOP_BACKGROUND_MODULE_ID) {
const defaultExport =
await importEntrypointFile<BackgroundScriptDefintition>(path, config);
const defaultExport = await importEntrypointFile<BackgroundDefinition>(
path,
config,
);
if (defaultExport == null) {
throw Error('Background script does not have a default export');
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/types/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export interface ContentScriptDefinition extends ExcludableEntrypoint {
main(ctx: ContentScriptContext): void | Promise<void>;
}

export interface BackgroundScriptDefintition extends ExcludableEntrypoint {
export interface BackgroundDefinition extends ExcludableEntrypoint {
type?: PerBrowserOption<'module'>;
persistent?: PerBrowserOption<boolean>;
main(): void;
Expand Down

0 comments on commit 446f265

Please sign in to comment.