Moved to use npm workspaces. updated imports
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
# Contribute
|
||||
|
||||
This file should introduce you with the concepts and tools used in this project.
|
||||
|
||||
## PDF Library Docs
|
||||
- [pdf-lib](https://pdf-lib.js.org) - js
|
||||
- [pdfcpu](https://pdfcpu.io) - go-wasm
|
||||
|
||||
## Adding a PDF Function
|
||||
|
||||
In order to add a PDF-Function there are several files that need to be changed. If the function is on the backend only, or on only on the frontend, you just need to add it to one of the locations. If it is available on both, you need to update both locations.
|
||||
Dependency Injection is used to accomodate for different imports across platforms.
|
||||
|
||||
Backend functions can have different implementations than their frontend counterparts if neccesary. Otherwise they can just link to their frontend implementation.
|
||||
|
||||
Registering functions will also pass them their dependencies for the specific target platform (Node, Browser)
|
||||
|
||||
[Traverse Operations](/public/traverseOperations.js)\
|
||||
|
||||
### Backend
|
||||
|
||||
[Register Functions](/functions.js)\
|
||||
[Functions Folder](/functions/)
|
||||
|
||||
Examples that go in the node-functions folder: server-side-only functions, different implementation for backend
|
||||
|
||||
### Frontend
|
||||
|
||||
[Register Functions](/public/functions.js)\
|
||||
[Functions Folder](/public/functions/)
|
||||
|
||||
Examples that go in the browser-functions folder: client-side-only functions, shared functions
|
||||
@@ -1,48 +0,0 @@
|
||||
import PDFLib from 'pdf-lib';
|
||||
import * as pdfcpuWraopper from "./public/wasm/pdfcpu-wrapper-node.js";
|
||||
|
||||
import { extractPages as dependantExtractPages } from "./public/functions/extractPages.js";
|
||||
import { impose as dependantImpose } from './public/functions/impose.js';
|
||||
import { mergePDFs as dependantMergePDFs } from './public/functions/mergePDFs.js';
|
||||
import { rotatePages as dependantRotatePages } from './public/functions/rotatePages.js';
|
||||
import { scaleContent as dependantScaleContent} from './public/functions/scaleContent.js';
|
||||
import { scalePage as dependantScalePage } from './public/functions/scalePage.js';
|
||||
import { splitPDF as dependantSplitPDF } from './public/functions/splitPDF.js';
|
||||
import { editMetadata as dependantEditMetadata } from './public/functions/editMetadata.js';
|
||||
import { organizePages as dependantOrganizePages } from './public/functions/organizePages.js';
|
||||
|
||||
export async function extractPages(snapshot, pagesToExtractArray) {
|
||||
return dependantExtractPages(snapshot, pagesToExtractArray, PDFLib);
|
||||
}
|
||||
|
||||
export async function impose(snapshot, nup, format) {
|
||||
return dependantImpose(snapshot, nup, format, pdfcpuWraopper);
|
||||
}
|
||||
|
||||
export async function mergePDFs(snapshots) {
|
||||
return dependantMergePDFs(snapshots, PDFLib);
|
||||
}
|
||||
|
||||
export async function rotatePages(snapshot, rotation) {
|
||||
return dependantRotatePages(snapshot, rotation, PDFLib);
|
||||
}
|
||||
|
||||
export async function scaleContent(snapshot, scaleFactor) {
|
||||
return dependantScaleContent(snapshot, scaleFactor, PDFLib);
|
||||
}
|
||||
|
||||
export async function scalePage(snapshot, pageSize) {
|
||||
return dependantScalePage(snapshot, pageSize, PDFLib);
|
||||
}
|
||||
|
||||
export async function splitPDF(snapshot, splitAfterPageArray) {
|
||||
return dependantSplitPDF(snapshot, splitAfterPageArray, PDFLib);
|
||||
}
|
||||
|
||||
export async function editMetadata(snapshot, metadata) {
|
||||
return dependantEditMetadata(snapshot, metadata, PDFLib);
|
||||
}
|
||||
|
||||
export async function organizePages(snapshot, operation, customOrderString) {
|
||||
return dependantOrganizePages(snapshot, operation, customOrderString, PDFLib);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "pdfjs",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"name": "@stirling-pdf/server-node",
|
||||
"version": "0.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node ."
|
||||
@@ -14,7 +13,7 @@
|
||||
"express": "^4.18.2",
|
||||
"express-fileupload": "^1.4.1",
|
||||
"pdf-lib": "^1.17.1",
|
||||
"shared-operations": "file:../shared-operations"
|
||||
"@stirling-pdf/shared-operations": "*"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { scaleContent } from "./functions/scaleContent.js";
|
||||
import { scalePage, PageSize } from "./functions/scalePage.js";
|
||||
import * as exampleWorkflows from "./exampleWorkflows.js";
|
||||
import { traverseOperations } from "./traverseOperations.js";
|
||||
import * as Functions from "./functions.js";
|
||||
import * as Functions from "./pdf-operations.js";
|
||||
|
||||
(async (workflow) => {
|
||||
const pdfFileInput = document.getElementById('pdfFile');
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
// PDFLib gets importet via index.html script-tag
|
||||
import * as pdfcpuWraopper from "./wasm/pdfcpu-wrapper-browser.js";
|
||||
import PDFLib from 'pdf-lib';
|
||||
import * as pdfcpuWraopper from "./wasm/pdfcpu-wrapper-node.js";
|
||||
|
||||
import { extractPages as dependantExtractPages } from "shared-operations/functions/extractPages.js";
|
||||
import { impose as dependantImpose } from 'shared-operations/functions/impose.js';
|
||||
import { mergePDFs as dependantMergePDFs } from 'shared-operations/functions/mergePDFs.js';
|
||||
import { rotatePages as dependantRotatePages } from 'shared-operations/functions/rotatePages.js';
|
||||
import { scaleContent as dependantScaleContent} from 'shared-operations/functions/scaleContent.js';
|
||||
import { scalePage as dependantScalePage } from 'shared-operations/functions/scalePage.js';
|
||||
import { splitPDF as dependantSplitPDF } from 'shared-operations/functions/splitPDF.js';
|
||||
import { editMetadata as dependantEditMetadata} from "shared-operations/functions/editMetadata.js";
|
||||
import { organizePages as dependantOrganizePages} from "shared-operations/functions/organizePages.js";
|
||||
import { editMetadata as dependantEditMetadata } from '@stirling-pdf/shared-operations/functions/editMetadata.js';
|
||||
import { extractPages as dependantExtractPages } from '@stirling-pdf/shared-operations/functions/extractPages.js';
|
||||
import { impose as dependantImpose } from '@stirling-pdf/shared-operations/functions/impose.js';
|
||||
import { mergePDFs as dependantMergePDFs } from '@stirling-pdf/shared-operations/functions/mergePDFs.js';
|
||||
import { organizePages as dependantOrganizePages } from '@stirling-pdf/shared-operations/functions/organizePages.js';
|
||||
import { rotatePages as dependantRotatePages } from '@stirling-pdf/shared-operations/functions/rotatePages.js';
|
||||
import { scaleContent as dependantScaleContent} from '@stirling-pdf/shared-operations/functions/scaleContent.js';
|
||||
import { scalePage as dependantScalePage } from '@stirling-pdf/shared-operations/functions/scalePage.js';
|
||||
import { splitPDF as dependantSplitPDF } from '@stirling-pdf/shared-operations/functions/splitPDF.js';
|
||||
|
||||
export async function editMetadata(snapshot, metadata) {
|
||||
return dependantEditMetadata(snapshot, metadata, PDFLib);
|
||||
}
|
||||
|
||||
export async function extractPages(snapshot, pagesToExtractArray) {
|
||||
return dependantExtractPages(snapshot, pagesToExtractArray, PDFLib);
|
||||
@@ -23,6 +27,10 @@ export async function mergePDFs(snapshots) {
|
||||
return dependantMergePDFs(snapshots, PDFLib);
|
||||
}
|
||||
|
||||
export async function organizePages(snapshot, operation, customOrderString) {
|
||||
return dependantOrganizePages(snapshot, operation, customOrderString, PDFLib);
|
||||
}
|
||||
|
||||
export async function rotatePages(snapshot, rotation) {
|
||||
return dependantRotatePages(snapshot, rotation, PDFLib);
|
||||
}
|
||||
@@ -38,11 +46,3 @@ export async function scalePage(snapshot, pageSize) {
|
||||
export async function splitPDF(snapshot, splitAfterPageArray) {
|
||||
return dependantSplitPDF(snapshot, splitAfterPageArray, PDFLib);
|
||||
}
|
||||
|
||||
export async function editMetadata(snapshot, metadata) {
|
||||
return dependantEditMetadata(snapshot, metadata, PDFLib);
|
||||
}
|
||||
|
||||
export async function organizePages(snapshot, operation, customOrderString) {
|
||||
return dependantOrganizePages(snapshot, operation, customOrderString, PDFLib);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { organizeWaitOperations } from "./organizeWaitOperations.js";
|
||||
*
|
||||
* @param {*} operations
|
||||
* @param {*} input
|
||||
* @param {import('./functions.js')} Functions
|
||||
* @param {import('./pdf-operations.js')} Functions
|
||||
* @returns
|
||||
*/
|
||||
export async function * traverseOperations(operations, input, Functions) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import crypto from 'crypto';
|
||||
import stream from "stream";
|
||||
import Archiver from 'archiver';
|
||||
|
||||
import * as Functions from "../../functions.js";
|
||||
import * as Functions from "../../public/pdf-operations.js";
|
||||
import { traverseOperations } from "../../public/traverseOperations.js";
|
||||
|
||||
const activeWorkflows = {};
|
||||
|
||||
Reference in New Issue
Block a user