UNPKG

adnbn

Version:

Addon Bone - Cross-browser web extension framework with shared code base

43 lines 1.07 kB
import { setActionPopup, setActionTitle } from "@addon-core/browser"; import { __t } from "./../locale/helpers.js"; import { changeActionIcon } from "./icon.js"; const definePopup = (options) => { return options; }; const getPopups = () => { const popups = /* @__PURE__ */ new Map(); try { Object.entries(__ADNBN_POPUP_MAP__).forEach(([key, value]) => { popups.set(key, value); }); } catch (e) { console.error("Failed getting popups: ", e); } return popups; }; const changePopup = async (alias, tab) => { const popup = getPopups().get(alias); if (!popup) { throw new Error(`Not found popup: "${alias}"`); } if (tab && typeof tab === "object") { tab = tab.id; } const { path, title, icon } = popup; if (!path) { throw new Error(`Not found popup path: "${alias}"`); } await setActionPopup(path, tab); if (title) { await setActionTitle(__t(title), tab); } if (icon) { await changeActionIcon(icon, tab); } }; export { changePopup, definePopup, getPopups }; //# sourceMappingURL=popup.js.map