Files
wxt/src/virtual/content-script-main-world-entrypoint.ts
T
2024-04-19 20:31:32 -05:00

22 lines
703 B
TypeScript

import definition from 'virtual:user-content-script-main-world-entrypoint';
import { logger } from '../sandbox/utils/logger';
const result = (async () => {
try {
const { main } = definition;
return await main();
} catch (err) {
logger.error(
`The content script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
err,
);
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;