mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
web: lazy load hash-wasm
This commit is contained in:
committed by
Abdullah Atta
parent
00053cb99d
commit
232a347f4a
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { xxhash64, createXXHash64 } from "hash-wasm";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { AppEventManager, AppEvents } from "../common/app-events";
|
import { AppEventManager, AppEvents } from "../common/app-events";
|
||||||
import { StreamableFS } from "@notesnook/streamable-fs";
|
import { StreamableFS } from "@notesnook/streamable-fs";
|
||||||
@@ -164,6 +163,7 @@ function hashBase64(data: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function hashBuffer(data: IDataType) {
|
export async function hashBuffer(data: IDataType) {
|
||||||
|
const { xxhash64 } = await import("hash-wasm");
|
||||||
return {
|
return {
|
||||||
hash: await xxhash64(data),
|
hash: await xxhash64(data),
|
||||||
type: "xxh64"
|
type: "xxh64"
|
||||||
@@ -173,6 +173,7 @@ export async function hashBuffer(data: IDataType) {
|
|||||||
export async function hashStream(
|
export async function hashStream(
|
||||||
reader: ReadableStreamDefaultReader<Uint8Array>
|
reader: ReadableStreamDefaultReader<Uint8Array>
|
||||||
) {
|
) {
|
||||||
|
const { createXXHash64 } = await import("hash-wasm");
|
||||||
const hasher = await createXXHash64();
|
const hasher = await createXXHash64();
|
||||||
hasher.init();
|
hasher.init();
|
||||||
|
|
||||||
@@ -647,7 +648,7 @@ export async function saveFile(filename: string, fileMetadata: FileMetadata) {
|
|||||||
|
|
||||||
const decrypted = await decryptFile(filename, fileMetadata);
|
const decrypted = await decryptFile(filename, fileMetadata);
|
||||||
logger.debug("Decrypting file", { filename, result: !!decrypted });
|
logger.debug("Decrypting file", { filename, result: !!decrypted });
|
||||||
if (decrypted) saveAs(decrypted, getFileNameWithExtension(name, type));
|
if (decrypted) saveAs(decrypted, await getFileNameWithExtension(name, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteFile(
|
async function deleteFile(
|
||||||
|
|||||||
Reference in New Issue
Block a user