mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-06 18:30:57 +00:00
Undid a few things that broke in the last commit
This commit is contained in:
parent
55f55afed2
commit
7b702734f3
@ -1,5 +1,7 @@
|
||||
|
||||
import SharedOperations from '@stirling-pdf/shared-operations'
|
||||
|
||||
// Import injected libraries here!
|
||||
import * as pdfcpuWrapper from "@stirling-pdf/shared-operations/wasm/pdfcpu/pdfcpu-wrapper-browser.js";
|
||||
|
||||
async function impose(snapshot: any, nup: number, format: string) {
|
||||
|
@ -1,17 +1,5 @@
|
||||
import { organizeWaitOperations } from "./organizeWaitOperations.js";
|
||||
|
||||
import { extractPages } from "../functions/extractPages.js";
|
||||
import { impose } from '../functions/impose.js';
|
||||
import { mergePDFs } from '../functions/mergePDFs.js';
|
||||
import { rotatePages } from '../functions/rotatePages.js';
|
||||
import { scaleContent} from '../functions/scaleContent.js';
|
||||
import { scalePage } from '../functions/scalePage.js';
|
||||
import { splitPDF } from '../functions/splitPDF.js';
|
||||
import { Metadata as dependantEditMetadata } from '../functions/editMetadata.js';
|
||||
import { organizePages } from '../functions/organizePages.js';
|
||||
import { removeBlankPages} from '../functions/removeBlankPages.js';
|
||||
import { splitOn } from "../functions/splitOn.js";
|
||||
|
||||
/**
|
||||
* @typedef PDF
|
||||
* @property {string} originalFileName
|
||||
@ -25,7 +13,7 @@ import { splitOn } from "../functions/splitOn.js";
|
||||
* @param {PDF|PDF[]} input
|
||||
* @returns {}
|
||||
*/
|
||||
export async function * traverseOperations(operations, input) {
|
||||
export async function * traverseOperations(operations, input, Operations) {
|
||||
const waitOperations = organizeWaitOperations(operations);
|
||||
/** @type {PDF[]} */ let results = [];
|
||||
yield* nextOperation(operations, input);
|
||||
@ -85,13 +73,13 @@ export async function * traverseOperations(operations, input) {
|
||||
case "extract":
|
||||
yield* nToN(input, operation, async (input) => {
|
||||
input.fileName += "_extractedPages";
|
||||
input.buffer = await extractPages(input.buffer, operation.values["pagesToExtractArray"]);
|
||||
input.buffer = await Operations.extractPages(input.buffer, operation.values["pagesToExtractArray"]);
|
||||
});
|
||||
break;
|
||||
case "impose":
|
||||
yield* nToN(input, operation, async (input) => {
|
||||
input.fileName += "_imposed";
|
||||
input.buffer = await impose(input.buffer, operation.values["nup"], operation.values["format"]);
|
||||
input.buffer = await Operations.impose(input.buffer, operation.values["nup"], operation.values["format"]);
|
||||
});
|
||||
break;
|
||||
case "merge":
|
||||
@ -99,20 +87,20 @@ export async function * traverseOperations(operations, input) {
|
||||
return {
|
||||
originalFileName: inputs.map(input => input.originalFileName).join("_and_"),
|
||||
fileName: inputs.map(input => input.fileName).join("_and_") + "_merged",
|
||||
buffer: await mergePDFs(inputs.map(input => input.buffer))
|
||||
buffer: await Operations.mergePDFs(inputs.map(input => input.buffer))
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "rotate":
|
||||
yield* nToN(input, operation, async (input) => {
|
||||
input.fileName += "_turned";
|
||||
input.buffer = await rotatePages(input.buffer, operation.values["rotation"]);
|
||||
input.buffer = await Operations.rotatePages(input.buffer, operation.values["rotation"]);
|
||||
});
|
||||
break;
|
||||
case "split":
|
||||
// TODO: A split might break the done condition, it may count multiple times. Needs further testing!
|
||||
yield* oneToN(input, operation, async (input) => {
|
||||
const splitResult = await splitPDF(input.buffer, operation.values["pagesToSplitAfterArray"]);
|
||||
const splitResult = await Operations.splitPDF(input.buffer, operation.values["pagesToSplitAfterArray"]);
|
||||
|
||||
const splits = [];
|
||||
for (let j = 0; j < splitResult.length; j++) {
|
||||
@ -128,24 +116,24 @@ export async function * traverseOperations(operations, input) {
|
||||
case "editMetadata":
|
||||
yield* nToN(input, operation, async (input) => {
|
||||
input.fileName += "_metadataEdited";
|
||||
input.buffer = await editMetadata(input.buffer, operation.values["metadata"]);
|
||||
input.buffer = await Operations.editMetadata(input.buffer, operation.values["metadata"]);
|
||||
});
|
||||
break;
|
||||
case "organizePages":
|
||||
yield* nToN(input, operation, async (input) => {
|
||||
input.fileName += "_pagesOrganized";
|
||||
input.buffer = await organizePages(input.buffer, operation.values["operation"], operation.values["customOrderString"]);
|
||||
input.buffer = await Operations.organizePages(input.buffer, operation.values["operation"], operation.values["customOrderString"]);
|
||||
});
|
||||
break;
|
||||
case "removeBlankPages":
|
||||
yield* nToN(input, operation, async (input) => {
|
||||
input.fileName += "_removedBlanks";
|
||||
input.buffer = await removeBlankPages(input.buffer, operation.values["whiteThreashold"]);
|
||||
input.buffer = await Operations.removeBlankPages(input.buffer, operation.values["whiteThreashold"]);
|
||||
});
|
||||
break;
|
||||
case "splitOn":
|
||||
yield* oneToN(input, operation, async (input) => {
|
||||
const splitResult = await splitOn(input.buffer, operation.values["type"], operation.values["whiteThreashold"]);
|
||||
const splitResult = await Operations.splitOn(input.buffer, operation.values["type"], operation.values["whiteThreashold"]);
|
||||
const splits = [];
|
||||
for (let j = 0; j < splitResult.length; j++) {
|
||||
splits.push({
|
||||
|
Loading…
x
Reference in New Issue
Block a user