diff --git a/client-tauri/src/utils/libre-office-utils.tsx b/client-tauri/src/utils/libre-office-utils.tsx index 47f5c432..e254f47e 100644 --- a/client-tauri/src/utils/libre-office-utils.tsx +++ b/client-tauri/src/utils/libre-office-utils.tsx @@ -1,6 +1,6 @@ import { readBinaryFile, writeBinaryFile, removeDir, BaseDirectory } from '@tauri-apps/api/fs'; -import { PdfFile, fromUint8Array } from '@stirling-pdf/shared-operations/wrappers/PdfFile' +import { PdfFile, fromUint8Array } from '@stirling-pdf/shared-operations/src/wrappers/PdfFile' import { runShell } from './tauri-wrapper'; export async function fileToPdf(byteArray: Uint8Array, filename: string): Promise { diff --git a/client-tauri/src/utils/pdf-operations.ts b/client-tauri/src/utils/pdf-operations.ts index 38519435..ee422c52 100644 --- a/client-tauri/src/utils/pdf-operations.ts +++ b/client-tauri/src/utils/pdf-operations.ts @@ -1,5 +1,5 @@ -import SharedOperations from '@stirling-pdf/shared-operations' +import SharedOperations, { OperationsUseages } from '@stirling-pdf/shared-operations/src' // Import injected libraries here! import * as pdfcpuWrapper from "@stirling-pdf/shared-operations/wasm/pdfcpu/pdfcpu-wrapper-browser.js"; @@ -8,7 +8,8 @@ async function impose(snapshot: any, nup: number, format: string) { return SharedOperations.impose(snapshot, nup, format, pdfcpuWrapper) } -export default { +const toExport: OperationsUseages = { ...SharedOperations, impose, } +export default toExport; diff --git a/server-node/src/utils/pdf-operations.ts b/server-node/src/utils/pdf-operations.ts index 79341dd1..f31a498b 100644 --- a/server-node/src/utils/pdf-operations.ts +++ b/server-node/src/utils/pdf-operations.ts @@ -1,14 +1,15 @@ -import SharedOperations from "@stirling-pdf/shared-operations/src"; +import SharedOperations, { OperationsUseages } from "@stirling-pdf/shared-operations/src"; // Import injected libraries here! //import * as pdfcpuWrapper from "@stirling-pdf/shared-operations/wasm/pdfcpu/pdfcpu-wrapper-node.js"; -/*async function impose(snapshot: any, nup: number, format: string) { - return SharedOperations.impose(snapshot, nup, format, pdfcpuWrapper); -}*/ - -export default { - ...SharedOperations, - //impose, +async function impose(snapshot: any, nup: number, format: string) { + return SharedOperations.impose(snapshot, nup, format, null); // TODO change null to pdfcpuWrapper } + +const toExport: OperationsUseages = { + ...SharedOperations, + impose, +} +export default toExport; diff --git a/shared-operations/src/index.ts b/shared-operations/src/index.ts index bad36c99..6810c3fd 100644 --- a/shared-operations/src/index.ts +++ b/shared-operations/src/index.ts @@ -11,7 +11,7 @@ import { splitOn } from './functions/splitOn'; import { splitPDF } from './functions/splitPDF'; import { updateMetadata } from "./functions/updateMetadata"; -export default { +const toExport = { sortPagesWithPreset, rearrangePages, selectPages, removePages, removeBlankPages, impose, mergePDFs, @@ -21,4 +21,12 @@ export default { splitOn, splitPDF, updateMetadata, -} \ No newline at end of file +} +export default toExport; + +// Overide fields in the type of toExport, with the given fields and types. This seems to magically work! +// https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l +type Override = Omit & T2; +export type OperationsUseages = Override any; +}>; \ No newline at end of file