diff --git a/.gitignore b/.gitignore index 20c3880d..33c8c333 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ node_modules -dist-mv2 -dist-mv2-safari -dist-mv3 +dist web-ext-artifacts .parcel-cache workspace.code-workspace diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 18aeafb0..931eaa14 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,53 +1,61 @@ # Contributing -## Installation +Welcome! This guide will help you install and run the extension for development. -```bash -npm install -``` +## Setup -## Running the extension +### Prerequisites -Depending on the target browser, you need to build the extension for Manifest -version 2 or 3. +- [Node.js](https://nodejs.org/en/download/) `^20` +- [npm](https://www.npmjs.com/get-npm) -This can be done with: +### Install -- `npm run-script watch` - where the extension will be built into the directory - `dist-mv2` -- `npm run-script watch:mv3` - where the extension will be built into the - directory `dist-mv3` +Clone and cd into the repository: -You can then follow the guide for how to load the extension into your browser of -choice. +```bash +git clone https://github.com/david-tejada/rango.git +cd rango +``` -The project includes scripts for running the extension in Firefox and Chromium -using the [WebExtension tool](https://github.com/mozilla/web-ext) for your -convenience. +Install dependencies: -### Firefox +```bash +npm install +``` + +### Run the extension for development + +The following command will build the extension for development and launch a +Firefox instance using [mozilla/web-ext](https://github.com/mozilla/web-ext). ```bash -npm run-script watch -npm run-script start:firefox +npm run dev ``` -### Chrome & Chromium Browsers +You can also run the extension in Chrome. Note that in Chrome content scripts +don't reload when the extension changes, so you need to refresh the page every +time there is a change in the extension's code: -By default `start:chromium` will launch Google Chrome: +First build the extension in watch mode: ```bash -npm run-script watch:mv3 -npm run-script start:chromium +npm run watch:chrome ``` -To launch alternative Chromium browsers like Edge or Brave you can append the -path to the binary suitable for your operating system: +Then, in another terminal, run the extension: -_This example is for launching Brave on MacOS_ +```bash +npm run start:chrome +``` + +To launch alternative Chromium browsers like Edge or Brave you can use the flag +`--chromium-binary` and append the path to the binary suitable for your +operating system: ```bash -npm run-script start:chromium -- --chromium-binary /Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser +# Launch Brave on MacOS +npm run start:chrome -- --chromium-binary /Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser ``` ### Safari @@ -63,10 +71,10 @@ or To build for development: -1. Build the extension for manifest version 2: +1. Build the extension for Safari in watch mode: ```bash - npm run build:mv2-safari + npm run watch:safari ``` 2. Update the project's marketing version from the manifest. @@ -89,6 +97,18 @@ To build for development: 5. Edit `Build` » `UserSpecific.xcconfig` according to the comments in the file. -6. Build and run the project. +6. At this point the files produced by the build process might not match the + ones specified in `Rango/Rango for Safari.xcodeproj/project.pbxproj`. If + that's the case some of them will be marked in red. In that case, in Xcode, + select all the files inside `Shared (Extension)/Resources` and delete them + (select `Remove References` when prompted). Then, right click on `Resources` + and select `Add Files to "Rango for Safari"`. Select all the files within + `dist/safari`. Make sure that only `Rango for Safari Extension (macOS)` is + checked in the `Targets` section. + +7. Build the project (`cmd-b`). + +8. Enable the extension in Safari’s Preferences. -7. Enable the extension in Safari’s Preferences. +9. After making changes to the extension, you need to run the build process + again and refresh the page in Safari. diff --git a/Rango/Build/UpdateRangoVersion.swift b/Rango/Build/UpdateRangoVersion.swift index 19554421..b8580a75 100644 --- a/Rango/Build/UpdateRangoVersion.swift +++ b/Rango/Build/UpdateRangoVersion.swift @@ -16,21 +16,29 @@ let PROJECT_DIR = FilePath(CommandLine.arguments[0]) .removingLastComponent() .removingLastComponent() -let manifestPath = PROJECT_DIR - .appending("..") - .appending("dist-mv2-safari") - .appending("manifest.json") - .string - -let manifestURL = URL(fileURLWithPath: manifestPath) -let jsonData = try Data(contentsOf: manifestURL) -let manifest = try JSONDecoder().decode(Manifest.self, from: jsonData) - -let xcconfigPath = PROJECT_DIR - .appending("Build") - .appending("RangoVersion.xcconfig") - .string - -try "MARKETING_VERSION = \(manifest.version)\n" - .write(toFile: xcconfigPath, atomically: false, encoding: .utf8) +do { + let manifestPath = PROJECT_DIR + .appending("..") + .appending("dist") + .appending("safari") + .appending("manifest.json") + .string + + let manifestURL = URL(fileURLWithPath: manifestPath) + let jsonData = try Data(contentsOf: manifestURL) + let manifest = try JSONDecoder().decode(Manifest.self, from: jsonData) + + let xcconfigPath = PROJECT_DIR + .appending("Build") + .appending("RangoVersion.xcconfig") + .string + + try "MARKETING_VERSION = \(manifest.version)\n" + .write(toFile: xcconfigPath, atomically: false, encoding: .utf8) + + print("\u{001B}[32m[SUCCESS]\u{001B}[0m Updated Rango \u{001B}[3mMARKETING_VERSION\u{001B}[0m in \u{001B}[3m\(xcconfigPath)\u{001B}[0m to \(manifest.version)") +} catch { + print("\u{001B}[31m[ERROR]\u{001B}[0m Failed to update version: \(error.localizedDescription)") + exit(1) +} diff --git a/Rango/Rango for Safari.xcodeproj/project.pbxproj b/Rango/Rango for Safari.xcodeproj/project.pbxproj index 5b5b765d..c57d8691 100644 --- a/Rango/Rango for Safari.xcodeproj/project.pbxproj +++ b/Rango/Rango for Safari.xcodeproj/project.pbxproj @@ -7,23 +7,22 @@ objects = { /* Begin PBXBuildFile section */ - 63A9F3B92D0AF8AB0082F9FC /* offscreen.a61bb80b.html in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B12D0AF8AB0082F9FC /* offscreen.a61bb80b.html */; }; - 63A9F3BA2D0AF8AB0082F9FC /* settings.e932913c.js in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B52D0AF8AB0082F9FC /* settings.e932913c.js */; }; - 63A9F3BB2D0AF8AB0082F9FC /* onboarding.b6199567.html in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B22D0AF8AB0082F9FC /* onboarding.b6199567.html */; }; - 63A9F3BC2D0AF8AB0082F9FC /* whatsNew.e79f552b.css in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B82D0AF8AB0082F9FC /* whatsNew.e79f552b.css */; }; - 63A9F3BD2D0AF8AB0082F9FC /* icon128.8b6ee0ac.png in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3AE2D0AF8AB0082F9FC /* icon128.8b6ee0ac.png */; }; - 63A9F3BE2D0AF8AB0082F9FC /* settings.c8a6c321.css in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B32D0AF8AB0082F9FC /* settings.c8a6c321.css */; }; - 63A9F3BF2D0AF8AB0082F9FC /* background.ec971b02.js in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3A82D0AF8AB0082F9FC /* background.ec971b02.js */; }; - 63A9F3C02D0AF8AB0082F9FC /* whatsNew.0b415932.html in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B72D0AF8AB0082F9FC /* whatsNew.0b415932.html */; }; - 63A9F3C12D0AF8AB0082F9FC /* manifest.json in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3AF2D0AF8AB0082F9FC /* manifest.json */; }; - 63A9F3C22D0AF8AB0082F9FC /* icon-keyboard-clicking48.ac857c64.png in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3AA2D0AF8AB0082F9FC /* icon-keyboard-clicking48.ac857c64.png */; }; - 63A9F3C32D0AF8AB0082F9FC /* tippy.a5573b16.css in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B62D0AF8AB0082F9FC /* tippy.a5573b16.css */; }; - 63A9F3C42D0AF8AB0082F9FC /* offscreen.18275b4d.js in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B02D0AF8AB0082F9FC /* offscreen.18275b4d.js */; }; - 63A9F3C52D0AF8AB0082F9FC /* content.d5600b6a.js in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3A92D0AF8AB0082F9FC /* content.d5600b6a.js */; }; - 63A9F3C62D0AF8AB0082F9FC /* icon48.ace12d5e.png in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3AD2D0AF8AB0082F9FC /* icon48.ace12d5e.png */; }; - 63A9F3C72D0AF8AB0082F9FC /* icon.f5383140.svg in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3AC2D0AF8AB0082F9FC /* icon.f5383140.svg */; }; - 63A9F3C82D0AF8AB0082F9FC /* settings.db0fd559.html in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3B42D0AF8AB0082F9FC /* settings.db0fd559.html */; }; - 63A9F3C92D0AF8AB0082F9FC /* icon.d20d9b97.svg in Resources */ = {isa = PBXBuildFile; fileRef = 63A9F3AB2D0AF8AB0082F9FC /* icon.d20d9b97.svg */; }; + 63BC7D0B2D15CFF600A5053D /* settings.568e3504.js in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D062D15CFF600A5053D /* settings.568e3504.js */; }; + 63BC7D0C2D15CFF600A5053D /* icon48.278694fa.png in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7CFF2D15CFF600A5053D /* icon48.278694fa.png */; }; + 63BC7D0D2D15CFF600A5053D /* whatsNew.b4149b1c.css in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D0A2D15CFF600A5053D /* whatsNew.b4149b1c.css */; }; + 63BC7D0E2D15CFF600A5053D /* manifest.json in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D012D15CFF600A5053D /* manifest.json */; }; + 63BC7D0F2D15CFF600A5053D /* icon-keyboard-clicking48.f52f8f73.png in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7CFD2D15CFF600A5053D /* icon-keyboard-clicking48.f52f8f73.png */; }; + 63BC7D102D15CFF600A5053D /* background.59f71d38.js in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7CFB2D15CFF600A5053D /* background.59f71d38.js */; }; + 63BC7D112D15CFF600A5053D /* offscreen.51e76c43.html in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D022D15CFF600A5053D /* offscreen.51e76c43.html */; }; + 63BC7D122D15CFF600A5053D /* offscreen.194ee590.js in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D032D15CFF600A5053D /* offscreen.194ee590.js */; }; + 63BC7D132D15CFF600A5053D /* settings.398e83d0.css in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D052D15CFF600A5053D /* settings.398e83d0.css */; }; + 63BC7D142D15CFF600A5053D /* settings.fb59ded2.html in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D072D15CFF600A5053D /* settings.fb59ded2.html */; }; + 63BC7D152D15CFF600A5053D /* icon.cb5b9b17.svg in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7CFE2D15CFF600A5053D /* icon.cb5b9b17.svg */; }; + 63BC7D162D15CFF600A5053D /* tippy.824e9ef4.css in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D082D15CFF600A5053D /* tippy.824e9ef4.css */; }; + 63BC7D172D15CFF600A5053D /* onboarding.7e0e0aee.html in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D042D15CFF600A5053D /* onboarding.7e0e0aee.html */; }; + 63BC7D182D15CFF600A5053D /* whatsNew.20ddf957.html in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D092D15CFF600A5053D /* whatsNew.20ddf957.html */; }; + 63BC7D192D15CFF600A5053D /* content.cbff2145.js in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7CFC2D15CFF600A5053D /* content.cbff2145.js */; }; + 63BC7D1A2D15CFF600A5053D /* icon128.2388c3de.png in Resources */ = {isa = PBXBuildFile; fileRef = 63BC7D002D15CFF600A5053D /* icon128.2388c3de.png */; }; E17BC8F8285E2315007EB9C6 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = E17BC8F7285E2315007EB9C6 /* Application.swift */; }; E1AEB977284D1D7800154974 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1AEB976284D1D7800154974 /* AppDelegate.swift */; }; E1AEB97A284D1D7800154974 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E1AEB978284D1D7800154974 /* Main.storyboard */; }; @@ -62,23 +61,22 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 63A9F3A82D0AF8AB0082F9FC /* background.ec971b02.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = background.ec971b02.js; sourceTree = ""; }; - 63A9F3A92D0AF8AB0082F9FC /* content.d5600b6a.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = content.d5600b6a.js; sourceTree = ""; }; - 63A9F3AA2D0AF8AB0082F9FC /* icon-keyboard-clicking48.ac857c64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-keyboard-clicking48.ac857c64.png"; sourceTree = ""; }; - 63A9F3AB2D0AF8AB0082F9FC /* icon.d20d9b97.svg */ = {isa = PBXFileReference; lastKnownFileType = text; path = icon.d20d9b97.svg; sourceTree = ""; }; - 63A9F3AC2D0AF8AB0082F9FC /* icon.f5383140.svg */ = {isa = PBXFileReference; lastKnownFileType = text; path = icon.f5383140.svg; sourceTree = ""; }; - 63A9F3AD2D0AF8AB0082F9FC /* icon48.ace12d5e.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon48.ace12d5e.png; sourceTree = ""; }; - 63A9F3AE2D0AF8AB0082F9FC /* icon128.8b6ee0ac.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon128.8b6ee0ac.png; sourceTree = ""; }; - 63A9F3AF2D0AF8AB0082F9FC /* manifest.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = manifest.json; sourceTree = ""; }; - 63A9F3B02D0AF8AB0082F9FC /* offscreen.18275b4d.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = offscreen.18275b4d.js; sourceTree = ""; }; - 63A9F3B12D0AF8AB0082F9FC /* offscreen.a61bb80b.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = offscreen.a61bb80b.html; sourceTree = ""; }; - 63A9F3B22D0AF8AB0082F9FC /* onboarding.b6199567.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = onboarding.b6199567.html; sourceTree = ""; }; - 63A9F3B32D0AF8AB0082F9FC /* settings.c8a6c321.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = settings.c8a6c321.css; sourceTree = ""; }; - 63A9F3B42D0AF8AB0082F9FC /* settings.db0fd559.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = settings.db0fd559.html; sourceTree = ""; }; - 63A9F3B52D0AF8AB0082F9FC /* settings.e932913c.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = settings.e932913c.js; sourceTree = ""; }; - 63A9F3B62D0AF8AB0082F9FC /* tippy.a5573b16.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = tippy.a5573b16.css; sourceTree = ""; }; - 63A9F3B72D0AF8AB0082F9FC /* whatsNew.0b415932.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = whatsNew.0b415932.html; sourceTree = ""; }; - 63A9F3B82D0AF8AB0082F9FC /* whatsNew.e79f552b.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = whatsNew.e79f552b.css; sourceTree = ""; }; + 63BC7CFB2D15CFF600A5053D /* background.59f71d38.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = background.59f71d38.js; path = ../dist/safari/background.59f71d38.js; sourceTree = SOURCE_ROOT; }; + 63BC7CFC2D15CFF600A5053D /* content.cbff2145.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = content.cbff2145.js; path = ../dist/safari/content.cbff2145.js; sourceTree = SOURCE_ROOT; }; + 63BC7CFD2D15CFF600A5053D /* icon-keyboard-clicking48.f52f8f73.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon-keyboard-clicking48.f52f8f73.png"; path = "../dist/safari/icon-keyboard-clicking48.f52f8f73.png"; sourceTree = SOURCE_ROOT; }; + 63BC7CFE2D15CFF600A5053D /* icon.cb5b9b17.svg */ = {isa = PBXFileReference; lastKnownFileType = text; name = icon.cb5b9b17.svg; path = ../dist/safari/icon.cb5b9b17.svg; sourceTree = SOURCE_ROOT; }; + 63BC7CFF2D15CFF600A5053D /* icon48.278694fa.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = icon48.278694fa.png; path = ../dist/safari/icon48.278694fa.png; sourceTree = SOURCE_ROOT; }; + 63BC7D002D15CFF600A5053D /* icon128.2388c3de.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = icon128.2388c3de.png; path = ../dist/safari/icon128.2388c3de.png; sourceTree = SOURCE_ROOT; }; + 63BC7D012D15CFF600A5053D /* manifest.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = manifest.json; path = ../dist/safari/manifest.json; sourceTree = SOURCE_ROOT; }; + 63BC7D022D15CFF600A5053D /* offscreen.51e76c43.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = offscreen.51e76c43.html; path = ../dist/safari/offscreen.51e76c43.html; sourceTree = SOURCE_ROOT; }; + 63BC7D032D15CFF600A5053D /* offscreen.194ee590.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = offscreen.194ee590.js; path = ../dist/safari/offscreen.194ee590.js; sourceTree = SOURCE_ROOT; }; + 63BC7D042D15CFF600A5053D /* onboarding.7e0e0aee.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = onboarding.7e0e0aee.html; path = ../dist/safari/onboarding.7e0e0aee.html; sourceTree = SOURCE_ROOT; }; + 63BC7D052D15CFF600A5053D /* settings.398e83d0.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; name = settings.398e83d0.css; path = ../dist/safari/settings.398e83d0.css; sourceTree = SOURCE_ROOT; }; + 63BC7D062D15CFF600A5053D /* settings.568e3504.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = settings.568e3504.js; path = ../dist/safari/settings.568e3504.js; sourceTree = SOURCE_ROOT; }; + 63BC7D072D15CFF600A5053D /* settings.fb59ded2.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = settings.fb59ded2.html; path = ../dist/safari/settings.fb59ded2.html; sourceTree = SOURCE_ROOT; }; + 63BC7D082D15CFF600A5053D /* tippy.824e9ef4.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; name = tippy.824e9ef4.css; path = ../dist/safari/tippy.824e9ef4.css; sourceTree = SOURCE_ROOT; }; + 63BC7D092D15CFF600A5053D /* whatsNew.20ddf957.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = whatsNew.20ddf957.html; path = ../dist/safari/whatsNew.20ddf957.html; sourceTree = SOURCE_ROOT; }; + 63BC7D0A2D15CFF600A5053D /* whatsNew.b4149b1c.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; name = whatsNew.b4149b1c.css; path = ../dist/safari/whatsNew.b4149b1c.css; sourceTree = SOURCE_ROOT; }; E17BC8F7285E2315007EB9C6 /* Application.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = ""; }; E18784B1298EEFB50028A679 /* UserSpecific.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = UserSpecific.xcconfig; sourceTree = ""; }; E18784B2298EEFB50028A679 /* RangoVersion.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = RangoVersion.xcconfig; sourceTree = ""; }; @@ -131,23 +129,22 @@ E18A7D4A298ED9B7000801AD /* Resources */ = { isa = PBXGroup; children = ( - 63A9F3A82D0AF8AB0082F9FC /* background.ec971b02.js */, - 63A9F3A92D0AF8AB0082F9FC /* content.d5600b6a.js */, - 63A9F3AA2D0AF8AB0082F9FC /* icon-keyboard-clicking48.ac857c64.png */, - 63A9F3AB2D0AF8AB0082F9FC /* icon.d20d9b97.svg */, - 63A9F3AC2D0AF8AB0082F9FC /* icon.f5383140.svg */, - 63A9F3AD2D0AF8AB0082F9FC /* icon48.ace12d5e.png */, - 63A9F3AE2D0AF8AB0082F9FC /* icon128.8b6ee0ac.png */, - 63A9F3AF2D0AF8AB0082F9FC /* manifest.json */, - 63A9F3B02D0AF8AB0082F9FC /* offscreen.18275b4d.js */, - 63A9F3B12D0AF8AB0082F9FC /* offscreen.a61bb80b.html */, - 63A9F3B22D0AF8AB0082F9FC /* onboarding.b6199567.html */, - 63A9F3B32D0AF8AB0082F9FC /* settings.c8a6c321.css */, - 63A9F3B42D0AF8AB0082F9FC /* settings.db0fd559.html */, - 63A9F3B52D0AF8AB0082F9FC /* settings.e932913c.js */, - 63A9F3B62D0AF8AB0082F9FC /* tippy.a5573b16.css */, - 63A9F3B72D0AF8AB0082F9FC /* whatsNew.0b415932.html */, - 63A9F3B82D0AF8AB0082F9FC /* whatsNew.e79f552b.css */, + 63BC7CFB2D15CFF600A5053D /* background.59f71d38.js */, + 63BC7CFC2D15CFF600A5053D /* content.cbff2145.js */, + 63BC7CFD2D15CFF600A5053D /* icon-keyboard-clicking48.f52f8f73.png */, + 63BC7CFE2D15CFF600A5053D /* icon.cb5b9b17.svg */, + 63BC7CFF2D15CFF600A5053D /* icon48.278694fa.png */, + 63BC7D002D15CFF600A5053D /* icon128.2388c3de.png */, + 63BC7D012D15CFF600A5053D /* manifest.json */, + 63BC7D022D15CFF600A5053D /* offscreen.51e76c43.html */, + 63BC7D032D15CFF600A5053D /* offscreen.194ee590.js */, + 63BC7D042D15CFF600A5053D /* onboarding.7e0e0aee.html */, + 63BC7D052D15CFF600A5053D /* settings.398e83d0.css */, + 63BC7D062D15CFF600A5053D /* settings.568e3504.js */, + 63BC7D072D15CFF600A5053D /* settings.fb59ded2.html */, + 63BC7D082D15CFF600A5053D /* tippy.824e9ef4.css */, + 63BC7D092D15CFF600A5053D /* whatsNew.20ddf957.html */, + 63BC7D0A2D15CFF600A5053D /* whatsNew.b4149b1c.css */, ); name = Resources; path = "../../dist-mv2-safari"; @@ -319,23 +316,22 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 63A9F3B92D0AF8AB0082F9FC /* offscreen.a61bb80b.html in Resources */, - 63A9F3BA2D0AF8AB0082F9FC /* settings.e932913c.js in Resources */, - 63A9F3BB2D0AF8AB0082F9FC /* onboarding.b6199567.html in Resources */, - 63A9F3BC2D0AF8AB0082F9FC /* whatsNew.e79f552b.css in Resources */, - 63A9F3BD2D0AF8AB0082F9FC /* icon128.8b6ee0ac.png in Resources */, - 63A9F3BE2D0AF8AB0082F9FC /* settings.c8a6c321.css in Resources */, - 63A9F3BF2D0AF8AB0082F9FC /* background.ec971b02.js in Resources */, - 63A9F3C02D0AF8AB0082F9FC /* whatsNew.0b415932.html in Resources */, - 63A9F3C12D0AF8AB0082F9FC /* manifest.json in Resources */, - 63A9F3C22D0AF8AB0082F9FC /* icon-keyboard-clicking48.ac857c64.png in Resources */, - 63A9F3C32D0AF8AB0082F9FC /* tippy.a5573b16.css in Resources */, - 63A9F3C42D0AF8AB0082F9FC /* offscreen.18275b4d.js in Resources */, - 63A9F3C52D0AF8AB0082F9FC /* content.d5600b6a.js in Resources */, - 63A9F3C62D0AF8AB0082F9FC /* icon48.ace12d5e.png in Resources */, - 63A9F3C72D0AF8AB0082F9FC /* icon.f5383140.svg in Resources */, - 63A9F3C82D0AF8AB0082F9FC /* settings.db0fd559.html in Resources */, - 63A9F3C92D0AF8AB0082F9FC /* icon.d20d9b97.svg in Resources */, + 63BC7D0B2D15CFF600A5053D /* settings.568e3504.js in Resources */, + 63BC7D0C2D15CFF600A5053D /* icon48.278694fa.png in Resources */, + 63BC7D0D2D15CFF600A5053D /* whatsNew.b4149b1c.css in Resources */, + 63BC7D0E2D15CFF600A5053D /* manifest.json in Resources */, + 63BC7D0F2D15CFF600A5053D /* icon-keyboard-clicking48.f52f8f73.png in Resources */, + 63BC7D102D15CFF600A5053D /* background.59f71d38.js in Resources */, + 63BC7D112D15CFF600A5053D /* offscreen.51e76c43.html in Resources */, + 63BC7D122D15CFF600A5053D /* offscreen.194ee590.js in Resources */, + 63BC7D132D15CFF600A5053D /* settings.398e83d0.css in Resources */, + 63BC7D142D15CFF600A5053D /* settings.fb59ded2.html in Resources */, + 63BC7D152D15CFF600A5053D /* icon.cb5b9b17.svg in Resources */, + 63BC7D162D15CFF600A5053D /* tippy.824e9ef4.css in Resources */, + 63BC7D172D15CFF600A5053D /* onboarding.7e0e0aee.html in Resources */, + 63BC7D182D15CFF600A5053D /* whatsNew.20ddf957.html in Resources */, + 63BC7D192D15CFF600A5053D /* content.cbff2145.js in Resources */, + 63BC7D1A2D15CFF600A5053D /* icon128.2388c3de.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js index 42104cfc..d9b49f22 100644 --- a/jest-puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -1,5 +1,5 @@ const path = require("node:path"); -const EXTENSION_PATH = path.resolve(__dirname, "dist-mv3"); +const EXTENSION_PATH = path.resolve(__dirname, "dist", "chrome"); module.exports = { launch: { diff --git a/package-lock.json b/package-lock.json index a10185f4..a6b939f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ "@types/lodash": "^4.14.195", "@types/react-dom": "^19.0.0", "@types/webextension-polyfill": "^0.12.1", + "cross-env": "^7.0.3", "eslint-config-xo-react": "^0.27.0", "eslint-plugin-react": "^7.36.1", "eslint-plugin-react-hooks": "^5.0.0", @@ -6345,6 +6346,25 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", diff --git a/package.json b/package.json index 466cdbf8..ca4c6090 100644 --- a/package.json +++ b/package.json @@ -1,38 +1,39 @@ { "private": true, "scripts": { - "build:mv2": "rimraf dist-mv2 && parcel build src/manifests/mv2/manifest.json --no-content-hash --dist-dir dist-mv2 --no-cache --no-source-maps --detailed-report 0", - "build:mv2-safari": "rimraf dist-mv2-safari && parcel build src/manifests/mv2-safari/manifest.json --no-content-hash --dist-dir dist-mv2-safari --no-cache --detailed-report 0", - "build:mv3": "rimraf dist-mv3 && parcel build src/manifests/mv3/manifest.json --no-content-hash --dist-dir dist-mv3 --no-cache --detailed-report 0", + "_build": "rimraf dist/$BROWSER && parcel build src/manifests/$BROWSER/manifest.json --no-content-hash --dist-dir dist/$BROWSER --no-cache --detailed-report 0", + "build:firefox": "cross-env BROWSER=firefox npm run _build -- --no-source-maps", + "build:safari": "cross-env BROWSER=safari npm run _build", + "build:chrome": "cross-env BROWSER=chrome npm run _build", "build": "run-p build:*", - "package:mv2": "web-ext build --artifacts-dir=web-ext-artifacts/mv2", - "package:mv2-safari": "web-ext build --source-dir=dist-mv2-safari --artifacts-dir=web-ext-artifacts/mv2-safari", - "package:mv3": "web-ext build --source-dir=dist-mv3 --artifacts-dir=web-ext-artifacts/mv3", + "_watch": "parcel watch src/manifests/$BROWSER/manifest.json --dist-dir dist/$BROWSER --no-cache --no-content-hash --no-hmr", + "watch:firefox": "cross-env BROWSER=firefox npm run _watch", + "watch:chrome": "cross-env BROWSER=chrome npm run _watch", + "watch:safari": "rimraf dist/safari && cross-env BROWSER=safari npm run _watch", + "_package": "web-ext build --source-dir=dist/$BROWSER --artifacts-dir=web-ext-artifacts/$BROWSER", + "package:firefox": "cross-env BROWSER=firefox npm run _package", + "package:safari": "cross-env BROWSER=safari npm run _package", + "package:chrome": "cross-env BROWSER=chrome npm run _package", "package": "run-p package:*", + "predev": "rimraf dist/firefox && mkdir -p dist/firefox && cp src/manifests/firefox/manifest.json dist/firefox/manifest.json", + "dev": "run-p watch:firefox start:firefox", + "start:firefox": "web-ext run --source-dir dist/firefox", + "start:chrome": "web-ext run --source-dir dist/chrome --target chromium", "build-and-package": "run-s build package", "check-types": "tsc --noemit", "check-format": "prettier --check .", "unused-exports": "ts-unused-exports ./tsconfig.json", - "lint-fix": "run-p 'lint:* -- --fix'", "lint:css": "stylelint src/**/*.css", "lint:js": "xo", "lint": "run-p lint:* check-types", - "pretest": "NODE_ENV=test run-p lint unused-exports build:mv3", - "test": "jest --runInBand", - "watch": "parcel watch src/manifests/mv2/manifest.json --dist-dir dist-mv2 --no-cache --no-content-hash --no-hmr", - "watch:mv3": "parcel watch src/manifests/mv3/manifest.json --dist-dir dist-mv3 --no-cache --no-content-hash --no-hmr", - "start:firefox": "web-ext run --target firefox-desktop", - "start:chromium": "web-ext run --source-dir dist-mv3 --target chromium" + "lint-fix": "run-p 'lint:* -- --fix'", + "pretest": "cross-env NODE_ENV=test run-p lint unused-exports build:chrome", + "test": "jest --runInBand" }, "browserslist": [ "last 1 Chrome version", "last 1 Firefox version" ], - "@parcel/bundler-default": { - "minBundles": 10000000, - "minBundleSize": 3000, - "maxParallelRequests": 20 - }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.4.0", "@fortawesome/free-solid-svg-icons": "^6.4.0", @@ -70,6 +71,7 @@ "@types/lodash": "^4.14.195", "@types/react-dom": "^19.0.0", "@types/webextension-polyfill": "^0.12.1", + "cross-env": "^7.0.3", "eslint-config-xo-react": "^0.27.0", "eslint-plugin-react": "^7.36.1", "eslint-plugin-react-hooks": "^5.0.0", @@ -97,10 +99,9 @@ } }, "webExt": { - "sourceDir": "dist-mv2", "run": { "startUrl": [ - "https://en.wikipedia.org/wiki/Main_Page" + "https://rango.click" ] } }, diff --git a/src/manifests/mv3/manifest.json b/src/manifests/chrome/manifest.json similarity index 100% rename from src/manifests/mv3/manifest.json rename to src/manifests/chrome/manifest.json diff --git a/src/manifests/mv2/manifest.json b/src/manifests/firefox/manifest.json similarity index 100% rename from src/manifests/mv2/manifest.json rename to src/manifests/firefox/manifest.json diff --git a/src/manifests/mv2-safari/manifest.json b/src/manifests/safari/manifest.json similarity index 100% rename from src/manifests/mv2-safari/manifest.json rename to src/manifests/safari/manifest.json