From a8d94cddfa42136eaad7889e881fa1d208ffaebb Mon Sep 17 00:00:00 2001
From: PatrykKuniczak
Date: Mon, 16 Dec 2024 13:18:49 +0100
Subject: [PATCH] fix: resolve conflicts
---
chrome-extension/manifest.js | 82 -------------------
.../utils/plugins/make-manifest-plugin.ts | 18 ++--
chrome-extension/utils/refresh.js | 72 ----------------
packages/storage/lib/impl/index.ts | 2 +-
packages/storage/lib/index.ts | 2 +-
pnpm-lock.yaml | 42 +++++-----
6 files changed, 36 insertions(+), 182 deletions(-)
delete mode 100755 chrome-extension/manifest.js
delete mode 100644 chrome-extension/utils/refresh.js
diff --git a/chrome-extension/manifest.js b/chrome-extension/manifest.js
deleted file mode 100755
index d88070ca9..000000000
--- a/chrome-extension/manifest.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import fs from 'node:fs';
-import deepmerge from 'deepmerge';
-
-const packageJson = JSON.parse(fs.readFileSync('../package.json', 'utf8'));
-
-const isFirefox = process.env.__FIREFOX__ === 'true';
-
-/**
- * If you want to disable the sidePanel, you can delete withSidePanel function and remove the sidePanel HoC on the manifest declaration.
- *
- * ```js
- * const manifest = { // remove `withSidePanel()`
- * ```
- */
-function withSidePanel(manifest) {
- // Firefox does not support sidePanel
- if (isFirefox) {
- return manifest;
- }
- return deepmerge(manifest, {
- side_panel: {
- default_path: 'side-panel/index.html',
- },
- permissions: ['sidePanel'],
- });
-}
-
-/**
- * After changing, please reload the extension at `chrome://extensions`
- * @type {chrome.runtime.ManifestV3}
- */
-const manifest = withSidePanel({
- manifest_version: 3,
- default_locale: 'en',
- /**
- * if you want to support multiple languages, you can use the following reference
- * https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Internationalization
- */
- name: '__MSG_extensionName__',
- version: packageJson.version,
- description: '__MSG_extensionDescription__',
- host_permissions: [''],
- permissions: ['storage', 'scripting', 'tabs', 'notifications'],
- options_page: 'options/index.html',
- background: {
- service_worker: 'background.iife.js',
- type: 'module',
- },
- action: {
- default_popup: 'popup/index.html',
- default_icon: 'icon-34.png',
- },
- chrome_url_overrides: {
- newtab: 'new-tab/index.html',
- },
- icons: {
- 128: 'icon-128.png',
- },
- content_scripts: [
- {
- matches: ['http://*/*', 'https://*/*', ''],
- js: ['content/index.iife.js'],
- },
- {
- matches: ['http://*/*', 'https://*/*', ''],
- js: ['content-ui/index.iife.js'],
- },
- {
- matches: ['http://*/*', 'https://*/*', ''],
- css: ['content.css'], // public folder
- },
- ],
- devtools_page: 'devtools/index.html',
- web_accessible_resources: [
- {
- resources: ['*.js', '*.css', '*.svg', 'icon-128.png', 'icon-34.png'],
- matches: ['*://*/*'],
- },
- ],
-});
-
-export default manifest;
diff --git a/chrome-extension/utils/plugins/make-manifest-plugin.ts b/chrome-extension/utils/plugins/make-manifest-plugin.ts
index f4de0ded4..b0359418f 100644
--- a/chrome-extension/utils/plugins/make-manifest-plugin.ts
+++ b/chrome-extension/utils/plugins/make-manifest-plugin.ts
@@ -1,4 +1,4 @@
-import { existsSync, mkdirSync, writeFileSync, copyFileSync } from 'node:fs';
+import { copyFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { env, platform } from 'node:process';
@@ -7,7 +7,17 @@ import { colorLog, ManifestParser } from '@extension/dev-utils';
import type { PluginOption } from 'vite';
const manifestFile = resolve(import.meta.dirname, '..', '..', 'manifest.js');
-const refreshFile = resolve(import.meta.dirname, '..', 'refresh.js');
+const refreshFile = resolve(
+ import.meta.dirname,
+ '..',
+ '..',
+ '..',
+ 'packages',
+ 'hmr',
+ 'lib',
+ 'injections',
+ 'refresh.js',
+);
const getManifestWithCacheBurst = async () => {
const withCacheBurst = (path: string) => `${path}?${Date.now().toString()}`;
@@ -31,14 +41,12 @@ export default (config: { outDir: string }): PluginOption => {
const manifestPath = resolve(to, 'manifest.json');
const isFirefox = env.__FIREFOX__ === 'true';
- const isDev = process.env.__DEV__ === 'true';
+ const isDev = env.__DEV__ === 'true';
writeFileSync(manifestPath, ManifestParser.convertManifestToString(manifest, isFirefox));
isDev && addRefreshContentScript(manifest);
- writeFileSync(manifestPath, ManifestParser.convertManifestToString(manifest, isFirefox ? 'firefox' : 'chrome'));
-
isDev && copyFileSync(refreshFile, resolve(to, 'refresh.js'));
colorLog(`Manifest file copy complete: ${manifestPath}`, 'success');
diff --git a/chrome-extension/utils/refresh.js b/chrome-extension/utils/refresh.js
deleted file mode 100644
index 5d3dad3dd..000000000
--- a/chrome-extension/utils/refresh.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/* eslint-disable */
-(function () {
- 'use strict';
- // This is the custom ID for HMR (chrome-extension/vite.config.mts)
- const __HMR_ID = 'chrome-extension-hmr';
-
- const LOCAL_RELOAD_SOCKET_PORT = 8081;
- const LOCAL_RELOAD_SOCKET_URL = `ws://localhost:${LOCAL_RELOAD_SOCKET_PORT}`;
-
- const DO_UPDATE = 'do_update';
- const DONE_UPDATE = 'done_update';
-
- class MessageInterpreter {
- // eslint-disable-next-line @typescript-eslint/no-empty-function
- constructor() {}
-
- static send(message) {
- return JSON.stringify(message);
- }
-
- static receive(serializedMessage) {
- return JSON.parse(serializedMessage);
- }
- }
-
- function initClient({ id, onUpdate }) {
- const ws = new WebSocket(LOCAL_RELOAD_SOCKET_URL);
-
- ws.onopen = () => {
- ws.addEventListener('message', event => {
- const message = MessageInterpreter.receive(String(event.data));
-
- if (message.type === DO_UPDATE && message.id === id) {
- onUpdate();
- ws.send(MessageInterpreter.send({ type: DONE_UPDATE }));
- return;
- }
- });
- };
- }
-
- function addRefresh() {
- let pendingReload = false;
-
- initClient({
- id: __HMR_ID,
- onUpdate: () => {
- // disable reload when tab is hidden
- if (document.hidden) {
- pendingReload = true;
- return;
- }
- reload();
- },
- });
-
- // reload
- function reload() {
- pendingReload = false;
- window.location.reload();
- }
-
- // reload when tab is visible
- function reloadWhenTabIsVisible() {
- !document.hidden && pendingReload && reload();
- }
-
- document.addEventListener('visibilitychange', reloadWhenTabIsVisible);
- }
-
- addRefresh();
-})();
diff --git a/packages/storage/lib/impl/index.ts b/packages/storage/lib/impl/index.ts
index bb9f0cbc4..49f6f17e9 100644
--- a/packages/storage/lib/impl/index.ts
+++ b/packages/storage/lib/impl/index.ts
@@ -1 +1 @@
-export * from './exampleThemeStorage';
+export * from './exampleThemeStorage.js';
diff --git a/packages/storage/lib/index.ts b/packages/storage/lib/index.ts
index dffa0f708..26bd78fec 100644
--- a/packages/storage/lib/index.ts
+++ b/packages/storage/lib/index.ts
@@ -1,2 +1,2 @@
export type { BaseStorage } from './base/types.js';
-export * from './impl';
+export * from './impl/index.js';
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 895561745..03c7a0266 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -36,12 +36,18 @@ importers:
'@typescript-eslint/parser':
specifier: ^7.18.0
version: 7.18.0(eslint@8.57.0)(typescript@5.5.4)
+ app-root-path:
+ specifier: ^3.1.0
+ version: 3.1.0
autoprefixer:
specifier: ^10.4.20
version: 10.4.20(postcss@8.4.47)
cross-env:
specifier: ^7.0.3
version: 7.0.3
+ deepmerge:
+ specifier: ^4.3.1
+ version: 4.3.1
esbuild:
specifier: ^0.23.0
version: 0.23.1
@@ -69,6 +75,9 @@ importers:
eslint-plugin-react-hooks:
specifier: 4.6.2
version: 4.6.2(eslint@8.57.0)
+ fast-glob:
+ specifier: ^3.3.2
+ version: 3.3.2
husky:
specifier: ^9.1.4
version: 9.1.5
@@ -78,6 +87,9 @@ importers:
postcss:
specifier: ^8.4.47
version: 8.4.47
+ postcss-load-config:
+ specifier: ^6.0.1
+ version: 6.0.1(jiti@1.21.6)(postcss@8.4.47)(tsx@4.19.2)(yaml@2.5.1)
prettier:
specifier: ^3.3.3
version: 3.3.3
@@ -133,6 +145,9 @@ importers:
cross-env:
specifier: ^7.0.3
version: 7.0.3
+ deepmerge:
+ specifier: ^4.3.1
+ version: 4.3.1
magic-string:
specifier: ^0.30.10
version: 0.30.11
@@ -178,9 +193,6 @@ importers:
packages/i18n:
devDependencies:
- '@extension/hmr':
- specifier: workspace:*
- version: link:../hmr
'@extension/tsconfig':
specifier: workspace:*
version: link:../tsconfig
@@ -216,9 +228,6 @@ importers:
'@extension/tsconfig':
specifier: workspace:*
version: link:../tsconfig
- deepmerge:
- specifier: ^4.3.1
- version: 4.3.1
tsc-alias:
specifier: ^1.8.10
version: 1.8.10
@@ -277,9 +286,6 @@ importers:
pages/content-runtime:
devDependencies:
- '@extension/hmr':
- specifier: workspace:*
- version: link:../../packages/hmr
'@extension/tsconfig':
specifier: workspace:*
version: link:../../packages/tsconfig
@@ -355,9 +361,6 @@ importers:
cross-env:
specifier: ^7.0.3
version: 7.0.3
- postcss-load-config:
- specifier: ^6.0.1
- version: 6.0.1(jiti@1.21.6)(postcss@8.4.47)(tsx@4.19.2)(yaml@2.5.1)
pages/new-tab:
dependencies:
@@ -417,9 +420,6 @@ importers:
cross-env:
specifier: ^7.0.3
version: 7.0.3
- postcss-load-config:
- specifier: ^6.0.1
- version: 6.0.1(jiti@1.21.6)(postcss@8.4.47)(tsx@4.19.2)(yaml@2.5.1)
pages/popup:
dependencies:
@@ -445,9 +445,6 @@ importers:
cross-env:
specifier: ^7.0.3
version: 7.0.3
- postcss-load-config:
- specifier: ^6.0.1
- version: 6.0.1(jiti@1.21.6)(postcss@8.4.47)(tsx@4.19.2)(yaml@2.5.1)
pages/side-panel:
dependencies:
@@ -470,9 +467,6 @@ importers:
cross-env:
specifier: ^7.0.3
version: 7.0.3
- postcss-load-config:
- specifier: ^6.0.1
- version: 6.0.1(jiti@1.21.6)(postcss@8.4.47)(tsx@4.19.2)(yaml@2.5.1)
tests/e2e:
devDependencies:
@@ -1528,6 +1522,10 @@ packages:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
+ app-root-path@3.1.0:
+ resolution: {integrity: sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA==}
+ engines: {node: '>= 6.0.0'}
+
archiver-utils@5.0.2:
resolution: {integrity: sha512-wuLJMmIBQYCsGZgYLTy5FIB2pF6Lfb6cXMSF8Qywwk3t20zWnAi7zLcQFdKQmIB8wyZpY5ER38x08GbwtR2cLA==}
engines: {node: '>= 14'}
@@ -5335,6 +5333,8 @@ snapshots:
normalize-path: 3.0.0
picomatch: 2.3.1
+ app-root-path@3.1.0: {}
+
archiver-utils@5.0.2:
dependencies:
glob: 10.4.5