🧩 Comlink funkiness
This commit is contained in:
@@ -33,7 +33,3 @@ export async function extractCoverFromComicBookArchive(
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function foo() {
|
||||
return { as: "af" };
|
||||
}
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
import * as React from "react";
|
||||
import { hot } from "react-hot-loader";
|
||||
import _ from "lodash";
|
||||
import axios from "axios";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { connect } from "react-redux";
|
||||
import { comicinfoAPICall } from "../actions/comicinfo.actions";
|
||||
import { IFolderData } from "../shared/interfaces/comicinfo.interfaces";
|
||||
import * as Comlink from "comlink";
|
||||
import WorkerAdd from "../workers/extractCovers.worker";
|
||||
import { wrap, proxy } from "comlink";
|
||||
interface IProps {
|
||||
matches: unknown;
|
||||
}
|
||||
@@ -31,14 +26,16 @@ class Import extends React.Component<IProps, IState> {
|
||||
});
|
||||
}
|
||||
|
||||
public async startFolderWalk(): Promise<void> {
|
||||
const { importComicBooks } = Comlink.wrap(new WorkerAdd());
|
||||
const folderWalkResults = await importComicBooks;
|
||||
this.setState({
|
||||
folderWalkResults,
|
||||
});
|
||||
public async startFolderWalk() {
|
||||
const multiply = wrap(
|
||||
new Worker(
|
||||
"http://localhost:3000/src/client/workers/extractCovers.worker.js",
|
||||
{ type: "module" },
|
||||
),
|
||||
);
|
||||
const sutarfeni = await proxy(multiply);
|
||||
console.log("foo", sutarfeni());
|
||||
}
|
||||
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
|
||||
10
src/client/workers/extractCovers.worker.js
Normal file
10
src/client/workers/extractCovers.worker.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as Comlink from "comlink";
|
||||
// importScripts("../../../node_modules/comlink/dist/umd/comlink.js");
|
||||
// import { walkFolder } from "../actions/fileops.actions";
|
||||
console.log("asdad");
|
||||
const comicBookImportProcessor = () => {
|
||||
// console.log(walkFolder);
|
||||
return "foo";
|
||||
};
|
||||
|
||||
Comlink.expose(comicBookImportProcessor);
|
||||
@@ -1,23 +0,0 @@
|
||||
import * as Comlink from "comlink";
|
||||
import { walkFolder } from "../actions/fileops.actions";
|
||||
import { IExtractionOptions } from "../../server/interfaces/folder.interface";
|
||||
import { IFolderData } from "../shared/interfaces/comicinfo.interfaces";
|
||||
|
||||
async function importComicBooks(): Promise<IFolderData[]> {
|
||||
// 1. Walk the folder structure
|
||||
// 2. Scan for .cbz, .cbr
|
||||
// 3. extract cover image
|
||||
// 4. Calculate image hash
|
||||
// 5. Get metadata, add to data model
|
||||
// 5. Save cover to disk
|
||||
// 6. Save model to mongo
|
||||
|
||||
const fileObjects = await walkFolder("./comics");
|
||||
return fileObjects;
|
||||
}
|
||||
|
||||
Comlink.expose({
|
||||
importComicBooks,
|
||||
});
|
||||
|
||||
export default null as any;
|
||||
Reference in New Issue
Block a user