common: make imports esm compatible

This commit is contained in:
Abdullah Atta
2024-09-23 15:11:34 +05:00
parent 7f31066e8f
commit 1fb86cb27b
13 changed files with 76 additions and 40 deletions

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { describe, test } from "vitest"; import { describe, test } from "vitest";
import { PathTree } from "../src/utils/path-tree"; import { PathTree } from "../src/utils/path-tree.js";
test("adding duplicate path should make it unique", (t) => { test("adding duplicate path should make it unique", (t) => {
const tree = new PathTree(); const tree = new PathTree();

View File

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
export * from "./resolved-item"; export * from "./resolved-item.js";

View File

@@ -21,7 +21,7 @@ import { ItemMap, ItemType } from "@notesnook/core";
import { import {
ResolvedItemOptions, ResolvedItemOptions,
useResolvedItem useResolvedItem
} from "../hooks/use-resolved-item"; } from "../hooks/use-resolved-item.js";
type ResolvedItemProps<TItemType extends ItemType> = type ResolvedItemProps<TItemType extends ItemType> =
ResolvedItemOptions<TItemType> & { ResolvedItemOptions<TItemType> & {

View File

@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import Database from "@notesnook/core/dist/api/index"; import { Database } from "@notesnook/core";
export const database = new Database(); export const database = new Database();

View File

@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
export * from "./use-time-ago"; export * from "./use-time-ago.js";
export * from "./use-promise"; export * from "./use-promise.js";
export * from "./use-resolved-item"; export * from "./use-resolved-item.js";

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { ItemMap, ItemType, VirtualizedGrouping } from "@notesnook/core"; import { ItemMap, ItemType, VirtualizedGrouping } from "@notesnook/core";
import { resolveItems } from "../utils/resolve-items"; import { resolveItems } from "../utils/resolve-items.js";
import { useDeferredValue, useEffect, useState, useTransition } from "react"; import { useDeferredValue, useEffect, useState, useTransition } from "react";
export type ResolvedItemOptions<TItemType extends ItemType> = { export type ResolvedItemOptions<TItemType extends ItemType> = {

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
export * from "./database"; export * from "./database.js";
export * from "./utils"; export * from "./utils/index.js";
export * from "./hooks"; export * from "./hooks/index.js";
export * from "./components"; export * from "./components/index.js";

View File

@@ -0,0 +1,20 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export { DataURL } from "@notesnook/core";

View File

@@ -17,14 +17,15 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { database } from "../database.js";
import { import {
FormatDateOptions,
TimeFormat, TimeFormat,
formatReminderTime,
HistorySession,
Reminder,
FormatDateOptions,
formatDate formatDate
} from "@notesnook/core/dist/utils/date"; } from "@notesnook/core";
import { database } from "../database";
import { formatReminderTime } from "@notesnook/core/dist/collections/reminders";
import { HistorySession, Reminder } from "@notesnook/core/dist/types";
export function getFormattedDate( export function getFormattedDate(
date: string | number | Date, date: string | number | Date,
@@ -53,3 +54,5 @@ export function getFormattedHistorySessionDate(session: HistorySession) {
fromDate !== toDate ? `${toDate}, ` : "" fromDate !== toDate ? `${toDate}, ` : ""
}${toTime}`; }${toTime}`;
} }
export { formatDate };

View File

@@ -17,17 +17,23 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { Attachment, Note, parseInternalLink } from "@notesnook/core"; import {
import { FilteredSelector } from "@notesnook/core/dist/database/sql-collection"; Attachment,
import { CHECK_IDS, checkIsUserPremium } from "@notesnook/core/dist/common"; Note,
import { isImage, isWebClip } from "@notesnook/core/dist/utils/filename"; parseInternalLink,
import { sanitizeFilename } from "./file"; getContentFromData,
import { database } from "../database"; ResolveInternalLink,
isImage,
isWebClip,
CHECK_IDS,
checkIsUserPremium,
FilteredSelector,
EMPTY_CONTENT
} from "@notesnook/core";
import { sanitizeFilename } from "./file.js";
import { database } from "../database.js";
import { join, relative } from "pathe"; import { join, relative } from "pathe";
import { EMPTY_CONTENT } from "@notesnook/core/dist/collections/content"; import { PathTree } from "./path-tree.js";
import { getContentFromData } from "@notesnook/core/dist/content-types";
import { PathTree } from "./path-tree";
import { ResolveInternalLink } from "@notesnook/core/dist/content-types/tiptap";
const FORMAT_TO_EXT = { const FORMAT_TO_EXT = {
pdf: "pdf", pdf: "pdf",

View File

@@ -17,12 +17,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
export * from "./file"; export * from "./file.js";
export * from "./number"; export * from "./number.js";
export * from "./time"; export * from "./date-time.js";
export * from "./debounce"; export * from "./debounce.js";
export * from "./random"; export * from "./random.js";
export * from "./string"; export * from "./string.js";
export * from "./resolve-items"; export * from "./resolve-items.js";
export * from "./migrate-toolbar"; export * from "./migrate-toolbar.js";
export * from "./export-notes"; export * from "./export-notes.js";
export * from "./dataurl.js";

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { ToolbarConfig, ToolbarConfigPlatforms } from "@notesnook/core"; import { ToolbarConfig, ToolbarConfigPlatforms } from "@notesnook/core";
import { database } from "../database"; import { database } from "../database.js";
export const CURRENT_TOOLBAR_VERSION = 2; export const CURRENT_TOOLBAR_VERSION = 2;
export async function migrateToolbar( export async function migrateToolbar(

View File

@@ -17,9 +17,15 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { Color, Item, Reminder, Notebook, Tag } from "@notesnook/core"; import {
import { database as db } from "../database"; Color,
import { getUpcomingReminder } from "@notesnook/core/dist/collections/reminders"; Item,
Reminder,
Notebook,
Tag,
getUpcomingReminder
} from "@notesnook/core";
import { database as db } from "../database.js";
type WithDateEdited<T> = { items: T[]; dateEdited: number }; type WithDateEdited<T> = { items: T[]; dateEdited: number };
export type NotebooksWithDateEdited = WithDateEdited<Notebook>; export type NotebooksWithDateEdited = WithDateEdited<Notebook>;