Skip to content

Commit

Permalink
Merge pull request #46 from DaniloNovakovic/v3.0.2-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniloNovakovic authored Jun 29, 2020
2 parents 5d59fda + cc94df5 commit 152d93d
Show file tree
Hide file tree
Showing 20 changed files with 5,241 additions and 1,617 deletions.
19 changes: 12 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true
es6: true,
},
extends: "eslint:recommended",
extends: ["eslint:recommended", "plugin:jest/recommended"],
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly"
SharedArrayBuffer: "readonly",
},
parserOptions: {
ecmaFeatures: {
jsx: true
experimentalObjectRestSpread: true,
jsx: true,
},
ecmaVersion: 2018,
sourceType: "module"
sourceType: "module",
},
plugins: ["react", "jest"],
rules: {
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
},
plugins: ["react"],
rules: {}
};
6,410 changes: 4,951 additions & 1,459 deletions package-lock.json

Large diffs are not rendered by default.

51 changes: 26 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chrome-dynamic-bookmarks",
"version": "3.0.1",
"version": "3.0.2",
"description": "Chrome extension which dynamically updates bookmarks based on the specified regular expression.",
"scripts": {
"start": "webpack-dev-server --open --env.env=dev",
Expand All @@ -13,60 +13,61 @@
"test": "jest"
},
"dependencies": {
"@material-ui/core": "^4.5.2",
"@material-ui/core": "^4.10.2",
"@material-ui/icons": "^4.5.1",
"clsx": "^1.0.4",
"core-js": "^3.3.6",
"core-js": "^3.6.5",
"denque": "^1.4.1",
"formik": "^1.5.8",
"formik-material-ui": "0.0.22",
"lodash": "^4.17.15",
"notistack": "^0.9.5",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"notistack": "^0.9.17",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hotkeys": "^2.0.0",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"yup": "^0.27.0"
},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/core": "^7.10.3",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-async-to-generator": "^7.5.0",
"@babel/preset-env": "^7.6.3",
"@babel/preset-env": "^7.10.3",
"@babel/preset-react": "^7.6.3",
"@types/jest": "^24.0.21",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"babel-plugin-import": "^1.12.2",
"buffer": "^5.4.3",
"buffer": "^5.6.0",
"chalk": "^2.4.2",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.0.4",
"copy-webpack-plugin": "^5.1.1",
"cross-env": "^6.0.3",
"css-loader": "^3.2.0",
"eslint": "^6.6.0",
"eslint-plugin-react": "^7.16.0",
"file-loader": "^4.2.0",
"css-loader": "^3.6.0",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.17.1",
"eslint-plugin-react": "^7.20.1",
"file-loader": "^4.3.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.9.0",
"mini-css-extract-plugin": "^0.8.0",
"mini-css-extract-plugin": "^0.8.2",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"prop-types": "^15.7.2",
"react-hot-loader": "^4.12.15",
"rimraf": "^3.0.0",
"style-loader": "^1.0.0",
"terser-webpack-plugin": "^2.2.1",
"react-hot-loader": "^4.12.21",
"rimraf": "^3.0.2",
"style-loader": "^1.2.1",
"terser-webpack-plugin": "^2.3.7",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.41.2",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0",
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.8.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-merge": "^4.2.2"
},
"main": "index.js",
Expand Down
14 changes: 7 additions & 7 deletions src/background/addConnectListeners.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { getCurrentBrowser } from "shared/lib/browser";
import { getCurrentBrowser, logInfo } from "shared/lib/browser";

const browser = getCurrentBrowser();

