Emoji favicons for the web
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: cleanup

+54 -53
+2
Makefile
··· 12 12 13 13 test: 14 14 deno fmt 15 + deno lint 15 16 deno test 17 + deno check source/background.ts source/content_script.ts source/options.tsx source/popup.tsx
+1 -2
bundler.ts
··· 11 11 import { denoPlugin } from 'https://raw.githubusercontent.com/ivebencrazy/esbuild_deno_loader/main/mod.ts'; 12 12 import { copySync, ensureDir } from 'fs'; 13 13 import { resolve } from 'https://deno.land/std@0.142.0/path/mod.ts'; 14 - import importMap from './import_map.json' assert { type: 'json' }; 15 14 16 15 const importMapURL = new URL('file://' + resolve('./import_map.json')); 17 16 ··· 88 87 outdir: `dist/${browserId}/`, 89 88 bundle: true, 90 89 watch: { 91 - onRebuild(error, result) { 90 + onRebuild(error) { 92 91 if (error) { 93 92 console.error(`Rebuild for ${colorizedBrowserName} failed:`, error); 94 93 } else console.log(`Rebuilt for ${colorizedBrowserName}`);
+2 -1
import_map.json
··· 2 2 "imports": { 3 3 "asserts": "https://deno.land/std@0.138.0/testing/asserts.ts", 4 4 "bdd": "https://deno.land/std@0.138.0/testing/bdd.ts", 5 - "emoji": "https://raw.githubusercontent.com/ivebencrazy/emoji/add-update-action/mod.ts", 5 + "browser": "./source/browser_api/mod.ts", 6 + "emoji": "https://deno.land/x/emoji@0.2.0/mod.ts", 6 7 "fs": "https://deno.land/std@0.138.0/fs/mod.ts", 7 8 "mock": "https://deno.land/std@0.138.0/testing/mock.ts", 8 9 "preact": "https://esm.sh/preact?dev",
+7 -11
source/background.ts
··· 2 2 * Serves as bridge point between popup and content_script. 3 3 */ 4 4 5 + import type { Tab, TabChangeInfo } from 'browser'; 5 6 import type { Favicon, Settings } from './types.ts'; 6 - import type { 7 - Tab, 8 - TabChangeInfo, 9 - } from './utilities/browser_api_interface/mod.ts'; 7 + 10 8 import { defaultSettings, STORAGE_KEYS } from './types.ts'; 11 9 import Autoselector from './utilities/autoselector.ts'; 12 - import browserAPI from './utilities/browser_api.ts'; 10 + import browserAPI from 'browser'; 13 11 14 12 const autoselector = new Autoselector(); 15 13 let settings: Settings = defaultSettings; ··· 59 57 ); 60 58 61 59 async function updateCache() { 62 - try { 63 - const storedSettings: Settings = await browserAPI.storage.sync.get( 64 - STORAGE_KEYS, 65 - ) as Settings; 66 - if (storedSettings) settings = storedSettings; 67 - } catch {} 60 + const storedSettings: Settings = await browserAPI.storage.sync.get( 61 + STORAGE_KEYS, 62 + ) as Settings; 63 + if (storedSettings) settings = storedSettings; 68 64 }
+3 -2
source/content_script.ts
··· 5 5 * Use those to determine if we should override favicon 6 6 * Override favicon if applicable 7 7 */ 8 + import browserAPI from 'browser'; 9 + 8 10 import type { Favicon } from './types.ts'; 9 11 import { appendFaviconLink } from './utilities/favicon_helpers.ts'; 10 - import browserAPI from './utilities/browser_api.ts'; 11 12 12 - browserAPI.storage.onChanged.addListener(async (changes) => { 13 + browserAPI.storage.onChanged.addListener((changes) => { 13 14 if (changes?.siteList) { 14 15 const { newValue = [], oldValue = [] } = changes?.siteList || {}; 15 16 const newDiff = newValue.filter(includesCurrUrl);
+3 -3
source/hooks/use_browser_storage.ts
··· 1 1 import { useCallback, useEffect, useState } from 'preact/hooks'; 2 - import browserAPI from '../utilities/browser_api.ts'; 2 + import browserAPI from 'browser'; 3 3 const { storage, runtime } = browserAPI; 4 4 5 5 // deno-lint-ignore no-explicit-any ··· 37 37 setLoading(false); 38 38 }); 39 39 40 - browserAPI.storage.onChanged.addListener(async (changes) => { 40 + browserAPI.storage.onChanged.addListener(async () => { 41 41 setCache(await storage.sync.get(keys) as Type); 42 42 }); 43 43 }, []); ··· 63 63 loading, 64 64 65 65 setCache: useCallback( 66 - (nextCache: Partial<Type>, saveImmediately: boolean = false): void => { 66 + (nextCache: Partial<Type>, saveImmediately = false): void => { 67 67 const nextStorage = { ...cache, ...nextCache }; 68 68 setCache(nextStorage as Type); 69 69 if (saveImmediately) saveToStorage(nextStorage);
+5 -2
source/hooks/use_status.ts
··· 2 2 3 3 const STATUS_TIME = 4000; 4 4 5 + // deno-lint-ignore no-explicit-any 6 + type SaveFunc = (...args: any[]) => any | void; 7 + 5 8 export default function useStatus( 6 9 error: string, 7 - save: (...args: any[]) => Promise<void>, 10 + save: SaveFunc, 8 11 ) { 9 12 const [status, setStatus] = useState<string>(''); 10 13 ··· 15 18 16 19 return { 17 20 status, 18 - save: useCallback(async (...args: any[]) => { 21 + save: useCallback<SaveFunc>(async (...args) => { 19 22 try { 20 23 await save(...args); 21 24 setStatus('Successfully Saved');
+15 -16
source/popup.tsx
··· 1 1 /* @jsx h */ 2 - import type { Tab } from './utilities/browser_api_interface/mod.ts'; 3 - 2 + import type { Tab } from 'browser'; 4 3 import { h, render } from 'preact'; 5 4 import { useCallback, useEffect, useMemo, useState } from 'preact/hooks'; 5 + import browserAPI from 'browser'; 6 + 6 7 import useBrowserStorage from './hooks/use_browser_storage.ts'; 7 - import browserAPI from './utilities/browser_api.ts'; 8 8 import useStatus from './hooks/use_status.ts'; 9 9 import { Settings, STORAGE_KEYS } from './types.ts'; 10 10 ··· 27 27 setup().catch(console.error); 28 28 }, [cache]); 29 29 30 - const { status, save } = useStatus( 31 - error || '', 32 - useCallback(async (add: boolean) => { 33 - if (!url) return; 34 - const origin = (new URL(url)).origin; 35 - const siteList = cache?.siteList || []; 36 - const nextList = siteList.filter((filter) => filter !== origin); 37 - if (add) nextList.push(origin); 38 - setCache({ siteList: nextList }, true); 39 - }, [url, cache, setCache]), 40 - ); 30 + const addSite = useCallback((add: boolean) => { 31 + if (!url) return; 32 + const origin = (new URL(url)).origin; 33 + const siteList = cache?.siteList || []; 34 + const nextList = siteList.filter((filter) => filter !== origin); 35 + if (add) nextList.push(origin); 36 + setCache({ siteList: nextList }, true); 37 + }, [url, cache, setCache]); 38 + 39 + const { status, save } = useStatus(error || '', addSite); 41 40 42 41 const addToOverrides = useCallback(() => { 43 42 save(true); 44 - }, [cache, url, setCache]); 43 + }, [save]); 45 44 46 45 const removeFromOverrides = useCallback(() => { 47 46 save(false); 48 - }, [cache, url, setCache]); 47 + }, [save]); 49 48 50 49 const goToOptions = useCallback(() => { 51 50 browserAPI.runtime.openOptionsPage();
+1 -1
source/utilities/autoselector.ts
··· 4 4 import LEGACY_EMOJI_SET from '../config/legacy_autoselect_set.ts'; 5 5 6 6 const emojis = emoji.all(); 7 - console.log(emojis); 7 + 8 8 type EmojiMap = { [alias: string]: emoji.Emoji }; 9 9 10 10 const NON_SPACING_MARK = String.fromCharCode(65039); // 65039 - '️' - 0xFE0F;
+14 -2
source/utilities/browser_api.ts source/browser_api/mod.ts
··· 12 12 * 13 13 * @todo Borrows heavily from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome 14 14 */ 15 - import { isChrome } from './predicates.ts'; 16 - import { BrowserAPI } from './browser_api_interface/mod.ts'; 15 + import { isChrome } from '../utilities/predicates.ts'; 16 + 17 + import type { PermissionsModule } from './modules/permissions.ts'; 18 + import type { RuntimeModule } from './modules/runtime.ts'; 19 + import type { StorageModule } from './modules/storage.ts'; 20 + import type { TabsModule } from './modules/tabs.ts'; 21 + export * from './modules/tabs.ts'; 22 + 23 + export interface BrowserAPI { 24 + permissions: PermissionsModule; 25 + runtime: RuntimeModule; 26 + storage: StorageModule; 27 + tabs: TabsModule; 28 + } 17 29 18 30 const browserAPI: BrowserAPI = isChrome() 19 31 // deno-lint-ignore no-explicit-any
-13
source/utilities/browser_api_interface/mod.ts
··· 1 - import type { PermissionsModule } from './modules/permissions.ts'; 2 - import type { RuntimeModule } from './modules/runtime.ts'; 3 - import type { StorageModule } from './modules/storage.ts'; 4 - import type { TabsModule } from './modules/tabs.ts'; 5 - 6 - export * from './modules/tabs.ts'; 7 - 8 - export interface BrowserAPI { 9 - permissions: PermissionsModule; 10 - runtime: RuntimeModule; 11 - storage: StorageModule; 12 - tabs: TabsModule; 13 - }
source/utilities/browser_api_interface/modules/event.ts source/browser_api/modules/event.ts
source/utilities/browser_api_interface/modules/manifest.ts source/browser_api/modules/manifest.ts
source/utilities/browser_api_interface/modules/permissions.ts source/browser_api/modules/permissions.ts
source/utilities/browser_api_interface/modules/platform.ts source/browser_api/modules/platform.ts
source/utilities/browser_api_interface/modules/runtime.ts source/browser_api/modules/runtime.ts
source/utilities/browser_api_interface/modules/storage.ts source/browser_api/modules/storage.ts
source/utilities/browser_api_interface/modules/tabs.ts source/browser_api/modules/tabs.ts
source/utilities/browser_api_interface/modules/web_request.ts source/browser_api/modules/web_request.ts
source/utilities/browser_api_interface/modules/windows.ts source/browser_api/modules/windows.ts
+1
source/utilities/predicates.ts
··· 37 37 export function isChrome(): boolean { 38 38 return isBrowser('CHROME'); 39 39 } 40 + 40 41 export function isFirefox(): boolean { 41 42 return isBrowser('FIREFOX'); 42 43 }