diff --git a/config/webpack.common.js b/config/webpack.common.js index 67e4508..b1f0280 100644 --- a/config/webpack.common.js +++ b/config/webpack.common.js @@ -53,7 +53,7 @@ const common = { patterns: [ { from: '**/*', - context: 'public', + context: 'src/asset', }, ] }), diff --git a/config/webpack.config.js b/config/webpack.config.js index f1854cd..9844c47 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -10,7 +10,7 @@ const config = merge(common, { entry: { popup: PATHS.src + '/popup.ts', contentScript: PATHS.src + '/contentScript.ts', - background: PATHS.src + '/background.js', + background: PATHS.src + '/background.ts', index: PATHS.src + '/index.ts', }, resolve: { diff --git a/public/manifest.json b/public/manifest.json deleted file mode 100644 index d721ba1..0000000 --- a/public/manifest.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "manifest_version": 3, - "name": "Filigrane", - "version": "0.1.0", - "description": "My Chrome Extension", - "options_page": "options.html", - "icons": { - "16": "icons/icon_16.png", - "32": "icons/icon_32.png", - "48": "icons/icon_48.png", - "128": "icons/icon_128.png" - }, - "background": { - "service_worker": "background.js" - }, - "action": { - "default_title": "Filigrane", - "default_popup": "popup.html" - }, - "permissions": [ - "storage", - "downloads" - ], - "content_scripts": [ - { - "matches": [ - "" - ], - "run_at": "document_idle", - "js": [ - "contentScript.js" - ] - } - ] -} \ No newline at end of file diff --git a/public/index.html b/src/asset/html/index.html similarity index 100% rename from public/index.html rename to src/asset/html/index.html diff --git a/public/options.html b/src/asset/html/options.html similarity index 100% rename from public/options.html rename to src/asset/html/options.html diff --git a/public/popup.html b/src/asset/html/popup.html similarity index 100% rename from public/popup.html rename to src/asset/html/popup.html diff --git a/public/icons/icon_128.png b/src/asset/icons/icon_128.png similarity index 100% rename from public/icons/icon_128.png rename to src/asset/icons/icon_128.png diff --git a/public/icons/icon_16.png b/src/asset/icons/icon_16.png similarity index 100% rename from public/icons/icon_16.png rename to src/asset/icons/icon_16.png diff --git a/public/icons/icon_32.png b/src/asset/icons/icon_32.png similarity index 100% rename from public/icons/icon_32.png rename to src/asset/icons/icon_32.png diff --git a/public/icons/icon_48.png b/src/asset/icons/icon_48.png similarity index 100% rename from public/icons/icon_48.png rename to src/asset/icons/icon_48.png diff --git a/src/index.scss b/src/asset/style/index.scss similarity index 100% rename from src/index.scss rename to src/asset/style/index.scss diff --git a/src/background.js b/src/background.ts similarity index 100% rename from src/background.js rename to src/background.ts diff --git a/src/shared.ts b/src/constant.ts similarity index 100% rename from src/shared.ts rename to src/constant.ts diff --git a/src/index.ts b/src/index.ts index 64ceb73..97f6bed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ -import './index.scss'; +import './asset/style/index.scss'; import { saveAs } from 'file-saver'; -import { FiligraneServices } from './filigrane.services'; +import { FiligraneServices } from './services/filigrane.services'; (() => { const filesMap = new Map(); diff --git a/src/popup-backup.js b/src/popup-backup.js deleted file mode 100644 index df75fa7..0000000 --- a/src/popup-backup.js +++ /dev/null @@ -1,119 +0,0 @@ -'use strict'; - - -// import './popup.css'; - -(function() { - // We will make use of Storage API to get and store `count` value - // More information on Storage API can we found at - // https://developer.chrome.com/extensions/storage - - // To get storage access, we have to mention it in `permissions` property of manifest.json file - // More information on Permissions can we found at - // https://developer.chrome.com/extensions/declare_permissions - const counterStorage = { - get: cb => { - chrome.storage.sync.get(['count'], result => { - cb(result.count); - }); - }, - set: (value, cb) => { - chrome.storage.sync.set( - { - count: value, - }, - () => { - cb(); - } - ); - }, - }; - - function setupCounter(initialValue = 0) { - document.getElementById('counter').innerHTML = initialValue; - - document.getElementById('incrementBtn').addEventListener('click', () => { - updateCounter({ - type: 'INCREMENT', - }); - }); - - document.getElementById('decrementBtn').addEventListener('click', () => { - updateCounter({ - type: 'DECREMENT', - }); - }); - } - - function updateCounter({ type }) { - counterStorage.get(count => { - let newCount; - - if (type === 'INCREMENT') { - newCount = count + 1; - } else if (type === 'DECREMENT') { - newCount = count - 1; - } else { - newCount = count; - } - - counterStorage.set(newCount, () => { - document.getElementById('counter').innerHTML = newCount; - - // Communicate with content script of - // active tab by sending a message - chrome.tabs.query({ active: true, currentWindow: true }, tabs => { - const tab = tabs[0]; - - chrome.tabs.sendMessage( - tab.id, - { - type: 'COUNT', - payload: { - count: newCount, - }, - }, - response => { - console.log('Current count value passed to contentScript file'); - } - ); - }); - }); - }); - } - - function restoreCounter() { - // Restore count value - counterStorage.get(count => { - if (typeof count === 'undefined') { - // Set counter value as 0 - counterStorage.set(0, () => { - setupCounter(0); - }); - } else { - setupCounter(count); - } - }); - - document.getElementById('settings').href = `chrome-extension://${chrome.runtime.id}/options.html`; - } - - document.addEventListener('DOMContentLoaded', restoreCounter); - - - // Communicate with background file by sending a message - chrome.runtime.sendMessage( - { - type: 'GREETINGS', - payload: { - message: 'Hello, my name is Pop. I am from Popup.', - }, - }, - response => { - console.log(response.message); - } - ); - - - console.log(chrome.runtime.id) -})(); diff --git a/src/popup.css b/src/popup.css deleted file mode 100644 index 1a43c4c..0000000 --- a/src/popup.css +++ /dev/null @@ -1,92 +0,0 @@ -/* normalize css starts here */ -*, -*::before, -*::after { - margin: 0; - padding: 0; - box-sizing: border-box; -} -/* normalize css ends here */ - - -html { - font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif; - color: #222; -} - -body { - width: 350px; - height: 300px; -} - -.app { - height: 100%; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - text-align: center; - padding: 20px; -} - -.title { - font-size: 18px; - font-weight: 600; - margin-bottom: 10px; -} - -.subtitle { - font-size: 12px; -} - -code { - font-size: 12px; - font-family: inherit; - background-color: rgba(254, 237, 185, .3); - padding: 2px 4px; - border-radius: 2px; -} - -.counter-label { - font-size: 12px; - margin-bottom: 5px; -} - -.counter { - font-size: 36px; - font-weight: 700; -} - -.button-container { - margin-top: 15px; -} - -.button { - border: 0; - display: inline-block; - padding: 10px 20px; - margin-right: 4px; - margin-left: 4px; - background-color: bisque; - font-size: 16px; - cursor: pointer; - border-radius: 4px; - text-decoration: none; - transition: transform .2s ease; - user-select: none; -} - -.button:focus { - outline: none; -} - -.button:hover { - transform: scale(1.1); -} - -.divider { - margin: 30px auto 25px; - width: 50px; - border: .5px dashed #000; - opacity: .1; -} diff --git a/src/popup.ts b/src/popup.ts index bbbfc70..ee05bce 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -1,4 +1,5 @@ -import { FiligraneServices } from './filigrane.services'; +import { FiligraneServices } from "./services/filigrane.services"; + (() => { let filesWithFiligrane: File[]; diff --git a/src/filigrane.services.ts b/src/services/filigrane.services.ts similarity index 100% rename from src/filigrane.services.ts rename to src/services/filigrane.services.ts