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 web_accessible_resources: [
31 {
32 resources: ['pdfjs/*'],
33 matches: ['<all_urls>'],
34 },
35 ],
36 icons: {
37 16: '/icons/icon-16.png',
38 32: '/icons/icon-32.png',
39 48: '/icons/icon-48.png',
40 128: '/icons/icon-128.png',
41 },
42 commands: {
43 'toggle-sidebar': {
44 suggested_key: {
45 default: 'Alt+M',
46 mac: 'Alt+M',
47 },
48 description: 'Toggle Margin sidebar',
49 },
50 'annotate-selection': {
51 suggested_key: {
52 default: 'Alt+A',
53 mac: 'Alt+A',
54 },
55 description: 'Annotate selected text',
56 },
57 'highlight-selection': {
58 suggested_key: {
59 default: 'Alt+H',
60 mac: 'Alt+H',
61 },
62 description: 'Highlight selected text',
63 },
64 'bookmark-page': {
65 suggested_key: {
66 default: 'Alt+B',
67 mac: 'Alt+B',
68 },
69 description: 'Bookmark current page',
70 },
71 },
72 action: {
73 default_title: 'Margin',
74 default_popup: 'popup.html',
75 default_icon: {
76 16: '/icons/icon-16.png',
77 32: '/icons/icon-32.png',
78 48: '/icons/icon-48.png',
79 128: '/icons/icon-128.png',
80 },
81 },
82 ...(browser === 'chrome'
83 ? {
84 side_panel: {
85 default_path: 'sidepanel.html',
86 },
87 }
88 : {
89 sidebar_action: {
90 default_title: 'Margin',
91 default_panel: 'sidepanel.html',
92 },
93 browser_specific_settings: {
94 gecko: {
95 id: 'hello@margin.at',
96 strict_min_version: '140.0',
97 data_collection_permissions: {
98 required: ['none'],
99 },
100 },
101 },
102 }),
103 };
104 },
105});