Compare commits
285 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 43e829309a | |||
|
|
393441faa1 | ||
|
|
cc4de7625d | ||
|
|
174877cd88 | ||
|
|
eceb29c22d | ||
|
|
4bdb643ed4 | ||
|
|
e125326720 | ||
|
|
0965928949 | ||
|
|
1ba82cf1b2 | ||
|
|
70fcc8413f | ||
|
|
bee3f6302b | ||
|
|
0d201261c8 | ||
|
|
f1439faf12 | ||
|
|
9cbd233dd6 | ||
|
|
7c93846afa | ||
|
|
b013b4d0bc | ||
|
|
d291f049b8 | ||
|
|
8aa23c75aa | ||
|
|
0483392f7e | ||
|
|
debbe5d1d4 | ||
|
|
cd32144bce | ||
|
|
f747a5b94b | ||
|
|
52af8d5824 | ||
|
|
8129ecdc39 | ||
|
|
18f2aa8562 | ||
|
|
081f62de95 | ||
|
|
1032311299 | ||
|
|
6c812b44bb | ||
|
|
7a936bdc04 | ||
|
|
7ec6b66da8 | ||
|
|
bb751163ba | ||
|
|
c3f17cc5a7 | ||
|
|
60f6f5b77f | ||
|
|
bbf6f6ba52 | ||
|
|
9802519e45 | ||
|
|
2b40443885 | ||
|
|
28e5ed4c03 | ||
|
|
c1ca9c770a | ||
|
|
f2a92aaf39 | ||
|
|
8af8e59b4f | ||
|
|
9ac5e7569b | ||
|
|
955ea5c014 | ||
|
|
5d70df424e | ||
|
|
911587ea68 | ||
|
|
3d84925e1b | ||
|
|
ab352987d5 | ||
|
|
689e66e3f9 | ||
|
|
4598745956 | ||
|
|
af199ab8bb | ||
|
|
20b321c308 | ||
|
|
8f898be20e | ||
|
|
df3330fdc2 | ||
|
|
12a5580694 | ||
|
|
eabd6e6a7f | ||
|
|
0521af0d52 | ||
|
|
826dc1062a | ||
|
|
84d7da0195 | ||
|
|
ad000f35ba | ||
|
|
2f965035b6 | ||
|
|
e3dc013b20 | ||
|
|
a59a9fdeec | ||
|
|
f5bc47b532 | ||
|
|
bef07a787e | ||
|
|
5268838975 | ||
|
|
550f472451 | ||
|
|
d165f11798 | ||
|
|
4ae2aab66a | ||
|
|
2be0b13d42 | ||
|
|
74ebf5e4dc | ||
|
|
128b118382 | ||
|
|
64264a41d9 | ||
|
|
0096a6f197 | ||
|
|
53c1a54df5 | ||
|
|
b5c20778f9 | ||
|
|
9a8d7a36b9 | ||
|
|
80b55657a4 | ||
|
|
32d1c567b9 | ||
|
|
152bbd1b78 | ||
|
|
4d65cc7228 | ||
|
|
1a4e2dec7c | ||
|
|
061e63e705 | ||
|
|
80142ff269 | ||
|
|
8b015f9045 | ||
|
|
0159ac0481 | ||
|
|
a677a5eec1 | ||
|
|
0ac585c9da | ||
|
|
4f61577421 | ||
|
|
3e7e95b53c | ||
|
|
27e9b7eb35 | ||
|
|
add3a6229e | ||
|
|
2e406cac3d | ||
|
|
6fa6978f30 | ||
|
|
7691594b10 | ||
|
|
17325a6e6d | ||
|
|
d984891791 | ||
|
|
78bac9c9ca | ||
|
|
126e60fec7 | ||
|
|
7a59070e91 | ||
|
|
c9b65c7652 | ||
|
|
13d9ce09a4 | ||
|
|
f4fc053db3 | ||
|
|
d3fc6a237f | ||
|
|
8a888ccda6 | ||
|
|
a4e20aa62a | ||
|
|
1cc4862d51 | ||
|
|
c6b64ced91 | ||
|
|
38cbf093e5 | ||
|
|
d8ddfa31e3 | ||
|
|
c3e4f676fc | ||
|
|
e668b828ea | ||
|
|
eaeac2cb78 | ||
|
|
5d74ec59c1 | ||
|
|
645b29e5d1 | ||
|
|
aee9677029 | ||
|
|
da982dc831 | ||
|
|
a64eaa3fc0 | ||
|
|
a63651f715 | ||
|
|
bb67b708e7 | ||
|
|
dc0d37c71e | ||
|
|
0287c4d458 | ||
|
|
47be1061b7 | ||
|
|
1c79de2f37 | ||
|
|
9696cc7188 | ||
|
|
082dd8c1f2 | ||
|
|
43524dcdb1 | ||
|
|
45a0540edf | ||
|
|
2b784d1edc | ||
|
|
8650cf9a63 | ||
|
|
76c840dbaa | ||
|
|
e78de6f6de | ||
|
|
554edf5a27 | ||
|
|
6fca398a12 | ||
|
|
5bf3fbc10e | ||
|
|
d994c38219 | ||
|
|
3dccbfc797 | ||
|
|
c3d461f102 | ||
|
|
c0105889ab | ||
|
|
c6006b58d2 | ||
|
|
178f009458 | ||
|
|
9c24cf4aba | ||
|
|
af68498494 | ||
|
|
eac22d53d3 | ||
|
|
e5ac60c187 | ||
|
|
4b42a5fbda | ||
|
|
08a833f1cf | ||
|
|
c0f0dc5192 | ||
|
|
6452d0b357 | ||
|
|
9f6b815197 | ||
|
|
d8cbc0aaee | ||
|
|
b1f70ec36c | ||
|
|
311d2516ce | ||
|
|
5957873534 | ||
|
|
7524f304fe | ||
|
|
f1730ede97 | ||
|
|
7f9c8868fd | ||
|
|
72b484a480 | ||
|
|
c47c1dd4f4 | ||
|
|
3975c70de7 | ||
|
|
fd4e73e76c | ||
|
|
301fab5c17 | ||
|
|
2c90454244 | ||
|
|
2db99edeaf | ||
|
|
4fa471263f | ||
|
|
435f654cbe | ||
|
|
15b03d7561 | ||
|
|
219e6a29e4 | ||
|
|
a85edb6cee | ||
|
|
43081c5179 | ||
|
|
d390dce843 | ||
|
|
e5939aaa5d | ||
|
|
1db0c0f531 | ||
|
|
eefd33ac88 | ||
|
|
de10436c1a | ||
|
|
81f109f830 | ||
|
|
858ee28ef2 | ||
|
|
b89afe1b0c | ||
|
|
b4fedc1c1d | ||
|
|
d24e8b4027 | ||
|
|
93fbdbe0f3 | ||
|
|
068d9b8716 | ||
|
|
2295f23725 | ||
|
|
fed587b4a4 | ||
|
|
8f73f9c365 | ||
|
|
363efc2e7f | ||
|
|
cf93fed64b | ||
|
|
99c689657f | ||
|
|
394c98c65a | ||
|
|
8f93ac29dd | ||
|
|
5ffb7f4a01 | ||
|
|
f5f718a84a | ||
|
|
4c36a950a7 | ||
|
|
a9bc9d7e8d | ||
|
|
18fed70ddf | ||
|
|
dd9d117ab8 | ||
|
|
0e94fe354f | ||
|
|
3b99c79495 | ||
|
|
20e914c85b | ||
|
|
efc4b3f84c | ||
|
|
2bc6b52e99 | ||
|
|
feb59e560b | ||
|
|
17be8f3601 | ||
|
|
3b053e8222 | ||
|
|
9d5050d3ee | ||
|
|
1bd56e1d0e | ||
|
|
3f46abf261 | ||
|
|
6a248e17be | ||
|
|
8273a2a6a0 | ||
|
|
78f52c769d | ||
|
|
fe22b2f8fb | ||
|
|
482421f10e | ||
|
|
dcb15aee0e | ||
|
|
827f22e2fc | ||
|
|
bd36314f00 | ||
|
|
4ad7892eab | ||
|
|
31b7e62983 | ||
|
|
0f5ef2f49c | ||
|
|
2ce3fee70b | ||
|
|
33e5bee9fb | ||
|
|
b32f7dba5d | ||
|
|
2661acbadb | ||
|
|
d28c079a57 | ||
|
|
29a159c094 | ||
|
|
68dad51948 | ||
|
|
3bf82b5b86 | ||
|
|
e52e8c12cf | ||
|
|
8f7a7faa91 | ||
|
|
ff0edec652 | ||
|
|
bbcecf274f | ||
|
|
cc41be6856 | ||
|
|
761f56b869 | ||
|
|
d4e8eaadd7 | ||
|
|
9f2bdadde7 | ||
|
|
f789d9dfe3 | ||
|
|
ce41ee2387 | ||
|
|
01c8fad012 | ||
|
|
908e91cb91 | ||
|
|
f1c5cd9f6b | ||
|
|
6ea3058e66 | ||
|
|
a4e741cc0a | ||
|
|
0f2172d61f | ||
|
|
2baa69ca17 | ||
|
|
3bbfa9186e | ||
|
|
c1428f5c2b | ||
|
|
1be11708c4 | ||
|
|
8c04b318fd | ||
|
|
ff2c0057e8 | ||
|
|
c830721e02 | ||
|
|
625e1a51f6 | ||
|
|
6af1e8f326 | ||
|
|
82f0e14abf | ||
|
|
9e759a75de | ||
|
|
33388cf209 | ||
|
|
2490c3a7e7 | ||
|
|
7f86c352e3 | ||
|
|
2a3b08487e | ||
|
|
29ba229bc2 | ||
|
|
50725edd02 | ||
|
|
40d1d8a191 | ||
|
|
3417564278 | ||
|
|
9a49dedaca | ||
|
|
d9076bf42a | ||
|
|
b9bbf7792f | ||
|
|
5cc6678ceb | ||
|
|
b47e5755f6 | ||
|
|
af5c768dc7 | ||
|
|
3b573cccae | ||
|
|
0c6f6d6904 | ||
|
|
6e2fe27f31 | ||
|
|
b6cdd3741a | ||
|
|
00f95b6daa | ||
|
|
2d05bbf86b | ||
|
|
2c87a6c8c2 | ||
|
|
254509db5e | ||
|
|
4e4c029cb8 | ||
|
|
6dc60679bb | ||
|
|
6e5d5d9de0 | ||
|
|
6289c033c8 | ||
|
|
b200049a81 | ||
|
|
5646f79f99 | ||
|
|
5083968b80 | ||
|
|
2eb9b8fe96 | ||
|
|
8dc60b41ff | ||
|
|
b4be479d02 | ||
|
|
f56a93a1b2 | ||
|
|
ff8b9fca67 |
1
.bun-version
Normal file
|
|
@ -0,0 +1 @@
|
|||
1.2.2
|
||||
70
.devcontainer/Dockerfile
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
FROM debian:trixie-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
unzip \
|
||||
git \
|
||||
ca-certificates \
|
||||
build-essential \
|
||||
assimp-utils \
|
||||
calibre \
|
||||
dasel \
|
||||
dcraw \
|
||||
dvisvgm \
|
||||
ffmpeg \
|
||||
ghostscript \
|
||||
graphicsmagick \
|
||||
imagemagick-7.q16 \
|
||||
inkscape \
|
||||
latexmk \
|
||||
libheif-examples \
|
||||
libjxl-tools \
|
||||
libreoffice \
|
||||
libva2 \
|
||||
libvips-tools \
|
||||
libemail-outlook-message-perl \
|
||||
lmodern \
|
||||
mupdf-tools \
|
||||
pandoc \
|
||||
poppler-utils \
|
||||
potrace \
|
||||
python3-numpy \
|
||||
python3-tinycss2 \
|
||||
resvg \
|
||||
texlive \
|
||||
texlive-fonts-recommended \
|
||||
texlive-latex-extra \
|
||||
texlive-latex-recommended \
|
||||
texlive-xetex \
|
||||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN ARCH=$(uname -m) && \
|
||||
if [ "$ARCH" = "aarch64" ]; then \
|
||||
curl -fsSL -o bun-linux-aarch64.zip https://github.com/oven-sh/bun/releases/download/bun-v1.2.2/bun-linux-aarch64.zip; \
|
||||
else \
|
||||
curl -fsSL -o bun-linux-x64-baseline.zip https://github.com/oven-sh/bun/releases/download/bun-v1.2.2/bun-linux-x64-baseline.zip; \
|
||||
fi && \
|
||||
unzip -j bun-linux-*.zip -d /usr/local/bin && \
|
||||
rm bun-linux-*.zip && \
|
||||
chmod +x /usr/local/bin/bun
|
||||
|
||||
RUN ARCH=$(uname -m) && \
|
||||
if [ "$ARCH" = "aarch64" ]; then \
|
||||
VTRACER_ASSET="vtracer-aarch64-unknown-linux-musl.tar.gz"; \
|
||||
else \
|
||||
VTRACER_ASSET="vtracer-x86_64-unknown-linux-musl.tar.gz"; \
|
||||
fi && \
|
||||
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/ && \
|
||||
mv /tmp/vtracer /usr/local/bin/vtracer && \
|
||||
chmod +x /usr/local/bin/vtracer && \
|
||||
rm /tmp/vtracer.tar.gz
|
||||
|
||||
RUN mkdir -p data
|
||||
ENV NODE_ENV=development
|
||||
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
|
||||
EXPOSE 3000
|
||||
CMD ["bun", "run", "dev"]
|
||||
53
.devcontainer/devcontainer.json
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "ConvertX",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/git:1": {},
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"ms-vscode.vscode-typescript-next",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"ms-vscode.vscode-json",
|
||||
"ms-vscode.vscode-docker",
|
||||
"oven.bun-vscode"
|
||||
],
|
||||
"settings": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "explicit"
|
||||
},
|
||||
"typescript.preferences.importModuleSpecifier": "relative",
|
||||
"typescript.suggest.autoImports": true,
|
||||
"tailwindCSS.includeLanguages": {
|
||||
"typescript": "javascript",
|
||||
"typescriptreact": "javascript"
|
||||
},
|
||||
"files.associations": {
|
||||
"*.css": "tailwindcss"
|
||||
},
|
||||
"terminal.integrated.defaultProfile.linux": "bash"
|
||||
}
|
||||
}
|
||||
},
|
||||
"forwardPorts": [3000],
|
||||
"portsAttributes": {
|
||||
"3000": {
|
||||
"label": "ConvertX Application",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bun install",
|
||||
"remoteUser": "root",
|
||||
"mounts": ["source=${localWorkspaceFolder}/data,target=/app/data,type=bind"],
|
||||
"containerEnv": {
|
||||
"JWT_SECRET": "jwt_secret_only_used_in_testing_for_easier_hot_reloading"
|
||||
}
|
||||
}
|
||||
|
|
@ -2,18 +2,24 @@
|
|||
.editorconfig
|
||||
.env
|
||||
.git
|
||||
.gitignore
|
||||
.github
|
||||
.idea
|
||||
.vscode
|
||||
biome.json
|
||||
CHANGELOG.md
|
||||
compose.yaml
|
||||
coverage*
|
||||
data
|
||||
docker-compose*
|
||||
Dockerfile*
|
||||
eslint.config.js
|
||||
helm-charts
|
||||
images
|
||||
LICENSE
|
||||
Makefile
|
||||
node_modules
|
||||
prettier.config.js
|
||||
README.md
|
||||
renovate.json
|
||||
renovate.json
|
||||
SECURITY.md
|
||||
|
|
|
|||
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ""
|
||||
labels: bug
|
||||
assignees: ""
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Checklist:**
|
||||
|
||||
- [ ] I am accessing ConvertX over HTTPS or have `HTTP_ALLOWED=true`
|
||||
26
.github/ISSUE_TEMPLATE/converter_request.md
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
name: Converter request
|
||||
about: Suggest a converter for this project
|
||||
title: "[Converter Request]"
|
||||
labels: "converter request"
|
||||
assignees: ""
|
||||
---
|
||||
|
||||
**What file formats are missing?**
|
||||
|
||||
<!-- Provide an example of what you would like to convert -->
|
||||
|
||||
**What converter should be added**
|
||||
|
||||
<!-- It has to be free and preferably open source -->
|
||||
|
||||
**Are you willing to add it?**
|
||||
|
||||
<!-- Adding a converter is very easy just copy one of the existing and modify it -->
|
||||
|
||||
- [ ] Yes
|
||||
- [ ] No
|
||||
|
||||
**Additional context**
|
||||
|
||||
<!-- Add any other context or screenshots about the feature request here. -->
|
||||
13
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[Feature Request]"
|
||||
labels: enhancement
|
||||
assignees: ""
|
||||
---
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
20
.github/release.yml
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
changelog:
|
||||
exclude:
|
||||
authors:
|
||||
- renovate[bot]
|
||||
categories:
|
||||
- title: Features
|
||||
labels:
|
||||
- feature
|
||||
- title: Bug Fixes
|
||||
labels:
|
||||
- fix
|
||||
- title: Miscellaneous Chores
|
||||
labels:
|
||||
- chore
|
||||
- ci
|
||||
- docs
|
||||
- test
|
||||
- title: Other Changes
|
||||
labels:
|
||||
- "*"
|
||||
33
.github/workflows/check-lint.yml
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
name: Check Lint
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Run linting checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.2.2
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
- name: Run lint
|
||||
run: bun run lint
|
||||
23
.github/workflows/conventional-label.yml
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
on:
|
||||
pull_request_target:
|
||||
types: [opened, edited]
|
||||
name: conventional-release-labels
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
jobs:
|
||||
label:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: bcoe/conventional-release-labels@v1
|
||||
with:
|
||||
type_labels: |
|
||||
{
|
||||
"feat": "Feature",
|
||||
"fix": "Fix",
|
||||
"breaking": "Breaking",
|
||||
"chore": "Chore",
|
||||
"docs": "Docs",
|
||||
"test": "Test",
|
||||
"ci": "CI"
|
||||
}
|
||||
253
.github/workflows/docker-publish.yml
vendored
|
|
@ -1,80 +1,173 @@
|
|||
name: Docker
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
# Publish semver tags as releases.
|
||||
tags: [ 'v*.*.*' ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
# Use docker.io for Docker Hub if empty
|
||||
REGISTRY: ghcr.io
|
||||
# github.repository as <account>/<repo>
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
DOCKERHUB_USERNAME: c4illin
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Workaround: https://github.com/docker/build-push-action/issues/461
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# Login against a Docker registry except on PR
|
||||
# https://github.com/docker/login-action
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# Extract metadata (tags, labels) for Docker
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
${{ env.IMAGE_NAME }}
|
||||
|
||||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and push Docker image
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
name: Docker
|
||||
|
||||
# thanks to https://github.com/sredevopsorg/multi-arch-docker-github-workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
tags: ["v*.*.*"]
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
workflow_dispatch:
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
DOCKERHUB_USERNAME: c4illin
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# The build job builds the Docker image for each platform specified in the matrix.
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
|
||||
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-24.04' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }}
|
||||
|
||||
name: Build Docker image for ${{ matrix.platform }}
|
||||
|
||||
steps:
|
||||
- name: Prepare environment for current platform
|
||||
# This step sets up the environment for the current platform being built.
|
||||
# It replaces the '/' character in the platform name with '-' and sets it as an environment variable.
|
||||
# This is useful for naming artifacts and other resources that cannot contain '/'.
|
||||
# The environment variable PLATFORMS_PAIR will be used later in the workflow.
|
||||
id: prepare
|
||||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: downcase REPO
|
||||
run: |
|
||||
echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Docker meta default
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/${{ env.REPO }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
# here we only login to ghcr.io since the this only pushes internal images
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
env:
|
||||
DOCKER_BUILDKIT: 1
|
||||
with:
|
||||
context: .
|
||||
platforms: ${{ matrix.platform }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
annotations: ${{ steps.meta.outputs.annotations }}
|
||||
outputs: type=image,name=ghcr.io/${{ env.REPO }},push-by-digest=true,name-canonical=true,oci-mediatypes=true
|
||||
push: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && contains(fromJSON('["COLLABORATOR","MEMBER","OWNER"]'), github.event.pull_request.author_association)) }}
|
||||
cache-from: type=gha,scope=${{ matrix.platform }}
|
||||
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: digests-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
merge:
|
||||
if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && contains(fromJSON('["COLLABORATOR","MEMBER","OWNER"]'), github.event.pull_request.author_association)) }}
|
||||
name: Merge Docker manifests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
|
||||
needs:
|
||||
- build
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digests-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: downcase REPO
|
||||
run: |
|
||||
echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/${{ env.REPO }}
|
||||
${{ env.IMAGE_NAME }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Get execution timestamp with RFC3339 format
|
||||
id: timestamp
|
||||
run: |
|
||||
echo "timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
docker buildx imagetools create \
|
||||
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
--annotation='index:org.opencontainers.image.description=${{ github.event.repository.description }}' \
|
||||
--annotation='index:org.opencontainers.image.created=${{ steps.timestamp.outputs.timestamp }}' \
|
||||
--annotation='index:org.opencontainers.image.url=${{ github.event.repository.url }}' \
|
||||
--annotation='index:org.opencontainers.image.source=${{ github.event.repository.url }}' \
|
||||
$(printf 'ghcr.io/${{ env.REPO }}@sha256:%s ' *)
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect 'ghcr.io/${{ env.REPO }}:${{ steps.meta.outputs.version }}'
|
||||
|
|
|
|||
20
.github/workflows/dockerhub-description.yml
vendored
|
|
@ -1,4 +1,6 @@
|
|||
name: Update Docker Hub Description
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
|
@ -15,13 +17,13 @@ jobs:
|
|||
dockerHubDescription:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v4
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
repository: ${{ env.IMAGE_NAME }}
|
||||
short-description: ${{ github.event.repository.description }}
|
||||
enable-url-completion: true
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v5
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
repository: ${{ env.IMAGE_NAME }}
|
||||
short-description: ${{ github.event.repository.description }}
|
||||
enable-url-completion: true
|
||||
|
|
|
|||
25
.github/workflows/release-please.yml
vendored
|
|
@ -1,25 +0,0 @@
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
name: release-please
|
||||
|
||||
jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: googleapis/release-please-action@v4
|
||||
with:
|
||||
# this assumes that you have created a personal access token
|
||||
# (PAT) and configured it as a GitHub action secret named
|
||||
# `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
|
||||
token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
|
||||
# token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# this is a built-in strategy in release-please, see "Action Inputs"
|
||||
# for more options
|
||||
release-type: node
|
||||
10
.github/workflows/remove-docker-tag.yml
vendored
|
|
@ -14,8 +14,8 @@ jobs:
|
|||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Remove Docker Tag
|
||||
uses: ArchieAtkinson/remove-dockertag-action@v0.0
|
||||
with:
|
||||
tag_name: master
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Remove Docker Tag
|
||||
uses: ArchieAtkinson/remove-dockertag-action@v0.0
|
||||
with:
|
||||
tag_name: master
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
|
|||
33
.github/workflows/run-bun-test.yml
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
name: Check Tests
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Run tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.2.2
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
- name: Run tests
|
||||
run: bun test
|
||||
103
.gitignore
vendored
|
|
@ -1,51 +1,52 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
**/*.trace
|
||||
**/*.zip
|
||||
**/*.tar.gz
|
||||
**/*.tgz
|
||||
**/*.log
|
||||
package-lock.json
|
||||
**/*.bun
|
||||
/src/uploads
|
||||
/uploads
|
||||
/mydb.sqlite
|
||||
/output
|
||||
/db
|
||||
/data
|
||||
/Bruno
|
||||
/tsconfig.tsbuildinfo
|
||||
/public/generated.css
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
**/*.trace
|
||||
**/*.zip
|
||||
**/*.tar.gz
|
||||
**/*.tgz
|
||||
**/*.log
|
||||
package-lock.json
|
||||
**/*.bun
|
||||
/src/uploads
|
||||
/uploads
|
||||
/mydb.sqlite
|
||||
/output
|
||||
/db
|
||||
/data
|
||||
/dist
|
||||
/Bruno
|
||||
/tsconfig.tsbuildinfo
|
||||
/public/generated.css
|
||||
|
|
|
|||
2
.vscode/settings.json
vendored
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
195
CHANGELOG.md
|
|
@ -1,244 +1,249 @@
|
|||
# Changelog
|
||||
|
||||
## [0.15.0](https://github.com/C4illin/ConvertX/compare/v0.14.1...v0.15.0) (2025-10-07)
|
||||
|
||||
### Features
|
||||
|
||||
- add download all file by file alongside the tar download ([#415](https://github.com/C4illin/ConvertX/issues/415)) ([3e7e95b](https://github.com/C4illin/ConvertX/commit/3e7e95b53c78469f4aada996e835fcc6b9fde134))
|
||||
- vtracer implemented and added docker file binaries install ([76c840d](https://github.com/C4illin/ConvertX/commit/76c840dbaa4a26d0623422b61581bb761ad6a6bc))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- add language env ([f789d9d](https://github.com/C4illin/ConvertX/commit/f789d9dfe381780dcc715b70bcf304d570a73e3f))
|
||||
- add lmodern ([761f56b](https://github.com/C4illin/ConvertX/commit/761f56b869d3a4faa7550d90b3da2d853baf8a1d)), closes [#320](https://github.com/C4illin/ConvertX/issues/320)
|
||||
- missing public files ([8a888cc](https://github.com/C4illin/ConvertX/commit/8a888ccda679a31f801855e37800f52f1a1fda6e)), closes [#314](https://github.com/C4illin/ConvertX/issues/314)
|
||||
- move color variables to seperate directory ([3bf82b5](https://github.com/C4illin/ConvertX/commit/3bf82b5b86177f95531293cab1dfee1e12c898a1)), closes [#53](https://github.com/C4illin/ConvertX/issues/53)
|
||||
- run qtwebengine without sandbox ([9f2bdad](https://github.com/C4illin/ConvertX/commit/9f2bdadde779d88973296e81af103ed0016f5411))
|
||||
- update favicon ([827f22e](https://github.com/C4illin/ConvertX/commit/827f22e2fc33bf32a02befb3c5bd519511826b38)), closes [#158](https://github.com/C4illin/ConvertX/issues/158)
|
||||
|
||||
## [0.14.1](https://github.com/C4illin/ConvertX/compare/v0.14.0...v0.14.1) (2025-06-04)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- change to baseline build ([6ea3058](https://github.com/C4illin/ConvertX/commit/6ea3058e66262f7a14633bddcecd5573948f524a)), closes [#311](https://github.com/C4illin/ConvertX/issues/311)
|
||||
|
||||
## [0.14.0](https://github.com/C4illin/ConvertX/compare/v0.13.0...v0.14.0) (2025-06-03)
|
||||
|
||||
### Features
|
||||
|
||||
- add dvisvgm ([625e1a5](https://github.com/C4illin/ConvertX/commit/625e1a51f620fe9da79d0127eb6c95f468d9ea2b))
|
||||
- add ImageMagick ([b47e575](https://github.com/C4illin/ConvertX/commit/b47e5755f677056e8acecad54c0c2e28a5e137f3)), closes [#295](https://github.com/C4illin/ConvertX/issues/295), closes [#269](https://github.com/C4illin/ConvertX/issues/269)
|
||||
- enhance job details display with file information ([50725ed](https://github.com/C4illin/ConvertX/commit/50725edd021bb9a7f58c85b79c1eab355ad22ced)), closes [#251](https://github.com/C4illin/ConvertX/issues/251)
|
||||
- improve job details interaction and accessibility ([29ba229](https://github.com/C4illin/ConvertX/commit/29ba229bc23d2019d2ee9829da7852f884ffa611))
|
||||
- show version in footer ([9a49ded](https://github.com/C4illin/ConvertX/commit/9a49dedacac7e67a432b6da0daf1967038d97d26))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- add av1 and h26X with containers ([af5c768](https://github.com/C4illin/ConvertX/commit/af5c768dc74b3124fd7ef4b29e27c83a5d19ad49)), closes [#287](https://github.com/C4illin/ConvertX/issues/287), closes [#293](https://github.com/C4illin/ConvertX/issues/293)
|
||||
- progress bars on firefox ([ff2c005](https://github.com/C4illin/ConvertX/commit/ff2c0057e890b9ecb552df30914333349ea20eb7))
|
||||
- register button style ([b9bbf77](https://github.com/C4illin/ConvertX/commit/b9bbf7792f01fcaa77e3520925de107e856926f1))
|
||||
- switch from alpine to debian trixie ([4e4c029](https://github.com/C4illin/ConvertX/commit/4e4c029cb800df86affb99c3a82dda9e6708bdde)), closes [#234](https://github.com/C4illin/ConvertX/issues/234), closes [#199](https://github.com/C4illin/ConvertX/issues/199)
|
||||
|
||||
## [0.13.0](https://github.com/C4illin/ConvertX/compare/v0.12.1...v0.13.0) (2025-05-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add HIDE_HISTORY option to control visibility of history page ([9d1c931](https://github.com/C4illin/ConvertX/commit/9d1c93155cc33ed6c83f9e5122afff8f28d0e4bf))
|
||||
* add potrace converter ([bdbd4a1](https://github.com/C4illin/ConvertX/commit/bdbd4a122c09559b089b985ea12c5f3e085107da))
|
||||
* Add support for .HIF files ([70705c1](https://github.com/C4illin/ConvertX/commit/70705c1850d470296df85958c02a01fb5bc3a25f))
|
||||
* add support for drag/drop of images ([ff2ef74](https://github.com/C4illin/ConvertX/commit/ff2ef7413542cf10ba7a6e246763bcecd6829ec1))
|
||||
|
||||
- add HIDE_HISTORY option to control visibility of history page ([9d1c931](https://github.com/C4illin/ConvertX/commit/9d1c93155cc33ed6c83f9e5122afff8f28d0e4bf))
|
||||
- add potrace converter ([bdbd4a1](https://github.com/C4illin/ConvertX/commit/bdbd4a122c09559b089b985ea12c5f3e085107da))
|
||||
- Add support for .HIF files ([70705c1](https://github.com/C4illin/ConvertX/commit/70705c1850d470296df85958c02a01fb5bc3a25f))
|
||||
- add support for drag/drop of images ([ff2ef74](https://github.com/C4illin/ConvertX/commit/ff2ef7413542cf10ba7a6e246763bcecd6829ec1))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add timezone support ([4b5c732](https://github.com/C4illin/ConvertX/commit/4b5c732380bc844dccf340ea1eb4f8bfe3bb44a5)), closes [#258](https://github.com/C4illin/ConvertX/issues/258)
|
||||
- add timezone support ([4b5c732](https://github.com/C4illin/ConvertX/commit/4b5c732380bc844dccf340ea1eb4f8bfe3bb44a5)), closes [#258](https://github.com/C4illin/ConvertX/issues/258)
|
||||
|
||||
## [0.12.1](https://github.com/C4illin/ConvertX/compare/v0.12.0...v0.12.1) (2025-03-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* rollback to bun 1.2.2 ([cdae798](https://github.com/C4illin/ConvertX/commit/cdae798fcf5879e4adea87386a38748b9a1e1ddc))
|
||||
- rollback to bun 1.2.2 ([cdae798](https://github.com/C4illin/ConvertX/commit/cdae798fcf5879e4adea87386a38748b9a1e1ddc))
|
||||
|
||||
## [0.12.0](https://github.com/C4illin/ConvertX/compare/v0.11.1...v0.12.0) (2025-03-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added progress bar for file upload ([db60f35](https://github.com/C4illin/ConvertX/commit/db60f355b2973f43f8e5990e6fe4e351b959b659))
|
||||
* made every upload file independent ([cc54bdc](https://github.com/C4illin/ConvertX/commit/cc54bdcbe764c41cc3273485d072fd3178ad2dca))
|
||||
* replace exec with execFile ([9263d17](https://github.com/C4illin/ConvertX/commit/9263d17609dc4b2b367eb7fee67b3182e283b3a3))
|
||||
|
||||
- added progress bar for file upload ([db60f35](https://github.com/C4illin/ConvertX/commit/db60f355b2973f43f8e5990e6fe4e351b959b659))
|
||||
- made every upload file independent ([cc54bdc](https://github.com/C4illin/ConvertX/commit/cc54bdcbe764c41cc3273485d072fd3178ad2dca))
|
||||
- replace exec with execFile ([9263d17](https://github.com/C4illin/ConvertX/commit/9263d17609dc4b2b367eb7fee67b3182e283b3a3))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add libheif ([6b92540](https://github.com/C4illin/ConvertX/commit/6b9254047c0598963aee1d99e20ba1650a0368bf))
|
||||
* add libheif ([decfea5](https://github.com/C4illin/ConvertX/commit/decfea5dc9627b216bb276a9e1578c32cfa1deb6)), closes [#202](https://github.com/C4illin/ConvertX/issues/202)
|
||||
* added onerror log ([ae4bbc8](https://github.com/C4illin/ConvertX/commit/ae4bbc8baacbaf67763c62ea44140bb21cc17230))
|
||||
* refactored uploadFile to only accept a single file instead of multiple ([dc82a43](https://github.com/C4illin/ConvertX/commit/dc82a438d4104b79ff423d502a6779a43928968a))
|
||||
* update libheif to 1.19.5 ([fba5e21](https://github.com/C4illin/ConvertX/commit/fba5e212e8d0eaba8971e239e35aeb521f3cd813)), closes [#202](https://github.com/C4illin/ConvertX/issues/202)
|
||||
- add libheif ([6b92540](https://github.com/C4illin/ConvertX/commit/6b9254047c0598963aee1d99e20ba1650a0368bf))
|
||||
- add libheif ([decfea5](https://github.com/C4illin/ConvertX/commit/decfea5dc9627b216bb276a9e1578c32cfa1deb6)), closes [#202](https://github.com/C4illin/ConvertX/issues/202)
|
||||
- added onerror log ([ae4bbc8](https://github.com/C4illin/ConvertX/commit/ae4bbc8baacbaf67763c62ea44140bb21cc17230))
|
||||
- refactored uploadFile to only accept a single file instead of multiple ([dc82a43](https://github.com/C4illin/ConvertX/commit/dc82a438d4104b79ff423d502a6779a43928968a))
|
||||
- update libheif to 1.19.5 ([fba5e21](https://github.com/C4illin/ConvertX/commit/fba5e212e8d0eaba8971e239e35aeb521f3cd813)), closes [#202](https://github.com/C4illin/ConvertX/issues/202)
|
||||
|
||||
## [0.11.1](https://github.com/C4illin/ConvertX/compare/v0.11.0...v0.11.1) (2025-02-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* mobile view overflow ([bec58ac](https://github.com/C4illin/ConvertX/commit/bec58ac59f9600e35385b9e21d174f3ab1b42b1d))
|
||||
- mobile view overflow ([bec58ac](https://github.com/C4illin/ConvertX/commit/bec58ac59f9600e35385b9e21d174f3ab1b42b1d))
|
||||
|
||||
## [0.11.0](https://github.com/C4illin/ConvertX/compare/v0.10.1...v0.11.0) (2025-02-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add deps for vaapi ([2bbbd03](https://github.com/C4illin/ConvertX/commit/2bbbd03554d384a4488143f29e5fc863cfdf333b)), closes [#192](https://github.com/C4illin/ConvertX/issues/192)
|
||||
|
||||
- add deps for vaapi ([2bbbd03](https://github.com/C4illin/ConvertX/commit/2bbbd03554d384a4488143f29e5fc863cfdf333b)), closes [#192](https://github.com/C4illin/ConvertX/issues/192)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* don't crash if file is not found ([16f27c1](https://github.com/C4illin/ConvertX/commit/16f27c13bbc1c0e5fa2316f3db11d0918524053b))
|
||||
* install numpy for inkscape ([0e61051](https://github.com/C4illin/ConvertX/commit/0e61051fc6be188164c3865b4fb579c140859fdc))
|
||||
- don't crash if file is not found ([16f27c1](https://github.com/C4illin/ConvertX/commit/16f27c13bbc1c0e5fa2316f3db11d0918524053b))
|
||||
- install numpy for inkscape ([0e61051](https://github.com/C4illin/ConvertX/commit/0e61051fc6be188164c3865b4fb579c140859fdc))
|
||||
|
||||
## [0.10.1](https://github.com/C4illin/ConvertX/compare/v0.10.0...v0.10.1) (2025-01-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ffmpeg works without ffmpeg_args ([3b7ea88](https://github.com/C4illin/ConvertX/commit/3b7ea88b7382f7c21b120bdc9bda5bb10547f55d)), closes [#212](https://github.com/C4illin/ConvertX/issues/212)
|
||||
- ffmpeg works without ffmpeg_args ([3b7ea88](https://github.com/C4illin/ConvertX/commit/3b7ea88b7382f7c21b120bdc9bda5bb10547f55d)), closes [#212](https://github.com/C4illin/ConvertX/issues/212)
|
||||
|
||||
## [0.10.0](https://github.com/C4illin/ConvertX/compare/v0.9.0...v0.10.0) (2025-01-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add calibre ([03d3edf](https://github.com/C4illin/ConvertX/commit/03d3edfff65c252dd4b8922fc98257c089c1ff74)), closes [#191](https://github.com/C4illin/ConvertX/issues/191)
|
||||
|
||||
- add calibre ([03d3edf](https://github.com/C4illin/ConvertX/commit/03d3edfff65c252dd4b8922fc98257c089c1ff74)), closes [#191](https://github.com/C4illin/ConvertX/issues/191)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add FFMPEG_ARGS env variable ([f537c81](https://github.com/C4illin/ConvertX/commit/f537c81db7815df8017f834e3162291197e1c40f)), closes [#190](https://github.com/C4illin/ConvertX/issues/190)
|
||||
* add qt6-qtbase-private-dev from community repo ([95dbc9f](https://github.com/C4illin/ConvertX/commit/95dbc9f678bec7e6e2c03587e1473fb8ff708ea3))
|
||||
* skip account setup when ALLOW_UNAUTHENTICATED is true ([538c5b6](https://github.com/C4illin/ConvertX/commit/538c5b60c9e27a8184740305475245da79bae143))
|
||||
- add FFMPEG_ARGS env variable ([f537c81](https://github.com/C4illin/ConvertX/commit/f537c81db7815df8017f834e3162291197e1c40f)), closes [#190](https://github.com/C4illin/ConvertX/issues/190)
|
||||
- add qt6-qtbase-private-dev from community repo ([95dbc9f](https://github.com/C4illin/ConvertX/commit/95dbc9f678bec7e6e2c03587e1473fb8ff708ea3))
|
||||
- skip account setup when ALLOW_UNAUTHENTICATED is true ([538c5b6](https://github.com/C4illin/ConvertX/commit/538c5b60c9e27a8184740305475245da79bae143))
|
||||
|
||||
## [0.9.0](https://github.com/C4illin/ConvertX/compare/v0.8.1...v0.9.0) (2024-11-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add inkscape for vector images ([f3740e9](https://github.com/C4illin/ConvertX/commit/f3740e9ded100b8500f3613517960248bbd3c210))
|
||||
* Allow to chose webroot ([36cb6cc](https://github.com/C4illin/ConvertX/commit/36cb6cc589d80d0a87fa8dbe605db71a9a2570f9)), closes [#180](https://github.com/C4illin/ConvertX/issues/180)
|
||||
* disable convert when uploading ([58e220e](https://github.com/C4illin/ConvertX/commit/58e220e82d7f9c163d6ea4dc31092c08a3e254f4)), closes [#177](https://github.com/C4illin/ConvertX/issues/177)
|
||||
|
||||
- add inkscape for vector images ([f3740e9](https://github.com/C4illin/ConvertX/commit/f3740e9ded100b8500f3613517960248bbd3c210))
|
||||
- Allow to chose webroot ([36cb6cc](https://github.com/C4illin/ConvertX/commit/36cb6cc589d80d0a87fa8dbe605db71a9a2570f9)), closes [#180](https://github.com/C4illin/ConvertX/issues/180)
|
||||
- disable convert when uploading ([58e220e](https://github.com/C4illin/ConvertX/commit/58e220e82d7f9c163d6ea4dc31092c08a3e254f4)), closes [#177](https://github.com/C4illin/ConvertX/issues/177)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* treat unknown as m4a ([1a442d6](https://github.com/C4illin/ConvertX/commit/1a442d6e69606afef63b1e7df36aa83d111fa23d)), closes [#178](https://github.com/C4illin/ConvertX/issues/178)
|
||||
* wait for both upload and selection ([4c05fd7](https://github.com/C4illin/ConvertX/commit/4c05fd72bbbf91ee02327f6fcbf749b78272376b)), closes [#177](https://github.com/C4illin/ConvertX/issues/177)
|
||||
- treat unknown as m4a ([1a442d6](https://github.com/C4illin/ConvertX/commit/1a442d6e69606afef63b1e7df36aa83d111fa23d)), closes [#178](https://github.com/C4illin/ConvertX/issues/178)
|
||||
- wait for both upload and selection ([4c05fd7](https://github.com/C4illin/ConvertX/commit/4c05fd72bbbf91ee02327f6fcbf749b78272376b)), closes [#177](https://github.com/C4illin/ConvertX/issues/177)
|
||||
|
||||
## [0.8.1](https://github.com/C4illin/ConvertX/compare/v0.8.0...v0.8.1) (2024-10-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* disable convert button when input is empty ([78844d7](https://github.com/C4illin/ConvertX/commit/78844d7bd55990789ed07c81e49043e688cbe656)), closes [#151](https://github.com/C4illin/ConvertX/issues/151)
|
||||
* resize to fit for ico ([b4e53db](https://github.com/C4illin/ConvertX/commit/b4e53dbb8e70b3a95b44e5b756759d16117a87e1)), closes [#157](https://github.com/C4illin/ConvertX/issues/157)
|
||||
* treat jfif as jpeg ([339b79f](https://github.com/C4illin/ConvertX/commit/339b79f786131deb93f0d5683e03178fdcab1ef5)), closes [#163](https://github.com/C4illin/ConvertX/issues/163)
|
||||
- disable convert button when input is empty ([78844d7](https://github.com/C4illin/ConvertX/commit/78844d7bd55990789ed07c81e49043e688cbe656)), closes [#151](https://github.com/C4illin/ConvertX/issues/151)
|
||||
- resize to fit for ico ([b4e53db](https://github.com/C4illin/ConvertX/commit/b4e53dbb8e70b3a95b44e5b756759d16117a87e1)), closes [#157](https://github.com/C4illin/ConvertX/issues/157)
|
||||
- treat jfif as jpeg ([339b79f](https://github.com/C4illin/ConvertX/commit/339b79f786131deb93f0d5683e03178fdcab1ef5)), closes [#163](https://github.com/C4illin/ConvertX/issues/163)
|
||||
|
||||
## [0.8.0](https://github.com/C4illin/ConvertX/compare/v0.7.0...v0.8.0) (2024-09-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add light theme, fixes [#156](https://github.com/C4illin/ConvertX/issues/156) ([72636c5](https://github.com/C4illin/ConvertX/commit/72636c5059ebf09c8fece2e268293650b2f8ccf6))
|
||||
|
||||
- add light theme, fixes [#156](https://github.com/C4illin/ConvertX/issues/156) ([72636c5](https://github.com/C4illin/ConvertX/commit/72636c5059ebf09c8fece2e268293650b2f8ccf6))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add support for usd for assimp, [#144](https://github.com/C4illin/ConvertX/issues/144) ([2057167](https://github.com/C4illin/ConvertX/commit/20571675766209ad1251f07e687d29a6791afc8b))
|
||||
* cleanup formats and add opus, fixes [#159](https://github.com/C4illin/ConvertX/issues/159) ([ae1dfaf](https://github.com/C4illin/ConvertX/commit/ae1dfafc9d9116a57b08c2f7fc326990e00824b0))
|
||||
* support .awb and clean up, fixes [#153](https://github.com/C4illin/ConvertX/issues/153), [#92](https://github.com/C4illin/ConvertX/issues/92) ([1c9e67f](https://github.com/C4illin/ConvertX/commit/1c9e67fc3201e0e5dee91e8981adf34daaabf33a))
|
||||
- add support for usd for assimp, [#144](https://github.com/C4illin/ConvertX/issues/144) ([2057167](https://github.com/C4illin/ConvertX/commit/20571675766209ad1251f07e687d29a6791afc8b))
|
||||
- cleanup formats and add opus, fixes [#159](https://github.com/C4illin/ConvertX/issues/159) ([ae1dfaf](https://github.com/C4illin/ConvertX/commit/ae1dfafc9d9116a57b08c2f7fc326990e00824b0))
|
||||
- support .awb and clean up, fixes [#153](https://github.com/C4illin/ConvertX/issues/153), [#92](https://github.com/C4illin/ConvertX/issues/92) ([1c9e67f](https://github.com/C4illin/ConvertX/commit/1c9e67fc3201e0e5dee91e8981adf34daaabf33a))
|
||||
|
||||
## [0.7.0](https://github.com/C4illin/ConvertX/compare/v0.6.0...v0.7.0) (2024-09-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add support for 3d assets through assimp converter ([63a4328](https://github.com/C4illin/ConvertX/commit/63a4328d4a1e01df3e0ec4a877bad8c8ffe71129))
|
||||
|
||||
- Add support for 3d assets through assimp converter ([63a4328](https://github.com/C4illin/ConvertX/commit/63a4328d4a1e01df3e0ec4a877bad8c8ffe71129))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* wrong layout on search with few options ([8817389](https://github.com/C4illin/ConvertX/commit/88173891ba2d69da46eda46f3f598a9b54f26f96))
|
||||
- wrong layout on search with few options ([8817389](https://github.com/C4illin/ConvertX/commit/88173891ba2d69da46eda46f3f598a9b54f26f96))
|
||||
|
||||
## [0.6.0](https://github.com/C4illin/ConvertX/compare/v0.5.0...v0.6.0) (2024-09-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* ui remake with tailwind ([22f823c](https://github.com/C4illin/ConvertX/commit/22f823c535b20382981f86a13616b830a1f3392f))
|
||||
|
||||
- ui remake with tailwind ([22f823c](https://github.com/C4illin/ConvertX/commit/22f823c535b20382981f86a13616b830a1f3392f))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* rename css file to force update cache, fixes [#141](https://github.com/C4illin/ConvertX/issues/141) ([47139a5](https://github.com/C4illin/ConvertX/commit/47139a550bd3d847da288c61bf8f88953b79c673))
|
||||
- rename css file to force update cache, fixes [#141](https://github.com/C4illin/ConvertX/issues/141) ([47139a5](https://github.com/C4illin/ConvertX/commit/47139a550bd3d847da288c61bf8f88953b79c673))
|
||||
|
||||
## [0.5.0](https://github.com/C4illin/ConvertX/compare/v0.4.1...v0.5.0) (2024-09-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add option to customize how often files are automatically deleted ([317c932](https://github.com/C4illin/ConvertX/commit/317c932c2a26280bf37ed3d3bf9b879413590f5a))
|
||||
|
||||
- add option to customize how often files are automatically deleted ([317c932](https://github.com/C4illin/ConvertX/commit/317c932c2a26280bf37ed3d3bf9b879413590f5a))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* improve file name replacement logic ([60ba7c9](https://github.com/C4illin/ConvertX/commit/60ba7c93fbdc961f3569882fade7cc13dee7a7a5))
|
||||
- improve file name replacement logic ([60ba7c9](https://github.com/C4illin/ConvertX/commit/60ba7c93fbdc961f3569882fade7cc13dee7a7a5))
|
||||
|
||||
## [0.4.1](https://github.com/C4illin/ConvertX/compare/v0.4.0...v0.4.1) (2024-09-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* allow non lowercase true and false values, fixes [#122](https://github.com/C4illin/ConvertX/issues/122) ([bef1710](https://github.com/C4illin/ConvertX/commit/bef1710e3376baa7e25c107ded20a40d18b8c6b0))
|
||||
- allow non lowercase true and false values, fixes [#122](https://github.com/C4illin/ConvertX/issues/122) ([bef1710](https://github.com/C4illin/ConvertX/commit/bef1710e3376baa7e25c107ded20a40d18b8c6b0))
|
||||
|
||||
## [0.4.0](https://github.com/C4illin/ConvertX/compare/v0.3.3...v0.4.0) (2024-08-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add option for unauthenticated file conversions [#114](https://github.com/C4illin/ConvertX/issues/114) ([f0d0e43](https://github.com/C4illin/ConvertX/commit/f0d0e4392983c3e4c530304ea88e023fda9bcac0))
|
||||
* add resvg converter ([d5eeef9](https://github.com/C4illin/ConvertX/commit/d5eeef9f6884b2bb878508bed97ea9ceaa662995))
|
||||
* add robots.txt ([6597c1d](https://github.com/C4illin/ConvertX/commit/6597c1d7caeb4dfb6bc47b442e4dfc9840ad12b7))
|
||||
* Add search bar for formats ([53fff59](https://github.com/C4illin/ConvertX/commit/53fff594fc4d69306abcb2a5cad890fcd0953a58))
|
||||
|
||||
- add option for unauthenticated file conversions [#114](https://github.com/C4illin/ConvertX/issues/114) ([f0d0e43](https://github.com/C4illin/ConvertX/commit/f0d0e4392983c3e4c530304ea88e023fda9bcac0))
|
||||
- add resvg converter ([d5eeef9](https://github.com/C4illin/ConvertX/commit/d5eeef9f6884b2bb878508bed97ea9ceaa662995))
|
||||
- add robots.txt ([6597c1d](https://github.com/C4illin/ConvertX/commit/6597c1d7caeb4dfb6bc47b442e4dfc9840ad12b7))
|
||||
- Add search bar for formats ([53fff59](https://github.com/C4illin/ConvertX/commit/53fff594fc4d69306abcb2a5cad890fcd0953a58))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* keep unauthenticated user logged in if allowed [#114](https://github.com/C4illin/ConvertX/issues/114) ([bc4ad49](https://github.com/C4illin/ConvertX/commit/bc4ad492852fad8cb832a0c03485cccdd7f7b117))
|
||||
* pdf support in vips ([8ca4f15](https://github.com/C4illin/ConvertX/commit/8ca4f1587df7f358893941c656d78d75f04dac93))
|
||||
* Slow click on conversion popup does not work ([4d9c4d6](https://github.com/C4illin/ConvertX/commit/4d9c4d64aa0266f3928935ada68d91ac81f638aa))
|
||||
- keep unauthenticated user logged in if allowed [#114](https://github.com/C4illin/ConvertX/issues/114) ([bc4ad49](https://github.com/C4illin/ConvertX/commit/bc4ad492852fad8cb832a0c03485cccdd7f7b117))
|
||||
- pdf support in vips ([8ca4f15](https://github.com/C4illin/ConvertX/commit/8ca4f1587df7f358893941c656d78d75f04dac93))
|
||||
- Slow click on conversion popup does not work ([4d9c4d6](https://github.com/C4illin/ConvertX/commit/4d9c4d64aa0266f3928935ada68d91ac81f638aa))
|
||||
|
||||
## [0.3.3](https://github.com/C4illin/ConvertX/compare/v0.3.2...v0.3.3) (2024-07-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* downgrade @elysiajs/html dependency to version 1.0.2 ([c714ade](https://github.com/C4illin/ConvertX/commit/c714ade3e23865ba6cfaf76c9e7259df1cda222c))
|
||||
- downgrade @elysiajs/html dependency to version 1.0.2 ([c714ade](https://github.com/C4illin/ConvertX/commit/c714ade3e23865ba6cfaf76c9e7259df1cda222c))
|
||||
|
||||
## [0.3.2](https://github.com/C4illin/ConvertX/compare/v0.3.1...v0.3.2) (2024-07-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* increase max request body to support large uploads ([3ae2db5](https://github.com/C4illin/ConvertX/commit/3ae2db5d9b36fe3dcd4372ddcd32aa573ea59aa6)), closes [#64](https://github.com/C4illin/ConvertX/issues/64)
|
||||
- increase max request body to support large uploads ([3ae2db5](https://github.com/C4illin/ConvertX/commit/3ae2db5d9b36fe3dcd4372ddcd32aa573ea59aa6)), closes [#64](https://github.com/C4illin/ConvertX/issues/64)
|
||||
|
||||
## [0.3.1](https://github.com/C4illin/ConvertX/compare/v0.3.0...v0.3.1) (2024-06-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* release releases ([4d4c13a](https://github.com/C4illin/ConvertX/commit/4d4c13a8d85ec7c9209ad41cdbea7d4380b0edbf))
|
||||
- release releases ([4d4c13a](https://github.com/C4illin/ConvertX/commit/4d4c13a8d85ec7c9209ad41cdbea7d4380b0edbf))
|
||||
|
||||
## [0.3.0](https://github.com/C4illin/ConvertX/compare/v0.2.0...v0.3.0) (2024-06-27)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add version number to log ([4dcb796](https://github.com/C4illin/ConvertX/commit/4dcb796e1bd27badc078d0638076cd9f1e81c4a4)), closes [#44](https://github.com/C4illin/ConvertX/issues/44)
|
||||
* change to xelatex ([fae2ba9](https://github.com/C4illin/ConvertX/commit/fae2ba9c54461dccdccd1bfb5e76398540d11d0b))
|
||||
* print version of installed converters to log ([801cf28](https://github.com/C4illin/ConvertX/commit/801cf28d1e5edac9353b0b16be75a4fb48470b8a))
|
||||
- add version number to log ([4dcb796](https://github.com/C4illin/ConvertX/commit/4dcb796e1bd27badc078d0638076cd9f1e81c4a4)), closes [#44](https://github.com/C4illin/ConvertX/issues/44)
|
||||
- change to xelatex ([fae2ba9](https://github.com/C4illin/ConvertX/commit/fae2ba9c54461dccdccd1bfb5e76398540d11d0b))
|
||||
- print version of installed converters to log ([801cf28](https://github.com/C4illin/ConvertX/commit/801cf28d1e5edac9353b0b16be75a4fb48470b8a))
|
||||
|
||||
## [0.2.0](https://github.com/C4illin/ConvertX/compare/v0.1.2...v0.2.0) (2024-06-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add libjxl for jpegxl conversion ([ff680cb](https://github.com/C4illin/ConvertX/commit/ff680cb29534a25c3148a90fd064bb86c71fb482))
|
||||
* change from debian to alpine ([1316957](https://github.com/C4illin/ConvertX/commit/13169574f0134ae236f8d41287bb73930b575e82)), closes [#34](https://github.com/C4illin/ConvertX/issues/34)
|
||||
- add libjxl for jpegxl conversion ([ff680cb](https://github.com/C4illin/ConvertX/commit/ff680cb29534a25c3148a90fd064bb86c71fb482))
|
||||
- change from debian to alpine ([1316957](https://github.com/C4illin/ConvertX/commit/13169574f0134ae236f8d41287bb73930b575e82)), closes [#34](https://github.com/C4illin/ConvertX/issues/34)
|
||||
|
||||
## [0.1.2](https://github.com/C4illin/ConvertX/compare/v0.1.1...v0.1.2) (2024-06-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix incorrect redirect ([25df58b](https://github.com/C4illin/ConvertX/commit/25df58ba82321aaa6617811a6995cb96c2a00a40)), closes [#23](https://github.com/C4illin/ConvertX/issues/23)
|
||||
- fix incorrect redirect ([25df58b](https://github.com/C4illin/ConvertX/commit/25df58ba82321aaa6617811a6995cb96c2a00a40)), closes [#23](https://github.com/C4illin/ConvertX/issues/23)
|
||||
|
||||
## [0.1.1](https://github.com/C4illin/ConvertX/compare/v0.1.0...v0.1.1) (2024-05-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* :bug: make sure all redirects are 302 ([9970fd3](https://github.com/C4illin/ConvertX/commit/9970fd3f89190af96f8762edc3817d1e03082b3a)), closes [#12](https://github.com/C4illin/ConvertX/issues/12)
|
||||
- :bug: make sure all redirects are 302 ([9970fd3](https://github.com/C4illin/ConvertX/commit/9970fd3f89190af96f8762edc3817d1e03082b3a)), closes [#12](https://github.com/C4illin/ConvertX/issues/12)
|
||||
|
||||
## 0.1.0 (2024-05-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* remove file from file list in index.html ([787ff97](https://github.com/C4illin/ConvertX/commit/787ff9741ecbbf4fb4c02b43bd22a214a173fd7b))
|
||||
|
||||
- remove file from file list in index.html ([787ff97](https://github.com/C4illin/ConvertX/commit/787ff9741ecbbf4fb4c02b43bd22a214a173fd7b))
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* release 0.1.0 ([54d9aec](https://github.com/C4illin/ConvertX/commit/54d9aecbf949689b12aa7e5e8e9be7b9032f4431))
|
||||
- release 0.1.0 ([54d9aec](https://github.com/C4illin/ConvertX/commit/54d9aecbf949689b12aa7e5e8e9be7b9032f4431))
|
||||
|
|
|
|||
184
Dockerfile
|
|
@ -1,71 +1,113 @@
|
|||
FROM oven/bun:1.2.2-alpine AS base
|
||||
LABEL org.opencontainers.image.source="https://github.com/C4illin/ConvertX"
|
||||
WORKDIR /app
|
||||
|
||||
# install dependencies into temp directory
|
||||
# this will cache them and speed up future builds
|
||||
FROM base AS install
|
||||
RUN mkdir -p /temp/dev
|
||||
COPY package.json bun.lock /temp/dev/
|
||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||
|
||||
# install with --production (exclude devDependencies)
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json bun.lock /temp/prod/
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||
|
||||
FROM base AS builder
|
||||
RUN apk --no-cache add curl gcc
|
||||
ENV PATH=/root/.cargo/bin:$PATH
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
RUN cargo install resvg
|
||||
|
||||
FROM base AS prerelease
|
||||
WORKDIR /app
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY . .
|
||||
|
||||
# ENV NODE_ENV=production
|
||||
RUN bun run build
|
||||
|
||||
# copy production dependencies and source code into final image
|
||||
FROM base AS release
|
||||
|
||||
RUN apk --no-cache add libheif-tools --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community/
|
||||
|
||||
# install additional dependencies
|
||||
RUN apk --no-cache add \
|
||||
pandoc \
|
||||
texlive \
|
||||
texlive-xetex \
|
||||
texmf-dist-latexextra \
|
||||
ffmpeg \
|
||||
graphicsmagick \
|
||||
ghostscript \
|
||||
vips-tools \
|
||||
vips-poppler \
|
||||
vips-jxl \
|
||||
vips-heif \
|
||||
vips-magick \
|
||||
libjxl-tools \
|
||||
assimp \
|
||||
inkscape \
|
||||
poppler-utils \
|
||||
gcompat \
|
||||
libva-utils \
|
||||
py3-numpy \
|
||||
potrace
|
||||
|
||||
# RUN apk --no-cache add calibre@testing --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main/
|
||||
|
||||
# this might be needed for some latex use cases, will add it if needed.
|
||||
# texmf-dist-fontsextra \
|
||||
|
||||
COPY --from=install /temp/prod/node_modules node_modules
|
||||
COPY --from=builder /root/.cargo/bin/resvg /usr/local/bin/resvg
|
||||
COPY --from=prerelease /app/public/generated.css /app/public/
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000/tcp
|
||||
ENV NODE_ENV=production
|
||||
ENTRYPOINT [ "bun", "run", "./src/index.tsx" ]
|
||||
FROM debian:testing-slim AS base
|
||||
LABEL org.opencontainers.image.source="https://github.com/C4illin/ConvertX"
|
||||
WORKDIR /app
|
||||
|
||||
# install bun
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
curl \
|
||||
unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# if architecture is arm64, use the arm64 version of bun
|
||||
RUN ARCH=$(uname -m) && \
|
||||
if [ "$ARCH" = "aarch64" ]; then \
|
||||
curl -fsSL -o bun-linux-aarch64.zip https://github.com/oven-sh/bun/releases/download/bun-v1.2.2/bun-linux-aarch64.zip; \
|
||||
else \
|
||||
curl -fsSL -o bun-linux-x64-baseline.zip https://github.com/oven-sh/bun/releases/download/bun-v1.2.2/bun-linux-x64-baseline.zip; \
|
||||
fi
|
||||
|
||||
RUN unzip -j bun-linux-*.zip -d /usr/local/bin && \
|
||||
rm bun-linux-*.zip && \
|
||||
chmod +x /usr/local/bin/bun
|
||||
|
||||
# install dependencies into temp directory
|
||||
# this will cache them and speed up future builds
|
||||
FROM base AS install
|
||||
RUN mkdir -p /temp/dev
|
||||
COPY package.json bun.lock /temp/dev/
|
||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||
|
||||
# install with --production (exclude devDependencies)
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json bun.lock /temp/prod/
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||
|
||||
FROM base AS prerelease
|
||||
WORKDIR /app
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY . .
|
||||
|
||||
# ENV NODE_ENV=production
|
||||
RUN bun run build
|
||||
|
||||
# copy production dependencies and source code into final image
|
||||
FROM base AS release
|
||||
|
||||
# install additional dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
assimp-utils \
|
||||
calibre \
|
||||
dasel \
|
||||
dcraw \
|
||||
dvisvgm \
|
||||
ffmpeg \
|
||||
ghostscript \
|
||||
graphicsmagick \
|
||||
imagemagick-7.q16 \
|
||||
inkscape \
|
||||
latexmk \
|
||||
libheif-examples \
|
||||
libjxl-tools \
|
||||
libreoffice \
|
||||
libva2 \
|
||||
libvips-tools \
|
||||
libemail-outlook-message-perl \
|
||||
lmodern \
|
||||
mupdf-tools \
|
||||
pandoc \
|
||||
poppler-utils \
|
||||
potrace \
|
||||
python3-numpy \
|
||||
python3-tinycss2 \
|
||||
resvg \
|
||||
texlive \
|
||||
texlive-fonts-recommended \
|
||||
texlive-latex-extra \
|
||||
texlive-latex-recommended \
|
||||
texlive-xetex \
|
||||
python3 \
|
||||
python3-pip \
|
||||
pipx \
|
||||
--no-install-recommends \
|
||||
&& pipx install "markitdown[all]" \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Add pipx bin directory to PATH
|
||||
ENV PATH="/root/.local/bin:${PATH}"
|
||||
|
||||
# Install VTracer binary
|
||||
RUN ARCH=$(uname -m) && \
|
||||
if [ "$ARCH" = "aarch64" ]; then \
|
||||
VTRACER_ASSET="vtracer-aarch64-unknown-linux-musl.tar.gz"; \
|
||||
else \
|
||||
VTRACER_ASSET="vtracer-x86_64-unknown-linux-musl.tar.gz"; \
|
||||
fi && \
|
||||
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/ && \
|
||||
mv /tmp/vtracer /usr/local/bin/vtracer && \
|
||||
chmod +x /usr/local/bin/vtracer && \
|
||||
rm /tmp/vtracer.tar.gz
|
||||
|
||||
COPY --from=install /temp/prod/node_modules node_modules
|
||||
COPY --from=prerelease /app/public/ /app/public/
|
||||
COPY --from=prerelease /app/dist /app/dist
|
||||
|
||||
# COPY . .
|
||||
RUN mkdir data
|
||||
|
||||
EXPOSE 3000/tcp
|
||||
# used for calibre
|
||||
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
|
||||
ENV NODE_ENV=production
|
||||
ENTRYPOINT [ "bun", "run", "dist/src/index.js" ]
|
||||
|
|
|
|||
157
README.md
|
|
@ -1,157 +0,0 @@
|
|||

|
||||
|
||||
# ConvertX
|
||||
|
||||
[](https://github.com/C4illin/ConvertX/actions/workflows/docker-publish.yml)
|
||||
[](https://github.com/C4illin/ConvertX/pkgs/container/ConvertX)
|
||||
[](https://hub.docker.com/r/c4illin/convertx)
|
||||
[](https://github.com/C4illin/ConvertX/pkgs/container/convertx)
|
||||

|
||||

|
||||

|
||||
<!--  -->
|
||||
|
||||
A self-hosted online file converter. Supports over a thousand different formats. Written with TypeScript, Bun and Elysia.
|
||||
|
||||
## Features
|
||||
|
||||
- Convert files to different formats
|
||||
- Process multiple files at once
|
||||
- Password protection
|
||||
- Multiple accounts
|
||||
|
||||
## Converters supported
|
||||
|
||||
| Converter | Use case | Converts from | Converts to |
|
||||
|------------------------------------------------------------------------------|---------------|---------------|-------------|
|
||||
| [libjxl](https://github.com/libjxl/libjxl) | JPEG XL | 11 | 11 |
|
||||
| [resvg](https://github.com/RazrFalcon/resvg) | SVG | 1 | 1 |
|
||||
| [Vips](https://github.com/libvips/libvips) | Images | 45 | 23 |
|
||||
| [libheif](https://github.com/strukturag/libheif) | HEIF | 2 | 4 |
|
||||
| [XeLaTeX](https://tug.org/xetex/) | LaTeX | 1 | 1 |
|
||||
| [Pandoc](https://pandoc.org/) | Documents | 43 | 65 |
|
||||
| [GraphicsMagick](http://www.graphicsmagick.org/) | Images | 167 | 130 |
|
||||
| [Inkscape](https://inkscape.org/) | Vector images | 7 | 17 |
|
||||
| [Assimp](https://github.com/assimp/assimp) | 3D Assets | 77 | 23 |
|
||||
| [FFmpeg](https://ffmpeg.org/) | Video | ~472 | ~199 |
|
||||
| [Potrace](https://potrace.sourceforge.net/) | Raster to vector | 4 | 11 |
|
||||
|
||||
<!-- | [Calibre](https://calibre-ebook.com/) | E-books | 26 | 19 | -->
|
||||
|
||||
<!-- many ffmpeg fileformats are duplicates -->
|
||||
|
||||
Any missing converter? Open an issue or pull request!
|
||||
|
||||
## Deployment
|
||||
|
||||
> [!WARNING]
|
||||
> If you can't login, make sure you are accessing the service over localhost or https otherwise set HTTP_ALLOWED=true
|
||||
|
||||
```yml
|
||||
# docker-compose.yml
|
||||
services:
|
||||
convertx:
|
||||
image: ghcr.io/c4illin/convertx
|
||||
container_name: convertx
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() if unset
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
docker run -p 3000:3000 -v ./data:/app/data ghcr.io/c4illin/convertx
|
||||
```
|
||||
|
||||
Then visit `http://localhost:3000` in your browser and create your account. Don't leave it unconfigured and open, as anyone can register the first account.
|
||||
|
||||
If you get unable to open database file run `chown -R $USER:$USER path` on the path you choose.
|
||||
|
||||
### Environment variables
|
||||
|
||||
All are optional, JWT_SECRET is recommended to be set.
|
||||
|
||||
| Name | Default | Description |
|
||||
|---------------------------|---------|-------------|
|
||||
| JWT_SECRET | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token |
|
||||
| ACCOUNT_REGISTRATION | false | Allow users to register accounts |
|
||||
| HTTP_ALLOWED | false | Allow HTTP connections, only set this to true locally |
|
||||
| ALLOW_UNAUTHENTICATED | false | Allow unauthenticated users to use the service, only set this to true locally |
|
||||
| AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable |
|
||||
| WEBROOT | | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" |
|
||||
| FFMPEG_ARGS | | Arguments to pass to ffmpeg, e.g. `-preset veryfast` |
|
||||
| HIDE_HISTORY | false | Hide the history page |
|
||||
|
||||
### Docker images
|
||||
|
||||
There is a `:latest` tag that is updated with every release and a `:main` tag that is updated with every push to the main branch. `:latest` is recommended for normal use.
|
||||
|
||||
The image is available on [GitHub Container Registry](https://github.com/C4illin/ConvertX/pkgs/container/ConvertX) and [Docker Hub](https://hub.docker.com/r/c4illin/convertx).
|
||||
|
||||
| Image | What it is |
|
||||
|-------|------------|
|
||||
| `image: ghcr.io/c4illin/convertx` | The latest release on ghcr |
|
||||
| `image: ghcr.io/c4illin/convertx:main` | The latest commit on ghcr |
|
||||
| `image: c4illin/convertx` | The latest release on docker hub |
|
||||
| `image: c4illin/convertx:main` | The latest commit on docker hub |
|
||||
|
||||

|
||||

|
||||
<!-- Dockerhub was introduced in 0.9.0 and older releases -->
|
||||
|
||||
### Tutorial
|
||||
|
||||
> [!NOTE]
|
||||
> These are written by other people, and may be outdated, incorrect or wrong.
|
||||
|
||||
Tutorial in french: <https://belginux.com/installer-convertx-avec-docker/>
|
||||
|
||||
Tutorial in chinese: <https://xzllll.com/24092901/>
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
## Development
|
||||
|
||||
0. Install [Bun](https://bun.sh/) and Git
|
||||
1. Clone the repository
|
||||
2. `bun install`
|
||||
3. `bun run dev`
|
||||
|
||||
Pull requests are welcome! See below and open issues for the list of todos.
|
||||
|
||||
## Todo
|
||||
|
||||
- [x] Add messages for errors in converters
|
||||
- [x] Add searchable list of formats
|
||||
- [ ] Add options for converters
|
||||
- [ ] Divide index.tsx into smaller components
|
||||
- [ ] Add tests
|
||||
- [ ] Make the upload button nicer and more easy to drop files on. Support copy paste as well if possible.
|
||||
- [ ] Make errors logs visible from the web ui
|
||||
- [ ] Add more converters:
|
||||
- [ ] [deark](https://github.com/jsummers/deark)
|
||||
- [ ] LibreOffice
|
||||
- [ ] [dvisvgm](https://github.com/mgieseki/dvisvgm)
|
||||
|
||||
## Contributors
|
||||
|
||||
<a href="https://github.com/C4illin/ConvertX/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=C4illin/ConvertX" alt="Image with all contributors"/>
|
||||
</a>
|
||||
|
||||
## Star History
|
||||
|
||||
<a href="https://github.com/C4illin/ConvertX/stargazers">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=C4illin/ConvertX&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=C4illin/ConvertX&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=C4illin/ConvertX&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
|
@ -10,10 +10,7 @@
|
|||
"attributePosition": "auto"
|
||||
},
|
||||
"files": {
|
||||
"ignore": [
|
||||
"**/node_modules/**",
|
||||
"**/pico.lime.min.css"
|
||||
]
|
||||
"ignore": ["**/node_modules/**", "**/pico.lime.min.css"]
|
||||
},
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
|
|
@ -72,4 +69,4 @@
|
|||
"attributePosition": "auto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
40
compose.yaml
|
|
@ -1,18 +1,22 @@
|
|||
services:
|
||||
convertx:
|
||||
build:
|
||||
context: .
|
||||
# dockerfile: Debian.Dockerfile
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
environment: # Defaults are listed below. All are optional.
|
||||
- ACCOUNT_REGISTRATION=true # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account)
|
||||
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default
|
||||
- HTTP_ALLOWED=true # setting this to true is unsafe, only set this to true locally
|
||||
- ALLOW_UNAUTHENTICATED=true # allows anyone to use the service without logging in, only set this to true locally
|
||||
- AUTO_DELETE_EVERY_N_HOURS=1 # checks every n hours for files older then n hours and deletes them, set to 0 to disable
|
||||
# - FFMPEG_ARGS=-hwaccel vulkan # additional arguments to pass to ffmpeg
|
||||
# - WEBROOT=/convertx # the root path of the web interface, leave empty to disable
|
||||
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
|
||||
ports:
|
||||
- 3000:3000
|
||||
# This compose file is for development and testing purposes only. See README for production deployment instructions.
|
||||
|
||||
services:
|
||||
convertx:
|
||||
build:
|
||||
context: .
|
||||
# dockerfile: Debian.Dockerfile
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
environment: # Defaults are listed below. All are optional.
|
||||
- ACCOUNT_REGISTRATION=true # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account)
|
||||
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default
|
||||
- HTTP_ALLOWED=false # setting this to true is unsafe, only set this to true locally
|
||||
- ALLOW_UNAUTHENTICATED=false # allows anyone to use the service without logging in, only set this to true locally
|
||||
- AUTO_DELETE_EVERY_N_HOURS=1 # checks every n hours for files older then n hours and deletes them, set to 0 to disable
|
||||
# - FFMPEG_ARGS=-hwaccel vulkan # additional arguments to pass to ffmpeg
|
||||
# - WEBROOT=/convertx # the root path of the web interface, leave empty to disable
|
||||
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
|
||||
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
|
||||
# - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices
|
||||
ports:
|
||||
- 3000:3000
|
||||
|
|
|
|||
134
eslint.config.ts
|
|
@ -1,57 +1,77 @@
|
|||
import js from "@eslint/js";
|
||||
import eslintParserTypeScript from "@typescript-eslint/parser";
|
||||
import type { Linter } from "eslint";
|
||||
import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";
|
||||
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
||||
import globals from "globals";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default [
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
// ...tailwind.configs["flat/recommended"],
|
||||
{
|
||||
plugins: {
|
||||
"simple-import-sort": simpleImportSortPlugin,
|
||||
"readable-tailwind": eslintPluginReadableTailwind,
|
||||
},
|
||||
ignores: ["**/node_modules/**"],
|
||||
languageOptions: {
|
||||
parser: eslintParserTypeScript,
|
||||
parserOptions: {
|
||||
project: true,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.browser,
|
||||
},
|
||||
},
|
||||
files: ["**/*.{js,mjs,cjs,jsx,tsx,ts}"],
|
||||
rules: {
|
||||
...eslintPluginReadableTailwind.configs.warning.rules,
|
||||
// "tailwindcss/classnames-order": "off",
|
||||
"readable-tailwind/multiline": [
|
||||
"warn",
|
||||
{
|
||||
group: "newLine",
|
||||
printWidth: 100,
|
||||
},
|
||||
],
|
||||
// "tailwindcss/no-custom-classname": [
|
||||
// "warn",
|
||||
// {
|
||||
// whitelist: [
|
||||
// "select_container",
|
||||
// "convert_to_popup",
|
||||
// "convert_to_group",
|
||||
// "target",
|
||||
// "convert_to_target",
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
},
|
||||
},
|
||||
] as Linter.Config[];
|
||||
import js from "@eslint/js";
|
||||
import eslintPluginBetterTailwindcss from "eslint-plugin-better-tailwindcss";
|
||||
import { defineConfig } from "eslint/config";
|
||||
import globals from "globals";
|
||||
import tseslint, { parser as eslintParserTypeScript } from "typescript-eslint";
|
||||
|
||||
export default defineConfig(
|
||||
{
|
||||
ignores: ["**/node_modules/**", "dist/**"],
|
||||
},
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
{
|
||||
files: ["**/*.{ts,tsx,cts,mts}"],
|
||||
extends: [
|
||||
eslintPluginBetterTailwindcss.configs.recommended,
|
||||
eslintPluginBetterTailwindcss.configs.stylistic,
|
||||
],
|
||||
languageOptions: {
|
||||
parser: eslintParserTypeScript,
|
||||
parserOptions: {
|
||||
project: "./tsconfig.eslint.json",
|
||||
},
|
||||
globals: {
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
"better-tailwindcss": {
|
||||
entryPoint: "src/main.css",
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"better-tailwindcss/enforce-consistent-line-wrapping": [
|
||||
"warn",
|
||||
{
|
||||
group: "newLine",
|
||||
printWidth: 100,
|
||||
},
|
||||
],
|
||||
"better-tailwindcss/no-unknown-classes": [
|
||||
"warn",
|
||||
{
|
||||
ignore: [
|
||||
"^group(?:\\/(\\S*))?$",
|
||||
"^peer(?:\\/(\\S*))?$",
|
||||
"select_container",
|
||||
"convert_to_popup",
|
||||
"convert_to_group",
|
||||
"target",
|
||||
"convert_to_target",
|
||||
"job-details-toggle",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["**/*.{jsx,tsx}"],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["**/*.{js,cjs,mjs,jsx}"],
|
||||
extends: [tseslint.configs.disableTypeChecked],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
61
flake.lock
generated
|
|
@ -1,61 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1747179050,
|
||||
"narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
60
flake.nix
|
|
@ -1,60 +0,0 @@
|
|||
{
|
||||
description = "ConvertX";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = import nixpkgs { inherit system; };
|
||||
appSrc = ./.;
|
||||
|
||||
app = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "convertx";
|
||||
tag = "latest";
|
||||
|
||||
contents = [
|
||||
pkgs.bun
|
||||
pkgs.resvg
|
||||
pkgs.ffmpeg
|
||||
pkgs.graphicsmagick
|
||||
pkgs.ghostscript
|
||||
pkgs.vips
|
||||
pkgs.pandoc
|
||||
pkgs.texlive.combined.scheme-full
|
||||
pkgs.calibre
|
||||
pkgs.inkscape
|
||||
pkgs.poppler_utils
|
||||
pkgs.assimp
|
||||
pkgs.jxrlib
|
||||
pkgs.libheif
|
||||
pkgs.libjxl
|
||||
pkgs.python3Packages.numpy
|
||||
];
|
||||
|
||||
config = {
|
||||
Env = [
|
||||
"NODE_ENV=production"
|
||||
"PATH=/bin:/usr/bin"
|
||||
];
|
||||
WorkingDir = "/app";
|
||||
Cmd = [ "bun" "run" "./src/index.tsx" ];
|
||||
ExposedPorts = {
|
||||
"3000/tcp" = {};
|
||||
};
|
||||
};
|
||||
|
||||
extraCommands = ''
|
||||
export PATH=${pkgs.bun}/bin:$PATH
|
||||
mkdir -p /app
|
||||
cp -r ${./dist}/* /app/
|
||||
'';
|
||||
};
|
||||
|
||||
in {
|
||||
packages.default = app;
|
||||
}
|
||||
);
|
||||
}
|
||||
8
knip.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"$schema": "https://unpkg.com/knip@5/schema.json",
|
||||
"entry": ["tests/**/*.test.ts"],
|
||||
"project": ["src/**/*.ts", "src/**/*.tsx", "tests/**/*.ts"],
|
||||
"tailwind": {
|
||||
"entry": ["src/main.css"]
|
||||
}
|
||||
}
|
||||
6
mise.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[tools]
|
||||
bun = "1.2.2"
|
||||
|
||||
[env]
|
||||
JWT_SECRET = "aLongAndSecretStringUsedToSignTheJSONWebToken1234"
|
||||
FFMPEG_OUTPUT_ARGS = "-preset veryfast -threads 2"
|
||||
75
package.json
|
|
@ -1,24 +1,28 @@
|
|||
{
|
||||
"name": "convertx-frontend",
|
||||
"version": "0.13.0",
|
||||
"version": "0.18.0",
|
||||
"scripts": {
|
||||
"dev": "bun run --watch src/index.tsx",
|
||||
"hot": "bun run --hot src/index.tsx",
|
||||
"start": "bun run src/index.tsx",
|
||||
"format": "eslint --fix .",
|
||||
"build": "bunx @tailwindcss/cli -i ./src/main.css -o ./public/generated.css",
|
||||
"lint": "run-p 'lint:*'",
|
||||
"format": "npm-run-all 'format:*'",
|
||||
"format:eslint": "eslint --fix .",
|
||||
"format:prettier": "prettier --write .",
|
||||
"build:js": "tsc",
|
||||
"build": "bun x @tailwindcss/cli -i ./src/main.css -o ./public/generated.css && bun run build:js",
|
||||
"lint": "npm-run-all 'lint:*'",
|
||||
"lint:tsc": "tsc --noEmit",
|
||||
"lint:knip": "knip",
|
||||
"lint:eslint": "eslint ."
|
||||
"lint:eslint": "eslint .",
|
||||
"lint:prettier": "prettier --check ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@elysiajs/html": "^1.3.0",
|
||||
"@elysiajs/jwt": "^1.3.0",
|
||||
"@elysiajs/static": "^1.3.0",
|
||||
"@kitajs/html": "^4.2.9",
|
||||
"elysia": "^1.3.1",
|
||||
"sanitize-filename": "^1.6.3"
|
||||
"@elysiajs/html": "^1.4.2",
|
||||
"@elysiajs/jwt": "^1.4.2",
|
||||
"@elysiajs/static": "^1.4.10",
|
||||
"@kitajs/html": "^4.2.13",
|
||||
"elysia": "1.4.22",
|
||||
"sanitize-filename": "^1.6.4",
|
||||
"tar": "^7.5.16"
|
||||
},
|
||||
"module": "src/index.tsx",
|
||||
"type": "module",
|
||||
|
|
@ -26,30 +30,27 @@
|
|||
"start": "bun run src/index.tsx"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.26.0",
|
||||
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
|
||||
"@kitajs/ts-html-plugin": "^4.1.1",
|
||||
"@tailwindcss/cli": "^4.1.6",
|
||||
"@tailwindcss/postcss": "^4.1.6",
|
||||
"@total-typescript/ts-reset": "^0.6.1",
|
||||
"@types/bun": "^1.2.13",
|
||||
"@types/eslint-plugin-tailwindcss": "^3.17.0",
|
||||
"@types/node": "^22.15.17",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"cssnano": "^7.0.7",
|
||||
"eslint": "^9.26.0",
|
||||
"eslint-plugin-readable-tailwind": "^2.1.1",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"eslint-plugin-tailwindcss": "4.0.0-alpha.0",
|
||||
"globals": "^16.1.0",
|
||||
"knip": "^5.55.1",
|
||||
"npm-run-all2": "^8.0.1",
|
||||
"postcss": "^8.5.3",
|
||||
"postcss-cli": "^11.0.1",
|
||||
"prettier": "^3.5.3",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@kitajs/ts-html-plugin": "^4.1.4",
|
||||
"@tailwindcss/cli": "^4.3.1",
|
||||
"@tailwindcss/postcss": "^4.3.1",
|
||||
"@types/bun": "latest",
|
||||
"@types/node": "^24.13.2",
|
||||
"eslint": "^10.5.0",
|
||||
"eslint-plugin-better-tailwindcss": "^4.6.0",
|
||||
"globals": "^17.6.0",
|
||||
"knip": "^5.88.1",
|
||||
"npm-run-all2": "^8.0.4",
|
||||
"postcss": "^8.5.15",
|
||||
"prettier": "^3.8.4",
|
||||
"tailwind-scrollbar": "^4.0.2",
|
||||
"tailwindcss": "^4.1.6",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.32.0"
|
||||
}
|
||||
"tailwindcss": "^4.3.1",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.61.1"
|
||||
},
|
||||
"trustedDependencies": [
|
||||
"@parcel/watcher",
|
||||
"@tailwindcss/oxide",
|
||||
"oxc-resolver"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export default {
|
||||
plugins: {
|
||||
"@tailwindcss/postcss": {},
|
||||
},
|
||||
};
|
||||
export default {
|
||||
plugins: {
|
||||
"@tailwindcss/postcss": {},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
/**
|
||||
* @type {import('prettier').Config & import("@ianvs/prettier-plugin-sort-imports").PluginConfig}
|
||||
* @type {import('prettier').Config}
|
||||
*/
|
||||
const config = {
|
||||
arrowParens: "always",
|
||||
printWidth: 80,
|
||||
printWidth: 100,
|
||||
singleQuote: false,
|
||||
semi: true,
|
||||
tabWidth: 2,
|
||||
plugins: ["@ianvs/prettier-plugin-sort-imports"],
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 476 B After Width: | Height: | Size: 405 B |
|
Before Width: | Height: | Size: 960 B After Width: | Height: | Size: 831 B |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
1
public/favicon.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="512" height="512" style="cursor:default" viewBox="0 0 96.983 132.292"><g transform="translate(-56.568 -82.29)"><path d="M124.878 83.82h-60.91a5.86 5.86 0 0 0-5.87 5.87v117.496a5.855 5.855 0 0 0 5.87 5.866h82.182a5.855 5.855 0 0 0 5.87-5.866v-92.55z" style="display:inline;fill:#111827;stroke:#aeb9d0;stroke-width:3.06006;stroke-dasharray:none;stroke-opacity:1"/><circle cx="84.331" cy="128.904" r="6.653" style="fill:#84cc16;fill-opacity:1;stroke-width:2.13082"/><circle cx="105.059" cy="128.904" r="6.653" style="fill:#fff;fill-opacity:1;stroke-width:2.13082"/><circle cx="125.786" cy="128.904" r="6.653" style="fill:#84cc16;fill-opacity:1;stroke-width:2.13082"/><circle cx="84.331" cy="148.438" r="6.653" style="fill:#fff;fill-opacity:1;stroke-width:2.13082"/><circle cx="105.059" cy="148.438" r="6.653" style="display:inline;fill:#84cc16;fill-opacity:1;stroke-width:2.13082"/><circle cx="125.786" cy="148.438" r="6.653" style="fill:#fff;fill-opacity:1;stroke-width:2.13082"/><circle cx="84.331" cy="167.971" r="6.653" style="fill:#84cc16;fill-opacity:1;stroke-width:2.13082"/><circle cx="105.059" cy="167.971" r="6.653" style="fill:#fff;fill-opacity:1;stroke-width:2.13082"/><circle cx="125.786" cy="167.971" r="6.653" style="fill:#84cc16;fill-opacity:1;stroke-width:2.13082"/><path d="M119.124 161.326h13.287v13.287h-13.287z" style="fill:#84cc16;fill-opacity:1;stroke:none;stroke-width:3.04496;stroke-opacity:1"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
|
@ -1,18 +1,4 @@
|
|||
const webroot = document.querySelector("meta[name='webroot']").content;
|
||||
|
||||
window.downloadAll = function () {
|
||||
// Get all download links
|
||||
const downloadLinks = document.querySelectorAll("a[download]");
|
||||
|
||||
// Trigger download for each link
|
||||
downloadLinks.forEach((link, index) => {
|
||||
// We add a delay for each download to prevent them from starting at the same time
|
||||
setTimeout(() => {
|
||||
const event = new MouseEvent("click");
|
||||
link.dispatchEvent(event);
|
||||
}, index * 100);
|
||||
});
|
||||
};
|
||||
const jobId = window.location.pathname.split("/").pop();
|
||||
const main = document.querySelector("main");
|
||||
let progressElem = document.querySelector("progress");
|
||||
|
|
@ -36,3 +22,17 @@ const refreshData = () => {
|
|||
};
|
||||
|
||||
refreshData();
|
||||
|
||||
window.downloadAll = function () {
|
||||
// Get all download links
|
||||
const downloadLinks = document.querySelectorAll("tbody a[download]");
|
||||
|
||||
// Trigger download for each link
|
||||
downloadLinks.forEach((link, index) => {
|
||||
// We add a delay for each download to prevent them from starting at the same time
|
||||
setTimeout(() => {
|
||||
const event = new MouseEvent("click");
|
||||
link.dispatchEvent(event);
|
||||
}, index * 300);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
User-agent: *
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
|
|
@ -17,20 +17,20 @@ dropZone.addEventListener("dragleave", () => {
|
|||
});
|
||||
|
||||
dropZone.addEventListener("drop", (e) => {
|
||||
e.preventDefault();
|
||||
dropZone.classList.remove("dragover");
|
||||
|
||||
const files = e.dataTransfer.files;
|
||||
|
||||
if (files.length === 0) {
|
||||
console.warn("No files dropped — likely a URL or unsupported source.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
console.log("Handling dropped file:", file.name);
|
||||
handleFile(file);
|
||||
}
|
||||
e.preventDefault();
|
||||
dropZone.classList.remove("dragover");
|
||||
|
||||
const files = e.dataTransfer.files;
|
||||
|
||||
if (files.length === 0) {
|
||||
console.warn("No files dropped — likely a URL or unsupported source.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
console.log("Handling dropped file:", file.name);
|
||||
handleFile(file);
|
||||
}
|
||||
});
|
||||
|
||||
// Extracted handleFile function for reusability in drag-and-drop and file input
|
||||
|
|
@ -40,9 +40,9 @@ function handleFile(file) {
|
|||
const row = document.createElement("tr");
|
||||
row.innerHTML = `
|
||||
<td>${file.name}</td>
|
||||
<td><progress max="100"></progress></td>
|
||||
<td><progress max="100" class="inline-block h-2 appearance-none overflow-hidden rounded-full border-0 bg-neutral-700 bg-none text-accent-500 accent-accent-500 [&::-moz-progress-bar]:bg-accent-500 [&::-webkit-progress-value]:rounded-full [&::-webkit-progress-value]:[background:none] [&[value]::-webkit-progress-value]:bg-accent-500 [&[value]::-webkit-progress-value]:transition-[inline-size]"></progress></td>
|
||||
<td>${(file.size / 1024).toFixed(2)} kB</td>
|
||||
<td><a onclick="deleteRow(this)">Remove</a></td>
|
||||
<td><button type="button" class="text-accent-500 hover:underline" onclick="deleteRow(this)">Remove</button></td>
|
||||
`;
|
||||
|
||||
if (!fileType) {
|
||||
|
|
@ -72,9 +72,7 @@ function handleFile(file) {
|
|||
const selectContainer = document.querySelector("form .select_container");
|
||||
|
||||
const updateSearchBar = () => {
|
||||
const convertToInput = document.querySelector(
|
||||
"input[name='convert_to_search']",
|
||||
);
|
||||
const convertToInput = document.querySelector("input[name='convert_to_search']");
|
||||
const convertToPopup = document.querySelector(".convert_to_popup");
|
||||
const convertToGroupElements = document.querySelectorAll(".convert_to_group");
|
||||
const convertToGroups = {};
|
||||
|
|
@ -195,8 +193,7 @@ const deleteRow = (target) => {
|
|||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
}).catch((err) => console.log(err));
|
||||
};
|
||||
|
||||
const uploadFile = (file) => {
|
||||
|
|
@ -207,7 +204,7 @@ const uploadFile = (file) => {
|
|||
const formData = new FormData();
|
||||
formData.append("file", file, file.name);
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open("POST", `${webroot}/upload`, true);
|
||||
|
||||
|
|
@ -234,7 +231,7 @@ const uploadFile = (file) => {
|
|||
console.log(`upload progress (${file.name}):`, (100 * sent) / total);
|
||||
|
||||
let progressbar = file.htmlRow.getElementsByTagName("progress");
|
||||
progressbar[0].value = ((100 * sent) / total);
|
||||
progressbar[0].value = (100 * sent) / total;
|
||||
};
|
||||
|
||||
xhr.onerror = (e) => {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended",
|
||||
":disableDependencyDashboard"
|
||||
],
|
||||
"extends": ["config:recommended", ":disableDependencyDashboard"],
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true,
|
||||
"automerge": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"ignoreDeps": ["bun-types", "@types/bun", "bun", "Bun"]
|
||||
}
|
||||
|
|
|
|||
1
reset.d.ts
vendored
|
|
@ -1 +0,0 @@
|
|||
import "@total-typescript/ts-reset";
|
||||
|
|
@ -1,40 +1,43 @@
|
|||
import { Html } from "@elysiajs/html";
|
||||
|
||||
export const BaseHtml = ({
|
||||
children,
|
||||
title = "ConvertX",
|
||||
webroot = "",
|
||||
}: {
|
||||
children: JSX.Element;
|
||||
title?: string;
|
||||
webroot?: string;
|
||||
}) => (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="webroot" content={webroot} />
|
||||
<title safe>{title}</title>
|
||||
<link rel="stylesheet" href={`${webroot}/generated.css`} />
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="180x180"
|
||||
href={`${webroot}/apple-touch-icon.png`}
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href={`${webroot}/favicon-32x32.png`}
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="16x16"
|
||||
href={`${webroot}/favicon-16x16.png`}
|
||||
/>
|
||||
<link rel="manifest" href={`${webroot}/site.webmanifest`} />
|
||||
</head>
|
||||
<body class="w-full bg-neutral-900 text-neutral-200">{children}</body>
|
||||
</html>
|
||||
);
|
||||
import { version } from "../../package.json";
|
||||
|
||||
export const BaseHtml = ({
|
||||
children,
|
||||
title = "ConvertX",
|
||||
webroot = "",
|
||||
}: {
|
||||
children: JSX.Element;
|
||||
title?: string;
|
||||
webroot?: string;
|
||||
}) => (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="webroot" content={webroot} />
|
||||
<title safe>{title}</title>
|
||||
<link rel="stylesheet" href={`${webroot}/generated.css`} />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href={`${webroot}/apple-touch-icon.png`} />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href={`${webroot}/favicon-32x32.png`} />
|
||||
<link rel="icon" type="image/png" sizes="16x16" href={`${webroot}/favicon-16x16.png`} />
|
||||
<link rel="manifest" href={`${webroot}/site.webmanifest`} />
|
||||
</head>
|
||||
<body class={`flex min-h-screen w-full flex-col bg-neutral-900 text-neutral-200`}>
|
||||
{children}
|
||||
<footer class="w-full">
|
||||
<div class="p-4 text-center text-sm text-neutral-500">
|
||||
<span>Powered by </span>
|
||||
<a
|
||||
href="https://github.com/C4illin/ConvertX"
|
||||
class={`
|
||||
text-neutral-400
|
||||
hover:text-accent-500
|
||||
`}
|
||||
>
|
||||
ConvertX{" "}
|
||||
</a>
|
||||
<span safe>v{version || ""}</span>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import { Html } from "@kitajs/html";
|
||||
|
||||
export const Header = ({
|
||||
loggedIn,
|
||||
accountRegistration,
|
||||
|
|
@ -30,6 +28,19 @@ export const Header = ({
|
|||
</a>
|
||||
</li>
|
||||
)}
|
||||
{!allowUnauthenticated ? (
|
||||
<li>
|
||||
<a
|
||||
class={`
|
||||
text-accent-600 transition-all
|
||||
hover:text-accent-500 hover:underline
|
||||
`}
|
||||
href={`${webroot}/account`}
|
||||
>
|
||||
Account
|
||||
</a>
|
||||
</li>
|
||||
) : null}
|
||||
{!allowUnauthenticated ? (
|
||||
<li>
|
||||
<a
|
||||
|
|
@ -78,7 +89,7 @@ export const Header = ({
|
|||
|
||||
return (
|
||||
<header class="w-full p-4">
|
||||
<nav class="mx-auto flex max-w-4xl justify-between rounded-sm bg-neutral-900 p-4">
|
||||
<nav class={`mx-auto flex max-w-4xl justify-between rounded-sm bg-neutral-900 p-4`}>
|
||||
<ul>
|
||||
<li>
|
||||
<strong>
|
||||
|
|
|
|||
|
|
@ -1,139 +1,144 @@
|
|||
import { execFile } from "node:child_process";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
object: [
|
||||
"3d",
|
||||
"3ds",
|
||||
"3mf",
|
||||
"ac",
|
||||
"ac3d",
|
||||
"acc",
|
||||
"amf",
|
||||
"amj",
|
||||
"ase",
|
||||
"ask",
|
||||
"assbin",
|
||||
"b3d",
|
||||
"blend",
|
||||
"bsp",
|
||||
"bvh",
|
||||
"cob",
|
||||
"csm",
|
||||
"dae",
|
||||
"dxf",
|
||||
"enff",
|
||||
"fbx",
|
||||
"glb",
|
||||
"gltf",
|
||||
"hmb",
|
||||
"hmp",
|
||||
"ifc",
|
||||
"ifczip",
|
||||
"iqm",
|
||||
"irr",
|
||||
"irrmesh",
|
||||
"lwo",
|
||||
"lws",
|
||||
"lxo",
|
||||
"m3d",
|
||||
"md2",
|
||||
"md3",
|
||||
"md5anim",
|
||||
"md5camera",
|
||||
"md5mesh",
|
||||
"mdc",
|
||||
"mdl",
|
||||
"mesh.xml",
|
||||
"mesh",
|
||||
"mot",
|
||||
"ms3d",
|
||||
"ndo",
|
||||
"nff",
|
||||
"obj",
|
||||
"off",
|
||||
"ogex",
|
||||
"pk3",
|
||||
"ply",
|
||||
"pmx",
|
||||
"prj",
|
||||
"q3o",
|
||||
"q3s",
|
||||
"raw",
|
||||
"scn",
|
||||
"sib",
|
||||
"smd",
|
||||
"step",
|
||||
"stl",
|
||||
"stp",
|
||||
"ter",
|
||||
"uc",
|
||||
"usd",
|
||||
"usda",
|
||||
"usdc",
|
||||
"usdz",
|
||||
"vta",
|
||||
"x",
|
||||
"x3d",
|
||||
"x3db",
|
||||
"xgl",
|
||||
"xml",
|
||||
"zae",
|
||||
"zgl",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
object: [
|
||||
"3ds",
|
||||
"3mf",
|
||||
"assbin",
|
||||
"assjson",
|
||||
"assxml",
|
||||
"collada",
|
||||
"dae",
|
||||
"fbx",
|
||||
"fbxa",
|
||||
"glb",
|
||||
"glb2",
|
||||
"gltf",
|
||||
"gltf2",
|
||||
"json",
|
||||
"obj",
|
||||
"objnomtl",
|
||||
"pbrt",
|
||||
"ply",
|
||||
"plyb",
|
||||
"stl",
|
||||
"stlb",
|
||||
"stp",
|
||||
"x",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export async function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("assimp", ["export", filePath, targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
object: [
|
||||
"3d",
|
||||
"3ds",
|
||||
"3mf",
|
||||
"ac",
|
||||
"ac3d",
|
||||
"acc",
|
||||
"amf",
|
||||
"amj",
|
||||
"ase",
|
||||
"ask",
|
||||
"assbin",
|
||||
"b3d",
|
||||
"blend",
|
||||
"bsp",
|
||||
"bvh",
|
||||
"cob",
|
||||
"csm",
|
||||
"dae",
|
||||
"dxf",
|
||||
"enff",
|
||||
"fbx",
|
||||
"glb",
|
||||
"gltf",
|
||||
"hmb",
|
||||
"hmp",
|
||||
"ifc",
|
||||
"ifczip",
|
||||
"iqm",
|
||||
"irr",
|
||||
"irrmesh",
|
||||
"lwo",
|
||||
"lws",
|
||||
"lxo",
|
||||
"m3d",
|
||||
"md2",
|
||||
"md3",
|
||||
"md5anim",
|
||||
"md5camera",
|
||||
"md5mesh",
|
||||
"mdc",
|
||||
"mdl",
|
||||
"mesh.xml",
|
||||
"mesh",
|
||||
"mot",
|
||||
"ms3d",
|
||||
"ndo",
|
||||
"nff",
|
||||
"obj",
|
||||
"off",
|
||||
"ogex",
|
||||
"pk3",
|
||||
"ply",
|
||||
"pmx",
|
||||
"prj",
|
||||
"q3o",
|
||||
"q3s",
|
||||
"raw",
|
||||
"scn",
|
||||
"sib",
|
||||
"smd",
|
||||
"step",
|
||||
"stl",
|
||||
"stp",
|
||||
"ter",
|
||||
"uc",
|
||||
"usd",
|
||||
"usda",
|
||||
"usdc",
|
||||
"usdz",
|
||||
"vta",
|
||||
"x",
|
||||
"x3d",
|
||||
"x3db",
|
||||
"xgl",
|
||||
"xml",
|
||||
"zae",
|
||||
"zgl",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
object: [
|
||||
"3ds",
|
||||
"3mf",
|
||||
"assbin",
|
||||
"assjson",
|
||||
"assxml",
|
||||
"collada",
|
||||
"dae",
|
||||
"fbx",
|
||||
"fbxa",
|
||||
"glb",
|
||||
"glb2",
|
||||
"gltf",
|
||||
"gltf2",
|
||||
"json",
|
||||
"obj",
|
||||
"objnomtl",
|
||||
"pbrt",
|
||||
"ply",
|
||||
"plyb",
|
||||
"stl",
|
||||
"stlb",
|
||||
"stp",
|
||||
"x",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export async function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
"assimp",
|
||||
["export", filePath, targetPath, `-f${convertTo}`],
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { execFile } from "node:child_process";
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
|
|
@ -39,6 +40,7 @@ export const properties = {
|
|||
"fb2",
|
||||
"html",
|
||||
"htmlz",
|
||||
"kepub.epub",
|
||||
"lit",
|
||||
"lrf",
|
||||
"mobi",
|
||||
|
|
@ -61,8 +63,8 @@ export async function convert(
|
|||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("ebook-convert", [filePath, targetPath], (error, stdout, stderr) => {
|
||||
|
|
|
|||
48
src/converters/dasel.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import fs from "fs";
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
document: ["yaml", "toml", "json", "xml", "csv"],
|
||||
},
|
||||
to: {
|
||||
document: ["yaml", "toml", "json", "csv"],
|
||||
},
|
||||
};
|
||||
|
||||
export async function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
const args: string[] = [];
|
||||
|
||||
args.push("--file", filePath);
|
||||
args.push("--read", fileType);
|
||||
args.push("--write", convertTo);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("dasel", args, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
fs.writeFile(targetPath, stdout, (err: NodeJS.ErrnoException | null) => {
|
||||
if (err) {
|
||||
reject(`Failed to write output: ${err}`);
|
||||
} else {
|
||||
resolve("Done");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
49
src/converters/dvisvgm.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
images: ["dvi", "xdv", "pdf", "eps"],
|
||||
},
|
||||
to: {
|
||||
images: ["svg", "svgz"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
const inputArgs: string[] = [];
|
||||
if (fileType === "eps") {
|
||||
inputArgs.push("--eps");
|
||||
}
|
||||
if (fileType === "pdf") {
|
||||
inputArgs.push("--pdf");
|
||||
}
|
||||
if (convertTo === "svgz") {
|
||||
inputArgs.push("-z");
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("dvisvgm", [...inputArgs, filePath, "-o", targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,340 +1,337 @@
|
|||
import { execFile } from "node:child_process";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
image: [
|
||||
"3fr",
|
||||
"8bim",
|
||||
"8bimtext",
|
||||
"8bimwtext",
|
||||
"app1",
|
||||
"app1jpeg",
|
||||
"art",
|
||||
"arw",
|
||||
"avs",
|
||||
"b",
|
||||
"bie",
|
||||
"bigtiff",
|
||||
"bmp",
|
||||
"c",
|
||||
"cals",
|
||||
"caption",
|
||||
"cin",
|
||||
"cmyk",
|
||||
"cmyka",
|
||||
"cr2",
|
||||
"crw",
|
||||
"cur",
|
||||
"cut",
|
||||
"dcm",
|
||||
"dcr",
|
||||
"dcx",
|
||||
"dng",
|
||||
"dpx",
|
||||
"epdf",
|
||||
"epi",
|
||||
"eps",
|
||||
"epsf",
|
||||
"epsi",
|
||||
"ept",
|
||||
"ept2",
|
||||
"ept3",
|
||||
"erf",
|
||||
"exif",
|
||||
"fax",
|
||||
"file",
|
||||
"fits",
|
||||
"fractal",
|
||||
"ftp",
|
||||
"g",
|
||||
"gif",
|
||||
"gif87",
|
||||
"gradient",
|
||||
"gray",
|
||||
"graya",
|
||||
"heic",
|
||||
"heif",
|
||||
"hrz",
|
||||
"http",
|
||||
"icb",
|
||||
"icc",
|
||||
"icm",
|
||||
"ico",
|
||||
"icon",
|
||||
"identity",
|
||||
"image",
|
||||
"iptc",
|
||||
"iptctext",
|
||||
"iptcwtext",
|
||||
"jbg",
|
||||
"jbig",
|
||||
"jng",
|
||||
"jnx",
|
||||
"jpeg",
|
||||
"jpg",
|
||||
"k",
|
||||
"k25",
|
||||
"kdc",
|
||||
"label",
|
||||
"m",
|
||||
"mac",
|
||||
"map",
|
||||
"mat",
|
||||
"mef",
|
||||
"miff",
|
||||
"mng",
|
||||
"mono",
|
||||
"mpc",
|
||||
"mrw",
|
||||
"msl",
|
||||
"mtv",
|
||||
"mvg",
|
||||
"nef",
|
||||
"null",
|
||||
"o",
|
||||
"orf",
|
||||
"otb",
|
||||
"p7",
|
||||
"pal",
|
||||
"palm",
|
||||
"pam",
|
||||
"pbm",
|
||||
"pcd",
|
||||
"pcds",
|
||||
"pct",
|
||||
"pcx",
|
||||
"pdb",
|
||||
"pdf",
|
||||
"pef",
|
||||
"pfa",
|
||||
"pfb",
|
||||
"pgm",
|
||||
"picon",
|
||||
"pict",
|
||||
"pix",
|
||||
"plasma",
|
||||
"png",
|
||||
"png00",
|
||||
"png24",
|
||||
"png32",
|
||||
"png48",
|
||||
"png64",
|
||||
"png8",
|
||||
"pnm",
|
||||
"ppm",
|
||||
"ps",
|
||||
"ptif",
|
||||
"pwp",
|
||||
"r",
|
||||
"raf",
|
||||
"ras",
|
||||
"rgb",
|
||||
"rgba",
|
||||
"rla",
|
||||
"rle",
|
||||
"sct",
|
||||
"sfw",
|
||||
"sgi",
|
||||
"sr2",
|
||||
"srf",
|
||||
"stegano",
|
||||
"sun",
|
||||
"svg",
|
||||
"svgz",
|
||||
"text",
|
||||
"tga",
|
||||
"tif",
|
||||
"tiff",
|
||||
"tile",
|
||||
"tim",
|
||||
"topol",
|
||||
"ttf",
|
||||
"txt",
|
||||
"uyvy",
|
||||
"vda",
|
||||
"vicar",
|
||||
"vid",
|
||||
"viff",
|
||||
"vst",
|
||||
"wbmp",
|
||||
"webp",
|
||||
"wmf",
|
||||
"wpg",
|
||||
"x3f",
|
||||
"xbm",
|
||||
"xc",
|
||||
"xcf",
|
||||
"xmp",
|
||||
"xpm",
|
||||
"xv",
|
||||
"xwd",
|
||||
"y",
|
||||
"yuv",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
image: [
|
||||
"8bim",
|
||||
"8bimtext",
|
||||
"8bimwtext",
|
||||
"app1",
|
||||
"app1jpeg",
|
||||
"art",
|
||||
"avs",
|
||||
"b",
|
||||
"bie",
|
||||
"bigtiff",
|
||||
"bmp",
|
||||
"bmp2",
|
||||
"bmp3",
|
||||
"brf",
|
||||
"c",
|
||||
"cals",
|
||||
"cin",
|
||||
"cmyk",
|
||||
"cmyka",
|
||||
"dcx",
|
||||
"dpx",
|
||||
"epdf",
|
||||
"epi",
|
||||
"eps",
|
||||
"eps2",
|
||||
"eps3",
|
||||
"epsf",
|
||||
"epsi",
|
||||
"ept",
|
||||
"ept2",
|
||||
"ept3",
|
||||
"exif",
|
||||
"fax",
|
||||
"fits",
|
||||
"g",
|
||||
"gif",
|
||||
"gif87",
|
||||
"gray",
|
||||
"graya",
|
||||
"histogram",
|
||||
"html",
|
||||
"icb",
|
||||
"icc",
|
||||
"icm",
|
||||
"info",
|
||||
"iptc",
|
||||
"iptctext",
|
||||
"iptcwtext",
|
||||
"isobrl",
|
||||
"isobrl6",
|
||||
"jbg",
|
||||
"jbig",
|
||||
"jng",
|
||||
"jpeg",
|
||||
"k",
|
||||
"m",
|
||||
"m2v",
|
||||
"map",
|
||||
"mat",
|
||||
"matte",
|
||||
"miff",
|
||||
"mng",
|
||||
"mono",
|
||||
"mpc",
|
||||
"mpeg",
|
||||
"mpg",
|
||||
"msl",
|
||||
"mtv",
|
||||
"mvg",
|
||||
"null",
|
||||
"o",
|
||||
"otb",
|
||||
"p7",
|
||||
"pal",
|
||||
"pam",
|
||||
"pbm",
|
||||
"pcd",
|
||||
"pcds",
|
||||
"pcl",
|
||||
"pct",
|
||||
"pcx",
|
||||
"pdb",
|
||||
"pdf",
|
||||
"pgm",
|
||||
"picon",
|
||||
"pict",
|
||||
"png",
|
||||
"png00",
|
||||
"png24",
|
||||
"png32",
|
||||
"png48",
|
||||
"png64",
|
||||
"png8",
|
||||
"pnm",
|
||||
"ppm",
|
||||
"preview",
|
||||
"ps",
|
||||
"ps2",
|
||||
"ps3",
|
||||
"ptif",
|
||||
"r",
|
||||
"ras",
|
||||
"rgb",
|
||||
"rgba",
|
||||
"sgi",
|
||||
"shtml",
|
||||
"sun",
|
||||
"text",
|
||||
"tga",
|
||||
"tiff",
|
||||
"txt",
|
||||
"ubrl",
|
||||
"ubrl6",
|
||||
"uil",
|
||||
"uyvy",
|
||||
"vda",
|
||||
"vicar",
|
||||
"vid",
|
||||
"viff",
|
||||
"vst",
|
||||
"wbmp",
|
||||
"webp",
|
||||
"x",
|
||||
"xbm",
|
||||
"xmp",
|
||||
"xpm",
|
||||
"xv",
|
||||
"xwd",
|
||||
"y",
|
||||
"yuv",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
"gm",
|
||||
["convert", filePath, targetPath],
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
image: [
|
||||
"3fr",
|
||||
"8bim",
|
||||
"8bimtext",
|
||||
"8bimwtext",
|
||||
"app1",
|
||||
"app1jpeg",
|
||||
"art",
|
||||
"arw",
|
||||
"avs",
|
||||
"b",
|
||||
"bie",
|
||||
"bigtiff",
|
||||
"bmp",
|
||||
"c",
|
||||
"cals",
|
||||
"caption",
|
||||
"cin",
|
||||
"cmyk",
|
||||
"cmyka",
|
||||
"cr2",
|
||||
"crw",
|
||||
"cur",
|
||||
"cut",
|
||||
"dcm",
|
||||
"dcr",
|
||||
"dcx",
|
||||
"dng",
|
||||
"dpx",
|
||||
"epdf",
|
||||
"epi",
|
||||
"eps",
|
||||
"epsf",
|
||||
"epsi",
|
||||
"ept",
|
||||
"ept2",
|
||||
"ept3",
|
||||
"erf",
|
||||
"exif",
|
||||
"fax",
|
||||
"file",
|
||||
"fits",
|
||||
"fractal",
|
||||
"ftp",
|
||||
"g",
|
||||
"gif",
|
||||
"gif87",
|
||||
"gradient",
|
||||
"gray",
|
||||
"graya",
|
||||
"heic",
|
||||
"heif",
|
||||
"hrz",
|
||||
"http",
|
||||
"icb",
|
||||
"icc",
|
||||
"icm",
|
||||
"ico",
|
||||
"icon",
|
||||
"identity",
|
||||
"image",
|
||||
"iptc",
|
||||
"iptctext",
|
||||
"iptcwtext",
|
||||
"jbg",
|
||||
"jbig",
|
||||
"jng",
|
||||
"jnx",
|
||||
"jpeg",
|
||||
"jpg",
|
||||
"k",
|
||||
"k25",
|
||||
"kdc",
|
||||
"label",
|
||||
"m",
|
||||
"mac",
|
||||
"map",
|
||||
"mat",
|
||||
"mef",
|
||||
"miff",
|
||||
"mng",
|
||||
"mono",
|
||||
"mpc",
|
||||
"mrw",
|
||||
"msl",
|
||||
"mtv",
|
||||
"mvg",
|
||||
"nef",
|
||||
"null",
|
||||
"o",
|
||||
"orf",
|
||||
"otb",
|
||||
"p7",
|
||||
"pal",
|
||||
"palm",
|
||||
"pam",
|
||||
"pbm",
|
||||
"pcd",
|
||||
"pcds",
|
||||
"pct",
|
||||
"pcx",
|
||||
"pdb",
|
||||
"pdf",
|
||||
"pef",
|
||||
"pfa",
|
||||
"pfb",
|
||||
"pgm",
|
||||
"picon",
|
||||
"pict",
|
||||
"pix",
|
||||
"plasma",
|
||||
"png",
|
||||
"png00",
|
||||
"png24",
|
||||
"png32",
|
||||
"png48",
|
||||
"png64",
|
||||
"png8",
|
||||
"pnm",
|
||||
"ppm",
|
||||
"ps",
|
||||
"ptif",
|
||||
"pwp",
|
||||
"r",
|
||||
"raf",
|
||||
"ras",
|
||||
"rgb",
|
||||
"rgba",
|
||||
"rla",
|
||||
"rle",
|
||||
"sct",
|
||||
"sfw",
|
||||
"sgi",
|
||||
"sr2",
|
||||
"srf",
|
||||
"stegano",
|
||||
"sun",
|
||||
"svg",
|
||||
"svgz",
|
||||
"text",
|
||||
"tga",
|
||||
"tif",
|
||||
"tiff",
|
||||
"tile",
|
||||
"tim",
|
||||
"topol",
|
||||
"ttf",
|
||||
"txt",
|
||||
"uyvy",
|
||||
"vda",
|
||||
"vicar",
|
||||
"vid",
|
||||
"viff",
|
||||
"vst",
|
||||
"wbmp",
|
||||
"webp",
|
||||
"wmf",
|
||||
"wpg",
|
||||
"x3f",
|
||||
"xbm",
|
||||
"xc",
|
||||
"xcf",
|
||||
"xmp",
|
||||
"xpm",
|
||||
"xv",
|
||||
"xwd",
|
||||
"y",
|
||||
"yuv",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
image: [
|
||||
"8bim",
|
||||
"8bimtext",
|
||||
"8bimwtext",
|
||||
"app1",
|
||||
"app1jpeg",
|
||||
"art",
|
||||
"avs",
|
||||
"b",
|
||||
"bie",
|
||||
"bigtiff",
|
||||
"bmp",
|
||||
"bmp2",
|
||||
"bmp3",
|
||||
"brf",
|
||||
"c",
|
||||
"cals",
|
||||
"cin",
|
||||
"cmyk",
|
||||
"cmyka",
|
||||
"dcx",
|
||||
"dpx",
|
||||
"epdf",
|
||||
"epi",
|
||||
"eps",
|
||||
"eps2",
|
||||
"eps3",
|
||||
"epsf",
|
||||
"epsi",
|
||||
"ept",
|
||||
"ept2",
|
||||
"ept3",
|
||||
"exif",
|
||||
"fax",
|
||||
"fits",
|
||||
"g",
|
||||
"gif",
|
||||
"gif87",
|
||||
"gray",
|
||||
"graya",
|
||||
"histogram",
|
||||
"html",
|
||||
"icb",
|
||||
"icc",
|
||||
"icm",
|
||||
"info",
|
||||
"iptc",
|
||||
"iptctext",
|
||||
"iptcwtext",
|
||||
"isobrl",
|
||||
"isobrl6",
|
||||
"jbg",
|
||||
"jbig",
|
||||
"jng",
|
||||
"jpeg",
|
||||
"k",
|
||||
"m",
|
||||
"m2v",
|
||||
"map",
|
||||
"mat",
|
||||
"matte",
|
||||
"miff",
|
||||
"mng",
|
||||
"mono",
|
||||
"mpc",
|
||||
"mpeg",
|
||||
"mpg",
|
||||
"msl",
|
||||
"mtv",
|
||||
"mvg",
|
||||
"null",
|
||||
"o",
|
||||
"otb",
|
||||
"p7",
|
||||
"pal",
|
||||
"pam",
|
||||
"pbm",
|
||||
"pcd",
|
||||
"pcds",
|
||||
"pcl",
|
||||
"pct",
|
||||
"pcx",
|
||||
"pdb",
|
||||
"pdf",
|
||||
"pgm",
|
||||
"picon",
|
||||
"pict",
|
||||
"png",
|
||||
"png00",
|
||||
"png24",
|
||||
"png32",
|
||||
"png48",
|
||||
"png64",
|
||||
"png8",
|
||||
"pnm",
|
||||
"ppm",
|
||||
"preview",
|
||||
"ps",
|
||||
"ps2",
|
||||
"ps3",
|
||||
"ptif",
|
||||
"r",
|
||||
"ras",
|
||||
"rgb",
|
||||
"rgba",
|
||||
"sgi",
|
||||
"shtml",
|
||||
"sun",
|
||||
"text",
|
||||
"tga",
|
||||
"tiff",
|
||||
"txt",
|
||||
"ubrl",
|
||||
"ubrl6",
|
||||
"uil",
|
||||
"uyvy",
|
||||
"vda",
|
||||
"vicar",
|
||||
"vid",
|
||||
"viff",
|
||||
"vst",
|
||||
"wbmp",
|
||||
"webp",
|
||||
"x",
|
||||
"xbm",
|
||||
"xmp",
|
||||
"xpm",
|
||||
"xv",
|
||||
"xwd",
|
||||
"y",
|
||||
"yuv",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("gm", ["convert", filePath, targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
492
src/converters/imagemagick.ts
Normal file
|
|
@ -0,0 +1,492 @@
|
|||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
// declare possible conversions
|
||||
export const properties = {
|
||||
from: {
|
||||
images: [
|
||||
"3fr",
|
||||
"3g2",
|
||||
"3gp",
|
||||
"aai",
|
||||
"ai",
|
||||
"apng",
|
||||
"art",
|
||||
"arw",
|
||||
"avci",
|
||||
"avi",
|
||||
"avif",
|
||||
"avs",
|
||||
"bayer",
|
||||
"bayera",
|
||||
"bgr",
|
||||
"bgra",
|
||||
"bgro",
|
||||
"bmp",
|
||||
"bmp2",
|
||||
"bmp3",
|
||||
"cal",
|
||||
"cals",
|
||||
"canvas",
|
||||
"caption",
|
||||
"cin",
|
||||
"clip",
|
||||
"clipboard",
|
||||
"cmyk",
|
||||
"cmyka",
|
||||
"cr2",
|
||||
"cr3",
|
||||
"crw",
|
||||
"cube",
|
||||
"cur",
|
||||
"cut",
|
||||
"data",
|
||||
"dcm",
|
||||
"dcr",
|
||||
"dcraw",
|
||||
"dcx",
|
||||
"dds",
|
||||
"dfont",
|
||||
"dng",
|
||||
"dpx",
|
||||
"dxt1",
|
||||
"dxt5",
|
||||
"emf",
|
||||
"epdf",
|
||||
"epi",
|
||||
"eps",
|
||||
"epsf",
|
||||
"epsi",
|
||||
"ept",
|
||||
"ept2",
|
||||
"ept3",
|
||||
"erf",
|
||||
"exr",
|
||||
"farbfeld",
|
||||
"fax",
|
||||
"ff",
|
||||
"fff",
|
||||
"file",
|
||||
"fits",
|
||||
"fl32",
|
||||
"flif",
|
||||
"flv",
|
||||
"fractal",
|
||||
"ftp",
|
||||
"fts",
|
||||
"ftxt",
|
||||
"g3",
|
||||
"g4",
|
||||
"gif",
|
||||
"gif87",
|
||||
"gradient",
|
||||
"gray",
|
||||
"graya",
|
||||
"group4",
|
||||
"hald",
|
||||
"hdr",
|
||||
"heic",
|
||||
"heif",
|
||||
"hrz",
|
||||
"http",
|
||||
"https",
|
||||
"icb",
|
||||
"ico",
|
||||
"icon",
|
||||
"iiq",
|
||||
"inline",
|
||||
"ipl",
|
||||
"j2c",
|
||||
"j2k",
|
||||
"jng",
|
||||
"jnx",
|
||||
"jp2",
|
||||
"jpc",
|
||||
"jpe",
|
||||
"jpeg",
|
||||
"jpg",
|
||||
"jpm",
|
||||
"jps",
|
||||
"jpt",
|
||||
"jxl",
|
||||
"k25",
|
||||
"kdc",
|
||||
"label",
|
||||
"m2v",
|
||||
"m4v",
|
||||
"mac",
|
||||
"map",
|
||||
"mask",
|
||||
"mat",
|
||||
"mdc",
|
||||
"mef",
|
||||
"miff",
|
||||
"mkv",
|
||||
"mng",
|
||||
"mono",
|
||||
"mos",
|
||||
"mov",
|
||||
"mp4",
|
||||
"mpc",
|
||||
"mpeg",
|
||||
"mpg",
|
||||
"mpo",
|
||||
"mrw",
|
||||
"msl",
|
||||
"msvg",
|
||||
"mtv",
|
||||
"mvg",
|
||||
"nef",
|
||||
"nrw",
|
||||
"null",
|
||||
"ora",
|
||||
"orf",
|
||||
"otb",
|
||||
"otf",
|
||||
"pal",
|
||||
"palm",
|
||||
"pam",
|
||||
"pango",
|
||||
"pattern",
|
||||
"pbm",
|
||||
"pcd",
|
||||
"pcds",
|
||||
"pcl",
|
||||
"pct",
|
||||
"pcx",
|
||||
"pdb",
|
||||
"pdf",
|
||||
"pdfa",
|
||||
"pef",
|
||||
"pes",
|
||||
"pfa",
|
||||
"pfb",
|
||||
"pfm",
|
||||
"pgm",
|
||||
"pgx",
|
||||
"phm",
|
||||
"picon",
|
||||
"pict",
|
||||
"pix",
|
||||
"pjpeg",
|
||||
"plasma",
|
||||
"png",
|
||||
"png00",
|
||||
"png24",
|
||||
"png32",
|
||||
"png48",
|
||||
"png64",
|
||||
"png8",
|
||||
"pnm",
|
||||
"pocketmod",
|
||||
"ppm",
|
||||
"ps",
|
||||
"psb",
|
||||
"psd",
|
||||
"ptif",
|
||||
"pwp",
|
||||
"qoi",
|
||||
"radial",
|
||||
"raf",
|
||||
"ras",
|
||||
"raw",
|
||||
"rgb",
|
||||
"rgb565",
|
||||
"rgba",
|
||||
"rgbo",
|
||||
"rgf",
|
||||
"rla",
|
||||
"rle",
|
||||
"rmf",
|
||||
"rsvg",
|
||||
"rw2",
|
||||
"rwl",
|
||||
"scr",
|
||||
"screenshot",
|
||||
"sct",
|
||||
"sfw",
|
||||
"sgi",
|
||||
"six",
|
||||
"sixel",
|
||||
"sr2",
|
||||
"srf",
|
||||
"srw",
|
||||
"stegano",
|
||||
"sti",
|
||||
"strimg",
|
||||
"sun",
|
||||
"svg",
|
||||
"svgz",
|
||||
"text",
|
||||
"tga",
|
||||
"tiff",
|
||||
"tiff64",
|
||||
"tile",
|
||||
"tim",
|
||||
"tm2",
|
||||
"ttc",
|
||||
"ttf",
|
||||
"txt",
|
||||
"uyvy",
|
||||
"vda",
|
||||
"vicar",
|
||||
"vid",
|
||||
"viff",
|
||||
"vips",
|
||||
"vst",
|
||||
"wbmp",
|
||||
"webm",
|
||||
"webp",
|
||||
"wmf",
|
||||
"wmv",
|
||||
"wpg",
|
||||
"x3f",
|
||||
"xbm",
|
||||
"xc",
|
||||
"xcf",
|
||||
"xpm",
|
||||
"xps",
|
||||
"xv",
|
||||
"ycbcr",
|
||||
"ycbcra",
|
||||
"yuv",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
images: [
|
||||
"aai",
|
||||
"ai",
|
||||
"apng",
|
||||
"art",
|
||||
"ashlar",
|
||||
"avif",
|
||||
"avs",
|
||||
"bayer",
|
||||
"bayera",
|
||||
"bgr",
|
||||
"bgra",
|
||||
"bgro",
|
||||
"bmp",
|
||||
"bmp2",
|
||||
"bmp3",
|
||||
"brf",
|
||||
"cal",
|
||||
"cals",
|
||||
"cin",
|
||||
"cip",
|
||||
"clip",
|
||||
"clipboard",
|
||||
"cmyk",
|
||||
"cmyka",
|
||||
"cur",
|
||||
"data",
|
||||
"dcx",
|
||||
"dds",
|
||||
"dpx",
|
||||
"dxt1",
|
||||
"dxt5",
|
||||
"epdf",
|
||||
"epi",
|
||||
"eps",
|
||||
"eps2",
|
||||
"eps3",
|
||||
"epsf",
|
||||
"epsi",
|
||||
"ept",
|
||||
"ept2",
|
||||
"ept3",
|
||||
"exr",
|
||||
"farbfeld",
|
||||
"fax",
|
||||
"ff",
|
||||
"fits",
|
||||
"fl32",
|
||||
"flif",
|
||||
"flv",
|
||||
"fts",
|
||||
"ftxt",
|
||||
"g3",
|
||||
"g4",
|
||||
"gif",
|
||||
"gif87",
|
||||
"gray",
|
||||
"graya",
|
||||
"group4",
|
||||
"hdr",
|
||||
"histogram",
|
||||
"hrz",
|
||||
"htm",
|
||||
"html",
|
||||
"icb",
|
||||
"ico",
|
||||
"icon",
|
||||
"info",
|
||||
"inline",
|
||||
"ipl",
|
||||
"isobrl",
|
||||
"isobrl6",
|
||||
"j2c",
|
||||
"j2k",
|
||||
"jng",
|
||||
"jp2",
|
||||
"jpc",
|
||||
"jpe",
|
||||
"jpeg",
|
||||
"jpg",
|
||||
"jpm",
|
||||
"jps",
|
||||
"jpt",
|
||||
"json",
|
||||
"jxl",
|
||||
"m2v",
|
||||
"m4v",
|
||||
"map",
|
||||
"mask",
|
||||
"mat",
|
||||
"matte",
|
||||
"miff",
|
||||
"mkv",
|
||||
"mng",
|
||||
"mono",
|
||||
"mov",
|
||||
"mp4",
|
||||
"mpc",
|
||||
"mpeg",
|
||||
"mpg",
|
||||
"msl",
|
||||
"msvg",
|
||||
"mtv",
|
||||
"mvg",
|
||||
"null",
|
||||
"otb",
|
||||
"pal",
|
||||
"palm",
|
||||
"pam",
|
||||
"pbm",
|
||||
"pcd",
|
||||
"pcds",
|
||||
"pcl",
|
||||
"pct",
|
||||
"pcx",
|
||||
"pdb",
|
||||
"pdf",
|
||||
"pdfa",
|
||||
"pfm",
|
||||
"pgm",
|
||||
"pgx",
|
||||
"phm",
|
||||
"picon",
|
||||
"pict",
|
||||
"pjpeg",
|
||||
"png",
|
||||
"png00",
|
||||
"png24",
|
||||
"png32",
|
||||
"png48",
|
||||
"png64",
|
||||
"png8",
|
||||
"pnm",
|
||||
"pocketmod",
|
||||
"ppm",
|
||||
"ps",
|
||||
"ps2",
|
||||
"ps3",
|
||||
"psb",
|
||||
"psd",
|
||||
"ptif",
|
||||
"qoi",
|
||||
"ras",
|
||||
"rgb",
|
||||
"rgba",
|
||||
"rgbo",
|
||||
"rgf",
|
||||
"rsvg",
|
||||
"sgi",
|
||||
"shtml",
|
||||
"six",
|
||||
"sixel",
|
||||
"sparse",
|
||||
"strimg",
|
||||
"sun",
|
||||
"svg",
|
||||
"svgz",
|
||||
"tga",
|
||||
"thumbnail",
|
||||
"tiff",
|
||||
"tiff64",
|
||||
"txt",
|
||||
"ubrl",
|
||||
"ubrl6",
|
||||
"uil",
|
||||
"uyvy",
|
||||
"vda",
|
||||
"vicar",
|
||||
"vid",
|
||||
"viff",
|
||||
"vips",
|
||||
"vst",
|
||||
"wbmp",
|
||||
"webm",
|
||||
"webp",
|
||||
"wmv",
|
||||
"wpg",
|
||||
"xbm",
|
||||
"xpm",
|
||||
"xv",
|
||||
"yaml",
|
||||
"ycbcr",
|
||||
"ycbcra",
|
||||
"yuv",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
let outputArgs: string[] = [];
|
||||
let inputArgs: string[] = [];
|
||||
|
||||
if (convertTo === "ico") {
|
||||
outputArgs = ["-define", "icon:auto-resize=256,128,64,48,32,16", "-background", "none"];
|
||||
|
||||
if (fileType === "svg") {
|
||||
// this might be a bit too much, but it works
|
||||
inputArgs = ["-background", "none", "-density", "512"];
|
||||
}
|
||||
}
|
||||
|
||||
// Handle EMF files specifically to avoid LibreOffice delegate issues
|
||||
if (fileType === "emf") {
|
||||
// Use direct conversion without delegates for EMF files
|
||||
inputArgs.push("-define", "emf:delegate=false", "-density", "300");
|
||||
outputArgs.push("-background", "white", "-alpha", "remove");
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
"magick",
|
||||
[...inputArgs, filePath, ...outputArgs, targetPath],
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { execFile } from "node:child_process";
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
|
|
@ -32,28 +33,24 @@ export function convert(
|
|||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
"inkscape",
|
||||
[filePath, "-o", targetPath],
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
execFile("inkscape", [filePath, "-o", targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
},
|
||||
);
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,9 @@
|
|||
import { execFile } from "child_process";
|
||||
import { execFile as execFileOriginal } from "child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
images: [
|
||||
"avci",
|
||||
"avcs",
|
||||
"avif",
|
||||
"h264",
|
||||
"heic",
|
||||
"heics",
|
||||
"heif",
|
||||
"heifs",
|
||||
"hif",
|
||||
"mkv",
|
||||
"mp4",
|
||||
],
|
||||
images: ["avci", "avcs", "avif", "h264", "heic", "heics", "heif", "heifs", "hif", "mkv", "mp4"],
|
||||
},
|
||||
to: {
|
||||
images: ["jpeg", "png", "y4m"],
|
||||
|
|
@ -26,28 +15,24 @@ export function convert(
|
|||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
"heif-convert",
|
||||
[filePath, targetPath],
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
execFile("heif-convert", [filePath, targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
},
|
||||
);
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +1,50 @@
|
|||
import { execFile } from "node:child_process";
|
||||
|
||||
// declare possible conversions
|
||||
export const properties = {
|
||||
from: {
|
||||
jxl: ["jxl"],
|
||||
images: [
|
||||
"apng",
|
||||
"exr",
|
||||
"gif",
|
||||
"jpeg",
|
||||
"pam",
|
||||
"pfm",
|
||||
"pgm",
|
||||
"pgx",
|
||||
"png",
|
||||
"ppm",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
jxl: [
|
||||
"apng",
|
||||
"exr",
|
||||
"gif",
|
||||
"jpeg",
|
||||
"pam",
|
||||
"pfm",
|
||||
"pgm",
|
||||
"pgx",
|
||||
"png",
|
||||
"ppm",
|
||||
],
|
||||
images: ["jxl"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
let tool = "";
|
||||
if (fileType === "jxl") {
|
||||
tool = "djxl";
|
||||
}
|
||||
|
||||
if (convertTo === "jxl") {
|
||||
tool = "cjxl";
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(tool, [filePath, targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
// declare possible conversions
|
||||
export const properties = {
|
||||
from: {
|
||||
jxl: ["jxl"],
|
||||
images: ["apng", "exr", "gif", "jpeg", "pam", "pfm", "pgm", "pgx", "png", "ppm"],
|
||||
},
|
||||
to: {
|
||||
jxl: ["apng", "exr", "jpeg", "pam", "pfm", "pgm", "pgx", "png", "ppm"],
|
||||
images: ["jxl"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
let tool = "";
|
||||
if (fileType === "jxl") {
|
||||
tool = "djxl";
|
||||
}
|
||||
|
||||
if (convertTo === "jxl") {
|
||||
tool = "cjxl";
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(tool, [filePath, targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
179
src/converters/libreoffice.ts
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
text: [
|
||||
"602",
|
||||
"abw",
|
||||
"csv",
|
||||
"cwk",
|
||||
"doc",
|
||||
"docm",
|
||||
"docx",
|
||||
"dot",
|
||||
"dotx",
|
||||
"dotm",
|
||||
"epub",
|
||||
"fb2",
|
||||
"fodt",
|
||||
"htm",
|
||||
"html",
|
||||
"hwp",
|
||||
"mcw",
|
||||
"mw",
|
||||
"mwd",
|
||||
"lwp",
|
||||
"lrf",
|
||||
"odt",
|
||||
"ott",
|
||||
"pages",
|
||||
"pdf",
|
||||
"psw",
|
||||
"rtf",
|
||||
"sdw",
|
||||
"stw",
|
||||
"sxw",
|
||||
"tab",
|
||||
"tsv",
|
||||
"txt",
|
||||
"wn",
|
||||
"wpd",
|
||||
"wps",
|
||||
"wpt",
|
||||
"wri",
|
||||
"xhtml",
|
||||
"xml",
|
||||
"zabw",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
text: [
|
||||
"csv",
|
||||
"doc",
|
||||
"docm",
|
||||
"docx",
|
||||
"dot",
|
||||
"dotx",
|
||||
"dotm",
|
||||
"epub",
|
||||
"fodt",
|
||||
"htm",
|
||||
"html",
|
||||
"odt",
|
||||
"ott",
|
||||
"pdf",
|
||||
"rtf",
|
||||
"tab",
|
||||
"tsv",
|
||||
"txt",
|
||||
"wps",
|
||||
"wpt",
|
||||
"xhtml",
|
||||
"xml",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
type FileCategories = "text" | "calc";
|
||||
|
||||
const filters: Record<FileCategories, Record<string, string>> = {
|
||||
text: {
|
||||
"602": "T602Document",
|
||||
abw: "AbiWord",
|
||||
csv: "Text",
|
||||
doc: "MS Word 97",
|
||||
docm: "MS Word 2007 XML VBA",
|
||||
docx: "MS Word 2007 XML",
|
||||
dot: "MS Word 97 Vorlage",
|
||||
dotx: "MS Word 2007 XML Template",
|
||||
dotm: "MS Word 2007 XML Template",
|
||||
epub: "EPUB",
|
||||
fb2: "Fictionbook 2",
|
||||
fodt: "OpenDocument Text Flat XML",
|
||||
htm: "HTML (StarWriter)",
|
||||
html: "HTML (StarWriter)",
|
||||
hwp: "writer_MIZI_Hwp_97",
|
||||
mcw: "MacWrite",
|
||||
mw: "MacWrite",
|
||||
mwd: "Mariner_Write",
|
||||
lwp: "LotusWordPro",
|
||||
lrf: "BroadBand eBook",
|
||||
odt: "writer8",
|
||||
ott: "writer8_template",
|
||||
pages: "Apple Pages",
|
||||
pdf: "writer_pdf_import",
|
||||
psw: "PocketWord File",
|
||||
rtf: "Rich Text Format",
|
||||
sdw: "StarOffice_Writer",
|
||||
stw: "writer_StarOffice_XML_Writer_Template",
|
||||
sxw: "StarOffice XML (Writer)",
|
||||
tab: "Text",
|
||||
tsv: "Text",
|
||||
txt: "Text",
|
||||
wn: "WriteNow",
|
||||
wpd: "WordPerfect",
|
||||
wps: "MS Word 97",
|
||||
wpt: "MS Word 97 Vorlage",
|
||||
wri: "MS_Write",
|
||||
xhtml: "HTML (StarWriter)",
|
||||
xml: "OpenDocument Text Flat XML",
|
||||
zabw: "AbiWord",
|
||||
},
|
||||
calc: {},
|
||||
};
|
||||
|
||||
const getFilters = (fileType: string, converto: string) => {
|
||||
if (converto === "pdf") {
|
||||
return [null, null];
|
||||
} else if (fileType in filters.text && converto in filters.text) {
|
||||
return [filters.text[fileType], filters.text[converto]];
|
||||
} else if (fileType in filters.calc && converto in filters.calc) {
|
||||
return [filters.calc[fileType], filters.calc[converto]];
|
||||
}
|
||||
return [null, null];
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal,
|
||||
): Promise<string> {
|
||||
const outputPath = targetPath.split("/").slice(0, -1).join("/").replace("./", "") ?? targetPath;
|
||||
|
||||
// Build arguments array
|
||||
const args: string[] = [];
|
||||
args.push("--headless");
|
||||
const [inFilter, outFilter] = getFilters(fileType, convertTo);
|
||||
|
||||
if (inFilter) {
|
||||
args.push(`--infilter=${inFilter}`);
|
||||
}
|
||||
|
||||
if (outFilter) {
|
||||
args.push("--convert-to", `${convertTo}:${outFilter}`, "--outdir", outputPath, filePath);
|
||||
} else {
|
||||
args.push("--convert-to", convertTo, "--outdir", outputPath, filePath);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("soffice", args, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,17 +1,30 @@
|
|||
import { normalizeFiletype } from "../helpers/normalizeFiletype";
|
||||
import { Cookie } from "elysia";
|
||||
import db from "../db/db";
|
||||
import { MAX_CONVERT_PROCESS } from "../helpers/env";
|
||||
import { normalizeFiletype, normalizeOutputFiletype } from "../helpers/normalizeFiletype";
|
||||
import { convert as convertassimp, properties as propertiesassimp } from "./assimp";
|
||||
import { convert as convertCalibre, properties as propertiesCalibre } from "./calibre";
|
||||
import { convert as convertDasel, properties as propertiesDasel } from "./dasel";
|
||||
import { convert as convertDvisvgm, properties as propertiesDvisvgm } from "./dvisvgm";
|
||||
import { convert as convertFFmpeg, properties as propertiesFFmpeg } from "./ffmpeg";
|
||||
import { convert as convertGraphicsmagick, properties as propertiesGraphicsmagick } from "./graphicsmagick";
|
||||
import {
|
||||
convert as convertGraphicsmagick,
|
||||
properties as propertiesGraphicsmagick,
|
||||
} from "./graphicsmagick";
|
||||
import { convert as convertImagemagick, properties as propertiesImagemagick } from "./imagemagick";
|
||||
import { convert as convertInkscape, properties as propertiesInkscape } from "./inkscape";
|
||||
import { convert as convertLibheif, properties as propertiesLibheif } from "./libheif";
|
||||
import { convert as convertLibjxl, properties as propertiesLibjxl } from "./libjxl";
|
||||
import { convert as convertLibreOffice, properties as propertiesLibreOffice } from "./libreoffice";
|
||||
import { convert as convertMsgconvert, properties as propertiesMsgconvert } from "./msgconvert";
|
||||
import { convert as convertPandoc, properties as propertiesPandoc } from "./pandoc";
|
||||
import { convert as convertPotrace, properties as propertiesPotrace } from "./potrace";
|
||||
import { convert as convertresvg, properties as propertiesresvg } from "./resvg";
|
||||
import { convert as convertImage, properties as propertiesImage } from "./vips";
|
||||
import { convert as convertVtracer, properties as propertiesVtracer } from "./vtracer";
|
||||
import { convert as convertVcf, properties as propertiesVcf } from "./vcf";
|
||||
import { convert as convertxelatex, properties as propertiesxelatex } from "./xelatex";
|
||||
// import { convert as convertCalibre, properties as propertiesCalibre } from "./calibre";
|
||||
import { convert as convertLibheif, properties as propertiesLibheif } from "./libheif";
|
||||
import { convert as convertpotrace, properties as propertiespotrace } from "./potrace";
|
||||
|
||||
import { convert as convertMarkitdown, properties as propertiesMarkitdown } from "./markitdown";
|
||||
|
||||
// This should probably be reconstructed so that the functions are not imported instead the functions hook into this to make the converters more modular
|
||||
|
||||
|
|
@ -43,6 +56,11 @@ const properties: Record<
|
|||
) => unknown;
|
||||
}
|
||||
> = {
|
||||
// Prioritize Inkscape for EMF files as it handles them better than ImageMagick
|
||||
inkscape: {
|
||||
properties: propertiesInkscape,
|
||||
converter: convertInkscape,
|
||||
},
|
||||
libjxl: {
|
||||
properties: propertiesLibjxl,
|
||||
converter: convertLibjxl,
|
||||
|
|
@ -63,22 +81,38 @@ const properties: Record<
|
|||
properties: propertiesxelatex,
|
||||
converter: convertxelatex,
|
||||
},
|
||||
// calibre: {
|
||||
// properties: propertiesCalibre,
|
||||
// converter: convertCalibre,
|
||||
// },
|
||||
calibre: {
|
||||
properties: propertiesCalibre,
|
||||
converter: convertCalibre,
|
||||
},
|
||||
dasel: {
|
||||
properties: propertiesDasel,
|
||||
converter: convertDasel,
|
||||
},
|
||||
libreoffice: {
|
||||
properties: propertiesLibreOffice,
|
||||
converter: convertLibreOffice,
|
||||
},
|
||||
pandoc: {
|
||||
properties: propertiesPandoc,
|
||||
converter: convertPandoc,
|
||||
},
|
||||
msgconvert: {
|
||||
properties: propertiesMsgconvert,
|
||||
converter: convertMsgconvert,
|
||||
},
|
||||
dvisvgm: {
|
||||
properties: propertiesDvisvgm,
|
||||
converter: convertDvisvgm,
|
||||
},
|
||||
imagemagick: {
|
||||
properties: propertiesImagemagick,
|
||||
converter: convertImagemagick,
|
||||
},
|
||||
graphicsmagick: {
|
||||
properties: propertiesGraphicsmagick,
|
||||
converter: convertGraphicsmagick,
|
||||
},
|
||||
inkscape: {
|
||||
properties: propertiesInkscape,
|
||||
converter: convertInkscape,
|
||||
},
|
||||
assimp: {
|
||||
properties: propertiesassimp,
|
||||
converter: convertassimp,
|
||||
|
|
@ -88,12 +122,79 @@ const properties: Record<
|
|||
converter: convertFFmpeg,
|
||||
},
|
||||
potrace: {
|
||||
properties: propertiespotrace,
|
||||
converter: convertpotrace,
|
||||
properties: propertiesPotrace,
|
||||
converter: convertPotrace,
|
||||
},
|
||||
vtracer: {
|
||||
properties: propertiesVtracer,
|
||||
converter: convertVtracer,
|
||||
},
|
||||
vcf: {
|
||||
properties: propertiesVcf,
|
||||
converter: convertVcf,
|
||||
},
|
||||
markitDown: {
|
||||
properties: propertiesMarkitdown,
|
||||
converter: convertMarkitdown,
|
||||
},
|
||||
};
|
||||
|
||||
export async function mainConverter(
|
||||
function chunks<T>(arr: T[], size: number): T[][] {
|
||||
if (size <= 0) {
|
||||
return [arr];
|
||||
}
|
||||
return Array.from({ length: Math.ceil(arr.length / size) }, (_: T, i: number) =>
|
||||
arr.slice(i * size, i * size + size),
|
||||
);
|
||||
}
|
||||
|
||||
export async function handleConvert(
|
||||
fileNames: string[],
|
||||
userUploadsDir: string,
|
||||
userOutputDir: string,
|
||||
convertTo: string,
|
||||
converterName: string,
|
||||
jobId: Cookie<string | undefined>,
|
||||
) {
|
||||
const query = db.query(
|
||||
"INSERT INTO file_names (job_id, file_name, output_file_name, status) VALUES (?1, ?2, ?3, ?4)",
|
||||
);
|
||||
|
||||
for (const chunk of chunks(fileNames, MAX_CONVERT_PROCESS)) {
|
||||
const toProcess: Promise<string>[] = [];
|
||||
for (const fileName of chunk) {
|
||||
const filePath = `${userUploadsDir}${fileName}`;
|
||||
const fileTypeOrig = fileName.includes(".") ? (fileName.split(".").pop() ?? "") : "";
|
||||
const fileType = normalizeFiletype(fileTypeOrig);
|
||||
const newFileExt = normalizeOutputFiletype(convertTo);
|
||||
let newFileName: string;
|
||||
if (fileTypeOrig === "") {
|
||||
newFileName = `${fileName}.${newFileExt}`;
|
||||
} else {
|
||||
newFileName = fileName.replace(
|
||||
new RegExp(`${fileTypeOrig}(?!.*${fileTypeOrig})`),
|
||||
newFileExt,
|
||||
);
|
||||
}
|
||||
const targetPath = `${userOutputDir}${newFileName}`;
|
||||
toProcess.push(
|
||||
new Promise((resolve, reject) => {
|
||||
mainConverter(filePath, fileType, convertTo, targetPath, {}, converterName)
|
||||
.then((r) => {
|
||||
if (jobId.value) {
|
||||
query.run(jobId.value, fileName, newFileName, r);
|
||||
}
|
||||
resolve(r);
|
||||
})
|
||||
.catch((c) => reject(c));
|
||||
}),
|
||||
);
|
||||
}
|
||||
await Promise.all(toProcess);
|
||||
}
|
||||
}
|
||||
|
||||
async function mainConverter(
|
||||
inputFilePath: string,
|
||||
fileTypeOriginal: string,
|
||||
convertTo: string,
|
||||
|
|
@ -103,7 +204,7 @@ export async function mainConverter(
|
|||
) {
|
||||
const fileType = normalizeFiletype(fileTypeOriginal);
|
||||
|
||||
let converterFunc: typeof properties["libjxl"]["converter"] | undefined;
|
||||
let converterFunc: (typeof properties)["libjxl"]["converter"] | undefined;
|
||||
|
||||
if (converterName) {
|
||||
converterFunc = properties[converterName]?.converter;
|
||||
|
|
@ -129,20 +230,12 @@ export async function mainConverter(
|
|||
}
|
||||
|
||||
if (!converterFunc) {
|
||||
console.log(
|
||||
`No available converter supports converting from ${fileType} to ${convertTo}.`,
|
||||
);
|
||||
console.log(`No available converter supports converting from ${fileType} to ${convertTo}.`);
|
||||
return "File type not supported";
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await converterFunc(
|
||||
inputFilePath,
|
||||
fileType,
|
||||
convertTo,
|
||||
targetPath,
|
||||
options,
|
||||
);
|
||||
const result = await converterFunc(inputFilePath, fileType, convertTo, targetPath, options);
|
||||
|
||||
console.log(
|
||||
`Converted ${inputFilePath} from ${fileType} to ${convertTo} successfully using ${converterName}.`,
|
||||
|
|
@ -167,23 +260,18 @@ const possibleTargets: Record<string, Record<string, string[]>> = {};
|
|||
|
||||
for (const converterName in properties) {
|
||||
const converterProperties = properties[converterName]?.properties;
|
||||
|
||||
if (!converterProperties) {
|
||||
continue;
|
||||
}
|
||||
if (!converterProperties) continue;
|
||||
|
||||
for (const key in converterProperties.from) {
|
||||
if (converterProperties.from[key] === undefined) {
|
||||
continue;
|
||||
}
|
||||
const fromList = converterProperties.from[key];
|
||||
const toList = converterProperties.to[key];
|
||||
|
||||
for (const extension of converterProperties.from[key] ?? []) {
|
||||
if (!possibleTargets[extension]) {
|
||||
possibleTargets[extension] = {};
|
||||
}
|
||||
if (!fromList || !toList) continue;
|
||||
|
||||
possibleTargets[extension][converterName] =
|
||||
converterProperties.to[key] || [];
|
||||
for (const ext of fromList) {
|
||||
if (!possibleTargets[ext]) possibleTargets[ext] = {};
|
||||
|
||||
possibleTargets[ext][converterName] = toList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -212,11 +300,6 @@ for (const converterName in properties) {
|
|||
}
|
||||
possibleInputs.sort();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const getPossibleInputs = () => {
|
||||
return possibleInputs;
|
||||
};
|
||||
|
||||
const allTargets: Record<string, string[]> = {};
|
||||
|
||||
for (const converterName in properties) {
|
||||
|
|
@ -259,29 +342,3 @@ for (const converterName in properties) {
|
|||
export const getAllInputs = (converter: string) => {
|
||||
return allInputs[converter] || [];
|
||||
};
|
||||
|
||||
// // count the number of unique formats
|
||||
// const uniqueFormats = new Set();
|
||||
|
||||
// for (const converterName in properties) {
|
||||
// const converterProperties = properties[converterName]?.properties;
|
||||
|
||||
// if (!converterProperties) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// for (const key in converterProperties.from) {
|
||||
// for (const extension of converterProperties.from[key] ?? []) {
|
||||
// uniqueFormats.add(extension);
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (const key in converterProperties.to) {
|
||||
// for (const extension of converterProperties.to[key] ?? []) {
|
||||
// uniqueFormats.add(extension);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // print the number of unique Inputs and Outputs
|
||||
// console.log(`Unique Formats: ${uniqueFormats.size}`);
|
||||
39
src/converters/markitdown.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
document: ["pdf", "powerpoint", "excel", "docx", "pptx", "html"],
|
||||
},
|
||||
to: {
|
||||
document: ["md"],
|
||||
},
|
||||
};
|
||||
|
||||
export async function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("markitdown", [filePath, "-o", targetPath], (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(`markitdown error: ${err}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
52
src/converters/msgconvert.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
email: ["msg"],
|
||||
},
|
||||
to: {
|
||||
email: ["eml"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (fileType === "msg" && convertTo === "eml") {
|
||||
// Convert MSG to EML using msgconvert
|
||||
// msgconvert will output to the same directory as the input file with .eml extension
|
||||
// We need to use --outfile to specify the target path
|
||||
const args = ["--outfile", targetPath, filePath];
|
||||
|
||||
execFile("msgconvert", args, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(new Error(`msgconvert failed: ${error.message}`));
|
||||
return;
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
// Log sanitized stderr to avoid exposing sensitive paths
|
||||
const sanitizedStderr = stderr.replace(/(\/[^\s]+)/g, "[REDACTED_PATH]");
|
||||
console.warn(
|
||||
`msgconvert stderr: ${sanitizedStderr.length > 200 ? sanitizedStderr.slice(0, 200) + "..." : sanitizedStderr}`,
|
||||
);
|
||||
}
|
||||
|
||||
resolve(targetPath);
|
||||
});
|
||||
} else {
|
||||
reject(
|
||||
new Error(
|
||||
`Unsupported conversion from ${fileType} to ${convertTo}. Only MSG to EML conversion is currently supported.`,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1,162 +1,163 @@
|
|||
import { execFile } from "node:child_process";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
text: [
|
||||
"textile",
|
||||
"tikiwiki",
|
||||
"tsv",
|
||||
"twiki",
|
||||
"typst",
|
||||
"vimwiki",
|
||||
"biblatex",
|
||||
"bibtex",
|
||||
"bits",
|
||||
"commonmark",
|
||||
"commonmark_x",
|
||||
"creole",
|
||||
"csljson",
|
||||
"csv",
|
||||
"djot",
|
||||
"docbook",
|
||||
"docx",
|
||||
"dokuwiki",
|
||||
"endnotexml",
|
||||
"epub",
|
||||
"fb2",
|
||||
"gfm",
|
||||
"haddock",
|
||||
"html",
|
||||
"ipynb",
|
||||
"jats",
|
||||
"jira",
|
||||
"json",
|
||||
"latex",
|
||||
"man",
|
||||
"markdown",
|
||||
"markdown_mmd",
|
||||
"markdown_phpextra",
|
||||
"markdown_strict",
|
||||
"mediawiki",
|
||||
"muse",
|
||||
"pandoc native",
|
||||
"opml",
|
||||
"org",
|
||||
"ris",
|
||||
"rst",
|
||||
"rtf",
|
||||
"t2t",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
text: [
|
||||
"tei",
|
||||
"texinfo",
|
||||
"textile",
|
||||
"typst",
|
||||
"xwiki",
|
||||
"zimwiki",
|
||||
"asciidoc",
|
||||
"asciidoc_legacy",
|
||||
"asciidoctor",
|
||||
"beamer",
|
||||
"biblatex",
|
||||
"bibtex",
|
||||
"chunkedhtml",
|
||||
"commonmark",
|
||||
"commonmark_x",
|
||||
"context",
|
||||
"csljson",
|
||||
"djot",
|
||||
"docbook",
|
||||
"docbook4",
|
||||
"docbook5",
|
||||
"docx",
|
||||
"dokuwiki",
|
||||
"dzslides",
|
||||
"epub",
|
||||
"epub2",
|
||||
"epub3",
|
||||
"fb2",
|
||||
"gfm",
|
||||
"haddock",
|
||||
"html",
|
||||
"html4",
|
||||
"html5",
|
||||
"icml",
|
||||
"ipynb",
|
||||
"jats",
|
||||
"jats_archiving",
|
||||
"jats_articleauthoring",
|
||||
"jats_publishing",
|
||||
"jira",
|
||||
"json",
|
||||
"latex",
|
||||
"man",
|
||||
"markdown",
|
||||
"markdown_mmd",
|
||||
"markdown_phpextra",
|
||||
"markdown_strict",
|
||||
"markua",
|
||||
"mediawiki",
|
||||
"ms",
|
||||
"muse",
|
||||
"pandoc native",
|
||||
"odt",
|
||||
"opendocument",
|
||||
"opml",
|
||||
"org",
|
||||
"pdf",
|
||||
"plain",
|
||||
"pptx",
|
||||
"revealjs",
|
||||
"rst",
|
||||
"rtf",
|
||||
"s5",
|
||||
"slideous",
|
||||
"slidy",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
// set xelatex here
|
||||
const xelatex = ["pdf", "latex"];
|
||||
|
||||
// Build arguments array
|
||||
const args: string[] = [];
|
||||
|
||||
if (xelatex.includes(convertTo)) {
|
||||
args.push("--pdf-engine=xelatex");
|
||||
}
|
||||
|
||||
args.push(filePath);
|
||||
args.push("-f", fileType);
|
||||
args.push("-t", convertTo);
|
||||
args.push("-o", targetPath);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("pandoc", args, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
text: [
|
||||
"textile",
|
||||
"tikiwiki",
|
||||
"tsv",
|
||||
"twiki",
|
||||
"typst",
|
||||
"vimwiki",
|
||||
"biblatex",
|
||||
"bibtex",
|
||||
"bits",
|
||||
"commonmark",
|
||||
"commonmark_x",
|
||||
"creole",
|
||||
"csljson",
|
||||
"csv",
|
||||
"djot",
|
||||
"docbook",
|
||||
"docx",
|
||||
"dokuwiki",
|
||||
"endnotexml",
|
||||
"epub",
|
||||
"fb2",
|
||||
"gfm",
|
||||
"haddock",
|
||||
"html",
|
||||
"ipynb",
|
||||
"jats",
|
||||
"jira",
|
||||
"json",
|
||||
"latex",
|
||||
"man",
|
||||
"markdown",
|
||||
"markdown_mmd",
|
||||
"markdown_phpextra",
|
||||
"markdown_strict",
|
||||
"mediawiki",
|
||||
"muse",
|
||||
"pandoc native",
|
||||
"opml",
|
||||
"org",
|
||||
"ris",
|
||||
"rst",
|
||||
"rtf",
|
||||
"t2t",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
text: [
|
||||
"tei",
|
||||
"texinfo",
|
||||
"textile",
|
||||
"typst",
|
||||
"xwiki",
|
||||
"zimwiki",
|
||||
"asciidoc",
|
||||
"asciidoc_legacy",
|
||||
"asciidoctor",
|
||||
"beamer",
|
||||
"biblatex",
|
||||
"bibtex",
|
||||
"chunkedhtml",
|
||||
"commonmark",
|
||||
"commonmark_x",
|
||||
"context",
|
||||
"csljson",
|
||||
"djot",
|
||||
"docbook",
|
||||
"docbook4",
|
||||
"docbook5",
|
||||
"docx",
|
||||
"dokuwiki",
|
||||
"dzslides",
|
||||
"epub",
|
||||
"epub2",
|
||||
"epub3",
|
||||
"fb2",
|
||||
"gfm",
|
||||
"haddock",
|
||||
"html",
|
||||
"html4",
|
||||
"html5",
|
||||
"icml",
|
||||
"ipynb",
|
||||
"jats",
|
||||
"jats_archiving",
|
||||
"jats_articleauthoring",
|
||||
"jats_publishing",
|
||||
"jira",
|
||||
"json",
|
||||
"latex",
|
||||
"man",
|
||||
"markdown",
|
||||
"markdown_mmd",
|
||||
"markdown_phpextra",
|
||||
"markdown_strict",
|
||||
"markua",
|
||||
"mediawiki",
|
||||
"ms",
|
||||
"muse",
|
||||
"pandoc native",
|
||||
"odt",
|
||||
"opendocument",
|
||||
"opml",
|
||||
"org",
|
||||
"pdf",
|
||||
"plain",
|
||||
"pptx",
|
||||
"revealjs",
|
||||
"rst",
|
||||
"rtf",
|
||||
"s5",
|
||||
"slideous",
|
||||
"slidy",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal,
|
||||
): Promise<string> {
|
||||
// set xelatex here
|
||||
const xelatex = ["pdf", "latex"];
|
||||
|
||||
// Build arguments array
|
||||
const args: string[] = [];
|
||||
|
||||
if (xelatex.includes(convertTo)) {
|
||||
args.push("--pdf-engine=xelatex");
|
||||
}
|
||||
|
||||
args.push(filePath);
|
||||
args.push("-f", fileType);
|
||||
args.push("-t", convertTo);
|
||||
args.push("-o", targetPath);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("pandoc", args, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,50 @@
|
|||
import { execFile } from "node:child_process";
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
images: ["pnm", "pbm", "pgm", "bmp"],
|
||||
},
|
||||
to: {
|
||||
images: ["svg", "pdf", "pdfpage", "eps", "postscript", "ps", "dxf", "geojson", "pgm", "gimppath", "xfig"],
|
||||
images: [
|
||||
"svg",
|
||||
"pdf",
|
||||
"pdfpage",
|
||||
"eps",
|
||||
"postscript",
|
||||
"ps",
|
||||
"dxf",
|
||||
"geojson",
|
||||
"pgm",
|
||||
"gimppath",
|
||||
"xfig",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("potrace", [filePath, "-o", targetPath, "-b", convertTo], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("potrace", [filePath, "-o", targetPath, "-b", convertTo], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,38 @@
|
|||
import { execFile } from "node:child_process";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
images: ["svg"],
|
||||
},
|
||||
to: {
|
||||
images: ["png"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("resvg", [filePath, targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
images: ["svg"],
|
||||
},
|
||||
to: {
|
||||
images: ["png"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("resvg", [filePath, targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
17
src/converters/types.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { ExecFileOptions } from "child_process";
|
||||
|
||||
export type ExecFileFn = (
|
||||
cmd: string,
|
||||
args: string[],
|
||||
callback: (err: Error | null, stdout: string, stderr: string) => void,
|
||||
options?: ExecFileOptions,
|
||||
) => void;
|
||||
|
||||
export type ConvertFnWithExecFile = (
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options: unknown,
|
||||
execFileOverride?: ExecFileFn,
|
||||
) => Promise<string>;
|
||||
69
src/converters/vcf.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import { readFile, writeFile } from "fs/promises";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
contacts: ["vcf"],
|
||||
},
|
||||
to: {
|
||||
contacts: ["csv"],
|
||||
},
|
||||
};
|
||||
|
||||
export function parseVCF(data: string): Record<string, string>[] {
|
||||
const cards = data
|
||||
.split(/BEGIN:VCARD/)
|
||||
.slice(1)
|
||||
.map((card) => card.split(/END:VCARD/)[0])
|
||||
.filter((card) => card);
|
||||
return cards
|
||||
.map((card) => {
|
||||
if (!card) return {};
|
||||
const lines = card.split("\n").filter((line) => line.trim());
|
||||
const contact: Record<string, string> = {};
|
||||
for (const line of lines) {
|
||||
const colonIndex = line.indexOf(":");
|
||||
if (colonIndex === -1) continue;
|
||||
const key = line.slice(0, colonIndex).trim();
|
||||
const value = line.slice(colonIndex + 1).trim();
|
||||
if (key === "FN") {
|
||||
contact["Full Name"] = value;
|
||||
} else if (key === "N") {
|
||||
const parts = value.split(";");
|
||||
contact["Last Name"] = parts[0] || "";
|
||||
contact["First Name"] = parts[1] || "";
|
||||
} else if (key.startsWith("TEL")) {
|
||||
contact["Phone"] = value;
|
||||
} else if (key.startsWith("EMAIL")) {
|
||||
contact["Email"] = value;
|
||||
} else if (key === "ORG") {
|
||||
contact["Organization"] = value.split(";")[0] || "";
|
||||
}
|
||||
}
|
||||
return contact;
|
||||
})
|
||||
.filter((contact) => Object.keys(contact).length > 0);
|
||||
}
|
||||
|
||||
export function toCSV(data: Record<string, string>[]): string {
|
||||
if (!data.length) return "";
|
||||
const first = data[0];
|
||||
if (!first) return "";
|
||||
const headers = Object.keys(first);
|
||||
const escape = (str: string) => `"${str.replace(/"/g, '""')}"`;
|
||||
const rows = data.map((row) => headers.map((h) => escape(row[h] || "")).join(","));
|
||||
return [headers.join(","), ...rows].join("\n");
|
||||
}
|
||||
|
||||
export async function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
): Promise<string> {
|
||||
const vcfData = await readFile(filePath, "utf-8");
|
||||
const contacts = parseVCF(vcfData);
|
||||
const csvData = toCSV(contacts);
|
||||
await writeFile(targetPath, csvData, "utf-8");
|
||||
return "Done";
|
||||
}
|
||||
|
|
@ -1,142 +1,139 @@
|
|||
import { execFile } from "node:child_process";
|
||||
|
||||
// declare possible conversions
|
||||
export const properties = {
|
||||
from: {
|
||||
images: [
|
||||
"avif",
|
||||
"bif",
|
||||
"csv",
|
||||
"exr",
|
||||
"fits",
|
||||
"gif",
|
||||
"hdr.gz",
|
||||
"hdr",
|
||||
"heic",
|
||||
"heif",
|
||||
"img.gz",
|
||||
"img",
|
||||
"j2c",
|
||||
"j2k",
|
||||
"jp2",
|
||||
"jpeg",
|
||||
"jpx",
|
||||
"jxl",
|
||||
"mat",
|
||||
"mrxs",
|
||||
"ndpi",
|
||||
"nia.gz",
|
||||
"nia",
|
||||
"nii.gz",
|
||||
"nii",
|
||||
"pdf",
|
||||
"pfm",
|
||||
"pgm",
|
||||
"pic",
|
||||
"png",
|
||||
"ppm",
|
||||
"raw",
|
||||
"scn",
|
||||
"svg",
|
||||
"svs",
|
||||
"svslide",
|
||||
"szi",
|
||||
"tif",
|
||||
"tiff",
|
||||
"v",
|
||||
"vips",
|
||||
"vms",
|
||||
"vmu",
|
||||
"webp",
|
||||
"zip",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
images: [
|
||||
"avif",
|
||||
"dzi",
|
||||
"fits",
|
||||
"gif",
|
||||
"hdr.gz",
|
||||
"heic",
|
||||
"heif",
|
||||
"img.gz",
|
||||
"j2c",
|
||||
"j2k",
|
||||
"jp2",
|
||||
"jpeg",
|
||||
"jpx",
|
||||
"jxl",
|
||||
"mat",
|
||||
"nia.gz",
|
||||
"nia",
|
||||
"nii.gz",
|
||||
"nii",
|
||||
"png",
|
||||
"tiff",
|
||||
"vips",
|
||||
"webp",
|
||||
],
|
||||
},
|
||||
options: {
|
||||
svg: {
|
||||
scale: {
|
||||
description: "Scale the image up or down",
|
||||
type: "number",
|
||||
default: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
// if (fileType === "svg") {
|
||||
// const scale = options.scale || 1;
|
||||
// const metadata = await sharp(filePath).metadata();
|
||||
|
||||
// if (!metadata || !metadata.width || !metadata.height) {
|
||||
// throw new Error("Could not get metadata from image");
|
||||
// }
|
||||
|
||||
// const newWidth = Math.round(metadata.width * scale);
|
||||
// const newHeight = Math.round(metadata.height * scale);
|
||||
|
||||
// return await sharp(filePath)
|
||||
// .resize(newWidth, newHeight)
|
||||
// .toFormat(convertTo)
|
||||
// .toFile(targetPath);
|
||||
// }
|
||||
let action = "copy";
|
||||
if (fileType === "pdf") {
|
||||
action = "pdfload";
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
"vips",
|
||||
[action, filePath, targetPath],
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
// declare possible conversions
|
||||
export const properties = {
|
||||
from: {
|
||||
images: [
|
||||
"avif",
|
||||
"bif",
|
||||
"csv",
|
||||
"exr",
|
||||
"fits",
|
||||
"gif",
|
||||
"hdr.gz",
|
||||
"hdr",
|
||||
"heic",
|
||||
"heif",
|
||||
"img.gz",
|
||||
"img",
|
||||
"j2c",
|
||||
"j2k",
|
||||
"jp2",
|
||||
"jpeg",
|
||||
"jpx",
|
||||
"jxl",
|
||||
"mat",
|
||||
"mrxs",
|
||||
"ndpi",
|
||||
"nia.gz",
|
||||
"nia",
|
||||
"nii.gz",
|
||||
"nii",
|
||||
"pdf",
|
||||
"pfm",
|
||||
"pgm",
|
||||
"pic",
|
||||
"png",
|
||||
"ppm",
|
||||
"raw",
|
||||
"scn",
|
||||
"svg",
|
||||
"svs",
|
||||
"svslide",
|
||||
"szi",
|
||||
"tif",
|
||||
"tiff",
|
||||
"v",
|
||||
"vips",
|
||||
"vms",
|
||||
"vmu",
|
||||
"webp",
|
||||
"zip",
|
||||
],
|
||||
},
|
||||
to: {
|
||||
images: [
|
||||
"avif",
|
||||
"dzi",
|
||||
"fits",
|
||||
"gif",
|
||||
"hdr.gz",
|
||||
"heic",
|
||||
"heif",
|
||||
"img.gz",
|
||||
"j2c",
|
||||
"j2k",
|
||||
"jp2",
|
||||
"jpeg",
|
||||
"jpx",
|
||||
"jxl",
|
||||
"mat",
|
||||
"nia.gz",
|
||||
"nia",
|
||||
"nii.gz",
|
||||
"nii",
|
||||
"png",
|
||||
"tiff",
|
||||
"vips",
|
||||
"webp",
|
||||
],
|
||||
},
|
||||
options: {
|
||||
svg: {
|
||||
scale: {
|
||||
description: "Scale the image up or down",
|
||||
type: "number",
|
||||
default: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal,
|
||||
): Promise<string> {
|
||||
// if (fileType === "svg") {
|
||||
// const scale = options.scale || 1;
|
||||
// const metadata = await sharp(filePath).metadata();
|
||||
|
||||
// if (!metadata || !metadata.width || !metadata.height) {
|
||||
// throw new Error("Could not get metadata from image");
|
||||
// }
|
||||
|
||||
// const newWidth = Math.round(metadata.width * scale);
|
||||
// const newHeight = Math.round(metadata.height * scale);
|
||||
|
||||
// return await sharp(filePath)
|
||||
// .resize(newWidth, newHeight)
|
||||
// .toFormat(convertTo)
|
||||
// .toFile(targetPath);
|
||||
// }
|
||||
let action = "copy";
|
||||
if (fileType === "pdf") {
|
||||
action = "pdfload";
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile("vips", [action, filePath, targetPath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
80
src/converters/vtracer.ts
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
images: ["jpg", "jpeg", "png", "bmp", "gif", "tiff", "tif", "webp"],
|
||||
},
|
||||
to: {
|
||||
images: ["svg"],
|
||||
},
|
||||
};
|
||||
|
||||
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(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Build vtracer arguments
|
||||
const args = ["--input", filePath, "--output", targetPath];
|
||||
|
||||
// Add optional parameter if provided
|
||||
if (options && typeof options === "object") {
|
||||
const opts = options as VTracerOptions;
|
||||
const validOptions: Array<keyof VTracerOptions> = [
|
||||
"colormode",
|
||||
"hierarchical",
|
||||
"mode",
|
||||
"filter_speckle",
|
||||
"color_precision",
|
||||
"layer_difference",
|
||||
"corner_threshold",
|
||||
"length_threshold",
|
||||
"max_iterations",
|
||||
"splice_threshold",
|
||||
"path_precision",
|
||||
];
|
||||
|
||||
for (const option of validOptions) {
|
||||
if (opts[option] !== undefined) {
|
||||
args.push(`--${option}`, String(opts[option]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execFile("vtracer", args, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}${stderr ? `\nstderr: ${stderr}` : ""}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,53 +1,45 @@
|
|||
import { execFile } from "node:child_process";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
text: ["tex", "latex"],
|
||||
},
|
||||
to: {
|
||||
text: ["pdf"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
options?: unknown,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// const fileName: string = (targetPath.split("/").pop() as string).replace(".pdf", "")
|
||||
const outputPath = targetPath
|
||||
.split("/")
|
||||
.slice(0, -1)
|
||||
.join("/")
|
||||
.replace("./", "");
|
||||
|
||||
execFile(
|
||||
"latexmk",
|
||||
[
|
||||
"-xelatex",
|
||||
"-interaction=nonstopmode",
|
||||
`-output-directory=${outputPath}`,
|
||||
filePath,
|
||||
],
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
import { execFile as execFileOriginal } from "node:child_process";
|
||||
import { ExecFileFn } from "./types";
|
||||
|
||||
export const properties = {
|
||||
from: {
|
||||
text: ["tex", "latex"],
|
||||
},
|
||||
to: {
|
||||
text: ["pdf"],
|
||||
},
|
||||
};
|
||||
|
||||
export function convert(
|
||||
filePath: string,
|
||||
fileType: string,
|
||||
convertTo: string,
|
||||
targetPath: string,
|
||||
options?: unknown,
|
||||
execFile: ExecFileFn = execFileOriginal,
|
||||
): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// const fileName: string = (targetPath.split("/").pop() as string).replace(".pdf", "")
|
||||
const outputPath = targetPath.split("/").slice(0, -1).join("/").replace("./", "");
|
||||
|
||||
execFile(
|
||||
"latexmk",
|
||||
["-xelatex", "-interaction=nonstopmode", `-output-directory=${outputPath}`, filePath],
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`error: ${error}`);
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
resolve("Done");
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
43
src/db/db.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { mkdirSync } from "node:fs";
|
||||
import { Database } from "bun:sqlite";
|
||||
|
||||
mkdirSync("./data", { recursive: true });
|
||||
const db = new Database("./data/mydb.sqlite", { create: true });
|
||||
|
||||
if (!db.query("SELECT * FROM sqlite_master WHERE type='table'").get()) {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
email TEXT NOT NULL,
|
||||
password TEXT NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS file_names (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
job_id INTEGER NOT NULL,
|
||||
file_name TEXT NOT NULL,
|
||||
output_file_name TEXT NOT NULL,
|
||||
status TEXT DEFAULT 'not started',
|
||||
FOREIGN KEY (job_id) REFERENCES jobs(id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS jobs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
date_created TEXT NOT NULL,
|
||||
status TEXT DEFAULT 'not started',
|
||||
num_files INTEGER DEFAULT 0,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||
);
|
||||
PRAGMA user_version = 1;`);
|
||||
}
|
||||
|
||||
const dbVersion = (db.query("PRAGMA user_version").get() as { user_version?: number }).user_version;
|
||||
if (dbVersion === 0) {
|
||||
db.exec("ALTER TABLE file_names ADD COLUMN status TEXT DEFAULT 'not started';");
|
||||
db.exec("PRAGMA user_version = 1;");
|
||||
console.log("Updated database to version 1.");
|
||||
}
|
||||
|
||||
// enable WAL mode
|
||||
db.exec("PRAGMA journal_mode = WAL;");
|
||||
|
||||
export default db;
|
||||
23
src/db/types.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
export class Filename {
|
||||
id!: number;
|
||||
job_id!: number;
|
||||
file_name!: string;
|
||||
output_file_name!: string;
|
||||
status!: string;
|
||||
}
|
||||
|
||||
export class Jobs {
|
||||
finished_files!: number;
|
||||
id!: number;
|
||||
user_id!: number;
|
||||
date_created!: string;
|
||||
status!: string;
|
||||
num_files!: number;
|
||||
files_detailed!: Filename[];
|
||||
}
|
||||
|
||||
export class User {
|
||||
id!: number;
|
||||
email!: string;
|
||||
password!: string;
|
||||
}
|
||||
27
src/helpers/env.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
export const ACCOUNT_REGISTRATION =
|
||||
process.env.ACCOUNT_REGISTRATION?.toLowerCase() === "true" || false;
|
||||
|
||||
export const HTTP_ALLOWED = process.env.HTTP_ALLOWED?.toLowerCase() === "true" || false;
|
||||
|
||||
export const ALLOW_UNAUTHENTICATED =
|
||||
process.env.ALLOW_UNAUTHENTICATED?.toLowerCase() === "true" || false;
|
||||
|
||||
export const AUTO_DELETE_EVERY_N_HOURS = process.env.AUTO_DELETE_EVERY_N_HOURS
|
||||
? Number(process.env.AUTO_DELETE_EVERY_N_HOURS)
|
||||
: 24;
|
||||
|
||||
export const HIDE_HISTORY = process.env.HIDE_HISTORY?.toLowerCase() === "true" || false;
|
||||
|
||||
export const WEBROOT = process.env.WEBROOT ?? "";
|
||||
|
||||
export const LANGUAGE = process.env.LANGUAGE?.toLowerCase() || "en";
|
||||
|
||||
export const MAX_CONVERT_PROCESS =
|
||||
process.env.MAX_CONVERT_PROCESS && Number(process.env.MAX_CONVERT_PROCESS) > 0
|
||||
? Number(process.env.MAX_CONVERT_PROCESS)
|
||||
: 0;
|
||||
|
||||
export const UNAUTHENTICATED_USER_SHARING =
|
||||
process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false;
|
||||
|
||||
export const TIMEZONE = process.env.TZ || undefined;
|
||||
|
|
@ -1,37 +1,55 @@
|
|||
export const normalizeFiletype = (filetype: string): string => {
|
||||
const lowercaseFiletype = filetype.toLowerCase();
|
||||
|
||||
switch (lowercaseFiletype) {
|
||||
case "jfif":
|
||||
case "jpg":
|
||||
return "jpeg";
|
||||
case "htm":
|
||||
return "html";
|
||||
case "tex":
|
||||
return "latex";
|
||||
case "md":
|
||||
return "markdown";
|
||||
case "unknown":
|
||||
return "m4a";
|
||||
default:
|
||||
return lowercaseFiletype;
|
||||
}
|
||||
};
|
||||
|
||||
export const normalizeOutputFiletype = (filetype: string): string => {
|
||||
const lowercaseFiletype = filetype.toLowerCase();
|
||||
|
||||
switch (lowercaseFiletype) {
|
||||
case "jpeg":
|
||||
return "jpg";
|
||||
case "latex":
|
||||
return "tex";
|
||||
case "markdown_phpextra":
|
||||
case "markdown_strict":
|
||||
case "markdown_mmd":
|
||||
case "markdown":
|
||||
return "md";
|
||||
default:
|
||||
return lowercaseFiletype;
|
||||
}
|
||||
};
|
||||
export const normalizeFiletype = (filetype: string): string => {
|
||||
const lowercaseFiletype = filetype.toLowerCase();
|
||||
|
||||
switch (lowercaseFiletype) {
|
||||
case "jfif":
|
||||
case "jpg":
|
||||
return "jpeg";
|
||||
case "htm":
|
||||
return "html";
|
||||
case "tex":
|
||||
return "latex";
|
||||
case "md":
|
||||
return "markdown";
|
||||
case "unknown":
|
||||
return "m4a";
|
||||
default:
|
||||
return lowercaseFiletype;
|
||||
}
|
||||
};
|
||||
|
||||
export const normalizeOutputFiletype = (filetype: string): string => {
|
||||
const lowercaseFiletype = filetype.toLowerCase();
|
||||
|
||||
switch (lowercaseFiletype) {
|
||||
case "jpeg":
|
||||
return "jpg";
|
||||
case "latex":
|
||||
return "tex";
|
||||
case "markdown_phpextra":
|
||||
case "markdown_strict":
|
||||
case "markdown_mmd":
|
||||
case "markdown":
|
||||
return "md";
|
||||
// assimp format ids that aren't real file extensions — map to the
|
||||
// canonical extension for the underlying format so the output file
|
||||
// opens in third-party viewers. The format id is still passed to
|
||||
// `assimp export -f<id>` so the right encoding/variant is produced.
|
||||
case "glb2":
|
||||
return "glb";
|
||||
case "gltf2":
|
||||
return "gltf";
|
||||
case "objnomtl":
|
||||
return "obj";
|
||||
case "stlb":
|
||||
return "stl";
|
||||
case "plyb":
|
||||
return "ply";
|
||||
case "fbxa":
|
||||
return "fbx";
|
||||
case "assjson":
|
||||
return "json";
|
||||
default:
|
||||
return lowercaseFiletype;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { exec } from "node:child_process";
|
||||
import { readFile } from "node:fs";
|
||||
import { version } from "../../package.json";
|
||||
|
||||
console.log(`ConvertX v${version}`);
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
exec("cat /etc/os-release", (error, stdout) => {
|
||||
readFile("/etc/os-release", "utf8", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Not running on docker, this is not supported.");
|
||||
}
|
||||
|
|
@ -44,6 +45,16 @@ if (process.env.NODE_ENV === "production") {
|
|||
}
|
||||
});
|
||||
|
||||
exec("magick --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("ImageMagick is not installed.");
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(stdout.split("\n")[0]?.replace("Version: ", ""));
|
||||
}
|
||||
});
|
||||
|
||||
exec("gm version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("GraphicsMagick is not installed.");
|
||||
|
|
@ -74,6 +85,16 @@ if (process.env.NODE_ENV === "production") {
|
|||
}
|
||||
});
|
||||
|
||||
exec("dasel --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("dasel is not installed.");
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(stdout.split("\n")[0]);
|
||||
}
|
||||
});
|
||||
|
||||
exec("xelatex -version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Tex Live with XeTeX is not installed.");
|
||||
|
|
@ -134,6 +155,26 @@ if (process.env.NODE_ENV === "production") {
|
|||
}
|
||||
});
|
||||
|
||||
exec("soffice --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("libreoffice is not installed");
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(stdout.split("\n")[0]);
|
||||
}
|
||||
});
|
||||
|
||||
exec("msgconvert --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("msgconvert (libemail-outlook-message-perl) is not installed");
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(stdout.split("\n")[0]);
|
||||
}
|
||||
});
|
||||
|
||||
exec("bun -v", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Bun is not installed. wait what");
|
||||
|
|
|
|||
18
src/icons/delete.tsx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
export function DeleteIcon() {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
strokeWidth="1.5"
|
||||
stroke="currentColor"
|
||||
class={`size-6`}
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
18
src/icons/download.tsx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
export function DownloadIcon() {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
strokeWidth="1.5"
|
||||
stroke="currentColor"
|
||||
class={`size-6`}
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
19
src/icons/eye.tsx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export function EyeIcon() {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
strokeWidth={1.5}
|
||||
stroke="currentColor"
|
||||
class={`size-6`}
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"
|
||||
/>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
1560
src/index.tsx
80
src/main.css
|
|
@ -1,39 +1,22 @@
|
|||
@import "./theme/theme.css";
|
||||
@import "tailwindcss";
|
||||
|
||||
@plugin 'tailwind-scrollbar';
|
||||
@plugin "tailwind-scrollbar";
|
||||
|
||||
@theme {
|
||||
--color-contrast: rgba(var(--contrast));
|
||||
--color-neutral-900: rgba(var(--neutral-900));
|
||||
--color-neutral-800: rgba(var(--neutral-800));
|
||||
--color-neutral-700: rgba(var(--neutral-700));
|
||||
--color-neutral-600: rgba(var(--neutral-600));
|
||||
--color-neutral-500: rgba(var(--neutral-500));
|
||||
--color-neutral-400: rgba(var(--neutral-400));
|
||||
--color-neutral-300: rgba(var(--neutral-300));
|
||||
--color-neutral-200: rgba(var(--neutral-200));
|
||||
--color-neutral-100: rgba(var(--neutral-100));
|
||||
--color-accent-600: rgba(var(--accent-600));
|
||||
--color-accent-500: rgba(var(--accent-500));
|
||||
--color-accent-400: rgba(var(--accent-400));
|
||||
}
|
||||
|
||||
/*
|
||||
The default border color has changed to `currentColor` in Tailwind CSS v4,
|
||||
so we've added these compatibility styles to make sure everything still
|
||||
looks the same as it did with Tailwind CSS v3.
|
||||
|
||||
If we ever want to remove these styles, we need to add an explicit border
|
||||
color utility to any element that depends on these defaults.
|
||||
*/
|
||||
@layer base {
|
||||
*,
|
||||
::after,
|
||||
::before,
|
||||
::backdrop,
|
||||
::file-selector-button {
|
||||
border-color: var(--color-gray-200, currentColor);
|
||||
}
|
||||
--color-contrast: var(--contrast);
|
||||
--color-neutral-900: var(--neutral-900);
|
||||
--color-neutral-800: var(--neutral-800);
|
||||
--color-neutral-700: var(--neutral-700);
|
||||
--color-neutral-600: var(--neutral-600);
|
||||
--color-neutral-500: var(--neutral-500);
|
||||
--color-neutral-400: var(--neutral-400);
|
||||
--color-neutral-300: var(--neutral-300);
|
||||
--color-neutral-200: var(--neutral-200);
|
||||
--color-neutral-100: var(--neutral-100);
|
||||
--color-accent-600: var(--accent-600);
|
||||
--color-accent-500: var(--accent-500);
|
||||
--color-accent-400: var(--accent-400);
|
||||
}
|
||||
|
||||
@utility article {
|
||||
|
|
@ -44,35 +27,6 @@
|
|||
@apply bg-accent-500 text-contrast rounded-sm p-2 sm:p-4 hover:bg-accent-400 cursor-pointer transition-colors;
|
||||
}
|
||||
|
||||
:root {
|
||||
--contrast: 255, 255, 255;
|
||||
--neutral-900: 243, 244, 246;
|
||||
--neutral-800: 229, 231, 235;
|
||||
--neutral-700: 209, 213, 219;
|
||||
--neutral-600: 156, 163, 175;
|
||||
--neutral-500: 180, 180, 180;
|
||||
--neutral-400: 75, 85, 99;
|
||||
--neutral-300: 55, 65, 81;
|
||||
--neutral-200: 31, 41, 55;
|
||||
--neutral-100: 17, 24, 39;
|
||||
--accent-400: 132, 204, 22;
|
||||
--accent-500: 101, 163, 13;
|
||||
--accent-600: 77, 124, 15;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--contrast: 0, 0, 0;
|
||||
--neutral-900: 17, 24, 39;
|
||||
--neutral-800: 31, 41, 55;
|
||||
--neutral-700: 55, 65, 81;
|
||||
--neutral-600: 75, 85, 99;
|
||||
--neutral-500: 107, 114, 128;
|
||||
--neutral-300: 209, 213, 219;
|
||||
--neutral-400: 156, 163, 175;
|
||||
--neutral-200: 229, 231, 235;
|
||||
--accent-600: 101, 163, 13;
|
||||
--accent-500: 132, 204, 22;
|
||||
--accent-400: 163, 230, 53;
|
||||
}
|
||||
@utility btn-secondary {
|
||||
@apply bg-neutral-400 text-contrast rounded-sm p-2 sm:p-4 hover:bg-neutral-300 cursor-pointer transition-colors;
|
||||
}
|
||||
|
|
|
|||
66
src/pages/chooseConverter.tsx
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import Elysia, { t } from "elysia";
|
||||
import { getPossibleTargets } from "../converters/main";
|
||||
import { userService } from "./user";
|
||||
|
||||
export const chooseConverter = new Elysia().use(userService).post(
|
||||
"/conversions",
|
||||
({ body }) => {
|
||||
return (
|
||||
<>
|
||||
<article
|
||||
class={`
|
||||
convert_to_popup absolute z-2 m-0 hidden h-[50vh] max-h-[50vh] w-full flex-col
|
||||
overflow-x-hidden overflow-y-auto rounded-sm bg-neutral-800
|
||||
sm:h-[30vh]
|
||||
`}
|
||||
>
|
||||
{Object.entries(getPossibleTargets(body.fileType)).map(([converter, targets]) => (
|
||||
<article
|
||||
class={`convert_to_group flex w-full flex-col border-b border-neutral-700 p-4`}
|
||||
data-converter={converter}
|
||||
>
|
||||
<header class="mb-2 w-full text-xl font-bold" safe>
|
||||
{converter}
|
||||
</header>
|
||||
<ul class="convert_to_target flex flex-row flex-wrap gap-1">
|
||||
{targets.map((target) => (
|
||||
<button
|
||||
// https://stackoverflow.com/questions/121499/when-a-blur-event-occurs-how-can-i-find-out-which-element-focus-went-to#comment82388679_33325953
|
||||
tabindex={0}
|
||||
class={`
|
||||
target rounded-sm bg-neutral-700 p-1 text-base
|
||||
hover:bg-neutral-600
|
||||
`}
|
||||
data-value={`${target},${converter}`}
|
||||
data-target={target}
|
||||
data-converter={converter}
|
||||
type="button"
|
||||
safe
|
||||
>
|
||||
{target}
|
||||
</button>
|
||||
))}
|
||||
</ul>
|
||||
</article>
|
||||
))}
|
||||
</article>
|
||||
|
||||
<select name="convert_to" aria-label="Convert to" required hidden>
|
||||
<option selected disabled value="">
|
||||
Convert to
|
||||
</option>
|
||||
{Object.entries(getPossibleTargets(body.fileType)).map(([converter, targets]) => (
|
||||
<optgroup label={converter}>
|
||||
{targets.map((target) => (
|
||||
<option value={`${target},${converter}`} safe>
|
||||
{target}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
</>
|
||||
);
|
||||
},
|
||||
{ body: t.Object({ fileType: t.String() }) },
|
||||
);
|
||||
99
src/pages/convert.tsx
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
import { mkdir } from "node:fs/promises";
|
||||
import { Elysia, t } from "elysia";
|
||||
import sanitize from "sanitize-filename";
|
||||
import { outputDir, uploadsDir } from "..";
|
||||
import { handleConvert } from "../converters/main";
|
||||
import db from "../db/db";
|
||||
import { Jobs } from "../db/types";
|
||||
import { WEBROOT } from "../helpers/env";
|
||||
import { normalizeFiletype } from "../helpers/normalizeFiletype";
|
||||
import { userService } from "./user";
|
||||
|
||||
export const convert = new Elysia().use(userService).post(
|
||||
"/convert",
|
||||
async ({ body, redirect, jwt, cookie: { auth, jobId } }) => {
|
||||
if (!auth?.value) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
const user = await jwt.verify(auth.value);
|
||||
if (!user) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
if (!jobId?.value) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
const existingJob = db
|
||||
.query("SELECT * FROM jobs WHERE id = ? AND user_id = ?")
|
||||
.as(Jobs)
|
||||
.get(jobId.value, user.id);
|
||||
|
||||
if (!existingJob) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
const userUploadsDir = `${uploadsDir}${user.id}/${jobId.value}/`;
|
||||
const userOutputDir = `${outputDir}${user.id}/${jobId.value}/`;
|
||||
|
||||
// create the output directory
|
||||
try {
|
||||
await mkdir(userOutputDir, { recursive: true });
|
||||
} catch (error) {
|
||||
console.error(`Failed to create the output directory: ${userOutputDir}.`, error);
|
||||
}
|
||||
|
||||
const convertTo = normalizeFiletype(body.convert_to.split(",")[0] ?? "");
|
||||
const converterName = body.convert_to.split(",")[1];
|
||||
|
||||
if (
|
||||
!converterName ||
|
||||
convertTo.includes("/") ||
|
||||
convertTo.includes("\\") ||
|
||||
convertTo.includes("..")
|
||||
) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
const fileNames = JSON.parse(body.file_names) as string[];
|
||||
|
||||
for (let i = 0; i < fileNames.length; i++) {
|
||||
fileNames[i] = sanitize(fileNames[i] || "");
|
||||
}
|
||||
|
||||
if (!Array.isArray(fileNames) || fileNames.length === 0) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
db.query("UPDATE jobs SET num_files = ?1, status = 'pending' WHERE id = ?2").run(
|
||||
fileNames.length,
|
||||
jobId.value,
|
||||
);
|
||||
|
||||
// Start the conversion process in the background
|
||||
handleConvert(fileNames, userUploadsDir, userOutputDir, convertTo, converterName, jobId)
|
||||
.then(() => {
|
||||
// All conversions are done, update the job status to 'completed'
|
||||
if (jobId.value) {
|
||||
db.query("UPDATE jobs SET status = 'completed' WHERE id = ?1").run(jobId.value);
|
||||
}
|
||||
|
||||
// Delete all uploaded files in userUploadsDir
|
||||
// rmSync(userUploadsDir, { recursive: true, force: true });
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error in conversion process:", error);
|
||||
});
|
||||
|
||||
// Redirect the client immediately
|
||||
return redirect(`${WEBROOT}/results/${jobId.value}`, 302);
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
convert_to: t.String(),
|
||||
file_names: t.String(),
|
||||
}),
|
||||
auth: true,
|
||||
},
|
||||
);
|
||||
37
src/pages/deleteFile.tsx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { unlink } from "node:fs/promises";
|
||||
import { Elysia, t } from "elysia";
|
||||
import { uploadsDir } from "..";
|
||||
import db from "../db/db";
|
||||
import { WEBROOT } from "../helpers/env";
|
||||
import { userService } from "./user";
|
||||
import sanitize from "sanitize-filename";
|
||||
import path from "node:path";
|
||||
|
||||
export const deleteFile = new Elysia().use(userService).post(
|
||||
"/delete",
|
||||
async ({ body, redirect, cookie: { jobId }, user }) => {
|
||||
if (!jobId?.value) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
const existingJob = await db
|
||||
.query("SELECT * FROM jobs WHERE id = ? AND user_id = ?")
|
||||
.get(jobId.value, user.id);
|
||||
|
||||
if (!existingJob) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
const userUploadsDir = path.join(uploadsDir, user.id, jobId.value);
|
||||
|
||||
const sanitized = sanitize(body.filename);
|
||||
const targetPath = path.join(userUploadsDir, sanitized);
|
||||
|
||||
await unlink(targetPath);
|
||||
|
||||
return {
|
||||
message: "File deleted successfully.",
|
||||
};
|
||||
},
|
||||
{ body: t.Object({ filename: t.String() }), auth: true },
|
||||
);
|
||||
117
src/pages/deleteJob.tsx
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
import { rmSync } from "node:fs";
|
||||
import { Elysia, t } from "elysia";
|
||||
import { outputDir, uploadsDir } from "..";
|
||||
import db from "../db/db";
|
||||
import { WEBROOT } from "../helpers/env";
|
||||
import { userService } from "./user";
|
||||
import { Jobs } from "../db/types";
|
||||
|
||||
export const deleteJob = new Elysia()
|
||||
.use(userService)
|
||||
// SECURE: Use POST instead of GET for state-changing actions to prevent CSRF.
|
||||
// Browsers automatically follow GET links, which can lead to silent data deletion.
|
||||
.post(
|
||||
"/delete/:jobId",
|
||||
async ({ params, redirect, user }) => {
|
||||
const job = db
|
||||
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
||||
.as(Jobs)
|
||||
.get(user.id, params.jobId);
|
||||
|
||||
if (!job) {
|
||||
return redirect(`${WEBROOT}/results`, 302);
|
||||
}
|
||||
|
||||
// delete the directories
|
||||
rmSync(`${outputDir}${job.user_id}/${job.id}`, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
rmSync(`${uploadsDir}${job.user_id}/${job.id}`, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
|
||||
// delete the job
|
||||
db.query("DELETE FROM jobs WHERE id = ?").run(job.id);
|
||||
return redirect(`${WEBROOT}/history`, 302);
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
},
|
||||
)
|
||||
.post(
|
||||
"/delete-multiple",
|
||||
async ({ body, user, set }) => {
|
||||
const { jobIds } = body;
|
||||
|
||||
if (!Array.isArray(jobIds) || jobIds.length === 0) {
|
||||
set.status = 400;
|
||||
return { success: false, message: "Invalid job IDs provided" };
|
||||
}
|
||||
|
||||
const results = {
|
||||
success: [] as string[],
|
||||
failed: [] as { jobId: string; error: string }[],
|
||||
};
|
||||
|
||||
// Process deletions sequentially for safety
|
||||
for (const jobId of jobIds) {
|
||||
try {
|
||||
const job = db
|
||||
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
||||
.as(Jobs)
|
||||
.get(user.id, jobId);
|
||||
|
||||
if (!job) {
|
||||
results.failed.push({
|
||||
jobId,
|
||||
error: "Job not found or unauthorized",
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// Delete the directories
|
||||
try {
|
||||
rmSync(`${outputDir}${job.user_id}/${job.id}`, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Failed to delete output directory for job ${jobId}:`, error);
|
||||
}
|
||||
|
||||
try {
|
||||
rmSync(`${uploadsDir}${job.user_id}/${job.id}`, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Failed to delete uploads directory for job ${jobId}:`, error);
|
||||
}
|
||||
|
||||
// Delete the job from database
|
||||
db.query("DELETE FROM jobs WHERE id = ?").run(job.id);
|
||||
results.success.push(jobId);
|
||||
} catch (error) {
|
||||
results.failed.push({
|
||||
jobId,
|
||||
error: error instanceof Error ? error.message : "Unknown error",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: results.failed.length === 0,
|
||||
deleted: results.success.length,
|
||||
failed: results.failed.length,
|
||||
details: results,
|
||||
};
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
body: t.Object({
|
||||
jobIds: t.Array(t.String(), { maxItems: 100 }),
|
||||
}),
|
||||
},
|
||||
);
|
||||
65
src/pages/download.tsx
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import path from "node:path";
|
||||
import { Elysia } from "elysia";
|
||||
import sanitize from "sanitize-filename";
|
||||
import * as tar from "tar";
|
||||
import { outputDir } from "..";
|
||||
import db from "../db/db";
|
||||
import { WEBROOT } from "../helpers/env";
|
||||
import { userService } from "./user";
|
||||
|
||||
export const download = new Elysia()
|
||||
.use(userService)
|
||||
.get(
|
||||
"/download/:userId/:jobId/:fileName",
|
||||
async ({ params, redirect, user }) => {
|
||||
const userId = user.id;
|
||||
const job = await db
|
||||
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
||||
.get(user.id, params.jobId);
|
||||
|
||||
if (!job) {
|
||||
return redirect(`${WEBROOT}/results`, 302);
|
||||
}
|
||||
// parse from URL encoded string
|
||||
const jobId = decodeURIComponent(params.jobId);
|
||||
const fileName = sanitize(decodeURIComponent(params.fileName));
|
||||
|
||||
const filePath = `${outputDir}${userId}/${jobId}/${fileName}`;
|
||||
return Bun.file(filePath);
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
},
|
||||
)
|
||||
.get(
|
||||
"/archive/:jobId",
|
||||
async ({ params, redirect, user }) => {
|
||||
const userId = user.id;
|
||||
const job = await db
|
||||
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
||||
.get(user.id, params.jobId);
|
||||
|
||||
if (!job) {
|
||||
return redirect(`${WEBROOT}/results`, 302);
|
||||
}
|
||||
|
||||
const jobId = decodeURIComponent(params.jobId);
|
||||
const outputPath = `${outputDir}${userId}/${jobId}`;
|
||||
const outputTar = path.join(outputPath, `converted_files_${jobId}.tar`);
|
||||
|
||||
await tar.create(
|
||||
{
|
||||
file: outputTar,
|
||||
cwd: outputPath,
|
||||
filter: (path) => {
|
||||
return !path.match(".*\\.tar");
|
||||
},
|
||||
},
|
||||
["."],
|
||||
);
|
||||
return Bun.file(outputTar);
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
},
|
||||
);
|
||||
12
src/pages/healthcheck.tsx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import Elysia from "elysia";
|
||||
import { userService } from "./user";
|
||||
|
||||
export const healthcheck = new Elysia().use(userService).get(
|
||||
"/healthcheck",
|
||||
() => {
|
||||
return { status: "ok" };
|
||||
},
|
||||
{
|
||||
auth: false,
|
||||
},
|
||||
);
|
||||
340
src/pages/history.tsx
Normal file
|
|
@ -0,0 +1,340 @@
|
|||
import { Elysia } from "elysia";
|
||||
import { BaseHtml } from "../components/base";
|
||||
import { Header } from "../components/header";
|
||||
import db from "../db/db";
|
||||
import { Filename, Jobs } from "../db/types";
|
||||
import { ALLOW_UNAUTHENTICATED, HIDE_HISTORY, LANGUAGE, TIMEZONE, WEBROOT } from "../helpers/env";
|
||||
import { userService } from "./user";
|
||||
import { EyeIcon } from "../icons/eye";
|
||||
import { DeleteIcon } from "../icons/delete";
|
||||
|
||||
export const history = new Elysia().use(userService).get(
|
||||
"/history",
|
||||
async ({ redirect, user }) => {
|
||||
if (HIDE_HISTORY) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
let userJobs = db.query("SELECT * FROM jobs WHERE user_id = ?").as(Jobs).all(user.id).reverse();
|
||||
|
||||
for (const job of userJobs) {
|
||||
const files = db.query("SELECT * FROM file_names WHERE job_id = ?").as(Filename).all(job.id);
|
||||
|
||||
job.finished_files = files.length;
|
||||
job.files_detailed = files;
|
||||
}
|
||||
|
||||
// Filter out jobs with no files
|
||||
userJobs = userJobs.filter((job) => job.num_files > 0);
|
||||
|
||||
return (
|
||||
<BaseHtml webroot={WEBROOT} title="ConvertX | Results">
|
||||
<>
|
||||
<Header
|
||||
webroot={WEBROOT}
|
||||
allowUnauthenticated={ALLOW_UNAUTHENTICATED}
|
||||
hideHistory={HIDE_HISTORY}
|
||||
loggedIn
|
||||
/>
|
||||
<main
|
||||
class={`
|
||||
w-full flex-1 px-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<article class="article">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h1 class="text-xl">Results</h1>
|
||||
<div id="delete-selected-container">
|
||||
<button
|
||||
id="delete-selected-btn"
|
||||
class={`
|
||||
flex btn-secondary flex-row gap-2 text-contrast
|
||||
disabled:cursor-not-allowed disabled:opacity-50
|
||||
`}
|
||||
disabled
|
||||
>
|
||||
<DeleteIcon />{" "}
|
||||
<span>
|
||||
Delete Selected (<span id="selected-count">0</span>)
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<table
|
||||
class={`
|
||||
w-full table-auto overflow-y-auto rounded-sm bg-neutral-900 text-left
|
||||
[&_td]:p-4
|
||||
[&_tr]:rounded-sm [&_tr]:border-b [&_tr]:border-neutral-800
|
||||
`}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="select-all"
|
||||
class="size-4 cursor-pointer"
|
||||
title="Select all"
|
||||
/>
|
||||
</th>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<span class="sr-only">Expand details</span>
|
||||
</th>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
Time
|
||||
</th>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
Files
|
||||
</th>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
max-sm:hidden
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
Files Done
|
||||
</th>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
Status
|
||||
</th>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{userJobs.map((job) => (
|
||||
<>
|
||||
<tr id={`job-row-${job.id}`}>
|
||||
<td>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="size-4 cursor-pointer"
|
||||
data-checkbox-type="job"
|
||||
data-job-id={job.id}
|
||||
/>
|
||||
</td>
|
||||
<td class="job-details-toggle cursor-pointer" data-job-id={job.id}>
|
||||
<svg
|
||||
id={`arrow-${job.id}`}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
class="inline-block size-4"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M8.25 4.5l7.5 7.5-7.5 7.5"
|
||||
/>
|
||||
</svg>
|
||||
</td>
|
||||
<td safe>
|
||||
{new Date(job.date_created).toLocaleTimeString(LANGUAGE, {
|
||||
timeZone: TIMEZONE,
|
||||
})}
|
||||
</td>
|
||||
<td>{job.num_files}</td>
|
||||
<td class="max-sm:hidden">{job.finished_files}</td>
|
||||
<td safe>{job.status}</td>
|
||||
<td class="flex flex-row gap-4">
|
||||
<a
|
||||
class={`
|
||||
text-accent-500 underline
|
||||
hover:text-accent-400
|
||||
`}
|
||||
href={`${WEBROOT}/results/${job.id}`}
|
||||
>
|
||||
<EyeIcon />
|
||||
</a>
|
||||
<form action={`${WEBROOT}/delete/${job.id}`} method="POST" class="inline">
|
||||
<button
|
||||
type="submit"
|
||||
class={`
|
||||
text-accent-500 underline
|
||||
hover:text-accent-400
|
||||
`}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id={`details-${job.id}`} class="hidden">
|
||||
<td colspan="7">
|
||||
<div class="p-2 text-sm text-neutral-500">
|
||||
<div class="mb-1 font-semibold">Detailed File Information:</div>
|
||||
{job.files_detailed.map((file: Filename) => (
|
||||
<div class="flex items-center">
|
||||
<span class="w-5/12 truncate" title={file.file_name} safe>
|
||||
{file.file_name}
|
||||
</span>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
class={`mx-2 inline-block size-4 text-neutral-500`}
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<span class="w-5/12 truncate" title={file.output_file_name} safe>
|
||||
{file.output_file_name}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
</main>
|
||||
<script>
|
||||
{`
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Expand/collapse job details
|
||||
const toggles = document.querySelectorAll('.job-details-toggle');
|
||||
toggles.forEach(toggle => {
|
||||
toggle.addEventListener('click', function() {
|
||||
const jobId = this.dataset.jobId;
|
||||
const detailsRow = document.getElementById(\`details-\${jobId}\`);
|
||||
const arrow = document.getElementById(\`arrow-\${jobId}\`);
|
||||
|
||||
if (detailsRow && arrow) {
|
||||
detailsRow.classList.toggle("hidden");
|
||||
if (detailsRow.classList.contains("hidden")) {
|
||||
arrow.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />';
|
||||
} else {
|
||||
arrow.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Checkbox management
|
||||
const selectAllCheckbox = document.getElementById('select-all');
|
||||
const jobCheckboxes = document.querySelectorAll('[data-checkbox-type="job"]');
|
||||
const deleteSelectedBtn = document.getElementById('delete-selected-btn');
|
||||
const deleteSelectedContainer = document.getElementById('delete-selected-container');
|
||||
const selectedCountSpan = document.getElementById('selected-count');
|
||||
|
||||
function updateDeleteButton() {
|
||||
const checkedBoxes = Array.from(jobCheckboxes).filter(cb => cb.checked);
|
||||
if (checkedBoxes.length > 0) {
|
||||
deleteSelectedBtn.disabled = false;
|
||||
selectedCountSpan.textContent = checkedBoxes.length;
|
||||
} else {
|
||||
deleteSelectedBtn.disabled = true;
|
||||
selectedCountSpan.textContent = '0';
|
||||
}
|
||||
}
|
||||
|
||||
selectAllCheckbox?.addEventListener('change', function() {
|
||||
jobCheckboxes.forEach(checkbox => {
|
||||
checkbox.checked = this.checked;
|
||||
});
|
||||
updateDeleteButton();
|
||||
});
|
||||
|
||||
jobCheckboxes.forEach(checkbox => {
|
||||
checkbox.addEventListener('change', function() {
|
||||
const allChecked = Array.from(jobCheckboxes).every(cb => cb.checked);
|
||||
const someChecked = Array.from(jobCheckboxes).some(cb => cb.checked);
|
||||
if (selectAllCheckbox) {
|
||||
selectAllCheckbox.checked = allChecked;
|
||||
selectAllCheckbox.indeterminate = someChecked && !allChecked;
|
||||
}
|
||||
updateDeleteButton();
|
||||
});
|
||||
});
|
||||
|
||||
deleteSelectedBtn?.addEventListener('click', async function() {
|
||||
const checkedBoxes = Array.from(jobCheckboxes).filter(cb => cb.checked);
|
||||
const jobIds = checkedBoxes.map(cb => cb.dataset.jobId);
|
||||
|
||||
if (jobIds.length === 0) return;
|
||||
|
||||
const confirmed = confirm(\`Are you sure you want to delete \${jobIds.length} job(s)? This action cannot be undone.\`);
|
||||
if (!confirmed) return;
|
||||
|
||||
try {
|
||||
const response = await fetch('${WEBROOT}/delete-multiple', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ jobIds }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(\`HTTP error! status: \${response.status}\`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success || result.deleted > 0) {
|
||||
alert(\`Successfully deleted \${result.deleted} job(s).\${result.failed > 0 ? \` Failed to delete \${result.failed} job(s).\` : ''}\`);
|
||||
window.location.reload();
|
||||
} else {
|
||||
alert('Failed to delete jobs. Please try again.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error deleting jobs:', error);
|
||||
alert('An error occurred while deleting jobs. Please try again.');
|
||||
}
|
||||
});
|
||||
});
|
||||
`}
|
||||
</script>
|
||||
</>
|
||||
</BaseHtml>
|
||||
);
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
},
|
||||
);
|
||||
74
src/pages/listConverters.tsx
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import Elysia from "elysia";
|
||||
import { BaseHtml } from "../components/base";
|
||||
import { Header } from "../components/header";
|
||||
import { getAllInputs, getAllTargets } from "../converters/main";
|
||||
import { ALLOW_UNAUTHENTICATED, WEBROOT } from "../helpers/env";
|
||||
import { userService } from "./user";
|
||||
|
||||
export const listConverters = new Elysia().use(userService).get(
|
||||
"/converters",
|
||||
async () => {
|
||||
return (
|
||||
<BaseHtml webroot={WEBROOT} title="ConvertX | Converters">
|
||||
<>
|
||||
<Header webroot={WEBROOT} allowUnauthenticated={ALLOW_UNAUTHENTICATED} loggedIn />
|
||||
<main
|
||||
class={`
|
||||
w-full flex-1 px-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<article class="article">
|
||||
<h1 class="mb-4 text-xl">Converters</h1>
|
||||
<table
|
||||
class={`
|
||||
w-full table-auto rounded-sm bg-neutral-900 text-left
|
||||
[&_td]:p-4
|
||||
[&_tr]:rounded-sm [&_tr]:border-b [&_tr]:border-neutral-800
|
||||
[&_ul]:list-inside [&_ul]:list-disc
|
||||
`}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="mx-4 my-2">Converter</th>
|
||||
<th class="mx-4 my-2">From (Count)</th>
|
||||
<th class="mx-4 my-2">To (Count)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Object.entries(getAllTargets()).map(([converter, targets]) => {
|
||||
const inputs = getAllInputs(converter);
|
||||
return (
|
||||
<tr>
|
||||
<td safe>{converter}</td>
|
||||
<td>
|
||||
Count: {inputs.length}
|
||||
<ul>
|
||||
{inputs.map((input) => (
|
||||
<li safe>{input}</li>
|
||||
))}
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
Count: {targets.length}
|
||||
<ul>
|
||||
{targets.map((target) => (
|
||||
<li safe>{target}</li>
|
||||
))}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
</main>
|
||||
</>
|
||||
</BaseHtml>
|
||||
);
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
},
|
||||
);
|
||||
211
src/pages/results.tsx
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
import { Elysia } from "elysia";
|
||||
import { BaseHtml } from "../components/base";
|
||||
import { Header } from "../components/header";
|
||||
import db from "../db/db";
|
||||
import { Filename, Jobs } from "../db/types";
|
||||
import { ALLOW_UNAUTHENTICATED, WEBROOT } from "../helpers/env";
|
||||
import { DownloadIcon } from "../icons/download";
|
||||
import { DeleteIcon } from "../icons/delete";
|
||||
import { EyeIcon } from "../icons/eye";
|
||||
import { userService } from "./user";
|
||||
|
||||
function ResultsArticle({
|
||||
job,
|
||||
files,
|
||||
outputPath,
|
||||
}: {
|
||||
job: Jobs;
|
||||
files: Filename[];
|
||||
outputPath: string;
|
||||
}) {
|
||||
return (
|
||||
<article class="article">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h1 class="text-xl">Results</h1>
|
||||
<div class="flex flex-row gap-4">
|
||||
<form action={`${WEBROOT}/delete/${job.id}`} method="POST">
|
||||
<button
|
||||
type="submit"
|
||||
style={files.length !== job.num_files ? "pointer-events: none;" : ""}
|
||||
class="flex btn-secondary flex-row gap-2 text-contrast"
|
||||
{...(files.length !== job.num_files ? { disabled: true, "aria-busy": "true" } : "")}
|
||||
>
|
||||
<DeleteIcon /> <p>Delete</p>
|
||||
</button>
|
||||
</form>
|
||||
<a
|
||||
style={files.length !== job.num_files ? "pointer-events: none;" : ""}
|
||||
href={`${WEBROOT}/archive/${job.id}`}
|
||||
download={`converted_files_${job.id}.tar`}
|
||||
class="flex btn-primary flex-row gap-2 text-contrast"
|
||||
{...(files.length !== job.num_files ? { disabled: true, "aria-busy": "true" } : "")}
|
||||
>
|
||||
<DownloadIcon /> <p>Tar</p>
|
||||
</a>
|
||||
<button class="flex btn-primary flex-row gap-2 text-contrast" onclick="downloadAll()">
|
||||
<DownloadIcon /> <p>All</p>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<progress
|
||||
max={job.num_files}
|
||||
{...(files.length === job.num_files ? { value: files.length } : "")}
|
||||
class={`
|
||||
mb-4 inline-block h-2 w-full appearance-none overflow-hidden rounded-full border-0
|
||||
bg-neutral-700 bg-none text-accent-500 accent-accent-500
|
||||
[&::-moz-progress-bar]:bg-accent-500
|
||||
[&::-webkit-progress-value]:rounded-full [&::-webkit-progress-value]:[background:none]
|
||||
[&[value]::-webkit-progress-value]:bg-accent-500
|
||||
[&[value]::-webkit-progress-value]:transition-[inline-size]
|
||||
`}
|
||||
/>
|
||||
<table
|
||||
class={`
|
||||
w-full table-auto rounded-sm bg-neutral-900 text-left
|
||||
[&_td]:p-4
|
||||
[&_tr]:rounded-sm [&_tr]:border-b [&_tr]:border-neutral-800
|
||||
`}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
Converted File Name
|
||||
</th>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
Status
|
||||
</th>
|
||||
<th
|
||||
class={`
|
||||
p-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{files.map((file) => (
|
||||
<tr>
|
||||
<td safe class="max-w-[20vw] truncate">
|
||||
{file.output_file_name}
|
||||
</td>
|
||||
<td safe>{file.status}</td>
|
||||
<td class="flex flex-row gap-4">
|
||||
<a
|
||||
class={`
|
||||
text-accent-500 underline
|
||||
hover:text-accent-400
|
||||
`}
|
||||
href={`${WEBROOT}/download/${outputPath}${file.output_file_name}`}
|
||||
>
|
||||
<EyeIcon />
|
||||
</a>
|
||||
<a
|
||||
class={`
|
||||
text-accent-500 underline
|
||||
hover:text-accent-400
|
||||
`}
|
||||
href={`${WEBROOT}/download/${outputPath}${file.output_file_name}`}
|
||||
download={file.output_file_name}
|
||||
>
|
||||
<DownloadIcon />
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
export const results = new Elysia()
|
||||
.use(userService)
|
||||
.get(
|
||||
"/results/:jobId",
|
||||
async ({ params, set, cookie: { job_id }, user }) => {
|
||||
if (job_id?.value) {
|
||||
// Clear the job_id cookie since we are viewing the results
|
||||
job_id.remove();
|
||||
}
|
||||
|
||||
const job = db
|
||||
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
||||
.as(Jobs)
|
||||
.get(user.id, params.jobId);
|
||||
|
||||
if (!job) {
|
||||
set.status = 404;
|
||||
return {
|
||||
message: "Job not found.",
|
||||
};
|
||||
}
|
||||
|
||||
const outputPath = `${user.id}/${params.jobId}/`;
|
||||
|
||||
const files = db
|
||||
.query("SELECT * FROM file_names WHERE job_id = ?")
|
||||
.as(Filename)
|
||||
.all(params.jobId);
|
||||
|
||||
return (
|
||||
<BaseHtml webroot={WEBROOT} title="ConvertX | Result">
|
||||
<>
|
||||
<Header webroot={WEBROOT} allowUnauthenticated={ALLOW_UNAUTHENTICATED} loggedIn />
|
||||
<main
|
||||
class={`
|
||||
w-full flex-1 px-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<ResultsArticle job={job} files={files} outputPath={outputPath} />
|
||||
</main>
|
||||
<script src={`${WEBROOT}/results.js`} defer />
|
||||
</>
|
||||
</BaseHtml>
|
||||
);
|
||||
},
|
||||
{ auth: true },
|
||||
)
|
||||
.post(
|
||||
"/progress/:jobId",
|
||||
async ({ set, params, cookie: { job_id }, user }) => {
|
||||
if (job_id?.value) {
|
||||
// Clear the job_id cookie since we are viewing the results
|
||||
job_id.remove();
|
||||
}
|
||||
|
||||
const job = db
|
||||
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
||||
.as(Jobs)
|
||||
.get(user.id, params.jobId);
|
||||
|
||||
if (!job) {
|
||||
set.status = 404;
|
||||
return {
|
||||
message: "Job not found.",
|
||||
};
|
||||
}
|
||||
|
||||
const outputPath = `${user.id}/${params.jobId}/`;
|
||||
|
||||
const files = db
|
||||
.query("SELECT * FROM file_names WHERE job_id = ?")
|
||||
.as(Filename)
|
||||
.all(params.jobId);
|
||||
|
||||
return <ResultsArticle job={job} files={files} outputPath={outputPath} />;
|
||||
},
|
||||
{ auth: true },
|
||||
);
|
||||
250
src/pages/root.tsx
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
import { randomInt } from "node:crypto";
|
||||
import { JWTPayloadSpec } from "@elysiajs/jwt";
|
||||
import { Elysia, t } from "elysia";
|
||||
import { BaseHtml } from "../components/base";
|
||||
import { Header } from "../components/header";
|
||||
import { getAllTargets } from "../converters/main";
|
||||
import db from "../db/db";
|
||||
import { User } from "../db/types";
|
||||
import {
|
||||
ACCOUNT_REGISTRATION,
|
||||
ALLOW_UNAUTHENTICATED,
|
||||
HIDE_HISTORY,
|
||||
HTTP_ALLOWED,
|
||||
UNAUTHENTICATED_USER_SHARING,
|
||||
WEBROOT,
|
||||
} from "../helpers/env";
|
||||
import { FIRST_RUN, userService } from "./user";
|
||||
|
||||
export const root = new Elysia().use(userService).get(
|
||||
"/",
|
||||
async ({ jwt, redirect, cookie: { auth, jobId } }) => {
|
||||
if (!ALLOW_UNAUTHENTICATED) {
|
||||
if (FIRST_RUN) {
|
||||
return redirect(`${WEBROOT}/setup`, 302);
|
||||
}
|
||||
|
||||
if (!auth?.value) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
}
|
||||
|
||||
// validate jwt
|
||||
let user: ({ id: string } & JWTPayloadSpec) | false = false;
|
||||
if (ALLOW_UNAUTHENTICATED) {
|
||||
const newUserId = String(
|
||||
UNAUTHENTICATED_USER_SHARING
|
||||
? 0
|
||||
: randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)),
|
||||
);
|
||||
const accessToken = await jwt.sign({
|
||||
id: newUserId,
|
||||
});
|
||||
|
||||
user = { id: newUserId };
|
||||
if (!auth) {
|
||||
return {
|
||||
message: "No auth cookie, perhaps your browser is blocking cookies.",
|
||||
};
|
||||
}
|
||||
|
||||
// set cookie
|
||||
auth.set({
|
||||
value: accessToken,
|
||||
httpOnly: true,
|
||||
secure: !HTTP_ALLOWED,
|
||||
maxAge: 24 * 60 * 60,
|
||||
sameSite: "strict",
|
||||
});
|
||||
} else if (auth?.value) {
|
||||
user = await jwt.verify(auth.value);
|
||||
|
||||
if (
|
||||
user !== false &&
|
||||
user.id &&
|
||||
(Number.parseInt(user.id) < 2 ** 24 || !ALLOW_UNAUTHENTICATED)
|
||||
) {
|
||||
// Make sure user exists in db
|
||||
const existingUser = db.query("SELECT * FROM users WHERE id = ?").as(User).get(user.id);
|
||||
|
||||
if (!existingUser) {
|
||||
if (auth?.value) {
|
||||
auth.remove();
|
||||
}
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
// create a new job
|
||||
db.query("INSERT INTO jobs (user_id, date_created) VALUES (?, ?)").run(
|
||||
user.id,
|
||||
new Date().toISOString(),
|
||||
);
|
||||
|
||||
const { id } = db
|
||||
.query("SELECT id FROM jobs WHERE user_id = ? ORDER BY id DESC")
|
||||
.get(user.id) as { id: number };
|
||||
|
||||
if (!jobId) {
|
||||
return { message: "Cookies should be enabled to use this app." };
|
||||
}
|
||||
|
||||
jobId.set({
|
||||
value: id,
|
||||
httpOnly: true,
|
||||
secure: !HTTP_ALLOWED,
|
||||
maxAge: 24 * 60 * 60,
|
||||
sameSite: "strict",
|
||||
});
|
||||
|
||||
console.log("jobId set to:", id);
|
||||
|
||||
return (
|
||||
<BaseHtml webroot={WEBROOT}>
|
||||
<>
|
||||
<Header
|
||||
webroot={WEBROOT}
|
||||
accountRegistration={ACCOUNT_REGISTRATION}
|
||||
allowUnauthenticated={ALLOW_UNAUTHENTICATED}
|
||||
hideHistory={HIDE_HISTORY}
|
||||
loggedIn
|
||||
/>
|
||||
<main
|
||||
class={`
|
||||
w-full flex-1 px-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<article class="article">
|
||||
<h1 class="mb-4 text-xl">Convert</h1>
|
||||
<div class="mb-4 scrollbar-thin max-h-[50vh] overflow-y-auto">
|
||||
<table
|
||||
id="file-list"
|
||||
class={`
|
||||
w-full table-auto rounded-sm bg-neutral-900
|
||||
[&_td]:p-4
|
||||
[&_td]:first:max-w-[30vw] [&_td]:first:truncate
|
||||
[&_tr]:rounded-sm [&_tr]:border-b [&_tr]:border-neutral-800
|
||||
`}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
id="dropzone"
|
||||
class={`
|
||||
relative flex h-48 w-full items-center justify-center rounded-sm border
|
||||
border-dashed border-neutral-700 transition-all
|
||||
hover:border-neutral-600
|
||||
[&.dragover]:border-4 [&.dragover]:border-neutral-500
|
||||
`}
|
||||
>
|
||||
<span>
|
||||
<b>Choose a file</b> or drag it here
|
||||
</span>
|
||||
<input
|
||||
type="file"
|
||||
name="file"
|
||||
multiple
|
||||
class="absolute inset-0 size-full cursor-pointer opacity-0"
|
||||
/>
|
||||
</div>
|
||||
</article>
|
||||
<form
|
||||
method="post"
|
||||
action={`${WEBROOT}/convert`}
|
||||
class="relative mx-auto mb-[35vh] w-full max-w-4xl"
|
||||
>
|
||||
<input type="hidden" name="file_names" id="file_names" />
|
||||
<article class="article w-full">
|
||||
<input
|
||||
type="search"
|
||||
name="convert_to_search"
|
||||
placeholder="Search for conversions"
|
||||
autocomplete="off"
|
||||
class="w-full rounded-sm bg-neutral-800 p-4"
|
||||
/>
|
||||
<div class="select_container relative">
|
||||
<article
|
||||
class={`
|
||||
convert_to_popup absolute z-2 m-0 hidden h-[30vh] max-h-[50vh] w-full flex-col
|
||||
overflow-x-hidden overflow-y-auto rounded-sm bg-neutral-800
|
||||
sm:h-[30vh]
|
||||
`}
|
||||
>
|
||||
{Object.entries(getAllTargets()).map(([converter, targets]) => (
|
||||
<article
|
||||
class={`
|
||||
convert_to_group flex w-full flex-col border-b border-neutral-700 p-4
|
||||
`}
|
||||
data-converter={converter}
|
||||
>
|
||||
<header class="mb-2 w-full text-xl font-bold" safe>
|
||||
{converter}
|
||||
</header>
|
||||
<ul class={`convert_to_target flex flex-row flex-wrap gap-1`}>
|
||||
{targets.map((target) => (
|
||||
<button
|
||||
// https://stackoverflow.com/questions/121499/when-a-blur-event-occurs-how-can-i-find-out-which-element-focus-went-to#comment82388679_33325953
|
||||
tabindex={0}
|
||||
class={`
|
||||
target rounded-sm bg-neutral-700 p-1 text-base
|
||||
hover:bg-neutral-600
|
||||
`}
|
||||
data-value={`${target},${converter}`}
|
||||
data-target={target}
|
||||
data-converter={converter}
|
||||
type="button"
|
||||
safe
|
||||
>
|
||||
{target}
|
||||
</button>
|
||||
))}
|
||||
</ul>
|
||||
</article>
|
||||
))}
|
||||
</article>
|
||||
|
||||
{/* Hidden element which determines the format to convert the file too and the converter to use */}
|
||||
<select name="convert_to" aria-label="Convert to" required hidden>
|
||||
<option selected disabled value="">
|
||||
Convert to
|
||||
</option>
|
||||
{Object.entries(getAllTargets()).map(([converter, targets]) => (
|
||||
<optgroup label={converter}>
|
||||
{targets.map((target) => (
|
||||
<option value={`${target},${converter}`} safe>
|
||||
{target}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</article>
|
||||
<input
|
||||
class={`
|
||||
w-full btn-primary opacity-100
|
||||
disabled:cursor-not-allowed disabled:opacity-50
|
||||
`}
|
||||
type="submit"
|
||||
value="Convert"
|
||||
disabled
|
||||
/>
|
||||
</form>
|
||||
</main>
|
||||
<script src="script.js" defer />
|
||||
</>
|
||||
</BaseHtml>
|
||||
);
|
||||
},
|
||||
{
|
||||
cookie: t.Cookie({
|
||||
auth: t.Optional(t.String()),
|
||||
jobId: t.Optional(t.String()),
|
||||
}),
|
||||
},
|
||||
);
|
||||
42
src/pages/upload.tsx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { Elysia, t } from "elysia";
|
||||
import db from "../db/db";
|
||||
import { WEBROOT } from "../helpers/env";
|
||||
import { uploadsDir } from "../index";
|
||||
import { userService } from "./user";
|
||||
import sanitize from "sanitize-filename";
|
||||
|
||||
export const upload = new Elysia().use(userService).post(
|
||||
"/upload",
|
||||
async ({ body, redirect, user, cookie: { jobId } }) => {
|
||||
if (!jobId?.value) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
const existingJob = await db
|
||||
.query("SELECT * FROM jobs WHERE id = ? AND user_id = ?")
|
||||
.get(jobId.value, user.id);
|
||||
|
||||
if (!existingJob) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
const userUploadsDir = `${uploadsDir}${user.id}/${jobId.value}/`;
|
||||
|
||||
if (body?.file) {
|
||||
if (Array.isArray(body.file)) {
|
||||
for (const file of body.file) {
|
||||
const santizedFileName = sanitize(file.name);
|
||||
await Bun.write(`${userUploadsDir}${santizedFileName}`, file);
|
||||
}
|
||||
} else {
|
||||
const santizedFileName = sanitize(body.file["name"]);
|
||||
await Bun.write(`${userUploadsDir}${santizedFileName}`, body.file);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
message: "Files uploaded successfully.",
|
||||
};
|
||||
},
|
||||
{ body: t.Object({ file: t.Files() }), auth: true },
|
||||
);
|
||||
522
src/pages/user.tsx
Normal file
|
|
@ -0,0 +1,522 @@
|
|||
import { randomUUID } from "node:crypto";
|
||||
import { jwt } from "@elysiajs/jwt";
|
||||
import { Elysia, t } from "elysia";
|
||||
import { BaseHtml } from "../components/base";
|
||||
import { Header } from "../components/header";
|
||||
import db from "../db/db";
|
||||
import { User } from "../db/types";
|
||||
import {
|
||||
ACCOUNT_REGISTRATION,
|
||||
ALLOW_UNAUTHENTICATED,
|
||||
HIDE_HISTORY,
|
||||
HTTP_ALLOWED,
|
||||
WEBROOT,
|
||||
} from "../helpers/env";
|
||||
|
||||
export let FIRST_RUN = db.query("SELECT * FROM users").get() === null || false;
|
||||
|
||||
export const userService = new Elysia({ name: "user/service" })
|
||||
.use(
|
||||
jwt({
|
||||
name: "jwt",
|
||||
schema: t.Object({
|
||||
id: t.String(),
|
||||
}),
|
||||
secret: process.env.JWT_SECRET ?? randomUUID(),
|
||||
exp: "7d",
|
||||
}),
|
||||
)
|
||||
.model({
|
||||
signIn: t.Object({
|
||||
email: t.String(),
|
||||
password: t.String(),
|
||||
}),
|
||||
session: t.Cookie({
|
||||
auth: t.String(),
|
||||
jobId: t.Optional(t.String()),
|
||||
}),
|
||||
optionalSession: t.Cookie({
|
||||
auth: t.Optional(t.String()),
|
||||
jobId: t.Optional(t.String()),
|
||||
}),
|
||||
})
|
||||
.macro("auth", {
|
||||
cookie: "session",
|
||||
async resolve({ status, jwt, cookie: { auth } }) {
|
||||
if (!auth.value) {
|
||||
return status(401, {
|
||||
success: false,
|
||||
message: "Unauthorized",
|
||||
});
|
||||
}
|
||||
const user = await jwt.verify(auth.value);
|
||||
if (!user) {
|
||||
return status(401, {
|
||||
success: false,
|
||||
message: "Unauthorized",
|
||||
});
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
user,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export const user = new Elysia()
|
||||
.use(userService)
|
||||
.get("/setup", ({ redirect }) => {
|
||||
if (!FIRST_RUN) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseHtml title="ConvertX | Setup" webroot={WEBROOT}>
|
||||
<main
|
||||
class={`
|
||||
mx-auto w-full max-w-4xl flex-1 px-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<h1 class="my-8 text-3xl">Welcome to ConvertX!</h1>
|
||||
<article class="article p-0">
|
||||
<header class="w-full bg-neutral-800 p-4">Create your account</header>
|
||||
<form method="post" action={`${WEBROOT}/register`} class="p-4">
|
||||
<fieldset class="mb-4 flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1">
|
||||
Email
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Email"
|
||||
autocomplete="email"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
Password
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Password"
|
||||
autocomplete="current-password"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<input type="submit" value="Create account" class="btn-primary" />
|
||||
</form>
|
||||
<footer class="p-4">
|
||||
Report any issues on{" "}
|
||||
<a
|
||||
class={`
|
||||
text-accent-500 underline
|
||||
hover:text-accent-400
|
||||
`}
|
||||
href="https://github.com/C4illin/ConvertX"
|
||||
>
|
||||
GitHub
|
||||
</a>
|
||||
.
|
||||
</footer>
|
||||
</article>
|
||||
</main>
|
||||
</BaseHtml>
|
||||
);
|
||||
})
|
||||
.get("/register", ({ redirect }) => {
|
||||
if (!ACCOUNT_REGISTRATION) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseHtml webroot={WEBROOT} title="ConvertX | Register">
|
||||
<>
|
||||
<Header
|
||||
webroot={WEBROOT}
|
||||
accountRegistration={ACCOUNT_REGISTRATION}
|
||||
allowUnauthenticated={ALLOW_UNAUTHENTICATED}
|
||||
hideHistory={HIDE_HISTORY}
|
||||
/>
|
||||
<main
|
||||
class={`
|
||||
w-full flex-1 px-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<article class="article">
|
||||
<form method="post" class="flex flex-col gap-4">
|
||||
<fieldset class="mb-4 flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1">
|
||||
Email
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Email"
|
||||
autocomplete="email"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
Password
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Password"
|
||||
autocomplete="current-password"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<input type="submit" value="Register" class="w-full btn-primary" />
|
||||
</form>
|
||||
</article>
|
||||
</main>
|
||||
</>
|
||||
</BaseHtml>
|
||||
);
|
||||
})
|
||||
.post(
|
||||
"/register",
|
||||
async ({ body: { email, password }, set, redirect, jwt, cookie: { auth } }) => {
|
||||
if (!ACCOUNT_REGISTRATION && !FIRST_RUN) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
if (FIRST_RUN) {
|
||||
FIRST_RUN = false;
|
||||
}
|
||||
|
||||
const existingUser = await db.query("SELECT * FROM users WHERE email = ?").get(email);
|
||||
if (existingUser) {
|
||||
set.status = 400;
|
||||
return {
|
||||
message: "Email already in use.",
|
||||
};
|
||||
}
|
||||
const savedPassword = await Bun.password.hash(password);
|
||||
|
||||
db.query("INSERT INTO users (email, password) VALUES (?, ?)").run(email, savedPassword);
|
||||
|
||||
const user = db.query("SELECT * FROM users WHERE email = ?").as(User).get(email);
|
||||
|
||||
if (!user) {
|
||||
set.status = 500;
|
||||
return {
|
||||
message: "Failed to create user.",
|
||||
};
|
||||
}
|
||||
|
||||
const accessToken = await jwt.sign({
|
||||
id: String(user.id),
|
||||
});
|
||||
|
||||
if (!auth) {
|
||||
set.status = 500;
|
||||
return {
|
||||
message: "No auth cookie, perhaps your browser is blocking cookies.",
|
||||
};
|
||||
}
|
||||
|
||||
// set cookie
|
||||
auth.set({
|
||||
value: accessToken,
|
||||
httpOnly: true,
|
||||
secure: !HTTP_ALLOWED,
|
||||
maxAge: 60 * 60 * 24 * 7,
|
||||
sameSite: "strict",
|
||||
});
|
||||
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
},
|
||||
{ body: "signIn" },
|
||||
)
|
||||
.get(
|
||||
"/login",
|
||||
async ({ jwt, redirect, cookie: { auth } }) => {
|
||||
if (FIRST_RUN) {
|
||||
return redirect(`${WEBROOT}/setup`, 302);
|
||||
}
|
||||
|
||||
// if already logged in, redirect to home
|
||||
if (auth?.value) {
|
||||
const user = await jwt.verify(auth.value);
|
||||
|
||||
if (user) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
auth.remove();
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseHtml webroot={WEBROOT} title="ConvertX | Login">
|
||||
<>
|
||||
<Header
|
||||
webroot={WEBROOT}
|
||||
accountRegistration={ACCOUNT_REGISTRATION}
|
||||
allowUnauthenticated={ALLOW_UNAUTHENTICATED}
|
||||
hideHistory={HIDE_HISTORY}
|
||||
/>
|
||||
<main
|
||||
class={`
|
||||
w-full flex-1 px-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<article class="article">
|
||||
<form method="post" class="flex flex-col gap-4">
|
||||
<fieldset class="mb-4 flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1">
|
||||
Email
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Email"
|
||||
autocomplete="email"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
Password
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Password"
|
||||
autocomplete="current-password"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<div class="flex flex-row gap-4">
|
||||
{ACCOUNT_REGISTRATION ? (
|
||||
<a
|
||||
href={`${WEBROOT}/register`}
|
||||
role="button"
|
||||
class="w-full btn-secondary text-center"
|
||||
>
|
||||
Register
|
||||
</a>
|
||||
) : null}
|
||||
<input type="submit" value="Login" class="w-full btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</article>
|
||||
</main>
|
||||
</>
|
||||
</BaseHtml>
|
||||
);
|
||||
},
|
||||
{ body: "signIn", cookie: "optionalSession" },
|
||||
)
|
||||
.post(
|
||||
"/login",
|
||||
async function handler({ body, set, redirect, jwt, cookie: { auth } }) {
|
||||
const existingUser = db.query("SELECT * FROM users WHERE email = ?").as(User).get(body.email);
|
||||
|
||||
if (!existingUser) {
|
||||
set.status = 403;
|
||||
return {
|
||||
message: "Invalid credentials.",
|
||||
};
|
||||
}
|
||||
|
||||
const validPassword = await Bun.password.verify(body.password, existingUser.password);
|
||||
|
||||
if (!validPassword) {
|
||||
set.status = 403;
|
||||
return {
|
||||
message: "Invalid credentials.",
|
||||
};
|
||||
}
|
||||
|
||||
const accessToken = await jwt.sign({
|
||||
id: String(existingUser.id),
|
||||
});
|
||||
|
||||
if (!auth) {
|
||||
set.status = 500;
|
||||
return {
|
||||
message: "No auth cookie, perhaps your browser is blocking cookies.",
|
||||
};
|
||||
}
|
||||
|
||||
// set cookie
|
||||
auth.set({
|
||||
value: accessToken,
|
||||
httpOnly: true,
|
||||
secure: !HTTP_ALLOWED,
|
||||
maxAge: 60 * 60 * 24 * 7,
|
||||
sameSite: "strict",
|
||||
});
|
||||
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
},
|
||||
{ body: "signIn" },
|
||||
)
|
||||
.get("/logoff", ({ redirect, cookie: { auth } }) => {
|
||||
if (auth?.value) {
|
||||
auth.remove();
|
||||
}
|
||||
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
})
|
||||
.post("/logoff", ({ redirect, cookie: { auth } }) => {
|
||||
if (auth?.value) {
|
||||
auth.remove();
|
||||
}
|
||||
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
})
|
||||
.get(
|
||||
"/account",
|
||||
async ({ user, redirect }) => {
|
||||
if (!user) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
const userData = db.query("SELECT * FROM users WHERE id = ?").as(User).get(user.id);
|
||||
|
||||
if (!userData) {
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseHtml webroot={WEBROOT} title="ConvertX | Account">
|
||||
<>
|
||||
<Header
|
||||
webroot={WEBROOT}
|
||||
accountRegistration={ACCOUNT_REGISTRATION}
|
||||
allowUnauthenticated={ALLOW_UNAUTHENTICATED}
|
||||
hideHistory={HIDE_HISTORY}
|
||||
loggedIn
|
||||
/>
|
||||
<main
|
||||
class={`
|
||||
w-full flex-1 px-2
|
||||
sm:px-4
|
||||
`}
|
||||
>
|
||||
<article class="article">
|
||||
<form method="post" class="flex flex-col gap-4">
|
||||
<fieldset class="mb-4 flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1">
|
||||
Email
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Email"
|
||||
autocomplete="email"
|
||||
value={userData.email}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
Password (leave blank for unchanged)
|
||||
<input
|
||||
type="password"
|
||||
name="newPassword"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Password"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
Current Password
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="rounded-sm bg-neutral-800 p-3"
|
||||
placeholder="Password"
|
||||
autocomplete="current-password"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<div role="group">
|
||||
<input type="submit" value="Update" class="w-full btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</article>
|
||||
</main>
|
||||
</>
|
||||
</BaseHtml>
|
||||
);
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
},
|
||||
)
|
||||
.post(
|
||||
"/account",
|
||||
async function handler({ body, set, redirect, jwt, cookie: { auth } }) {
|
||||
if (!auth?.value) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
const user = await jwt.verify(auth.value);
|
||||
if (!user) {
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
const existingUser = db.query("SELECT * FROM users WHERE id = ?").as(User).get(user.id);
|
||||
|
||||
if (!existingUser) {
|
||||
if (auth?.value) {
|
||||
auth.remove();
|
||||
}
|
||||
return redirect(`${WEBROOT}/login`, 302);
|
||||
}
|
||||
|
||||
const validPassword = await Bun.password.verify(body.password, existingUser.password);
|
||||
|
||||
if (!validPassword) {
|
||||
set.status = 403;
|
||||
return {
|
||||
message: "Invalid credentials.",
|
||||
};
|
||||
}
|
||||
|
||||
const fields = [];
|
||||
const values = [];
|
||||
|
||||
if (body.email) {
|
||||
const existingUser = await db
|
||||
.query("SELECT id FROM users WHERE email = ?")
|
||||
.as(User)
|
||||
.get(body.email);
|
||||
if (existingUser && existingUser.id.toString() !== user.id) {
|
||||
set.status = 409;
|
||||
return { message: "Email already in use." };
|
||||
}
|
||||
fields.push("email");
|
||||
values.push(body.email);
|
||||
}
|
||||
if (body.newPassword) {
|
||||
fields.push("password");
|
||||
values.push(await Bun.password.hash(body.newPassword));
|
||||
}
|
||||
|
||||
if (fields.length > 0) {
|
||||
db.query(
|
||||
`UPDATE users SET ${fields.map((field) => `${field}=?`).join(", ")} WHERE id=?`,
|
||||
).run(...values, user.id);
|
||||
}
|
||||
|
||||
return redirect(`${WEBROOT}/`, 302);
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
email: t.MaybeEmpty(t.String()),
|
||||
newPassword: t.MaybeEmpty(t.String()),
|
||||
password: t.String(),
|
||||
}),
|
||||
cookie: "session",
|
||||
},
|
||||
);
|
||||
47
src/theme/theme.css
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
:root {
|
||||
/* Light mode */
|
||||
--contrast: oklch(100% 0 0);
|
||||
/* Neutral colors - Gray */
|
||||
--neutral-950: oklch(98.5% 0.002 247.839);
|
||||
--neutral-900: oklch(96.7% 0.003 264.542);
|
||||
--neutral-800: oklch(92.8% 0.006 264.531);
|
||||
--neutral-700: oklch(87.2% 0.01 258.338);
|
||||
--neutral-600: oklch(70.7% 0.022 261.325);
|
||||
--neutral-500: oklch(55.1% 0.027 264.364);
|
||||
--neutral-400: oklch(44.6% 0.03 256.802);
|
||||
--neutral-300: oklch(37.3% 0.034 259.733);
|
||||
--neutral-200: oklch(26.9% 0 0);
|
||||
--neutral-100: oklch(21% 0.034 264.665);
|
||||
--neutral-50: oklch(13% 0.028 261.692);
|
||||
/* lime-700 */
|
||||
--accent-600: oklch(53.2% 0.157 131.589);
|
||||
/* lime-600 */
|
||||
--accent-500: oklch(64.8% 0.2 131.684);
|
||||
/* lime-500 */
|
||||
--accent-400: oklch(76.8% 0.233 130.85);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
/* Dark mode */
|
||||
:root {
|
||||
--contrast: oklch(0% 0 0);
|
||||
/* Neutral colors - Gray */
|
||||
--neutral-950: oklch(13% 0.028 261.692);
|
||||
--neutral-900: oklch(21% 0.034 264.665);
|
||||
--neutral-800: oklch(27.8% 0.033 256.848);
|
||||
--neutral-700: oklch(37.3% 0.034 259.733);
|
||||
--neutral-600: oklch(44.6% 0.03 256.802);
|
||||
--neutral-500: oklch(55.1% 0.027 264.364);
|
||||
--neutral-400: oklch(70.7% 0.022 261.325);
|
||||
--neutral-300: oklch(87.2% 0.01 258.338);
|
||||
--neutral-200: oklch(92.8% 0.006 264.531);
|
||||
--neutral-100: oklch(96.7% 0.003 264.542);
|
||||
--neutral-50: oklch(98.5% 0.002 247.839);
|
||||
/* lime-600 */
|
||||
--accent-600: oklch(64.8% 0.2 131.684);
|
||||
/* lime-500 */
|
||||
--accent-500: oklch(76.8% 0.233 130.85);
|
||||
/* lime-400 */
|
||||
--accent-400: oklch(84.1% 0.238 128.85);
|
||||
}
|
||||
}
|
||||
7
tests/converters/assimp.test.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { test } from "bun:test";
|
||||
import { convert } from "../../src/converters/assimp";
|
||||
import { runCommonTests } from "./helpers/commonTests";
|
||||
|
||||
runCommonTests(convert);
|
||||
|
||||
test.skip("dummy - required to trigger test detection", () => {});
|
||||
7
tests/converters/calibre.test.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { test } from "bun:test";
|
||||
import { convert } from "../../src/converters/calibre";
|
||||
import { runCommonTests } from "./helpers/commonTests";
|
||||
|
||||
runCommonTests(convert);
|
||||
|
||||
test.skip("dummy - required to trigger test detection", () => {});
|
||||
72
tests/converters/dasel.test.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import fs from "fs";
|
||||
import { beforeEach, afterEach, expect, test, describe } from "bun:test";
|
||||
import { convert } from "../../src/converters/dasel";
|
||||
import type { ExecFileFn } from "../../src/converters/types";
|
||||
|
||||
const originalWriteFile = fs.writeFile;
|
||||
|
||||
describe("convert", () => {
|
||||
let mockExecFile: ExecFileFn;
|
||||
|
||||
beforeEach(() => {
|
||||
// mock fs.writeFile
|
||||
// @ts-expect-error: property __promisify__ is missing
|
||||
fs.writeFile = (path, data, cb) => cb(null);
|
||||
// mock execFile
|
||||
mockExecFile = (cmd, args, callback) => callback(null, "output-data", "");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// reset fs.writeFile
|
||||
fs.writeFile = originalWriteFile;
|
||||
});
|
||||
|
||||
test("should call dasel with correct arguments and write output", async () => {
|
||||
let calledArgs: Parameters<ExecFileFn> = ["", [], () => {}];
|
||||
mockExecFile = (cmd, args, callback) => {
|
||||
calledArgs = [cmd, args, callback];
|
||||
callback(null, "output-data", "");
|
||||
};
|
||||
|
||||
let writeFileCalled = false;
|
||||
// @ts-expect-error: property __promisify__ is missing
|
||||
fs.writeFile = (path, data, cb) => {
|
||||
writeFileCalled = true;
|
||||
expect(path).toBe("output.json");
|
||||
expect(data).toBe("output-data");
|
||||
// @ts-expect-error: could not be callable with null
|
||||
cb(null);
|
||||
};
|
||||
|
||||
const result = await convert(
|
||||
"input.yaml",
|
||||
"yaml",
|
||||
"json",
|
||||
"output.json",
|
||||
undefined,
|
||||
mockExecFile,
|
||||
);
|
||||
|
||||
expect(calledArgs[0]).toBe("dasel");
|
||||
expect(calledArgs[1]).toEqual(["--file", "input.yaml", "--read", "yaml", "--write", "json"]);
|
||||
expect(writeFileCalled).toBe(true);
|
||||
expect(result).toBe("Done");
|
||||
});
|
||||
|
||||
test("should reject if execFile returns an error", async () => {
|
||||
mockExecFile = (cmd, args, callback) => callback(new Error("fail"), "", "");
|
||||
await expect(
|
||||
convert("input.yaml", "yaml", "json", "output.json", undefined, mockExecFile),
|
||||
).rejects.toMatch(/error: Error: fail/);
|
||||
});
|
||||
|
||||
test("should reject if writeFile fails", async () => {
|
||||
// @ts-expect-error: property __promisify__ is missing
|
||||
fs.writeFile = (path, data, cb) => cb(new Error("write fail"));
|
||||
await expect(
|
||||
convert("input.yaml", "yaml", "json", "output.json", undefined, (cmd, args, cb) =>
|
||||
cb(null, "output-data", ""),
|
||||
),
|
||||
).rejects.toMatch(/Failed to write output/);
|
||||
});
|
||||
});
|
||||
91
tests/converters/dvisvgm.test.ts
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
import type { ExecFileException } from "node:child_process";
|
||||
import { beforeEach, expect, test } from "bun:test";
|
||||
import { convert } from "../../src/converters/dvisvgm";
|
||||
import { ExecFileFn } from "../../src/converters/types";
|
||||
import { runCommonTests } from "./helpers/commonTests";
|
||||
|
||||
let calls: string[][] = [];
|
||||
|
||||
beforeEach(() => {
|
||||
calls = [];
|
||||
});
|
||||
|
||||
runCommonTests(convert);
|
||||
|
||||
test("convert respects eps filetype", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
calls.push(_args);
|
||||
callback(null, "Fake stdout", "");
|
||||
};
|
||||
|
||||
const result = await convert("input.eps", "eps", "stl", "output.stl", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(calls[0]).toEqual(expect.arrayContaining(["--eps", "input.eps", "output.stl"]));
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("convert respects pdf filetype", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
calls.push(_args);
|
||||
callback(null, "Fake stdout", "");
|
||||
};
|
||||
|
||||
const result = await convert("input.pdf", "pdf", "stl", "output.stl", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(calls[0]).toEqual(expect.arrayContaining(["--pdf", "input.pdf", "output.stl"]));
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("convert respects svgz conversion target type", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
calls.push(_args);
|
||||
callback(null, "Fake stdout", "");
|
||||
};
|
||||
|
||||
const result = await convert("input.obj", "eps", "svgz", "output.svgz", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(calls[0]).toEqual(expect.arrayContaining(["-z", "input.obj", "output.svgz"]));
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
181
tests/converters/ffmpeg.test.ts
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
import { beforeEach, expect, test } from "bun:test";
|
||||
import { convert } from "../../src/converters/ffmpeg";
|
||||
|
||||
let calls: string[][] = [];
|
||||
|
||||
function mockExecFile(
|
||||
_cmd: string,
|
||||
args: string[],
|
||||
callback: (err: Error | null, stdout: string, stderr: string) => void,
|
||||
) {
|
||||
calls.push(args);
|
||||
if (args.includes("fail.mov")) {
|
||||
callback(new Error("mock failure"), "", "Fake stderr: fail");
|
||||
} else {
|
||||
callback(null, "Fake stdout", "");
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
calls = [];
|
||||
delete process.env.FFMPEG_ARGS;
|
||||
});
|
||||
|
||||
test("converts a normal file", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const result = await convert("in.mp4", "mp4", "avi", "out.avi", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(calls[0]).toEqual(expect.arrayContaining(["-i", "in.mp4", "out.avi"]));
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("adds resize for ico output", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const result = await convert("in.png", "png", "ico", "out.ico", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done: resized to 256x256");
|
||||
expect(calls[0]).toEqual(
|
||||
expect.arrayContaining(["-filter:v", expect.stringContaining("scale=")]),
|
||||
);
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("uses libaom-av1 for av1.mp4", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
await convert("in.mkv", "mkv", "av1.mp4", "out.mp4", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(calls[0]).toEqual(expect.arrayContaining(["-c:v", "libaom-av1"]));
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("uses libx264 for h264.mp4", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
await convert("in.mkv", "mkv", "h264.mp4", "out.mp4", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(calls[0]).toEqual(expect.arrayContaining(["-c:v", "libx264"]));
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("uses libx265 for h265.mp4", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
await convert("in.mkv", "mkv", "h265.mp4", "out.mp4", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(calls[0]).toEqual(expect.arrayContaining(["-c:v", "libx265"]));
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("uses libx266 for h266.mp4", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
await convert("in.mkv", "mkv", "h266.mp4", "out.mp4", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(calls[0]).toEqual(expect.arrayContaining(["-c:v", "libx266"]));
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("respects FFMPEG_ARGS", async () => {
|
||||
process.env.FFMPEG_ARGS = "-hide_banner -y";
|
||||
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
await convert("input.mov", "mov", "mp4", "output.mp4", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(calls[0]?.slice(0, 2)).toEqual(["-hide_banner", "-y"]);
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("fails on exec error", async () => {
|
||||
const originalConsoleError = console.error;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.error = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
expect(convert("fail.mov", "mov", "mp4", "output.mp4", undefined, mockExecFile)).rejects.toThrow(
|
||||
"mock failure",
|
||||
);
|
||||
|
||||
console.error = originalConsoleError;
|
||||
|
||||
expect(loggedMessage).toBe("stderr: Fake stderr: fail");
|
||||
});
|
||||
|
||||
test("logs stderr when execFile returns only stderr and no error", async () => {
|
||||
const originalConsoleError = console.error;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.error = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
// Mock execFile to call back with no error, no stdout, but with stderr
|
||||
const mockExecFileStderrOnly = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: Error | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
callback(null, "", "Only stderr output");
|
||||
};
|
||||
|
||||
await convert("input.mov", "mov", "mp4", "output.mp4", undefined, mockExecFileStderrOnly);
|
||||
|
||||
console.error = originalConsoleError;
|
||||
|
||||
expect(loggedMessage).toBe("stderr: Only stderr output");
|
||||
});
|
||||
7
tests/converters/graphicsmagick.test.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { test } from "bun:test";
|
||||
import { convert } from "../../src/converters/graphicsmagick";
|
||||
import { runCommonTests } from "./helpers/commonTests";
|
||||
|
||||
runCommonTests(convert);
|
||||
|
||||
test.skip("dummy - required to trigger test detection", () => {});
|
||||
26
tests/converters/helpers/commonTests.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { test } from "bun:test";
|
||||
import { ConvertFnWithExecFile } from "../../../src/converters/types";
|
||||
import {
|
||||
runConvertFailTest,
|
||||
runConvertLogsStderror,
|
||||
runConvertLogsStderrorAndStdout,
|
||||
runConvertSuccessTest,
|
||||
} from "./converters";
|
||||
|
||||
export function runCommonTests(convert: ConvertFnWithExecFile) {
|
||||
test("convert resolves when execFile succeeds", async () => {
|
||||
await runConvertSuccessTest(convert);
|
||||
});
|
||||
|
||||
test("convert rejects when execFile fails", async () => {
|
||||
await runConvertFailTest(convert);
|
||||
});
|
||||
|
||||
test("convert logs stderr when present", async () => {
|
||||
await runConvertLogsStderror(convert);
|
||||
});
|
||||
|
||||
test("convert logs both stderr and stdout when present", async () => {
|
||||
await runConvertLogsStderrorAndStdout(convert);
|
||||
});
|
||||
}
|
||||
121
tests/converters/helpers/converters.ts
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
import { expect } from "bun:test";
|
||||
import type { ExecFileException } from "node:child_process";
|
||||
import { ConvertFnWithExecFile, ExecFileFn } from "../../../src/converters/types";
|
||||
|
||||
export async function runConvertSuccessTest(convertFn: ConvertFnWithExecFile) {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
callback(null, "Fake stdout", "");
|
||||
};
|
||||
|
||||
const result = await convertFn("input.obj", "obj", "stl", "output.stl", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
}
|
||||
|
||||
export async function runConvertFailTest(convertFn: ConvertFnWithExecFile) {
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
callback(new Error("Test error"), "", "");
|
||||
};
|
||||
|
||||
expect(
|
||||
convertFn("input.obj", "obj", "stl", "output.stl", undefined, mockExecFile),
|
||||
).rejects.toMatch(/error: Error: Test error/);
|
||||
|
||||
// Test with error object lacking 'message' property
|
||||
const mockExecFileNoMessage: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
// Simulate a non-standard error object
|
||||
callback({ notMessage: true } as unknown as ExecFileException, "", "");
|
||||
};
|
||||
|
||||
expect(
|
||||
convertFn("input.obj", "obj", "stl", "output.stl", undefined, mockExecFileNoMessage),
|
||||
).rejects.toMatch(/error:/i);
|
||||
|
||||
// Test with a non-object error (e.g., a string)
|
||||
const mockExecFileStringError: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
callback("string error" as unknown as ExecFileException, "", "");
|
||||
};
|
||||
|
||||
expect(
|
||||
convertFn("input.obj", "obj", "stl", "output.stl", undefined, mockExecFileStringError),
|
||||
).rejects.toMatch(/error:/i);
|
||||
}
|
||||
|
||||
export async function runConvertLogsStderror(convertFn: ConvertFnWithExecFile) {
|
||||
const originalConsoleError = console.error;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.error = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: Error | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
callback(null, "", "Fake stderr");
|
||||
};
|
||||
|
||||
await convertFn("file.obj", "obj", "stl", "out.stl", undefined, mockExecFile);
|
||||
|
||||
console.error = originalConsoleError;
|
||||
|
||||
expect(loggedMessage).toBe("stderr: Fake stderr");
|
||||
}
|
||||
|
||||
export async function runConvertLogsStderrorAndStdout(convertFn: ConvertFnWithExecFile) {
|
||||
const originalConsoleError = console.error;
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedError = "";
|
||||
let loggedMessage = "";
|
||||
console.error = (msg) => {
|
||||
loggedError = msg;
|
||||
};
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: Error | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
callback(null, "Fake stdout", "Fake stderr");
|
||||
};
|
||||
|
||||
await convertFn("file.obj", "obj", "stl", "out.stl", undefined, mockExecFile);
|
||||
|
||||
console.error = originalConsoleError;
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(loggedError).toBe("stderr: Fake stderr");
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
}
|
||||
165
tests/converters/imagemagick.test.ts
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
import { beforeEach, expect, test } from "bun:test";
|
||||
import type { ExecFileException } from "node:child_process";
|
||||
import { convert } from "../../src/converters/imagemagick";
|
||||
import { ExecFileFn } from "../../src/converters/types";
|
||||
import { runCommonTests } from "./helpers/commonTests";
|
||||
|
||||
let calls: string[][] = [];
|
||||
|
||||
beforeEach(() => {
|
||||
calls = [];
|
||||
});
|
||||
|
||||
runCommonTests(convert);
|
||||
|
||||
test("convert respects ico conversion target type", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
calls.push(_args);
|
||||
callback(null, "Fake stdout", "");
|
||||
};
|
||||
|
||||
const result = await convert("input.obj", "eps", "ico", "output.ico", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(calls[0]).toEqual(
|
||||
expect.arrayContaining([
|
||||
"-define",
|
||||
"icon:auto-resize=256,128,64,48,32,16",
|
||||
"-background",
|
||||
"none",
|
||||
"input.obj",
|
||||
"output.ico",
|
||||
]),
|
||||
);
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("convert respects ico conversion target type with svg as input filetype", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
calls.push(_args);
|
||||
callback(null, "Fake stdout", "");
|
||||
};
|
||||
|
||||
const result = await convert("input.svg", "svg", "ico", "output.ico", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(calls[0]).toEqual(
|
||||
expect.arrayContaining([
|
||||
"-define",
|
||||
"icon:auto-resize=256,128,64,48,32,16",
|
||||
"-background",
|
||||
"none",
|
||||
"-density",
|
||||
"512",
|
||||
"input.svg",
|
||||
"output.ico",
|
||||
]),
|
||||
);
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("convert respects ico conversion target type with emf as input filetype", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
calls.push(_args);
|
||||
callback(null, "Fake stdout", "");
|
||||
};
|
||||
|
||||
const result = await convert("input.emf", "emf", "ico", "output.ico", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(calls[0]).toEqual(
|
||||
expect.arrayContaining([
|
||||
"-define",
|
||||
"icon:auto-resize=256,128,64,48,32,16",
|
||||
"-background",
|
||||
"none",
|
||||
"emf:delegate=false",
|
||||
"-density",
|
||||
"300",
|
||||
"white",
|
||||
"-alpha",
|
||||
"remove",
|
||||
"input.emf",
|
||||
"output.ico",
|
||||
]),
|
||||
);
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||
|
||||
test("convert respects emf as input filetype", async () => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
let loggedMessage = "";
|
||||
console.log = (msg) => {
|
||||
loggedMessage = msg;
|
||||
};
|
||||
|
||||
const mockExecFile: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
calls.push(_args);
|
||||
callback(null, "Fake stdout", "");
|
||||
};
|
||||
|
||||
const result = await convert("input.emf", "emf", "obj", "output.obj", undefined, mockExecFile);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
|
||||
expect(result).toBe("Done");
|
||||
expect(calls[0]).toEqual(
|
||||
expect.arrayContaining([
|
||||
"-define",
|
||||
"emf:delegate=false",
|
||||
"-density",
|
||||
"300",
|
||||
"-background",
|
||||
"white",
|
||||
"-alpha",
|
||||
"remove",
|
||||
"input.emf",
|
||||
"output.obj",
|
||||
]),
|
||||
);
|
||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||
});
|
||||