aboutsummaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-12-01 21:00:49 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2023-12-01 21:00:49 -0500
commit54984ef915a3bf640e06015bd294bd2186b3a588 (patch)
tree51bc8384138a5eca389186f178fa5fd669cf3916 /extension
parentc4205bfe23dc321c77e2ff032fcb355d16e5d6c0 (diff)
internal polish, minor refactors & manifest v3 progression
Diffstat (limited to 'extension')
-rw-r--r--extension/README.md61
-rw-r--r--extension/src/entries/background/serviceWorker.js (renamed from extension/src/entries/background/serviceWorker.ts)2
-rw-r--r--extension/src/entries/contentScript/primary/components/PromptPopup.vue7
-rw-r--r--extension/src/entries/contentScript/primary/main.js4
-rw-r--r--extension/src/entries/store/identity.ts1
-rw-r--r--extension/src/manifest.js6
-rw-r--r--extension/tsconfig.json2
7 files changed, 18 insertions, 65 deletions
diff --git a/extension/README.md b/extension/README.md
index 36b26c2..a476f96 100644
--- a/extension/README.md
+++ b/extension/README.md
@@ -1,65 +1,20 @@
# @vnuge/nvault-extension
-This template should help get you started developing a vue web extension in Vite.
+This directory contains the source code for the NVault browser extension. Base template forked from [@samrum/vite-plugin-web-extension](https://github.com/samrum/vite-plugin-web-extension)
## Usage Notes
+The .env file contains build configuration variables. API variables are used as defaults on extension startup. Most settings such as server base url and endpoint urls are configurable from the extension options page.
-The extension manifest is defined in `src/manifest.js` and used by `@samrum/vite-plugin-web-extension` in the vite config.
+### Install dependencies
-Background, content scripts, options, and popup entry points exist in the `src/entries` directory.
-
-Content scripts are rendered by `src/entries/contentScript/renderContent.js` which renders content within a ShadowRoot
-and handles style injection for HMR and build modes.
-
-Otherwise, the project functions just like a regular Vite project.
-
-To switch between Manifest V2 and Manifest V3 builds, use the MANIFEST_VERSION environment variable defined in `.env`
-
-HMR during development in Manifest V3 requires Chromium version >= 110.0.5480.0.
-
-Refer to [@samrum/vite-plugin-web-extension](https://github.com/samrum/vite-plugin-web-extension) for more usage notes.
-
-## Customize configuration
-
-See [Vite Configuration Reference](https://vitejs.dev/config/).
-
-## Project Setup
-
-```sh
+```bash
npm install
```
-## Commands
-### Build
-#### Development, HMR
-
-Hot Module Reloading is used to load changes inline without requiring extension rebuilds and extension/page reloads
-Currently only works in Chromium based browsers.
-```sh
-npm run dev
-```
-
-#### Development, Watch
-
-Rebuilds extension on file changes. Requires a reload of the extension (and page reload if using content scripts)
-```sh
-npm run watch
-```
-
-#### Production
-
-Minifies and optimizes extension build
-```sh
+### Build the extension
+
+```bash
npm run build
```
-### Load extension in browser
-
-Loads the contents of the dist directory into the specified browser
-```sh
-npm run serve:chrome
-```
-
-```sh
-npm run serve:firefox
-```
+Built extension output will be in the `dist` directory. You can zip the contents of this directory and load it into your browser. \ No newline at end of file
diff --git a/extension/src/entries/background/serviceWorker.ts b/extension/src/entries/background/serviceWorker.js
index cb6f42a..b0211d1 100644
--- a/extension/src/entries/background/serviceWorker.ts
+++ b/extension/src/entries/background/serviceWorker.js
@@ -13,4 +13,4 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-import "./main";
+import "./main.ts";
diff --git a/extension/src/entries/contentScript/primary/components/PromptPopup.vue b/extension/src/entries/contentScript/primary/components/PromptPopup.vue
index d019b5d..156dfb8 100644
--- a/extension/src/entries/contentScript/primary/components/PromptPopup.vue
+++ b/extension/src/entries/contentScript/primary/components/PromptPopup.vue
@@ -85,12 +85,13 @@
<script setup lang="ts">
import { ref } from 'vue'
-import { usePrompt, type UserPermissionRequest } from '../../util'
+import { debugLog } from '@vnuge/vnlib.browser';
+import { storeToRefs } from 'pinia';
import { computed } from 'vue';
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'
import { clone, first } from 'lodash';
+import { usePrompt, type UserPermissionRequest } from '../../util'
import { useStore } from '../../../store';
-import { storeToRefs } from 'pinia';
const store = useStore()
const { loggedIn, selectedKey, darkMode } = storeToRefs(store)
@@ -127,7 +128,7 @@ usePrompt((ev: UserPermissionRequest):Promise<boolean> => {
ev = clone(ev)
- console.log('[usePrompt] =>', ev)
+ debugLog('[usePrompt] =>', ev)
switch(ev.type){
case 'getPublicKey':
diff --git a/extension/src/entries/contentScript/primary/main.js b/extension/src/entries/contentScript/primary/main.js
index 16cc6fc..bbe5edf 100644
--- a/extension/src/entries/contentScript/primary/main.js
+++ b/extension/src/entries/contentScript/primary/main.js
@@ -51,12 +51,12 @@ renderContent([], (appRoot, shadowRoot) => {
//Add tailwind styles just to the shadow dom element
const style = document.createElement('style')
- style.innerHTML = tw.toString()
+ style.textContent = tw.toString()
shadowRoot.appendChild(style)
//Add local styles
const style2 = document.createElement('style')
- style2.innerHTML = localStyle.toString()
+ style2.textContent = localStyle.toString()
shadowRoot.appendChild(style2)
createApp(App)
diff --git a/extension/src/entries/store/identity.ts b/extension/src/entries/store/identity.ts
index b1635f2..ef1941e 100644
--- a/extension/src/entries/store/identity.ts
+++ b/extension/src/entries/store/identity.ts
@@ -25,7 +25,6 @@ export const identityPlugin = ({ store }: PiniaPluginContext) => {
const selectedKey = shallowRef<NostrPubKey | undefined>(undefined)
onWatchableChange(identity, async () => {
- console.log('Identity changed')
allKeys.value = await identity.getAllKeys();
selectedKey.value = await identity.getPublicKey();
}, { immediate:true })
diff --git a/extension/src/manifest.js b/extension/src/manifest.js
index 6c96f41..f4c38fc 100644
--- a/extension/src/manifest.js
+++ b/extension/src/manifest.js
@@ -41,20 +41,18 @@ const sharedManifest = {
'activeTab',
],
-
browser_specific_settings: {
"gecko": {
- "id": "{fdacee2c-bab4-490d-bc4b-ecdd03d5d68a}"
+ "id": "{d71bf2c0-7485-4572-b1a5-c5dd2c5f16d5}"
}
},
- "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self';"
+ "content_security_policy": "script-src 'self'; object-src 'self';"
};
const browserAction = {
default_icon: {
16: "icons/16.png",
- 19: "icons/19.png",
32: "icons/32.png",
38: "icons/38.png",
},
diff --git a/extension/tsconfig.json b/extension/tsconfig.json
index ca3b4f0..ea75d8b 100644
--- a/extension/tsconfig.json
+++ b/extension/tsconfig.json
@@ -23,5 +23,5 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
- "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/entries/background/serviceWorker.js"],
}