From 54984ef915a3bf640e06015bd294bd2186b3a588 Mon Sep 17 00:00:00 2001 From: vnugent Date: Fri, 1 Dec 2023 21:00:49 -0500 Subject: internal polish, minor refactors & manifest v3 progression --- extension/README.md | 61 +++------------------- extension/src/entries/background/serviceWorker.js | 16 ++++++ extension/src/entries/background/serviceWorker.ts | 16 ------ .../primary/components/PromptPopup.vue | 7 +-- .../src/entries/contentScript/primary/main.js | 4 +- extension/src/entries/store/identity.ts | 1 - extension/src/manifest.js | 6 +-- extension/tsconfig.json | 2 +- 8 files changed, 33 insertions(+), 80 deletions(-) create mode 100644 extension/src/entries/background/serviceWorker.js delete mode 100644 extension/src/entries/background/serviceWorker.ts (limited to 'extension') 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.js b/extension/src/entries/background/serviceWorker.js new file mode 100644 index 0000000..b0211d1 --- /dev/null +++ b/extension/src/entries/background/serviceWorker.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Vaughn Nugent +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import "./main.ts"; diff --git a/extension/src/entries/background/serviceWorker.ts b/extension/src/entries/background/serviceWorker.ts deleted file mode 100644 index cb6f42a..0000000 --- a/extension/src/entries/background/serviceWorker.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Vaughn Nugent -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import "./main"; 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 @@