global: fix type errors during build

This commit is contained in:
Ammar Ahmed
2024-02-03 12:35:28 +05:00
committed by Abdullah Atta
parent 2bb3652be2
commit 4e157455c8
8 changed files with 490 additions and 416 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -236,7 +236,10 @@ class Database {
await sql.raw(statement).execute(this.sql());
}
await this.sql().destroy();
this._sql = await createDatabase("notesnook", this.options.sqliteOptions);
this._sql = (await createDatabase(
"notesnook",
this.options.sqliteOptions
)) as unknown as Kysely<DatabaseSchema>;
}
async init() {
@@ -251,8 +254,8 @@ class Database {
this
);
EV.subscribe(EVENTS.attachmentDeleted, async (attachment: Attachment) => {
await this.fs().cancel(attachment.hash, "upload");
await this.fs().cancel(attachment.hash, "download");
await this.fs().cancel(attachment.hash);
await this.fs().cancel(attachment.hash);
});
EV.subscribe(EVENTS.userLoggedOut, async () => {
await this.monographs.clear();
@@ -260,7 +263,10 @@ class Database {
this.disconnectSSE();
});
this._sql = await createDatabase("notesnook", this.options.sqliteOptions);
this._sql = (await createDatabase(
"notesnook",
this.options.sqliteOptions
)) as unknown as Kysely<DatabaseSchema>;
await this._validate();

View File

@@ -212,10 +212,6 @@ export default class Vault {
return !!vaultKey && isCipher(vaultKey);
}
get unlocked() {
return !!this.vaultPassword;
}
// Private & internal methods
private async getVaultPassword() {

View File

@@ -182,7 +182,7 @@ export class Tiptap {
for (const image of sources) {
try {
const { data, mimeType } = dataurl.toObject(image.src);
if (!data) continue;
if (!data || !mimeType) continue;
const hash = await store(data, mimeType, image.filename);
if (!hash) continue;

View File

@@ -19,18 +19,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { parse, validate } from "@readme/data-urls";
function toObject(dataurl: string): { mime?: string; data?: string } {
function toObject(dataurl: string): { mimeType?: string; data?: string } {
const result = parse(dataurl);
if (!result) return {};
return {
mime: result.contentType,
mimeType: result.contentType,
data: result.data
};
}
function fromObject({ type, data }: { type: string; data: string }) {
function fromObject({ mimeType, data }: { mimeType: string; data: string }) {
if (validate(data)) return data;
return `data:${type};base64,${data}`;
return `data:${mimeType};base64,${data}`;
}
function isValid(url: string) {

View File

@@ -138,7 +138,7 @@ export function useEditorController(update: () => void): EditorController {
}, [colors]);
const contentChange = useCallback(
(editor: Editor, ignoreEdit) => {
(editor: Editor, ignoreEdit?: boolean) => {
const currentSessionId = globalThis.sessionId;
post(EventTypes.contentchange);
if (!editor) return;

View File

@@ -973,6 +973,22 @@
"@styled-system/css": "^5.1.5"
}
},
"node_modules/@theme-ui/color-modes": {
"version": "0.16.1",
"resolved": "https://registry.npmjs.org/@theme-ui/color-modes/-/color-modes-0.16.1.tgz",
"integrity": "sha512-G2YoNEMwZroRS0DcftUG+E/8WM5/Osf8TRrQLLK+L43HJ4BmaWuBmVeyoNOaPBDlAuqMBx2203VRgoPmUaMqOg==",
"dev": true,
"peer": true,
"dependencies": {
"@theme-ui/core": "^0.16.1",
"@theme-ui/css": "^0.16.1",
"deepmerge": "^4.2.2"
},
"peerDependencies": {
"@emotion/react": "^11.11.1",
"react": ">=18"
}
},
"node_modules/@theme-ui/components": {
"version": "0.16.1",
"resolved": "https://registry.npmjs.org/@theme-ui/components/-/components-0.16.1.tgz",
@@ -1018,6 +1034,22 @@
"@emotion/react": "^11.11.1"
}
},
"node_modules/@theme-ui/theme-provider": {
"version": "0.16.1",
"resolved": "https://registry.npmjs.org/@theme-ui/theme-provider/-/theme-provider-0.16.1.tgz",
"integrity": "sha512-+/3BJYLIOC2DwTS76cqNhigRQJJ+qOT845DYF7t3TaG2fXDfgh16/DGZSnVjGOGc9dYE3C/ZFAYcVDVwO94Guw==",
"dev": true,
"peer": true,
"dependencies": {
"@theme-ui/color-modes": "^0.16.1",
"@theme-ui/core": "^0.16.1",
"@theme-ui/css": "^0.16.1"
},
"peerDependencies": {
"@emotion/react": "^11.11.1",
"react": ">=18"
}
},
"node_modules/@tiptap/core": {
"version": "2.1.12",
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.1.12.tgz",
@@ -2508,8 +2540,7 @@
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"node_modules/json-parse-even-better-errors": {
"version": "2.3.1",
@@ -2573,7 +2604,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"dev": true,
"dependencies": {
"js-tokens": "^3.0.0 || ^4.0.0"
},
@@ -3149,7 +3179,6 @@
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
"integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
"dev": true,
"dependencies": {
"loose-envify": "^1.1.0"
},
@@ -3170,7 +3199,6 @@
"version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
"integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
"dev": true,
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.0"
@@ -3302,7 +3330,6 @@
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
"integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
"dev": true,
"dependencies": {
"loose-envify": "^1.1.0"
}

View File

@@ -126,7 +126,7 @@ export function toBlobURL(
if (!DataURL.isValid(dataurl)) return;
const dataurlObject = DataURL.toObject(dataurl);
let mime = dataurlObject.mime || "";
let mime = dataurlObject.mimeType || "";
const data = dataurlObject.data;
if (!data) return;