Cleanup to help me debug build errors
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { PdfFile } from "wrappers/PdfFile";
|
||||
import { PdfFile } from "../wrappers/PdfFile";
|
||||
import { Action } from "../../declarations/Action";
|
||||
import Joi from "@stirling-tools/joi";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import i18next from "i18next";
|
||||
import resourcesToBackend from "i18next-resources-to-backend";
|
||||
|
||||
i18next
|
||||
.use(resourcesToBackend((language, namespace) => import(`./public/locales/${namespace}/${language}.json`, {
|
||||
.use(resourcesToBackend((language: string, namespace: string) => import(`../public/locales/${namespace}/${language}.json`, {
|
||||
assert: { type: "json" },
|
||||
})))
|
||||
.init({
|
||||
|
||||
8
shared-operations/src/wasm/browserfs.min.js
vendored
8
shared-operations/src/wasm/browserfs.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -61,16 +61,13 @@ async function loadFileAsync(data) {
|
||||
`/input.pdf`,
|
||||
]);
|
||||
|
||||
console.log("Exit Code: " + exitcode);
|
||||
if (exitcode !== 0)
|
||||
throw new Error("There was an error validating your PDFs");
|
||||
|
||||
console.log(`File is Valid`);
|
||||
}
|
||||
|
||||
export async function impose(snapshot, nup, format) {
|
||||
|
||||
};
|
||||
|
||||
export async function oneToOne(wasmArray, snapshot) {
|
||||
await loadFileAsync(Buffer.from(snapshot));
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ const wasmfs = new WasmFs();
|
||||
|
||||
// TODO: This can later be defered to load asynchronously
|
||||
(async () => {
|
||||
configureFs();
|
||||
await loadWasm();
|
||||
await configureFs();
|
||||
})();
|
||||
|
||||
async function configureFs() {
|
||||
function configureFs() {
|
||||
// Can't use BrowserFS: https://github.com/jvilk/BrowserFS/issues/271
|
||||
fs = wasmfs.fs;
|
||||
global.fs = fs;
|
||||
@@ -43,6 +43,9 @@ const runWasm = async (param) => {
|
||||
|
||||
async function loadFileAsync(data) {
|
||||
console.log(`Writing file to Disk`);
|
||||
if(fs === undefined) {
|
||||
throw new Error("FS hasn't loaded, this should never happen.")
|
||||
}
|
||||
fs.writeFileSync(`input.pdf`, data);
|
||||
console.log(`Write done. Validating...`);
|
||||
let exitcode = await runWasm([
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import { Operator } from "../functions";
|
||||
import i18next from "i18next";
|
||||
|
||||
function getCompileTimeOperatorList(): string[] {
|
||||
return import.meta.compileTime("./listOperatorsInDir.ts"); // The will compile to ["impose", "extractPages", etc...]
|
||||
}
|
||||
const compileTimeOperatorList: string[] = ["impose"]; import.meta.compileTime("./listOperatorsInDir.ts"); // The will compile to ["impose", "extractPages", etc...]
|
||||
|
||||
export async function getOperatorByName(name: string): Promise<typeof Operator | undefined> {
|
||||
// Check if exists
|
||||
if(!getCompileTimeOperatorList().includes(name)) return;
|
||||
if(!compileTimeOperatorList.includes(name)) return;
|
||||
|
||||
i18next.loadNamespaces(name, (err, t) => { if (err) throw err; });
|
||||
return (await import("../functions/" + name + ".ts"))[capitalizeFirstLetter(name)];
|
||||
const loadedModule = await import("../functions/" + name + ".ts");
|
||||
return loadedModule[capitalizeFirstLetter(name)];
|
||||
}
|
||||
|
||||
export function listOperatorNames(): string[] {
|
||||
const availableOperators = getCompileTimeOperatorList();
|
||||
const availableOperators = compileTimeOperatorList;
|
||||
// TODO: Implement this
|
||||
return availableOperators;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,11 @@ export async function traverseOperations(operations: Action[], input: PdfFile[],
|
||||
async function nextOperation(actions: Action[] | undefined, input: PdfFile[], progressCallback: (state: Progress) => void): Promise<void> {
|
||||
if(!actions || (Array.isArray(actions) && actions.length == 0)) { // isEmpty
|
||||
if(input && Array.isArray(input)) {
|
||||
console.log("operation done: " + input[0].filename + (input.length > 1 ? "+" : ""));
|
||||
console.log("operation done: " + input.map(file => file.filename) + (input.length > 1 ? "+" : ""));
|
||||
results = results.concat(input);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < actions.length; i++) {
|
||||
await computeOperation(actions[i], Object.assign([], input), progressCallback); // structuredClone-like for ts TODO: test if this really works
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
"baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */
|
||||
"paths": {
|
||||
"#pdfcpu": ["../../shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server"],
|
||||
}
|
||||
}
|
||||
} /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
}
|
||||
Reference in New Issue
Block a user