export default function addConnectListeners(observable) {
browser.runtime.onConnect.addListener(port => {
browser.runtime.onConnect.addListener((port) => {
const key = getKeyFromPort(port);
console.log("subscribing", key);
observable.subscribe(key, event => port.postMessage(event));
logInfo(`subscribing: ${key}`);
observable.subscribe(key, (event) => port.postMessage(event));

port.onDisconnect.addListener(p => {
console.log("unsubscribing", p);
port.onDisconnect.addListener((p) => {
logInfo("unsubscribing", p);
observable.unsubscribe(key);
});
});

function getKeyFromPort(port) {
console.log(port);
logInfo(port);
const sender = port.sender;
return `${sender.id}-${sender.url}-${sender.tlsChannelId}`;
}
Expand Down
5 changes: 3 additions & 2 deletions src/background/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import addInstalledListeners from "./addInstalledListeners";
import addMessageListeners from "./addMessageListeners";
import addTabsListeners from "./addTabsListeners";
import createObservable from "./createObservable";
import { logInfo } from "shared/lib/browser";

const observable = createObservable();
observable.subscribe("logger", event => console.log(event));
observable.subscribe("logger", (event) => logInfo(event));

addInstalledListeners();
addTabsListeners();
addMessageListeners();
addConnectListeners(observable);
addBookmarkListeners(event => observable.notify(event));
addBookmarkListeners((event) => observable.notify(event));
4 changes: 2 additions & 2 deletions src/background/requestHandlers/addBookmarkNodeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function addBookmarkNodeHandler({ data }, sendResponse) {
} else {
sendResponse({
type: responseTypes.SUCCESS,
message: `Successfully created bookmark node ${createdNode.id}`,
data: createdNode
message: `Successfully created bookmark '${createdNode.title}'`,
data: createdNode,
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/background/requestHandlers/editBookmarkNodeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function editBookmarkNodeHandler({ data }, sendResponse) {
sendResponse({
type: responseTypes.SUCCESS,
message: `Successfully updated bookmark node ${updatedNode.id}`,
data: updatedNode
data: updatedNode,
});
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/bookmarkManager/createEventQueueHandler.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import actionTypes from "shared/constants/actionTypes";
import { logInfo } from "shared/lib/browser";

export default function createEventQueueHandler(store, reducer) {
return function queueHandler(eventQueue) {
let state = store.getState();
while (!eventQueue.isEmpty()) {
const event = eventQueue.dequeue();
logInfo(event);
state = reducer(state, event);
}
store.dispatch({ type: actionTypes.SET_STATE, state });
Expand Down
7 changes: 4 additions & 3 deletions src/popup/NavTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import { LinkTab } from "shared/components/helpers";
function a11yProps(index) {
return {
id: `nav-tab-${index}`,
"aria-controls": `nav-tabpanel-${index}`
"aria-controls": `nav-tabpanel-${index}`,
};
}

export default function NavTabs(props) {
return (
<AppBar position="static">
<Tabs
variant="fullWidth"
variant="scrollable"
scrollButtons="on"
value={props.value}
onChange={props.onChange}
aria-label="Navigation Tabs"
Expand All @@ -35,5 +36,5 @@ export default function NavTabs(props) {

NavTabs.propTypes = {
value: PropTypes.number.isRequired,
onChange: PropTypes.func.isRequired
onChange: PropTypes.func.isRequired,
};
23 changes: 13 additions & 10 deletions src/shared/lib/browser/dynBookmarksFacade.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function copyBookmarkNode(id, { parentId, index }, done) {
done(errMsg);
}
copyNodeAsync({ ...node, parentId, index })
.then(_ => done(null))
.then(() => done(null))
.catch(done);
});
}
Expand All @@ -53,11 +53,11 @@ export function editBookmarkNode(node, done) {
done(null, { ...updatedNode, ...updatedDynBookItem });
});
} else {
storage.findByIdAndRemove(node.id, errMsg => {
storage.findByIdAndRemove(node.id, (errMsg) => {
if (errMsg) {
return done(errMsg);
}
done(null, updatedNode);
done(null, { ...updatedNode, regExp: "" });
});
}
});
Expand All @@ -68,13 +68,16 @@ export function createBookmarkNode(node, done) {
if (errMsg) {
return done(errMsg);
}
if (node.regExp) {
storage.create(
{ id: createdNode.id, regExp: node.regExp, history: [] },
done
);
if (!node.regExp) {
done(null, createdNode);
}
done(null, createdNode);
storage.create(
{ id: createdNode.id, regExp: node.regExp, history: [] },
(errMsg, item) => {
if (errMsg) return done(errMsg);
done(null, { ...createdNode, ...item });
}
);
});
}

Expand All @@ -89,7 +92,7 @@ export function removeBookmarkNode(id, done) {
if (!node.url) {
bookmarks.removeTree(id, done);
} else {
bookmarks.remove(id, errMsg => {
bookmarks.remove(id, (errMsg) => {
if (errMsg) {
return done(errMsg);
}
Expand Down
13 changes: 10 additions & 3 deletions src/shared/lib/browser/log/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ import getCurrentBrowser from "../getCurrentBrowser";
const browser = getCurrentBrowser();
const runtime = browser.runtime;

export function logInfo(msg) {
console.log(msg);
export function logInfo(msg, ...optionalParams) {
if (!msg) {
return;
}
if (!optionalParams) {
console.log(msg);
} else {
console.log(msg, ...optionalParams);
}
}

export function logError(errMsg) {
Expand Down Expand Up @@ -33,5 +40,5 @@ export function checkAndHandleError(onErrorFound = logError) {
export default {
logError,
logWarn,
checkAndHandleError
checkAndHandleError,
};
7 changes: 4 additions & 3 deletions src/shared/lib/browser/messages/sendMessage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import getCurrentBrowser from "../getCurrentBrowser";
import responseTypes from "shared/constants/responseTypes";
import { logInfo } from "../log";

const browser = getCurrentBrowser();

/**
* @callback onResponseFunction
* @param {{type: string, message: string}} response
* @param {{type: string, message: string, data?: any} response
*/

/**
Expand All @@ -17,11 +18,10 @@ const browser = getCurrentBrowser();
export default function sendMessage(type, data, onResponse) {
const req = {
type,
data
data,
};

function handleResponse(res = {}) {
console.log("response", res);
if (!res.type) {
res.type = responseTypes.ERROR;
}
Expand All @@ -35,6 +35,7 @@ export default function sendMessage(type, data, onResponse) {
}
}

logInfo("response", res);
onResponse(res);
}

Expand Down
Loading

0 comments on commit 152d93d

Please sign in to comment.