-
- table
- .getColumn("label")
- ?.setFilterValue(event.target.value)
- }
- className="max-w-sm"
- />
+
@@ -96,7 +178,10 @@ export function DataTable
({
}
>
{row.getVisibleCells().map((cell: any) => (
-
+
{flexRender(
cell.column.columnDef.cell,
cell.getContext()
diff --git a/src/components/MagikaProcess.tsx b/src/components/MagikaProcess.tsx
index 6887b4f..65cd583 100644
--- a/src/components/MagikaProcess.tsx
+++ b/src/components/MagikaProcess.tsx
@@ -3,12 +3,10 @@
import { Button } from "@/components/ui/button";
import { Loader } from "@/components/ui/loader";
-//@ts-ignore
import { Magika } from "magika";
import { listen } from "@tauri-apps/api/event";
import { useEffect, useState } from "react";
import { readFile } from "@tauri-apps/plugin-fs";
-//@ts-ignore
import { open } from "@tauri-apps/plugin-dialog";
import { columns } from "@/components/DT/columns";
import { DataTable } from "@/components/DT/data-table";
@@ -19,22 +17,19 @@ const MagikaProcess = () => {
useEffect(() => {
if (loading) return;
- const unlisten = listen(
- "tauri://file-drop",
- async ({ payload }: any) => {
- setLoading(true);
- const filepaths: string[] = payload.paths;
- const filepredictions: any[] = [];
+ listen("tauri://file-drop", async ({ payload }: any) => {
+ setLoading(true);
+ const filepaths: string[] = payload.paths;
+ const filepredictions: any[] = [];
- for await (const filepath of filepaths) {
- const prediction = await getPrediction(filepath);
- filepredictions.push(prediction);
- }
-
- setPredictions(filepredictions);
- setLoading(false);
+ for await (const filepath of filepaths) {
+ const prediction = await getPrediction(filepath);
+ filepredictions.push(prediction);
}
- );
+
+ setPredictions(filepredictions);
+ setLoading(false);
+ });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -43,9 +38,13 @@ const MagikaProcess = () => {
const fileBytes = await readFile(filepath);
const magika = new Magika();
await magika.load({});
- const prediction = await magika.identifyBytes(fileBytes);
- prediction.path = filepath;
- return prediction;
+ const result = await magika.identifyBytes(
+ new Uint16Array(fileBytes.buffer)
+ );
+ return {
+ path: filepath,
+ result: result,
+ };
} catch (e) {
console.error(
`Error while getting prediction for ${filepath}: ${e}`
@@ -68,7 +67,6 @@ const MagikaProcess = () => {
}
setPredictions(filePredictions);
} else if (selected === null) {
- // user cancelled the selection
console.log("User cancelled selection");
} else {
// user selected a single file
@@ -90,7 +88,7 @@ const MagikaProcess = () => {
fformat
- Examine file formats
+ Identify potential file content types
@@ -110,7 +108,11 @@ const MagikaProcess = () => {
{predictions.length > 0 && (
-
+
)}