mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-22 23:45:02 +00:00
Progress on dynamic imports & operators in fe
This commit is contained in:
parent
50ab159abe
commit
829127c3f8
@ -28,7 +28,7 @@ i18next.use(LanguageDetector).use(initReactI18next).use(resourcesToBackend((lang
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
initImmediate: true // Makes loading blocking but sync
|
||||
initImmediate: false // Makes loading blocking but sync
|
||||
}); // TODO: use i18next.config.ts instead
|
||||
|
||||
import "./general.css";
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
import { BaseSyntheticEvent } from "react";
|
||||
import { Operator } from "@stirling-pdf/shared-operations/src/functions";
|
||||
import i18next from "i18next";
|
||||
|
||||
function Dynamic() {
|
||||
const operators = ["impose"]; // TODO: Make this dynamic
|
||||
@ -8,8 +10,23 @@ function Dynamic() {
|
||||
function selectionChanged(s: BaseSyntheticEvent) {
|
||||
const selectedValue = s.target.value;
|
||||
if(selectedValue == "none") return;
|
||||
const LoadedOperator = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`);
|
||||
LoadedOperator.then(console.log);
|
||||
|
||||
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 }>;
|
||||
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);
|
||||
// TODO: use description to generate fields
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function capitalizeFirstLetter(string: String) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
return (
|
||||
|
61
package-lock.json
generated
61
package-lock.json
generated
@ -896,11 +896,45 @@
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@hapi/address": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-5.1.1.tgz",
|
||||
"integrity": "sha512-A+po2d/dVoY7cYajycYI43ZbYMXukuopIsqCjh5QzsBCipDtdofHntljDlpccMjIfTy6UOkg+5KPriwYch2bXA==",
|
||||
"dependencies": {
|
||||
"@hapi/hoek": "^11.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@hapi/address/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/@hapi/formula": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@hapi/formula/-/formula-3.0.2.tgz",
|
||||
"integrity": "sha512-hY5YPNXzw1He7s0iqkRQi+uMGh383CGdyyIGYtB+W5N3KHPXoqychklvHhKCC9M3Xtv0OCs/IHw+r4dcHtBYWw=="
|
||||
},
|
||||
"node_modules/@hapi/hoek": {
|
||||
"version": "9.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz",
|
||||
"integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ=="
|
||||
},
|
||||
"node_modules/@hapi/pinpoint": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@hapi/pinpoint/-/pinpoint-2.0.1.tgz",
|
||||
"integrity": "sha512-EKQmr16tM8s16vTT3cA5L0kZZcTMU5DUOZTuvpnY738m+jyP3JIUj+Mm1xc1rsLkGBQ/gVnfKYPwOmPg1tUR4Q=="
|
||||
},
|
||||
"node_modules/@hapi/tlds": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@hapi/tlds/-/tlds-1.0.2.tgz",
|
||||
"integrity": "sha512-JHeIUwqHw3xk1fMJNU8YL2eYhRZxTMExTOnnqHp0y0NZJAGs2UypK2Dg+QT1NPnm29wj5n2zvg5Aoi9Dq/IZGg==",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@hapi/topo": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz",
|
||||
@ -2818,6 +2852,32 @@
|
||||
"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",
|
||||
@ -9320,6 +9380,7 @@
|
||||
"version": "0.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@vizzly/joi": "^17.11.0",
|
||||
"i18next-resources-to-backend": "^1.2.0",
|
||||
"image-js": "^0.35.5",
|
||||
"next-i18next": "^15.1.1",
|
||||
|
@ -9,6 +9,7 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@vizzly/joi": "^17.11.0",
|
||||
"i18next-resources-to-backend": "^1.2.0",
|
||||
"image-js": "^0.35.5",
|
||||
"next-i18next": "^15.1.1",
|
||||
|
@ -8,7 +8,6 @@ import Joi from "joi";
|
||||
import { JoiPDFFileSchema } from "../wrappers/PdfFileJoi";
|
||||
|
||||
import i18next from "i18next";
|
||||
i18next.loadNamespaces("impose", (err, t) => { if (err) throw err; });
|
||||
|
||||
export class Impose extends Operator {
|
||||
static type = "impose";
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { Operator } from "../functions";
|
||||
import i18next from "i18next";
|
||||
|
||||
// TODO: Import other Operators (could make this dynamic)
|
||||
// TODO: Import other Operators (should make this dynamic imports)
|
||||
i18next.loadNamespaces("impose", (err, t) => { if (err) throw err; });
|
||||
import { Impose } from "../functions/impose";
|
||||
|
||||
export const Operators = {
|
||||
Impose: Impose
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user