diff --git a/public/manifest.json b/public/manifest.json index 3362b54..9559059 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -5,11 +5,11 @@ "version": "0.11.0", "manifest_version": 3, "icons": { - "16": "./static/Logo_16.png", - "32": "./static/Logo_32.png", - "48": "./static/Logo_48.png", - "128": "./static/Logo_128.png", - "256": "./static/Logo_256.png" + "16": "./static/logo/Logo_16.png", + "32": "./static/logo/Logo_32.png", + "48": "./static/logo/Logo_48.png", + "128": "./static/logo/Logo_128.png", + "256": "./static/logo/Logo_256.png" }, "action": { "default_popup": "./popup.html" diff --git a/public/static/Logo_128.png b/public/static/logo/Logo_128.png similarity index 100% rename from public/static/Logo_128.png rename to public/static/logo/Logo_128.png diff --git a/public/static/Logo_16.png b/public/static/logo/Logo_16.png similarity index 100% rename from public/static/Logo_16.png rename to public/static/logo/Logo_16.png diff --git a/public/static/Logo_256.png b/public/static/logo/Logo_256.png similarity index 100% rename from public/static/Logo_256.png rename to public/static/logo/Logo_256.png diff --git a/public/static/Logo_32.png b/public/static/logo/Logo_32.png similarity index 100% rename from public/static/Logo_32.png rename to public/static/logo/Logo_32.png diff --git a/public/static/Logo_48.png b/public/static/logo/Logo_48.png similarity index 100% rename from public/static/Logo_48.png rename to public/static/logo/Logo_48.png diff --git a/src/shared/config.ts b/src/app/config.ts similarity index 100% rename from src/shared/config.ts rename to src/app/config.ts diff --git a/src/shared/injections.ts b/src/app/injections.ts similarity index 100% rename from src/shared/injections.ts rename to src/app/injections.ts diff --git a/src/shared/messaging.ts b/src/app/messaging.ts similarity index 100% rename from src/shared/messaging.ts rename to src/app/messaging.ts diff --git a/src/shared/storage.ts b/src/app/storage.ts similarity index 100% rename from src/shared/storage.ts rename to src/app/storage.ts diff --git a/src/background/background.ts b/src/background/background.ts index 7e09f05..78e1bec 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -1,6 +1,4 @@ -import "./services/active_tab_setter/active_tab_setter"; -import "./services/active_window_setter/active_window_setter"; -import "./services/camera_bubble_injector/camera_bubble_injector"; -import "./services/permissions_giver/permissions_giver"; -import "./services/recording_controller/recording_controller"; -import "./services/storage_controller/storage_controller"; +import "./controllers/camera_bubble_controller"; +import "./controllers/current_window_tab_controller"; +import "./controllers/recording_controller"; +import "./controllers/storage_controller"; diff --git a/src/background/services/camera_bubble_injector/camera_bubble_injector.ts b/src/background/controllers/camera_bubble_controller.ts similarity index 82% rename from src/background/services/camera_bubble_injector/camera_bubble_injector.ts rename to src/background/controllers/camera_bubble_controller.ts index 98b2da8..bd5e124 100644 --- a/src/background/services/camera_bubble_injector/camera_bubble_injector.ts +++ b/src/background/controllers/camera_bubble_controller.ts @@ -3,14 +3,14 @@ import { MessageResponse, MessageResponseType, MessageType, -} from "@/shared/messaging"; -import { storage } from "@/shared/storage"; -import { Injection, InjectionElementId } from "@/shared/injections"; -import { Injector } from "./injector"; +} from "@/app/messaging"; +import { storage } from "@/app/storage"; +import { Injection, InjectionElementId } from "@/app/injections"; +import { Injector } from "@/background/injector"; -class CameraBubbleInjector { +class CameraBubbleController { static async show() { - console.log("CameraBubbleInjector.show()"); + console.log("CameraBubbleController.show()"); const [currentTab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true, @@ -21,7 +21,7 @@ class CameraBubbleInjector { } static async hide() { - console.log("CameraBubbleInjector.hide()"); + console.log("CameraBubbleController.hide()"); await Injector.deinject( await storage.ui.cameraBubble.tabId.get(), InjectionElementId.CameraBubble, @@ -37,8 +37,8 @@ chrome.tabs.onActivated.addListener((_activeTabInfo) => { if (!(await storage.ui.cameraBubble.enabled.get())) { return; } - await CameraBubbleInjector.hide(); - await CameraBubbleInjector.show(); + await CameraBubbleController.hide(); + await CameraBubbleController.show(); })().catch((err) => { console.error( `Error in 'chrome.tabs.onActivated' handler: ${(err as Error).toString()}`, @@ -52,7 +52,7 @@ chrome.tabs.onUpdated.addListener((_tabId, _changeInfo, _tab) => { if (!(await storage.ui.cameraBubble.enabled.get())) { return; } - await CameraBubbleInjector.show(); + await CameraBubbleController.show(); })().catch((err) => { console.error( `Error in 'chrome.tabs.onUpdated' handler: ${(err as Error).toString()}`, @@ -66,7 +66,7 @@ chrome.tabs.onRemoved.addListener((_closedTabId, _removeInfo) => { if (!(await storage.ui.cameraBubble.enabled.get())) { return; } - await CameraBubbleInjector.show(); + await CameraBubbleController.show(); })().catch((err) => { console.error( `Error in 'chrome.tabs.onRemoved' handler: ${(err as Error).toString()}`, @@ -80,8 +80,8 @@ chrome.windows.onFocusChanged.addListener((_windowId) => { if (!(await storage.ui.cameraBubble.enabled.get())) { return; } - await CameraBubbleInjector.hide(); - await CameraBubbleInjector.show(); + await CameraBubbleController.hide(); + await CameraBubbleController.show(); })().catch((err) => { console.error( `Error in 'chrome.windows.onFocusChanged' handler: ${(err as Error).toString()}`, @@ -102,10 +102,10 @@ chrome.runtime.onMessage.addListener( } switch (type) { case MessageType.CameraBubbleShow: - await CameraBubbleInjector.show(); + await CameraBubbleController.show(); break; case MessageType.CameraBubbleHide: - await CameraBubbleInjector.hide(); + await CameraBubbleController.hide(); break; } })() diff --git a/src/background/controllers/current_window_tab_controller.ts b/src/background/controllers/current_window_tab_controller.ts new file mode 100644 index 0000000..2511fab --- /dev/null +++ b/src/background/controllers/current_window_tab_controller.ts @@ -0,0 +1,23 @@ +import { storage } from "@/app/storage"; + +chrome.tabs.onActivated.addListener((activatedTabInfo) => { + console.log("Handle 'chrome.tabs.onActivated'"); + (async () => { + await storage.current.tabId.set(activatedTabInfo.tabId); + })().catch((err) => { + console.error( + `Error in 'chrome.tabs.onActivated' handler: ${(err as Error).toString()}`, + ); + }); +}); + +chrome.windows.onFocusChanged.addListener((windowId) => { + console.log("Handle 'chrome.windows.onFocusChanged'"); + (async () => { + await storage.current.windowId.set(windowId); + })().catch((err) => { + console.error( + `Error in 'chrome.windows.onFocusChanged' handler: ${(err as Error).toString()}`, + ); + }); +}); diff --git a/src/background/services/recorder_controller/recorder_controller.ts b/src/background/controllers/recorder_controller.ts similarity index 99% rename from src/background/services/recorder_controller/recorder_controller.ts rename to src/background/controllers/recorder_controller.ts index bea1fce..aad1b59 100644 --- a/src/background/services/recorder_controller/recorder_controller.ts +++ b/src/background/controllers/recorder_controller.ts @@ -5,7 +5,7 @@ import { MessageType, RecorderCreateOptions, sender, -} from "@/shared/messaging"; +} from "@/app/messaging"; class Recorder { #mimeType: string; diff --git a/src/background/services/recording_controller/recording_controller.ts b/src/background/controllers/recording_controller.ts similarity index 97% rename from src/background/services/recording_controller/recording_controller.ts rename to src/background/controllers/recording_controller.ts index aab2918..77bc71a 100644 --- a/src/background/services/recording_controller/recording_controller.ts +++ b/src/background/controllers/recording_controller.ts @@ -5,8 +5,8 @@ import { MessageType, RecordingSaveOptions, sender, -} from "@/shared/messaging"; -import { RecordingState, storage } from "@/shared/storage"; +} from "@/app/messaging"; +import { RecordingState, storage } from "@/app/storage"; class RecordingController { static async start() { diff --git a/src/background/services/storage_controller/storage_controller.ts b/src/background/controllers/storage_controller.ts similarity index 86% rename from src/background/services/storage_controller/storage_controller.ts rename to src/background/controllers/storage_controller.ts index 7e8badc..44563ca 100644 --- a/src/background/services/storage_controller/storage_controller.ts +++ b/src/background/controllers/storage_controller.ts @@ -1,5 +1,5 @@ -import { config } from "@/shared/config"; -import { RecordingState, storage } from "@/shared/storage"; +import { config } from "@/app/config"; +import { RecordingState, storage } from "@/app/storage"; chrome.runtime.onInstalled.addListener((_details) => { console.log("Handle 'chrome.runtime.onInstalled'"); @@ -23,6 +23,11 @@ chrome.runtime.onInstalled.addListener((_details) => { console.log( `Storage: ${JSON.stringify(await storage.getEntireStorage(), undefined, 2)}`, ); + + await chrome.tabs.create({ + active: true, + url: chrome.runtime.getURL("permissions.html"), + }); })().catch((err) => { console.error( `Error in 'chrome.runtime.onInstalled' handler: ${(err as Error).toString()}`, diff --git a/src/background/services/camera_bubble_injector/injector.ts b/src/background/injector.ts similarity index 89% rename from src/background/services/camera_bubble_injector/injector.ts rename to src/background/injector.ts index 6b36e7c..26aa7b5 100644 --- a/src/background/services/camera_bubble_injector/injector.ts +++ b/src/background/injector.ts @@ -1,4 +1,4 @@ -import type { Injection, InjectionElementId } from "@/shared/injections"; +import type { Injection, InjectionElementId } from "@/app/injections"; export class Injector { static inject(tabId: number, injection: Injection) { diff --git a/src/background/offscreen.ts b/src/background/offscreen.ts index 76b0b95..dac84b0 100644 --- a/src/background/offscreen.ts +++ b/src/background/offscreen.ts @@ -1 +1 @@ -import "./services/recorder_controller/recorder_controller"; +import "./controllers/recorder_controller"; diff --git a/src/background/services/active_tab_setter/active_tab_setter.ts b/src/background/services/active_tab_setter/active_tab_setter.ts deleted file mode 100644 index 7d68374..0000000 --- a/src/background/services/active_tab_setter/active_tab_setter.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { storage } from "@/shared/storage"; - -chrome.tabs.onActivated.addListener((activatedTabInfo) => { - console.log("Handle 'chrome.tabs.onActivated'"); - (async () => { - await storage.current.tabId.set(activatedTabInfo.tabId); - })().catch((err) => { - console.error( - `Error in 'chrome.tabs.onActivated' handler: ${(err as Error).toString()}`, - ); - }); -}); diff --git a/src/background/services/active_window_setter/active_window_setter.ts b/src/background/services/active_window_setter/active_window_setter.ts deleted file mode 100644 index e574b22..0000000 --- a/src/background/services/active_window_setter/active_window_setter.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { storage } from "@/shared/storage"; - -chrome.windows.onFocusChanged.addListener((windowId) => { - console.log("Handle 'chrome.windows.onFocusChanged'"); - (async () => { - await storage.current.windowId.set(windowId); - })().catch((err) => { - console.error( - `Error in 'chrome.windows.onFocusChanged' handler: ${(err as Error).toString()}`, - ); - }); -}); diff --git a/src/background/services/permissions_giver/permissions_giver.ts b/src/background/services/permissions_giver/permissions_giver.ts deleted file mode 100644 index 417aa9d..0000000 --- a/src/background/services/permissions_giver/permissions_giver.ts +++ /dev/null @@ -1,13 +0,0 @@ -chrome.runtime.onInstalled.addListener((_details) => { - console.log("Handle 'chrome.runtime.onInstalled'"); - (async () => { - await chrome.tabs.create({ - active: true, - url: chrome.runtime.getURL("permissions.html"), - }); - })().catch((err) => { - console.error( - `Error in 'chrome.runtime.onInstalled' handler: ${(err as Error).toString()}`, - ); - }); -}); diff --git a/public/static/Background.svg b/src/ui/assets/Background.svg similarity index 100% rename from public/static/Background.svg rename to src/ui/assets/Background.svg diff --git a/public/static/Lookup_128.png b/src/ui/assets/Lookup_128.png similarity index 100% rename from public/static/Lookup_128.png rename to src/ui/assets/Lookup_128.png diff --git a/src/ui/hooks/useStorageValue.tsx b/src/ui/hooks/useStorageValue.tsx index 60c3576..4fcb739 100644 --- a/src/ui/hooks/useStorageValue.tsx +++ b/src/ui/hooks/useStorageValue.tsx @@ -4,7 +4,7 @@ import { createStorageSetter, StorageKey, StorageValueType, -} from "@/shared/storage"; +} from "@/app/storage"; export default function useStorageValue( storageKey: Key, diff --git a/src/ui/pages/camera_bubble/CameraBubble.tsx b/src/ui/pages/camera_bubble/CameraBubble.tsx index f4534c3..8b2bfac 100644 --- a/src/ui/pages/camera_bubble/CameraBubble.tsx +++ b/src/ui/pages/camera_bubble/CameraBubble.tsx @@ -1,4 +1,4 @@ -import { StorageKey } from "@/shared/storage"; +import { StorageKey } from "@/app/storage"; import useStorageValue from "@/ui/hooks/useStorageValue"; import { Draggable } from "./components/Draggable"; diff --git a/src/ui/pages/camera_bubble/camera_bubble.ts b/src/ui/pages/camera_bubble/camera_bubble.ts index 5889483..f4ed57e 100644 --- a/src/ui/pages/camera_bubble/camera_bubble.ts +++ b/src/ui/pages/camera_bubble/camera_bubble.ts @@ -1,7 +1,7 @@ import React from "react"; import ReactDOM from "react-dom/client"; -import { Injection, InjectionElementId } from "@/shared/injections"; -import { storage } from "@/shared/storage"; +import { Injection, InjectionElementId } from "@/app/injections"; +import { storage } from "@/app/storage"; import { CameraBubble } from "./CameraBubble"; async function inject() { diff --git a/src/ui/pages/popup/Popup.tsx b/src/ui/pages/popup/Popup.tsx index 5dda3dc..229c82e 100644 --- a/src/ui/pages/popup/Popup.tsx +++ b/src/ui/pages/popup/Popup.tsx @@ -1,5 +1,5 @@ -import { RecordingState, StorageKey } from "@/shared/storage"; -import { sender } from "@/shared/messaging"; +import { RecordingState, StorageKey } from "@/app/storage"; +import { sender } from "@/app/messaging"; import useStorageValue from "@/ui/hooks/useStorageValue"; import { PauseButton } from "./components/PauseButton"; import { PlayButton } from "./components/PlayButton"; @@ -14,8 +14,8 @@ import { IconTrash, IconUserCircle, } from "@tabler/icons-react"; -import background from "/static/Background.svg"; -import lookup128 from "/static/Lookup_128.png"; +import background from "/assets/Background.svg"; +import lookup128 from "/assets/Lookup_128.png"; const Settings = () => { const [cameraBubbleEnabled] = useStorageValue( diff --git a/tsconfig.json b/tsconfig.json index 469e329..1917509 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,7 +29,8 @@ "paths": { /* Specify a set of entries that re-map imports to additional lookup locations. */ "@/*": ["./*"], - "/static/*": ["../public/static/*"] + "/static/*": ["../public/static/*"], + "/assets/*": ["./ui/assets/*"] }, // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ "typeRoots": [