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
core: make imports compatible with esm
Abdullah Atta59739067b6ef
diff --git a/packages/core/__benches__/lookup.bench.ts b/packages/core/__benches__/lookup.bench.tsindex 76765a797..8a12df73f 100644--- a/packages/core/__benches__/lookup.bench.ts+++ b/packages/core/__benches__/lookup.bench.ts@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { bench, describe } from "vitest";-import { databaseTest } from "../__tests__/utils";-import Database from "../src/api";+import { databaseTest } from "../__tests__/utils/index.js";+import Database from "../src/api/index.js";async function addNotes(db: Database) {const words = [diff --git a/packages/core/__benches__/notes.bench.ts b/packages/core/__benches__/notes.bench.tsindex 64535f3e7..e6d173122 100644--- a/packages/core/__benches__/notes.bench.ts+++ b/packages/core/__benches__/notes.bench.ts@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { bench, describe } from "vitest";-import { databaseTest } from "../__tests__/utils";-import Database from "../src/api";+import { databaseTest } from "../__tests__/utils/index.js";+import Database from "../src/api/index.js";async function addNotes(db: Database) {const titles = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(diff --git a/packages/core/__benches__/objectid.bench.ts b/packages/core/__benches__/objectid.bench.tsindex d47f43eed..8572a406a 100644--- a/packages/core/__benches__/objectid.bench.ts+++ b/packages/core/__benches__/objectid.bench.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { bench, describe } from "vitest";-import { createObjectId } from "../src/utils/object-id";+import { createObjectId } from "../src/utils/object-id.js";import boid from "bson-objectid";import { nanoid } from "nanoid";diff --git a/packages/core/__benches__/relations.bench.ts b/packages/core/__benches__/relations.bench.tsindex e28e4f01d..c99a0baf2 100644--- a/packages/core/__benches__/relations.bench.ts+++ b/packages/core/__benches__/relations.bench.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { bench, describe } from "vitest";-import { databaseTest } from "../__tests__/utils";+import { describe } from "vitest";+import { databaseTest } from "../__tests__/utils/index.js";describe("relations", async () => {const db = await databaseTest();diff --git a/packages/core/__benches__/reminders.bench.ts b/packages/core/__benches__/reminders.bench.tsindex 4e03cc6e7..6c70fc9b1 100644--- a/packages/core/__benches__/reminders.bench.ts+++ b/packages/core/__benches__/reminders.bench.ts@@ -18,15 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { bench, describe } from "vitest";-import { databaseTest } from "../__tests__/utils";-import Database from "../src/api";+import { databaseTest } from "../__tests__/utils/index.js";+import Database from "../src/api/index.js";import MockDate from "mockdate";import dayjs from "dayjs";-import { Reminder } from "../src/types";+import { Reminder } from "../src/types.js";import {createUpcomingReminderTimeQuery,getUpcomingReminderTime-} from "../src/collections/reminders";+} from "../src/collections/reminders.js";async function addReminders(db: Database) {const reminders: Partial<Reminder>[] = [diff --git a/packages/core/__e2e__/monographs.test.js b/packages/core/__e2e__/monographs.test.jsindex 0e0c67a7a..7ceabff5f 100644--- a/packages/core/__e2e__/monographs.test.js+++ b/packages/core/__e2e__/monographs.test.js@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { databaseTest, noteTest } from "../__tests__/utils";-import { login, logout } from "./utils";+import { databaseTest, noteTest } from "../__tests__/utils/index.js";+import { login, logout } from "./utils.js";import { test, expect, afterAll } from "vitest";const TEST_TIMEOUT = 30 * 1000;diff --git a/packages/core/__e2e__/offers.test.js b/packages/core/__e2e__/offers.test.jsindex 9853b464d..77835e717 100644--- a/packages/core/__e2e__/offers.test.js+++ b/packages/core/__e2e__/offers.test.js@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import hosts from "../src/utils/constants";-import { Offers } from "../src/api/offers";+import hosts from "../src/utils/constants.js";+import { Offers } from "../src/api/offers.js";import { test, expect } from "vitest";test("get offer code", async () => {diff --git a/packages/core/__e2e__/pricing.test.js b/packages/core/__e2e__/pricing.test.jsindex dec200b19..e53b8392c 100644--- a/packages/core/__e2e__/pricing.test.js+++ b/packages/core/__e2e__/pricing.test.js@@ -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/>.*/-import { Pricing } from "../src/api/pricing";+import { Pricing } from "../src/api/pricing.js";import { test, expect, describe } from "vitest";test.each(["monthly", "yearly", undefined])(`get %s price`, async (period) => {diff --git a/packages/core/__e2e__/sync.test.js b/packages/core/__e2e__/sync.test.jsindex 441367e95..a88a0098c 100644--- a/packages/core/__e2e__/sync.test.js+++ b/packages/core/__e2e__/sync.test.js@@ -17,14 +17,14 @@ 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 "../src/api/index";-import { NodeStorageInterface } from "../__mocks__/node-storage.mock";-import { FS } from "../__mocks__/fs.mock";-import Compressor from "../__mocks__/compressor.mock";-import { CHECK_IDS, EV, EVENTS } from "../src/common";+import Database from "../src/api/index.js";+import { NodeStorageInterface } from "../__mocks__/node-storage.mock.js";+import { FS } from "../__mocks__/fs.mock.js";+import Compressor from "../__mocks__/compressor.mock.js";+import { CHECK_IDS, EV, EVENTS } from "../src/common.js";import { EventSource } from "event-source-polyfill";import { test, expect, vitest } from "vitest";-import { login } from "./utils";+import { login } from "./utils.js";import { SqliteDialect } from "@streetwriters/kysely";import BetterSQLite3 from "better-sqlite3-multiple-ciphers";diff --git a/packages/core/__e2e__/token-manager.test.js b/packages/core/__e2e__/token-manager.test.jsindex 13f52e483..d3e4cda1c 100644--- a/packages/core/__e2e__/token-manager.test.js+++ b/packages/core/__e2e__/token-manager.test.js@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { databaseTest } from "../__tests__/utils";-import { login } from "./utils";+import { databaseTest } from "../__tests__/utils/index.js";+import { login } from "./utils.js";import { test, expect } from "vitest";test(diff --git a/packages/core/__e2e__/user-manager.test.js b/packages/core/__e2e__/user-manager.test.jsindex f8700f179..156658f56 100644--- a/packages/core/__e2e__/user-manager.test.js+++ b/packages/core/__e2e__/user-manager.test.js@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { authenticator } from "otplib";-import { databaseTest } from "../__tests__/utils";-import { login, USER } from "./utils";+import { databaseTest } from "../__tests__/utils/index.js";+import { login, USER } from "./utils.js";import { test, expect } from "vitest";// test("signup user and check for token", async () => {diff --git a/packages/core/__mocks__/fs.mock.ts b/packages/core/__mocks__/fs.mock.tsindex aa4f62dbe..e5044c30b 100644--- a/packages/core/__mocks__/fs.mock.ts+++ b/packages/core/__mocks__/fs.mock.ts@@ -22,7 +22,7 @@ import {FileEncryptionMetadataWithOutputType,IFileStorage,RequestOptions-} from "../src/interfaces";+} from "../src/interfaces.js";import { xxhash64 } from "hash-wasm";import { IDataType } from "hash-wasm/dist/lib/util";diff --git a/packages/core/__mocks__/node-storage.mock.ts b/packages/core/__mocks__/node-storage.mock.tsindex a11a08201..191118755 100644--- a/packages/core/__mocks__/node-storage.mock.ts+++ b/packages/core/__mocks__/node-storage.mock.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Cipher, NNCrypto, SerializedKey } from "@notesnook/crypto";-import { IStorage } from "../src/interfaces";+import { IStorage } from "../src/interfaces.js";export class NodeStorageInterface implements IStorage {storage = {};diff --git a/packages/core/__tests__/backup.test.js b/packages/core/__tests__/backup.test.jsindex f4f5e637a..8df0c5d65 100644--- a/packages/core/__tests__/backup.test.js+++ b/packages/core/__tests__/backup.test.js@@ -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/>.*/-import { TEST_NOTE, databaseTest, loginFakeUser, notebookTest } from "./utils";+import { TEST_NOTE, databaseTest, loginFakeUser, notebookTest } from "./utils/index.js";import { test, expect } from "vitest";test("export backup", () =>diff --git a/packages/core/__tests__/db.test.js b/packages/core/__tests__/db.test.jsindex dcd47991d..f0206f74e 100644--- a/packages/core/__tests__/db.test.js+++ b/packages/core/__tests__/db.test.js@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import Constants from "../src/utils/constants";+import Constants from "../src/utils/constants.js";import { test, expect } from "vitest";-import { databaseTest } from "./utils";+import { databaseTest } from "./utils/index.js";test("db.host should change HOST", () =>databaseTest().then((db) => {diff --git a/packages/core/__tests__/fts-triggers.test.ts b/packages/core/__tests__/fts-triggers.test.tsindex 6a2590d11..e2d8ddccc 100644--- a/packages/core/__tests__/fts-triggers.test.ts+++ b/packages/core/__tests__/fts-triggers.test.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { expect, test } from "vitest";-import { databaseTest, noteTest } from "./utils";+import { databaseTest, noteTest } from "./utils/index.js";test("updating deleted content should not throw", () =>databaseTest().then(async (db) => {diff --git a/packages/core/__tests__/logger.test.ts b/packages/core/__tests__/logger.test.tsindex d996b339e..d5b1b1494 100644--- a/packages/core/__tests__/logger.test.ts+++ b/packages/core/__tests__/logger.test.ts@@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { describe, it, expect } from "vitest";-import { initialize, logManager, logger } from "../src/logger";+import { initialize, logManager, logger } from "../src/logger.js";import { SqliteDialect } from "@streetwriters/kysely";import BetterSQLite3 from "better-sqlite3-multiple-ciphers";import { NoopLogger } from "@notesnook/logger";-import { delay } from "./utils";+import { delay } from "./utils/index.js";async function initializeLogger() {await initialize(diff --git a/packages/core/__tests__/lookup.test.js b/packages/core/__tests__/lookup.test.jsindex b0c8ba39b..9641e86c9 100644--- a/packages/core/__tests__/lookup.test.js+++ b/packages/core/__tests__/lookup.test.js@@ -23,7 +23,7 @@ import {notebookTest,TEST_NOTEBOOK2,databaseTest-} from "./utils";+} from "./utils/index.js";import { test, expect } from "vitest";const content = {diff --git a/packages/core/__tests__/migrations.test.ts b/packages/core/__tests__/migrations.test.tsindex 7613cb692..4de149795 100644--- a/packages/core/__tests__/migrations.test.ts+++ b/packages/core/__tests__/migrations.test.ts@@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { test, expect, describe } from "vitest";-import { migrateItem, migrateKV, migrateVaultKey } from "../src/migrations";-import { databaseTest } from "./utils";-import { getId, makeId } from "../src/utils/id";-import { DeletedItem, LegacySettingsItem } from "../src/types";-import { KEYS } from "../src/database/kv";+import { migrateItem, migrateKV, migrateVaultKey } from "../src/migrations.js";+import { databaseTest } from "./utils/index.js";+import { getId, makeId } from "../src/utils/id.js";+import { DeletedItem, LegacySettingsItem } from "../src/types.js";+import { KEYS } from "../src/database/kv.js";describe.concurrent("[5.2] replace date edited with date modified", () => {const itemsWithDateEdited = ["note", "notebook", "trash", "tiny"] as const;diff --git a/packages/core/__tests__/note-history.test.js b/packages/core/__tests__/note-history.test.jsindex c42f0f3bf..5ed5b6f6f 100644--- a/packages/core/__tests__/note-history.test.js+++ b/packages/core/__tests__/note-history.test.js@@ -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/>.*/-import { delay, noteTest, TEST_NOTE } from "./utils";+import { delay, noteTest, TEST_NOTE } from "./utils/index.js";import { test, expect } from "vitest";// async function sessionTest(db, noteId) {diff --git a/packages/core/__tests__/notebooks.test.js b/packages/core/__tests__/notebooks.test.jsindex 0fd9e4ad1..540cf1202 100644--- a/packages/core/__tests__/notebooks.test.js+++ b/packages/core/__tests__/notebooks.test.js@@ -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/>.*/-import { notebookTest, TEST_NOTEBOOK } from "./utils";+import { notebookTest, TEST_NOTEBOOK } from "./utils/index.js";import { test, expect } from "vitest";test("add a notebook", () =>diff --git a/packages/core/__tests__/notes.test.ts b/packages/core/__tests__/notes.test.tsindex f8c0a4bb8..c72eb94c2 100644--- a/packages/core/__tests__/notes.test.ts+++ b/packages/core/__tests__/notes.test.ts@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import dayjs from "dayjs";-import Database from "../src/api";-import { createKeySelector, groupArray } from "../src/utils/grouping";+import Database from "../src/api/index.js";+import { createKeySelector, groupArray } from "../src/utils/grouping.js";import {databaseTest,noteTest,@@ -27,10 +27,9 @@ import {TEST_NOTEBOOK,IMG_CONTENT,loginFakeUser-} from "./utils";+} from "./utils/index.js";import { test, expect } from "vitest";-import { MONTHS_FULL } from "../src/utils/date";-import { GroupOptions, Note } from "../src/types";+import { GroupOptions, Note } from "../src/types.js";async function createAndAddNoteToNotebook(db: Database,diff --git a/packages/core/__tests__/reminders.test.js b/packages/core/__tests__/reminders.test.jsindex e061b4ab5..46f2dfd8f 100644--- a/packages/core/__tests__/reminders.test.js+++ b/packages/core/__tests__/reminders.test.js@@ -23,10 +23,10 @@ import {formatReminderTime,getUpcomingReminderTime,isReminderActive-} from "../src/collections/reminders";+} from "../src/collections/reminders.js";import MockDate from "mockdate";import { describe, afterAll, beforeEach, test, expect } from "vitest";-import { databaseTest } from "./utils";+import { databaseTest } from "./utils/index.js";import dayjs from "dayjs";import assert from "assert";diff --git a/packages/core/__tests__/settings.test.js b/packages/core/__tests__/settings.test.jsindex 250711da9..73eba0677 100644--- a/packages/core/__tests__/settings.test.js+++ b/packages/core/__tests__/settings.test.js@@ -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/>.*/-import { databaseTest } from "./utils";+import { databaseTest } from "./utils/index.js";import { test, expect } from "vitest";test("save group options", () =>diff --git a/packages/core/__tests__/shortcuts.test.js b/packages/core/__tests__/shortcuts.test.jsindex 0fd8e1a2c..30f12d83d 100644--- a/packages/core/__tests__/shortcuts.test.js+++ b/packages/core/__tests__/shortcuts.test.js@@ -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/>.*/-import { databaseTest, notebookTest } from "./utils";+import { databaseTest, notebookTest } from "./utils/index.js";import { test, expect } from "vitest";test("create a shortcut of an invalid item should throw", () =>diff --git a/packages/core/__tests__/storage.test.js b/packages/core/__tests__/storage.test.jsindex a5d8f804a..f5382b279 100644--- a/packages/core/__tests__/storage.test.js+++ b/packages/core/__tests__/storage.test.js@@ -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/>.*/-import { NodeStorageInterface } from "../__mocks__/node-storage.mock";+import { NodeStorageInterface } from "../__mocks__/node-storage.mock.js";import { test, expect } from "vitest";test("add a value", async () => {diff --git a/packages/core/__tests__/tags.test.ts b/packages/core/__tests__/tags.test.tsindex 5724813f3..4fe49ca77 100644--- a/packages/core/__tests__/tags.test.ts+++ b/packages/core/__tests__/tags.test.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/>.*/-import { databaseTest, noteTest, TEST_NOTE } from "./utils";+import { databaseTest, noteTest, TEST_NOTE } from "./utils/index.js";import { test, expect } from "vitest";function tag(title: string) {diff --git a/packages/core/__tests__/trash.test.ts b/packages/core/__tests__/trash.test.tsindex d6de4de79..944e62b51 100644--- a/packages/core/__tests__/trash.test.ts+++ b/packages/core/__tests__/trash.test.ts@@ -24,7 +24,7 @@ import {TEST_NOTE,TEST_NOTEBOOK,databaseTest-} from "./utils";+} from "./utils/index.js";import { test, expect } from "vitest";test("trash should be empty", () =>diff --git a/packages/core/__tests__/utils/index.ts b/packages/core/__tests__/utils/index.tsindex 67a43e10d..ebf8a8492 100644--- a/packages/core/__tests__/utils/index.ts+++ b/packages/core/__tests__/utils/index.ts@@ -17,19 +17,19 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import DB from "../../src/api";-import { NodeStorageInterface } from "../../__mocks__/node-storage.mock";-import { FS } from "../../__mocks__/fs.mock";-import Compressor from "../../__mocks__/compressor.mock";+import DB from "../../src/api/index.js";+import { NodeStorageInterface } from "../../__mocks__/node-storage.mock.js";+import { FS } from "../../__mocks__/fs.mock.js";+import Compressor from "../../__mocks__/compressor.mock.js";import { EventSourcePolyfill as EventSource } from "event-source-polyfill";-import { randomBytes } from "../../src/utils/random";-import { Note, Notebook } from "../../src/types";-import { NoteContent } from "../../src/collections/session-content";+import { randomBytes } from "../../src/utils/random.js";+import { Note, Notebook } from "../../src/types.js";+import { NoteContent } from "../../src/collections/session-content.js";import { SqliteDialect } from "@streetwriters/kysely";import BetterSQLite3 from "better-sqlite3-multiple-ciphers";import path from "path";import { tmpdir } from "os";-import { getId } from "../../src/utils/id";+import { getId } from "../../src/utils/id.js";import { existsSync, mkdirSync } from "fs";const TEST_NOTEBOOK: Partial<Notebook> = {diff --git a/packages/core/__tests__/vault.test.js b/packages/core/__tests__/vault.test.jsindex e0c437568..cd016ac05 100644--- a/packages/core/__tests__/vault.test.js+++ b/packages/core/__tests__/vault.test.js@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { VAULT_ERRORS } from "../src/api/vault";-import { databaseTest, delay, noteTest, TEST_NOTE } from "./utils";+import { VAULT_ERRORS } from "../src/api/vault.js";+import { databaseTest, delay, noteTest, TEST_NOTE } from "./utils/index.js";import { test, expect } from "vitest";test("create vault", () =>diff --git a/packages/core/src/api/__tests__/debug.test.js b/packages/core/src/api/__tests__/debug.test.jsindex 1122ddfef..91b663e66 100644--- a/packages/core/src/api/__tests__/debug.test.js+++ b/packages/core/src/api/__tests__/debug.test.js@@ -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/>.*/-import { Debug } from "../debug";+import { Debug } from "../debug.js";import createFetchMock from "vitest-fetch-mock";import { vi, test, expect } from "vitest";const fetchMocker = createFetchMock(vi);diff --git a/packages/core/src/api/__tests__/healthcheck.test.ts b/packages/core/src/api/__tests__/healthcheck.test.tsindex d3b12f8da..ccf3a90d3 100644--- a/packages/core/src/api/__tests__/healthcheck.test.ts+++ b/packages/core/src/api/__tests__/healthcheck.test.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/>.*/-import { HealthCheck, check } from "../healthcheck";+import { HealthCheck, check } from "../healthcheck.js";import { describe } from "vitest";describe.concurrent("Health check", (test) => {diff --git a/packages/core/src/api/debug.ts b/packages/core/src/api/debug.tsindex 4c41e43b4..a7858b107 100644--- a/packages/core/src/api/debug.ts+++ b/packages/core/src/api/debug.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/>.*/-import hosts from "../utils/constants";+import hosts from "../utils/constants.js";export class Debug {static async report(reportData: {diff --git a/packages/core/src/api/healthcheck.ts b/packages/core/src/api/healthcheck.tsindex 729d4fbab..3a67ab520 100644--- a/packages/core/src/api/healthcheck.ts+++ b/packages/core/src/api/healthcheck.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import hosts from "../utils/constants";-import http from "../utils/http";+import hosts from "../utils/constants.js";+import http from "../utils/http.js";export class HealthCheck {static async auth() {diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.tsindex 8f8afca04..a7280f5e4 100644--- a/packages/core/src/api/index.ts+++ b/packages/core/src/api/index.ts@@ -17,38 +17,38 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { Notes } from "../collections/notes";-import { Crypto, CryptoAccessor } from "../database/crypto";-import { FileStorage, FileStorageAccessor } from "../database/fs";-import { Notebooks } from "../collections/notebooks";-import Trash from "../collections/trash";-import Sync, { SyncOptions } from "./sync";-import { Tags } from "../collections/tags";-import { Colors } from "../collections/colors";-import Vault from "./vault";-import Lookup from "./lookup";-import { Content } from "../collections/content";-import Backup from "../database/backup";-import Hosts from "../utils/constants";-import { EV, EVENTS } from "../common";-import { LegacySettings } from "../collections/legacy-settings";-import Migrations from "./migrations";-import UserManager from "./user-manager";-import http from "../utils/http";-import { Monographs } from "./monographs";-import { Offers } from "./offers";-import { Attachments } from "../collections/attachments";-import { Debug } from "./debug";+import { Notes } from "../collections/notes.js";+import { Crypto, CryptoAccessor } from "../utils/crypto.js";+import { FileStorage, FileStorageAccessor } from "../database/fs.js";+import { Notebooks } from "../collections/notebooks.js";+import Trash from "../collections/trash.js";+import Sync, { SyncOptions } from "./sync/index.js";+import { Tags } from "../collections/tags.js";+import { Colors } from "../collections/colors.js";+import Vault from "./vault.js";+import Lookup from "./lookup.js";+import { Content } from "../collections/content.js";+import Backup from "../database/backup.js";+import Hosts from "../utils/constants.js";+import { EV, EVENTS } from "../common.js";+import { LegacySettings } from "../collections/legacy-settings.js";+import Migrations from "./migrations.js";+import UserManager from "./user-manager.js";+import http from "../utils/http.js";+import { Monographs } from "./monographs.js";+import { Offers } from "./offers.js";+import { Attachments } from "../collections/attachments.js";+import { Debug } from "./debug.js";import { Mutex } from "async-mutex";-import { NoteHistory } from "../collections/note-history";-import MFAManager from "./mfa-manager";-import EventManager from "../utils/event-manager";-import { Pricing } from "./pricing";-import { logger } from "../logger";-import { Shortcuts } from "../collections/shortcuts";-import { Reminders } from "../collections/reminders";-import { Relations } from "../collections/relations";-import Subscriptions from "./subscriptions";+import { NoteHistory } from "../collections/note-history.js";+import MFAManager from "./mfa-manager.js";+import EventManager from "../utils/event-manager.js";+import { Pricing } from "./pricing.js";+import { logger } from "../logger.js";+import { Shortcuts } from "../collections/shortcuts.js";+import { Reminders } from "../collections/reminders.js";+import { Relations } from "../collections/relations.js";+import Subscriptions from "./subscriptions.js";import {CompressorAccessor,ConfigStorageAccessor,@@ -57,10 +57,10 @@ import {IStorage,KVStorageAccessor,StorageAccessor-} from "../interfaces";-import TokenManager from "./token-manager";-import { Attachment } from "../types";-import { Settings } from "../collections/settings";+} from "../interfaces.js";+import TokenManager from "./token-manager.js";+import { Attachment } from "../types.js";+import { Settings } from "../collections/settings.js";import {DatabaseAccessor,DatabaseSchema,@@ -69,16 +69,16 @@ import {changeDatabasePassword,createDatabase,initializeDatabase-} from "../database";+} from "../database/index.js";import { Kysely, Transaction, sql } from "@streetwriters/kysely";-import { CachedCollection } from "../database/cached-collection";-import { Vaults } from "../collections/vaults";-import { KVStorage } from "../database/kv";-import { QueueValue } from "../utils/queue-value";-import { Sanitizer } from "../database/sanitizer";-import { createTriggers, dropTriggers } from "../database/triggers";-import { NNMigrationProvider } from "../database/migrations";-import { ConfigStorage } from "../database/config";+import { CachedCollection } from "../database/cached-collection.js";+import { Vaults } from "../collections/vaults.js";+import { KVStorage } from "../database/kv.js";+import { QueueValue } from "../utils/queue-value.js";+import { Sanitizer } from "../database/sanitizer.js";+import { createTriggers, dropTriggers } from "../database/triggers.js";+import { NNMigrationProvider } from "../database/migrations.js";+import { ConfigStorage } from "../database/config.js";type EventSourceConstructor = new (uri: string,diff --git a/packages/core/src/api/lookup.ts b/packages/core/src/api/lookup.tsindex 26ce2b2a0..1fae6b974 100644--- a/packages/core/src/api/lookup.ts+++ b/packages/core/src/api/lookup.ts@@ -18,15 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { match } from "fuzzyjs";-import Database from ".";-import { Item, Note, TrashItem } from "../types";-import { DatabaseSchema, RawDatabaseSchema } from "../database";+import Database from "./index.js";+import { Item, Note, TrashItem } from "../types.js";+import { DatabaseSchema, RawDatabaseSchema } from "../database/index.js";import { AnyColumnWithTable, Kysely, sql } from "@streetwriters/kysely";-import { FilteredSelector } from "../database/sql-collection";-import { VirtualizedGrouping } from "../utils/virtualized-grouping";-import { logger } from "../logger";-import { rebuildSearchIndex } from "../database/fts";-import { transformQuery } from "../utils/query-transformer";+import { FilteredSelector } from "../database/sql-collection.js";+import { VirtualizedGrouping } from "../utils/virtualized-grouping.js";+import { logger } from "../logger.js";+import { rebuildSearchIndex } from "../database/fts.js";+import { transformQuery } from "../utils/query-transformer.js";type SearchResults<T> = {sorted: (limit?: number) => Promise<VirtualizedGrouping<T>>;diff --git a/packages/core/src/api/mfa-manager.ts b/packages/core/src/api/mfa-manager.tsindex 5069c4590..283dfc668 100644--- a/packages/core/src/api/mfa-manager.ts+++ b/packages/core/src/api/mfa-manager.ts@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import http from "../utils/http";-import constants from "../utils/constants";-import TokenManager from "./token-manager";+import http from "../utils/http.js";+import constants from "../utils/constants.js";+import TokenManager from "./token-manager.js";const ENDPOINTS = {setup: "/mfa",diff --git a/packages/core/src/api/migrations.ts b/packages/core/src/api/migrations.tsindex 9dd966cc4..50092cf3a 100644--- a/packages/core/src/api/migrations.ts+++ b/packages/core/src/api/migrations.ts@@ -17,9 +17,9 @@ 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 ".";-import { CURRENT_DATABASE_VERSION } from "../common";-import Migrator, { MigratableCollections } from "../database/migrator";+import Database from "./index.js";+import { CURRENT_DATABASE_VERSION } from "../common.js";+import Migrator, { MigratableCollections } from "../database/migrator.js";const collections: MigratableCollections = [{diff --git a/packages/core/src/api/monographs.ts b/packages/core/src/api/monographs.tsindex 0980af642..46ed24064 100644--- a/packages/core/src/api/monographs.ts+++ b/packages/core/src/api/monographs.ts@@ -17,13 +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/>.*/-import http from "../utils/http";-import Constants from "../utils/constants";-import Database from ".";-import { Note, isDeleted } from "../types";+import http from "../utils/http.js";+import Constants from "../utils/constants.js";+import Database from "./index.js";+import { Note, isDeleted } from "../types.js";import { Cipher } from "@notesnook/crypto";-import { isFalse } from "../database";-import { logger } from "../logger";+import { isFalse } from "../database/index.js";+import { logger } from "../logger.js";type BaseMonograph = {id: string;diff --git a/packages/core/src/api/offers.ts b/packages/core/src/api/offers.tsindex d5df571ee..83d28d0fb 100644--- a/packages/core/src/api/offers.ts+++ b/packages/core/src/api/offers.ts@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { CLIENT_ID } from "../common";-import hosts from "../utils/constants";-import http from "../utils/http";+import { CLIENT_ID } from "../common.js";+import hosts from "../utils/constants.js";+import http from "../utils/http.js";export class Offers {static async getCode(promo: string, platform: "ios" | "android" | "web") {diff --git a/packages/core/src/api/pricing.ts b/packages/core/src/api/pricing.tsindex a4f165f97..bbbfc7747 100644--- a/packages/core/src/api/pricing.ts+++ b/packages/core/src/api/pricing.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/>.*/-import http from "../utils/http";+import http from "../utils/http.js";export type Product = {country: string;diff --git a/packages/core/src/api/subscriptions.ts b/packages/core/src/api/subscriptions.tsindex edb106657..72a625f70 100644--- a/packages/core/src/api/subscriptions.ts+++ b/packages/core/src/api/subscriptions.ts@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import hosts from "../utils/constants";-import http from "../utils/http";-import TokenManager from "./token-manager";+import hosts from "../utils/constants.js";+import http from "../utils/http.js";+import TokenManager from "./token-manager.js";export type TransactionStatus =| "completed"diff --git a/packages/core/src/api/sync/__tests__/collector.test.js b/packages/core/src/api/sync/__tests__/collector.test.jsindex fa1ea715d..d79d027ad 100644--- a/packages/core/src/api/sync/__tests__/collector.test.js+++ b/packages/core/src/api/sync/__tests__/collector.test.js@@ -21,8 +21,8 @@ import {databaseTest,TEST_NOTE,loginFakeUser-} from "../../../../__tests__/utils";-import Collector from "../collector";+} from "../../../../__tests__/utils/index.js";+import Collector from "../collector.js";import { test, expect } from "vitest";test("newly created note should get included in collector", () =>diff --git a/packages/core/src/api/sync/__tests__/merger.test.js b/packages/core/src/api/sync/__tests__/merger.test.jsindex 81cbee52c..15534c8b0 100644--- a/packages/core/src/api/sync/__tests__/merger.test.js+++ b/packages/core/src/api/sync/__tests__/merger.test.js@@ -21,9 +21,9 @@ import {TEST_NOTE,databaseTest,loginFakeUser-} from "../../../../__tests__/utils";+} from "../../../../__tests__/utils/index.js";import { expect, describe, vi } from "vitest";-import Merger from "../merger";+import Merger from "../merger.js";describe.concurrent("merge item synchronously", (test) => {test("accept remote item if no local item is found", () =>diff --git a/packages/core/src/api/sync/auto-sync.ts b/packages/core/src/api/sync/auto-sync.tsindex 060bd14dc..bb36566f8 100644--- a/packages/core/src/api/sync/auto-sync.ts+++ b/packages/core/src/api/sync/auto-sync.ts@@ -17,10 +17,10 @@ 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 "..";-import { EVENTS } from "../../common";-import { DatabaseUpdatedEvent } from "../../database";-import { logger } from "../../logger";+import Database from "../index.js";+import { EVENTS } from "../../common.js";+import { DatabaseUpdatedEvent } from "../../database/index.js";+import { logger } from "../../logger.js";export class AutoSync {timeout = 0;diff --git a/packages/core/src/api/sync/collector.ts b/packages/core/src/api/sync/collector.tsindex e3d9289a5..273f0a322 100644--- a/packages/core/src/api/sync/collector.ts+++ b/packages/core/src/api/sync/collector.ts@@ -17,17 +17,17 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { Cipher, SerializedKey } from "@notesnook/crypto";-import Database from "..";-import { CURRENT_DATABASE_VERSION, EV, EVENTS } from "../../common";-import { logger } from "../../logger";+import { Cipher } from "@notesnook/crypto";+import Database from "../index.js";+import { CURRENT_DATABASE_VERSION, EV, EVENTS } from "../../common.js";+import { logger } from "../../logger.js";import {SyncItem,SyncTransferItem,SYNC_COLLECTIONS_MAP,SYNC_ITEM_TYPES-} from "./types";-import { Item, MaybeDeletedItem } from "../../types";+} from "./types.js";+import { Item, MaybeDeletedItem } from "../../types.js";class Collector {logger = logger.scope("SyncCollector");diff --git a/packages/core/src/api/sync/devices.ts b/packages/core/src/api/sync/devices.tsindex 20e55e912..65ab34f32 100644--- a/packages/core/src/api/sync/devices.ts+++ b/packages/core/src/api/sync/devices.ts@@ -17,11 +17,11 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { KVStorageAccessor } from "../../interfaces";-import hosts from "../../utils/constants";-import http from "../../utils/http";-import { getId } from "../../utils/id";-import TokenManager from "../token-manager";+import { KVStorageAccessor } from "../../interfaces.js";+import hosts from "../../utils/constants.js";+import http from "../../utils/http.js";+import { getId } from "../../utils/id.js";+import TokenManager from "../token-manager.js";export class SyncDevices {constructor(diff --git a/packages/core/src/api/sync/index.ts b/packages/core/src/api/sync/index.tsindex de1509922..2bb4383db 100644--- a/packages/core/src/api/sync/index.ts+++ b/packages/core/src/api/sync/index.ts@@ -24,17 +24,17 @@ import {EVENTS,sendSyncProgressEvent,SYNC_CHECK_IDS-} from "../../common";-import Constants from "../../utils/constants";-import TokenManager from "../token-manager";-import Collector from "./collector";+} from "../../common.js";+import Constants from "../../utils/constants.js";+import TokenManager from "../token-manager.js";+import Collector from "./collector.js";import * as signalr from "@microsoft/signalr";-import Merger from "./merger";-import { AutoSync } from "./auto-sync";-import { logger } from "../../logger";+import Merger from "./merger.js";+import { AutoSync } from "./auto-sync.js";+import { logger } from "../../logger.js";import { Mutex } from "async-mutex";-import Database from "..";-import { migrateItem, migrateVaultKey } from "../../migrations";+import Database from "../index.js";+import { migrateItem, migrateVaultKey } from "../../migrations.js";import { SerializedKey } from "@notesnook/crypto";import {Attachment,@@ -44,15 +44,15 @@ import {MaybeDeletedItem,Note,Notebook-} from "../../types";+} from "../../types.js";import {SYNC_COLLECTIONS_MAP,SyncableItemType,SyncTransferItem-} from "./types";-import { DownloadableFile } from "../../database/fs";-import { SyncDevices } from "./devices";-import { DefaultColors } from "../../collections/colors";+} from "./types.js";+import { DownloadableFile } from "../../database/fs.js";+import { SyncDevices } from "./devices.js";+import { DefaultColors } from "../../collections/colors.js";export type SyncOptions = {type: "full" | "fetch" | "send";@@ -61,9 +61,12 @@ export type SyncOptions = {};export default class SyncManager {- sync = new Sync(this.db);- devices = this.sync.devices;- constructor(private readonly db: Database) {}+ sync;+ devices;+ constructor(private readonly db: Database) {+ this.sync = new Sync(db);+ this.devices = this.sync.devices;+ }async start(options: SyncOptions) {try {@@ -114,17 +117,22 @@ export default class SyncManager {}class Sync {- collector = new Collector(this.db);- merger = new Merger(this.db);- autoSync = new AutoSync(this.db, 1000);+ collector;+ merger;+ autoSync;logger = logger.scope("Sync");syncConnectionMutex = new Mutex();connection?: signalr.HubConnection;- devices = new SyncDevices(this.db.kv, this.db.tokenManager);+ devices;private conflictedNoteIds: string[] = [];private uncachedAttachments: DownloadableFile[] = [];constructor(private readonly db: Database) {+ this.collector = new Collector(db);+ this.merger = new Merger(db);+ this.autoSync = new AutoSync(db, 1000);+ this.devices = new SyncDevices(db.kv, db.tokenManager);+EV.subscribe(EVENTS.userLoggedOut, async () => {await this.connection?.stop();this.autoSync.stop();diff --git a/packages/core/src/api/sync/merger.ts b/packages/core/src/api/sync/merger.tsindex 5d655a293..722a7efb6 100644--- a/packages/core/src/api/sync/merger.ts+++ b/packages/core/src/api/sync/merger.ts@@ -17,16 +17,16 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { logger } from "../../logger";-import { isHTMLEqual } from "../../utils/html-diff";-import Database from "..";+import { logger } from "../../logger.js";+import { isHTMLEqual } from "../../utils/html-diff.js";+import Database from "../index.js";import {Attachment,ContentItem,Item,MaybeDeletedItem,isDeleted-} from "../../types";+} from "../../types.js";const THRESHOLD = process.env.NODE_ENV === "test" ? 6 * 1000 : 60 * 1000;class Merger {diff --git a/packages/core/src/api/token-manager.ts b/packages/core/src/api/token-manager.tsindex 2020b1260..f3c7deeb4 100644--- a/packages/core/src/api/token-manager.ts+++ b/packages/core/src/api/token-manager.ts@@ -17,12 +17,12 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import http from "../utils/http";-import constants from "../utils/constants";-import { EV, EVENTS } from "../common";+import http from "../utils/http.js";+import constants from "../utils/constants.js";+import { EV, EVENTS } from "../common.js";import { withTimeout, Mutex } from "async-mutex";-import { logger } from "../logger";-import { KVStorageAccessor } from "../interfaces";+import { logger } from "../logger.js";+import { KVStorageAccessor } from "../interfaces.js";export type Token = {access_token: string;diff --git a/packages/core/src/api/user-manager.ts b/packages/core/src/api/user-manager.tsindex afe36515e..96ca60514 100644--- a/packages/core/src/api/user-manager.ts+++ b/packages/core/src/api/user-manager.ts@@ -17,15 +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 { User } from "../types";-import http from "../utils/http";-import constants from "../utils/constants";-import TokenManager from "./token-manager";-import { EV, EVENTS } from "../common";-import { HealthCheck } from "./healthcheck";-import Database from ".";+import { User } from "../types.js";+import http from "../utils/http.js";+import constants from "../utils/constants.js";+import TokenManager from "./token-manager.js";+import { EV, EVENTS } from "../common.js";+import { HealthCheck } from "./healthcheck.js";+import Database from "./index.js";import { SerializedKey } from "@notesnook/crypto";-import { logger } from "../logger";+import { logger } from "../logger.js";const ENDPOINTS = {signup: "/users",diff --git a/packages/core/src/api/vault.ts b/packages/core/src/api/vault.tsindex 20dbb9afb..882e12ea2 100644--- a/packages/core/src/api/vault.ts+++ b/packages/core/src/api/vault.ts@@ -18,12 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Cipher } from "@notesnook/crypto";-import Database from ".";-import { CHECK_IDS, EV, EVENTS, checkIsUserPremium } from "../common";-import { isCipher } from "../database/crypto";-import { NoteContent } from "../collections/session-content";-import { Note } from "../types";-import { logger } from "../logger";+import Database from "./index.js";+import { CHECK_IDS, EV, EVENTS, checkIsUserPremium } from "../common.js";+import { isCipher } from "../utils/crypto.js";+import { Note, NoteContent } from "../types.js";+import { logger } from "../logger.js";export const VAULT_ERRORS = {noVault: "ERR_NO_VAULT",diff --git a/packages/core/src/collections/attachments.ts b/packages/core/src/collections/attachments.tsindex 977a8fe35..c29053305 100644--- a/packages/core/src/collections/attachments.ts+++ b/packages/core/src/collections/attachments.ts@@ -17,20 +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 { ICollection } from "./collection";-import { getId } from "../utils/id";-import { EV, EVENTS } from "../common";-import dataurl from "../utils/dataurl";+import { ICollection } from "./collection.js";+import { getId } from "../utils/id.js";+import { EV, EVENTS } from "../common.js";+import dataurl from "../utils/dataurl.js";import dayjs from "dayjs";-import { DocumentMimeTypes, getFileNameWithExtension } from "../utils/filename";+import {+ DocumentMimeTypes,+ getFileNameWithExtension+} from "../utils/filename.js";import { Cipher, DataFormat, SerializedKey } from "@notesnook/crypto";-import { Output } from "../interfaces";-import { Attachment } from "../types";-import Database from "../api";-import { FilteredSelector, SQLCollection } from "../database/sql-collection";-import { isFalse } from "../database";+import { Output } from "../interfaces.js";+import { Attachment } from "../types.js";+import Database from "../api/index.js";+import { FilteredSelector, SQLCollection } from "../database/sql-collection.js";+import { isFalse } from "../database/index.js";import { sql } from "@streetwriters/kysely";-import { logger } from "../logger";+import { logger } from "../logger.js";export class Attachments implements ICollection {name = "attachments";diff --git a/packages/core/src/collections/colors.ts b/packages/core/src/collections/colors.tsindex ea91e357e..378b4a6e4 100644--- a/packages/core/src/collections/colors.ts+++ b/packages/core/src/collections/colors.ts@@ -17,14 +17,14 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { ICollection } from "./collection";-import { getId } from "../utils/id";-import { Color } from "../types";-import Database from "../api";-import { Tags } from "./tags";-import { SQLCollection } from "../database/sql-collection";-import { isFalse } from "../database";-import { CHECK_IDS, checkIsUserPremium } from "../common";+import { ICollection } from "./collection.js";+import { getId } from "../utils/id.js";+import { Color } from "../types.js";+import Database from "../api/index.js";+import { sanitizeTag } from "./tags.js";+import { SQLCollection } from "../database/sql-collection.js";+import { isFalse } from "../database/index.js";+import { CHECK_IDS, checkIsUserPremium } from "../common.js";export const DefaultColors: Record<string, string> = {red: "#f44336",@@ -70,7 +70,7 @@ export class Colors implements ICollection {// }async add(item: Partial<Color>) {- item.title = item.title ? Tags.sanitize(item.title) : item.title;+ item.title = item.title ? sanitizeTag(item.title) : item.title;const oldColor = item.id? await this.color(item.id): item.colorCodediff --git a/packages/core/src/collections/content.ts b/packages/core/src/collections/content.tsindex b845532f8..7dd4ae431 100644--- a/packages/core/src/collections/content.ts+++ b/packages/core/src/collections/content.ts@@ -17,25 +17,25 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { ICollection } from "./collection";-import { getId } from "../utils/id";-import { getContentFromData } from "../content-types";-import { isCipher } from "../database/crypto";+import { ICollection } from "./collection.js";+import { getId } from "../utils/id.js";+import { getContentFromData } from "../content-types/index.js";+import { isCipher } from "../utils/crypto.js";import {ContentItem,ContentType,UnencryptedContentItem,- isDeleted-} from "../types";-import Database from "../api";-import { getOutputType } from "./attachments";-import { SQLCollection } from "../database/sql-collection";-import { NoteContent } from "./session-content";-import { InternalLink } from "../utils/internal-link";-import { tinyToTiptap } from "../migrations";-import { EVENTS } from "../common";-import { DeleteEvent, UpdateEvent } from "../database";-import { logger } from "../logger";+ isDeleted,+ NoteContent+} from "../types.js";+import Database from "../api/index.js";+import { getOutputType } from "./attachments.js";+import { SQLCollection } from "../database/sql-collection.js";+import { InternalLink } from "../utils/internal-link.js";+import { tinyToTiptap } from "../migrations.js";+import { EVENTS } from "../common.js";+import { DeleteEvent, UpdateEvent } from "../database/index.js";+import { logger } from "../logger.js";export const EMPTY_CONTENT = (noteId: string): UnencryptedContentItem => ({noteId,@@ -419,15 +419,3 @@ export class Content implements ICollection {}}}--export function isDecryptedContent(- content: NoteContent<boolean>-): content is NoteContent<false> {- return !isCipher(content.data);-}--export function isEncryptedContent(- content: NoteContent<boolean>-): content is NoteContent<true> {- return isCipher(content.data);-}diff --git a/packages/core/src/collections/legacy-settings.ts b/packages/core/src/collections/legacy-settings.tsindex 8521ba8e6..0c9290846 100644--- a/packages/core/src/collections/legacy-settings.ts+++ b/packages/core/src/collections/legacy-settings.ts@@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { getId } from "../utils/id";-import Database from "../api";-import { LegacySettingsItem } from "../types";-import { ICollection } from "./collection";+import { getId } from "../utils/id.js";+import Database from "../api/index.js";+import { LegacySettingsItem } from "../types.js";+import { ICollection } from "./collection.js";/*** @deprecated only kept here for migration purposesdiff --git a/packages/core/src/collections/note-history.ts b/packages/core/src/collections/note-history.tsindex 116d18368..270d8ee01 100644--- a/packages/core/src/collections/note-history.ts+++ b/packages/core/src/collections/note-history.ts@@ -17,20 +17,21 @@ 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 "../api";-import { isCipher } from "../database/crypto";-import { FilteredSelector, SQLCollection } from "../database/sql-collection";-import { HistorySession, isDeleted } from "../types";-import { makeSessionContentId } from "../utils/id";-import { ICollection } from "./collection";-import { NoteContent, SessionContent } from "./session-content";+import Database from "../api/index.js";+import { isCipher } from "../utils/crypto.js";+import { FilteredSelector, SQLCollection } from "../database/sql-collection.js";+import { HistorySession, isDeleted, NoteContent } from "../types.js";+import { makeSessionContentId } from "../utils/id.js";+import { ICollection } from "./collection.js";+import { SessionContent } from "./session-content.js";export class NoteHistory implements ICollection {name = "notehistory";versionsLimit = 100;- sessionContent = new SessionContent(this.db);+ sessionContent;readonly collection: SQLCollection<"notehistory", HistorySession>;constructor(private readonly db: Database) {+ this.sessionContent = new SessionContent(db);this.collection = new SQLCollection(db.sql,db.transaction,diff --git a/packages/core/src/collections/notebooks.ts b/packages/core/src/collections/notebooks.tsindex 597298b3a..57a0b0269 100644--- a/packages/core/src/collections/notebooks.ts+++ b/packages/core/src/collections/notebooks.ts@@ -17,15 +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 { getId } from "../utils/id";-import Database from "../api";-import { Notebook, TrashOrItem, isTrashItem } from "../types";-import { ICollection } from "./collection";-import { SQLCollection } from "../database/sql-collection";-import { isFalse } from "../database";+import { getId } from "../utils/id.js";+import Database from "../api/index.js";+import { Notebook, TrashOrItem, isTrashItem } from "../types.js";+import { ICollection } from "./collection.js";+import { SQLCollection } from "../database/sql-collection.js";+import { isFalse } from "../database/index.js";import { sql } from "@streetwriters/kysely";-import { deleteItems } from "../utils/array";-import { CHECK_IDS, checkIsUserPremium } from "../common";+import { deleteItems } from "../utils/array.js";+import { CHECK_IDS, checkIsUserPremium } from "../common.js";export class Notebooks implements ICollection {name = "notebooks";diff --git a/packages/core/src/collections/notes.ts b/packages/core/src/collections/notes.tsindex 06651ebd2..6cdd678c5 100644--- a/packages/core/src/collections/notes.ts+++ b/packages/core/src/collections/notes.ts@@ -17,20 +17,25 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { getId } from "../utils/id";-import { getContentFromData } from "../content-types";-import { NEWLINE_STRIP_REGEX, formatTitle } from "../utils/title-format";-import { clone } from "../utils/clone";-import { Tiptap } from "../content-types/tiptap";-import { EMPTY_CONTENT } from "./content";-import { buildFromTemplate } from "../utils/templates";-import { Note, TrashOrItem, isTrashItem, isDeleted } from "../types";-import Database from "../api";-import { ICollection } from "./collection";-import { NoteContent } from "./session-content";-import { SQLCollection } from "../database/sql-collection";-import { isFalse } from "../database";-import { logger } from "../logger";+import { getId } from "../utils/id.js";+import { getContentFromData } from "../content-types/index.js";+import { NEWLINE_STRIP_REGEX, formatTitle } from "../utils/title-format.js";+import { clone } from "../utils/clone.js";+import { Tiptap } from "../content-types/tiptap.js";+import { EMPTY_CONTENT } from "./content.js";+import { buildFromTemplate } from "../utils/templates/index.js";+import {+ Note,+ TrashOrItem,+ isTrashItem,+ isDeleted,+ NoteContent+} from "../types.js";+import Database from "../api/index.js";+import { ICollection } from "./collection.js";+import { SQLCollection } from "../database/sql-collection.js";+import { isFalse } from "../database/index.js";+import { logger } from "../logger.js";export type ExportOptions = {format: "html" | "md" | "txt" | "md-frontmatter";diff --git a/packages/core/src/collections/relations.ts b/packages/core/src/collections/relations.tsindex 86929aa9d..69c00bbb3 100644--- a/packages/core/src/collections/relations.ts+++ b/packages/core/src/collections/relations.ts@@ -17,20 +17,20 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { makeId } from "../utils/id";-import { ICollection } from "./collection";+import { makeId } from "../utils/id.js";+import { ICollection } from "./collection.js";import {Relation,ItemMap,ItemReference,ItemReferences,ValueOf-} from "../types";-import Database from "../api";-import { FilteredSelector, SQLCollection } from "../database/sql-collection";-import { DatabaseSchema, UnlinkEvent, isFalse } from "../database";+} from "../types.js";+import Database from "../api/index.js";+import { FilteredSelector, SQLCollection } from "../database/sql-collection.js";+import { DatabaseSchema, UnlinkEvent, isFalse } from "../database/index.js";import { SelectQueryBuilder } from "@streetwriters/kysely";-import { EVENTS } from "../common";+import { EVENTS } from "../common.js";export class Relations implements ICollection {name = "relations";diff --git a/packages/core/src/collections/reminders.ts b/packages/core/src/collections/reminders.tsindex 0f8fe2a77..5d5db6113 100644--- a/packages/core/src/collections/reminders.ts+++ b/packages/core/src/collections/reminders.ts@@ -18,17 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import dayjs from "dayjs";-import isSameOrBefore from "dayjs/plugin/isSameOrBefore";-import isToday from "dayjs/plugin/isToday";-import isTomorrow from "dayjs/plugin/isTomorrow";-import isYesterday from "dayjs/plugin/isYesterday";-import { TimeFormat, formatDate } from "../utils/date";-import { getId } from "../utils/id";-import { ICollection } from "./collection";-import { Reminder } from "../types";-import Database from "../api";-import { SQLCollection } from "../database/sql-collection";-import { isFalse } from "../database";+import isSameOrBefore from "dayjs/plugin/isSameOrBefore.js";+import isToday from "dayjs/plugin/isToday.js";+import isTomorrow from "dayjs/plugin/isTomorrow.js";+import isYesterday from "dayjs/plugin/isYesterday.js";+import { formatDate } from "../utils/date.js";+import { getId } from "../utils/id.js";+import { ICollection } from "./collection.js";+import { Reminder, TimeFormat } from "../types.js";+import Database from "../api/index.js";+import { SQLCollection } from "../database/sql-collection.js";+import { isFalse } from "../database/index.js";import { sql } from "@streetwriters/kysely";dayjs.extend(isTomorrow);diff --git a/packages/core/src/collections/session-content.ts b/packages/core/src/collections/session-content.tsindex d8d3743f7..692e0290d 100644--- a/packages/core/src/collections/session-content.ts+++ b/packages/core/src/collections/session-content.ts@@ -17,19 +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/>.*/-import { Cipher } from "@notesnook/crypto";-import { tinyToTiptap } from "../migrations";-import { makeSessionContentId } from "../utils/id";-import { ICollection } from "./collection";-import { isCipher } from "../database/crypto";-import Database from "../api";-import { ContentType, SessionContentItem, isDeleted } from "../types";-import { SQLCollection } from "../database/sql-collection";--export type NoteContent<TLocked extends boolean> = {- data: TLocked extends true ? Cipher<"base64"> : string;- type: ContentType;-};+import { tinyToTiptap } from "../migrations.js";+import { makeSessionContentId } from "../utils/id.js";+import { ICollection } from "./collection.js";+import { isCipher } from "../utils/crypto.js";+import Database from "../api/index.js";+import { NoteContent, SessionContentItem, isDeleted } from "../types.js";+import { SQLCollection } from "../database/sql-collection.js";export class SessionContent implements ICollection {name = "sessioncontent";diff --git a/packages/core/src/collections/settings.ts b/packages/core/src/collections/settings.tsindex 9c66521a1..e6f7cb282 100644--- a/packages/core/src/collections/settings.ts+++ b/packages/core/src/collections/settings.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { makeId } from "../utils/id";-import Database from "../api";+import { makeId } from "../utils/id.js";+import Database from "../api/index.js";import {GroupOptions,GroupingKey,@@ -29,11 +29,11 @@ import {SideBarSection,ToolbarConfig,ToolbarConfigPlatforms,- TrashCleanupInterval-} from "../types";-import { ICollection } from "./collection";-import { TimeFormat } from "../utils/date";-import { SQLCachedCollection } from "../database/sql-cached-collection";+ TrashCleanupInterval,+ TimeFormat+} from "../types.js";+import { ICollection } from "./collection.js";+import { SQLCachedCollection } from "../database/sql-cached-collection.js";const DEFAULT_GROUP_OPTIONS = (key: GroupingKey) =>({diff --git a/packages/core/src/collections/shortcuts.ts b/packages/core/src/collections/shortcuts.tsindex fea418be0..0f854de0f 100644--- a/packages/core/src/collections/shortcuts.ts+++ b/packages/core/src/collections/shortcuts.ts@@ -17,10 +17,10 @@ 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 "../api";-import { SQLCachedCollection } from "../database/sql-cached-collection";-import { Notebook, Shortcut, Tag } from "../types";-import { ICollection } from "./collection";+import Database from "../api/index.js";+import { SQLCachedCollection } from "../database/sql-cached-collection.js";+import { Notebook, Shortcut, Tag } from "../types.js";+import { ICollection } from "./collection.js";type ResolveTypeToItem<T extends "notebooks" | "tags" | "all"> =T extends "tags"diff --git a/packages/core/src/collections/tags.ts b/packages/core/src/collections/tags.tsindex c111ecd87..dedfef48f 100644--- a/packages/core/src/collections/tags.ts+++ b/packages/core/src/collections/tags.ts@@ -17,14 +17,14 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { getId } from "../utils/id";-import { Tag } from "../types";-import Database from "../api";-import { ICollection } from "./collection";-import { SQLCollection } from "../database/sql-collection";-import { isFalse } from "../database";+import { getId } from "../utils/id.js";+import { Tag } from "../types.js";+import Database from "../api/index.js";+import { ICollection } from "./collection.js";+import { SQLCollection } from "../database/sql-collection.js";+import { isFalse } from "../database/index.js";import { sql } from "@streetwriters/kysely";-import { CHECK_IDS, checkIsUserPremium } from "../common";+import { CHECK_IDS, checkIsUserPremium } from "../common.js";export class Tags implements ICollection {name = "tags";@@ -52,7 +52,7 @@ export class Tags implements ICollection {}async add(item: Partial<Tag> & { title: string }) {- item.title = Tags.sanitize(item.title);+ item.title = sanitizeTag(item.title);const oldTag = item.id ? await this.tag(item.id) : undefined;@@ -103,8 +103,8 @@ export class Tags implements ICollection {exists(id: string) {return this.collection.exists(id);}+}- static sanitize(title: string) {- return title.replace(/^\s+|\s+$/gm, "");- }+export function sanitizeTag(title: string) {+ return title.replace(/^\s+|\s+$/gm, "");}diff --git a/packages/core/src/collections/trash.ts b/packages/core/src/collections/trash.tsindex 07fafd3fb..6612ba206 100644--- a/packages/core/src/collections/trash.ts+++ b/packages/core/src/collections/trash.ts@@ -18,17 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import dayjs from "dayjs";-import Database from "../api";-import { deleteItems, toChunks } from "../utils/array";-import { GroupOptions, TrashItem } from "../types";-import { VirtualizedGrouping } from "../utils/virtualized-grouping";+import Database from "../api/index.js";+import { deleteItems, toChunks } from "../utils/array.js";+import { GroupOptions, TrashItem } from "../types.js";+import { VirtualizedGrouping } from "../utils/virtualized-grouping.js";import {createKeySelector,getSortSelectors,groupArray-} from "../utils/grouping";+} from "../utils/grouping.js";import { sql } from "@streetwriters/kysely";-import { MAX_SQL_PARAMETERS } from "../database/sql-collection";+import { MAX_SQL_PARAMETERS } from "../database/sql-collection.js";export default class Trash {collections = ["notes", "notebooks"] as const;diff --git a/packages/core/src/collections/vaults.ts b/packages/core/src/collections/vaults.tsindex 4c4f45d16..051e5c032 100644--- a/packages/core/src/collections/vaults.ts+++ b/packages/core/src/collections/vaults.ts@@ -17,12 +17,12 @@ 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 "../api";-import { ItemReference, Vault } from "../types";-import { ICollection } from "./collection";-import { SQLCollection } from "../database/sql-collection";-import { getId } from "../utils/id";-import { isFalse } from "../database";+import Database from "../api/index.js";+import { ItemReference, Vault } from "../types.js";+import { ICollection } from "./collection.js";+import { SQLCollection } from "../database/sql-collection.js";+import { getId } from "../utils/id.js";+import { isFalse } from "../database/index.js";export class Vaults implements ICollection {name = "vaults";diff --git a/packages/core/src/common.ts b/packages/core/src/common.tsindex 1f480a17b..8fb764fbb 100644--- a/packages/core/src/common.ts+++ b/packages/core/src/common.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/>.*/-import EventManager from "./utils/event-manager";+import EventManager from "./utils/event-manager.js";export const EV = new EventManager();diff --git a/packages/core/src/content-types/__tests__/tiptap.test.js b/packages/core/src/content-types/__tests__/tiptap.test.jsindex 8c1405d5b..dd366238a 100644--- a/packages/core/src/content-types/__tests__/tiptap.test.js+++ b/packages/core/src/content-types/__tests__/tiptap.test.js@@ -20,8 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import {IMG_CONTENT,IMG_CONTENT_WITHOUT_HASH-} from "../../../__tests__/utils";-import { Tiptap } from "../tiptap";+} from "../../../__tests__/utils/index.js";+import { Tiptap } from "../tiptap.js";import { test, expect } from "vitest";test("img src is empty after extract attachments", async () => {diff --git a/packages/core/src/content-types/index.ts b/packages/core/src/content-types/index.tsindex db8bec417..fa892b09e 100644--- a/packages/core/src/content-types/index.ts+++ b/packages/core/src/content-types/index.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { ContentType } from "../types";-import { Tiptap } from "./tiptap";+import { ContentType } from "../types.js";+import { Tiptap } from "./tiptap.js";export function getContentFromData(type: ContentType, data: string) {switch (type) {@@ -30,3 +30,5 @@ export function getContentFromData(type: ContentType, data: string) {);}}++export * from "./tiptap.js";diff --git a/packages/core/src/content-types/tiptap.ts b/packages/core/src/content-types/tiptap.tsindex 3e466c5a8..02fb18358 100644--- a/packages/core/src/content-types/tiptap.ts+++ b/packages/core/src/content-types/tiptap.ts@@ -27,22 +27,22 @@ import {} from "html-to-text";import { BlockTextBuilder } from "html-to-text/lib/block-text-builder";import { parseDocument } from "htmlparser2";-import dataurl from "../utils/dataurl";+import dataurl from "../utils/dataurl.js";import {HTMLParser,extractFirstParagraph,getDummyDocument-} from "../utils/html-parser";-import { HTMLRewriter } from "../utils/html-rewriter";-import { ContentBlock } from "../types";+} from "../utils/html-parser.js";+import { HTMLRewriter } from "../utils/html-rewriter.js";+import { ContentBlock } from "../types.js";import {InternalLink,isInternalLink,parseInternalLink-} from "../utils/internal-link";+} from "../utils/internal-link.js";import { Element } from "domhandler";import { render } from "dom-serializer";-import { logger } from "../logger";+import { logger } from "../logger.js";export type ResolveHashes = (hashes: string[]diff --git a/packages/core/src/database/backup.ts b/packages/core/src/database/backup.tsindex e15acd032..d01563988 100644--- a/packages/core/src/database/backup.ts+++ b/packages/core/src/database/backup.ts@@ -32,8 +32,8 @@ import {isDeleted} from "../types.js";import { Cipher, SerializedKey } from "@notesnook/crypto";-import { isCipher } from "./crypto.js";-import { migrateItem } from "../migrations";+import { isCipher } from "../utils/crypto.js";+import { migrateItem } from "../migrations.js";import { DatabaseCollection } from "./index.js";import { DefaultColors } from "../collections/colors.js";import { toChunks } from "../utils/array.js";diff --git a/packages/core/src/database/cached-collection.ts b/packages/core/src/database/cached-collection.tsindex b04143fb6..272f03cc8 100644--- a/packages/core/src/database/cached-collection.ts+++ b/packages/core/src/database/cached-collection.ts@@ -17,15 +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 { IndexedCollection } from "./indexed-collection";+import { IndexedCollection } from "./indexed-collection.js";import {CollectionType,Collections,ItemMap,MaybeDeletedItem,isDeleted-} from "../types";-import { StorageAccessor } from "../interfaces";+} from "../types.js";+import { StorageAccessor } from "../interfaces.js";/*** @deprecated only kept here for migration purposesdiff --git a/packages/core/src/database/config.ts b/packages/core/src/database/config.tsindex 1c51821f8..445c79c34 100644--- a/packages/core/src/database/config.ts+++ b/packages/core/src/database/config.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/>.*/-import { DatabaseAccessor, RawDatabaseSchema } from ".";+import { DatabaseAccessor, RawDatabaseSchema } from "./index.js";export class ConfigStorage {private readonly db: DatabaseAccessor<RawDatabaseSchema>;diff --git a/packages/core/src/database/fs.ts b/packages/core/src/database/fs.tsindex bb2f24e97..1ae799d52 100644--- a/packages/core/src/database/fs.ts+++ b/packages/core/src/database/fs.ts@@ -17,15 +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 hosts from "../utils/constants";-import TokenManager from "../api/token-manager";+import hosts from "../utils/constants.js";+import TokenManager from "../api/token-manager.js";import {FileEncryptionMetadataWithOutputType,IFileStorage-} from "../interfaces";-import { DataFormat, SerializedKey } from "@notesnook/crypto/dist/src/types";-import { EV, EVENTS } from "../common";-import { logger } from "../logger";+} from "../interfaces.js";+import { DataFormat, SerializedKey } from "@notesnook/crypto";+import { EV, EVENTS } from "../common.js";+import { logger } from "../logger.js";export type FileStorageAccessor = () => FileStorage;export type DownloadableFile = {diff --git a/packages/core/src/database/fts.ts b/packages/core/src/database/fts.tsindex 4c817bb6c..7d3e646a7 100644--- a/packages/core/src/database/fts.ts+++ b/packages/core/src/database/fts.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Kysely, sql } from "@streetwriters/kysely";-import { RawDatabaseSchema } from ".";+import { RawDatabaseSchema } from "./index.js";export async function rebuildSearchIndex(db: Kysely<RawDatabaseSchema>) {await db.transaction().execute(async (tx) => {diff --git a/packages/core/src/database/index.ts b/packages/core/src/database/index.tsindex 0c8f74a3f..9229002d2 100644--- a/packages/core/src/database/index.ts+++ b/packages/core/src/database/index.ts@@ -58,8 +58,8 @@ import {ValueOf,Vault,isDeleted-} from "../types";-import { logger } from "../logger";+} from "../types.js";+import { logger } from "../logger.js";// type FilteredKeys<T, U> = {// [P in keyof T]: T[P] extends U ? P : never;diff --git a/packages/core/src/database/indexed-collection.ts b/packages/core/src/database/indexed-collection.tsindex aa60e4928..7864847b1 100644--- a/packages/core/src/database/indexed-collection.ts+++ b/packages/core/src/database/indexed-collection.ts@@ -17,15 +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 { toChunks } from "../utils/array";-import { StorageAccessor } from "../interfaces";+import { toChunks } from "../utils/array.js";+import { StorageAccessor } from "../interfaces.js";import {CollectionType,Collections,ItemMap,MaybeDeletedItem-} from "../types";-import Indexer from "./indexer";+} from "../types.js";+import Indexer from "./indexer.js";/*** @deprecated only kept here for migration purposesdiff --git a/packages/core/src/database/indexer.ts b/packages/core/src/database/indexer.tsindex b2a5486bc..d88171e55 100644--- a/packages/core/src/database/indexer.ts+++ b/packages/core/src/database/indexer.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { StorageAccessor } from "../interfaces";-import { MaybeDeletedItem } from "../types";+import { StorageAccessor } from "../interfaces.js";+import { MaybeDeletedItem } from "../types.js";export default class Indexer<T> {private _indices: string[] = [];diff --git a/packages/core/src/database/kv.ts b/packages/core/src/database/kv.tsindex a67e20511..ff1f6cad8 100644--- a/packages/core/src/database/kv.ts+++ b/packages/core/src/database/kv.ts@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { DatabaseAccessor, RawDatabaseSchema } from ".";-import { Token } from "../api/token-manager";-import { User } from "../types";+import { DatabaseAccessor, RawDatabaseSchema } from "./index.js";+import { Token } from "../api/token-manager.js";+import { User } from "../types.js";interface KV {v: number;diff --git a/packages/core/src/database/migrations.ts b/packages/core/src/database/migrations.tsindex 649b72212..e28bee5d7 100644--- a/packages/core/src/database/migrations.ts+++ b/packages/core/src/database/migrations.ts@@ -25,7 +25,7 @@ import {MigrationProvider,sql} from "@streetwriters/kysely";-import { rebuildSearchIndex } from "./fts";+import { rebuildSearchIndex } from "./fts.js";const COLLATE_NOCASE: ColumnBuilderCallback = (col) =>col.modifyEnd(sql`collate nocase`);diff --git a/packages/core/src/database/migrator.ts b/packages/core/src/database/migrator.tsindex fc8de69fd..86281d0de 100644--- a/packages/core/src/database/migrator.ts+++ b/packages/core/src/database/migrator.ts@@ -18,18 +18,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Cipher } from "@notesnook/crypto";-import { DatabaseSchema } from ".";-import Database from "../api";+import { DatabaseSchema } from "./index.js";+import Database from "../api/index.js";import {CURRENT_DATABASE_VERSION,sendMigrationProgressEvent-} from "../common";+} from "../common.js";import {migrateCollection,migrateItem,migrateKV,migrateVaultKey-} from "../migrations";+} from "../migrations.js";import {CollectionType,Collections,@@ -38,10 +38,10 @@ import {MaybeDeletedItem,isDeleted,isTrashItem-} from "../types";-import { IndexedCollection } from "./indexed-collection";-import { SQLCollection } from "./sql-collection";-import { logger } from "../logger";+} from "../types.js";+import { IndexedCollection } from "./indexed-collection.js";+import { SQLCollection } from "./sql-collection.js";+import { logger } from "../logger.js";export type RawItem = MaybeDeletedItem<Item>;type MigratableCollection = {diff --git a/packages/core/src/database/sanitizer.ts b/packages/core/src/database/sanitizer.tsindex 0148836d7..0d135c7d6 100644--- a/packages/core/src/database/sanitizer.ts+++ b/packages/core/src/database/sanitizer.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { DatabaseAccessor } from ".";-import { logger } from "../logger";+import { DatabaseAccessor } from "./index.js";+import { logger } from "../logger.js";export class Sanitizer {tables: Record<string, Set<string>> = {};diff --git a/packages/core/src/database/sql-cached-collection.ts b/packages/core/src/database/sql-cached-collection.tsindex 2e635a6d3..da07db156 100644--- a/packages/core/src/database/sql-cached-collection.ts+++ b/packages/core/src/database/sql-cached-collection.ts@@ -17,12 +17,12 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { MaybeDeletedItem, isDeleted } from "../types";-import EventManager from "../utils/event-manager";-import { DatabaseAccessor, DatabaseCollection, DatabaseSchema } from ".";-import { SQLCollection } from "./sql-collection";+import { MaybeDeletedItem, isDeleted } from "../types.js";+import EventManager from "../utils/event-manager.js";+import { DatabaseAccessor, DatabaseCollection, DatabaseSchema } from "./index.js";+import { SQLCollection } from "./sql-collection.js";import { Kysely } from "@streetwriters/kysely";-import { Sanitizer } from "./sanitizer";+import { Sanitizer } from "./sanitizer.js";export class SQLCachedCollection<TCollectionType extends keyof DatabaseSchema,diff --git a/packages/core/src/database/sql-collection.ts b/packages/core/src/database/sql-collection.tsindex b962dbf20..6841570ba 100644--- a/packages/core/src/database/sql-collection.ts+++ b/packages/core/src/database/sql-collection.ts@@ -17,15 +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 { EVENTS } from "../common";+import { EVENTS } from "../common.js";import {GroupOptions,Item,MaybeDeletedItem,SortOptions,isDeleted-} from "../types";-import EventManager from "../utils/event-manager";+} from "../types.js";+import EventManager from "../utils/event-manager.js";import {DatabaseAccessor,DatabaseCollection,@@ -35,7 +35,7 @@ import {UpdateEvent,UpsertEvent,isFalse-} from ".";+} from "./index.js";import {AliasedRawBuilder,AnyColumn,@@ -46,14 +46,14 @@ import {SqlBool,sql} from "@streetwriters/kysely";-import { VirtualizedGrouping } from "../utils/virtualized-grouping";-import { createKeySelector, groupArray } from "../utils/grouping";-import { toChunks } from "../utils/array";-import { Sanitizer } from "./sanitizer";+import { VirtualizedGrouping } from "../utils/virtualized-grouping.js";+import { createKeySelector, groupArray } from "../utils/grouping.js";+import { toChunks } from "../utils/array.js";+import { Sanitizer } from "./sanitizer.js";import {createIsReminderActiveQuery,createUpcomingReminderTimeQuery-} from "../collections/reminders";+} from "../collections/reminders.js";const formats = {month: "%Y-%m",diff --git a/packages/core/src/database/triggers.ts b/packages/core/src/database/triggers.tsindex 9b45d2f38..bbdefe8b4 100644--- a/packages/core/src/database/triggers.ts+++ b/packages/core/src/database/triggers.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Kysely, sql } from "@streetwriters/kysely";-import { DatabaseSchema, RawDatabaseSchema } from ".";+import { DatabaseSchema, RawDatabaseSchema } from "./index.js";export async function createTriggers(db: Kysely<RawDatabaseSchema>) {// content triggersdiff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 1fc654351..dd28d9038 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -17,19 +17,29 @@ 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 "./types";-export { VirtualizedGrouping } from "./utils/virtualized-grouping";-export { DefaultColors } from "./collections/colors";-export { type BackupFile, type LegacyBackupFile } from "./database/backup";+export * from "./types.js";+export * from "./interfaces.js";+export * from "./utils/index.js";+export * from "./content-types/index.js";+export * from "./common.js";+export { default as Database } from "./api/index.js";+export { DefaultColors } from "./collections/colors.js";+export { EMPTY_CONTENT } from "./collections/content.js";+export { type BackupFile, type LegacyBackupFile } from "./database/backup.js";+export { type DatabaseUpdatedEvent } from "./database/index.js";+export { FilteredSelector } from "./database/sql-collection.js";export {- createInternalLink,- parseInternalLink,- type InternalLink-} from "./utils/internal-link";-export {- extractInternalLinks,- highlightInternalLinks,- type TextSlice-} from "./utils/content-block";-export { type DatabaseUpdatedEvent } from "./database";-export { isServerCompatible } from "./utils/constants";+ getUpcomingReminder,+ formatReminderTime,+ isReminderToday,+ isReminderActive+} from "./collections/reminders.js";+export * from "./logger.js";+export * from "./api/debug.js";+export * from "./api/monographs.js";+export * from "./api/subscriptions.js";+export * from "./api/pricing.js";+export { VAULT_ERRORS } from "./api/vault.js";+export type { SyncOptions } from "./api/sync/index.js";+export { sanitizeTag } from "./collections/tags.js";+export { default as DataURL } from "./utils/dataurl.js";diff --git a/packages/core/src/interfaces.ts b/packages/core/src/interfaces.tsindex 4604a4268..23620b8ec 100644--- a/packages/core/src/interfaces.ts+++ b/packages/core/src/interfaces.ts@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Cipher, DataFormat, SerializedKey } from "@notesnook/crypto";-import { KVStorage } from "./database/kv";-import { ConfigStorage } from "./database/config";+import { KVStorage } from "./database/kv.js";+import { ConfigStorage } from "./database/config.js";export type Output<TOutputFormat extends DataFormat> =TOutputFormat extends "uint8array" ? Uint8Array : string;diff --git a/packages/core/src/logger.ts b/packages/core/src/logger.tsindex c903e2370..523140b4b 100644--- a/packages/core/src/logger.ts+++ b/packages/core/src/logger.ts@@ -29,8 +29,8 @@ import {ILogger} from "@notesnook/logger";import { Kysely, Migration, MigrationProvider } from "@streetwriters/kysely";-import { SQLiteOptions, createDatabase } from "./database";-import { toChunks } from "./utils/array";+import { SQLiteOptions, createDatabase } from "./database/index.js";+import { toChunks } from "./utils/array.js";const WEEK = 86400000 * 7;diff --git a/packages/core/src/migrations.ts b/packages/core/src/migrations.tsindex 9d515f925..a6a573753 100644--- a/packages/core/src/migrations.ts+++ b/packages/core/src/migrations.ts@@ -17,11 +17,11 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { parseHTML } from "./utils/html-parser";+import { parseHTML } from "./utils/html-parser.js";import { decodeHTML5 } from "entities";-import { CURRENT_DATABASE_VERSION } from "./common";-import Database from "./api";-import { makeId } from "./utils/id";+import { CURRENT_DATABASE_VERSION } from "./common.js";+import Database from "./api/index.js";+import { makeId } from "./utils/id.js";import {Color,ContentItem,@@ -33,12 +33,12 @@ import {ToolbarConfigPlatforms,isDeleted,isGroupingKey-} from "./types";-import { isCipher } from "./database/crypto";-import { IndexedCollection } from "./database/indexed-collection";-import { DefaultColors } from "./collections/colors";+} from "./types.js";+import { isCipher } from "./utils/crypto.js";+import { IndexedCollection } from "./database/indexed-collection.js";+import { DefaultColors } from "./collections/colors.js";import { Cipher } from "@notesnook/crypto";-import { KEYS } from "./database/kv";+import { KEYS } from "./database/kv.js";type MigrationType = "local" | "sync" | "backup";type MigrationItemType = ItemType | "notehistory" | "content" | "never";diff --git a/packages/core/src/types.ts b/packages/core/src/types.tsindex bae8b0fdf..5a857f212 100644--- a/packages/core/src/types.ts+++ b/packages/core/src/types.ts@@ -18,7 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Cipher } from "@notesnook/crypto";-import { TimeFormat } from "./utils/date";+import { isCipher } from "./utils/index.js";++export type TimeFormat = "12-hour" | "24-hour";export type SortOptions = {sortBy:@@ -567,3 +569,20 @@ export type ContentBlock = {type: string;id: string;};++export type NoteContent<TLocked extends boolean> = {+ data: TLocked extends true ? Cipher<"base64"> : string;+ type: ContentType;+};++export function isDecryptedContent(+ content: NoteContent<boolean>+): content is NoteContent<false> {+ return !isCipher(content.data);+}++export function isEncryptedContent(+ content: NoteContent<boolean>+): content is NoteContent<true> {+ return isCipher(content.data);+}diff --git a/packages/core/src/utils/__tests__/content-block.test.ts b/packages/core/src/utils/__tests__/content-block.test.tsindex eb6d3a5f1..8c332312d 100644--- a/packages/core/src/utils/__tests__/content-block.test.ts+++ b/packages/core/src/utils/__tests__/content-block.test.ts@@ -22,8 +22,8 @@ import {extractInternalLinks,highlightInternalLinks,ellipsize-} from "../content-block";-import { ContentBlock } from "../../types";+} from "../content-block.js";+import { ContentBlock } from "../../types.js";describe("ContentBlock Utils", () => {describe("extractInternalLinks", () => {diff --git a/packages/core/src/utils/__tests__/html-diff.test.js b/packages/core/src/utils/__tests__/html-diff.test.jsindex 89132d9a2..9b6803e1e 100644--- a/packages/core/src/utils/__tests__/html-diff.test.js+++ b/packages/core/src/utils/__tests__/html-diff.test.js@@ -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/>.*/-import { isHTMLEqual } from "../html-diff";+import { isHTMLEqual } from "../html-diff.js";import { test, expect, describe } from "vitest";const equalPairs = [diff --git a/packages/core/src/utils/__tests__/query-transformer.test.ts b/packages/core/src/utils/__tests__/query-transformer.test.tsindex c9b54a58b..8ad04037c 100644--- a/packages/core/src/utils/__tests__/query-transformer.test.ts+++ b/packages/core/src/utils/__tests__/query-transformer.test.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { expect, test } from "vitest";-import { transformQuery } from "../query-transformer";+import { transformQuery } from "../query-transformer.js";const TRANSFORM_QUERY_TESTS = [["hello world", `"hello world"`],diff --git a/packages/core/src/utils/__tests__/set.test.js b/packages/core/src/utils/__tests__/set.test.jsindex 194e198d2..67b764c57 100644--- a/packages/core/src/utils/__tests__/set.test.js+++ b/packages/core/src/utils/__tests__/set.test.js@@ -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/>.*/-import { set } from "../set";+import { set } from "../set.js";import { test, expect } from "vitest";test("union", () => {diff --git a/packages/core/src/utils/__tests__/title-format.test.js b/packages/core/src/utils/__tests__/title-format.test.jsindex 2e6cfdf7c..df227961b 100644--- a/packages/core/src/utils/__tests__/title-format.test.js+++ b/packages/core/src/utils/__tests__/title-format.test.js@@ -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/>.*/-import { formatTitle } from "../title-format";+import { formatTitle } from "../title-format.js";import MockDate from "mockdate";import { test, expect, describe, beforeAll, afterAll } from "vitest";diff --git a/packages/core/src/utils/__tests__/virtualized-grouping.test.ts b/packages/core/src/utils/__tests__/virtualized-grouping.test.tsindex ca0e7416a..33cad287d 100644--- a/packages/core/src/utils/__tests__/virtualized-grouping.test.ts+++ b/packages/core/src/utils/__tests__/virtualized-grouping.test.ts@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { test } from "vitest";-import { VirtualizedGrouping } from "../virtualized-grouping";-import { groupArray } from "../grouping";+import { VirtualizedGrouping } from "../virtualized-grouping.js";+import { groupArray } from "../grouping.js";function generateItems(length: number, groupSize: number) {const items: { group: string; id: string }[] = [];diff --git a/packages/core/src/utils/constants.ts b/packages/core/src/utils/constants.tsindex eb9a6352c..3802724bf 100644--- a/packages/core/src/utils/constants.ts+++ b/packages/core/src/utils/constants.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/>.*/-import { extractHostname } from "./hostname";+import { extractHostname } from "./hostname.js";const COMPATIBLE_SERVER_VERSION = 1;diff --git a/packages/core/src/utils/content-block.ts b/packages/core/src/utils/content-block.tsindex 82214aff8..d77c97c65 100644--- a/packages/core/src/utils/content-block.ts+++ b/packages/core/src/utils/content-block.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { ContentBlock } from "../types";-import { InternalLinkWithOffset, parseInternalLink } from "./internal-link";+import { ContentBlock } from "../types.js";+import { InternalLinkWithOffset, parseInternalLink } from "./internal-link.js";const INTERNAL_LINK_REGEX = /(?:\[\[(nn:\/\/note\/.+?)\]\])/gm;export function extractInternalLinks(block: ContentBlock) {diff --git a/packages/core/src/database/crypto.ts b/packages/core/src/utils/crypto.tssimilarity index 93%rename from packages/core/src/database/crypto.tsrename to packages/core/src/utils/crypto.tsindex 377377366..96b30eee4 100644--- a/packages/core/src/database/crypto.ts+++ b/packages/core/src/utils/crypto.ts@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { Cipher } from "@notesnook/crypto";-import { StorageAccessor } from "../interfaces";-import { randomBytes } from "../utils/random";+import { StorageAccessor } from "../interfaces.js";+import { randomBytes } from "./random.js";export type CryptoAccessor = () => Crypto;export class Crypto {diff --git a/packages/core/src/utils/date.ts b/packages/core/src/utils/date.tsindex 57c6afbd4..193f3da82 100644--- a/packages/core/src/utils/date.ts+++ b/packages/core/src/utils/date.ts@@ -18,8 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import dayjs from "dayjs";--export type TimeFormat = "12-hour" | "24-hour";+import { TimeFormat } from "../types.js";export function getWeekGroupFromTimestamp(timestamp: number) {const date = new Date(timestamp);diff --git a/packages/core/src/utils/event-manager.ts b/packages/core/src/utils/event-manager.tsindex d22d8d758..c1ad94fde 100644--- a/packages/core/src/utils/event-manager.ts+++ b/packages/core/src/utils/event-manager.ts@@ -28,7 +28,7 @@ export type EventProperties = {once?: boolean;};-class EventManager {+export class EventManager {public _registry: Map<EventHandler, EventProperties>;constructor() {this._registry = new Map();diff --git a/packages/core/src/utils/grouping.ts b/packages/core/src/utils/grouping.tsindex ce75608f5..b9b3bfe46 100644--- a/packages/core/src/utils/grouping.ts+++ b/packages/core/src/utils/grouping.ts@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { isReminderActive } from "../collections/reminders";-import { GroupHeader, GroupOptions, ItemType, Reminder } from "../types";-import { getWeekGroupFromTimestamp, MONTHS_FULL } from "./date";+import { isReminderActive } from "../collections/reminders.js";+import { GroupHeader, GroupOptions, ItemType, Reminder } from "../types.js";+import { getWeekGroupFromTimestamp, MONTHS_FULL } from "../utils/date.js";type PartialGroupableItem = {id: string;diff --git a/packages/core/src/utils/html-parser.ts b/packages/core/src/utils/html-parser.tsindex a29528e21..5c89cdef9 100644--- a/packages/core/src/utils/html-parser.ts+++ b/packages/core/src/utils/html-parser.ts@@ -21,10 +21,12 @@ import { decodeHTML5 } from "entities";import { Parser } from "htmlparser2";export const parseHTML = (input: string) =>- new globalThis.DOMParser().parseFromString(- wrapIntoHTMLDocument(input),- "text/html"- );+ "DOMParser" in globalThis+ ? new globalThis.DOMParser().parseFromString(+ wrapIntoHTMLDocument(input),+ "text/html"+ )+ : null;export function getDummyDocument() {const doc = parseHTML("<div></div>");diff --git a/packages/core/src/utils/http.ts b/packages/core/src/utils/http.tsindex bb2f78f17..bc4e79bef 100644--- a/packages/core/src/utils/http.ts+++ b/packages/core/src/utils/http.ts@@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { EV, EVENTS } from "../common";-import { logger } from "../logger";-import { getServerNameFromHost } from "./constants";-import { extractHostname } from "./hostname";+import { EV, EVENTS } from "../common.js";+import { logger } from "../logger.js";+import { getServerNameFromHost } from "./constants.js";+import { extractHostname } from "./hostname.js";type ContentType = "application/json" | "application/x-www-form-urlencoded";type RequestBody = Record<string, string | number | boolean | undefined> | null;diff --git a/packages/core/src/utils/id.ts b/packages/core/src/utils/id.tsindex 761210a14..ca8cec0d1 100644--- a/packages/core/src/utils/id.ts+++ b/packages/core/src/utils/id.ts@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import SparkMD5 from "spark-md5";-import { createObjectId } from "./object-id";+import { createObjectId } from "./object-id.js";export function getId(time?: number) {return createObjectId(time);diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.tsnew file mode 100644index 000000000..f88eb4ebb--- /dev/null+++ b/packages/core/src/utils/index.ts@@ -0,0 +1,43 @@+/*+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 * from "./array.js";+export * from "./clone.js";+export * from "./constants.js";+export * from "./content-block.js";+export * from "./date.js";+export * from "./event-manager.js";+export * from "./filename.js";+export * from "./grouping.js";+export * from "./has-require.js";+export * from "./hostname.js";+export * from "./html-diff.js";+export * from "./html-parser.js";+export * from "./html-rewriter.js";+export * from "./http.js";+export * from "./id.js";+export * from "./internal-link.js";+export * from "./object-id.js";+export * from "./query-transformer.js";+export * from "./queue-value.js";+export * from "./random.js";+export * from "./set.js";+export * from "./title-format.js";+export * from "./virtualized-grouping.js";+export * from "./crypto.js";diff --git a/packages/core/src/utils/object-id.ts b/packages/core/src/utils/object-id.tsindex 331834b93..a201aee6f 100644--- a/packages/core/src/utils/object-id.ts+++ b/packages/core/src/utils/object-id.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/>.*/-import { randomBytes, randomInt } from "./random";+import { randomBytes, randomInt } from "./random.js";const PROCESS_UNIQUE = randomBytes(5).toString("hex");let index = ~~(randomInt() * 0xffffff);diff --git a/packages/core/src/utils/random.ts b/packages/core/src/utils/random.tsindex 0cd8a3279..c78eaa827 100644--- a/packages/core/src/utils/random.ts+++ b/packages/core/src/utils/random.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/>.*/-import { hasRequire } from "./has-require";+import { hasRequire } from "./has-require.js";export function randomBytes(size: number): Buffer {const crypto =@@ -31,7 +31,7 @@ export function randomBytes(size: number): Buffer {"Crypto.getRandomValues is not available on this platform.");- const buffer = Buffer.allocUnsafe(size);+ const buffer = Buffer.alloc(size);crypto.getRandomValues(buffer);return buffer;}diff --git a/packages/core/src/utils/templates/html/index.ts b/packages/core/src/utils/templates/html/index.tsindex c8f116494..8f462006e 100644--- a/packages/core/src/utils/templates/html/index.ts+++ b/packages/core/src/utils/templates/html/index.ts@@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { TemplateData } from "..";-import { hasRequire } from "../../has-require";-import { parseHTML } from "../../html-parser";-import { template } from "./template";+import { TemplateData } from "../index.js";+import { parseHTML } from "../../html-parser.js";+import { hasRequire } from "../../has-require.js";+import { template } from "./template.js";const replaceableAttributes = {'data-float="true" data-align="right"': 'align="right"',diff --git a/packages/core/src/utils/templates/html/template.ts b/packages/core/src/utils/templates/html/template.tsindex ac619fbaf..6c4b75e99 100644--- a/packages/core/src/utils/templates/html/template.ts+++ b/packages/core/src/utils/templates/html/template.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { TemplateData } from "..";-import { formatDate } from "../../date";+import { TemplateData } from "../index.js";+import { formatDate } from "../../date.js";export function template(data: TemplateData) {return `<!DOCTYPE html>diff --git a/packages/core/src/utils/templates/index.ts b/packages/core/src/utils/templates/index.tsindex d48355ca9..ec177df03 100644--- a/packages/core/src/utils/templates/index.ts+++ b/packages/core/src/utils/templates/index.ts@@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { Note } from "../../types";-import { buildHTML } from "./html";-import { buildMarkdown, templateWithFrontmatter } from "./md";-import { buildText } from "./text";+import { Note } from "../../types.js";+import { buildHTML } from "./html/index.js";+import { buildMarkdown, templateWithFrontmatter } from "./md.js";+import { buildText } from "./text.js";export type TemplateData = Omit<Note, "tags" | "color"> & {tags?: string[];diff --git a/packages/core/src/utils/templates/md.ts b/packages/core/src/utils/templates/md.tsindex 1d9d665bf..7bc1f52c0 100644--- a/packages/core/src/utils/templates/md.ts+++ b/packages/core/src/utils/templates/md.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { TemplateData } from ".";-import { formatDate } from "../date";+import { TemplateData } from "./index.js";+import { formatDate } from "../date.js";export const buildMarkdown = (data: TemplateData) => `# ${data.title}diff --git a/packages/core/src/utils/templates/text.ts b/packages/core/src/utils/templates/text.tsindex 517c8b417..0ba100bd1 100644--- a/packages/core/src/utils/templates/text.ts+++ b/packages/core/src/utils/templates/text.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/>.*/-import { TemplateData } from ".";+import { TemplateData } from "./index.js";export function buildText(data: TemplateData) {return `${data.title}diff --git a/packages/core/src/utils/title-format.ts b/packages/core/src/utils/title-format.tsindex adab9a23d..81045b902 100644--- a/packages/core/src/utils/title-format.ts+++ b/packages/core/src/utils/title-format.ts@@ -17,7 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { TimeFormat, formatDate } from "./date";+import { TimeFormat } from "../types.js";+import { formatDate } from "./date.js";export const NEWLINE_STRIP_REGEX = /[\r\n\t\v]+/gm;diff --git a/packages/core/src/utils/virtualized-grouping.ts b/packages/core/src/utils/virtualized-grouping.tsindex 9ff1311ce..ac3caf81b 100644--- a/packages/core/src/utils/virtualized-grouping.ts+++ b/packages/core/src/utils/virtualized-grouping.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/>.*/-import { GroupHeader } from "../types";+import { GroupHeader } from "../types.js";type BatchOperator<T> = (ids: string[], items: T[]) => Promise<unknown[]>;type Batch<T> = {