diff --git a/packages/core/__benches__/notes.bench.ts b/packages/core/__benches__/notes.bench.ts new file mode 100644 index 000000000..64535f3e7 --- /dev/null +++ b/packages/core/__benches__/notes.bench.ts @@ -0,0 +1,69 @@ +/* +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 . +*/ + +import { bench, describe } from "vitest"; +import { databaseTest } from "../__tests__/utils"; +import Database from "../src/api"; + +async function addNotes(db: Database) { + const titles = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split( + "" + ); + for (let i = 0; i < 40000; ++i) { + await db.notes.add({ + title: `${titles[getRandom(0, titles.length)]} Some other title of mine` + }); + if (i % 100 === 0) console.log(i); + } + console.log("DONE"); +} + +describe("notes", async () => { + const db = await databaseTest(); + + bench("get grouping", async () => { + await db.notes.all.grouped({ + groupBy: "abc", + sortBy: "title", + sortDirection: "asc" + }); + }); + + const grouping = await db.notes.all.grouped({ + groupBy: "abc", + sortBy: "title", + sortDirection: "asc" + }); + + bench("get items in adjacent batches (sequential access)", async function () { + await grouping.item(30000); + await grouping.item(30000 + 500 + 1); + await grouping.item(30000 + 500 + 500 + 1); + await grouping.item(30000 + 500 + 500 + 500 + 1); + await grouping.item(30000 + 500 + 500 + 500 + 500 + 1); + }); + + bench("get item from random batches (random access)", async () => { + await grouping.item(getRandom(0, 40000)); + }); +}); + +function getRandom(min: number, max: number) { + return Math.round(Math.random() * (max - min) + min); +} diff --git a/packages/core/__tests__/utils/index.ts b/packages/core/__tests__/utils/index.ts index c4ae0bf05..5bfeecfb6 100644 --- a/packages/core/__tests__/utils/index.ts +++ b/packages/core/__tests__/utils/index.ts @@ -48,7 +48,9 @@ function databaseTest() { eventsource: EventSource, fs: FS, compressor: Compressor, - dialect: new SqliteDialect({ database: BetterSQLite3(":memory:") }) + sqliteOptions: { + dialect: new SqliteDialect({ database: BetterSQLite3("db.sql") }) + } }); return db.init().then(() => db); } diff --git a/packages/core/package-lock.json b/packages/core/package-lock.json index 6d0d6a919..b126da80b 100644 --- a/packages/core/package-lock.json +++ b/packages/core/package-lock.json @@ -42,7 +42,7 @@ "@types/spark-md5": "^3.0.2", "@types/streetwriters__showdown": "npm:@types/showdown@^2.0.6", "@types/ws": "^8.5.5", - "@vitest/coverage-v8": "^0.34.1", + "@vitest/coverage-v8": "^1.0.1", "abortcontroller-polyfill": "^1.7.3", "better-sqlite3": "^8.6.0", "bson-objectid": "^2.0.4", @@ -57,7 +57,7 @@ "nanoid": "^5.0.1", "otplib": "^12.0.1", "refractor": "^4.8.1", - "vitest": "^0.34.1", + "vitest": "^1.0.1", "vitest-fetch-mock": "^0.2.2", "ws": "^8.13.0" } @@ -1452,18 +1452,415 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/helper-string-parser": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.9.tgz", + "integrity": "sha512-9tcKgqKbs3xGJ+NtKF2ndOBBLVwPjl1SHxPQkd36r3Dlirw3xWUeGaTbqr7uGZcTaxkVNwc+03SVP7aCdWrTlA==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.9.tgz", + "integrity": "sha512-dQjSq/7HaSjRM43FFGnv5keM2HsxpmyV1PfaSVm0nzzjwwTmjOe6J4bC8e3+pTEIgHaHj+1ZlLThRJ2auc/w1Q==", + "dev": true, + "dependencies": { + "@babel/helper-string-parser": "^7.23.4", + "@babel/helper-validator-identifier": "^7.22.20", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@bcoe/v8-coverage": { "version": "0.2.3", "dev": true, "license": "MIT" }, - "node_modules/@esbuild/win32-x64": { - "version": "0.18.20", + "node_modules/@esbuild/aix-ppc64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz", + "integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz", + "integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz", + "integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz", + "integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz", + "integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz", + "integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz", + "integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz", + "integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz", + "integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz", + "integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz", + "integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz", + "integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz", + "integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz", + "integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz", + "integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz", + "integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz", + "integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz", + "integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz", + "integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz", + "integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz", + "integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz", + "integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz", + "integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==", "cpu": [ "x64" ], "dev": true, - "license": "MIT", "optional": true, "os": [ "win32" @@ -1480,6 +1877,18 @@ "node": ">=8" } }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "dev": true, @@ -1630,6 +2039,175 @@ "node": ">=18" } }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.6.tgz", + "integrity": "sha512-MVNXSSYN6QXOulbHpLMKYi60ppyO13W9my1qogeiAqtjb2yR4LSmfU2+POvDkLzhjYLXz9Rf9+9a3zFHW1Lecg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.6.tgz", + "integrity": "sha512-T14aNLpqJ5wzKNf5jEDpv5zgyIqcpn1MlwCrUXLrwoADr2RkWA0vOWP4XxbO9aiO3dvMCQICZdKeDrFl7UMClw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.6.tgz", + "integrity": "sha512-CqNNAyhRkTbo8VVZ5R85X73H3R5NX9ONnKbXuHisGWC0qRbTTxnF1U4V9NafzJbgGM0sHZpdO83pLPzq8uOZFw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.6.tgz", + "integrity": "sha512-zRDtdJuRvA1dc9Mp6BWYqAsU5oeLixdfUvkTHuiYOHwqYuQ4YgSmi6+/lPvSsqc/I0Omw3DdICx4Tfacdzmhog==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.6.tgz", + "integrity": "sha512-oNk8YXDDnNyG4qlNb6is1ojTOGL/tRhbbKeE/YuccItzerEZT68Z9gHrY3ROh7axDc974+zYAPxK5SH0j/G+QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.6.tgz", + "integrity": "sha512-Z3O60yxPtuCYobrtzjo0wlmvDdx2qZfeAWTyfOjEDqd08kthDKexLpV97KfAeUXPosENKd8uyJMRDfFMxcYkDQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.6.tgz", + "integrity": "sha512-gpiG0qQJNdYEVad+1iAsGAbgAnZ8j07FapmnIAQgODKcOTjLEWM9sRb+MbQyVsYCnA0Im6M6QIq6ax7liws6eQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.6.tgz", + "integrity": "sha512-+uCOcvVmFUYvVDr27aiyun9WgZk0tXe7ThuzoUTAukZJOwS5MrGbmSlNOhx1j80GdpqbOty05XqSl5w4dQvcOA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.6.tgz", + "integrity": "sha512-HUNqM32dGzfBKuaDUBqFB7tP6VMN74eLZ33Q9Y1TBqRDn+qDonkAUyKWwF9BR9unV7QUzffLnz9GrnKvMqC/fw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.6.tgz", + "integrity": "sha512-ch7M+9Tr5R4FK40FHQk8VnML0Szi2KRujUgHXd/HjuH9ifH72GUmw6lStZBo3c3GB82vHa0ZoUfjfcM7JiiMrQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.6.tgz", + "integrity": "sha512-VD6qnR99dhmTQ1mJhIzXsRcTBvTjbfbGGwKAHcu+52cVl15AC/kplkhxzW/uT0Xl62Y/meBKDZvoJSJN+vTeGA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.6.tgz", + "integrity": "sha512-J9AFDq/xiRI58eR2NIDfyVmTYGyIZmRcvcAoJ48oDld/NTR8wyiPUu2X/v1navJ+N/FGg68LEbX3Ejd6l8B7MQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.6.tgz", + "integrity": "sha512-jqzNLhNDvIZOrt69Ce4UjGRpXJBzhUBzawMwnaDAwyHriki3XollsewxWzOzz+4yOFDkuJHtTsZFwMxhYJWmLQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@selderee/plugin-htmlparser2": { "version": "0.11.0", "license": "MIT", @@ -1641,6 +2219,12 @@ "url": "https://ko-fi.com/killymxi" } }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true + }, "node_modules/@streetwriters/showdown": { "version": "3.0.4-alpha", "license": "MIT", @@ -1669,18 +2253,11 @@ "@types/node": "*" } }, - "node_modules/@types/chai": { - "version": "4.3.5", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/chai-subset": { - "version": "1.3.3", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/chai": "*" - } + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true }, "node_modules/@types/event-source-polyfill": { "version": "1.0.5", @@ -1701,9 +2278,10 @@ "license": "MIT" }, "node_modules/@types/istanbul-lib-coverage": { - "version": "2.0.4", - "dev": true, - "license": "MIT" + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true }, "node_modules/@types/katex": { "version": "0.16.7", @@ -1751,205 +2329,101 @@ } }, "node_modules/@vitest/coverage-v8": { - "version": "0.34.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-1.2.2.tgz", + "integrity": "sha512-IHyKnDz18SFclIEEAHb9Y4Uxx0sPKC2VO1kdDCs1BF6Ip4S8rQprs971zIsooLUn7Afs71GRxWMWpkCGZpRMhw==", "dev": true, - "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.1", "@bcoe/v8-coverage": "^0.2.3", - "istanbul-lib-coverage": "^3.2.0", + "debug": "^4.3.4", + "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-report": "^3.0.1", "istanbul-lib-source-maps": "^4.0.1", - "istanbul-reports": "^3.1.5", - "magic-string": "^0.30.1", + "istanbul-reports": "^3.1.6", + "magic-string": "^0.30.5", + "magicast": "^0.3.3", "picocolors": "^1.0.0", - "std-env": "^3.3.3", + "std-env": "^3.5.0", "test-exclude": "^6.0.0", - "v8-to-istanbul": "^9.1.0" + "v8-to-istanbul": "^9.2.0" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "vitest": ">=0.32.0 <1" + "vitest": "^1.0.0" } }, "node_modules/@vitest/expect": { - "version": "0.34.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-1.2.2.tgz", + "integrity": "sha512-3jpcdPAD7LwHUUiT2pZTj2U82I2Tcgg2oVPvKxhn6mDI2On6tfvPQTjAI4628GUGDZrCm4Zna9iQHm5cEexOAg==", "dev": true, - "license": "MIT", "dependencies": { - "@vitest/spy": "0.34.1", - "@vitest/utils": "0.34.1", - "chai": "^4.3.7" + "@vitest/spy": "1.2.2", + "@vitest/utils": "1.2.2", + "chai": "^4.3.10" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/runner": { - "version": "0.34.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-1.2.2.tgz", + "integrity": "sha512-JctG7QZ4LSDXr5CsUweFgcpEvrcxOV1Gft7uHrvkQ+fsAVylmWQvnaAr/HDp3LAH1fztGMQZugIheTWjaGzYIg==", "dev": true, - "license": "MIT", "dependencies": { - "@vitest/utils": "0.34.1", - "p-limit": "^4.0.0", + "@vitest/utils": "1.2.2", + "p-limit": "^5.0.0", "pathe": "^1.1.1" }, "funding": { "url": "https://opencollective.com/vitest" } }, - "node_modules/@vitest/runner/node_modules/p-limit": { - "version": "4.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "yocto-queue": "^1.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@vitest/runner/node_modules/yocto-queue": { - "version": "1.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@vitest/snapshot": { - "version": "0.34.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-1.2.2.tgz", + "integrity": "sha512-SmGY4saEw1+bwE1th6S/cZmPxz/Q4JWsl7LvbQIky2tKE35US4gd0Mjzqfr84/4OD0tikGWaWdMja/nWL5NIPA==", "dev": true, - "license": "MIT", "dependencies": { - "magic-string": "^0.30.1", + "magic-string": "^0.30.5", "pathe": "^1.1.1", - "pretty-format": "^29.5.0" + "pretty-format": "^29.7.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, - "node_modules/@vitest/snapshot/node_modules/@jest/schemas": { - "version": "29.6.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@sinclair/typebox": "^0.27.8" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@vitest/snapshot/node_modules/@sinclair/typebox": { - "version": "0.27.8", - "dev": true, - "license": "MIT" - }, - "node_modules/@vitest/snapshot/node_modules/ansi-styles": { - "version": "5.2.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@vitest/snapshot/node_modules/pretty-format": { - "version": "29.6.2", - "dev": true, - "license": "MIT", - "dependencies": { - "@jest/schemas": "^29.6.0", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, "node_modules/@vitest/spy": { - "version": "0.34.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-1.2.2.tgz", + "integrity": "sha512-k9Gcahssw8d7X3pSLq3e3XEu/0L78mUkCjivUqCQeXJm9clfXR/Td8+AP+VC1O6fKPIDLcHDTAmBOINVuv6+7g==", "dev": true, - "license": "MIT", "dependencies": { - "tinyspy": "^2.1.1" + "tinyspy": "^2.2.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/utils": { - "version": "0.34.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-1.2.2.tgz", + "integrity": "sha512-WKITBHLsBHlpjnDQahr+XK6RE7MiAsgrIkr0pGhQ9ygoxBfUeG0lUG5iLlzqjmKSlBv3+j5EGsriBzh+C3Tq9g==", "dev": true, - "license": "MIT", "dependencies": { - "diff-sequences": "^29.4.3", - "loupe": "^2.3.6", - "pretty-format": "^29.5.0" + "diff-sequences": "^29.6.3", + "estree-walker": "^3.0.3", + "loupe": "^2.3.7", + "pretty-format": "^29.7.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, - "node_modules/@vitest/utils/node_modules/@jest/schemas": { - "version": "29.6.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@sinclair/typebox": "^0.27.8" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@vitest/utils/node_modules/@sinclair/typebox": { - "version": "0.27.8", - "dev": true, - "license": "MIT" - }, - "node_modules/@vitest/utils/node_modules/ansi-styles": { - "version": "5.2.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@vitest/utils/node_modules/diff-sequences": { - "version": "29.4.3", - "dev": true, - "license": "MIT", - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@vitest/utils/node_modules/pretty-format": { - "version": "29.6.2", - "dev": true, - "license": "MIT", - "dependencies": { - "@jest/schemas": "^29.6.0", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, "node_modules/abab": { "version": "2.0.6", "dev": true, @@ -1971,9 +2445,10 @@ "license": "MIT" }, "node_modules/acorn": { - "version": "8.10.0", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, - "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -1982,9 +2457,10 @@ } }, "node_modules/acorn-walk": { - "version": "8.2.0", + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", "dev": true, - "license": "MIT", "engines": { "node": ">=0.4.0" } @@ -2000,10 +2476,23 @@ "node": ">= 6.0.0" } }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/assertion-error": { "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true, - "license": "MIT", "engines": { "node": "*" } @@ -2121,24 +2610,26 @@ }, "node_modules/cac": { "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/chai": { - "version": "4.3.7", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", + "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==", "dev": true, - "license": "MIT", "dependencies": { "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^4.1.2", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", "pathval": "^1.1.1", - "type-detect": "^4.0.5" + "type-detect": "^4.0.8" }, "engines": { "node": ">=4" @@ -2172,9 +2663,13 @@ } }, "node_modules/check-error": { - "version": "1.0.2", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", "dev": true, - "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.2" + }, "engines": { "node": "*" } @@ -2211,9 +2706,10 @@ "license": "MIT" }, "node_modules/convert-source-map": { - "version": "1.9.0", - "dev": true, - "license": "MIT" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true }, "node_modules/cross-env": { "version": "7.0.3", @@ -2346,8 +2842,9 @@ }, "node_modules/deep-eql": { "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", "dev": true, - "license": "MIT", "dependencies": { "type-detect": "^4.0.0" }, @@ -2388,6 +2885,15 @@ "node": ">=8" } }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/discontinuous-range": { "version": "1.0.0", "license": "MIT" @@ -2478,10 +2984,11 @@ } }, "node_modules/esbuild": { - "version": "0.18.20", + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz", + "integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==", "dev": true, "hasInstallScript": true, - "license": "MIT", "bin": { "esbuild": "bin/esbuild" }, @@ -2489,28 +2996,38 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/android-arm": "0.18.20", - "@esbuild/android-arm64": "0.18.20", - "@esbuild/android-x64": "0.18.20", - "@esbuild/darwin-arm64": "0.18.20", - "@esbuild/darwin-x64": "0.18.20", - "@esbuild/freebsd-arm64": "0.18.20", - "@esbuild/freebsd-x64": "0.18.20", - "@esbuild/linux-arm": "0.18.20", - "@esbuild/linux-arm64": "0.18.20", - "@esbuild/linux-ia32": "0.18.20", - "@esbuild/linux-loong64": "0.18.20", - "@esbuild/linux-mips64el": "0.18.20", - "@esbuild/linux-ppc64": "0.18.20", - "@esbuild/linux-riscv64": "0.18.20", - "@esbuild/linux-s390x": "0.18.20", - "@esbuild/linux-x64": "0.18.20", - "@esbuild/netbsd-x64": "0.18.20", - "@esbuild/openbsd-x64": "0.18.20", - "@esbuild/sunos-x64": "0.18.20", - "@esbuild/win32-arm64": "0.18.20", - "@esbuild/win32-ia32": "0.18.20", - "@esbuild/win32-x64": "0.18.20" + "@esbuild/aix-ppc64": "0.19.12", + "@esbuild/android-arm": "0.19.12", + "@esbuild/android-arm64": "0.19.12", + "@esbuild/android-x64": "0.19.12", + "@esbuild/darwin-arm64": "0.19.12", + "@esbuild/darwin-x64": "0.19.12", + "@esbuild/freebsd-arm64": "0.19.12", + "@esbuild/freebsd-x64": "0.19.12", + "@esbuild/linux-arm": "0.19.12", + "@esbuild/linux-arm64": "0.19.12", + "@esbuild/linux-ia32": "0.19.12", + "@esbuild/linux-loong64": "0.19.12", + "@esbuild/linux-mips64el": "0.19.12", + "@esbuild/linux-ppc64": "0.19.12", + "@esbuild/linux-riscv64": "0.19.12", + "@esbuild/linux-s390x": "0.19.12", + "@esbuild/linux-x64": "0.19.12", + "@esbuild/netbsd-x64": "0.19.12", + "@esbuild/openbsd-x64": "0.19.12", + "@esbuild/sunos-x64": "0.19.12", + "@esbuild/win32-arm64": "0.19.12", + "@esbuild/win32-ia32": "0.19.12", + "@esbuild/win32-x64": "0.19.12" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0" } }, "node_modules/event-source-polyfill": { @@ -2532,6 +3049,29 @@ "node": ">=12.0.0" } }, + "node_modules/execa": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, "node_modules/expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", @@ -2579,6 +3119,20 @@ "dev": true, "license": "ISC" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/fuzzyjs": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/fuzzyjs/-/fuzzyjs-5.0.1.tgz", @@ -2588,13 +3142,26 @@ } }, "node_modules/get-func-name": { - "version": "2.0.0", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", "dev": true, - "license": "MIT", "engines": { "node": "*" } }, + "node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/github-from-package": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", @@ -2733,6 +3300,15 @@ "node": ">= 6" } }, + "node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "dev": true, + "engines": { + "node": ">=16.17.0" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "dev": true, @@ -2829,6 +3405,18 @@ "dev": true, "license": "MIT" }, + "node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/isexe": { "version": "2.0.0", "dev": true, @@ -2844,9 +3432,10 @@ } }, "node_modules/istanbul-lib-coverage": { - "version": "3.2.0", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", "dev": true, - "license": "BSD-3-Clause", "engines": { "node": ">=8" } @@ -2964,9 +3553,10 @@ } }, "node_modules/jsonc-parser": { - "version": "3.2.0", - "dev": true, - "license": "MIT" + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz", + "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==", + "dev": true }, "node_modules/katex": { "version": "0.16.2", @@ -3031,9 +3621,14 @@ } }, "node_modules/local-pkg": { - "version": "0.4.3", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.0.tgz", + "integrity": "sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==", "dev": true, - "license": "MIT", + "dependencies": { + "mlly": "^1.4.2", + "pkg-types": "^1.0.3" + }, "engines": { "node": ">=14" }, @@ -3042,11 +3637,12 @@ } }, "node_modules/loupe": { - "version": "2.3.6", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", "dev": true, - "license": "MIT", "dependencies": { - "get-func-name": "^2.0.0" + "get-func-name": "^2.0.1" } }, "node_modules/lru-cache": { @@ -3061,9 +3657,10 @@ } }, "node_modules/magic-string": { - "version": "0.30.2", + "version": "0.30.6", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.6.tgz", + "integrity": "sha512-n62qCLbPjNjyo+owKtveQxZFZTBm+Ms6YoGD23Wew6Vw337PElFNifQpknPruVRQV57kVShPnLGo9vWxVhpPvA==", "dev": true, - "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" }, @@ -3071,6 +3668,17 @@ "node": ">=12" } }, + "node_modules/magicast": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.3.3.tgz", + "integrity": "sha512-ZbrP1Qxnpoes8sz47AM0z08U+jW6TyRgZzcWy3Ma3vDhJttwMwAFDMMQFobwdBxByBD46JYmxRzeF7w2+wJEuw==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.23.6", + "@babel/types": "^7.23.6", + "source-map-js": "^1.0.2" + } + }, "node_modules/make-dir": { "version": "4.0.0", "dev": true, @@ -3085,6 +3693,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, "node_modules/mime-db": { "version": "1.52.0", "license": "MIT", @@ -3103,6 +3717,18 @@ "node": ">= 0.6" } }, + "node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/mimic-response": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", @@ -3142,14 +3768,15 @@ "dev": true }, "node_modules/mlly": { - "version": "1.4.0", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.5.0.tgz", + "integrity": "sha512-NPVQvAY1xr1QoVeG0cy8yUYC7FQcOx6evl/RjT1wL5FvzPnzOysoqB/jmx/DhssT2dYa8nxECLAaFI/+gVLhDQ==", "dev": true, - "license": "MIT", "dependencies": { - "acorn": "^8.9.0", - "pathe": "^1.1.1", + "acorn": "^8.11.3", + "pathe": "^1.1.2", "pkg-types": "^1.0.3", - "ufo": "^1.1.2" + "ufo": "^1.3.2" } }, "node_modules/mockdate": { @@ -3260,6 +3887,33 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/npm-run-path": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.2.0.tgz", + "integrity": "sha512-W4/tgAXFqFA0iL7fk0+uQ3g7wkL8xJmx3XdK0VGb4cHW//eZTtKGvFBBoRKVTpY7n6ze4NL9ly7rgXcHufqXKg==", + "dev": true, + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npm-run-path/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/nth-check": { "version": "2.1.1", "license": "BSD-2-Clause", @@ -3283,6 +3937,21 @@ "wrappy": "1" } }, + "node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/otplib": { "version": "12.0.1", "dev": true, @@ -3293,6 +3962,21 @@ "@otplib/preset-v11": "^12.0.1" } }, + "node_modules/p-limit": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-5.0.0.tgz", + "integrity": "sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/parse-entities": { "version": "4.0.1", "dev": true, @@ -3351,14 +4035,16 @@ } }, "node_modules/pathe": { - "version": "1.1.1", - "dev": true, - "license": "MIT" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "dev": true }, "node_modules/pathval": { "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "dev": true, - "license": "MIT", "engines": { "node": "*" } @@ -3377,8 +4063,9 @@ }, "node_modules/pkg-types": { "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", "dev": true, - "license": "MIT", "dependencies": { "jsonc-parser": "^3.2.0", "mlly": "^1.2.0", @@ -3386,7 +4073,9 @@ } }, "node_modules/postcss": { - "version": "8.4.27", + "version": "8.4.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", + "integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", "dev": true, "funding": [ { @@ -3402,9 +4091,8 @@ "url": "https://github.com/sponsors/ai" } ], - "license": "MIT", "dependencies": { - "nanoid": "^3.3.6", + "nanoid": "^3.3.7", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, @@ -3456,6 +4144,20 @@ "node": ">=10" } }, + "node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/prismjs": { "version": "1.29.0", "license": "MIT", @@ -3533,8 +4235,9 @@ }, "node_modules/react-is": { "version": "18.2.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true }, "node_modules/readable-stream": { "version": "3.6.2", @@ -3581,17 +4284,34 @@ "license": "MIT" }, "node_modules/rollup": { - "version": "3.28.0", + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.9.6.tgz", + "integrity": "sha512-05lzkCS2uASX0CiLFybYfVkwNbKZG5NFQ6Go0VWyogFTXXbR039UVsegViTntkk4OglHBdF54ccApXRRuXRbsg==", "dev": true, - "license": "MIT", + "dependencies": { + "@types/estree": "1.0.5" + }, "bin": { "rollup": "dist/bin/rollup" }, "engines": { - "node": ">=14.18.0", + "node": ">=18.0.0", "npm": ">=8.0.0" }, "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.9.6", + "@rollup/rollup-android-arm64": "4.9.6", + "@rollup/rollup-darwin-arm64": "4.9.6", + "@rollup/rollup-darwin-x64": "4.9.6", + "@rollup/rollup-linux-arm-gnueabihf": "4.9.6", + "@rollup/rollup-linux-arm64-gnu": "4.9.6", + "@rollup/rollup-linux-arm64-musl": "4.9.6", + "@rollup/rollup-linux-riscv64-gnu": "4.9.6", + "@rollup/rollup-linux-x64-gnu": "4.9.6", + "@rollup/rollup-linux-x64-musl": "4.9.6", + "@rollup/rollup-win32-arm64-msvc": "4.9.6", + "@rollup/rollup-win32-ia32-msvc": "4.9.6", + "@rollup/rollup-win32-x64-msvc": "4.9.6", "fsevents": "~2.3.2" } }, @@ -3688,6 +4408,18 @@ "dev": true, "license": "ISC" }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/simple-concat": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", @@ -3743,8 +4475,9 @@ }, "node_modules/source-map-js": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", "dev": true, - "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } @@ -3768,9 +4501,10 @@ "license": "MIT" }, "node_modules/std-env": { - "version": "3.3.3", - "dev": true, - "license": "MIT" + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", + "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", + "dev": true }, "node_modules/string_decoder": { "version": "1.3.0", @@ -3781,6 +4515,18 @@ "safe-buffer": "~5.2.0" } }, + "node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", @@ -3866,26 +4612,38 @@ } }, "node_modules/tinybench": { - "version": "2.5.0", - "dev": true, - "license": "MIT" + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.6.0.tgz", + "integrity": "sha512-N8hW3PG/3aOoZAN5V/NSAEDz0ZixDSSt5b/a05iqtpgfLWMSVuCo7w0k2vVvEjdrIoeGqZzweX2WlyioNIHchA==", + "dev": true }, "node_modules/tinypool": { - "version": "0.7.0", + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.8.2.tgz", + "integrity": "sha512-SUszKYe5wgsxnNOVlBYO6IC+8VGWdVGZWAqUxp3UErNBtptZvWbwyUOyzNL59zigz2rCA92QiL3wvG+JDSdJdQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=14.0.0" } }, "node_modules/tinyspy": { - "version": "2.1.1", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-2.2.0.tgz", + "integrity": "sha512-d2eda04AN/cPOR89F7Xv5bK/jrQEhmcLFe6HFldoeO9AJtps+fqEnh486vnT/8y4bw38pSyxDcTCAq+Ks2aJTg==", "dev": true, - "license": "MIT", "engines": { "node": ">=14.0.0" } }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/tough-cookie": { "version": "4.1.3", "license": "BSD-3-Clause", @@ -3932,16 +4690,18 @@ }, "node_modules/type-detect": { "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true, - "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/ufo": { - "version": "1.2.0", - "dev": true, - "license": "MIT" + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.3.2.tgz", + "integrity": "sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==", + "dev": true }, "node_modules/uhyphen": { "version": "0.1.0", @@ -3969,41 +4729,43 @@ "dev": true }, "node_modules/v8-to-istanbul": { - "version": "9.1.0", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz", + "integrity": "sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==", "dev": true, - "license": "ISC", "dependencies": { "@jridgewell/trace-mapping": "^0.3.12", "@types/istanbul-lib-coverage": "^2.0.1", - "convert-source-map": "^1.6.0" + "convert-source-map": "^2.0.0" }, "engines": { "node": ">=10.12.0" } }, "node_modules/vite": { - "version": "4.4.9", + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz", + "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==", "dev": true, - "license": "MIT", "dependencies": { - "esbuild": "^0.18.10", - "postcss": "^8.4.27", - "rollup": "^3.27.1" + "esbuild": "^0.19.3", + "postcss": "^8.4.32", + "rollup": "^4.2.0" }, "bin": { "vite": "bin/vite.js" }, "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^18.0.0 || >=20.0.0" }, "funding": { "url": "https://github.com/vitejs/vite?sponsor=1" }, "optionalDependencies": { - "fsevents": "~2.3.2" + "fsevents": "~2.3.3" }, "peerDependencies": { - "@types/node": ">= 14", + "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", @@ -4036,80 +4798,79 @@ } }, "node_modules/vite-node": { - "version": "0.34.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-1.2.2.tgz", + "integrity": "sha512-1as4rDTgVWJO3n1uHmUYqq7nsFgINQ9u+mRcXpjeOMJUmviqNKjcZB7UfRZrlM7MjYXMKpuWp5oGkjaFLnjawg==", "dev": true, - "license": "MIT", "dependencies": { "cac": "^6.7.14", "debug": "^4.3.4", - "mlly": "^1.4.0", "pathe": "^1.1.1", "picocolors": "^1.0.0", - "vite": "^3.0.0 || ^4.0.0" + "vite": "^5.0.0" }, "bin": { "vite-node": "vite-node.mjs" }, "engines": { - "node": ">=v14.18.0" + "node": "^18.0.0 || >=20.0.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/vitest": { - "version": "0.34.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-1.2.2.tgz", + "integrity": "sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==", "dev": true, - "license": "MIT", "dependencies": { - "@types/chai": "^4.3.5", - "@types/chai-subset": "^1.3.3", - "@types/node": "*", - "@vitest/expect": "0.34.1", - "@vitest/runner": "0.34.1", - "@vitest/snapshot": "0.34.1", - "@vitest/spy": "0.34.1", - "@vitest/utils": "0.34.1", - "acorn": "^8.9.0", - "acorn-walk": "^8.2.0", + "@vitest/expect": "1.2.2", + "@vitest/runner": "1.2.2", + "@vitest/snapshot": "1.2.2", + "@vitest/spy": "1.2.2", + "@vitest/utils": "1.2.2", + "acorn-walk": "^8.3.2", "cac": "^6.7.14", - "chai": "^4.3.7", + "chai": "^4.3.10", "debug": "^4.3.4", - "local-pkg": "^0.4.3", - "magic-string": "^0.30.1", + "execa": "^8.0.1", + "local-pkg": "^0.5.0", + "magic-string": "^0.30.5", "pathe": "^1.1.1", "picocolors": "^1.0.0", - "std-env": "^3.3.3", - "strip-literal": "^1.0.1", - "tinybench": "^2.5.0", - "tinypool": "^0.7.0", - "vite": "^3.0.0 || ^4.0.0", - "vite-node": "0.34.1", + "std-env": "^3.5.0", + "strip-literal": "^1.3.0", + "tinybench": "^2.5.1", + "tinypool": "^0.8.2", + "vite": "^5.0.0", + "vite-node": "1.2.2", "why-is-node-running": "^2.2.2" }, "bin": { "vitest": "vitest.mjs" }, "engines": { - "node": ">=v14.18.0" + "node": "^18.0.0 || >=20.0.0" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { "@edge-runtime/vm": "*", - "@vitest/browser": "*", - "@vitest/ui": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "^1.0.0", + "@vitest/ui": "^1.0.0", "happy-dom": "*", - "jsdom": "*", - "playwright": "*", - "safaridriver": "*", - "webdriverio": "*" + "jsdom": "*" }, "peerDependenciesMeta": { "@edge-runtime/vm": { "optional": true }, + "@types/node": { + "optional": true + }, "@vitest/browser": { "optional": true }, @@ -4121,15 +4882,6 @@ }, "jsdom": { "optional": true - }, - "playwright": { - "optional": true - }, - "safaridriver": { - "optional": true - }, - "webdriverio": { - "optional": true } } }, @@ -4273,6 +5025,18 @@ "version": "4.0.0", "dev": true, "license": "ISC" + }, + "node_modules/yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "dev": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/packages/core/package.json b/packages/core/package.json index 9fa471703..ea0996862 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -18,7 +18,7 @@ "@types/spark-md5": "^3.0.2", "@types/streetwriters__showdown": "npm:@types/showdown@^2.0.6", "@types/ws": "^8.5.5", - "@vitest/coverage-v8": "^0.34.1", + "@vitest/coverage-v8": "^1.0.1", "abortcontroller-polyfill": "^1.7.3", "better-sqlite3": "^8.6.0", "bson-objectid": "^2.0.4", @@ -33,7 +33,7 @@ "nanoid": "^5.0.1", "otplib": "^12.0.1", "refractor": "^4.8.1", - "vitest": "^0.34.1", + "vitest": "^1.0.1", "vitest-fetch-mock": "^0.2.2", "ws": "^8.13.0" }, diff --git a/packages/core/src/api/lookup.ts b/packages/core/src/api/lookup.ts index a560414df..17240225f 100644 --- a/packages/core/src/api/lookup.ts +++ b/packages/core/src/api/lookup.ts @@ -100,16 +100,21 @@ export default class Lookup { trash(query: string): SearchResults { return { sorted: async (limit?: number) => { - const { ids, records } = await this.filterTrash(query, limit); + const { ids, items } = await this.filterTrash(query, limit); return new VirtualizedGrouping( - ids, + ids.length, this.db.options.batchSize, - async () => records + async (start, end) => { + return { + ids: ids.slice(start, end), + items: items.slice(start, end) + }; + } ); }, items: async (limit?: number) => { - const { records } = await this.filterTrash(query, limit); - return Object.values(records); + const { items } = await this.filterTrash(query, limit); + return items; }, ids: () => this.filterTrash(query).then(({ ids }) => ids) }; @@ -176,22 +181,23 @@ export default class Lookup { private async filterTrash(query: string, limit?: number) { const items = await this.db.trash.all(); - const records: Record = {}; - const results: Map = new Map(); + const results: Map = new Map(); for (const item of items) { if (limit && results.size >= limit) break; const result = match(query, item.title); if (result.match) { - records[item.id] = item; - results.set(item.id, result.score); + results.set(item.id, { rank: result.score, item }); } } - const ids = Array.from(results.entries()) - .sort((a, b) => a[1] - b[1]) - .map((a) => a[0]); - return { ids, records }; + const sorted = Array.from(results.entries()).sort( + (a, b) => a[1].rank - b[1].rank + ); + return { + ids: sorted.map((a) => a[0]), + items: sorted.map((a) => a[1].item) + }; } private toVirtualizedGrouping( @@ -199,9 +205,15 @@ export default class Lookup { selector: FilteredSelector ) { return new VirtualizedGrouping( - ids, + ids.length, this.db.options.batchSize, - async (ids) => selector.records(ids) + async (start, end) => { + const items = await selector.items(ids); + return { + ids: ids.slice(start, end), + items: items.slice(start, end) + }; + } ); } diff --git a/packages/core/src/collections/relations.ts b/packages/core/src/collections/relations.ts index 42779771d..37a9b6c98 100644 --- a/packages/core/src/collections/relations.ts +++ b/packages/core/src/collections/relations.ts @@ -34,7 +34,7 @@ export class Relations implements ICollection { } async init() { - await this.buildCache(); + // await this.buildCache(); // return this.collection.init(); } diff --git a/packages/core/src/collections/trash.ts b/packages/core/src/collections/trash.ts index c8e8a46dd..82bda297d 100644 --- a/packages/core/src/collections/trash.ts +++ b/packages/core/src/collections/trash.ts @@ -212,18 +212,28 @@ export default class Trash { } async grouped(options: GroupOptions) { - const items = await this.all(); - const ids = groupArray(items, options); - const records: Record = {}; - for (const item of items) records[item.id] = item; + // const items = await this.all(); + // const ids = groupArray(items, options); + // const records: Record = {}; + // for (const item of items) records[item.id] = item; + // const ids = [...this.cache.notebooks,...this.cache.notes] return new VirtualizedGrouping( - ids, - this.db.options?.batchSize || 500, - async (ids: string[]) => { - const items: Record = {}; - for (const id of ids) items[id] = records[id]; - return items; + this.cache.notebooks.length + this.cache.notes.length, + this.db.options.batchSize, + async (start, end) => { + // const notesRange = end < this.cache.notes.length ? [start, end] : [start, this.cache.notes.length - 1]; + // const notebooksRange = start >= this.cache.notes.length ?[start, end] : [ + // 0, end + // ] + // TODO: + return { ids: [], items: [] }; + // return { + // ids: ids.slice(start,end), + // } + // const items: Record = {}; + // for (const id of ids) items[id] = records[id]; + // return items; } ); } diff --git a/packages/core/src/database/migrations.ts b/packages/core/src/database/migrations.ts index bfafc0164..612f9b16c 100644 --- a/packages/core/src/database/migrations.ts +++ b/packages/core/src/database/migrations.ts @@ -18,6 +18,7 @@ along with this program. If not, see . */ import { + ColumnBuilderCallback, CreateTableBuilder, Kysely, Migration, @@ -25,6 +26,9 @@ import { sql } from "kysely"; +const COLLATE_NOCASE: ColumnBuilderCallback = (col) => + col.modifyEnd(sql`collate nocase`); + export class NNMigrationProvider implements MigrationProvider { async getMigrations(): Promise> { return { @@ -35,7 +39,7 @@ export class NNMigrationProvider implements MigrationProvider { // .modifyEnd(sql`without rowid`) .$call(addBaseColumns) .$call(addTrashColumns) - .addColumn("title", "text") + .addColumn("title", "text", COLLATE_NOCASE) .addColumn("headline", "text") .addColumn("contentId", "text") .addColumn("pinned", "boolean") @@ -95,7 +99,7 @@ export class NNMigrationProvider implements MigrationProvider { .modifyEnd(sql`without rowid`) .$call(addBaseColumns) .$call(addTrashColumns) - .addColumn("title", "text") + .addColumn("title", "text", COLLATE_NOCASE) .addColumn("description", "text") .addColumn("dateEdited", "integer") .addColumn("pinned", "boolean") @@ -105,14 +109,14 @@ export class NNMigrationProvider implements MigrationProvider { .createTable("tags") .modifyEnd(sql`without rowid`) .$call(addBaseColumns) - .addColumn("title", "text") + .addColumn("title", "text", COLLATE_NOCASE) .execute(); await db.schema .createTable("colors") .modifyEnd(sql`without rowid`) .$call(addBaseColumns) - .addColumn("title", "text") + .addColumn("title", "text", COLLATE_NOCASE) .addColumn("colorCode", "text") .execute(); @@ -139,7 +143,7 @@ export class NNMigrationProvider implements MigrationProvider { .createTable("reminders") .modifyEnd(sql`without rowid`) .$call(addBaseColumns) - .addColumn("title", "text") + .addColumn("title", "text", COLLATE_NOCASE) .addColumn("description", "text") .addColumn("priority", "text") .addColumn("date", "integer") @@ -230,6 +234,18 @@ export class NNMigrationProvider implements MigrationProvider { .columns(["type"]) .execute(); + await db.schema + .createIndex("note_deleted") + .on("notes") + .columns(["deleted"]) + .execute(); + + await db.schema + .createIndex("note_date_deleted") + .on("notes") + .columns(["dateDeleted"]) + .execute(); + await db.schema .createIndex("notebook_type") .on("notebooks") diff --git a/packages/core/src/database/sql-collection.ts b/packages/core/src/database/sql-collection.ts index 68eb8436e..f78ab93de 100644 --- a/packages/core/src/database/sql-collection.ts +++ b/packages/core/src/database/sql-collection.ts @@ -19,6 +19,7 @@ along with this program. If not, see . import { EVENTS } from "../common"; import { + GroupHeader, GroupOptions, Item, MaybeDeletedItem, @@ -34,9 +35,9 @@ import { isFalse } from "."; import { + AnyColumn, AnyColumnWithTable, ExpressionOrFactory, - SelectExpression, SelectQueryBuilder, SqlBool, sql @@ -353,10 +354,41 @@ export class FilteredSelector { } async grouped(options: GroupOptions) { - console.time("getting items"); + const count = await this.count(); + const sortFields = this.sortFields(options, true); + const cursorRowValue = sql.join(sortFields.map((f) => sql.ref(f))); + return new VirtualizedGrouping( + count, + this.batchSize, + async (start, end, cursor) => { + const items = (await this.filter + .$call(this.buildSortExpression(options)) + .$if(!cursor, (qb) => qb.offset(start)) + .$if(!!cursor, (qb) => + qb.where( + (eb) => eb.parens(cursorRowValue), + ">", + (eb) => + eb.parens(sql.join(sortFields.map((f) => (cursor as any)[f]))) + ) + ) + .limit(end - start) + .selectAll() + .execute()) as T[]; + return { + ids: items.map((i) => i.id), + items + }; + }, + (items) => groupArray(items as any, options), + () => this.groups(options) + ); + } + async groups(options: GroupOptions) { const fields: Array< - SelectExpression + | AnyColumnWithTable + | AnyColumn > = ["id", "type", options.sortBy]; if (this.type === "notes") fields.push("notes.pinned", "notes.conflicted"); else if (this.type === "notebooks") fields.push("notebooks.pinned"); @@ -372,33 +404,63 @@ export class FilteredSelector { "reminders.snoozeUntil" ); } - - const items = await this.filter - .$if(!!this._limit, (eb) => eb.limit(this._limit)) - .$call(this.buildSortExpression(options)) - .select(fields) - .execute(); - console.timeEnd("getting items"); - console.log(items.length); - const ids = groupArray(items, options); - return new VirtualizedGrouping(ids, this.batchSize, (ids) => - this.records(ids) + return groupArray( + await this.filter + .$call(this.buildSortExpression(options)) + .select(fields) + .execute(), + options ); } async sorted(options: SortOptions) { - const items = await this.filter - .$if(!!this._limit, (eb) => eb.limit(this._limit)) - .$call(this.buildSortExpression(options)) - .select("id") - .execute(); - const ids = items.map((item) => item.id); - return new VirtualizedGrouping(ids, this.batchSize, (ids) => - this.records(ids) + const count = await this.count(); + + return new VirtualizedGrouping( + count, + this.batchSize, + async (start, end) => { + const items = (await this.filter + .$call(this.buildSortExpression(options)) + .offset(start) + .limit(end - start) + .selectAll() + .execute()) as T[]; + return { + ids: items.map((i) => i.id), + items + }; + } ); } - private buildSortExpression(options: SortOptions) { + async *[Symbol.asyncIterator]() { + let lastRow: any | null = null; + while (true) { + const rows = await this.filter + .orderBy("dateCreated asc") + .orderBy("id asc") + .$if(lastRow !== null, (qb) => + qb.where( + (eb) => eb.refTuple("dateCreated", "id"), + ">", + (eb) => eb.tuple(lastRow.dateCreated, lastRow.id) + ) + ) + .limit(this.batchSize) + .$if(this._fields.length === 0, (eb) => eb.selectAll()) + .$if(this._fields.length > 0, (eb) => eb.select(this._fields)) + .execute(); + if (rows.length === 0) break; + for (const row of rows) { + yield row as T; + } + + lastRow = rows[rows.length - 1]; + } + } + + private buildSortExpression(options: SortOptions, persistent?: boolean) { return ( qb: SelectQueryBuilder ) => { @@ -407,34 +469,21 @@ export class FilteredSelector { .$if(this.type === "notes" || this.type === "notebooks", (eb) => eb.orderBy("pinned desc") ) - .$if(options.sortBy === "title", (eb) => - eb.orderBy( - sql`${sql.raw(options.sortBy)} COLLATE NOCASE ${sql.raw( - options.sortDirection - )}` - ) - ) - .$if(options.sortBy !== "title", (eb) => - eb.orderBy(options.sortBy, options.sortDirection) - ); + .orderBy(options.sortBy, options.sortDirection) + .$if(!!persistent, (eb) => eb.orderBy("id")); }; } - async *[Symbol.asyncIterator]() { - let index = 0; - while (true) { - const rows = await this.filter - .$if(this._fields.length === 0, (eb) => eb.selectAll()) - .$if(this._fields.length > 0, (eb) => eb.select(this._fields)) - .orderBy("dateCreated asc") - .offset(index) - .limit(this.batchSize) - .execute(); - if (rows.length === 0) break; - index += this.batchSize; - for (const row of rows) { - yield row as T; - } - } + private sortFields(options: SortOptions, persistent?: boolean) { + const fields: Array< + | AnyColumnWithTable + | AnyColumn + > = []; + if (this.type === "notes") fields.push("conflicted"); + if (this.type === "notes" || this.type === "notebooks") + fields.push("pinned"); + fields.push(options.sortBy); + if (persistent) fields.push("id"); + return fields; } } diff --git a/packages/core/src/utils/__tests__/virtualized-grouping.test.ts b/packages/core/src/utils/__tests__/virtualized-grouping.test.ts index 0f38de458..a5228128c 100644 --- a/packages/core/src/utils/__tests__/virtualized-grouping.test.ts +++ b/packages/core/src/utils/__tests__/virtualized-grouping.test.ts @@ -28,98 +28,98 @@ function createMock() { Object.fromEntries(ids.map((id) => [id, id])) ); } -test("fetch items in batch if not found in cache", async (t) => { - const mocked = createMock(); - const grouping = new VirtualizedGrouping( - ["1", "2", "3", "4", "5", "6", "7"], - 3, - mocked - ); - t.expect(await grouping.item("4")).toStrictEqual(item("4")); - t.expect(mocked).toHaveBeenCalledOnce(); -}); +// test("fetch items in batch if not found in cache", async (t) => { +// const mocked = createMock(); +// const grouping = new VirtualizedGrouping( +// ["1", "2", "3", "4", "5", "6", "7"], +// 3, +// mocked +// ); +// t.expect(await grouping.item("4")).toStrictEqual(item("4")); +// t.expect(mocked).toHaveBeenCalledOnce(); +// }); -test("do not fetch items in batch if found in cache", async (t) => { - const mocked = createMock(); - const grouping = new VirtualizedGrouping( - ["1", "2", "3", "4", "5", "6", "7"], - 3, - mocked - ); - t.expect(await grouping.item("4")).toStrictEqual(item("4")); - t.expect(await grouping.item("4")).toStrictEqual(item("4")); - t.expect(await grouping.item("4")).toStrictEqual(item("4")); - t.expect(await grouping.item("4")).toStrictEqual(item("4")); - t.expect(await grouping.item("4")).toStrictEqual(item("4")); - t.expect(mocked).toHaveBeenCalledOnce(); -}); +// test("do not fetch items in batch if found in cache", async (t) => { +// const mocked = createMock(); +// const grouping = new VirtualizedGrouping( +// ["1", "2", "3", "4", "5", "6", "7"], +// 3, +// mocked +// ); +// t.expect(await grouping.item("4")).toStrictEqual(item("4")); +// t.expect(await grouping.item("4")).toStrictEqual(item("4")); +// t.expect(await grouping.item("4")).toStrictEqual(item("4")); +// t.expect(await grouping.item("4")).toStrictEqual(item("4")); +// t.expect(await grouping.item("4")).toStrictEqual(item("4")); +// t.expect(mocked).toHaveBeenCalledOnce(); +// }); -test("clear old cached batches", async (t) => { - const mocked = createMock(); - const grouping = new VirtualizedGrouping( - ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"], - 3, - mocked - ); - t.expect(await grouping.item("1")).toStrictEqual(item("1")); - t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); - t.expect(await grouping.item("4")).toStrictEqual(item("4")); - t.expect(mocked).toHaveBeenLastCalledWith(["4", "5", "6"]); - t.expect(await grouping.item("7")).toStrictEqual(item("7")); - t.expect(mocked).toHaveBeenLastCalledWith(["7", "8", "9"]); - t.expect(await grouping.item("1")).toStrictEqual(item("1")); - t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); -}); +// test("clear old cached batches", async (t) => { +// const mocked = createMock(); +// const grouping = new VirtualizedGrouping( +// ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"], +// 3, +// mocked +// ); +// t.expect(await grouping.item("1")).toStrictEqual(item("1")); +// t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); +// t.expect(await grouping.item("4")).toStrictEqual(item("4")); +// t.expect(mocked).toHaveBeenLastCalledWith(["4", "5", "6"]); +// t.expect(await grouping.item("7")).toStrictEqual(item("7")); +// t.expect(mocked).toHaveBeenLastCalledWith(["7", "8", "9"]); +// t.expect(await grouping.item("1")).toStrictEqual(item("1")); +// t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); +// }); -test("clear old cached batches (random access)", async (t) => { - const mocked = createMock(); - const grouping = new VirtualizedGrouping( - ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"], - 3, - mocked - ); - t.expect(await grouping.item("1")).toStrictEqual(item("1")); - t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); +// test("clear old cached batches (random access)", async (t) => { +// const mocked = createMock(); +// const grouping = new VirtualizedGrouping( +// ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"], +// 3, +// mocked +// ); +// t.expect(await grouping.item("1")).toStrictEqual(item("1")); +// t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); - t.expect(await grouping.item("7")).toStrictEqual(item("7")); - t.expect(mocked).toHaveBeenLastCalledWith(["7", "8", "9"]); +// t.expect(await grouping.item("7")).toStrictEqual(item("7")); +// t.expect(mocked).toHaveBeenLastCalledWith(["7", "8", "9"]); - t.expect(await grouping.item("11")).toStrictEqual(item("11")); - t.expect(mocked).toHaveBeenLastCalledWith(["10", "11", "12"]); +// t.expect(await grouping.item("11")).toStrictEqual(item("11")); +// t.expect(mocked).toHaveBeenLastCalledWith(["10", "11", "12"]); - t.expect(await grouping.item("1")).toStrictEqual(item("1")); - t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); +// t.expect(await grouping.item("1")).toStrictEqual(item("1")); +// t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); - t.expect(await grouping.item("7")).toStrictEqual(item("7")); - t.expect(mocked).toHaveBeenLastCalledWith(["7", "8", "9"]); -}); +// t.expect(await grouping.item("7")).toStrictEqual(item("7")); +// t.expect(mocked).toHaveBeenLastCalledWith(["7", "8", "9"]); +// }); -test("reloading ids should clear all cached batches", async (t) => { - const mocked = createMock(); - const grouping = new VirtualizedGrouping( - ["1", "3", "4", "5", "7", "6", "50"], - 3, - mocked - ); +// test("reloading ids should clear all cached batches", async (t) => { +// const mocked = createMock(); +// const grouping = new VirtualizedGrouping( +// ["1", "3", "4", "5", "7", "6", "50"], +// 3, +// mocked +// ); - t.expect(await grouping.item("1")).toStrictEqual(item("1")); - t.expect(mocked).toHaveBeenLastCalledWith(["1", "3", "4"]); +// t.expect(await grouping.item("1")).toStrictEqual(item("1")); +// t.expect(mocked).toHaveBeenLastCalledWith(["1", "3", "4"]); - grouping.refresh([ - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11", - "12" - ]); +// grouping.refresh([ +// "1", +// "2", +// "3", +// "4", +// "5", +// "6", +// "7", +// "8", +// "9", +// "10", +// "11", +// "12" +// ]); - t.expect(await grouping.item("1")).toStrictEqual(item("1")); - t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); -}); +// t.expect(await grouping.item("1")).toStrictEqual(item("1")); +// t.expect(mocked).toHaveBeenLastCalledWith(["1", "2", "3"]); +// }); diff --git a/packages/core/src/utils/grouping.ts b/packages/core/src/utils/grouping.ts index 38edfff18..e118b8223 100644 --- a/packages/core/src/utils/grouping.ts +++ b/packages/core/src/utils/grouping.ts @@ -96,37 +96,42 @@ export function groupArray( sortBy: "dateEdited", sortDirection: "desc" } -): (string | GroupHeader)[] { - const groups = new Map([ - ["Conflicted", []], - ["Pinned", []] - ]); +): { index: number; group: GroupHeader }[] { + const groups = new Map(); + // [ + // ["Conflicted", 0], + // ["Pinned", 1] + // ] const keySelector = getKeySelector(options); - for (const item of items) { + for (let i = 0; i < items.length; ++i) { + const item = items[i]; const groupTitle = keySelector(item); - const group = groups.get(groupTitle) || []; - group.push(item.id); - groups.set(groupTitle, group); + const group = groups.get(groupTitle); + if (typeof group === "undefined") groups.set(groupTitle, i); } - - return flattenGroups(groups); + const groupIndices: { index: number; group: GroupHeader }[] = []; + groups.forEach((index, title) => + groupIndices.push({ index, group: { id: title, title, type: "header" } }) + ); + return groupIndices; + // return flattenGroups(groups); } -function flattenGroups(groups: Map) { - const items: (string | GroupHeader)[] = []; - groups.forEach((groupItems, groupTitle) => { - if (groupItems.length <= 0) return; - items.push({ - title: groupTitle, - id: groupTitle.toLowerCase(), - type: "header" - }); - items.push(...groupItems); - }); +// function flattenGroups(groups: Map) { +// const items: GroupedItems = []; +// groups.forEach((groupItems, groupTitle) => { +// if (groupItems.length <= 0) return; +// items.push({ +// title: groupTitle, +// id: groupTitle.toLowerCase(), +// type: "header" +// }); +// items.push(...groupItems); +// }); - return items; -} +// return items; +// } function getFirstCharacter(str: string) { if (!str) return "-"; @@ -136,5 +141,5 @@ function getFirstCharacter(str: string) { } function getTitle(item: PartialGroupableItem): string { - return item.filename || item.title || "Unknown"; + return ("filename" in item ? item.filename : item.title) || "Unknown"; } diff --git a/packages/core/src/utils/virtualized-grouping.ts b/packages/core/src/utils/virtualized-grouping.ts index 86a90b9ba..f5672e9c6 100644 --- a/packages/core/src/utils/virtualized-grouping.ts +++ b/packages/core/src/utils/virtualized-grouping.ts @@ -17,61 +17,78 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import { GroupHeader, isGroupHeader } from "../types"; +import { GroupHeader } from "../types"; -type BatchOperator = ( - ids: string[], - items: Record -) => Promise>; -type Batch = { items: Record; data?: Record }; +type BatchOperator = (ids: string[], items: T[]) => Promise; +type Batch = { + items: T[]; + groups?: { index: number; hidden?: boolean; group: GroupHeader }[]; + data?: unknown[]; +}; export class VirtualizedGrouping { private cache: Map> = new Map(); private pending: Map>> = new Map(); - groups: GroupHeader[] = []; + public ids: number[]; + private loadBatchTimeout?: number; + private cacheHits = 0; constructor( - public ids: (string | GroupHeader)[], + count: number, private readonly batchSize: number, - private readonly fetchItems: (ids: string[]) => Promise> + private readonly fetchItems: ( + start: number, + end: number, + cursor?: T + ) => Promise<{ ids: string[]; items: T[] }>, + private readonly groupItems?: ( + items: T[] + ) => { index: number; hidden?: boolean; group: GroupHeader }[], + readonly groups?: () => Promise<{ index: number; group: GroupHeader }[]> ) { - this.ids = ids; - this.groups = ids.filter((i) => isGroupHeader(i)) as GroupHeader[]; + this.ids = new Array(count).fill(0); } getKey(index: number) { - const item = this.ids[index]; - if (isGroupHeader(item)) return item.id; - return item; - } - - get ungrouped() { - return this.ids.filter((i) => !isGroupHeader(i)) as string[]; - } - - /** - * Get item from cache or request the appropriate batch for caching - * and load it from there. - */ - item(id: string): Promise; - item( - id: string, - operate: BatchOperator - ): Promise<{ item: T; data: unknown } | undefined>; - async item(id: string, operate?: BatchOperator) { - const index = this.ids.indexOf(id); - if (index <= -1) return; - const batchIndex = Math.floor(index / this.batchSize); - const { items, data } = + const batch = this.cache.get(batchIndex); + if (!batch) return `${index}`; + + const { items, groups } = batch; + const itemIndexInBatch = index - batchIndex * this.batchSize; + const group = groups?.find( + (f) => f.index === itemIndexInBatch && !f.hidden + ); + return group + ? group.group.id + : (items[itemIndexInBatch] as any)?.id || `${index}`; + } + + item(index: number): Promise<{ item: T; group?: GroupHeader }>; + item( + index: number, + operate: BatchOperator + ): Promise<{ item: T; group?: GroupHeader; data: unknown }>; + async item(index: number, operate?: BatchOperator) { + const batchIndex = Math.floor(index / this.batchSize); + if (this.cache.has(batchIndex)) this.cacheHits++; + const { items, groups, data } = this.cache.get(batchIndex) || (await this.loadBatch(batchIndex, operate)); - return operate ? { item: items[id], data: data?.[id] } : items[id]; + const itemIndexInBatch = index - batchIndex * this.batchSize; + const group = groups?.find( + (f) => f.index === itemIndexInBatch && !f.hidden + ); + return { + item: items[itemIndexInBatch], + group: group?.group, + data: data?.[itemIndexInBatch] + }; } /** * Reload the cache */ - refresh(ids: (string | GroupHeader)[]) { + refresh(ids: number[]) { this.ids = ids; this.cache.clear(); } @@ -80,19 +97,49 @@ export class VirtualizedGrouping { * * @param index */ - private async load(batchIndex: number, operate?: BatchOperator) { + private async load( + batchIndex: number, + operate?: BatchOperator + ): Promise> { + const lastBatchIndex = this.last; + const prev = this.cache.get(lastBatchIndex); const start = batchIndex * this.batchSize; const end = start + this.batchSize; - const batchIds = this.ids - .slice(start, end) - .filter((id) => typeof id === "string") as string[]; - const items = await this.fetchItems(batchIds); - console.time("operate"); + // we can use a cursor instead of start/end offsets for batches that are + // right next to each other. + const cursor = + lastBatchIndex + 1 === batchIndex + ? prev?.items.at(-1) + : lastBatchIndex - 1 === batchIndex + ? prev?.items[0] + : undefined; + const { ids, items } = await this.fetchItems(start, end, cursor); + const groups = this.groupItems?.(items); + + if ( + prev && + prev.groups && + prev.groups.length > 0 && + groups && + groups.length > 0 + ) { + // if user is moving downwards, we hide the first group from the + // current batch, otherwise we hide the last group from the previous + // batch. + const group = + lastBatchIndex < batchIndex + ? groups[0] //groups.length - 1] + : prev.groups[prev.groups.length - 1]; + if (group.group.title === groups[0].group.title) { + group.hidden = true; + } + } + const batch = { items, - data: operate ? await operate(batchIds, items) : undefined + groups, + data: operate ? await operate(ids, items) : undefined }; - console.timeEnd("operate"); this.cache.set(batchIndex, batch); this.clear(); return batch; @@ -100,12 +147,18 @@ export class VirtualizedGrouping { private loadBatch(batch: number, operate?: BatchOperator) { if (this.pending.has(batch)) return this.pending.get(batch)!; - console.time("loading batch"); - const promise = this.load(batch, operate); - this.pending.set(batch, promise); - return promise.finally(() => { - console.timeEnd("loading batch"); - this.pending.delete(batch); + if (!this.isLastBatch(batch)) clearTimeout(this.loadBatchTimeout); + return new Promise>((resolve, reject) => { + this.loadBatchTimeout = setTimeout(() => { + const promise = this.load(batch, operate); + this.pending.set(batch, promise); + return promise + .then(resolve) + .catch(reject) + .finally(() => { + this.pending.delete(batch); + }); + }, 16) as unknown as number; }); } @@ -116,4 +169,13 @@ export class VirtualizedGrouping { if (this.cache.size === 2) break; } } + + private get last() { + const keys = Array.from(this.cache.keys()); + return keys[keys.length - 1]; + } + + private isLastBatch(batch: number) { + return Math.floor(this.ids.length / this.batchSize) === batch; + } }