feat: add custom branding, air-gapped deployment script, and updated self-hosting docs

This commit is contained in:
alam00000
2026-02-14 21:38:58 +05:30
parent 75b1d67fbd
commit 3cf435d59d
38 changed files with 1487 additions and 123 deletions

View File

@@ -4,6 +4,7 @@ import { pdfSocket } from '../sockets';
import type { SocketData } from '../types';
import { requirePdfInput, processBatch } from '../types';
import { PDFDocument } from 'pdf-lib';
import { parsePageRange } from '../../utils/pdf-operations';
export class DividePagesNode extends BaseWorkflowNode {
readonly category = 'Organize & Manage' as const;
@@ -18,6 +19,10 @@ export class DividePagesNode extends BaseWorkflowNode {
'direction',
new ClassicPreset.InputControl('text', { initial: 'vertical' })
);
this.addControl(
'pages',
new ClassicPreset.InputControl('text', { initial: '' })
);
}
async data(
@@ -30,23 +35,39 @@ export class DividePagesNode extends BaseWorkflowNode {
const direction =
dirCtrl?.value === 'horizontal' ? 'horizontal' : 'vertical';
const pagesCtrl = this.controls['pages'] as
| ClassicPreset.InputControl<'text'>
| undefined;
const rangeStr = (pagesCtrl?.value || '').trim();
return {
pdf: await processBatch(pdfInputs, async (input) => {
const srcDoc = await PDFDocument.load(input.bytes);
const newDoc = await PDFDocument.create();
for (let i = 0; i < srcDoc.getPageCount(); i++) {
const [page1] = await newDoc.copyPages(srcDoc, [i]);
const [page2] = await newDoc.copyPages(srcDoc, [i]);
const { width, height } = page1.getSize();
if (direction === 'vertical') {
page1.setCropBox(0, 0, width / 2, height);
page2.setCropBox(width / 2, 0, width / 2, height);
const totalPages = srcDoc.getPageCount();
const pagesToDivide: Set<number> = rangeStr
? new Set(parsePageRange(rangeStr, totalPages))
: new Set(Array.from({ length: totalPages }, (_, i) => i));
for (let i = 0; i < totalPages; i++) {
if (pagesToDivide.has(i)) {
const [page1] = await newDoc.copyPages(srcDoc, [i]);
const [page2] = await newDoc.copyPages(srcDoc, [i]);
const { width, height } = page1.getSize();
if (direction === 'vertical') {
page1.setCropBox(0, 0, width / 2, height);
page2.setCropBox(width / 2, 0, width / 2, height);
} else {
page1.setCropBox(0, height / 2, width, height / 2);
page2.setCropBox(0, 0, width, height / 2);
}
newDoc.addPage(page1);
newDoc.addPage(page2);
} else {
page1.setCropBox(0, height / 2, width, height / 2);
page2.setCropBox(0, 0, width, height / 2);
const [copiedPage] = await newDoc.copyPages(srcDoc, [i]);
newDoc.addPage(copiedPage);
}
newDoc.addPage(page1);
newDoc.addPage(page2);
}
const pdfBytes = await newDoc.save();
return {