From e7b4c93481c69fac61d4781ae6dfbb16f2352f2a Mon Sep 17 00:00:00 2001
From: sbplat <71648843+sbplat@users.noreply.github.com>
Date: Mon, 5 Feb 2024 12:15:01 -0500
Subject: [PATCH 1/4] fix: use fork of joi with full features on browser
---
.gitignore | 3 +-
client-tauri/src/pages/Dynamic.tsx | 6 ++--
package-lock.json | 29 ++++++++++++++++++++
package.json | 5 +++-
shared-operations/src/functions/impose.ts | 2 +-
shared-operations/src/functions/index.ts | 2 +-
shared-operations/src/functions/scalePage.ts | 2 +-
shared-operations/src/wrappers/PdfFile.ts | 2 +-
shared-operations/src/wrappers/PdfFileJoi.ts | 2 +-
9 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/.gitignore b/.gitignore
index 1ef8bc238..cf7ba3dda 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ node_modules/
dist/
android/
ios/
-releases/
\ No newline at end of file
+releases/
+.vscode/
diff --git a/client-tauri/src/pages/Dynamic.tsx b/client-tauri/src/pages/Dynamic.tsx
index 93ff3ad7e..b8cbdda82 100644
--- a/client-tauri/src/pages/Dynamic.tsx
+++ b/client-tauri/src/pages/Dynamic.tsx
@@ -17,9 +17,9 @@ function Dynamic() {
const LoadingModule = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`) as Promise<{ [key: string]: typeof Operator }>;
LoadingModule.then((Module) => {
const Operator = Module[capitalizeFirstLetter(selectedValue)];
- const description = Operator.schema.describe(); // TODO: The browser build of joi does not include describe.
-
- console.log(description);
+ const description = Operator.schema.describe();
+
+ console.log("abc", description);
// TODO: use description to generate fields
});
});
diff --git a/package-lock.json b/package-lock.json
index 96bc634de..b9410f251 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,6 +10,9 @@
"server-node",
"shared-operations"
],
+ "dependencies": {
+ "@stirling-tools/joi": "github:Stirling-Tools/joi"
+ },
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
@@ -1924,6 +1927,32 @@
"resolved": "shared-operations",
"link": true
},
+ "node_modules/@stirling-tools/joi": {
+ "version": "17.12.0",
+ "resolved": "git+ssh://git@github.com/Stirling-Tools/joi.git#f2994904b4716082ac74449cfa1f1574616c5883",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@hapi/address": "^5.1.1",
+ "@hapi/formula": "^3.0.2",
+ "@hapi/hoek": "^11.0.2",
+ "@hapi/pinpoint": "^2.0.1",
+ "@hapi/tlds": "^1.0.2",
+ "@hapi/topo": "^6.0.2"
+ }
+ },
+ "node_modules/@stirling-tools/joi/node_modules/@hapi/hoek": {
+ "version": "11.0.4",
+ "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-11.0.4.tgz",
+ "integrity": "sha512-PnsP5d4q7289pS2T2EgGz147BFJ2Jpb4yrEdkpz2IhgEUzos1S7HTl7ezWh1yfYzYlj89KzLdCRkqsP6SIryeQ=="
+ },
+ "node_modules/@stirling-tools/joi/node_modules/@hapi/topo": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-6.0.2.tgz",
+ "integrity": "sha512-KR3rD5inZbGMrHmgPxsJ9dbi6zEK+C3ZwUwTa+eMwWLz7oijWUTWD2pMSNNYJAU6Qq+65NkxXjqHr/7LM2Xkqg==",
+ "dependencies": {
+ "@hapi/hoek": "^11.0.2"
+ }
+ },
"node_modules/@swc/core": {
"version": "1.3.102",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.102.tgz",
diff --git a/package.json b/package.json
index 11178e69b..fe47124ed 100644
--- a/package.json
+++ b/package.json
@@ -21,5 +21,8 @@
"engines": {
"npm": ">=7.24.2"
},
- "engineStrict": true
+ "engineStrict": true,
+ "dependencies": {
+ "@stirling-tools/joi": "github:Stirling-Tools/joi"
+ }
}
diff --git a/shared-operations/src/functions/impose.ts b/shared-operations/src/functions/impose.ts
index 516f4ad18..dbd1bb57b 100644
--- a/shared-operations/src/functions/impose.ts
+++ b/shared-operations/src/functions/impose.ts
@@ -4,7 +4,7 @@ import { Operator, Progress, oneToOne } from ".";
import * as pdfcpuWrapper from "#pdfcpu"; // This is updated by tsconfig.json/paths for the context (browser, node, etc.) this module is used in.
-import Joi from "joi";
+import Joi from "@stirling-tools/joi";
import { JoiPDFFileSchema } from "../wrappers/PdfFileJoi";
import i18next from "i18next";
diff --git a/shared-operations/src/functions/index.ts b/shared-operations/src/functions/index.ts
index 96444e912..49985e134 100644
--- a/shared-operations/src/functions/index.ts
+++ b/shared-operations/src/functions/index.ts
@@ -1,5 +1,5 @@
import { Action } from "../../declarations/Action";
-import Joi from "joi";
+import Joi from "@stirling-tools/joi";
export interface ValidationResult {
valid: boolean,
diff --git a/shared-operations/src/functions/scalePage.ts b/shared-operations/src/functions/scalePage.ts
index b582f9a78..41505c2a9 100644
--- a/shared-operations/src/functions/scalePage.ts
+++ b/shared-operations/src/functions/scalePage.ts
@@ -1,5 +1,5 @@
-import Joi from "joi";
+import Joi from "@stirling-tools/joi";
import { PDFPage } from "pdf-lib";
import { PdfFile, RepresentationType, JoiPDFFileSchema } from "../wrappers/PdfFileJoi";
diff --git a/shared-operations/src/wrappers/PdfFile.ts b/shared-operations/src/wrappers/PdfFile.ts
index 2c9273a0f..09e93c4ed 100644
--- a/shared-operations/src/wrappers/PdfFile.ts
+++ b/shared-operations/src/wrappers/PdfFile.ts
@@ -1,7 +1,7 @@
import * as PDFJS from "pdfjs-dist";
import type { PDFDocumentProxy as PDFJSDocument } from "pdfjs-dist/types/src/display/api";
import { PDFDocument as PDFLibDocument } from "pdf-lib";
-import Joi from "joi";
+import Joi from "@stirling-tools/joi";
export enum RepresentationType {
Uint8Array,
diff --git a/shared-operations/src/wrappers/PdfFileJoi.ts b/shared-operations/src/wrappers/PdfFileJoi.ts
index 9955f238a..cdc6ab2be 100644
--- a/shared-operations/src/wrappers/PdfFileJoi.ts
+++ b/shared-operations/src/wrappers/PdfFileJoi.ts
@@ -1,4 +1,4 @@
-import Joi from "joi";
+import Joi from "@stirling-tools/joi";
import { PdfFile } from "./PdfFile";
export const JoiPDFFileSchema = Joi.custom((value: Express.Multer.File[] /* <- also handles single files */ | PdfFile[] | PdfFile, helpers) => {
From da32769463fd370a6ac352bb3a7798ba0167bbb8 Mon Sep 17 00:00:00 2001
From: sbplat <71648843+sbplat@users.noreply.github.com>
Date: Mon, 5 Feb 2024 13:28:46 -0500
Subject: [PATCH 2/4] chore: move dependencies out of root
---
client-tauri/src/pages/Dynamic.tsx | 18 ++++++++---------
package-lock.json | 31 +-----------------------------
package.json | 5 +----
shared-operations/package.json | 2 +-
4 files changed, 12 insertions(+), 44 deletions(-)
diff --git a/client-tauri/src/pages/Dynamic.tsx b/client-tauri/src/pages/Dynamic.tsx
index b8cbdda82..cff9f9678 100644
--- a/client-tauri/src/pages/Dynamic.tsx
+++ b/client-tauri/src/pages/Dynamic.tsx
@@ -6,12 +6,12 @@ import i18next from "i18next";
function Dynamic() {
const operators = ["impose"]; // TODO: Make this dynamic
-
+
function selectionChanged(s: BaseSyntheticEvent) {
const selectedValue = s.target.value;
if(selectedValue == "none") return;
- i18next.loadNamespaces("impose", (err, t) => {
+ i18next.loadNamespaces("impose", (err, t) => {
if (err) throw err;
const LoadingModule = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`) as Promise<{ [key: string]: typeof Operator }>;
@@ -19,9 +19,9 @@ function Dynamic() {
const Operator = Module[capitalizeFirstLetter(selectedValue)];
const description = Operator.schema.describe();
- console.log("abc", description);
+ console.log(description);
// TODO: use description to generate fields
- });
+ });
});
}
@@ -35,19 +35,19 @@ function Dynamic() {
-
+
-
+
@@ -59,4 +59,4 @@ function Dynamic() {
}
-export default Dynamic;
\ No newline at end of file
+export default Dynamic;
diff --git a/package-lock.json b/package-lock.json
index b9410f251..49a894f7c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,9 +10,6 @@
"server-node",
"shared-operations"
],
- "dependencies": {
- "@stirling-tools/joi": "github:Stirling-Tools/joi"
- },
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
@@ -2881,32 +2878,6 @@
"vite": "^4.2.0 || ^5.0.0"
}
},
- "node_modules/@vizzly/joi": {
- "version": "17.11.0",
- "resolved": "https://registry.npmjs.org/@vizzly/joi/-/joi-17.11.0.tgz",
- "integrity": "sha512-VpLziKclrc0ul9euaxhD0C+31CXwkmrKBxg7RKNEKnZi/iy4mQPERkxBHCaYksjoZKQEOAnB/IXY7PPbF/OiUw==",
- "dependencies": {
- "@hapi/address": "^5.1.1",
- "@hapi/formula": "^3.0.2",
- "@hapi/hoek": "^11.0.2",
- "@hapi/pinpoint": "^2.0.1",
- "@hapi/tlds": "^1.0.2",
- "@hapi/topo": "^6.0.2"
- }
- },
- "node_modules/@vizzly/joi/node_modules/@hapi/hoek": {
- "version": "11.0.4",
- "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-11.0.4.tgz",
- "integrity": "sha512-PnsP5d4q7289pS2T2EgGz147BFJ2Jpb4yrEdkpz2IhgEUzos1S7HTl7ezWh1yfYzYlj89KzLdCRkqsP6SIryeQ=="
- },
- "node_modules/@vizzly/joi/node_modules/@hapi/topo": {
- "version": "6.0.2",
- "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-6.0.2.tgz",
- "integrity": "sha512-KR3rD5inZbGMrHmgPxsJ9dbi6zEK+C3ZwUwTa+eMwWLz7oijWUTWD2pMSNNYJAU6Qq+65NkxXjqHr/7LM2Xkqg==",
- "dependencies": {
- "@hapi/hoek": "^11.0.2"
- }
- },
"node_modules/@wasmer/wasmfs": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@wasmer/wasmfs/-/wasmfs-0.12.0.tgz",
@@ -9409,7 +9380,7 @@
"version": "0.0.0",
"license": "ISC",
"dependencies": {
- "@vizzly/joi": "^17.11.0",
+ "@stirling-tools/joi": "github:Stirling-Tools/joi",
"i18next-resources-to-backend": "^1.2.0",
"image-js": "^0.35.5",
"next-i18next": "^15.1.1",
diff --git a/package.json b/package.json
index fe47124ed..11178e69b 100644
--- a/package.json
+++ b/package.json
@@ -21,8 +21,5 @@
"engines": {
"npm": ">=7.24.2"
},
- "engineStrict": true,
- "dependencies": {
- "@stirling-tools/joi": "github:Stirling-Tools/joi"
- }
+ "engineStrict": true
}
diff --git a/shared-operations/package.json b/shared-operations/package.json
index e6e87e6fc..c568d1343 100644
--- a/shared-operations/package.json
+++ b/shared-operations/package.json
@@ -9,7 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
- "@vizzly/joi": "^17.11.0",
+ "@stirling-tools/joi": "github:Stirling-Tools/joi",
"i18next-resources-to-backend": "^1.2.0",
"image-js": "^0.35.5",
"next-i18next": "^15.1.1",
From fe12a2722c182798632c69c3a34b5289b518bafd Mon Sep 17 00:00:00 2001
From: sbplat <71648843+sbplat@users.noreply.github.com>
Date: Mon, 5 Feb 2024 13:57:05 -0500
Subject: [PATCH 3/4] chore: update joi fork and its dependencies
---
package-lock.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package-lock.json b/package-lock.json
index 49a894f7c..d9a76f888 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1926,7 +1926,7 @@
},
"node_modules/@stirling-tools/joi": {
"version": "17.12.0",
- "resolved": "git+ssh://git@github.com/Stirling-Tools/joi.git#f2994904b4716082ac74449cfa1f1574616c5883",
+ "resolved": "git+ssh://git@github.com/Stirling-Tools/joi.git#fc6eddf22e5535155080934ab21dba45c610f199",
"license": "BSD-3-Clause",
"dependencies": {
"@hapi/address": "^5.1.1",
From aadc5b5cda6b77683e6b892db9f156155f0b9b63 Mon Sep 17 00:00:00 2001
From: Felix Kaspar
Date: Mon, 5 Feb 2024 20:58:46 +0100
Subject: [PATCH 4/4] Fix: node_server locales, root-dependencies
---
package.json | 2 +-
server-node/src/index.ts | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/package.json b/package.json
index 11178e69b..9bfa0016a 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
],
"scripts": {
"dev-all": "concurrently --names \"node,tauri\" -c \"red.bold,cyan.bold\" --kill-others \"npm run -w server-node dev\" \"npm run -w client-tauri dev\"",
- "update-all-dependencies": "npm i --workspace=server-node --workspace=client-tauri --workspace=shared-operation",
+ "update-all-dependencies": "npm i --workspace=stirling-pdf --workspace=server-node --workspace=client-tauri --workspace=shared-operation",
"update-backend-dependencies": "npm i --workspace=server-node --workspace=shared-operation",
"update-frontend-dependencies": "npm i --workspace=client-tauri --workspace=shared-operation"
},
diff --git a/server-node/src/index.ts b/server-node/src/index.ts
index 11b584791..0e1a85c85 100644
--- a/server-node/src/index.ts
+++ b/server-node/src/index.ts
@@ -1,5 +1,4 @@
-import { init } from "@stirling-pdf/shared-operations/src/i18next.config";
-init("./public/locales/");
+import "@stirling-pdf/shared-operations/src/i18next.config";
import express from "express";
const app = express();