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
common: make imports esm compatible
Abdullah Atta1fb86cb27ba8
diff --git a/packages/common/__tests__/path-tree.test.ts b/packages/common/__tests__/path-tree.test.tsindex 46e549ebe..929a8ec08 100644--- a/packages/common/__tests__/path-tree.test.ts+++ b/packages/common/__tests__/path-tree.test.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { describe, test } from "vitest";-import { PathTree } from "../src/utils/path-tree";+import { PathTree } from "../src/utils/path-tree.js";test("adding duplicate path should make it unique", (t) => {const tree = new PathTree();diff --git a/packages/common/src/components/index.ts b/packages/common/src/components/index.tsindex d55208242..8673b387d 100644--- a/packages/common/src/components/index.ts+++ b/packages/common/src/components/index.ts@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-export * from "./resolved-item";+export * from "./resolved-item.js";diff --git a/packages/common/src/components/resolved-item.tsx b/packages/common/src/components/resolved-item.tsxindex b6e3d57bf..5eed0d8be 100644--- a/packages/common/src/components/resolved-item.tsx+++ b/packages/common/src/components/resolved-item.tsx@@ -21,7 +21,7 @@ import { ItemMap, ItemType } from "@notesnook/core";import {ResolvedItemOptions,useResolvedItem-} from "../hooks/use-resolved-item";+} from "../hooks/use-resolved-item.js";type ResolvedItemProps<TItemType extends ItemType> =ResolvedItemOptions<TItemType> & {diff --git a/packages/common/src/database.ts b/packages/common/src/database.tsindex 610ad391d..cd938d852 100644--- a/packages/common/src/database.ts+++ b/packages/common/src/database.ts@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import Database from "@notesnook/core/dist/api/index";+import { Database } from "@notesnook/core";export const database = new Database();diff --git a/packages/common/src/hooks/index.ts b/packages/common/src/hooks/index.tsindex ebb10c6cd..52ded516f 100644--- a/packages/common/src/hooks/index.ts+++ b/packages/common/src/hooks/index.ts@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-export * from "./use-time-ago";-export * from "./use-promise";-export * from "./use-resolved-item";+export * from "./use-time-ago.js";+export * from "./use-promise.js";+export * from "./use-resolved-item.js";diff --git a/packages/common/src/hooks/use-resolved-item.ts b/packages/common/src/hooks/use-resolved-item.tsindex 7a8db1d84..c0dd4e14d 100644--- a/packages/common/src/hooks/use-resolved-item.ts+++ b/packages/common/src/hooks/use-resolved-item.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { ItemMap, ItemType, VirtualizedGrouping } from "@notesnook/core";-import { resolveItems } from "../utils/resolve-items";+import { resolveItems } from "../utils/resolve-items.js";import { useDeferredValue, useEffect, useState, useTransition } from "react";export type ResolvedItemOptions<TItemType extends ItemType> = {diff --git a/packages/common/src/index.ts b/packages/common/src/index.tsindex b36ea2925..1194da116 100644--- a/packages/common/src/index.ts+++ b/packages/common/src/index.ts@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-export * from "./database";-export * from "./utils";-export * from "./hooks";-export * from "./components";+export * from "./database.js";+export * from "./utils/index.js";+export * from "./hooks/index.js";+export * from "./components/index.js";diff --git a/packages/common/src/utils/dataurl.ts b/packages/common/src/utils/dataurl.tsnew file mode 100644index 000000000..b6d9bb1cb--- /dev/null+++ b/packages/common/src/utils/dataurl.ts@@ -0,0 +1,20 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2023 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 { DataURL } from "@notesnook/core";diff --git a/packages/common/src/utils/time.ts b/packages/common/src/utils/date-time.tssimilarity index 88%rename from packages/common/src/utils/time.tsrename to packages/common/src/utils/date-time.tsindex 05db187de..20c0ffdba 100644--- a/packages/common/src/utils/time.ts+++ b/packages/common/src/utils/date-time.ts@@ -17,14 +17,15 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/+import { database } from "../database.js";import {- FormatDateOptions,TimeFormat,+ formatReminderTime,+ HistorySession,+ Reminder,+ FormatDateOptions,formatDate-} from "@notesnook/core/dist/utils/date";-import { database } from "../database";-import { formatReminderTime } from "@notesnook/core/dist/collections/reminders";-import { HistorySession, Reminder } from "@notesnook/core/dist/types";+} from "@notesnook/core";export function getFormattedDate(date: string | number | Date,@@ -53,3 +54,5 @@ export function getFormattedHistorySessionDate(session: HistorySession) {fromDate !== toDate ? `${toDate}, ` : ""}${toTime}`;}++export { formatDate };diff --git a/packages/common/src/utils/export-notes.ts b/packages/common/src/utils/export-notes.tsindex 326bf7312..37bca9deb 100644--- a/packages/common/src/utils/export-notes.ts+++ b/packages/common/src/utils/export-notes.ts@@ -17,17 +17,23 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { Attachment, Note, parseInternalLink } from "@notesnook/core";-import { FilteredSelector } from "@notesnook/core/dist/database/sql-collection";-import { CHECK_IDS, checkIsUserPremium } from "@notesnook/core/dist/common";-import { isImage, isWebClip } from "@notesnook/core/dist/utils/filename";-import { sanitizeFilename } from "./file";-import { database } from "../database";+import {+ Attachment,+ Note,+ parseInternalLink,+ getContentFromData,+ ResolveInternalLink,+ isImage,+ isWebClip,+ CHECK_IDS,+ checkIsUserPremium,+ FilteredSelector,+ EMPTY_CONTENT+} from "@notesnook/core";+import { sanitizeFilename } from "./file.js";+import { database } from "../database.js";import { join, relative } from "pathe";-import { EMPTY_CONTENT } from "@notesnook/core/dist/collections/content";-import { getContentFromData } from "@notesnook/core/dist/content-types";-import { PathTree } from "./path-tree";-import { ResolveInternalLink } from "@notesnook/core/dist/content-types/tiptap";+import { PathTree } from "./path-tree.js";const FORMAT_TO_EXT = {pdf: "pdf",diff --git a/packages/common/src/utils/index.ts b/packages/common/src/utils/index.tsindex 84f327a08..3ab8846e8 100644--- a/packages/common/src/utils/index.ts+++ b/packages/common/src/utils/index.ts@@ -17,12 +17,13 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-export * from "./file";-export * from "./number";-export * from "./time";-export * from "./debounce";-export * from "./random";-export * from "./string";-export * from "./resolve-items";-export * from "./migrate-toolbar";-export * from "./export-notes";+export * from "./file.js";+export * from "./number.js";+export * from "./date-time.js";+export * from "./debounce.js";+export * from "./random.js";+export * from "./string.js";+export * from "./resolve-items.js";+export * from "./migrate-toolbar.js";+export * from "./export-notes.js";+export * from "./dataurl.js";diff --git a/packages/common/src/utils/migrate-toolbar.ts b/packages/common/src/utils/migrate-toolbar.tsindex 4ba802f68..594662f81 100644--- a/packages/common/src/utils/migrate-toolbar.ts+++ b/packages/common/src/utils/migrate-toolbar.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { ToolbarConfig, ToolbarConfigPlatforms } from "@notesnook/core";-import { database } from "../database";+import { database } from "../database.js";export const CURRENT_TOOLBAR_VERSION = 2;export async function migrateToolbar(diff --git a/packages/common/src/utils/resolve-items.ts b/packages/common/src/utils/resolve-items.tsindex 90cb4a55c..5601ccd95 100644--- a/packages/common/src/utils/resolve-items.ts+++ b/packages/common/src/utils/resolve-items.ts@@ -17,9 +17,15 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { Color, Item, Reminder, Notebook, Tag } from "@notesnook/core";-import { database as db } from "../database";-import { getUpcomingReminder } from "@notesnook/core/dist/collections/reminders";+import {+ Color,+ Item,+ Reminder,+ Notebook,+ Tag,+ getUpcomingReminder+} from "@notesnook/core";+import { database as db } from "../database.js";type WithDateEdited<T> = { items: T[]; dateEdited: number };export type NotebooksWithDateEdited = WithDateEdited<Notebook>;