A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
clipper: make imports esm compatible
Abdullah Atta7458aa53ae91
diff --git a/packages/clipper/__tests__/example.spec.ts b/packages/clipper/__tests__/example.spec.tsindex 1a9e889a8..e11dd6b06 100644--- a/packages/clipper/__tests__/example.spec.ts+++ b/packages/clipper/__tests__/example.spec.ts@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import { expect, test } from "@playwright/test";import { buildSync } from "esbuild";import path, { join } from "path";-import type { Clipper } from "../src";+import type { Clipper } from "../src/index.js";import Websites from "./pages.json";import slugify from "slugify";import { mkdirSync, rmSync, writeFileSync } from "fs";diff --git a/packages/clipper/package-lock.json b/packages/clipper/package-lock.jsonindex e7bead2cf..35c580f35 100644--- a/packages/clipper/package-lock.json+++ b/packages/clipper/package-lock.json@@ -1,12 +1,12 @@{"name": "@notesnook/clipper",- "version": "2.0.7",+ "version": "2.1.1","lockfileVersion": 2,"requires": true,"packages": {"": {"name": "@notesnook/clipper",- "version": "2.0.7",+ "version": "2.1.1","hasInstallScript": true,"license": "GPL-3.0-or-later","dependencies": {diff --git a/packages/clipper/package.json b/packages/clipper/package.jsonindex 8b0dc5f54..8cef30de4 100644--- a/packages/clipper/package.json+++ b/packages/clipper/package.json@@ -1,6 +1,6 @@{"name": "@notesnook/clipper",- "version": "2.0.7",+ "version": "2.1.1","description": "Web clipper core used by the Notesnook Web Clipper","keywords": ["web-clipper"diff --git a/packages/clipper/src/clone.ts b/packages/clipper/src/clone.tsindex c3f0e4146..9067b5495 100644--- a/packages/clipper/src/clone.ts+++ b/packages/clipper/src/clone.ts@@ -16,9 +16,9 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { createImage, FetchOptions } from "./fetch";-import { Filter } from "./types";-import { uid } from "./utils";+import { createImage, FetchOptions } from "./fetch.js";+import { Filter } from "./types.js";+import { uid } from "./utils.js";const SVGElements = ["altGlyph",diff --git a/packages/clipper/src/domtoimage.ts b/packages/clipper/src/domtoimage.tsindex a0da1349f..d20dc18c4 100644--- a/packages/clipper/src/domtoimage.ts+++ b/packages/clipper/src/domtoimage.ts@@ -16,13 +16,13 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { cloneNode, isSVGElement } from "./clone";-import { createImage, FetchOptions } from "./fetch";-import { resolveAll } from "./fontfaces";-import { inlineAllImages } from "./images";-import { Options } from "./types";-import { canvasToBlob, delay, escapeXhtml, height, width } from "./utils";-import { cacheStylesheets, inlineStylesheets } from "./styles";+import { cloneNode, isSVGElement } from "./clone.js";+import { createImage, FetchOptions } from "./fetch.js";+import { resolveAll } from "./fontfaces.js";+import { inlineAllImages } from "./images.js";+import { Options } from "./types.js";+import { canvasToBlob, delay, escapeXhtml, height, width } from "./utils.js";+import { cacheStylesheets, inlineStylesheets } from "./styles.js";// Default impl optionsconst defaultOptions: Options = {diff --git a/packages/clipper/src/fontfaces.ts b/packages/clipper/src/fontfaces.tsindex 7266e6ea3..cbbb01b91 100644--- a/packages/clipper/src/fontfaces.ts+++ b/packages/clipper/src/fontfaces.ts@@ -16,8 +16,8 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { FetchOptions } from "./fetch";-import { inlineAll, shouldProcess } from "./inliner";+import { FetchOptions } from "./fetch.js";+import { inlineAll, shouldProcess } from "./inliner.js";async function resolveAll(options?: FetchOptions) {const fonts = readAll();diff --git a/packages/clipper/src/images.ts b/packages/clipper/src/images.tsindex 10a8f590a..3d76b6303 100644--- a/packages/clipper/src/images.ts+++ b/packages/clipper/src/images.ts@@ -16,9 +16,9 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { FetchOptions, fetchResource } from "./fetch";-import { inlineAll } from "./inliner";-import { isDataUrl } from "./utils";+import { FetchOptions, fetchResource } from "./fetch.js";+import { inlineAll } from "./inliner.js";+import { isDataUrl } from "./utils.js";async function inlineAllImages(root: HTMLElement, options?: FetchOptions) {const imageNodes = root.querySelectorAll("img");diff --git a/packages/clipper/src/index.global.ts b/packages/clipper/src/index.global.tsindex 1a05ba5bb..833a053c9 100644--- a/packages/clipper/src/index.global.ts+++ b/packages/clipper/src/index.global.ts@@ -16,10 +16,14 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { clipArticle, clipPage } from "./index";+import { clipArticle, clipPage } from "./index.js";-declare module global {- var Clipper: any;+declare global {+ // eslint-disable-next-line no-var+ var Clipper: {+ clipArticle: typeof clipArticle;+ clipPage: typeof clipPage;+ };}global.Clipper = {diff --git a/packages/clipper/src/index.ts b/packages/clipper/src/index.tsindex c57d9f664..0e72e0d7f 100644--- a/packages/clipper/src/index.ts+++ b/packages/clipper/src/index.ts@@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Readability } from "@mozilla/readability";-import { injectCss } from "./utils";+import { injectCss } from "./utils.js";import { app, h, text } from "hyperapp";-import { getInlinedNode, toBlob, toJpeg, toPng } from "./domtoimage";-import { Config, InlineOptions } from "./types";-import { FetchOptions } from "./fetch";+import { getInlinedNode, toBlob, toJpeg, toPng } from "./domtoimage.js";+import { Config, InlineOptions } from "./types.js";+import { FetchOptions } from "./fetch.js";type ReadabilityEnhanced = Readability<string> & {PRESENTATIONAL_ATTRIBUTES: string[];diff --git a/packages/clipper/src/inliner.ts b/packages/clipper/src/inliner.tsindex 2ff3f6f07..b86b420f8 100644--- a/packages/clipper/src/inliner.ts+++ b/packages/clipper/src/inliner.ts@@ -16,8 +16,8 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { FetchOptions, fetchResource } from "./fetch";-import { isDataUrl, resolveUrl, escape } from "./utils";+import { FetchOptions, fetchResource } from "./fetch.js";+import { isDataUrl, resolveUrl, escape } from "./utils.js";const URL_REGEX = /url\(['"]?([^'"]+?)['"]?\)/g;diff --git a/packages/clipper/src/styles.ts b/packages/clipper/src/styles.tsindex 61f238050..fa69c55c6 100644--- a/packages/clipper/src/styles.ts+++ b/packages/clipper/src/styles.ts@@ -16,11 +16,11 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { constructUrl, FetchOptions } from "./fetch";+import { constructUrl, FetchOptions } from "./fetch.js";import { compare, calculate, SpecificityArray } from "specificity";-import { tokenize } from "./css-tokenizer";+import { tokenize } from "./css-tokenizer.js";import { stringify, parse, SelectorType } from "css-what";-import { safeQuerySelectorAll } from "./utils";+import { safeQuerySelectorAll } from "./utils.js";const SHORTHANDS = ["animation",diff --git a/packages/clipper/src/types.ts b/packages/clipper/src/types.tsindex ee8639327..53b99efa2 100644--- a/packages/clipper/src/types.ts+++ b/packages/clipper/src/types.ts@@ -16,7 +16,7 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { FetchOptions } from "./fetch";+import { FetchOptions } from "./fetch.js";export type ClipArea = "full-page" | "visible" | "selection" | "article";export type ClipMode = "simplified" | "screenshot" | "complete";