Add visual workflow builder, fix critical bugs, and add Arabic i18n support

This commit is contained in:
alam00000
2026-02-08 17:05:40 +05:30
parent 36ebb3b429
commit 5d8b83e105
118 changed files with 14151 additions and 2357 deletions

View File

@@ -0,0 +1,45 @@
import { ClassicPreset } from 'rete';
import { BaseWorkflowNode } from './base-node';
import { pdfSocket } from '../sockets';
import type { SocketData } from '../types';
import { requirePdfInput, processBatch } from '../types';
import { PDFDocument } from 'pdf-lib';
export class ReversePagesNode extends BaseWorkflowNode {
readonly category = 'Organize & Manage' as const;
readonly icon = 'ph-sort-descending';
readonly description = 'Reverse page order';
constructor() {
super('Reverse Pages');
this.addInput('pdf', new ClassicPreset.Input(pdfSocket, 'PDF'));
this.addOutput('pdf', new ClassicPreset.Output(pdfSocket, 'Reversed PDF'));
}
async data(
inputs: Record<string, SocketData[]>
): Promise<Record<string, SocketData>> {
const pdfInputs = requirePdfInput(inputs, 'Reverse Pages');
return {
pdf: await processBatch(pdfInputs, async (input) => {
const srcDoc = await PDFDocument.load(input.bytes);
const pageCount = srcDoc.getPageCount();
const newDoc = await PDFDocument.create();
const reversedIndices = Array.from(
{ length: pageCount },
(_, i) => pageCount - 1 - i
);
const copiedPages = await newDoc.copyPages(srcDoc, reversedIndices);
copiedPages.forEach((page) => newDoc.addPage(page));
const pdfBytes = await newDoc.save();
return {
type: 'pdf',
document: newDoc,
bytes: new Uint8Array(pdfBytes),
filename: input.filename.replace(/\.pdf$/i, '_reversed.pdf'),
};
}),
};
}
}