diff --git a/client-tauri/package.json b/client-tauri/package.json index eb95ccaa3..40215a0d5 100644 --- a/client-tauri/package.json +++ b/client-tauri/package.json @@ -7,7 +7,9 @@ "dev": "vite", "build": "tsc && vite build", "preview": "vite preview", - "tauri": "tauri" + "tauri-dev (currently broken)": "tauri dev", + "tauri-build-debug": "tauri build --debug", + "tauri-build": "tauri build" }, "dependencies": { "@stirling-pdf/shared-operations": "^0.0.0", diff --git a/client-tauri/src/App.tsx b/client-tauri/src/App.tsx index 28d489cd9..fd458fc4c 100644 --- a/client-tauri/src/App.tsx +++ b/client-tauri/src/App.tsx @@ -5,8 +5,8 @@ import Home from "./pages/Home"; import About from "./pages/About"; import Dashboard from "./pages/Dashboard"; import Dynamic from "./pages/Dynamic"; -import ToPdf from "./pages/convert/ToPdf"; -import Impose from "./pages/page-operations/Impose"; +// import ToPdf from "./pages/convert/ToPdf"; +// import Impose from "./pages/page-operations/Impose"; import NoMatch from "./pages/NoMatch"; import NavBar from "./components/NavBar"; @@ -53,11 +53,11 @@ export default function App() { } /> }> - } /> + {/* } /> */} } /> }> - } /> + {/* } /> */} } /> diff --git a/client-tauri/src/components/DynamicParameterFields.tsx b/client-tauri/src/components/DynamicParameterFields.tsx deleted file mode 100644 index 97437508b..000000000 --- a/client-tauri/src/components/DynamicParameterFields.tsx +++ /dev/null @@ -1,63 +0,0 @@ - -import Form from "react-bootstrap/Form"; -import { useTranslation } from "react-i18next"; -import { FieldConstraint, RecordConstraint } from "@stirling-pdf/shared-operations/src/dynamic-ui/OperatorConstraints"; - -interface DynamicParameterFieldsProps { - constraints: RecordConstraint; - parentKeyPath?: string[]; -} - -const DynamicParameterFields: React.FC = ({constraints, parentKeyPath=["DPF"]}) => { - const { t } = useTranslation(); - - return (<> - {Object.entries(constraints.record).map(([fieldName, value]) => { - console.log(fieldName, value); - const globallyUniqueId = joinKeyPath([...parentKeyPath, fieldName]); - return
- - {fieldConstraintToElement(fieldName, parentKeyPath, globallyUniqueId, value)} -
; - })} - ); -}; - -function joinKeyPath(keyPath: string[]) { - return keyPath.join("."); -} - -function fieldConstraintToElement(fieldName: string, parentKeyPath: string[], globallyUniqueId: string, fieldConstraint: FieldConstraint) { - if (Array.isArray(fieldConstraint.type)) { - if (fieldConstraint.type.every(e => typeof e == "string" || typeof e == "number")) { - return ( - - - {fieldConstraint.type.map((option) => )} - - ); - } else { - return
Error: Field type '{fieldConstraint.type}' not supported
; - } - } else if (typeof fieldConstraint.type == "string") { - switch (fieldConstraint.type) { - case "file.pdf": - return ; - case "files.pdf": - return ; - case "string": - return ; - case "number": - return ; - default: - return
Error: Field type '{fieldConstraint.type}' not supported
; - } - } else if (fieldConstraint.type instanceof RecordConstraint) { - //return - return
Error: Field type 'RecordConstraint' not supported yet!
; - } - - return
Error: Field type '{fieldConstraint.type}' not supported
; -} - -export default DynamicParameterFields; \ No newline at end of file diff --git a/client-tauri/src/components/fields/BuildFields.tsx b/client-tauri/src/components/fields/BuildFields.tsx index e07bc8840..c85b1a09a 100644 --- a/client-tauri/src/components/fields/BuildFields.tsx +++ b/client-tauri/src/components/fields/BuildFields.tsx @@ -20,7 +20,7 @@ export function BuildFields({ schemaDescription, onSubmit }: BuildFieldsProps) {
{ onSubmit(e); e.preventDefault(); }}> { - values ? Object.keys(values).map((key, i) => { + values ? Object.keys(values).map((key) => { return () }) : undefined } diff --git a/client-tauri/src/components/fields/StringField.tsx b/client-tauri/src/components/fields/StringField.tsx deleted file mode 100644 index 532092dbc..000000000 --- a/client-tauri/src/components/fields/StringField.tsx +++ /dev/null @@ -1,12 +0,0 @@ -interface StringFieldProps { - /** The text to display inside the button */ - validValues: string[]; - exampleValues: string; -} - - -export function StringField({ validValues, exampleValues }: StringFieldProps) { - return ( - - ); -} \ No newline at end of file diff --git a/client-tauri/src/pages/Dynamic.tsx b/client-tauri/src/pages/Dynamic.tsx index 182931c66..fad5f39f1 100644 --- a/client-tauri/src/pages/Dynamic.tsx +++ b/client-tauri/src/pages/Dynamic.tsx @@ -1,6 +1,6 @@ import { Link } from "react-router-dom"; -import { BaseSyntheticEvent, createContext, useRef, useState } from "react"; +import { BaseSyntheticEvent, useRef, useState } from "react"; import { Operator } from "@stirling-pdf/shared-operations/src/functions"; import i18next from "i18next"; import Joi from "@stirling-tools/joi"; @@ -26,6 +26,7 @@ function Dynamic() { console.log("Loading namespaces for", selectedValue); await i18next.loadNamespaces(selectedValue, (err, t) => { if (err) throw err; + console.log(t); }); console.log("Loading namespaces done"); @@ -110,7 +111,7 @@ function Dynamic() {
diff --git a/client-tauri/src/pages/convert/ToPdf.tsx b/client-tauri/src/pages/convert/ToPdf.tsx deleted file mode 100644 index e193060de..000000000 --- a/client-tauri/src/pages/convert/ToPdf.tsx +++ /dev/null @@ -1,16 +0,0 @@ - -import { isLibreOfficeInstalled } from "../../utils/libre-office-utils"; - -const hasLibreOffice = await isLibreOfficeInstalled(); -console.log(hasLibreOffice); - -function About() { - return ( -
-

Convert to PDF

- {"hasLibreOffice: "+hasLibreOffice} -
- ); -} - -export default About; diff --git a/client-tauri/src/pages/page-operations/Impose.tsx b/client-tauri/src/pages/page-operations/Impose.tsx deleted file mode 100644 index 9120faeb6..000000000 --- a/client-tauri/src/pages/page-operations/Impose.tsx +++ /dev/null @@ -1,18 +0,0 @@ - -import DynamicParameterFields from "../../components/DynamicParameterFields"; -// import { ImposeParamConstraints } from "@stirling-pdf/shared-operations/src/functions/impose"; -import { useTranslation } from "react-i18next"; - -function Impose() { - const { t } = useTranslation(); - return ( -
-

{t("pageLayout.header")}

- - {/* */} - -
- ); -} - -export default Impose; diff --git a/client-tauri/src/utils/pdf-operations.ts b/client-tauri/src/utils/pdf-operations.ts deleted file mode 100644 index af772f2bb..000000000 --- a/client-tauri/src/utils/pdf-operations.ts +++ /dev/null @@ -1,17 +0,0 @@ - -import SharedOperations, { OperationsType } from "@stirling-pdf/shared-operations/src"; -import { ImposeParamsType } from "@stirling-pdf/shared-operations/src/functions/impose"; -import { PdfFile } from "@stirling-pdf/shared-operations/src/wrappers/PdfFile"; - -// Import injected libraries here! -import * as pdfcpuWrapper from "@stirling-pdf/shared-operations/wasm/pdfcpu/pdfcpu-wrapper-browser.js"; - -async function impose(params: ImposeParamsType): Promise { - return SharedOperations.impose(params, pdfcpuWrapper); -} - -const toExport: OperationsType = { - ...SharedOperations, - impose, -}; -export default toExport; diff --git a/client-tauri/tsconfig.json b/client-tauri/tsconfig.json index ce8a07e6d..9bd0514c1 100644 --- a/client-tauri/tsconfig.json +++ b/client-tauri/tsconfig.json @@ -22,7 +22,8 @@ }, "include": [ "src", - "declarations/*.d.ts" + "declarations/*.d.ts", + "../shared-operations/declarations/*.d.ts" ], "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/shared-operations/src/functions/common/getPagesByIndex.ts b/shared-operations/src/functions/common/getPagesByIndex.ts index 63940824d..ab575dbb5 100644 --- a/shared-operations/src/functions/common/getPagesByIndex.ts +++ b/shared-operations/src/functions/common/getPagesByIndex.ts @@ -7,7 +7,7 @@ export async function getPages(file: PdfFile, pageIndexes: number[]): Promise= pdfLibDocument.getPageCount()) { + if(Math.max(...pageIndexes) > pdfLibDocument.getPageCount()) { throw new Error(`The PDF document only has ${pdfLibDocument.getPageCount()} pages and you tried to extract page ${Math.max(...pageIndexes)}`); } diff --git a/shared-operations/src/functions/index.ts b/shared-operations/src/functions/index.ts index 4fa729848..0f2ac4a4c 100644 --- a/shared-operations/src/functions/index.ts +++ b/shared-operations/src/functions/index.ts @@ -35,7 +35,8 @@ export class Operator { } async run(input: PdfFile[] | any[], progressCallback: (progress: Progress) => void): Promise { - return []; + progressCallback({ curFileProgress: 1, operationProgress: 1 }) + return input; } } diff --git a/shared-operations/src/workflow/operatorAccessor.ts b/shared-operations/src/workflow/operatorAccessor.ts index e2c5f792d..245321170 100644 --- a/shared-operations/src/workflow/operatorAccessor.ts +++ b/shared-operations/src/workflow/operatorAccessor.ts @@ -7,7 +7,7 @@ export async function getOperatorByName(name: string): Promise { if (err) throw err; }); + i18next.loadNamespaces(name, (err, t) => { if (err) throw err; console.log(t) }); const loadedModule = await import("../functions/" + name + ".ts"); const operator = loadedModule[capitalizeFirstLetter(name)]; if(!operator) {