Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

clipper(web): fix all eslint warnings

Abdullah Atta7cd6a6e9eef3
diff --git a/apps/web/package.json b/apps/web/package.json
index eb8b2e04b..5d401bb7a 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -3,7 +3,7 @@
"description": "Your private note taking space",
"version": "2.2.4",
"private": true,
- "main": "./src/App.js",
+ "main": "./src/app.js",
"homepage": "https://notesnook.com/",
"repository": "https://github.com/streetwriters/notesnook",
"license": "GPL-3.0-or-later",
@@ -136,8 +136,5 @@
"name": "Streetwriters (Private) Ltd.",
"email": "[email protected]",
"url": "https://streetwriters.co"
- },
- "volta": {
- "node": "16.15.1"
}
}
diff --git a/extensions/web-clipper/build-utils/build.js b/extensions/web-clipper/build-utils/build.js
index 2a60b840e..2c948481e 100644
--- a/extensions/web-clipper/build-utils/build.js
+++ b/extensions/web-clipper/build-utils/build.js
@@ -1,4 +1,21 @@
-// Do this as the first thing so that any code reading it knows the right env.
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
process.env.BABEL_ENV = "production";
process.env.NODE_ENV = "production";
process.env.ASSET_PATH = "/";
diff --git a/extensions/web-clipper/build-utils/dev.js b/extensions/web-clipper/build-utils/dev.js
index 61297df29..85dffc29c 100644
--- a/extensions/web-clipper/build-utils/dev.js
+++ b/extensions/web-clipper/build-utils/dev.js
@@ -1,4 +1,21 @@
-// Do this as the first thing so that any code reading it knows the right env.
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
process.env.BABEL_ENV = "development";
process.env.NODE_ENV = "development";
process.env.ASSET_PATH = "/";
diff --git a/extensions/web-clipper/build-utils/env.js b/extensions/web-clipper/build-utils/env.js
index 960b25877..9e3dd1443 100644
--- a/extensions/web-clipper/build-utils/env.js
+++ b/extensions/web-clipper/build-utils/env.js
@@ -1,4 +1,21 @@
-// tiny wrapper with default env vars
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
module.exports = {
NODE_ENV: process.env.NODE_ENV || "development",
PORT: process.env.PORT || 3000,
diff --git a/extensions/web-clipper/build-utils/manifest.js b/extensions/web-clipper/build-utils/manifest.js
index 370642093..22b6851eb 100644
--- a/extensions/web-clipper/build-utils/manifest.js
+++ b/extensions/web-clipper/build-utils/manifest.js
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
const ICONS = {
16: "16x16.png",
32: "32x32.png",
diff --git a/extensions/web-clipper/global.d.ts b/extensions/web-clipper/global.d.ts
index f53a87ad4..f3acb7392 100644
--- a/extensions/web-clipper/global.d.ts
+++ b/extensions/web-clipper/global.d.ts
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
declare module "*.svg" {
import React = require("react");
export const ReactComponent: React.SFC<React.SVGProps<SVGSVGElement>>;
diff --git a/extensions/web-clipper/package.json b/extensions/web-clipper/package.json
index 93a6b2274..27928b5b6 100644
--- a/extensions/web-clipper/package.json
+++ b/extensions/web-clipper/package.json
@@ -32,16 +32,6 @@
"dev:firefox": "MANIFEST_VERSION=2 node build-utils/dev.js",
"build": "tsc"
},
- "eslintConfig": {
- "extends": "react-app",
- "env": {
- "browser": true,
- "commonjs": true,
- "es6": true,
- "node": true,
- "webextensions": true
- }
- },
"browserslist": {
"production": [
">0.2%",
@@ -106,5 +96,13 @@
],
"extensions": "ts,js,json,tsx,jsx"
}
- }
+ },
+ "license": "GPL-3.0-or-later",
+ "author": {
+ "name": "Streetwriters (Private) Ltd.",
+ "email": "[email protected]",
+ "url": "https://streetwriters.co"
+ },
+ "homepage": "https://notesnook.com/",
+ "repository": "https://github.com/streetwriters/notesnook"
}
diff --git a/extensions/web-clipper/src/api.ts b/extensions/web-clipper/src/api.ts
index 0e367f327..f78776755 100644
--- a/extensions/web-clipper/src/api.ts
+++ b/extensions/web-clipper/src/api.ts
@@ -1,34 +1,56 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { browser, Runtime } from "webextension-polyfill-ts";
import { Remote, wrap } from "comlink";
import { createEndpoint } from "./utils/comlink-extension";
import { Server } from "./common/bridge";
import { APP_URL, APP_URL_FILTER } from "./common/constants";
+type WebExtensionChannelMessage = { success: boolean };
+
let api: Remote<Server> | undefined;
export async function connectApi(openNew = false, onDisconnect?: () => void) {
if (api) return api;
const tab = await getTab(openNew);
- if (!tab || !tab.id) return false;
+ if (!tab) return false;
+
+ return await new Promise<Remote<Server> | false>(function connect(resolve) {
+ if (!tab.id) return resolve(false);
- return await new Promise<Remote<Server> | undefined>(function connect(
- resolve,
- reject
- ) {
- const port = browser.tabs.connect(tab.id!);
+ const port = browser.tabs.connect(tab.id);
port.onDisconnect.addListener(() => {
api = undefined;
onDisconnect?.();
});
- async function onMessage(message: any, port: Runtime.Port) {
- if (message?.success) {
+ async function onMessage(
+ message: WebExtensionChannelMessage,
+ port: Runtime.Port
+ ) {
+ if (message.success) {
port.onMessage.removeListener(onMessage);
api = wrap<Server>(createEndpoint(port));
resolve(api);
} else {
- resolve(undefined);
+ resolve(false);
}
}
diff --git a/extensions/web-clipper/src/app.tsx b/extensions/web-clipper/src/app.tsx
index 078d34eee..bbe34acb2 100644
--- a/extensions/web-clipper/src/app.tsx
+++ b/extensions/web-clipper/src/app.tsx
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { ThemeProvider } from "./components/theme-provider";
import { useAppStore } from "./stores/app-store";
import { Login } from "./views/login";
diff --git a/extensions/web-clipper/src/background.ts b/extensions/web-clipper/src/background.ts
index 6195ece14..4f0aa25c2 100644
--- a/extensions/web-clipper/src/background.ts
+++ b/extensions/web-clipper/src/background.ts
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { browser } from "webextension-polyfill-ts";
import { storeClip } from "./utils/storage";
diff --git a/extensions/web-clipper/src/common/constants.ts b/extensions/web-clipper/src/common/constants.ts
index cfddd85fa..e86930042 100644
--- a/extensions/web-clipper/src/common/constants.ts
+++ b/extensions/web-clipper/src/common/constants.ts
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
export const APP_URL =
process.env.NODE_ENV === "production"
? "https://app.notesnook.com"
diff --git a/extensions/web-clipper/src/components/filtered-list/index.tsx b/extensions/web-clipper/src/components/filtered-list/index.tsx
index 16226ee22..1b41b2aba 100644
--- a/extensions/web-clipper/src/components/filtered-list/index.tsx
+++ b/extensions/web-clipper/src/components/filtered-list/index.tsx
@@ -1,4 +1,22 @@
-import React, { useCallback, useEffect, useRef, useState } from "react";
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+import { useCallback, useEffect, useRef, useState } from "react";
import { Button, Flex, Input, Text } from "@theme-ui/components";
import { Icon } from "../icons/icon";
import { Icons } from "../icons";
diff --git a/extensions/web-clipper/src/components/icons/icon.tsx b/extensions/web-clipper/src/components/icons/icon.tsx
index 94b8fb123..0a65a46f6 100644
--- a/extensions/web-clipper/src/components/icons/icon.tsx
+++ b/extensions/web-clipper/src/components/icons/icon.tsx
@@ -1,4 +1,21 @@
-import React from "react";
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import MDIIcon from "@mdi/react";
import { SchemeColors } from "@notesnook/theme/dist/theme/colorscheme";
import { Flex, FlexProps } from "@theme-ui/components";
diff --git a/extensions/web-clipper/src/components/icons/index.ts b/extensions/web-clipper/src/components/icons/index.ts
index b9224152a..bf39ae7b4 100644
--- a/extensions/web-clipper/src/components/icons/index.ts
+++ b/extensions/web-clipper/src/components/icons/index.ts
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import {
mdiCheck,
mdiChevronDown,
diff --git a/extensions/web-clipper/src/components/note-picker/index.tsx b/extensions/web-clipper/src/components/note-picker/index.tsx
index eb441db01..43731df94 100644
--- a/extensions/web-clipper/src/components/note-picker/index.tsx
+++ b/extensions/web-clipper/src/components/note-picker/index.tsx
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { useState } from "react";
import { Button, Flex, Text } from "@theme-ui/components";
import { FilteredList } from "../filtered-list";
diff --git a/extensions/web-clipper/src/components/notebook-picker/index.tsx b/extensions/web-clipper/src/components/notebook-picker/index.tsx
index 0557889cc..8f454e87e 100644
--- a/extensions/web-clipper/src/components/notebook-picker/index.tsx
+++ b/extensions/web-clipper/src/components/notebook-picker/index.tsx
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { useState } from "react";
import { Button, Flex, Text } from "@theme-ui/components";
import { FilteredList } from "../filtered-list";
@@ -83,7 +101,7 @@ export const NotebookPicker = (props: NotebookPickerProps) => {
itemName="notebook"
placeholder={"Search for a notebook"}
refreshItems={() => notebooks}
- renderItem={(item, index) => (
+ renderItem={(item) => (
<Notebook
notebook={item}
isExpanded={expanded === item.id}
@@ -156,7 +174,7 @@ function Notebook(props: NotebookProps) {
itemName="topic"
placeholder={"Search for a topic"}
refreshItems={() => notebook.topics}
- renderItem={(topic, index) => (
+ renderItem={(topic) => (
<Topic
topic={topic}
onSelected={() => {
diff --git a/extensions/web-clipper/src/components/picker/index.tsx b/extensions/web-clipper/src/components/picker/index.tsx
index f83b11dde..fe4c81a9c 100644
--- a/extensions/web-clipper/src/components/picker/index.tsx
+++ b/extensions/web-clipper/src/components/picker/index.tsx
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { PropsWithChildren } from "react";
import Modal from "react-modal";
import { Flex } from "@theme-ui/components";
diff --git a/extensions/web-clipper/src/components/tag-picker/index.tsx b/extensions/web-clipper/src/components/tag-picker/index.tsx
index 9ee1311e6..229252569 100644
--- a/extensions/web-clipper/src/components/tag-picker/index.tsx
+++ b/extensions/web-clipper/src/components/tag-picker/index.tsx
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { useState } from "react";
import { Button, Flex, Text } from "@theme-ui/components";
import { FilteredList } from "../filtered-list";
@@ -35,7 +53,7 @@ export const TagPicker = (props: TagPickerProps) => {
}}
>
{selectedTags.length
- ? selectedTags.map((tag, index) => (
+ ? selectedTags.map((tag) => (
<InlineTag
key={tag}
tag={tag}
@@ -77,7 +95,7 @@ export const TagPicker = (props: TagPickerProps) => {
placeholder={"Search for a tag"}
onCreateNewItem={(tag) => onSelected(tag)}
refreshItems={() => tags}
- renderItem={(tag, index) => (
+ renderItem={(tag) => (
<Tag
tag={tag}
onSelected={() => {
diff --git a/extensions/web-clipper/src/content-scripts/all.ts b/extensions/web-clipper/src/content-scripts/all.ts
index ec725f141..b05f2e05a 100644
--- a/extensions/web-clipper/src/content-scripts/all.ts
+++ b/extensions/web-clipper/src/content-scripts/all.ts
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { browser } from "webextension-polyfill-ts";
import {
clipArticle,
diff --git a/extensions/web-clipper/src/content-scripts/nn.ts b/extensions/web-clipper/src/content-scripts/nn.ts
index 411fab8c7..a366acb7e 100644
--- a/extensions/web-clipper/src/content-scripts/nn.ts
+++ b/extensions/web-clipper/src/content-scripts/nn.ts
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { browser } from "webextension-polyfill-ts";
import { expose, Remote, wrap } from "comlink";
import { createEndpoint } from "../utils/comlink-extension";
@@ -8,7 +26,7 @@ import {
WEB_EXTENSION_CHANNEL_EVENTS
} from "../common/bridge";
-var mainPort: MessagePort | undefined;
+let mainPort: MessagePort | undefined;
browser.runtime.onConnect.addListener((port) => {
if (mainPort) {
diff --git a/extensions/web-clipper/src/index.tsx b/extensions/web-clipper/src/index.tsx
index 364c0ce4c..0d11c9a77 100644
--- a/extensions/web-clipper/src/index.tsx
+++ b/extensions/web-clipper/src/index.tsx
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import "../assets/16x16.png";
import "../assets/32x32.png";
import "../assets/48x48.png";
@@ -9,6 +27,10 @@ import ReactDOM from "react-dom";
import { App } from "./app";
import "./index.css";
+declare let module: NodeModule & {
+ hot?: { accept: () => void };
+};
+
ReactDOM.render(
<React.StrictMode>
<App />
@@ -16,5 +38,4 @@ ReactDOM.render(
document.getElementById("root")
);
-// @ts-ignore
if (module.hot) module.hot.accept();
diff --git a/extensions/web-clipper/src/stores/app-store.tsx b/extensions/web-clipper/src/stores/app-store.tsx
index f23591e7d..d9a6bc9d6 100644
--- a/extensions/web-clipper/src/stores/app-store.tsx
+++ b/extensions/web-clipper/src/stores/app-store.tsx
@@ -1,9 +1,23 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import create from "zustand";
-import {
- ItemReference,
- NotebookReference,
- User
-} from "../common/bridge";
+import { ItemReference, NotebookReference, User } from "../common/bridge";
import { connectApi } from "../api";
interface AppStore {
@@ -17,7 +31,7 @@ interface AppStore {
login(openNew?: boolean): Promise<void>;
}
-export const useAppStore = create<AppStore>((set, get) => ({
+export const useAppStore = create<AppStore>((set) => ({
isLoggedIn: false,
isLoggingIn: false,
notebooks: [],
diff --git a/extensions/web-clipper/src/utils/comlink-extension.ts b/extensions/web-clipper/src/utils/comlink-extension.ts
index 1f23f8804..1e7de42bd 100644
--- a/extensions/web-clipper/src/utils/comlink-extension.ts
+++ b/extensions/web-clipper/src/utils/comlink-extension.ts
@@ -1,21 +1,8 @@
-/*
-This file is part of the Notesnook project (https://notesnook.com/)
+/* eslint-disable @typescript-eslint/no-explicit-any */
+/* eslint-disable header/header */
-Copyright (C) 2022 Streetwriters (Private) Limited
+// Taken from https://github.com/samdenty/comlink-extension
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
import * as Comlink from "comlink";
import { Runtime, browser } from "webextension-polyfill-ts";
@@ -25,7 +12,7 @@ export type Port = Runtime.Port;
export type OnPortCallback = (port: Port) => void;
export type PortResolver = (id: string, onPort: OnPortCallback) => void;
-export type PortDeserializer = (id: string) => MessagePort;
+export type PortDeserializer = (id: string) => MessagePort | undefined;
function _resolvePort(id: string, onPort: OnPortCallback) {
onPort(browser.runtime.connect({ name: id }));
@@ -51,7 +38,7 @@ export function createEndpoint(
function serialize(data: any): void {
if (Array.isArray(data)) {
- data.forEach((value, i) => {
+ data.forEach((value) => {
serialize(value);
});
} else if (data && typeof data === "object") {
@@ -123,7 +110,7 @@ export function createEndpoint(
}
return {
- postMessage: (message, transfer: MessagePort[]) => {
+ postMessage: (message, _transfer: MessagePort[]) => {
serialize(message);
port.postMessage(message);
},
@@ -183,12 +170,13 @@ function serializePort(id: string, onPort: OnPortCallback) {
if (!portCallbacks.has(id)) {
portCallbacks.set(id, []);
}
- const callbacks = portCallbacks.get(id)!;
- callbacks.push(onPort);
+ const callbacks = portCallbacks.get(id);
+ callbacks?.push(onPort);
}
function deserializePort(id: string) {
- const port = ports.get(id)!;
+ const port = ports.get(id);
+ if (!port) return;
const { port1, port2 } = new MessageChannel();
forward(port2, port, serializePort, deserializePort);
return port1;
diff --git a/extensions/web-clipper/src/utils/storage.ts b/extensions/web-clipper/src/utils/storage.ts
index d3f20b9a3..6b4920cb5 100644
--- a/extensions/web-clipper/src/utils/storage.ts
+++ b/extensions/web-clipper/src/utils/storage.ts
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import browser from "webextension-polyfill";
export async function storeClip(data: string) {
diff --git a/extensions/web-clipper/src/views/login.tsx b/extensions/web-clipper/src/views/login.tsx
index dce108f98..cf96d77f0 100644
--- a/extensions/web-clipper/src/views/login.tsx
+++ b/extensions/web-clipper/src/views/login.tsx
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { Button, Flex, Image, Text } from "@theme-ui/components";
import { useEffect, useState } from "react";
import Logo from "../../assets/logo.svg";
diff --git a/extensions/web-clipper/src/views/main.tsx b/extensions/web-clipper/src/views/main.tsx
index c33513837..c313f58ea 100644
--- a/extensions/web-clipper/src/views/main.tsx
+++ b/extensions/web-clipper/src/views/main.tsx
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
import { Box, Button, Flex, Input, Text } from "@theme-ui/components";
import { useEffect, useRef, useState } from "react";
import { browser } from "webextension-polyfill-ts";
diff --git a/extensions/web-clipper/src/views/settings.tsx b/extensions/web-clipper/src/views/settings.tsx
index 27b8a7668..b9cea263c 100644
--- a/extensions/web-clipper/src/views/settings.tsx
+++ b/extensions/web-clipper/src/views/settings.tsx
@@ -1 +1,19 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
export const s = "";
\ No newline at end of file
diff --git a/extensions/web-clipper/webpack.config.js b/extensions/web-clipper/webpack.config.js
index 55429952e..81d038c36 100644
--- a/extensions/web-clipper/webpack.config.js
+++ b/extensions/web-clipper/webpack.config.js
@@ -1,3 +1,21 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
const webpack = require("webpack");
const path = require("path");
const fileSystem = require("fs-extra");
@@ -125,7 +143,7 @@ var options = {
from: "src/manifest.json",
to: path.join(__dirname, "build"),
force: true,
- transform: function (content, path) {
+ transform: function () {
// generates the manifest file using the package.json informations
return Buffer.from(
JSON.stringify(MANIFEST_VERSION === "2" ? v2 : v3)
diff --git a/package.json b/package.json
index 5d3739b4b..843467e62 100644
--- a/package.json
+++ b/package.json
@@ -54,5 +54,8 @@
"@nrwl/nx-cloud": "^14.6.2",
"eslint-plugin-header": "^3.1.1"
},
- "license": "GPL-3.0-or-later"
+ "license": "GPL-3.0-or-later",
+ "volta": {
+ "node": "16.15.1"
+ }
}