Refactor and fix: clean up dockerfile and format done with fix in types
This commit is contained in:
parent
45a0540edf
commit
43524dcdb1
3 changed files with 38 additions and 22 deletions
|
|
@ -82,14 +82,11 @@ RUN ARCH=$(uname -m) && \
|
||||||
else \
|
else \
|
||||||
VTRACER_ASSET="vtracer-x86_64-unknown-linux-musl.tar.gz"; \
|
VTRACER_ASSET="vtracer-x86_64-unknown-linux-musl.tar.gz"; \
|
||||||
fi && \
|
fi && \
|
||||||
echo "Downloading VTracer: $VTRACER_ASSET" && \
|
|
||||||
curl -L -o /tmp/vtracer.tar.gz "https://github.com/visioncortex/vtracer/releases/download/0.6.4/${VTRACER_ASSET}" && \
|
curl -L -o /tmp/vtracer.tar.gz "https://github.com/visioncortex/vtracer/releases/download/0.6.4/${VTRACER_ASSET}" && \
|
||||||
tar -xzf /tmp/vtracer.tar.gz -C /tmp/ && \
|
tar -xzf /tmp/vtracer.tar.gz -C /tmp/ && \
|
||||||
mv /tmp/vtracer /usr/local/bin/vtracer && \
|
mv /tmp/vtracer /usr/local/bin/vtracer && \
|
||||||
chmod +x /usr/local/bin/vtracer && \
|
chmod +x /usr/local/bin/vtracer && \
|
||||||
rm /tmp/vtracer.tar.gz && \
|
rm /tmp/vtracer.tar.gz
|
||||||
echo "VTracer installed successfully" && \
|
|
||||||
vtracer --help
|
|
||||||
|
|
||||||
COPY --from=install /temp/prod/node_modules node_modules
|
COPY --from=install /temp/prod/node_modules node_modules
|
||||||
COPY --from=prerelease /app/public/generated.css /app/public/
|
COPY --from=prerelease /app/public/generated.css /app/public/
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,8 @@ import { convert as convertPandoc, properties as propertiesPandoc } from "./pand
|
||||||
import { convert as convertPotrace, properties as propertiesPotrace } from "./potrace";
|
import { convert as convertPotrace, properties as propertiesPotrace } from "./potrace";
|
||||||
import { convert as convertresvg, properties as propertiesresvg } from "./resvg";
|
import { convert as convertresvg, properties as propertiesresvg } from "./resvg";
|
||||||
import { convert as convertImage, properties as propertiesImage } from "./vips";
|
import { convert as convertImage, properties as propertiesImage } from "./vips";
|
||||||
|
import { convert as convertVtracer, properties as propertiesVtracer } from "./vtracer";
|
||||||
import { convert as convertxelatex, properties as propertiesxelatex } from "./xelatex";
|
import { convert as convertxelatex, properties as propertiesxelatex } from "./xelatex";
|
||||||
import {convert as convertVtracer, properties as propertiesVtracer} from './vtracer';
|
|
||||||
|
|
||||||
|
|
||||||
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
|
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
|
||||||
|
|
||||||
|
|
@ -122,7 +121,7 @@ const properties: Record<
|
||||||
vtracer: {
|
vtracer: {
|
||||||
properties: propertiesVtracer,
|
properties: propertiesVtracer,
|
||||||
converter: convertVtracer,
|
converter: convertVtracer,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function chunks<T>(arr: T[], size: number): T[][] {
|
function chunks<T>(arr: T[], size: number): T[][] {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,20 @@ export const properties = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface VTracerOptions {
|
||||||
|
colormode?: string;
|
||||||
|
hierarchical?: string;
|
||||||
|
mode?: string;
|
||||||
|
filter_speckle?: string | number;
|
||||||
|
color_precision?: string | number;
|
||||||
|
layer_difference?: string | number;
|
||||||
|
corner_threshold?: string | number;
|
||||||
|
length_threshold?: string | number;
|
||||||
|
max_iterations?: string | number;
|
||||||
|
splice_threshold?: string | number;
|
||||||
|
path_precision?: string | number;
|
||||||
|
}
|
||||||
|
|
||||||
export function convert(
|
export function convert(
|
||||||
filePath: string,
|
filePath: string,
|
||||||
fileType: string,
|
fileType: string,
|
||||||
|
|
@ -24,34 +38,40 @@ export function convert(
|
||||||
|
|
||||||
// Add optional parameter if provided
|
// Add optional parameter if provided
|
||||||
if (options && typeof options === "object") {
|
if (options && typeof options === "object") {
|
||||||
const opts = options as Record<string, any>;
|
const opts = options as VTracerOptions;
|
||||||
|
const validOptions: Array<keyof VTracerOptions> = [
|
||||||
const validOptions = [
|
"colormode",
|
||||||
"colormode", "hierarchical", "mode", "filter_speckle",
|
"hierarchical",
|
||||||
"color_precision", "layer_difference", "corner_threshold",
|
"mode",
|
||||||
"length_threshold", "max_iterations", "splice_threshold",
|
"filter_speckle",
|
||||||
|
"color_precision",
|
||||||
|
"layer_difference",
|
||||||
|
"corner_threshold",
|
||||||
|
"length_threshold",
|
||||||
|
"max_iterations",
|
||||||
|
"splice_threshold",
|
||||||
"path_precision",
|
"path_precision",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const option of validOptions) {
|
for (const option of validOptions) {
|
||||||
if(opts[option]){
|
if (opts[option] !== undefined) {
|
||||||
args.push(`--${option}`, opts[option]);
|
args.push(`--${option}`, String(opts[option]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
execFile("vtracer", args, (error, stdout, stderr) => {
|
execFile("vtracer", args, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(`error: ${error}${stderr ? `\nstderr: ${stderr}` : ''}`)
|
reject(`error: ${error}${stderr ? `\nstderr: ${stderr}` : ""}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stdout) {
|
if (stdout) {
|
||||||
console.log(`stdout: ${stdout}`)
|
console.log(`stdout: ${stdout}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
console.log(`stderr: ${stderr}`)
|
console.log(`stderr: ${stderr}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve("Done");
|
resolve("Done");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue