A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: fully move to using web streams everywhere
Abdullah Atta24e13f488e0a
diff --git a/apps/web/__tests__/base64-stream.test.ts b/apps/web/__tests__/base64-stream.test.tsnew file mode 100644index 000000000..d523cbfac--- /dev/null+++ b/apps/web/__tests__/base64-stream.test.ts@@ -0,0 +1,40 @@+/*+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/>.+*/++import "./bootstrap";+import { test } from "vitest";+import { Base64DecoderStream } from "../src/interfaces/base64-decoder-stream";+import { consumeReadableStream } from "../src/interfaces/stream-utils";+import { createReadStream, readFileSync } from "fs";+import { Readable } from "stream";++test("streamed base64 decoder should output same as non-streamed", async (t) => {+ const expected = readFileSync(__filename, "base64");+ const fileStream = Readable.toWeb(+ createReadStream(__filename)+ ) as ReadableStream<Uint8Array>;++ t.expect(+ (+ await consumeReadableStream(+ fileStream.pipeThrough(new Base64DecoderStream("base64"))+ )+ ).join()+ ).toBe(expected);+});diff --git a/apps/web/__tests__/bootstrap.ts b/apps/web/__tests__/bootstrap.tsnew file mode 100644index 000000000..f6ac57235--- /dev/null+++ b/apps/web/__tests__/bootstrap.ts@@ -0,0 +1,34 @@+/*+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/>.+*/++import {+ TransformStream,+ ReadableStream,+ WritableStream+} from "node:stream/web";++// eslint-disable-next-line @typescript-eslint/ban-ts-comment+// @ts-ignore+globalThis.TransformStream = TransformStream;+// eslint-disable-next-line @typescript-eslint/ban-ts-comment+// @ts-ignore+globalThis.ReadableStream = ReadableStream;+// eslint-disable-next-line @typescript-eslint/ban-ts-comment+// @ts-ignore+globalThis.WritableStream = WritableStream;diff --git a/apps/web/__tests__/chunked-stream.test.ts b/apps/web/__tests__/chunked-stream.test.tsnew file mode 100644index 000000000..83792d959--- /dev/null+++ b/apps/web/__tests__/chunked-stream.test.ts@@ -0,0 +1,43 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2023 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import "./bootstrap";+import { test } from "vitest";+import { ChunkedStream } from "../src/interfaces/chunked-stream";+import { toAsyncIterator } from "@notesnook-importer/core/dist/src/utils/stream";++test("chunked stream should create equal sized chunks", async (t) => {+ const { readable, writable } = new ChunkedStream(512);+ const lengths: number[] = [];++ setTimeout(async () => {+ for await (const chunk of toAsyncIterator(readable)) {+ lengths.push(chunk.length);+ }+ });+ const writer = writable.getWriter();+ await writer.write(Buffer.alloc(411));+ await writer.write(Buffer.alloc(411));+ await writer.write(Buffer.alloc(411));+ await writer.write(Buffer.alloc(815));+ await writer.write(Buffer.alloc(12));+ await writer.close();++ t.expect(lengths).toMatchObject([512, 512, 512, 512, 12]);+});diff --git a/apps/web/package-lock.json b/apps/web/package-lock.jsonindex 144597754..261250657 100644--- a/apps/web/package-lock.json+++ b/apps/web/package-lock.json@@ -24,7 +24,7 @@"@theme-ui/core": "^0.14.7","allotment": "^1.12.1","async-mutex": "^0.3.2",- "axios": "^0.21.4",+ "axios": "^1.3.4","clipboard-polyfill": "^3.0.3","comlink": "^4.3.1","cronosjs": "^1.7.1",@@ -77,6 +77,7 @@"env-cmd": "^10.1.0","file-loader": "^6.2.0","find-process": "^1.4.4",+ "happy-dom": "^8.9.0","ip": "^1.1.8","lorem-ipsum": "^2.0.4","otplib": "^12.0.1",@@ -86,6 +87,7 @@"react-dom": "17.0.2","source-map-explorer": "^2.5.2","typescript": "^4.8.2",+ "vitest": "^0.29.8","webpack-bundle-analyzer": "^4.8.0","worker-loader": "^3.0.8"}@@ -2569,6 +2571,358 @@"resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.0.tgz","integrity": "sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg=="},+ "node_modules/@esbuild/android-arm": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.14.tgz",+ "integrity": "sha512-0CnlwnjDU8cks0yJLXfkaU/uoLyRf9VZJs4p1PskBr2AlAHeEsFEwJEo0of/Z3g+ilw5mpyDwThlxzNEIxOE4g==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/android-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.14.tgz",+ "integrity": "sha512-eLOpPO1RvtsP71afiFTvS7tVFShJBCT0txiv/xjFBo5a7R7Gjw7X0IgIaFoLKhqXYAXhahoXm7qAmRXhY4guJg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/android-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.14.tgz",+ "integrity": "sha512-nrfQYWBfLGfSGLvRVlt6xi63B5IbfHm3tZCdu/82zuFPQ7zez4XjmRtF/wIRYbJQ/DsZrxJdEvYFE67avYXyng==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/darwin-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.14.tgz",+ "integrity": "sha512-eoSjEuDsU1ROwgBH/c+fZzuSyJUVXQTOIN9xuLs9dE/9HbV/A5IqdXHU1p2OfIMwBwOYJ9SFVGGldxeRCUJFyw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/darwin-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.14.tgz",+ "integrity": "sha512-zN0U8RWfrDttdFNkHqFYZtOH8hdi22z0pFm0aIJPsNC4QQZv7je8DWCX5iA4Zx6tRhS0CCc0XC2m7wKsbWEo5g==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/freebsd-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.14.tgz",+ "integrity": "sha512-z0VcD4ibeZWVQCW1O7szaLxGsx54gcCnajEJMdYoYjLiq4g1jrP2lMq6pk71dbS5+7op/L2Aod+erw+EUr28/A==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/freebsd-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.14.tgz",+ "integrity": "sha512-hd9mPcxfTgJlolrPlcXkQk9BMwNBvNBsVaUe5eNUqXut6weDQH8whcNaKNF2RO8NbpT6GY8rHOK2A9y++s+ehw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-arm": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.14.tgz",+ "integrity": "sha512-BNTl+wSJ1omsH8s3TkQmIIIQHwvwJrU9u1ggb9XU2KTVM4TmthRIVyxSp2qxROJHhZuW/r8fht46/QE8hU8Qvg==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.14.tgz",+ "integrity": "sha512-FhAMNYOq3Iblcj9i+K0l1Fp/MHt+zBeRu/Qkf0LtrcFu3T45jcwB6A1iMsemQ42vR3GBhjNZJZTaCe3VFPbn9g==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-ia32": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.14.tgz",+ "integrity": "sha512-91OK/lQ5y2v7AsmnFT+0EyxdPTNhov3y2CWMdizyMfxSxRqHazXdzgBKtlmkU2KYIc+9ZK3Vwp2KyXogEATYxQ==",+ "cpu": [+ "ia32"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-loong64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.14.tgz",+ "integrity": "sha512-vp15H+5NR6hubNgMluqqKza85HcGJgq7t6rMH7O3Y6ApiOWPkvW2AJfNojUQimfTp6OUrACUXfR4hmpcENXoMQ==",+ "cpu": [+ "loong64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-mips64el": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.14.tgz",+ "integrity": "sha512-90TOdFV7N+fgi6c2+GO9ochEkmm9kBAKnuD5e08GQMgMINOdOFHuYLPQ91RYVrnWwQ5683sJKuLi9l4SsbJ7Hg==",+ "cpu": [+ "mips64el"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-ppc64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.14.tgz",+ "integrity": "sha512-NnBGeoqKkTugpBOBZZoktQQ1Yqb7aHKmHxsw43NddPB2YWLAlpb7THZIzsRsTr0Xw3nqiPxbA1H31ZMOG+VVPQ==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-riscv64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.14.tgz",+ "integrity": "sha512-0qdlKScLXA8MGVy21JUKvMzCYWovctuP8KKqhtE5A6IVPq4onxXhSuhwDd2g5sRCzNDlDjitc5sX31BzDoL5Fw==",+ "cpu": [+ "riscv64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-s390x": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.14.tgz",+ "integrity": "sha512-Hdm2Jo1yaaOro4v3+6/zJk6ygCqIZuSDJHdHaf8nVH/tfOuoEX5Riv03Ka15LmQBYJObUTNS1UdyoMk0WUn9Ww==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.14.tgz",+ "integrity": "sha512-8KHF17OstlK4DuzeF/KmSgzrTWQrkWj5boluiiq7kvJCiQVzUrmSkaBvcLB2UgHpKENO2i6BthPkmUhNDaJsVw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/netbsd-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.14.tgz",+ "integrity": "sha512-nVwpqvb3yyXztxIT2+VsxJhB5GCgzPdk1n0HHSnchRAcxqKO6ghXwHhJnr0j/B+5FSyEqSxF4q03rbA2fKXtUQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "netbsd"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/openbsd-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.14.tgz",+ "integrity": "sha512-1RZ7uQQ9zcy/GSAJL1xPdN7NDdOOtNEGiJalg/MOzeakZeTrgH/DoCkbq7TaPDiPhWqnDF+4bnydxRqQD7il6g==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "openbsd"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/sunos-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.14.tgz",+ "integrity": "sha512-nqMjDsFwv7vp7msrwWRysnM38Sd44PKmW8EzV01YzDBTcTWUpczQg6mGao9VLicXSgW/iookNK6AxeogNVNDZA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "sunos"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/win32-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.14.tgz",+ "integrity": "sha512-xrD0mccTKRBBIotrITV7WVQAwNJ5+1va6L0H9zN92v2yEdjfAN7864cUaZwJS7JPEs53bDTzKFbfqVlG2HhyKQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/win32-ia32": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.14.tgz",+ "integrity": "sha512-nXpkz9bbJrLLyUTYtRotSS3t5b+FOuljg8LgLdINWFs3FfqZMtbnBCZFUmBzQPyxqU87F8Av+3Nco/M3hEcu1w==",+ "cpu": [+ "ia32"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/win32-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.14.tgz",+ "integrity": "sha512-gPQmsi2DKTaEgG14hc3CHXHp62k8g6qr0Pas+I4lUxRMugGSATh/Bi8Dgusoz9IQ0IfdrvLpco6kujEIBoaogA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=12"+ }+ },"node_modules/@eslint/eslintrc": {"version": "1.4.1","resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz",@@ -4245,6 +4599,21 @@"@types/node": "*"}},+ "node_modules/@types/chai": {+ "version": "4.3.4",+ "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.4.tgz",+ "integrity": "sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==",+ "dev": true+ },+ "node_modules/@types/chai-subset": {+ "version": "1.3.3",+ "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.3.tgz",+ "integrity": "sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==",+ "dev": true,+ "dependencies": {+ "@types/chai": "*"+ }+ },"node_modules/@types/connect": {"version": "3.4.35","resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",@@ -4794,6 +5163,76 @@"resolved": "https://registry.npmjs.org/@virtuoso.dev/urx/-/urx-0.2.13.tgz","integrity": "sha512-iirJNv92A1ZWxoOHHDYW/1KPoi83939o83iUBQHIim0i3tMeSKEh+bxhJdTHQ86Mr4uXx9xGUTq69cp52ZP8Xw=="},+ "node_modules/@vitest/expect": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.29.8.tgz",+ "integrity": "sha512-xlcVXn5I5oTq6NiZSY3ykyWixBxr5mG8HYtjvpgg6KaqHm0mvhX18xuwl5YGxIRNt/A5jidd7CWcNHrSvgaQqQ==",+ "dev": true,+ "dependencies": {+ "@vitest/spy": "0.29.8",+ "@vitest/utils": "0.29.8",+ "chai": "^4.3.7"+ }+ },+ "node_modules/@vitest/runner": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.29.8.tgz",+ "integrity": "sha512-FzdhnRDwEr/A3Oo1jtIk/B952BBvP32n1ObMEb23oEJNO+qO5cBet6M2XWIDQmA7BDKGKvmhUf2naXyp/2JEwQ==",+ "dev": true,+ "dependencies": {+ "@vitest/utils": "0.29.8",+ "p-limit": "^4.0.0",+ "pathe": "^1.1.0"+ }+ },+ "node_modules/@vitest/runner/node_modules/p-limit": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz",+ "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==",+ "dev": true,+ "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",+ "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"+ }+ },+ "node_modules/@vitest/spy": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.29.8.tgz",+ "integrity": "sha512-VdjBe9w34vOMl5I5mYEzNX8inTxrZ+tYUVk9jxaZJmHFwmDFC/GV3KBFTA/JKswr3XHvZL+FE/yq5EVhb6pSAw==",+ "dev": true,+ "dependencies": {+ "tinyspy": "^1.0.2"+ }+ },+ "node_modules/@vitest/utils": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.29.8.tgz",+ "integrity": "sha512-qGzuf3vrTbnoY+RjjVVIBYfuWMjn3UMUqyQtdGNZ6ZIIyte7B37exj6LaVkrZiUTvzSadVvO/tJm8AEgbGCBPg==",+ "dev": true,+ "dependencies": {+ "cli-truncate": "^3.1.0",+ "diff": "^5.1.0",+ "loupe": "^2.3.6",+ "pretty-format": "^27.5.1"+ }+ },"node_modules/@webassemblyjs/ast": {"version": "1.11.1","resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz",@@ -5293,6 +5732,15 @@"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz","integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA=="},+ "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,+ "engines": {+ "node": "*"+ }+ },"node_modules/ast-types-flow": {"version": "0.0.7","resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz",@@ -5389,11 +5837,26 @@}},"node_modules/axios": {- "version": "0.21.4",- "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",- "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",+ "version": "1.3.4",+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",+ "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==","dependencies": {- "follow-redirects": "^1.14.0"+ "follow-redirects": "^1.15.0",+ "form-data": "^4.0.0",+ "proxy-from-env": "^1.1.0"+ }+ },+ "node_modules/axios/node_modules/form-data": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",+ "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",+ "dependencies": {+ "asynckit": "^0.4.0",+ "combined-stream": "^1.0.8",+ "mime-types": "^2.1.12"+ },+ "engines": {+ "node": ">= 6"}},"node_modules/axobject-query": {@@ -5960,6 +6423,15 @@"node": ">= 0.8"}},+ "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,+ "engines": {+ "node": ">=8"+ }+ },"node_modules/call-bind": {"version": "1.0.2","resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",@@ -6047,6 +6519,24 @@"node": ">=4"}},+ "node_modules/chai": {+ "version": "4.3.7",+ "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz",+ "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==",+ "dev": true,+ "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",+ "pathval": "^1.1.1",+ "type-detect": "^4.0.5"+ },+ "engines": {+ "node": ">=4"+ }+ },"node_modules/chalk": {"version": "4.1.2","resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",@@ -6070,6 +6560,15 @@"node": ">=10"}},+ "node_modules/check-error": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",+ "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==",+ "dev": true,+ "engines": {+ "node": "*"+ }+ },"node_modules/check-types": {"version": "11.2.2","resolved": "https://registry.npmjs.org/check-types/-/check-types-11.2.2.tgz",@@ -6161,6 +6660,66 @@"node": ">=0.10.0"}},+ "node_modules/cli-truncate": {+ "version": "3.1.0",+ "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz",+ "integrity": "sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==",+ "dev": true,+ "dependencies": {+ "slice-ansi": "^5.0.0",+ "string-width": "^5.0.0"+ },+ "engines": {+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/cli-truncate/node_modules/ansi-regex": {+ "version": "6.0.1",+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz",+ "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==",+ "dev": true,+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/chalk/ansi-regex?sponsor=1"+ }+ },+ "node_modules/cli-truncate/node_modules/string-width": {+ "version": "5.1.2",+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",+ "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",+ "dev": true,+ "dependencies": {+ "eastasianwidth": "^0.2.0",+ "emoji-regex": "^9.2.2",+ "strip-ansi": "^7.0.1"+ },+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/cli-truncate/node_modules/strip-ansi": {+ "version": "7.0.1",+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz",+ "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==",+ "dev": true,+ "dependencies": {+ "ansi-regex": "^6.0.1"+ },+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/chalk/strip-ansi?sponsor=1"+ }+ },"node_modules/clipboard-polyfill": {"version": "3.0.3","resolved": "https://registry.npmjs.org/clipboard-polyfill/-/clipboard-polyfill-3.0.3.tgz",@@ -6727,6 +7286,12 @@"url": "https://github.com/sponsors/fb55"}},+ "node_modules/css.escape": {+ "version": "1.5.1",+ "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",+ "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==",+ "dev": true+ },"node_modules/cssdb": {"version": "7.4.1","resolved": "https://registry.npmjs.org/cssdb/-/cssdb-7.4.1.tgz",@@ -6970,6 +7535,18 @@"resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz","integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA=="},+ "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,+ "dependencies": {+ "type-detect": "^4.0.0"+ },+ "engines": {+ "node": ">=6"+ }+ },"node_modules/deep-equal": {"version": "2.2.0","resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.0.tgz",@@ -7158,6 +7735,15 @@"resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz","integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw=="},+ "node_modules/diff": {+ "version": "5.1.0",+ "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz",+ "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==",+ "dev": true,+ "engines": {+ "node": ">=0.3.1"+ }+ },"node_modules/diff-sequences": {"version": "27.5.1","resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.5.1.tgz",@@ -7319,6 +7905,12 @@"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz","integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg=="},+ "node_modules/eastasianwidth": {+ "version": "0.2.0",+ "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",+ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==",+ "dev": true+ },"node_modules/ecdsa-sig-formatter": {"version": "1.0.11","resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",@@ -7559,6 +8151,43 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/esbuild": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.14.tgz",+ "integrity": "sha512-vOO5XhmVj/1XQR9NQ1UPq6qvMYL7QFJU57J5fKBKBKxp17uDt5PgxFDb4A2nEiXhr1qQs4x0F5+66hVVw4ruNw==",+ "dev": true,+ "hasInstallScript": true,+ "bin": {+ "esbuild": "bin/esbuild"+ },+ "engines": {+ "node": ">=12"+ },+ "optionalDependencies": {+ "@esbuild/android-arm": "0.17.14",+ "@esbuild/android-arm64": "0.17.14",+ "@esbuild/android-x64": "0.17.14",+ "@esbuild/darwin-arm64": "0.17.14",+ "@esbuild/darwin-x64": "0.17.14",+ "@esbuild/freebsd-arm64": "0.17.14",+ "@esbuild/freebsd-x64": "0.17.14",+ "@esbuild/linux-arm": "0.17.14",+ "@esbuild/linux-arm64": "0.17.14",+ "@esbuild/linux-ia32": "0.17.14",+ "@esbuild/linux-loong64": "0.17.14",+ "@esbuild/linux-mips64el": "0.17.14",+ "@esbuild/linux-ppc64": "0.17.14",+ "@esbuild/linux-riscv64": "0.17.14",+ "@esbuild/linux-s390x": "0.17.14",+ "@esbuild/linux-x64": "0.17.14",+ "@esbuild/netbsd-x64": "0.17.14",+ "@esbuild/openbsd-x64": "0.17.14",+ "@esbuild/sunos-x64": "0.17.14",+ "@esbuild/win32-arm64": "0.17.14",+ "@esbuild/win32-ia32": "0.17.14",+ "@esbuild/win32-x64": "0.17.14"+ }+ },"node_modules/escalade": {"version": "3.1.1","resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",@@ -9021,6 +9650,15 @@"node": "6.* || 8.* || >= 10.*"}},+ "node_modules/get-func-name": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",+ "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==",+ "dev": true,+ "engines": {+ "node": "*"+ }+ },"node_modules/get-intrinsic": {"version": "1.2.0","resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz",@@ -9246,6 +9884,51 @@"resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-2.0.1.tgz","integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg=="},+ "node_modules/happy-dom": {+ "version": "8.9.0",+ "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-8.9.0.tgz",+ "integrity": "sha512-JZwJuGdR7ko8L61136YzmrLv7LgTh5b8XaEM3P709mLjyQuXJ3zHTDXvUtBBahRjGlcYW0zGjIiEWizoTUGKfA==",+ "dev": true,+ "dependencies": {+ "css.escape": "^1.5.1",+ "he": "^1.2.0",+ "iconv-lite": "^0.6.3",+ "node-fetch": "^2.x.x",+ "webidl-conversions": "^7.0.0",+ "whatwg-encoding": "^2.0.0",+ "whatwg-mimetype": "^3.0.0"+ }+ },+ "node_modules/happy-dom/node_modules/webidl-conversions": {+ "version": "7.0.0",+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",+ "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",+ "dev": true,+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/happy-dom/node_modules/whatwg-encoding": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",+ "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",+ "dev": true,+ "dependencies": {+ "iconv-lite": "0.6.3"+ },+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/happy-dom/node_modules/whatwg-mimetype": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz",+ "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==",+ "dev": true,+ "engines": {+ "node": ">=12"+ }+ },"node_modules/harmony-reflect": {"version": "1.6.2","resolved": "https://registry.npmjs.org/harmony-reflect/-/harmony-reflect-1.6.2.tgz",@@ -11349,6 +12032,12 @@"node": ">=6"}},+ "node_modules/jsonc-parser": {+ "version": "3.2.0",+ "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",+ "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",+ "dev": true+ },"node_modules/jsonfile": {"version": "6.1.0","resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",@@ -11539,6 +12228,18 @@"node": ">=8.9.0"}},+ "node_modules/local-pkg": {+ "version": "0.4.3",+ "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz",+ "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==",+ "dev": true,+ "engines": {+ "node": ">=14"+ },+ "funding": {+ "url": "https://github.com/sponsors/antfu"+ }+ },"node_modules/localforage": {"version": "1.10.0","resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz",@@ -11698,6 +12399,15 @@"node": "^12.20.0 || >=14"}},+ "node_modules/loupe": {+ "version": "2.3.6",+ "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz",+ "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==",+ "dev": true,+ "dependencies": {+ "get-func-name": "^2.0.0"+ }+ },"node_modules/lower-case": {"version": "2.0.2","resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",@@ -11973,6 +12683,18 @@"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==","optional": true},+ "node_modules/mlly": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.2.0.tgz",+ "integrity": "sha512-+c7A3CV0KGdKcylsI6khWyts/CYrGTrRVo4R/I7u/cUsy0Conxa6LUhiEzVKIw14lc2L5aiO4+SeVe4TeGRKww==",+ "dev": true,+ "dependencies": {+ "acorn": "^8.8.2",+ "pathe": "^1.1.0",+ "pkg-types": "^1.0.2",+ "ufo": "^1.1.1"+ }+ },"node_modules/mrmime": {"version": "1.0.1","resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz",@@ -12671,7 +13393,22 @@"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz","integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==","engines": {- "node": ">=8"+ "node": ">=8"+ }+ },+ "node_modules/pathe": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.0.tgz",+ "integrity": "sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==",+ "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,+ "engines": {+ "node": "*"}},"node_modules/performance-now": {@@ -12778,6 +13515,17 @@"node": ">=8"}},+ "node_modules/pkg-types": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.2.tgz",+ "integrity": "sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ==",+ "dev": true,+ "dependencies": {+ "jsonc-parser": "^3.2.0",+ "mlly": "^1.1.1",+ "pathe": "^1.1.0"+ }+ },"node_modules/pkg-up": {"version": "3.1.0","resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz",@@ -14286,6 +15034,11 @@"node": ">= 0.10"}},+ "node_modules/proxy-from-env": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",+ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="+ },"node_modules/psl": {"version": "1.9.0","resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",@@ -15628,6 +16381,12 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/siginfo": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",+ "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",+ "dev": true+ },"node_modules/signal-exit": {"version": "3.0.7","resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",@@ -15706,6 +16465,46 @@"node": ">=6"}},+ "node_modules/slice-ansi": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz",+ "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==",+ "dev": true,+ "dependencies": {+ "ansi-styles": "^6.0.0",+ "is-fullwidth-code-point": "^4.0.0"+ },+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/chalk/slice-ansi?sponsor=1"+ }+ },+ "node_modules/slice-ansi/node_modules/ansi-styles": {+ "version": "6.2.1",+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",+ "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",+ "dev": true,+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"+ }+ },+ "node_modules/slice-ansi/node_modules/is-fullwidth-code-point": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz",+ "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==",+ "dev": true,+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },"node_modules/sockjs": {"version": "0.3.24","resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz",@@ -15879,6 +16678,12 @@"node": ">=8"}},+ "node_modules/stackback": {+ "version": "0.0.2",+ "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",+ "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",+ "dev": true+ },"node_modules/stackframe": {"version": "1.3.4","resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz",@@ -15892,6 +16697,12 @@"node": ">= 0.8"}},+ "node_modules/std-env": {+ "version": "3.3.2",+ "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.2.tgz",+ "integrity": "sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA==",+ "dev": true+ },"node_modules/stop-iteration-iterator": {"version": "1.0.0","resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",@@ -16047,6 +16858,18 @@"node": ">=0.10.0"}},+ "node_modules/strip-literal": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz",+ "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==",+ "dev": true,+ "dependencies": {+ "acorn": "^8.8.2"+ },+ "funding": {+ "url": "https://github.com/sponsors/antfu"+ }+ },"node_modules/style-loader": {"version": "3.3.1","resolved": "https://registry.npmjs.org/style-loader/-/style-loader-3.3.1.tgz",@@ -16561,6 +17384,30 @@"resolved": "https://registry.npmjs.org/timeago.js/-/timeago.js-4.0.2.tgz","integrity": "sha512-a7wPxPdVlQL7lqvitHGGRsofhdwtkoSXPGATFuSOA2i1ZNQEPLrGnj68vOp2sOJTCFAQVXPeNMX/GctBaO9L2w=="},+ "node_modules/tinybench": {+ "version": "2.4.0",+ "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.4.0.tgz",+ "integrity": "sha512-iyziEiyFxX4kyxSp+MtY1oCH/lvjH3PxFN8PGCDeqcZWAJ/i+9y+nL85w99PxVzrIvew/GSkSbDYtiGVa85Afg==",+ "dev": true+ },+ "node_modules/tinypool": {+ "version": "0.4.0",+ "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.4.0.tgz",+ "integrity": "sha512-2ksntHOKf893wSAH4z/+JbPpi92esw8Gn9N2deXX+B0EO92hexAVI9GIZZPx7P5aYo5KULfeOSt3kMOmSOy6uA==",+ "dev": true,+ "engines": {+ "node": ">=14.0.0"+ }+ },+ "node_modules/tinyspy": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-1.1.1.tgz",+ "integrity": "sha512-UVq5AXt/gQlti7oxoIg5oi/9r0WpF7DGEVwXgqWSMmyN16+e3tl5lIvTaOpJ3TAtu5xFzWccFRM4R5NaWHF+4g==",+ "dev": true,+ "engines": {+ "node": ">=14.0.0"+ }+ },"node_modules/tmp": {"version": "0.0.33","resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",@@ -16783,6 +17630,12 @@"node": ">=4.2.0"}},+ "node_modules/ufo": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.1.tgz",+ "integrity": "sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==",+ "dev": true+ },"node_modules/unbox-primitive": {"version": "1.0.2","resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",@@ -16997,6 +17850,189 @@"node": ">= 0.8"}},+ "node_modules/vite": {+ "version": "4.2.1",+ "resolved": "https://registry.npmjs.org/vite/-/vite-4.2.1.tgz",+ "integrity": "sha512-7MKhqdy0ISo4wnvwtqZkjke6XN4taqQ2TBaTccLIpOKv7Vp2h4Y+NpmWCnGDeSvvn45KxvWgGyb0MkHvY1vgbg==",+ "dev": true,+ "dependencies": {+ "esbuild": "^0.17.5",+ "postcss": "^8.4.21",+ "resolve": "^1.22.1",+ "rollup": "^3.18.0"+ },+ "bin": {+ "vite": "bin/vite.js"+ },+ "engines": {+ "node": "^14.18.0 || >=16.0.0"+ },+ "optionalDependencies": {+ "fsevents": "~2.3.2"+ },+ "peerDependencies": {+ "@types/node": ">= 14",+ "less": "*",+ "sass": "*",+ "stylus": "*",+ "sugarss": "*",+ "terser": "^5.4.0"+ },+ "peerDependenciesMeta": {+ "@types/node": {+ "optional": true+ },+ "less": {+ "optional": true+ },+ "sass": {+ "optional": true+ },+ "stylus": {+ "optional": true+ },+ "sugarss": {+ "optional": true+ },+ "terser": {+ "optional": true+ }+ }+ },+ "node_modules/vite-node": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.29.8.tgz",+ "integrity": "sha512-b6OtCXfk65L6SElVM20q5G546yu10/kNrhg08afEoWlFRJXFq9/6glsvSVY+aI6YeC1tu2TtAqI2jHEQmOmsFw==",+ "dev": true,+ "dependencies": {+ "cac": "^6.7.14",+ "debug": "^4.3.4",+ "mlly": "^1.1.0",+ "pathe": "^1.1.0",+ "picocolors": "^1.0.0",+ "vite": "^3.0.0 || ^4.0.0"+ },+ "bin": {+ "vite-node": "vite-node.mjs"+ },+ "engines": {+ "node": ">=v14.16.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/antfu"+ }+ },+ "node_modules/vite/node_modules/rollup": {+ "version": "3.20.2",+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.20.2.tgz",+ "integrity": "sha512-3zwkBQl7Ai7MFYQE0y1MeQ15+9jsi7XxfrqwTb/9EK8D9C9+//EBR4M+CuA1KODRaNbFez/lWxA5vhEGZp4MUg==",+ "dev": true,+ "bin": {+ "rollup": "dist/bin/rollup"+ },+ "engines": {+ "node": ">=14.18.0",+ "npm": ">=8.0.0"+ },+ "optionalDependencies": {+ "fsevents": "~2.3.2"+ }+ },+ "node_modules/vitest": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.29.8.tgz",+ "integrity": "sha512-JIAVi2GK5cvA6awGpH0HvH/gEG9PZ0a/WoxdiV3PmqK+3CjQMf8c+J/Vhv4mdZ2nRyXFw66sAg6qz7VNkaHfDQ==",+ "dev": true,+ "dependencies": {+ "@types/chai": "^4.3.4",+ "@types/chai-subset": "^1.3.3",+ "@types/node": "*",+ "@vitest/expect": "0.29.8",+ "@vitest/runner": "0.29.8",+ "@vitest/spy": "0.29.8",+ "@vitest/utils": "0.29.8",+ "acorn": "^8.8.1",+ "acorn-walk": "^8.2.0",+ "cac": "^6.7.14",+ "chai": "^4.3.7",+ "debug": "^4.3.4",+ "local-pkg": "^0.4.2",+ "pathe": "^1.1.0",+ "picocolors": "^1.0.0",+ "source-map": "^0.6.1",+ "std-env": "^3.3.1",+ "strip-literal": "^1.0.0",+ "tinybench": "^2.3.1",+ "tinypool": "^0.4.0",+ "tinyspy": "^1.0.2",+ "vite": "^3.0.0 || ^4.0.0",+ "vite-node": "0.29.8",+ "why-is-node-running": "^2.2.2"+ },+ "bin": {+ "vitest": "vitest.mjs"+ },+ "engines": {+ "node": ">=v14.16.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/antfu"+ },+ "peerDependencies": {+ "@edge-runtime/vm": "*",+ "@vitest/browser": "*",+ "@vitest/ui": "*",+ "happy-dom": "*",+ "jsdom": "*",+ "playwright": "*",+ "safaridriver": "*",+ "webdriverio": "*"+ },+ "peerDependenciesMeta": {+ "@edge-runtime/vm": {+ "optional": true+ },+ "@vitest/browser": {+ "optional": true+ },+ "@vitest/ui": {+ "optional": true+ },+ "happy-dom": {+ "optional": true+ },+ "jsdom": {+ "optional": true+ },+ "playwright": {+ "optional": true+ },+ "safaridriver": {+ "optional": true+ },+ "webdriverio": {+ "optional": true+ }+ }+ },+ "node_modules/vitest/node_modules/acorn-walk": {+ "version": "8.2.0",+ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",+ "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",+ "dev": true,+ "engines": {+ "node": ">=0.4.0"+ }+ },+ "node_modules/vitest/node_modules/source-map": {+ "version": "0.6.1",+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",+ "dev": true,+ "engines": {+ "node": ">=0.10.0"+ }+ },"node_modules/w3c-hr-time": {"version": "1.0.2","resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz",@@ -17540,6 +18576,22 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/why-is-node-running": {+ "version": "2.2.2",+ "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz",+ "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==",+ "dev": true,+ "dependencies": {+ "siginfo": "^2.0.0",+ "stackback": "0.0.2"+ },+ "bin": {+ "why-is-node-running": "cli.js"+ },+ "engines": {+ "node": ">=8"+ }+ },"node_modules/word-wrap": {"version": "1.2.3","resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",@@ -19622,25 +20674,179 @@"resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.2.1.tgz","integrity": "sha512-zxRBwl93sHMsOj4zs+OslQKg/uhF38MB+OMKoCrVuS0nyTkqnau+BM3WGEoOptg9Oz45T/aIGs1qbVAsEFo3nA=="},- "@emotion/unitless": {- "version": "0.8.0",- "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.0.tgz",- "integrity": "sha512-VINS5vEYAscRl2ZUDiT3uMPlrFQupiKgHz5AA4bCH1miKBg4qtwkim1qPmJj/4WG6TreYMY111rEFsjupcOKHw=="+ "@emotion/unitless": {+ "version": "0.8.0",+ "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.0.tgz",+ "integrity": "sha512-VINS5vEYAscRl2ZUDiT3uMPlrFQupiKgHz5AA4bCH1miKBg4qtwkim1qPmJj/4WG6TreYMY111rEFsjupcOKHw=="+ },+ "@emotion/use-insertion-effect-with-fallbacks": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.0.tgz",+ "integrity": "sha512-1eEgUGmkaljiBnRMTdksDV1W4kUnmwgp7X9G8B++9GYwl1lUdqSndSriIrTJ0N7LQaoauY9JJ2yhiOYK5+NI4A=="+ },+ "@emotion/utils": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.2.0.tgz",+ "integrity": "sha512-sn3WH53Kzpw8oQ5mgMmIzzyAaH2ZqFEbozVVBSYp538E06OSE6ytOp7pRAjNQR+Q/orwqdQYJSe2m3hCOeznkw=="+ },+ "@emotion/weak-memoize": {+ "version": "0.3.0",+ "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.0.tgz",+ "integrity": "sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg=="+ },+ "@esbuild/android-arm": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.14.tgz",+ "integrity": "sha512-0CnlwnjDU8cks0yJLXfkaU/uoLyRf9VZJs4p1PskBr2AlAHeEsFEwJEo0of/Z3g+ilw5mpyDwThlxzNEIxOE4g==",+ "dev": true,+ "optional": true+ },+ "@esbuild/android-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.14.tgz",+ "integrity": "sha512-eLOpPO1RvtsP71afiFTvS7tVFShJBCT0txiv/xjFBo5a7R7Gjw7X0IgIaFoLKhqXYAXhahoXm7qAmRXhY4guJg==",+ "dev": true,+ "optional": true+ },+ "@esbuild/android-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.14.tgz",+ "integrity": "sha512-nrfQYWBfLGfSGLvRVlt6xi63B5IbfHm3tZCdu/82zuFPQ7zez4XjmRtF/wIRYbJQ/DsZrxJdEvYFE67avYXyng==",+ "dev": true,+ "optional": true+ },+ "@esbuild/darwin-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.14.tgz",+ "integrity": "sha512-eoSjEuDsU1ROwgBH/c+fZzuSyJUVXQTOIN9xuLs9dE/9HbV/A5IqdXHU1p2OfIMwBwOYJ9SFVGGldxeRCUJFyw==",+ "dev": true,+ "optional": true+ },+ "@esbuild/darwin-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.14.tgz",+ "integrity": "sha512-zN0U8RWfrDttdFNkHqFYZtOH8hdi22z0pFm0aIJPsNC4QQZv7je8DWCX5iA4Zx6tRhS0CCc0XC2m7wKsbWEo5g==",+ "dev": true,+ "optional": true+ },+ "@esbuild/freebsd-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.14.tgz",+ "integrity": "sha512-z0VcD4ibeZWVQCW1O7szaLxGsx54gcCnajEJMdYoYjLiq4g1jrP2lMq6pk71dbS5+7op/L2Aod+erw+EUr28/A==",+ "dev": true,+ "optional": true+ },+ "@esbuild/freebsd-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.14.tgz",+ "integrity": "sha512-hd9mPcxfTgJlolrPlcXkQk9BMwNBvNBsVaUe5eNUqXut6weDQH8whcNaKNF2RO8NbpT6GY8rHOK2A9y++s+ehw==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-arm": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.14.tgz",+ "integrity": "sha512-BNTl+wSJ1omsH8s3TkQmIIIQHwvwJrU9u1ggb9XU2KTVM4TmthRIVyxSp2qxROJHhZuW/r8fht46/QE8hU8Qvg==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.14.tgz",+ "integrity": "sha512-FhAMNYOq3Iblcj9i+K0l1Fp/MHt+zBeRu/Qkf0LtrcFu3T45jcwB6A1iMsemQ42vR3GBhjNZJZTaCe3VFPbn9g==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-ia32": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.14.tgz",+ "integrity": "sha512-91OK/lQ5y2v7AsmnFT+0EyxdPTNhov3y2CWMdizyMfxSxRqHazXdzgBKtlmkU2KYIc+9ZK3Vwp2KyXogEATYxQ==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-loong64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.14.tgz",+ "integrity": "sha512-vp15H+5NR6hubNgMluqqKza85HcGJgq7t6rMH7O3Y6ApiOWPkvW2AJfNojUQimfTp6OUrACUXfR4hmpcENXoMQ==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-mips64el": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.14.tgz",+ "integrity": "sha512-90TOdFV7N+fgi6c2+GO9ochEkmm9kBAKnuD5e08GQMgMINOdOFHuYLPQ91RYVrnWwQ5683sJKuLi9l4SsbJ7Hg==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-ppc64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.14.tgz",+ "integrity": "sha512-NnBGeoqKkTugpBOBZZoktQQ1Yqb7aHKmHxsw43NddPB2YWLAlpb7THZIzsRsTr0Xw3nqiPxbA1H31ZMOG+VVPQ==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-riscv64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.14.tgz",+ "integrity": "sha512-0qdlKScLXA8MGVy21JUKvMzCYWovctuP8KKqhtE5A6IVPq4onxXhSuhwDd2g5sRCzNDlDjitc5sX31BzDoL5Fw==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-s390x": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.14.tgz",+ "integrity": "sha512-Hdm2Jo1yaaOro4v3+6/zJk6ygCqIZuSDJHdHaf8nVH/tfOuoEX5Riv03Ka15LmQBYJObUTNS1UdyoMk0WUn9Ww==",+ "dev": true,+ "optional": true+ },+ "@esbuild/linux-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.14.tgz",+ "integrity": "sha512-8KHF17OstlK4DuzeF/KmSgzrTWQrkWj5boluiiq7kvJCiQVzUrmSkaBvcLB2UgHpKENO2i6BthPkmUhNDaJsVw==",+ "dev": true,+ "optional": true+ },+ "@esbuild/netbsd-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.14.tgz",+ "integrity": "sha512-nVwpqvb3yyXztxIT2+VsxJhB5GCgzPdk1n0HHSnchRAcxqKO6ghXwHhJnr0j/B+5FSyEqSxF4q03rbA2fKXtUQ==",+ "dev": true,+ "optional": true+ },+ "@esbuild/openbsd-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.14.tgz",+ "integrity": "sha512-1RZ7uQQ9zcy/GSAJL1xPdN7NDdOOtNEGiJalg/MOzeakZeTrgH/DoCkbq7TaPDiPhWqnDF+4bnydxRqQD7il6g==",+ "dev": true,+ "optional": true+ },+ "@esbuild/sunos-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.14.tgz",+ "integrity": "sha512-nqMjDsFwv7vp7msrwWRysnM38Sd44PKmW8EzV01YzDBTcTWUpczQg6mGao9VLicXSgW/iookNK6AxeogNVNDZA==",+ "dev": true,+ "optional": true},- "@emotion/use-insertion-effect-with-fallbacks": {- "version": "1.0.0",- "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.0.tgz",- "integrity": "sha512-1eEgUGmkaljiBnRMTdksDV1W4kUnmwgp7X9G8B++9GYwl1lUdqSndSriIrTJ0N7LQaoauY9JJ2yhiOYK5+NI4A=="+ "@esbuild/win32-arm64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.14.tgz",+ "integrity": "sha512-xrD0mccTKRBBIotrITV7WVQAwNJ5+1va6L0H9zN92v2yEdjfAN7864cUaZwJS7JPEs53bDTzKFbfqVlG2HhyKQ==",+ "dev": true,+ "optional": true},- "@emotion/utils": {- "version": "1.2.0",- "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.2.0.tgz",- "integrity": "sha512-sn3WH53Kzpw8oQ5mgMmIzzyAaH2ZqFEbozVVBSYp538E06OSE6ytOp7pRAjNQR+Q/orwqdQYJSe2m3hCOeznkw=="+ "@esbuild/win32-ia32": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.14.tgz",+ "integrity": "sha512-nXpkz9bbJrLLyUTYtRotSS3t5b+FOuljg8LgLdINWFs3FfqZMtbnBCZFUmBzQPyxqU87F8Av+3Nco/M3hEcu1w==",+ "dev": true,+ "optional": true},- "@emotion/weak-memoize": {- "version": "0.3.0",- "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.0.tgz",- "integrity": "sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg=="+ "@esbuild/win32-x64": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.14.tgz",+ "integrity": "sha512-gPQmsi2DKTaEgG14hc3CHXHp62k8g6qr0Pas+I4lUxRMugGSATh/Bi8Dgusoz9IQ0IfdrvLpco6kujEIBoaogA==",+ "dev": true,+ "optional": true},"@eslint/eslintrc": {"version": "1.4.1",@@ -20940,6 +22146,21 @@"@types/node": "*"}},+ "@types/chai": {+ "version": "4.3.4",+ "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.4.tgz",+ "integrity": "sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==",+ "dev": true+ },+ "@types/chai-subset": {+ "version": "1.3.3",+ "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.3.tgz",+ "integrity": "sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==",+ "dev": true,+ "requires": {+ "@types/chai": "*"+ }+ },"@types/connect": {"version": "3.4.35","resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",@@ -21380,6 +22601,66 @@"resolved": "https://registry.npmjs.org/@virtuoso.dev/urx/-/urx-0.2.13.tgz","integrity": "sha512-iirJNv92A1ZWxoOHHDYW/1KPoi83939o83iUBQHIim0i3tMeSKEh+bxhJdTHQ86Mr4uXx9xGUTq69cp52ZP8Xw=="},+ "@vitest/expect": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.29.8.tgz",+ "integrity": "sha512-xlcVXn5I5oTq6NiZSY3ykyWixBxr5mG8HYtjvpgg6KaqHm0mvhX18xuwl5YGxIRNt/A5jidd7CWcNHrSvgaQqQ==",+ "dev": true,+ "requires": {+ "@vitest/spy": "0.29.8",+ "@vitest/utils": "0.29.8",+ "chai": "^4.3.7"+ }+ },+ "@vitest/runner": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.29.8.tgz",+ "integrity": "sha512-FzdhnRDwEr/A3Oo1jtIk/B952BBvP32n1ObMEb23oEJNO+qO5cBet6M2XWIDQmA7BDKGKvmhUf2naXyp/2JEwQ==",+ "dev": true,+ "requires": {+ "@vitest/utils": "0.29.8",+ "p-limit": "^4.0.0",+ "pathe": "^1.1.0"+ },+ "dependencies": {+ "p-limit": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz",+ "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==",+ "dev": true,+ "requires": {+ "yocto-queue": "^1.0.0"+ }+ },+ "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+ }+ }+ },+ "@vitest/spy": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.29.8.tgz",+ "integrity": "sha512-VdjBe9w34vOMl5I5mYEzNX8inTxrZ+tYUVk9jxaZJmHFwmDFC/GV3KBFTA/JKswr3XHvZL+FE/yq5EVhb6pSAw==",+ "dev": true,+ "requires": {+ "tinyspy": "^1.0.2"+ }+ },+ "@vitest/utils": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.29.8.tgz",+ "integrity": "sha512-qGzuf3vrTbnoY+RjjVVIBYfuWMjn3UMUqyQtdGNZ6ZIIyte7B37exj6LaVkrZiUTvzSadVvO/tJm8AEgbGCBPg==",+ "dev": true,+ "requires": {+ "cli-truncate": "^3.1.0",+ "diff": "^5.1.0",+ "loupe": "^2.3.6",+ "pretty-format": "^27.5.1"+ }+ },"@webassemblyjs/ast": {"version": "1.11.1","resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz",@@ -21777,6 +23058,12 @@"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz","integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA=="},+ "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+ },"ast-types-flow": {"version": "0.0.7","resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz",@@ -21841,11 +23128,25 @@"integrity": "sha512-/BQzOX780JhsxDnPpH4ZiyrJAzcd8AfzFPkv+89veFSr1rcMjuq2JDCwypKaPeB6ljHp9KjXhPpjgCvQlWYuqg=="},"axios": {- "version": "0.21.4",- "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",- "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",+ "version": "1.3.4",+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",+ "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==","requires": {- "follow-redirects": "^1.14.0"+ "follow-redirects": "^1.15.0",+ "form-data": "^4.0.0",+ "proxy-from-env": "^1.1.0"+ },+ "dependencies": {+ "form-data": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",+ "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",+ "requires": {+ "asynckit": "^0.4.0",+ "combined-stream": "^1.0.8",+ "mime-types": "^2.1.12"+ }+ }}},"axobject-query": {@@ -22260,6 +23561,12 @@"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz","integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw=="},+ "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+ },"call-bind": {"version": "1.0.2","resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",@@ -22321,6 +23628,21 @@"resolved": "https://registry.npmjs.org/case-sensitive-paths-webpack-plugin/-/case-sensitive-paths-webpack-plugin-2.4.0.tgz","integrity": "sha512-roIFONhcxog0JSSWbvVAh3OocukmSgpqOH6YpMkCvav/ySIV3JKg4Dc8vYtQjYi/UxpNE36r/9v+VqTQqgkYmw=="},+ "chai": {+ "version": "4.3.7",+ "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz",+ "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==",+ "dev": true,+ "requires": {+ "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",+ "pathval": "^1.1.1",+ "type-detect": "^4.0.5"+ }+ },"chalk": {"version": "4.1.2","resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",@@ -22335,6 +23657,12 @@"resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz","integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw=="},+ "check-error": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",+ "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==",+ "dev": true+ },"check-types": {"version": "11.2.2","resolved": "https://registry.npmjs.org/check-types/-/check-types-11.2.2.tgz",@@ -22407,6 +23735,44 @@}}},+ "cli-truncate": {+ "version": "3.1.0",+ "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz",+ "integrity": "sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==",+ "dev": true,+ "requires": {+ "slice-ansi": "^5.0.0",+ "string-width": "^5.0.0"+ },+ "dependencies": {+ "ansi-regex": {+ "version": "6.0.1",+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz",+ "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==",+ "dev": true+ },+ "string-width": {+ "version": "5.1.2",+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",+ "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",+ "dev": true,+ "requires": {+ "eastasianwidth": "^0.2.0",+ "emoji-regex": "^9.2.2",+ "strip-ansi": "^7.0.1"+ }+ },+ "strip-ansi": {+ "version": "7.0.1",+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz",+ "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==",+ "dev": true,+ "requires": {+ "ansi-regex": "^6.0.1"+ }+ }+ }+ },"clipboard-polyfill": {"version": "3.0.3","resolved": "https://registry.npmjs.org/clipboard-polyfill/-/clipboard-polyfill-3.0.3.tgz",@@ -22808,6 +24174,12 @@"resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz","integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw=="},+ "css.escape": {+ "version": "1.5.1",+ "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",+ "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==",+ "dev": true+ },"cssdb": {"version": "7.4.1","resolved": "https://registry.npmjs.org/cssdb/-/cssdb-7.4.1.tgz",@@ -22990,6 +24362,15 @@"resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz","integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA=="},+ "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,+ "requires": {+ "type-detect": "^4.0.0"+ }+ },"deep-equal": {"version": "2.2.0","resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.0.tgz",@@ -23127,6 +24508,12 @@"resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz","integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw=="},+ "diff": {+ "version": "5.1.0",+ "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz",+ "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==",+ "dev": true+ },"diff-sequences": {"version": "27.5.1","resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.5.1.tgz",@@ -23253,6 +24640,12 @@"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz","integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg=="},+ "eastasianwidth": {+ "version": "0.2.0",+ "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",+ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==",+ "dev": true+ },"ecdsa-sig-formatter": {"version": "1.0.11","resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",@@ -23442,6 +24835,36 @@"is-symbol": "^1.0.2"}},+ "esbuild": {+ "version": "0.17.14",+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.14.tgz",+ "integrity": "sha512-vOO5XhmVj/1XQR9NQ1UPq6qvMYL7QFJU57J5fKBKBKxp17uDt5PgxFDb4A2nEiXhr1qQs4x0F5+66hVVw4ruNw==",+ "dev": true,+ "requires": {+ "@esbuild/android-arm": "0.17.14",+ "@esbuild/android-arm64": "0.17.14",+ "@esbuild/android-x64": "0.17.14",+ "@esbuild/darwin-arm64": "0.17.14",+ "@esbuild/darwin-x64": "0.17.14",+ "@esbuild/freebsd-arm64": "0.17.14",+ "@esbuild/freebsd-x64": "0.17.14",+ "@esbuild/linux-arm": "0.17.14",+ "@esbuild/linux-arm64": "0.17.14",+ "@esbuild/linux-ia32": "0.17.14",+ "@esbuild/linux-loong64": "0.17.14",+ "@esbuild/linux-mips64el": "0.17.14",+ "@esbuild/linux-ppc64": "0.17.14",+ "@esbuild/linux-riscv64": "0.17.14",+ "@esbuild/linux-s390x": "0.17.14",+ "@esbuild/linux-x64": "0.17.14",+ "@esbuild/netbsd-x64": "0.17.14",+ "@esbuild/openbsd-x64": "0.17.14",+ "@esbuild/sunos-x64": "0.17.14",+ "@esbuild/win32-arm64": "0.17.14",+ "@esbuild/win32-ia32": "0.17.14",+ "@esbuild/win32-x64": "0.17.14"+ }+ },"escalade": {"version": "3.1.1","resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",@@ -24526,6 +25949,12 @@"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz","integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="},+ "get-func-name": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",+ "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==",+ "dev": true+ },"get-intrinsic": {"version": "1.2.0","resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz",@@ -24689,6 +26118,44 @@"resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-2.0.1.tgz","integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg=="},+ "happy-dom": {+ "version": "8.9.0",+ "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-8.9.0.tgz",+ "integrity": "sha512-JZwJuGdR7ko8L61136YzmrLv7LgTh5b8XaEM3P709mLjyQuXJ3zHTDXvUtBBahRjGlcYW0zGjIiEWizoTUGKfA==",+ "dev": true,+ "requires": {+ "css.escape": "^1.5.1",+ "he": "^1.2.0",+ "iconv-lite": "^0.6.3",+ "node-fetch": "^2.x.x",+ "webidl-conversions": "^7.0.0",+ "whatwg-encoding": "^2.0.0",+ "whatwg-mimetype": "^3.0.0"+ },+ "dependencies": {+ "webidl-conversions": {+ "version": "7.0.0",+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",+ "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",+ "dev": true+ },+ "whatwg-encoding": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",+ "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",+ "dev": true,+ "requires": {+ "iconv-lite": "0.6.3"+ }+ },+ "whatwg-mimetype": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz",+ "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==",+ "dev": true+ }+ }+ },"harmony-reflect": {"version": "1.6.2","resolved": "https://registry.npmjs.org/harmony-reflect/-/harmony-reflect-1.6.2.tgz",@@ -26213,6 +27680,12 @@"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz","integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="},+ "jsonc-parser": {+ "version": "3.2.0",+ "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",+ "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",+ "dev": true+ },"jsonfile": {"version": "6.1.0","resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",@@ -26368,6 +27841,12 @@"json5": "^2.1.2"}},+ "local-pkg": {+ "version": "0.4.3",+ "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz",+ "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==",+ "dev": true+ },"localforage": {"version": "1.10.0","resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz",@@ -26504,6 +27983,15 @@}}},+ "loupe": {+ "version": "2.3.6",+ "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz",+ "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==",+ "dev": true,+ "requires": {+ "get-func-name": "^2.0.0"+ }+ },"lower-case": {"version": "2.0.2","resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",@@ -26705,6 +28193,18 @@"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==","optional": true},+ "mlly": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.2.0.tgz",+ "integrity": "sha512-+c7A3CV0KGdKcylsI6khWyts/CYrGTrRVo4R/I7u/cUsy0Conxa6LUhiEzVKIw14lc2L5aiO4+SeVe4TeGRKww==",+ "dev": true,+ "requires": {+ "acorn": "^8.8.2",+ "pathe": "^1.1.0",+ "pkg-types": "^1.0.2",+ "ufo": "^1.1.1"+ }+ },"mrmime": {"version": "1.0.1","resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz",@@ -27222,6 +28722,18 @@"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz","integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw=="},+ "pathe": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.0.tgz",+ "integrity": "sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==",+ "dev": true+ },+ "pathval": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",+ "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==",+ "dev": true+ },"performance-now": {"version": "2.1.0","resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",@@ -27295,6 +28807,17 @@}}},+ "pkg-types": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.2.tgz",+ "integrity": "sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ==",+ "dev": true,+ "requires": {+ "jsonc-parser": "^3.2.0",+ "mlly": "^1.1.1",+ "pathe": "^1.1.0"+ }+ },"pkg-up": {"version": "3.1.0","resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz",@@ -28197,6 +29720,11 @@}}},+ "proxy-from-env": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",+ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="+ },"psl": {"version": "1.9.0","resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",@@ -29179,6 +30707,12 @@"object-inspect": "^1.9.0"}},+ "siginfo": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",+ "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",+ "dev": true+ },"signal-exit": {"version": "3.0.7","resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",@@ -29223,6 +30757,30 @@"integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==","dev": true},+ "slice-ansi": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz",+ "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==",+ "dev": true,+ "requires": {+ "ansi-styles": "^6.0.0",+ "is-fullwidth-code-point": "^4.0.0"+ },+ "dependencies": {+ "ansi-styles": {+ "version": "6.2.1",+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",+ "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",+ "dev": true+ },+ "is-fullwidth-code-point": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz",+ "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==",+ "dev": true+ }+ }+ },"sockjs": {"version": "0.3.24","resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz",@@ -29362,6 +30920,12 @@}}},+ "stackback": {+ "version": "0.0.2",+ "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",+ "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",+ "dev": true+ },"stackframe": {"version": "1.3.4","resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz",@@ -29372,6 +30936,12 @@"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz","integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ=="},+ "std-env": {+ "version": "3.3.2",+ "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.2.tgz",+ "integrity": "sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA==",+ "dev": true+ },"stop-iteration-iterator": {"version": "1.0.0","resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",@@ -29493,6 +31063,15 @@"integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==","optional": true},+ "strip-literal": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz",+ "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==",+ "dev": true,+ "requires": {+ "acorn": "^8.8.2"+ }+ },"style-loader": {"version": "3.3.1","resolved": "https://registry.npmjs.org/style-loader/-/style-loader-3.3.1.tgz",@@ -29884,6 +31463,24 @@"resolved": "https://registry.npmjs.org/timeago.js/-/timeago.js-4.0.2.tgz","integrity": "sha512-a7wPxPdVlQL7lqvitHGGRsofhdwtkoSXPGATFuSOA2i1ZNQEPLrGnj68vOp2sOJTCFAQVXPeNMX/GctBaO9L2w=="},+ "tinybench": {+ "version": "2.4.0",+ "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.4.0.tgz",+ "integrity": "sha512-iyziEiyFxX4kyxSp+MtY1oCH/lvjH3PxFN8PGCDeqcZWAJ/i+9y+nL85w99PxVzrIvew/GSkSbDYtiGVa85Afg==",+ "dev": true+ },+ "tinypool": {+ "version": "0.4.0",+ "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.4.0.tgz",+ "integrity": "sha512-2ksntHOKf893wSAH4z/+JbPpi92esw8Gn9N2deXX+B0EO92hexAVI9GIZZPx7P5aYo5KULfeOSt3kMOmSOy6uA==",+ "dev": true+ },+ "tinyspy": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-1.1.1.tgz",+ "integrity": "sha512-UVq5AXt/gQlti7oxoIg5oi/9r0WpF7DGEVwXgqWSMmyN16+e3tl5lIvTaOpJ3TAtu5xFzWccFRM4R5NaWHF+4g==",+ "dev": true+ },"tmp": {"version": "0.0.33","resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",@@ -30049,6 +31646,12 @@"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==","dev": true},+ "ufo": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.1.tgz",+ "integrity": "sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==",+ "dev": true+ },"unbox-primitive": {"version": "1.0.2","resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",@@ -30199,6 +31802,90 @@"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz","integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="},+ "vite": {+ "version": "4.2.1",+ "resolved": "https://registry.npmjs.org/vite/-/vite-4.2.1.tgz",+ "integrity": "sha512-7MKhqdy0ISo4wnvwtqZkjke6XN4taqQ2TBaTccLIpOKv7Vp2h4Y+NpmWCnGDeSvvn45KxvWgGyb0MkHvY1vgbg==",+ "dev": true,+ "requires": {+ "esbuild": "^0.17.5",+ "fsevents": "~2.3.2",+ "postcss": "^8.4.21",+ "resolve": "^1.22.1",+ "rollup": "^3.18.0"+ },+ "dependencies": {+ "rollup": {+ "version": "3.20.2",+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.20.2.tgz",+ "integrity": "sha512-3zwkBQl7Ai7MFYQE0y1MeQ15+9jsi7XxfrqwTb/9EK8D9C9+//EBR4M+CuA1KODRaNbFez/lWxA5vhEGZp4MUg==",+ "dev": true,+ "requires": {+ "fsevents": "~2.3.2"+ }+ }+ }+ },+ "vite-node": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.29.8.tgz",+ "integrity": "sha512-b6OtCXfk65L6SElVM20q5G546yu10/kNrhg08afEoWlFRJXFq9/6glsvSVY+aI6YeC1tu2TtAqI2jHEQmOmsFw==",+ "dev": true,+ "requires": {+ "cac": "^6.7.14",+ "debug": "^4.3.4",+ "mlly": "^1.1.0",+ "pathe": "^1.1.0",+ "picocolors": "^1.0.0",+ "vite": "^3.0.0 || ^4.0.0"+ }+ },+ "vitest": {+ "version": "0.29.8",+ "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.29.8.tgz",+ "integrity": "sha512-JIAVi2GK5cvA6awGpH0HvH/gEG9PZ0a/WoxdiV3PmqK+3CjQMf8c+J/Vhv4mdZ2nRyXFw66sAg6qz7VNkaHfDQ==",+ "dev": true,+ "requires": {+ "@types/chai": "^4.3.4",+ "@types/chai-subset": "^1.3.3",+ "@types/node": "*",+ "@vitest/expect": "0.29.8",+ "@vitest/runner": "0.29.8",+ "@vitest/spy": "0.29.8",+ "@vitest/utils": "0.29.8",+ "acorn": "^8.8.1",+ "acorn-walk": "^8.2.0",+ "cac": "^6.7.14",+ "chai": "^4.3.7",+ "debug": "^4.3.4",+ "local-pkg": "^0.4.2",+ "pathe": "^1.1.0",+ "picocolors": "^1.0.0",+ "source-map": "^0.6.1",+ "std-env": "^3.3.1",+ "strip-literal": "^1.0.0",+ "tinybench": "^2.3.1",+ "tinypool": "^0.4.0",+ "tinyspy": "^1.0.2",+ "vite": "^3.0.0 || ^4.0.0",+ "vite-node": "0.29.8",+ "why-is-node-running": "^2.2.2"+ },+ "dependencies": {+ "acorn-walk": {+ "version": "8.2.0",+ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",+ "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",+ "dev": true+ },+ "source-map": {+ "version": "0.6.1",+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",+ "dev": true+ }+ }+ },"w3c-hr-time": {"version": "1.0.2","resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz",@@ -30593,6 +32280,16 @@"is-typed-array": "^1.1.10"}},+ "why-is-node-running": {+ "version": "2.2.2",+ "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz",+ "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==",+ "dev": true,+ "requires": {+ "siginfo": "^2.0.0",+ "stackback": "0.0.2"+ }+ },"word-wrap": {"version": "1.2.3","resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",diff --git a/apps/web/package.json b/apps/web/package.jsonindex fef0c2972..bab371736 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -32,7 +32,7 @@"@theme-ui/core": "^0.14.7","allotment": "^1.12.1","async-mutex": "^0.3.2",- "axios": "^0.21.4",+ "axios": "^1.3.4","clipboard-polyfill": "^3.0.3","comlink": "^4.3.1","cronosjs": "^1.7.1",@@ -85,6 +85,7 @@"env-cmd": "^10.1.0","file-loader": "^6.2.0","find-process": "^1.4.4",+ "happy-dom": "^8.9.0","ip": "^1.1.8","lorem-ipsum": "^2.0.4","otplib": "^12.0.1",@@ -94,6 +95,7 @@"react-dom": "17.0.2","source-map-explorer": "^2.5.2","typescript": "^4.8.2",+ "vitest": "^0.29.8","webpack-bundle-analyzer": "^4.8.0","worker-loader": "^3.0.8"},diff --git a/apps/web/public/stream-saver-sw.js b/apps/web/public/stream-saver-sw.jsnew file mode 100644index 000000000..79161736c--- /dev/null+++ b/apps/web/public/stream-saver-sw.js@@ -0,0 +1,154 @@+/*+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/>.+*/+/* eslint-disable no-restricted-globals */++self.addEventListener("install", () => {+ self.skipWaiting();+});++self.addEventListener("activate", (event) => {+ event.waitUntil(self.clients.claim());+});++const map = new Map();++// This should be called once per download+// Each event has a dataChannel that the data will be piped through+self.onmessage = (event) => {+ // We send a heartbeat every x second to keep the+ // service worker alive if a transferable stream is not sent+ if (event.data === "ping") {+ return;+ }++ const data = event.data;+ const downloadUrl =+ data.url ||+ self.registration.scope ++ Math.random() ++ "/" ++ (typeof data === "string" ? data : data.filename);+ const port = event.ports[0];+ const metadata = new Array(3); // [stream, data, port]++ metadata[1] = data;+ metadata[2] = port;++ if (event.data.transferringReadable) {+ port.onmessage = (evt) => {+ port.onmessage = null;+ metadata[0] = evt.data.readableStream;+ };+ } else {+ metadata[0] = createStream(port);+ }++ map.set(downloadUrl, metadata);+ port.postMessage({ download: downloadUrl });+};++function createStream(port) {+ // ReadableStream is only supported by chrome 52+ return new ReadableStream({+ start(controller) {+ // When we receive data on the messageChannel, we write+ port.onmessage = ({ data }) => {+ if (data === "end") {+ return controller.close();+ }++ if (data === "abort") {+ controller.error("Aborted the download");+ return;+ }++ controller.enqueue(data);+ };+ },+ cancel(reason) {+ console.log("user aborted", reason);+ port.postMessage({ abort: true });+ }+ });+}++self.onfetch = (event) => {+ const url = event.request.url;++ // this only works for Firefox+ if (url.endsWith("/ping")) {+ return event.respondWith(new Response("pong"));+ }++ const metadata = map.get(url);+ if (!metadata) return null;++ const [stream, data, port] = metadata;++ map.delete(url);++ // Not comfortable letting any user control all headers+ // so we only copy over the length & disposition+ const responseHeaders = new Headers({+ "Content-Type": "application/octet-stream; charset=utf-8",++ // To be on the safe side, The link can be opened in a iframe.+ // but octet-stream should stop it.+ "Content-Security-Policy": "default-src 'none'",+ "X-Content-Security-Policy": "default-src 'none'",+ "X-WebKit-CSP": "default-src 'none'",+ "X-XSS-Protection": "1; mode=block"+ });++ let headers = new Headers(data.headers || {});++ if (headers.has("Content-Length")) {+ responseHeaders.set("Content-Length", headers.get("Content-Length"));+ }++ if (headers.has("Content-Disposition")) {+ responseHeaders.set(+ "Content-Disposition",+ headers.get("Content-Disposition")+ );+ }++ // data, data.filename and size should not be used anymore+ if (data.size) {+ console.warn("Depricated");+ responseHeaders.set("Content-Length", data.size);+ }++ let fileName = typeof data === "string" ? data : data.filename;+ if (fileName) {+ console.warn("Depricated");+ // Make filename RFC5987 compatible+ fileName = encodeURIComponent(fileName)+ .replace(/['()]/g, escape)+ .replace(/\*/g, "%2A");+ responseHeaders.set(+ "Content-Disposition",+ "attachment; filename*=UTF-8''" + fileName+ );+ }++ event.respondWith(new Response(stream, { headers: responseHeaders }));++ port.postMessage({ debug: "Download started" });+};diff --git a/apps/web/src/common/attachment-stream.ts b/apps/web/src/common/attachment-stream.tsnew file mode 100644index 000000000..8ec5f4281--- /dev/null+++ b/apps/web/src/common/attachment-stream.ts@@ -0,0 +1,66 @@+/*+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/>.+*/++import { decryptFile } from "../interfaces/fs";+import { db } from "./db";+import { ZipFile } from "../utils/zip-stream";++export const METADATA_FILENAME = "metadata.json";++export class AttachmentStream extends ReadableStream<ZipFile> {+ constructor(attachments: Array<any>) {+ let index = 0;+ super({+ start() {},+ async pull(controller) {+ const attachment = attachments[index++];++ await db.fs.downloadFile(+ "all-attachments",+ attachment.metadata.hash,+ attachment.chunkSize,+ attachment.metadata+ );++ const key = await db.attachments?.decryptKey(attachment.key);+ const file = await decryptFile(attachment.metadata.hash, {+ key,+ iv: attachment.iv,+ name: attachment.metadata.filename,+ type: attachment.metadata.type,+ isUploaded: !!attachment.dateUploaded+ });++ if (file) {+ const filePath = `/${attachment.metadata.filename}`;+ controller.enqueue({+ path: filePath,+ data: new Uint8Array(await file.arrayBuffer())+ });+ } else {+ controller.error(new Error("Failed to decrypt file."));+ }++ if (index === attachments.length) {+ controller.close();+ }+ }+ });+ }+}diff --git a/apps/web/src/common/attachments/attachment-stream.ts b/apps/web/src/common/attachments/attachment-stream.tsdeleted file mode 100644index 3be132652..000000000--- a/apps/web/src/common/attachments/attachment-stream.ts+++ /dev/null@@ -1,108 +0,0 @@-/*-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/>.-*/--import { StreamableFS } from "@notesnook/streamable-fs";-import FS from "../../interfaces/fs";-import { getNNCrypto } from "../../interfaces/nncrypto.stub";-import { db } from "../db";-import { ZipFile } from "./zip-stream";--export type PackageMetadata = {- version: string;- attachments: string[];-};--export const METADATA_FILENAME = "metadata.json";--export class AttachmentStream extends ReadableStream<ZipFile> {- constructor(attachments: Array<any>) {- super({- async pull(controller) {- const token = await db.fs.tokenManager.getAccessToken();- let index = 0;- for (const attachment of attachments) {- if (index > 2) {- return controller.close();- }- const url = `${hosts.API_HOST}/s3?name=${attachment.metadata.hash}`;-- const { execute } = FS.downloadAttachment(attachment.metadata.hash, {- metadata: attachment.metadata,- url,- chunkSize: attachment.chunkSize,- headers: { Authorization: `Bearer ${token}` }- });- await execute();- const key = await db.attachments?.decryptKey(attachment.key);- const file = await saveFile(attachment.metadata.hash, {- key,- iv: attachment.iv,- name: attachment.metadata.filename,- type: attachment.metadata.type,- isUploaded: !!attachment.dateUploaded- });- const filePath = `/${attachment.metadata.hash}`;- if (file)- controller.enqueue({- path: filePath,- data: file- });- index++;- }- }- });- }-}--async function saveFile(filename: string, fileMetadata: any) {- if (!fileMetadata) return false;- const streamablefs = new StreamableFS("streamable-fs");-- const fileHandle = await streamablefs.readFile(filename);- if (!fileHandle) return false;- const { key, iv, name, type, isUploaded } = fileMetadata;-- const blobParts: Array<any> = [];- const reader = fileHandle.getReader();-- const crypto = await getNNCrypto();- await crypto.decryptStream(- key,- iv,- {- read: async () => {- const { value } = await reader.read();- return value;- },- write: async (chunk: any) => {- blobParts.push(chunk.data);- }- },- filename- );-- if (isUploaded) await streamablefs.deleteFile(filename);- return new Blob(blobParts, { type }).arrayBuffer().then((buffer) => {- return new Uint8Array(buffer);- });-}--const hosts = {- API_HOST: "https://api.notesnook.com"-};diff --git a/apps/web/src/components/dialogs/attachments-dialog.js b/apps/web/src/components/dialogs/attachments-dialog.jsindex e2731ef51..154345076 100644--- a/apps/web/src/components/dialogs/attachments-dialog.js+++ b/apps/web/src/components/dialogs/attachments-dialog.js@@ -26,9 +26,10 @@ import Field from "../field";import ListContainer from "../list-container";import Dialog from "./dialog";import Placeholder from "../placeholders";-import { AttachmentStream } from "../../common/attachments/attachment-stream";-import { ZipStream } from "../../common/attachments/zip-stream";-import { createWriteStream } from "../../common/attachments/stream-saver";+import { AttachmentStream } from "../../common/attachment-stream";+import { ZipStream } from "../../utils/zip-stream";+import { createWriteStream } from "../../utils/stream-saver";+import { register } from "../../utils/mitm";function AttachmentsDialog({ onClose }) {const attachments = useStore((store) => store.attachments);@@ -51,14 +52,10 @@ function AttachmentsDialog({ onClose }) {positiveButton={{text: "Download All Attachments",onClick: async () => {- if (navigator.serviceWorker) {- console.log(- "attachment-dialog",- await new AttachmentStream(attachments)- .pipeThrough(new ZipStream())- .pipeTo(createWriteStream("notesnook-importer.zip"))- );- }+ await register();+ await new AttachmentStream(attachments)+ .pipeThrough(new ZipStream())+ .pipeTo(createWriteStream("attachments.zip"));}}}showdiff --git a/apps/web/src/interfaces/base64-decoder-stream.ts b/apps/web/src/interfaces/base64-decoder-stream.tsnew file mode 100644index 000000000..b5e431f13--- /dev/null+++ b/apps/web/src/interfaces/base64-decoder-stream.ts@@ -0,0 +1,56 @@+/*+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 class Base64DecoderStream extends TransformStream<Uint8Array, string> {+ constructor(encoding: "base64url" | "base64" = "base64") {+ let backBuffer: Uint8Array | null = null;+ super({+ start() {},+ transform(chunk, controller) {+ let part = backBuffer+ ? Buffer.concat(+ [Buffer.from(backBuffer.buffer), Buffer.from(chunk.buffer)],+ backBuffer.length + chunk.length+ )+ : Buffer.from(chunk.buffer);++ const remaining = part.length % 3;+ if (remaining) {+ backBuffer = part.subarray(part.length - remaining);+ part = part.subarray(0, part.length - remaining);+ } else {+ backBuffer = null;+ }++ controller.enqueue(toBase64(part, encoding));+ },+ flush(controller) {+ if (backBuffer)+ controller.enqueue(toBase64(Buffer.from(backBuffer), encoding));+ }+ });+ }+}++function toBase64(bytes: Buffer, encoding: "base64url" | "base64") {+ const result = Buffer.isEncoding(encoding)+ ? bytes.toString(encoding)+ : bytes.toString("base64");+ return result;+}diff --git a/apps/web/src/interfaces/chunked-stream.ts b/apps/web/src/interfaces/chunked-stream.tsnew file mode 100644index 000000000..c38f63a33--- /dev/null+++ b/apps/web/src/interfaces/chunked-stream.ts@@ -0,0 +1,71 @@+/*+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/>.+*/++import { Chunk } from "@notesnook/crypto";++export class ChunkedStream extends TransformStream<Uint8Array, Uint8Array> {+ constructor(chunkSize: number) {+ let backBuffer: Uint8Array | null = null;+ super({+ start() {},+ transform(chunk, controller) {+ backBuffer = backBuffer+ ? Buffer.concat(+ [Buffer.from(backBuffer.buffer), Buffer.from(chunk.buffer)],+ backBuffer.length + chunk.length+ )+ : Buffer.from(chunk.buffer);++ if (backBuffer.length >= chunkSize) {+ let remainingBytes = backBuffer.length;+ while (remainingBytes > chunkSize) {+ const start = backBuffer.length - remainingBytes;+ const end = start + chunkSize;+ controller.enqueue(backBuffer.subarray(start, end));+ remainingBytes -= chunkSize;+ }++ backBuffer =+ remainingBytes > 0+ ? backBuffer.subarray(+ backBuffer.length - remainingBytes,+ backBuffer.length+ )+ : null;+ }+ },+ flush(controller) {+ if (backBuffer) controller.enqueue(backBuffer);+ }+ });+ }+}++export class IntoChunks extends TransformStream<Uint8Array, Chunk> {+ constructor(totalSize: number) {+ let size = 0;+ super({+ start() {},+ transform(chunk, controller) {+ size += chunk.length;+ controller.enqueue({ data: chunk, final: size === totalSize });+ }+ });+ }+}diff --git a/apps/web/src/interfaces/fs.js b/apps/web/src/interfaces/fs.tssimilarity index 54%rename from apps/web/src/interfaces/fs.jsrename to apps/web/src/interfaces/fs.tsindex fc81c0f1c..3f6bb62e6 100644--- a/apps/web/src/interfaces/fs.js+++ b/apps/web/src/interfaces/fs.ts@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import "web-streams-polyfill/dist/ponyfill";import localforage from "localforage";import { xxhash64, createXXHash64 } from "hash-wasm";-import axios from "axios";+import axios, { AxiosProgressEvent } from "axios";import { AppEventManager, AppEvents } from "../common/app-events";import { StreamableFS } from "@notesnook/streamable-fs";import { getNNCrypto } from "./nncrypto.stub";@@ -30,6 +30,13 @@ import { saveAs } from "file-saver";import { showToast } from "../utils/toast";import { db } from "../common/db";import { getFileNameWithExtension } from "@notesnook/core/utils/filename";+import { ChunkedStream, IntoChunks } from "./chunked-stream";+import { ProgressStream } from "./progress-stream";+import { consumeReadableStream } from "./stream-utils";+import { Base64DecoderStream } from "./base64-decoder-stream";+import { toBlob } from "@notesnook-importer/core/dist/src/utils/stream";+import { Cipher, OutputFormat, SerializedKey } from "@notesnook/crypto";+import { IDataType } from "hash-wasm/dist/lib/util";const ABYTES = 17;const CHUNK_SIZE = 512 * 1024;@@ -39,12 +46,11 @@ const UPLOAD_PART_REQUIRED_CHUNKS = Math.ceil();const streamablefs = new StreamableFS("streamable-fs");-/**- * @param {File} file- * @param {import("nncrypto/dist/src/types").SerializedKey} key- * @param {string} hash- */-async function writeEncryptedFile(file, key, hash) {+async function writeEncryptedFile(+ file: File,+ key: SerializedKey,+ hash: string+) {const crypto = await getNNCrypto();if (!localforage.supports(localforage.INDEXEDDB))@@ -52,38 +58,29 @@ async function writeEncryptedFile(file, key, hash) {if (await streamablefs.exists(hash)) await streamablefs.deleteFile(hash);- let offset = 0;- let encrypted = 0;+ // let offset = 0;+ // let encrypted = 0;const fileHandle = await streamablefs.createFile(hash, file.size, file.type);sendAttachmentsProgressEvent("encrypt", hash, 1, 0);- const iv = await crypto.encryptStream(- key,- {- read: async () => {- let end = Math.min(offset + CHUNK_SIZE, file.size);- if (offset === end) return;- const chunk = new Uint8Array(- await file.slice(offset, end).arrayBuffer()- );- offset = end;- const isFinal = offset === file.size;- return {- final: isFinal,- data: chunk- };- },- write: async (chunk) => {- encrypted += chunk.data.length - ABYTES;+ const { iv, stream } = await crypto.createEncryptionStream(key);+ await file+ .stream()+ .pipeThrough(new ChunkedStream(CHUNK_SIZE))+ .pipeThrough(new IntoChunks(file.size))+ .pipeThrough(stream)+ .pipeThrough(+ new ProgressStream((totalRead, done) =>reportProgress(- { total: file.size, loaded: encrypted },+ {+ total: file.size,+ loaded: done ? file.size : totalRead+ },{ type: "encrypt", hash }- );- await fileHandle.write(chunk.data);- }- },- file.name- );+ )+ )+ )+ .pipeTo(fileHandle.writeable);sendAttachmentsProgressEvent("encrypt", hash, 1);@@ -91,7 +88,7 @@ async function writeEncryptedFile(file, key, hash) {chunkSize: CHUNK_SIZE,iv: iv,length: file.size,- salt: key.salt,+ salt: key.salt!,alg: "xcha-stream"};}@@ -103,7 +100,11 @@ async function writeEncryptedFile(file, key, hash) {* 3. We encrypt the Uint8Array* 4. We save the encrypted Uint8Array*/-async function writeEncryptedBase64(metadata) {+async function writeEncryptedBase64(metadata: {+ data: string;+ key: SerializedKey;+ mimeType?: string;+}) {const { data, key, mimeType } = metadata;const bytes = new Uint8Array(Buffer.from(data, "base64"));@@ -122,33 +123,18 @@ async function writeEncryptedBase64(metadata) {};}-/**- *- * @param {string} data the base64 data- * @returns- */-function hashBase64(data) {+function hashBase64(data: string) {return hashBuffer(Buffer.from(data, "base64"));}-/**- *- * @param {import("hash-wasm/dist/lib/util").IDataType} data- * @returns- */-async function hashBuffer(data) {+async function hashBuffer(data: IDataType) {return {hash: await xxhash64(data),type: "xxh64"};}-/**- *- * @param {ReadableStreamReader<Uint8Array>} reader- * @returns- */-async function hashStream(reader) {+async function hashStream(reader: ReadableStreamDefaultReader<Uint8Array>) {const hasher = await createXXHash64();hasher.init();@@ -162,42 +148,51 @@ async function hashStream(reader) {return { type: "xxh64", hash: hasher.digest("hex") };}-async function readEncrypted(filename, key, cipherData) {+async function readEncrypted(+ filename: string,+ key: SerializedKey,+ cipherData: Cipher & { outputType: OutputFormat }+) {const fileHandle = await streamablefs.readFile(filename);if (!fileHandle) {console.error(`File not found. (File hash: ${filename})`);return null;}-- const reader = fileHandle.getReader();- const plainText = new Uint8Array(fileHandle.file.size);- let offset = 0;-const crypto = await getNNCrypto();- await crypto.decryptStream(+ const decryptionStream = await crypto.createDecryptionStream(key,- cipherData.iv,- {- read: async () => {- const { value } = await reader.read();- return value;- },- write: async (chunk) => {- plainText.set(chunk.data, offset);- offset += chunk.data.length;- }- },- filename+ cipherData.iv);- return cipherData.outputType === "base64"- ? Buffer.from(plainText).toString("base64")- : cipherData.outputType === "text"- ? new TextDecoder().decode(plainText)- : plainText;+ return cipherData.outputType === "base64" || cipherData.outputType === "text"+ ? (+ await consumeReadableStream(+ fileHandle.readable+ .pipeThrough(decryptionStream)+ .pipeThrough(+ cipherData.outputType === "text"+ ? new globalThis.TextDecoderStream()+ : new Base64DecoderStream()+ )+ )+ ).join()+ : new Uint8Array(+ Buffer.concat(+ await consumeReadableStream(+ fileHandle.readable.pipeThrough(decryptionStream)+ )+ )+ );}-async function uploadFile(filename, requestOptions) {+type RequestOptions = {+ headers: Record<string, string>;+ signal: AbortSignal;+ url: string;+ chunkSize: number;+};++async function uploadFile(filename: string, requestOptions: RequestOptions) {const fileHandle = await streamablefs.readFile(filename);if (!fileHandle)throw new Error(`File stream not found. (File hash: ${filename})`);@@ -205,12 +200,15 @@ async function uploadFile(filename, requestOptions) {fileHandle.file.chunks / UPLOAD_PART_REQUIRED_CHUNKS);- let {- uploadedChunks = [],- uploadedBytes = 0,- uploaded = false,- uploadId = ""- } = fileHandle.file.additionalData || {};+ const additionalData = (fileHandle.file.additionalData || {}) as {+ uploadedBytes?: number;+ uploadId?: string;+ uploaded?: boolean;+ uploadedChunks?: { PartNumber: number; ETag: string }[];+ };++ const { uploadedChunks = [], uploaded = false } = additionalData;+ let { uploadedBytes = 0, uploadId = "" } = additionalData;try {if (uploaded) {@@ -218,14 +216,14 @@ async function uploadFile(filename, requestOptions) {return true;}- const { headers, cancellationToken } = requestOptions;+ const { headers, signal } = requestOptions;const initiateMultiPartUpload = await axios.get(`${hosts.API_HOST}/s3/multipart?name=${filename}&parts=${TOTAL_PARTS}&uploadId=${uploadId}`,{headers,- cancelToken: cancellationToken+ signal}).catch((e) => {@@ -237,7 +235,7 @@ async function uploadFile(filename, requestOptions) {await fileHandle.addAdditionalData("uploadId", uploadId);- const onUploadProgress = (ev) => {+ const onUploadProgress = (ev: AxiosProgressEvent) => {reportProgress({total: fileHandle.file.size + ABYTES,@@ -262,7 +260,7 @@ async function uploadFile(filename, requestOptions) {url,method: "PUT",headers: { "Content-Type": "" },- cancelToken: cancellationToken,+ signal,data,onUploadProgress})@@ -294,7 +292,7 @@ async function uploadFile(filename, requestOptions) {},{headers,- cancelToken: cancellationToken+ signal}).catch((e) => {@@ -311,21 +309,24 @@ async function uploadFile(filename, requestOptions) {return true;} catch (e) {reportProgress(undefined, { type: "upload", hash: filename });- if (e.handle) e.handle();+ if (e instanceof S3Error) e.handle();else handleS3Error(e);return false;}}-async function checkUpload(filename) {+async function checkUpload(filename: string) {if ((await getUploadedFileSize(filename)) <= 0) {const error = `Upload verification failed: file size is 0. Please upload this file again. (File hash: ${filename})`;throw new Error(error);}}-function reportProgress(ev, { type, hash }) {+function reportProgress(+ ev: { total?: number; loaded?: number } | undefined,+ { type, hash }: { type: string; hash: string }+) {AppEventManager.publish(AppEvents.UPDATE_ATTACHMENT_PROGRESS, {type,hash,@@ -334,8 +335,8 @@ function reportProgress(ev, { type, hash }) {});}-async function downloadFile(filename, requestOptions) {- const { url, headers, chunkSize, cancellationToken } = requestOptions;+async function downloadFile(filename: string, requestOptions: RequestOptions) {+ const { url, headers, chunkSize, signal } = requestOptions;if (await streamablefs.exists(filename)) return true;try {@@ -344,100 +345,59 @@ async function downloadFile(filename, requestOptions) {{ type: "download", hash: filename });- const signedUrlResponse = await axios.get(url, {- headers,- responseType: "text"- });+ const signedUrl = (+ await axios.get(url, {+ headers,+ responseType: "text"+ })+ ).data;- const signedUrl = signedUrlResponse.data;- const response = await axios.get(signedUrl, {- responseType: "arraybuffer",- cancelToken: cancellationToken,- onDownloadProgress: (ev) =>- reportProgress(ev, { type: "download", hash: filename })+ const response = await fetch(signedUrl, {+ signal});- const contentType = response.headers["content-type"];+ const contentType = response.headers.get("content-type");if (contentType === "application/xml") {- const error = parseS3Error(response.data);+ const error = parseS3Error(await response.text());if (error.Code !== "Unknown") {throw new Error(`[${error.Code}] ${error.Message}`);}}-- const contentLength = response.headers["content-length"];- if (contentLength === "0") {+ const contentLength = parseInt(+ response.headers.get("content-length") || "0"+ );+ if (contentLength === 0 || isNaN(contentLength)) {const error = `File length is 0. Please upload this file again from the attachment manager. (File hash: ${filename})`;- await db.attachments.markAsFailed(filename, error);+ await db.attachments?.markAsFailed(filename, error);throw new Error(error);}- const distributor = new ChunkDistributor(chunkSize + ABYTES);- distributor.fill(new Uint8Array(response.data));- distributor.close();-- const fileHandle = await streamablefs.createFile(- filename,- response.data.byteLength,- "application/octet-stream"- );-- for (let chunk of distributor.chunks) {- await fileHandle.write(chunk.data);- }-- return true;- } catch (e) {- handleS3Error(e, "Could not download file");- reportProgress(undefined, { type: "download", hash: filename });- return false;- }-}--async function downloadAttachment(filename, requestOptions) {- const { url, headers, chunkSize, cancellationToken } = requestOptions;- if (await streamablefs.exists(filename)) return true;-- try {- const signedUrlResponse = await axios.get(url, {- headers,- responseType: "text"- });-- const signedUrl = signedUrlResponse.data;- const response = await axios.get(signedUrl, {- responseType: "arraybuffer",- cancelToken: cancellationToken- });-- const contentType = response.headers["content-type"];- if (contentType === "application/xml") {- const error = parseS3Error(response.data);- if (error.Code !== "Unknown") {- throw new Error(`[${error.Code}] ${error.Message}`);- }- }-- const contentLength = response.headers["content-length"];- if (contentLength === "0") {- const error = `File length is 0. Please upload this file again from the attachment manager. (File hash: ${filename})`;- await db.attachments.markAsFailed(filename, error);+ if (!response.body) {+ const error = `The download response does not contain a body. Please upload this file again from the attachment manager. (File hash: ${filename})`;+ await db.attachments?.markAsFailed(filename, error);throw new Error(error);}- const distributor = new ChunkDistributor(chunkSize + ABYTES);- distributor.fill(new Uint8Array(response.data));- distributor.close();-const fileHandle = await streamablefs.createFile(filename,- response.data.byteLength,+ contentLength,"application/octet-stream");- for (let chunk of distributor.chunks) {- await fileHandle.write(chunk.data);- }+ await response.body+ .pipeThrough(+ new ProgressStream((totalRead, done) => {+ reportProgress(+ {+ total: contentLength,+ loaded: done ? contentLength : totalRead+ },+ { type: "download", hash: filename }+ );+ })+ )+ .pipeThrough(new ChunkedStream(chunkSize + ABYTES))+ .pipeTo(fileHandle.writeable);return true;} catch (e) {@@ -447,43 +407,45 @@ async function downloadAttachment(filename, requestOptions) {}}-function exists(filename) {+function exists(filename: string) {return streamablefs.exists(filename);}-async function saveFile(filename, fileMetadata) {+type FileMetadata = {+ key: SerializedKey;+ iv: string;+ name: string;+ type: string;+ isUploaded: boolean;+};+export async function decryptFile(+ filename: string,+ fileMetadata: FileMetadata+) {if (!fileMetadata) return false;const fileHandle = await streamablefs.readFile(filename);if (!fileHandle) return false;- const { key, iv, name, type, isUploaded } = fileMetadata;-- const blobParts = [];- const reader = fileHandle.getReader();+ const { key, iv } = fileMetadata;const crypto = await getNNCrypto();- await crypto.decryptStream(- key,- iv,- {- read: async () => {- const { value } = await reader.read();- return value;- },- write: async (chunk) => {- blobParts.push(chunk.data);- }- },- filename- );+ const decryptionStream = await crypto.createDecryptionStream(key, iv);+ return await toBlob(fileHandle.readable.pipeThrough(decryptionStream));+}++async function saveFile(filename: string, fileMetadata: FileMetadata) {+ if (!fileMetadata) return false;++ const { name, type, isUploaded } = fileMetadata;- saveAs(new Blob(blobParts, { type }), getFileNameWithExtension(name, type));+ const decrypted = await decryptFile(filename, fileMetadata);+ if (decrypted) saveAs(decrypted, getFileNameWithExtension(name, type));if (isUploaded) await streamablefs.deleteFile(filename);}-async function deleteFile(filename, requestOptions) {+async function deleteFile(filename: string, requestOptions: RequestOptions) {if (!requestOptions) return await streamablefs.deleteFile(filename);if (!requestOptions && !(await streamablefs.exists(filename))) return true;@@ -502,10 +464,10 @@ async function deleteFile(filename, requestOptions) {}}-async function getUploadedFileSize(filename) {+async function getUploadedFileSize(filename: string) {try {const url = `${hosts.API_HOST}/s3?name=${filename}`;- const token = await db.user.tokenManager.getAccessToken();+ const token = await db.user?.tokenManager.getAccessToken();const attachmentInfo = await axios.head(url, {headers: { Authorization: `Bearer ${token}` }@@ -528,13 +490,13 @@ const FS = {readEncrypted,uploadFile: cancellable(uploadFile),downloadFile: cancellable(downloadFile),- downloadAttachment: cancellable(downloadAttachment),deleteFile,saveFile,exists,writeEncryptedFile,clearFileStorage,getUploadedFileSize,+ decryptFile,hashBase64,hashBuffer,@@ -542,106 +504,25 @@ const FS = {};export default FS;-function isSuccessStatusCode(statusCode) {+function isSuccessStatusCode(statusCode: number) {return statusCode >= 200 && statusCode <= 299;}-function cancellable(operation) {- return function (filename, requestOptions) {- const source = axios.CancelToken.source();- requestOptions.cancellationToken = source.token;+function cancellable(+ operation: (filename: string, requestOptions: RequestOptions) => any+) {+ return function (filename: string, requestOptions: RequestOptions) {+ const abortController = new AbortController();+ requestOptions.signal = abortController.signal;return {execute: () => operation(filename, requestOptions),- cancel: (message) => {- source.cancel(message);+ cancel: (message: string) => {+ abortController.abort(message);}};};}--class ChunkDistributor {- /**- * @typedef {{length: number, data: Uint8Array, final: boolean}} Chunk- */- constructor(chunkSize) {- this.chunkSize = chunkSize;- this.chunks = [];- this.filledCount = 0;- this.done = false;- }-- /**- * @returns {Chunk}- */- get lastChunk() {- return this.chunks[this.chunks.length - 1];- }-- /**- * @returns {boolean}- */- get isLastChunkFilled() {- return this.lastChunk.length === this.chunkSize;- }-- /**- * @returns {Chunk}- */- get firstChunk() {- const chunk = this.chunks.shift();- if (chunk.data.length === this.chunkSize) this.filledCount--;- return chunk;- }-- close() {- if (!this.lastChunk)- throw new Error("No data available in this distributor.");- this.lastChunk.data = this.lastChunk.data.slice(0, this.lastChunk.length);- this.lastChunk.final = true;- this.done = true;- }-- /**- * @param {Uint8Array} data- */- fill(data) {- if (this.done || !data || !data.length) return;-- const dataLength = data.length;- const totalBlocks = Math.ceil(dataLength / this.chunkSize);-- for (let i = 0; i < totalBlocks; ++i) {- const start = i * this.chunkSize;-- if (this.lastChunk && !this.isLastChunkFilled) {- const needed = this.chunkSize - this.lastChunk.length;- const end = Math.min(start + needed, dataLength);- const chunk = data.slice(start, end);-- this.lastChunk.data.set(chunk, this.lastChunk.length);- this.lastChunk.length += chunk.length;-- if (this.lastChunk.length === this.chunkSize) this.filledCount++;-- if (end !== dataLength) {- this.fill(data.slice(end));- break;- }- } else {- const end = Math.min(start + this.chunkSize, dataLength);- let chunk = data.slice(start, end);-- const buffer = new Uint8Array(this.chunkSize);- buffer.set(chunk, 0);-- this.chunks.push({ data: buffer, final: false, length: chunk.length });- if (chunk.length === this.chunkSize) this.filledCount++;- }- }- }-}--function parseS3Error(data) {+function parseS3Error(data: ArrayBuffer | unknown) {if (!(data instanceof ArrayBuffer)) {return {Code: "UNKNOWN",@@ -655,28 +536,29 @@ function parseS3Error(data) {if (!ErrorElement)return { Code: "Unknown", Message: "An unknown error occured." };- const error = {};+ const error: Record<string, string> = {};for (const child of ErrorElement.children) {- error[child.tagName] = child.textContent;+ if (child.textContent) error[child.tagName] = child.textContent;}return error;}-function handleS3Error(e, message) {+function handleS3Error(e: unknown, message?: unknown) {if (axios.isAxiosError(e) && e.response?.data) {const error = parseS3Error(e.response.data);showToast("error", `${message}: [${error.Code}] ${error.Message}`);- } else if (message) {+ } else if (message && e instanceof Error) {showToast("error", `${message}: ${e.message}`);- } else {+ } else if (e instanceof Error) {showToast("error", e.message);+ } else {+ showToast("error", JSON.stringify(e));}}class S3Error extends Error {- constructor(message, error) {+ constructor(message: string, readonly error: Error) {super(message);- this.error = error;}handle() {diff --git a/packages/crypto-worker/src/utils.ts b/apps/web/src/interfaces/progress-stream.tssimilarity index 60%rename from packages/crypto-worker/src/utils.tsrename to apps/web/src/interfaces/progress-stream.tsindex 9843a51fb..d9287eaa4 100644--- a/packages/crypto-worker/src/utils.ts+++ b/apps/web/src/interfaces/progress-stream.ts@@ -17,24 +17,18 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-type Message<T> = {- type: string;- data?: T;-};--export function sendEventWithResult<T>(type: string): Promise<T> {- return new Promise<T>((resolve) => {- // eslint-disable-next-line no-restricted-globals- addEventListener(- "message",- (ev: MessageEvent<Message<T>>) => {- const { type: messageType, data } = ev.data;- if (messageType === type && data) {- resolve(data);- }+export class ProgressStream extends TransformStream<Uint8Array, Uint8Array> {+ constructor(report: (totalRead: number, done?: boolean) => void) {+ let totalRead = 0;+ super({+ start() {},+ transform(chunk, controller) {+ controller.enqueue(chunk);+ report((totalRead += chunk.length));},- { once: true }- );- postMessage({ type });- });+ flush() {+ report(totalRead, true);+ }+ });+ }}diff --git a/apps/web/src/interfaces/stream-utils.ts b/apps/web/src/interfaces/stream-utils.tsnew file mode 100644index 000000000..67dc98ee6--- /dev/null+++ b/apps/web/src/interfaces/stream-utils.ts@@ -0,0 +1,29 @@+/*+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/>.+*/+import { toAsyncIterator } from "@notesnook-importer/core/dist/src/utils/stream";++export async function consumeReadableStream<T>(+ stream: ReadableStream<T>+): Promise<T[]> {+ const chunks: T[] = [];+ for await (const chunk of toAsyncIterator(stream)) {+ chunks.push(chunk);+ }+ return chunks;+}diff --git a/apps/web/src/stores/attachment-store.js b/apps/web/src/stores/attachment-store.jsindex b436f1659..ec2fe102f 100644--- a/apps/web/src/stores/attachment-store.js+++ b/apps/web/src/stores/attachment-store.js@@ -40,7 +40,7 @@ class AttachmentStore extends BaseStore {const percent = Math.round((loaded / total) * 100);const status =percent < 100 ? { type, loaded, total, progress: percent } : null;- if (!status) return this.refresh();+ if (!status) this.refresh();state.attachments[index] = {...state.attachments[index],statusdiff --git a/apps/web/src/common/attachments/mitm.ts b/apps/web/src/utils/mitm.tssimilarity index 95%rename from apps/web/src/common/attachments/mitm.tsrename to apps/web/src/utils/mitm.tsindex 4de9a3169..c63732f76 100644--- a/apps/web/src/common/attachments/mitm.ts+++ b/apps/web/src/utils/mitm.ts@@ -26,7 +26,8 @@ function registerWorker() {.getRegistration("./").then((swReg) => {return (- swReg || navigator.serviceWorker.register("sw.js", { scope: "./" })+ swReg ||+ navigator.serviceWorker.register("stream-saver-sw.js", { scope: "./" }));}).then((swReg) => {@@ -90,7 +91,7 @@ export function postMessage(data.pathname = data.pathname.replace(/^\/+/g, "");// remove protocol- let org = origin.replace(/(^\w+:|^)\/\//, "");+ const org = origin.replace(/(^\w+:|^)\/\//, "");// set the absolute pathname to the download url.data.url = new URL(`${scope + org}/${data.pathname}`).toString();diff --git a/apps/web/src/common/attachments/stream-saver.ts b/apps/web/src/utils/stream-saver.tssimilarity index 85%rename from apps/web/src/common/attachments/stream-saver.tsrename to apps/web/src/utils/stream-saver.tsindex 1abdda2bc..259bfe532 100644--- a/apps/web/src/common/attachments/stream-saver.ts+++ b/apps/web/src/utils/stream-saver.ts@@ -27,48 +27,17 @@ let useBlobFallback ="safari" in globalThis ||"WebKitPoint" in globalThis;-type IFrameContainer = HTMLIFrameElement & {- loaded: boolean;- isIFrame: boolean;- remove: () => void;- addEventListener: HTMLIFrameElement["addEventListener"];- dispatchEvent: HTMLIFrameElement["dispatchEvent"];- removeEventListener: HTMLIFrameElement["removeEventListener"];- postMessage(- message: any,- targetOrigin: string,- transfer?: Transferable[] | undefined- ): void;-};-/*** create a hidden iframe and append it to the DOM (body)- *- * @param {string} src page to load- * @return {HTMLIFrameElement} page to load*/-function makeIframe(src: string, doc = true): IFrameContainer {+function makeIframe(src: string, doc = true) {if (!src) throw new Error("meh");- const iframe = document.createElement("iframe") as IFrameContainer;+ const iframe = document.createElement("iframe");iframe.hidden = true;if (doc) iframe.srcdoc = src;else iframe.src = src;- iframe.name = "iframe";- iframe.loaded = false;- iframe.isIFrame = true;- iframe.postMessage = (message, targetOrigin, transfer) =>- iframe.contentWindow?.postMessage(message, targetOrigin, transfer);-- iframe.addEventListener(- "load",- () => {- iframe.loaded = true;- },- { once: true }- );document.body.appendChild(iframe);- return iframe;}try {@@ -85,7 +54,6 @@ function checkSupportsTransferable() {// Transferable stream was first enabled in chrome v73 behind a flagconst { readable } = new TransformStream();const mc = new MessageChannel();- // @ts-ignoremc.port1.postMessage(readable, [readable]);mc.port1.close();mc.port2.close();@@ -139,7 +107,6 @@ export function createWriteStream(ts = new TransformStream();const readableStream = ts.readable;- // @ts-ignorechannel.port1.postMessage({ readableStream }, [readableStream]);}channel.port1.onmessage = async (evt) => {diff --git a/apps/web/src/common/attachments/zip-stream.ts b/apps/web/src/utils/zip-stream.tssimilarity index 93%rename from apps/web/src/common/attachments/zip-stream.tsrename to apps/web/src/utils/zip-stream.tsindex 42ab8d953..16a8d0d45 100644--- a/apps/web/src/common/attachments/zip-stream.ts+++ b/apps/web/src/utils/zip-stream.ts@@ -26,8 +26,9 @@ export class ZipStream extends TransformStream<ZipFile, Uint8Array> {super({start(controller) {zipper.ondata = (err, data) => {- if (err) controller.error(err);- else controller.enqueue(data);+ if (err) {+ controller.error(err);+ } else controller.enqueue(data);};},transform(chunk) {diff --git a/apps/web/vitest.config.ts b/apps/web/vitest.config.tsnew file mode 100644index 000000000..7b2c5ef86--- /dev/null+++ b/apps/web/vitest.config.ts@@ -0,0 +1,27 @@+/*+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/>.+*/++import { defineConfig } from "vitest/config";++export default defineConfig({+ test: {+ environment: "happy-dom",+ dir: "./__tests__/"+ }+});diff --git a/bugs.md b/bugs.mdnew file mode 100644index 000000000..3bc73292c--- /dev/null+++ b/bugs.md@@ -0,0 +1,14 @@+Mobile:++1. Select all notes in a topic -> Click on add button+2. Edit button in a notebook doesn't work+3. Edit notebook sheet doesn't close after saving edits+4. Removing notes from a topic doesn't update the notes count in the list automatically+5. Notes inside a notebook/topic keep showing the notebook tag at the top+6.++Web:++1. When a note is in a single topic, its impossible to move it to its parent notebook+2. When a note is in a single notebook, its impossible to remove it+3. Disable sync -> Refresh app -> Enable sync & notice how the sync status is not updated nor does the sync run automaticallydiff --git a/package.json b/package.jsonindex 28c9b1ad4..39c6198b7 100644--- a/package.json+++ b/package.json@@ -56,6 +56,6 @@},"license": "GPL-3.0-or-later","volta": {- "node": "16.15.1"+ "node": "18.15.0"}}diff --git a/packages/crypto-worker/index.ts b/packages/crypto-worker/index.tsindex e59694819..8bdab26cd 100644--- a/packages/crypto-worker/index.ts+++ b/packages/crypto-worker/index.ts@@ -23,10 +23,9 @@ import {OutputFormat,Cipher,EncryptionKey,- Chunk-} from "@notesnook/crypto/dist/src/types";+ INNCrypto+} from "@notesnook/crypto";import { NNCryptoWorkerModule } from "./src/worker";-import { INNCrypto, IStreamable } from "@notesnook/crypto/dist/src/interfaces";import { wrap } from "comlink";export class NNCryptoWorker implements INNCrypto {@@ -92,80 +91,92 @@ export class NNCryptoWorker implements INNCrypto {return this.workermodule.exportKey(password, salt);}- async encryptStream(- key: SerializedKey,- stream: IStreamable,- streamId?: string- ): Promise<string> {- if (!streamId) throw new Error("streamId is required.");+ async createEncryptionStream(key: SerializedKey) {await this.init();if (!this.workermodule) throw new Error("Worker module is not ready.");- if (!this.worker) throw new Error("Worker is not ready.");-- const eventListener = await this.createWorkerStream(- streamId,- stream,- () => {- if (this.worker)- this.worker.removeEventListener("message", eventListener);- }- );- this.worker.addEventListener("message", eventListener);- const iv = await this.workermodule.createEncryptionStream(streamId, key);- this.worker.removeEventListener("message", eventListener);- return iv;+ return this.workermodule.createEncryptionStream(key);}- async decryptStream(- key: SerializedKey,- iv: string,- stream: IStreamable,- streamId?: string- ): Promise<void> {- if (!streamId) throw new Error("streamId is required.");+ async createDecryptionStream(key: SerializedKey, iv: string) {await this.init();if (!this.workermodule) throw new Error("Worker module is not ready.");- if (!this.worker) throw new Error("Worker is not ready.");-- const eventListener = await this.createWorkerStream(- streamId,- stream,- () => {- if (this.worker)- this.worker.removeEventListener("message", eventListener);- }- );- this.worker.addEventListener("message", eventListener);- await this.workermodule.createDecryptionStream(streamId, iv, key);- this.worker.removeEventListener("message", eventListener);- }-- private async createWorkerStream(- streamId: string,- stream: IStreamable,- done: () => void- ): Promise<EventListenerObject> {- const readEventType = `${streamId}:read`;- const writeEventType = `${streamId}:write`;- let finished = false;- return {- handleEvent: async (ev: MessageEvent) => {- if (finished) return;-- const { type } = ev.data;- if (type === readEventType) {- const chunk = await stream.read();- if (!chunk || !this.worker || !chunk.data) return;- this.worker.postMessage({ type, data: chunk }, [chunk.data.buffer]);- } else if (type === writeEventType) {- const chunk = ev.data.data as Chunk;- await stream.write(chunk);- if (chunk.final) {- finished = true;- done();- }- }- }- };+ const { stream } = await this.workermodule.createDecryptionStream(key, iv);+ return stream;}+ // async encryptStream(+ // key: SerializedKey,+ // stream: IStreamable,+ // streamId?: string+ // ): Promise<string> {+ // if (!streamId) throw new Error("streamId is required.");+ // await this.init();+ // if (!this.workermodule) throw new Error("Worker module is not ready.");+ // if (!this.worker) throw new Error("Worker is not ready.");++ // const eventListener = await this.createWorkerStream(+ // streamId,+ // stream,+ // () => {+ // if (this.worker)+ // this.worker.removeEventListener("message", eventListener);+ // }+ // );+ // this.worker.addEventListener("message", eventListener);+ // const iv = await this.workermodule.createEncryptionStream(streamId, key);+ // this.worker.removeEventListener("message", eventListener);+ // return iv;+ // }++ // async decryptStream(+ // key: SerializedKey,+ // iv: string,+ // stream: IStreamable,+ // streamId?: string+ // ): Promise<void> {+ // if (!streamId) throw new Error("streamId is required.");+ // await this.init();+ // if (!this.workermodule) throw new Error("Worker module is not ready.");+ // if (!this.worker) throw new Error("Worker is not ready.");++ // const eventListener = await this.createWorkerStream(+ // streamId,+ // stream,+ // () => {+ // if (this.worker)+ // this.worker.removeEventListener("message", eventListener);+ // }+ // );+ // this.worker.addEventListener("message", eventListener);+ // await this.workermodule.createDecryptionStream(streamId, iv, key);+ // this.worker.removeEventListener("message", eventListener);+ // }++ // private async createWorkerStream(+ // streamId: string,+ // stream: IStreamable,+ // done: () => void+ // ): Promise<EventListenerObject> {+ // const readEventType = `${streamId}:read`;+ // const writeEventType = `${streamId}:write`;+ // let finished = false;+ // return {+ // handleEvent: async (ev: MessageEvent) => {+ // if (finished) return;++ // const { type } = ev.data;+ // if (type === readEventType) {+ // const chunk = await stream.read();+ // if (!chunk || !this.worker || !chunk.data) return;+ // this.worker.postMessage({ type, data: chunk }, [chunk.data.buffer]);+ // } else if (type === writeEventType) {+ // const chunk = ev.data.data as Chunk;+ // await stream.write(chunk);+ // if (chunk.final) {+ // finished = true;+ // done();+ // }+ // }+ // }+ // };+ // }}diff --git a/packages/crypto-worker/src/worker.ts b/packages/crypto-worker/src/worker.tsindex 3ed8f523c..e8b00cf60 100644--- a/packages/crypto-worker/src/worker.ts+++ b/packages/crypto-worker/src/worker.ts@@ -23,8 +23,7 @@ import {Plaintext,SerializedKey} from "@notesnook/crypto/dist/src/types";-import { expose } from "comlink";-import WorkerStream from "./workerstream";+import { expose, transfer } from "comlink";import { NNCrypto } from "@notesnook/crypto";let crypto: NNCrypto | null = null;@@ -63,17 +62,19 @@ const module = {const crypto = await loadNNCrypto();return crypto.decrypt(key, cipherData, outputFormat);},- createEncryptionStream: async function (id: string, key: SerializedKey) {+ createEncryptionStream: async function (key: SerializedKey) {const crypto = await loadNNCrypto();- return crypto.createEncryptionStream(key, new WorkerStream(id));+ const stream = await crypto.createEncryptionStream(key);+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment+ // @ts-ignore+ return transfer(stream, [stream.stream]);},- createDecryptionStream: async function (- id: string,- iv: string,- key: SerializedKey- ) {+ createDecryptionStream: async function (key: SerializedKey, iv: string) {const crypto = await loadNNCrypto();- return crypto.createDecryptionStream(iv, key, new WorkerStream(id));+ const obj = { stream: await crypto.createDecryptionStream(key, iv) };+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment+ // @ts-ignore+ return transfer(obj, [obj.stream]);}};diff --git a/packages/crypto-worker/src/workerstream.ts b/packages/crypto-worker/src/workerstream.tsdeleted file mode 100644index bd53eb5ef..000000000--- a/packages/crypto-worker/src/workerstream.ts+++ /dev/null@@ -1,64 +0,0 @@-/*-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/>.-*/--import { IStreamable } from "@notesnook/crypto/dist/src/interfaces";-import { Chunk } from "@notesnook/crypto/dist/src/types";-import { sendEventWithResult } from "./utils";--export default class WorkerStream- extends ReadableStream<Chunk>- implements IStreamable-{- private id: string;- private reader?: ReadableStreamReader<Chunk>;-- constructor(streamId: string) {- super(new WorkerStreamSource(streamId));- this.id = streamId;- }-- async read(): Promise<Chunk | undefined> {- if (!this.reader) this.reader = this.getReader();- const { value } = await this.reader.read();- return value;- }-- /**- * @param {Uint8Array} chunk- */- async write(chunk: Chunk): Promise<void> {- if (!chunk.data) return;- postMessage({ type: `${this.id}:write`, data: chunk }, [chunk.data.buffer]);- }-}--class WorkerStreamSource implements UnderlyingSource<Chunk> {- private id: string;- constructor(streamId: string) {- this.id = streamId;- }-- start() {}-- async pull(controller: ReadableStreamController<Chunk>) {- const chunk = await sendEventWithResult<Chunk>(`${this.id}:read`);- controller.enqueue(chunk);- if (chunk.final) controller.close();- }-}diff --git a/packages/crypto/index.ts b/packages/crypto/index.tsindex 8b23eb1e9..42c285e93 100644--- a/packages/crypto/index.ts+++ b/packages/crypto/index.ts@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import { ready } from "libsodium-wrappers";import Decryption from "./src/decryption";import Encryption from "./src/encryption";-import { INNCrypto, IStreamable } from "./src/interfaces";+import { INNCrypto } from "./src/interfaces";import KeyUtils from "./src/keyutils";import Password from "./src/password";import {@@ -28,8 +28,7 @@ import {EncryptionKey,OutputFormat,Plaintext,- SerializedKey,- Chunk+ SerializedKey} from "./src/types";export class NNCrypto implements INNCrypto {@@ -74,73 +73,69 @@ export class NNCrypto implements INNCrypto {return KeyUtils.exportKey(password, salt);}- async createEncryptionStream(- key: SerializedKey,- stream: IStreamable- ): Promise<string> {+ async createEncryptionStream(key: SerializedKey) {await this.init();- const encryptionStream = Encryption.createStream(key);+ return Encryption.createStream(key);- // eslint-disable-next-line no-constant-condition- while (true) {- const chunk = await stream.read();- if (!chunk) break;-- const { data, final } = chunk;- if (!data) break;-- const encryptedChunk: Chunk = {- data: encryptionStream.write(data, final),- final- };- await stream.write(encryptedChunk);-- if (final) break;- }- return encryptionStream.header;+ // // eslint-disable-next-line no-constant-condition+ // while (true) {+ // const chunk = await stream.read();+ // if (!chunk) break;++ // const { data, final } = chunk;+ // if (!data) break;++ // const encryptedChunk: Chunk = {+ // data: encryptionStream.write(data, final),+ // final+ // };+ // await stream.write(encryptedChunk);++ // if (final) break;+ // }+ // return encryptionStream.header;}- async createDecryptionStream(- iv: string,- key: SerializedKey,- stream: IStreamable- ) {+ async createDecryptionStream(key: SerializedKey, iv: string) {await this.init();- const decryptionStream = Decryption.createStream(iv, key);+ return Decryption.createStream(iv, key);// eslint-disable-next-line no-constant-condition- while (true) {- const chunk = await stream.read();- if (!chunk) break;-- const { data, final } = chunk;- if (!data) break;+ // while (true) {+ // const chunk = await stream.read();+ // if (!chunk) break;- const decryptedChunk: Chunk = {- data: decryptionStream.read(data),- final- };- await stream.write(decryptedChunk);+ // const { data, final } = chunk;+ // if (!data) break;- if (final) break;- }- }+ // const decryptedChunk: Chunk = {+ // data: decryptionStream.read(data),+ // final+ // };+ // await stream.write(decryptedChunk);- async encryptStream(- key: SerializedKey,- stream: IStreamable,- _streamId?: string- ): Promise<string> {- await this.init();- return await this.createEncryptionStream(key, stream);+ // if (final) break;+ // }}- async decryptStream(- key: SerializedKey,- iv: string,- stream: IStreamable,- _streamId?: string- ): Promise<void> {- await this.init();- await this.createDecryptionStream(iv, key, stream);- }+ // async encryptStream(+ // key: SerializedKey,+ // stream: IStreamable,+ // _streamId?: string+ // ): Promise<string> {+ // await this.init();+ // return await this.createEncryptionStream(key, stream);+ // }++ // async decryptStream(+ // key: SerializedKey,+ // iv: string,+ // stream: IStreamable,+ // _streamId?: string+ // ): Promise<void> {+ // await this.init();+ // await this.createDecryptionStream(iv, key, stream);+ // }}++export * from "./src/types";+export * from "./src/interfaces";diff --git a/packages/crypto/src/decryption.ts b/packages/crypto/src/decryption.tsindex f9edf24e7..5b2c8b0f9 100644--- a/packages/crypto/src/decryption.ts+++ b/packages/crypto/src/decryption.ts@@ -24,18 +24,12 @@ import {to_base64,from_base64,base64_variants,- StateAddress,to_string,- from_hex+ from_hex,+ crypto_secretstream_xchacha20poly1305_TAG_FINAL} from "libsodium-wrappers";import KeyUtils from "./keyutils";-import {- Cipher,- EncryptionKey,- OutputFormat,- Plaintext,- SerializedKey-} from "./types";+import { Cipher, OutputFormat, Plaintext, SerializedKey } from "./types";export default class Decryption {private static transformInput(cipherData: Cipher): Uint8Array {@@ -88,26 +82,47 @@ export default class Decryption {};}- static createStream(header: string, key: SerializedKey): DecryptionStream {- return new DecryptionStream(header, KeyUtils.transform(key));- }-}--class DecryptionStream {- state: StateAddress;- constructor(header: string, key: EncryptionKey) {- this.state = crypto_secretstream_xchacha20poly1305_init_pull(+ static createStream(+ header: string,+ key: SerializedKey+ ): TransformStream<Uint8Array, Uint8Array> {+ const { key: _key } = KeyUtils.transform(key);+ const state = crypto_secretstream_xchacha20poly1305_init_pull(from_base64(header),- key.key+ _key);- }- read(chunk: Uint8Array): Uint8Array {- const { message } = crypto_secretstream_xchacha20poly1305_pull(- this.state,- chunk,- null- );- return message;+ return new TransformStream<Uint8Array, Uint8Array>({+ start() {},+ transform(chunk, controller) {+ const { message, tag } = crypto_secretstream_xchacha20poly1305_pull(+ state,+ chunk,+ null+ );+ controller.enqueue(message);+ if (tag === crypto_secretstream_xchacha20poly1305_TAG_FINAL)+ controller.terminate();+ }+ });}}++// class DecryptionStream {+// state: StateAddress;+// constructor(header: string, key: EncryptionKey) {+// this.state = crypto_secretstream_xchacha20poly1305_init_pull(+// from_base64(header),+// key.key+// );+// }++// read(chunk: Uint8Array): Uint8Array {+// const { message } = crypto_secretstream_xchacha20poly1305_pull(+// this.state,+// chunk,+// null+// );+// return message;+// }+// }diff --git a/packages/crypto/src/encryption.ts b/packages/crypto/src/encryption.tsindex d11aaa242..103ba78ba 100644--- a/packages/crypto/src/encryption.ts+++ b/packages/crypto/src/encryption.ts@@ -27,17 +27,10 @@ import {crypto_secretstream_xchacha20poly1305_TAG_MESSAGE,to_base64,from_base64,- base64_variants,- StateAddress+ base64_variants} from "libsodium-wrappers";import KeyUtils from "./keyutils";-import {- Cipher,- EncryptionKey,- OutputFormat,- Plaintext,- SerializedKey-} from "./types";+import { Chunk, Cipher, OutputFormat, Plaintext, SerializedKey } from "./types";const encoder = new TextEncoder();export default class Encryption {@@ -89,35 +82,62 @@ export default class Encryption {};}- static createStream(key: SerializedKey): EncryptionStream {- return new EncryptionStream(KeyUtils.transform(key));- }-}--class EncryptionStream {- state: StateAddress;- header: string;- constructor(key: EncryptionKey) {+ static createStream(key: SerializedKey): {+ iv: string;+ stream: TransformStream<Chunk, Uint8Array>;+ } {+ const { key: _key } = KeyUtils.transform(key);const { state, header } = crypto_secretstream_xchacha20poly1305_init_push(- key.key,+ _key,"base64");- this.state = state;- this.header = header;- }- write(chunk: Uint8Array, final?: boolean): Uint8Array {- return crypto_secretstream_xchacha20poly1305_push(- this.state,- chunk,- null,- final- ? crypto_secretstream_xchacha20poly1305_TAG_FINAL- : crypto_secretstream_xchacha20poly1305_TAG_MESSAGE- );+ return {+ iv: header,+ stream: new TransformStream<Chunk, Uint8Array>({+ start() {},+ transform(chunk, controller) {+ controller.enqueue(+ crypto_secretstream_xchacha20poly1305_push(+ state,+ chunk.data,+ null,+ chunk.final+ ? crypto_secretstream_xchacha20poly1305_TAG_FINAL+ : crypto_secretstream_xchacha20poly1305_TAG_MESSAGE+ )+ );+ if (chunk.final) controller.terminate();+ }+ })+ };}}+// class EncryptionStream {+// state: StateAddress;+// header: string;+// constructor(key: EncryptionKey) {+// const { state, header } = crypto_secretstream_xchacha20poly1305_init_push(+// key.key,+// "base64"+// );+// this.state = state;+// this.header = header;+// }++// write(chunk: Uint8Array, final?: boolean): Uint8Array {+// return crypto_secretstream_xchacha20poly1305_push(+// this.state,+// chunk,+// null,+// final+// ? crypto_secretstream_xchacha20poly1305_TAG_FINAL+// : crypto_secretstream_xchacha20poly1305_TAG_MESSAGE+// );+// }+// }+function getAlgorithm(base64Variant: base64_variants) {//Template: encryptionAlgorithm-kdfAlgorithm-base64variantreturn `xcha-argon2i13-${base64Variant}`;diff --git a/packages/crypto/src/interfaces.ts b/packages/crypto/src/interfaces.tsindex 92e4b4255..dc913bdf2 100644--- a/packages/crypto/src/interfaces.ts+++ b/packages/crypto/src/interfaces.ts@@ -50,16 +50,12 @@ export interface INNCrypto {exportKey(password: string, salt?: string): Promise<SerializedKey>;- encryptStream(- key: SerializedKey,- stream: IStreamable,- streamId?: string- ): Promise<string>;+ createEncryptionStream(+ key: SerializedKey+ ): Promise<{ iv: string; stream: TransformStream<Chunk, Uint8Array> }>;- decryptStream(+ createDecryptionStream(key: SerializedKey,- iv: string,- stream: IStreamable,- streamId?: string- ): Promise<void>;+ iv: string+ ): Promise<TransformStream<Uint8Array, Uint8Array>>;}diff --git a/packages/streamable-fs/src/filehandle.ts b/packages/streamable-fs/src/filehandle.tsindex bb0e24c6a..7fb396eb5 100644--- a/packages/streamable-fs/src/filehandle.ts+++ b/packages/streamable-fs/src/filehandle.ts@@ -17,28 +17,36 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { Chunk } from "@notesnook/crypto/dist/src/types";import FileStreamSource from "./filestreamsource";import { File } from "./types";-export default class FileHandle extends ReadableStream<Chunk> {+export default class FileHandle {private storage: LocalForage;- private file: File;+ public file: File;constructor(storage: LocalForage, file: File) {- super(new FileStreamSource(storage, file));-this.file = file;this.storage = storage;}- /**- *- * @param {Uint8Array} chunk- */- async write(chunk: Uint8Array) {- await this.storage.setItem(this.getChunkKey(this.file.chunks++), chunk);- await this.storage.setItem(this.file.filename, this.file);+ get readable() {+ return new ReadableStream(new FileStreamSource(this.storage, this.file));+ }++ get writeable() {+ return new WritableStream<Uint8Array>({+ write: async (chunk, controller) => {+ if (controller.signal.aborted) return;++ await this.storage.setItem(this.getChunkKey(this.file.chunks++), chunk);+ await this.storage.setItem(this.file.filename, this.file);+ },+ abort: async () => {+ for (let i = 0; i < this.file.chunks; ++i) {+ await this.storage.removeItem(this.getChunkKey(i));+ }+ }+ });}async addAdditionalData<T>(key: string, value: T) {diff --git a/packages/streamable-fs/src/filestreamsource.ts b/packages/streamable-fs/src/filestreamsource.tsindex 2b1e08b3d..4a6ebb870 100644--- a/packages/streamable-fs/src/filestreamsource.ts+++ b/packages/streamable-fs/src/filestreamsource.ts@@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { File } from "./types";-import { Chunk } from "@notesnook/crypto/dist/src/types";export default class FileStreamSource {private storage: LocalForage;@@ -32,16 +31,12 @@ export default class FileStreamSource {start() {}- async pull(controller: ReadableStreamDefaultController<Chunk>) {+ async pull(controller: ReadableStreamDefaultController<Uint8Array>) {const data = await this.readChunk(this.offset++);- const isFinalChunk = this.offset === this.file.chunks;- if (data)- controller.enqueue({- data,- final: isFinalChunk- });+ if (data) controller.enqueue(data);+ const isFinalChunk = this.offset === this.file.chunks;if (isFinalChunk || !data) controller.close();}