Write on the margins of the internet. Powered by the AT Protocol.
margin.at
extension
web
atproto
comments
1import { defineConfig } from 'wxt';
2import { cp } from 'fs/promises';
3import { existsSync } from 'fs';
4import { resolve } from 'path';
5
6export default defineConfig({
7 srcDir: 'src',
8 modules: ['@wxt-dev/module-react'],
9 manifestVersion: 3,
10 hooks: {
11 'build:done': async (wxt) => {
12 const publicDir = resolve(__dirname, 'public');
13 const outDir = wxt.config.outDir;
14
15 if (existsSync(publicDir)) {
16 await cp(publicDir, outDir, { recursive: true });
17 }
18 },
19 },
20 manifest: ({ browser }) => {
21 const basePermissions = ['storage', 'activeTab', 'tabs', 'cookies', 'contextMenus'];
22 const chromePermissions = [...basePermissions, 'sidePanel'];
23
24 return {
25 name: 'Margin',
26 description:
27 'Annotate and highlight any webpage, with your notes saved to the decentralized AT Protocol.',
28 permissions: browser === 'firefox' ? basePermissions : chromePermissions,
29 host_permissions: ['https://margin.at/*', '*://*/*'],
30 icons: {
31 16: '/icons/icon-16.png',
32 32: '/icons/icon-32.png',
33 48: '/icons/icon-48.png',
34 128: '/icons/icon-128.png',
35 },
36 commands: {
37 'open-sidebar': {
38 suggested_key: {
39 default: 'Alt+M',
40 mac: 'Alt+M',
41 },
42 description: 'Open Margin sidebar',
43 },
44 'annotate-selection': {
45 suggested_key: {
46 default: 'Alt+A',
47 mac: 'Alt+A',
48 },
49 description: 'Annotate selected text',
50 },
51 'highlight-selection': {
52 suggested_key: {
53 default: 'Alt+H',
54 mac: 'Alt+H',
55 },
56 description: 'Highlight selected text',
57 },
58 'bookmark-page': {
59 suggested_key: {
60 default: 'Alt+B',
61 mac: 'Alt+B',
62 },
63 description: 'Bookmark current page',
64 },
65 },
66 action: {
67 default_title: 'Margin',
68 default_popup: 'popup.html',
69 default_icon: {
70 16: '/icons/icon-16.png',
71 32: '/icons/icon-32.png',
72 48: '/icons/icon-48.png',
73 128: '/icons/icon-128.png',
74 },
75 },
76 ...(browser === 'chrome'
77 ? {
78 side_panel: {
79 default_path: 'sidepanel.html',
80 },
81 }
82 : {
83 sidebar_action: {
84 default_title: 'Margin',
85 default_panel: 'sidepanel.html',
86 },
87 browser_specific_settings: {
88 gecko: {
89 id: 'hello@margin.at',
90 strict_min_version: '140.0',
91 data_collection_permissions: {
92 required: ['none'],
93 },
94 },
95 },
96 }),
97 };
98 },
99});